/* ---------- Palette ---------- */
:root {
  --bg-1: #e7f8f2;
  --bg-2: #e2f1fc;
  --surface: #ffffff;
  --surface-2: #f2fbf8;
  --ink: #1d4447;
  --ink-2: #5d8183;
  --ink-3: #8aa9aa;
  --line: #d3ebe5;
  --mint: #3fcfa9;
  --mint-strong: #17a985;
  --mint-soft: #d3f5ea;
  --sky: #4db5f0;
  --sky-strong: #238fd3;
  --sky-soft: #daf0fd;
  --teal: #29a7a8;
  --blush: #ffb9c7;
  --mark: #c8f3e4;
  --shadow: 0 12px 32px rgba(41, 130, 128, 0.16);
  --shadow-sm: 0 4px 14px rgba(41, 130, 128, 0.12);
  --radius: 26px;
  --font-ui: "Nunito", "Gowun Dodum", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-ko: "Gowun Dodum", "Nunito", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --font-cute: "Jua", "Gowun Dodum", "Nunito", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-1: #0d2225;
    --bg-2: #0e1f2c;
    --surface: #15333a;
    --surface-2: #1a3c43;
    --ink: #e3f6f2;
    --ink-2: #a2c7c4;
    --ink-3: #6f9894;
    --line: #24494f;
    --mint: #4fdcb7;
    --mint-strong: #74e8c9;
    --mint-soft: #1d4a43;
    --sky: #66c3f5;
    --sky-strong: #8ad2fa;
    --sky-soft: #1b3d52;
    --teal: #4cc4c2;
    --mark: #22594d;
    --shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
    --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg-1: #0d2225;
  --bg-2: #0e1f2c;
  --surface: #15333a;
  --surface-2: #1a3c43;
  --ink: #e3f6f2;
  --ink-2: #a2c7c4;
  --ink-3: #6f9894;
  --line: #24494f;
  --mint: #4fdcb7;
  --mint-strong: #74e8c9;
  --mint-soft: #1d4a43;
  --sky: #66c3f5;
  --sky-strong: #8ad2fa;
  --sky-soft: #1b3d52;
  --teal: #4cc4c2;
  --mark: #22594d;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.3);
  color-scheme: dark;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-ui);
  color: var(--ink);
  background: linear-gradient(160deg, var(--bg-1) 0%, var(--bg-2) 100%) fixed;
  background-color: var(--bg-1);
  -webkit-tap-highlight-color: transparent;
  /* Break Korean at spaces, not between syllables. */
  word-break: keep-all;
  overflow-wrap: break-word;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--sky-strong); }
:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; border-radius: 12px; }
.noscript { text-align: center; padding: 40px 16px; }

.ko { font-family: var(--font-ko); }
.cute { font-family: var(--font-cute); font-weight: 400; }

#app {
  position: relative;
  z-index: 1;
  max-width: 980px;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 16px max(28px, env(safe-area-inset-bottom));
}

/* floating bubbles */
.bubbles { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.bubbles span {
  position: absolute; bottom: -80px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,.75), rgba(77,181,240,.18) 60%, rgba(63,207,169,.12));
  animation: rise 22s linear infinite;
}
.bubbles span:nth-child(1) { left: 6%;  width: 46px; height: 46px; animation-duration: 26s; }
.bubbles span:nth-child(2) { left: 28%; width: 22px; height: 22px; animation-duration: 18s; animation-delay: -6s; }
.bubbles span:nth-child(3) { left: 57%; width: 64px; height: 64px; animation-duration: 30s; animation-delay: -12s; }
.bubbles span:nth-child(4) { left: 78%; width: 30px; height: 30px; animation-duration: 21s; animation-delay: -3s; }
.bubbles span:nth-child(5) { left: 92%; width: 18px; height: 18px; animation-duration: 16s; animation-delay: -9s; }
@keyframes rise { to { transform: translateY(-120vh) translateX(20px); } }
@media (prefers-reduced-motion: reduce) { .bubbles { display: none; } }

/* ---------- Buttons & chips ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 999px; padding: 12px 20px;
  font-weight: 800; font-size: 15px; text-decoration: none;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm);
  transition: transform .15s ease, box-shadow .15s ease, background .15s;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0) scale(.97); }
.btn.mint { background: var(--mint); color: #08392e; }
.btn.sky { background: var(--sky); color: #06324d; }
.btn.ghost { background: transparent; box-shadow: none; border: 2px solid var(--line); }
.btn.small { padding: 8px 14px; font-size: 14px; }
.btn.block { width: 100%; }
.btn svg { width: 20px; height: 20px; flex: none; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 0;
  display: inline-grid; place-items: center; flex: none;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm);
  transition: transform .15s ease;
  text-decoration: none;
}
.icon-btn:hover { transform: translateY(-2px) rotate(-4deg); }
.icon-btn:disabled { opacity: .4; transform: none; cursor: default; }
.icon-btn svg { width: 22px; height: 22px; }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 800; letter-spacing: .02em;
  background: var(--surface-2); color: var(--ink-2); border: 1.5px solid var(--line);
}
.chip.lv1 { background: var(--mint-soft); color: var(--mint-strong); border-color: transparent; }
.chip.lv2 { background: var(--sky-soft); color: var(--sky-strong); border-color: transparent; }
.chip.lv3 { background: #e9e4fb; color: #6f5bc2; border-color: transparent; }
:root[data-theme="dark"] .chip.lv3 { background: #2f2a4d; color: #b9acf5; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chip.lv3 { background: #2f2a4d; color: #b9acf5; } }
.chip.ai { background: transparent; border-style: dashed; }
.chip.hanja { font-family: "Noto Serif KR", "Batang", serif; font-weight: 600; font-size: 13px; }

/* ---------- Home ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 6px 0 14px; }
.top-btns { display: flex; gap: 8px; flex: none; }
.icon-btn.acct { font-family: var(--font-cute); font-size: 20px; }
.icon-btn.acct.in { background: linear-gradient(135deg, var(--mint), var(--sky)); color: #08392e; }

/* search */
.search { position: relative; margin-bottom: 18px; }
.search input {
  width: 100%; border: 2px solid transparent; border-radius: 999px; padding: 13px 48px 13px 46px;
  background: var(--surface); box-shadow: var(--shadow-sm); font-size: 16px; font-weight: 700; outline: none;
  -webkit-appearance: none; appearance: none;
}
.search input::placeholder { color: var(--ink-3); font-weight: 600; }
.search input:focus { border-color: var(--sky); }
.search input::-webkit-search-cancel-button { display: none; }
.search .s-icon { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--ink-3); display: grid; pointer-events: none; }
.search .s-icon svg { width: 20px; height: 20px; }
.search .s-clear { position: absolute; right: 7px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; border: 0; border-radius: 50%; background: var(--surface-2); color: var(--ink-2); display: grid; place-items: center; }
.search .s-clear[hidden] { display: none; }
.search .s-clear svg { width: 16px; height: 16px; }
.res-count { font-size: 13px; font-weight: 800; color: var(--ink-3); margin: 0 6px 10px; }
#results .word-list { margin-bottom: 20px; }
.word-row.result { width: 100%; border: 0; text-align: left; color: var(--ink); font: inherit; cursor: pointer; transition: transform .15s ease; }
.word-row.result:hover { transform: translateY(-2px); }
.word-row.result .n { width: auto; min-width: 34px; white-space: nowrap; }
.res-main { min-width: 0; }
.res-main .m { display: block; }
.res-side { display: grid; justify-items: end; gap: 4px; }
.res-set { font-size: 11px; font-weight: 800; color: var(--ink-3); white-space: nowrap; }
.no-results { text-align: center; color: var(--ink-2); font-weight: 700; padding: 30px 0; }
.no-results .whale { width: 90px; height: 76px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--sky-strong); font-weight: 800; text-decoration: underline; font-size: inherit; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand .whale { width: 64px; height: 54px; flex: none; animation: bob 3.2s ease-in-out infinite; }
.brand h1 { margin: 0; font-family: var(--font-cute); font-weight: 400; font-size: 30px; line-height: 1; color: var(--teal); }
.brand p { margin: 4px 0 0; font-size: 13px; color: var(--ink-2); font-weight: 700; }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-5px) rotate(2deg); } }
@media (prefers-reduced-motion: reduce) { .brand .whale { animation: none; } }

.hero {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; margin-bottom: 22px;
  display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center;
}
.hero h2 { margin: 0 0 4px; font-size: 15px; color: var(--ink-2); font-weight: 800; }
.hero .big { font-family: var(--font-cute); font-size: 34px; line-height: 1.1; color: var(--ink); }
.hero .big small { font-size: 18px; color: var(--ink-3); }
.hero .stats { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 6px; font-size: 13px; font-weight: 700; color: var(--ink-2); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: 0; }
.dot.known { background: var(--mint); }
.dot.learning { background: var(--sky); }
.dot.new { background: var(--line); }
.bar { height: 12px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-top: 12px; display: flex; border: 1.5px solid var(--line); }
.bar i { display: block; height: 100%; }
.bar i.known { background: linear-gradient(90deg, var(--mint), #63dcbd); }
.bar i.learning { background: linear-gradient(90deg, var(--sky), #7cc9f5); }
@media (max-width: 560px) {
  .hero { grid-template-columns: 1fr; }
  .hero .btn { width: 100%; }
}

.chapter { margin-bottom: 14px; background: color-mix(in srgb, var(--surface) 55%, transparent); border-radius: var(--radius); padding: 4px 6px; }
.chapter > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 12px; border-radius: 20px; font-weight: 800;
}
.chapter > summary::-webkit-details-marker { display: none; }
.chapter > summary .ch-title { font-family: var(--font-cute); font-weight: 400; font-size: 20px; color: var(--ink); }
.chapter > summary .ch-meta { font-size: 13px; color: var(--ink-2); display: flex; align-items: center; gap: 10px; }
.chapter > summary .caret { transition: transform .2s; color: var(--ink-3); }
.chapter[open] > summary .caret { transform: rotate(90deg); }
.mini-bar { width: 70px; height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--line); }
.mini-bar i { display: block; height: 100%; background: var(--mint); }

.sets { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; padding: 4px 8px 14px; }
.set-tile {
  position: relative; display: flex; gap: 12px; align-items: center;
  padding: 12px; border-radius: 22px; text-decoration: none; color: var(--ink);
  background: var(--surface); box-shadow: var(--shadow-sm);
  transition: transform .15s ease, box-shadow .15s ease;
}
.set-tile:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.set-tile .ring { width: 46px; height: 46px; flex: none; }
.set-tile .ring circle { fill: none; stroke-width: 6; }
.set-tile .ring .track { stroke: var(--surface-2); }
.set-tile .ring .lrn { stroke: var(--sky); stroke-linecap: round; }
.set-tile .ring .val { stroke: var(--mint); stroke-linecap: round; }
.set-tile .ring text { font-size: 12px; font-weight: 900; fill: var(--ink-2); font-family: var(--font-ui); }
.set-tile .s-name { font-weight: 900; font-size: 15px; }
.set-tile .s-range { font-size: 12px; color: var(--ink-3); font-weight: 700; }
.set-tile .s-first { font-size: 13px; color: var(--ink-2); font-family: var(--font-ko); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 90px; }
.set-tile.done { background: linear-gradient(135deg, var(--mint-soft), var(--sky-soft)); }
.set-tile.done::after { content: "✿"; position: absolute; top: 6px; right: 10px; color: var(--mint-strong); font-size: 14px; }
.set-tile.current { outline: 3px solid var(--sky); outline-offset: 2px; }

.foot { text-align: center; font-size: 13px; color: var(--ink-3); margin-top: 26px; line-height: 1.6; }
.foot button { background: none; border: 0; color: var(--sky-strong); font-weight: 800; text-decoration: underline; padding: 0; }

/* ---------- Study ---------- */
.study { display: flex; flex-direction: column; min-height: calc(100dvh - 48px); }
.study-top { display: flex; align-items: center; gap: 10px; margin: 4px 0 10px; }
.study-top .title { flex: 1; min-width: 0; text-align: center; }
.study-top .title b { display: block; font-family: var(--font-cute); font-weight: 400; font-size: 22px; line-height: 1.1; }
.study-top .title small { font-size: 12px; color: var(--ink-3); font-weight: 800; }
/* Everything on the study screen shares one centered column, so the header,
   progress bar, card and buttons line up on wide screens too. */
.study { --col: 440px; }
.study .study-top, .study .round, .study .deck, .study .actions, .study .hint, .study .done {
  width: 100%; max-width: var(--col); margin-left: auto; margin-right: auto;
}
/* Title centered over the card: equal side columns for the buttons. */
.study .study-top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.study .study-top .title { flex: none; }
.st-side { display: flex; gap: 8px; min-width: 0; }
.st-side.end { justify-content: flex-end; }
.round { width: 100%; }
.round .bar { margin-top: 0; height: 10px; }
.counts { display: flex; justify-content: space-between; font-size: 13px; font-weight: 800; color: var(--ink-2); margin: 8px 4px 0; }
.counts .c-learn { color: var(--sky-strong); }
.counts .c-know { color: var(--mint-strong); }

.deck { position: relative; width: 100%; max-width: 420px; margin: 16px auto 0; height: min(64dvh, 540px); min-height: 400px; }
.card {
  position: absolute; inset: 0;
  perspective: 1400px;
  touch-action: pan-y;
  user-select: none; -webkit-user-select: none;
  will-change: transform;
}
.card.next { transform: translateY(14px) scale(.95); opacity: .75; pointer-events: none; }
.card.next .inner { filter: saturate(.7); }
.card.enter { animation: pop .28s ease-out; }
@keyframes pop { from { transform: translateY(14px) scale(.95); opacity: .7; } to { transform: none; opacity: 1; } }
.inner { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform .5s cubic-bezier(.3,1.4,.5,1); }
.card.flipped .inner { transform: rotateY(180deg); }
.face {
  position: absolute; inset: 0; border-radius: 30px; overflow: hidden;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  background: var(--surface); box-shadow: var(--shadow);
  border: 2px solid var(--line);
  display: flex; flex-direction: column;
}
.face.back { transform: rotateY(180deg); }
.face::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 9px;
  background: linear-gradient(90deg, var(--mint), var(--sky));
}

.front { align-items: center; justify-content: center; text-align: center; padding: 30px 20px 22px; gap: 10px; cursor: grab; }
.front .meta-row { position: absolute; top: 20px; left: 18px; right: 18px; display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.front .num { font-weight: 900; color: var(--ink-3); font-size: 14px; }
.front .word { font-family: var(--font-cute); font-size: clamp(54px, 15vw, 80px); line-height: 1.1; color: var(--ink); word-break: keep-all; overflow-wrap: anywhere; }
.front .word.long { font-size: clamp(40px, 11vw, 58px); }
.front .guide { font-size: 18px; color: var(--ink-2); font-weight: 700; letter-spacing: .02em; }
.front-btns { display: flex; gap: 10px; justify-content: center; }
.front .tap-hint { position: absolute; bottom: 18px; left: 0; right: 0; font-size: 12px; font-weight: 800; color: var(--ink-3); letter-spacing: .04em; }
.front .meaning-front .vi { font-size: 26px; font-weight: 800; line-height: 1.25; }
.front .meaning-front .en { font-size: 18px; color: var(--ink-2); font-weight: 700; margin-top: 8px; }
.front .meaning-front .pos { margin-bottom: 10px; }

.speak {
  border: 0; border-radius: 999px; width: 46px; height: 46px; display: inline-grid; place-items: center; flex: none;
  background: var(--sky-soft); color: var(--sky-strong);
  transition: transform .15s;
}
.speak:hover { transform: scale(1.08); }
.speak svg { width: 22px; height: 22px; }
.speak.sm { width: 34px; height: 34px; }
.speak.sm svg { width: 17px; height: 17px; }
.speak.copy { background: var(--mint-soft); color: var(--mint-strong); }

.back { padding: 22px 18px 16px; gap: 10px; overflow-y: auto; overscroll-behavior: contain; cursor: grab; }
.back-head { display: flex; align-items: center; gap: 10px; padding-top: 4px; }
.back-head .bh-text { flex: 1; min-width: 0; }
.back-head .w { font-family: var(--font-cute); font-size: 34px; line-height: 1.1; overflow-wrap: anywhere; }
.back-head .bh-sub { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 2px; }
.back-head .r { color: var(--ink-2); font-weight: 700; font-size: 14.5px; }
.back-head .pr { color: var(--ink-3); font-size: 14px; font-family: var(--font-ko); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.mean { display: grid; gap: 7px; }
.line { display: grid; grid-template-columns: 30px 1fr; gap: 8px; align-items: baseline; }
.flag {
  font-size: 11px; font-weight: 900; border-radius: 8px; padding: 2px 0; text-align: center;
  background: var(--mint-soft); color: var(--mint-strong);
}
.flag.en { background: var(--sky-soft); color: var(--sky-strong); }
.line .t { font-size: 18px; font-weight: 800; line-height: 1.3; }
.line .t.long { font-size: 15px; font-weight: 700; }
.line.en .t { color: var(--ink-2); }
details.defs { font-size: 13px; color: var(--ink-2); }
details.defs summary { cursor: pointer; font-weight: 800; color: var(--ink-3); list-style: none; display: inline-block; }
details.defs summary::-webkit-details-marker { display: none; }
details.defs p { margin: 6px 0 0; line-height: 1.45; }
.example {
  background: var(--surface-2); border-radius: 18px; padding: 10px 12px; border: 1.5px dashed var(--line);
  display: flex; gap: 10px; align-items: flex-start;
}
.example .ex-body { flex: 1; min-width: 0; display: grid; gap: 5px; }
.example p { margin: 0; }
.example .ko { font-family: var(--font-ko); font-size: 18px; line-height: 1.5; }
.example .tr { display: grid; grid-template-columns: 30px 1fr; gap: 8px; align-items: baseline; font-size: 14.5px; line-height: 1.4; color: var(--ink-2); font-weight: 600; }
.example .tr .flag { font-size: 10px; }
.example mark { background: var(--mark); color: var(--ink); border-radius: 6px; padding: 0 3px; font-weight: 800; }
.ex-btns { display: grid; gap: 6px; flex: none; }
.example .lbl { display: block; font-family: var(--font-ui); font-size: 11px; font-weight: 900; color: var(--ink-3); letter-spacing: .06em; }
.also { border-top: 2px dotted var(--line); padding-top: 8px; display: grid; gap: 6px; }
.also .lbl { font-size: 11px; font-weight: 900; color: var(--ink-3); letter-spacing: .06em; }
.also .alt { font-size: 14px; line-height: 1.4; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden; }
.also .alt .pos { color: var(--ink-3); font-weight: 800; font-size: 12px; margin-right: 4px; }
.also .alt .vi { font-weight: 800; }
.also .alt .en { color: var(--ink-2); }
.ai-note { font-size: 11px; color: var(--ink-3); font-weight: 700; }

.stamp {
  position: absolute; top: 34px; z-index: 5; pointer-events: none;
  padding: 6px 14px; border-radius: 14px; font-weight: 900; font-size: 20px; letter-spacing: .04em;
  border: 3px solid currentColor; background: var(--surface); opacity: 0;
}
.stamp.know { left: 22px; color: var(--mint-strong); transform: rotate(-12deg); }
.stamp.learn { right: 22px; color: var(--sky-strong); transform: rotate(12deg); }

.actions { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; max-width: 420px; width: 100%; margin: 22px auto 0; }
.actions .btn { padding: 14px 10px; }
.actions .flip { width: 54px; height: 54px; padding: 0; border-radius: 50%; }
.hint { text-align: center; font-size: 12px; color: var(--ink-3); font-weight: 700; margin: 14px 0 0; }
.kbd { display: inline-block; border: 1.5px solid var(--line); border-bottom-width: 3px; border-radius: 6px; padding: 0 5px; font-size: 11px; }
.kbd-hint { display: block; margin-top: 6px; }
@media (hover: none) { .kbd-hint { display: none; } }

/* ---------- Done screen ---------- */
.done {
  max-width: 440px; margin: 24px auto 0; text-align: center;
  background: var(--surface); border-radius: 32px; box-shadow: var(--shadow); padding: 26px 22px;
}
.done .whale { width: 120px; height: 100px; animation: bob 2.6s ease-in-out infinite; }
.done h2 { font-family: var(--font-cute); font-weight: 400; font-size: 32px; margin: 6px 0 4px; color: var(--teal); }
.done p { margin: 0 0 16px; color: var(--ink-2); font-weight: 700; }
.done .tally { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.done .tally div { border-radius: 20px; padding: 12px; font-weight: 800; }
.done .tally .k { background: var(--mint-soft); color: var(--mint-strong); }
.done .tally .l { background: var(--sky-soft); color: var(--sky-strong); }
.done .tally b { display: block; font-family: var(--font-cute); font-weight: 400; font-size: 34px; }
.done .btns { display: grid; gap: 10px; }

/* ---------- List ---------- */
.list-head { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 12px; }
.seg { display: inline-flex; background: var(--surface); border-radius: 999px; padding: 4px; box-shadow: var(--shadow-sm); gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; border-radius: 999px; padding: 7px 13px; font-weight: 800; font-size: 13px; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--mint); color: #08392e; }
.word-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.word-row {
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center;
  background: var(--surface); border-radius: 18px; padding: 10px 12px; box-shadow: var(--shadow-sm);
}
.word-row .n { font-size: 12px; font-weight: 900; color: var(--ink-3); width: 34px; text-align: right; }
.word-row .w { font-family: var(--font-cute); font-size: 22px; margin-right: 8px; }
.word-row .m { font-size: 14px; color: var(--ink-2); }
.word-row .m b { color: var(--ink); }
.status-btn { border: 0; border-radius: 999px; padding: 6px 12px; font-size: 12px; font-weight: 900; white-space: nowrap; background: var(--surface-2); color: var(--ink-3); border: 1.5px solid var(--line); }
.status-btn.known { background: var(--mint-soft); color: var(--mint-strong); border-color: transparent; }
.status-btn.learning { background: var(--sky-soft); color: var(--sky-strong); border-color: transparent; }

/* ---------- Modal ---------- */
.modal-bg {
  position: fixed; inset: 0; z-index: 50; background: rgba(13, 50, 52, .35);
  display: grid; place-items: center; padding: 16px; animation: fade .2s;
  backdrop-filter: blur(3px);
}
.modal {
  width: 100%; max-width: 460px; max-height: 90dvh; overflow-y: auto;
  background: var(--surface); border-radius: 28px; box-shadow: var(--shadow); padding: 20px;
  animation: pop .25s ease-out;
}
.modal h2 { margin: 0 0 14px; font-family: var(--font-cute); font-weight: 400; font-size: 26px; color: var(--teal); display: flex; justify-content: space-between; align-items: center; }
.modal h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); margin: 18px 0 8px; }
.modal p { line-height: 1.55; font-size: 14px; color: var(--ink-2); margin: 0 0 10px; }
.opt { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1.5px solid var(--line); font-weight: 700; }
.opt > div:first-child { flex: 1; min-width: 0; }
.opt .seg { flex: none; flex-wrap: nowrap; }
.opt:last-child { border-bottom: 0; }
.opt small { display: block; color: var(--ink-3); font-weight: 600; font-size: 12px; }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: .2s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; width: 24px; height: 24px; left: 3px; top: 3px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 2px 6px rgba(0,0,0,.15); }
.switch input:checked + span { background: var(--mint); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 3px solid var(--sky); outline-offset: 2px; }
.row-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.opt.opt-col { flex-direction: column; align-items: stretch; gap: 8px; }
.voice-row { display: flex; gap: 8px; align-items: center; }
.voice-row select { flex: 1; min-width: 0; border: 2px solid var(--line); border-radius: 14px; padding: 9px 12px; background: var(--surface-2); font-weight: 700; font-size: 14px; }
.voice-row .btn { flex: none; }
@keyframes fade { from { opacity: 0; } }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); z-index: 60;
  transform: translate(-50%, 30px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--surface); font-weight: 800; font-size: 14px;
  padding: 10px 18px; border-radius: 999px; box-shadow: var(--shadow); transition: .25s; max-width: calc(100vw - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Confetti ---------- */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 70; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 10px; height: 10px; border-radius: 50%; animation: fall 1.8s ease-in forwards; }
.confetti i.h { width: auto; height: auto; background: none !important; font-style: normal; font-size: 16px; }
@keyframes fall { to { transform: translateY(105vh) rotate(540deg); opacity: .8; } }

.loading { text-align: center; padding: 80px 0; color: var(--ink-3); font-weight: 800; }
.loading .whale { width: 90px; height: 76px; animation: bob 1.6s ease-in-out infinite; display: block; margin: 0 auto 10px; }

/* ---------- Card popup (search) ---------- */
.card-detail { display: flex; flex-direction: column; gap: 10px; }
.cm-title { font-size: 18px; color: var(--ink-3); }
.cm-status { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 14px; padding-top: 12px; border-top: 1.5px solid var(--line); font-weight: 800; color: var(--ink-2); font-size: 14px; }
.cm-go { margin-top: 12px; }

/* ---------- Account ---------- */
.btn.google { background: var(--surface); border: 2px solid var(--line); box-shadow: none; margin-top: 4px; }
.btn.google svg { width: 20px; height: 20px; }
.or { display: flex; align-items: center; gap: 10px; color: var(--ink-3); font-size: 12px; font-weight: 800; margin: 16px 0 12px; }
.or::before, .or::after { content: ""; flex: 1; height: 1.5px; background: var(--line); }
.login-form { display: grid; gap: 10px; }
.login-form input { width: 100%; border: 2px solid var(--line); border-radius: 14px; padding: 11px 14px; background: var(--surface-2); font-size: 16px; outline: none; }
.login-form input:focus { border-color: var(--sky); }
.login-form .row-btns { align-items: center; }
.sync-state { font-size: 13px !important; font-weight: 700; color: var(--mint-strong) !important; }

/* ---------- Pronunciation help ---------- */
.guide-table { border-collapse: collapse; margin: 4px 0 10px; font-size: 15px; }
.guide-table td { padding: 4px 14px 4px 0; }
.guide-table td:first-child { font-family: var(--font-ko); }
.jamo-chart { display: grid; grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: 6px; margin: 0 0 10px; }
.jamo-chart div { display: grid; justify-items: center; gap: 2px; padding: 6px 2px; border-radius: 12px; background: var(--surface-2); border: 1.5px solid var(--line); }
.jamo-chart .j { font-family: var(--font-ko); font-size: 20px; line-height: 1.1; }
.jamo-chart .v { font-size: 13px; font-weight: 800; color: var(--mint-strong); white-space: nowrap; }

/* ---------- Breakdown: how the word is built ---------- */
details.bd { background: var(--surface); border: 1.5px solid var(--line); border-radius: 18px; padding: 8px 12px; }
details.bd > summary { cursor: pointer; list-style: none; display: flex; align-items: baseline; gap: 8px; }
details.bd > summary::-webkit-details-marker { display: none; }
details.bd > summary::after { content: "▾"; margin-left: auto; color: var(--ink-3); font-size: 12px; transition: transform .2s; }
details.bd:not([open]) > summary::after { transform: rotate(-90deg); }
details.bd .lbl { font-size: 11px; font-weight: 900; color: var(--ink-3); letter-spacing: .06em; }
details.bd .bd-word { font-family: var(--font-ko); font-weight: 700; color: var(--teal); }
.bd-steps { list-style: none; margin: 8px 0 2px; padding: 0; display: grid; gap: 8px; counter-reset: bd; }
.bd-steps li { display: grid; gap: 3px; padding-left: 26px; position: relative; counter-increment: bd; }
.bd-steps li::before {
  content: counter(bd); position: absolute; left: 0; top: 1px; width: 19px; height: 19px; border-radius: 50%;
  display: grid; place-items: center; font-size: 11px; font-weight: 900; background: var(--mint-soft); color: var(--mint-strong);
}
.bd-step { font-family: var(--font-ko); font-size: 16px; line-height: 1.35; }
.bd-step b { color: var(--teal); }
.bd-step i { font-style: normal; color: var(--ink-3); margin: 0 6px; }
.bd-why { display: flex; flex-wrap: wrap; gap: 5px; }
.g-tag {
  display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 800;
  background: var(--sky-soft); color: var(--sky-strong); text-decoration: none; border: 1.5px solid transparent;
}
a.g-tag:hover { border-color: var(--sky); }
.g-tag.note { background: transparent; border-color: var(--line); color: var(--ink-2); font-family: var(--font-ko); font-weight: 700; }
.chip.gram { text-decoration: none; background: var(--sky-soft); color: var(--sky-strong); border-color: transparent; }
.chip.gram svg { width: 13px; height: 13px; }

/* ---------- Grammar page & popup ---------- */
.g-intro { color: var(--ink-2); font-size: 14px; line-height: 1.5; margin: 0 4px 12px; }
.seg button small { font-weight: 700; opacity: .7; }
.g-cat { font-size: 13px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); margin: 20px 6px 8px; }
.g-list { display: grid; gap: 8px; padding-bottom: 20px; }
.g-point { background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-sm); scroll-margin-top: 12px; }
.g-point > summary { list-style: none; cursor: pointer; padding: 12px 14px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.g-point > summary::-webkit-details-marker { display: none; }
.g-point[open] > summary { border-bottom: 1.5px solid var(--line); }
.g-point.flash { outline: 3px solid var(--sky); outline-offset: 2px; }
.gp-ko { font-family: var(--font-ko); font-size: 19px; font-weight: 700; color: var(--teal); }
.gp-names { font-size: 14px; color: var(--ink-2); }
.gp-names b { color: var(--ink); }
.gp-body { padding: 12px 14px 14px; display: grid; gap: 10px; }
.gp-form { margin: 0; display: grid; gap: 3px; font-size: 15px; line-height: 1.5; background: var(--mint-soft); border-radius: 12px; padding: 8px 12px; }
.gp-form .lbl { font-size: 11px; font-weight: 900; color: var(--mint-strong); letter-spacing: .06em; }
.gp-d { margin: 0; font-size: 15px; line-height: 1.55; }
.gp-d.second { font-size: 13.5px; color: var(--ink-2); }
.gp-ex { display: grid; gap: 8px; }
.g-modal h2 { margin-bottom: 8px; }
.g-modal .gp-title { display: grid; gap: 2px; margin-bottom: 10px; }
.g-modal .gp-ko { font-size: 24px; }
.g-modal .gp-form, .g-modal .gp-d, .g-modal .gp-ex { margin-bottom: 10px; }
.g-modal .row-btns { margin-top: 4px; }

/* ---------- Movies ---------- */
.sec-title { font-size: 13px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); margin: 0 6px 10px; }
.movies { margin-bottom: 22px; }
.movie-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.movie-tile {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 22px; text-decoration: none; color: var(--ink);
  background: var(--surface); box-shadow: var(--shadow-sm); transition: transform .15s ease, box-shadow .15s ease;
}
.movie-tile:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.movie-tile .mt-icon { font-size: 26px; line-height: 1; }
.movie-tile .mt-main { flex: 1; min-width: 0; display: grid; gap: 4px; }
.movie-tile b { font-family: var(--font-cute); font-weight: 400; font-size: 20px; line-height: 1.1; }
.movie-tile small { font-size: 12px; font-weight: 700; color: var(--ink-3); }
.movie-tile .mini-bar { width: 100%; }
.movie-tile svg { width: 20px; height: 20px; color: var(--ink-3); flex: none; }
.chip.uses { background: var(--sky-soft); color: var(--sky-strong); border-color: transparent; }
