/* 공통: 색 토큰(라이트/다크), 글꼴, 상단 메뉴, 카드, 버튼, 입력 */

:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #f1efe9;
  --ink: #1c2320;
  --muted: #6f7773;
  --line: #e6e2d9;
  --accent: #2d6a55;       /* 통독 */
  --accent-ink: #ffffff;
  --accent-soft: #e2efe9;
  --qt: #c1832a;           /* QT */
  --qt-soft: #f8ecd9;
  --warn: #b5532f;
  --warn-soft: #f8e6dd;
  --shadow: 0 1px 2px rgb(20 30 25 / .04), 0 4px 16px rgb(20 30 25 / .05);
  --radius: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121614; --surface: #1a1f1d; --surface-2: #222826; --ink: #e9ece9; --muted: #98a19c; --line: #2c3330;
    --accent: #7cc4a6; --accent-ink: #0d1a14; --accent-soft: #203129; --qt: #e3a94f; --qt-soft: #3a2d1a;
    --warn: #e58b66; --warn-soft: #3a2821; --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121614; --surface: #1a1f1d; --surface-2: #222826; --ink: #e9ece9; --muted: #98a19c; --line: #2c3330;
  --accent: #7cc4a6; --accent-ink: #0d1a14; --accent-soft: #203129; --qt: #e3a94f; --qt-soft: #3a2d1a;
  --warn: #e58b66; --warn-soft: #3a2821; --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, system-ui, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  letter-spacing: -0.01em;
  word-break: keep-all;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
h1, h2, h3 { margin: 0 0 8px; line-height: 1.3; letter-spacing: -0.025em; }
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.1rem; font-weight: 700; }
h3 { font-size: .98rem; font-weight: 650; }
p { margin: 0 0 6px; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.center { text-align: center; }
.warn-text { color: var(--warn); }
[hidden] { display: none !important; }
button { font: inherit; letter-spacing: inherit; }
button svg, a svg, .step-pill svg, .t-st svg, .qt-today svg {
  width: 1.1em; height: 1.1em; fill: none; stroke: currentColor; stroke-width: 2.4;
  stroke-linecap: round; stroke-linejoin: round; flex: none;
}

/* ---------- 상단 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; font-weight: 700; letter-spacing: -0.03em; }
.brand img { border-radius: 8px; box-shadow: 0 0 0 1px var(--line); }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.reload-btn {
  flex: none; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--surface); color: var(--muted); font-size: 1.05rem; line-height: 1; cursor: pointer; padding: 0;
}
.reload-btn:active { transform: scale(.94); }
.reload-btn.spin { animation: reload-spin 0.9s linear infinite; opacity: .6; }
@keyframes reload-spin { to { transform: rotate(360deg); } }
.tabs { display: flex; gap: 2px; background: var(--surface-2); padding: 3px; border-radius: 12px; }
.tabs a {
  padding: 6px 16px; border-radius: 9px; text-decoration: none; color: var(--muted);
  font-weight: 600; font-size: .92rem; white-space: nowrap;
}
.tabs a.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgb(0 0 0 / .1); }

main { max-width: 880px; margin: 0 auto; padding: 18px 16px; display: grid; gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-width: 0; box-shadow: var(--shadow); }
.footer { max-width: 880px; margin: 0 auto; padding: 4px 16px 32px; color: var(--muted); font-size: .78rem; text-align: center; }

/* ---------- 버튼 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: 12px; padding: 10px 18px;
  font-weight: 650; cursor: pointer; text-decoration: none; white-space: nowrap; color: var(--ink);
  transition: transform .08s, background .15s;
}
.btn:active { transform: scale(.98); }
.btn.small { padding: 7px 12px; font-size: .86rem; border-radius: 10px; }
.btn.big { padding: 12px 18px; font-size: 1rem; width: 100%; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.soft { background: var(--accent-soft); color: var(--accent); }
.btn.ghost { background: var(--surface); border-color: var(--line); }
.btn.danger { background: transparent; color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.btn.text { background: transparent; color: var(--muted); padding: 10px 8px; width: auto; }
.btn:disabled { opacity: .4; cursor: default; }
.icon-btn {
  width: 38px; height: 38px; flex: none; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font-size: 1.35rem; line-height: 1; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:disabled { opacity: .3; cursor: default; }
.chip-btn {
  flex: none; height: 38px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font-weight: 600; font-size: .88rem; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none; white-space: nowrap; position: relative;
}
.chip-btn.tall { height: 46px; }
.chip-btn svg { color: var(--muted); }
.seg { display: inline-flex; background: var(--surface-2); padding: 3px; border-radius: 12px; gap: 2px; }
.seg button { border: 0; background: transparent; color: var(--muted); padding: 7px 14px; border-radius: 9px; font-weight: 600; cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgb(0 0 0 / .1); }
.seg.wide { display: flex; }
.seg.wide button { flex: 1; }
/* 슬라이드 막대: 한 가지만 고르는 묶음에서 .on 자리를 막대가 밀려 가며 보여 줌 (js/shared/slide.js) */
.seg, .opts { position: relative; }
.slide-thumb { position: absolute; left: 0; top: 0; z-index: 0; pointer-events: none; border-radius: 9px; background: var(--surface); box-shadow: 0 1px 3px rgb(0 0 0 / .1); transition: transform .32s cubic-bezier(.2, .8, .2, 1), width .32s cubic-bezier(.2, .8, .2, 1), height .32s cubic-bezier(.2, .8, .2, 1); }
.opts > .slide-thumb { border-radius: 12px; background: var(--accent-soft); border: 2px solid var(--accent); box-sizing: border-box; box-shadow: none; }
.sl-active > button { position: relative; z-index: 1; }
.seg.sl-active > button.on { background: transparent; box-shadow: none; }
.opts.sl-active > .opt.on { background: transparent; border-color: transparent; }
select, input[type=number], input[type=date], textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; width: 100%;
}
select:focus, input:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); outline-offset: 0; }
textarea { resize: vertical; line-height: 1.6; }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.inline { display: flex; gap: 8px; align-items: center; }
.inline.wrap { flex-wrap: wrap; }
.inline select { flex: 1; min-width: 0; }
.badge {
  display: inline-block; font-style: normal; font-size: .7rem; font-weight: 700; padding: 1px 7px; border-radius: 99px;
  background: var(--qt-soft); color: var(--qt); vertical-align: 1px;
}
.badge.good { background: var(--accent-soft); color: var(--accent); }
.tag { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; font-size: .9rem; }
.bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width .3s; }
.bar.thin { height: 4px; margin-top: 5px; }

@media (max-width: 560px) {
  h1 { font-size: 1.3rem; }
  .topbar { padding: 6px 10px; }
  .brand span { display: none; }
  .tabs a { padding: 6px 10px; }
  .topbar-right { gap: 6px; }
  main { padding: 12px 10px; }
  .card { padding: 15px; }
}

/* 오른쪽 위 버전 · 만든 사람 */
.app-sign { display: grid; justify-items: end; line-height: 1.1; color: var(--muted); font-size: .64rem; white-space: nowrap; }
.app-sign b { font-weight: 700; color: var(--ink); }
.app-sign small { display: inline-flex; align-items: center; gap: 2px; font-size: .6rem; }

/* 로고 옆 연속 일수 */
.topbar-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.streak-chip {
  flex: none; display: inline-flex; align-items: center; gap: 3px; padding: 4px 9px; border-radius: 99px;
  font-size: .8rem; font-weight: 700; white-space: nowrap; background: var(--surface-2); color: var(--muted);
  font-variant-numeric: tabular-nums; filter: grayscale(.9);
}
.streak-chip b { font-size: .95rem; }
.streak-chip.on { background: var(--accent-soft); color: var(--accent); filter: none; }
.streak-chip.qt.on { background: var(--qt-soft); color: var(--qt); }

/* 관리자 표시 (좌상단 빈 공간) */
.topbar-left { position: relative; }
.admin-badge { position: absolute; left: -6px; top: -9px; z-index: 2; display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 24px; border-radius: 8px; background: var(--surface); box-shadow: 0 1px 3px rgb(0 0 0 / .18), inset 0 0 0 1px var(--line); pointer-events: none; }
.admin-badge svg { width: 24px; height: 19px; }
.admin-badge[hidden] { display: none; }

/* 상단 메뉴(통독·QT·관리)도 슬라이드 막대로 움직임 (js/shared/slide.js) */
.tabs.sl-active > a.active { background: transparent; box-shadow: none; }
.tabs.sl-active > a { position: relative; z-index: 1; }
.tabs > .slide-thumb { background: var(--surface); box-shadow: 0 1px 3px rgb(0 0 0 / .1); border-radius: 9px; }
.tabs { position: relative; }
