:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #1c2230;
  --muted: #5d6677;
  --line: #e2e6ec;
  --accent: #2f6fed;
  --accent-soft: #e8f0fe;
  --good: #128a52;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12151b;
    --card: #1b2029;
    --text: #e8ebf1;
    --muted: #9aa3b4;
    --line: #2c3340;
    --accent: #6c9cff;
    --accent-soft: #1f2a40;
    --good: #3fcf8e;
  }
}
:root[data-theme="dark"] {
  --bg: #12151b;
  --card: #1b2029;
  --text: #e8ebf1;
  --muted: #9aa3b4;
  --line: #2c3340;
  --accent: #6c9cff;
  --accent-soft: #1f2a40;
  --good: #3fcf8e;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  line-height: 1.6;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }

header.site {
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
header.site .wrap {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; min-height: 56px; flex-wrap: wrap;
}
.logo { font-weight: 800; font-size: 1.15rem; color: var(--text); }
.logo span { color: var(--accent); }
nav.top { display: flex; gap: 14px; flex-wrap: wrap; font-size: .95rem; }
nav.top a { color: var(--muted); }
nav.top a.on { color: var(--accent); font-weight: 700; }

main { padding: 24px 0 40px; }
h1 { font-size: 1.6rem; margin: 0 0 6px; line-height: 1.3; }
.lead { color: var(--muted); margin: 0 0 20px; }
h2 { font-size: 1.2rem; margin: 32px 0 10px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

label { display: block; font-weight: 600; margin-bottom: 6px; font-size: .95rem; }
input[type="date"], input[type="number"], textarea, select {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}
textarea { min-height: 220px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .row { grid-template-columns: 1fr; } }

.btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
button {
  font: inherit; cursor: pointer;
  border: 1px solid var(--line);
  background: var(--card); color: var(--text);
  border-radius: 10px; padding: 8px 14px;
}
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
button:hover { filter: brightness(.97); }

.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px;
}
.stat {
  background: var(--accent-soft);
  border-radius: 12px; padding: 12px 14px;
}
.stat .k { font-size: .85rem; color: var(--muted); }
.stat .v { font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: .9rem; font-weight: 600; color: var(--muted); margin-left: 2px; }

.big {
  font-size: 2.2rem; font-weight: 800; color: var(--accent);
  font-variant-numeric: tabular-nums; margin: 4px 0;
}
.note { font-size: .88rem; color: var(--muted); }
.hide { display: none; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs button.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.tool-list { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.tool-list a.card { display: block; color: var(--text); margin: 0; }
.tool-list a.card:hover { border-color: var(--accent); text-decoration: none; }
.tool-list .t { font-weight: 800; font-size: 1.05rem; }
.tool-list .d { color: var(--muted); font-size: .92rem; }

@media (max-width: 520px) {
  .tool-list { grid-template-columns: 1fr 1fr; gap: 8px; }
  .tool-list a.card { padding: 12px; border-radius: 12px; }
  .tool-list a.card:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .tool-list .t { font-size: .95rem; line-height: 1.35; }
  .tool-list .d { font-size: .8rem; line-height: 1.45; margin-top: 2px; }
  .card { padding: 16px; }
  h1 { font-size: 1.4rem; }
}

.faq h3 { font-size: 1rem; margin: 18px 0 4px; }
.faq p { margin: 0; color: var(--muted); }

/* 날짜 입력 보조 UI (assets/date-ui.js) */
.dui-row {
  position: relative;
  display: grid;
  grid-template-columns: 44px 1.25fr 1fr 1fr 44px auto;
  grid-template-areas: "prev y m d next cal";
  gap: 6px;
}
.dui-row.nostep { grid-template-columns: 1.25fr 1fr 1fr auto; grid-template-areas: "y m d cal"; }
.dui-y { grid-area: y; } .dui-m { grid-area: m; } .dui-d { grid-area: d; }
.dui-cal { grid-area: cal; }
.dui-prev { grid-area: prev; }
.dui-next { grid-area: next; }
.dui select { padding: 10px 8px; min-height: 46px; font-size: 1rem; }
.dui-step, .dui-cal { min-height: 46px; padding: 0 10px; font-weight: 700; }
.dui-step { font-size: .9rem; color: var(--accent); }
.dui input.dui-native {
  position: absolute; left: 50%; bottom: 0; min-width: 0;
  width: 1px; height: 1px; opacity: 0; pointer-events: none; border: 0; padding: 0;
}
.dui-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  border-radius: 999px; padding: 7px 14px; font-size: .92rem;
  background: var(--accent-soft); border-color: transparent; color: var(--text);
}
.chip:active, .chip.on { background: var(--accent); color: #fff; }
@media (max-width: 520px) {
  .dui-row { grid-template-columns: 1.3fr 1fr 1fr; grid-template-areas: "y m d" "prev cal next"; }
  .dui-row.nostep { grid-template-columns: 1.3fr 1fr 1fr; grid-template-areas: "y m d" "cal cal cal"; }
}
.field + .field { margin-top: 18px; }

/* 한 줄 계산식 (퍼센트 계산기 등) */
input[type="text"] {
  width: 100%; font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
}
.calc-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 1.05rem; }
.calc-line input { flex: 1 1 90px; width: auto; min-width: 0; max-width: 160px; text-align: right; }
.calc-line select { flex: 0 0 auto; }
.calc-res {
  margin-top: 12px; padding: 12px 14px; border-radius: 10px;
  background: var(--accent-soft); font-size: 1.05rem;
}
.calc-res strong { font-size: 1.35rem; color: var(--accent); font-variant-numeric: tabular-nums; }
.card h3 { margin: 0 0 12px; font-size: 1.05rem; }

table.simple { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.simple th, table.simple td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: right; }
table.simple th:first-child, table.simple td:first-child { text-align: left; }
table.simple th { color: var(--muted); font-weight: 600; font-size: .9rem; }

.progress { height: 14px; background: var(--line); border-radius: 999px; overflow: hidden; margin: 8px 0; }
.progress > div { height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s; }

#more-tools .tool-list { margin-top: 8px; }

/* 안내 문서 (소개, 개인정보처리방침, 문의) */
.doc h2 { font-size: 1.1rem; margin: 28px 0 8px; }
.doc ul { padding-left: 1.3em; }
.doc li { margin: 4px 0; }
footer.site nav { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 6px; }

/* 내 D-day 목록 */
.save-row { display: flex; gap: 8px; margin-top: 16px; }
.save-row input { flex: 1; min-width: 0; }
.save-row button { flex: none; }
.dd-title { font-weight: 700; margin: 18px 0 8px; }
.dd-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.dd-list li {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 4px 6px 4px 4px;
}
.dd-open {
  flex: 1; min-width: 0; text-align: left; border: 0; background: transparent;
  display: flex; flex-direction: column; padding: 6px 8px;
}
.dd-open b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-tag { font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; white-space: nowrap; }
.dd-tag.past { color: var(--muted); }
.dd-del { border: 0; background: transparent; color: var(--muted); padding: 8px 10px; }

/* 항목 추가형 입력 (assets/list-input.js) */
.li-add { display: flex; gap: 8px; }
.li-add input { flex: 1; min-width: 0; min-height: 46px; }
.li-add button { flex: none; min-width: 64px; }
.li-chips { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.li-chips:empty { display: none; }
.li-chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  background: var(--accent-soft); border-radius: 999px; padding: 4px 4px 4px 6px;
}
.li-num {
  min-width: 22px; height: 22px; border-radius: 999px; background: var(--accent); color: #fff;
  font-size: .75rem; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; padding: 0 5px;
}
.li-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li-x {
  border: 0; background: transparent; color: var(--muted);
  width: 30px; height: 30px; padding: 0; border-radius: 999px; font-size: .85rem;
}
.li-x:hover { background: var(--card); color: var(--text); }
.li-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.li-msg { color: #d64545; }
.li-clear { margin-left: auto; border: 0; background: transparent; color: var(--muted); font-size: .85rem; padding: 4px 6px; text-decoration: underline; }
.li-clear.armed { background: #d64545; color: #fff; text-decoration: none; border-radius: 8px; padding: 6px 10px; font-weight: 700; }

/* 화면 모드 버튼 */
.theme-btn {
  font-size: .85rem; padding: 5px 10px; border-radius: 999px;
  background: transparent; color: var(--muted);
}
header.site nav.top { align-items: center; }

/* 광고 자리: 애드센스 승인 후 이 자리에 광고 코드를 넣습니다 */
.ad-slot { margin: 20px 0; min-height: 0; }

footer.site {
  border-top: 1px solid var(--line);
  color: var(--muted); font-size: .85rem;
  padding: 20px 0 32px;
}
footer.site a { color: var(--muted); }
