/* 공통 토큰과 기본 스타일. 색은 탭마다 --accent 가 바뀌어요 (html[data-module]). */
:root {
  --bg: #EEF1F6;
  --surface: #FFFFFF;
  --surface2: #E5EAF2;
  --fg: #131C2B;
  --muted: #566176;
  --line: #D3DAE6;
  --accent-h: #2B4C9B;      /* 藍 */
  --accent-k: #0B7480;      /* 浅葱 (가타카나) */
  --m-kana: #2B4C9B;
  --m-songs: #7B3F8F;       /* 紫 */
  --m-kanji: #4B7A2C;       /* 苔 */
  --m-reading: #946200;     /* 山吹 */
  --m-speaking: #B03A2E;    /* 朱 */
  --accent: var(--accent-h);
  --on-accent: #FFFFFF;
  --ok: #2A7A4B;
  --bad: #B2402F;
  --f-body: 'IBM Plex Sans KR', 'Apple SD Gothic Neo', 'Malgun Gothic', system-ui, sans-serif;
  --f-kana: 'Klee One', 'Hiragino Kaku Gothic ProN', 'Yu Gothic', 'Noto Sans JP', sans-serif;
  --f-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0D131C; --surface: #161E2B; --surface2: #1E2838; --fg: #E8EDF5; --muted: #98A3B8; --line: #2A3548;
    --accent-h: #92ABF2; --accent-k: #5EC6CF; --m-kana: #92ABF2; --m-songs: #CFA0DE; --m-kanji: #A4D27E; --m-reading: #E6B450; --m-speaking: #F3917F;
    --on-accent: #0D131C; --ok: #6CCB92; --bad: #F2907E;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0D131C; --surface: #161E2B; --surface2: #1E2838; --fg: #E8EDF5; --muted: #98A3B8; --line: #2A3548;
  --accent-h: #92ABF2; --accent-k: #5EC6CF; --m-kana: #92ABF2; --m-songs: #CFA0DE; --m-kanji: #A4D27E; --m-reading: #E6B450; --m-speaking: #F3917F;
  --on-accent: #0D131C; --ok: #6CCB92; --bad: #F2907E;
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-module="songs"] { --accent: var(--m-songs); }
:root[data-module="kanji"] { --accent: var(--m-kanji); }
:root[data-module="reading"] { --accent: var(--m-reading); }
:root[data-module="speaking"] { --accent: var(--m-speaking); }
:root[data-script="k"] { --accent: var(--accent-k); }   /* 가나 탭에서 가타카나를 고르면 */

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--f-body); font-size: 15px; line-height: 1.6; }
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; }
button:focus-visible, input:focus-visible, summary:focus-visible, a:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.kana { font-family: var(--f-kana); font-weight: 600; }
.mono { font-family: var(--f-mono); }
.muted { color: var(--muted); }

/* 공통 */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.stack { display: grid; gap: 14px; }
h2 { margin: 0; font-size: 17px; line-height: 1.35; text-wrap: balance; }
h3 { margin: 0; font-size: 14px; text-wrap: balance; }
.sec-h { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-block: 8px 2px; flex-wrap: wrap; }
.sec-h small { color: var(--muted); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 20px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); font-weight: 500; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 700; }
.btn[disabled] { opacity: .5; cursor: default; }
.btn.block { width: 100%; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 38px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-size: 14px; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 500; }
.meter { display: block; height: 6px; border-radius: 3px; background: var(--surface2); overflow: hidden; }
.meter u { display: block; height: 100%; background: var(--accent); text-decoration: none; }

/* 시트 */
.scrim { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; background: rgb(8 12 20 / .5); }
.sheet { width: min(520px, 100%); max-height: 92%; overflow: auto; padding: 18px 16px; padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px)); background: var(--surface); border-radius: 18px 18px 0 0; display: grid; gap: 12px; }
@media (min-width: 560px) { .scrim { align-items: center; } .sheet { border-radius: 18px; } }
.big { display: flex; align-items: center; gap: 16px; }
.big .g { flex: none; width: 112px; height: 112px; display: grid; place-items: center; border-radius: 16px; background: var(--surface2); font-size: 72px; line-height: 1; color: var(--accent); }
.big .i b { display: block; font-family: var(--f-mono); font-size: 26px; }
.big .i span { color: var(--muted); }
.hint { padding: 10px 12px; border-radius: 10px; background: var(--surface2); font-size: 14px; }
.sims { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); }
.sims button { min-width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font-size: 22px; }

/* 폼 */
.field { display: grid; gap: 8px; }
.field > label, .field > .lab { font-size: 13px; font-weight: 500; color: var(--muted); }
.note { padding: 10px 12px; border-radius: 10px; background: var(--surface2); font-size: 14px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
