@font-face {
  font-family: "HanRoots Sans";  /* subset of Pretendard, renamed per the OFL Reserved Font Name */
  src: url("fonts/hanroots-sans.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

/* ---------- design tokens ---------- */
:root {
  --bg: #f6f7f9; --surface: #ffffff; --surface-2: #f1f3f6; --fg: #111827; --muted: #6b7280;
  --line: #e7e9ee; --accent: #2458b3; --accent-soft: #e6eefb; --brand: #1f3a5f;
  --known: #16a34a; --star: #f59e0b;
  --g1: #15803d; --g1-bg: #dcfce7; --g2: #1d4ed8; --g2-bg: #dbeafe;
  --g3: #7e22ce; --g3-bg: #f3e8ff; --g0: #6b7280; --g0-bg: #eef0f3;
  --shadow: 0 1px 2px rgba(17, 24, 39, .04), 0 6px 20px rgba(17, 24, 39, .05);
  --radius: 18px;
  --topbar-bg: rgba(246, 247, 249, .82);
  --tab-h: 62px;
  --serif: "Noto Serif KR", "Noto Serif CJK KR", "AppleMyungjo", "Batang", serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115; --surface: #181b21; --surface-2: #20242c; --fg: #e8eaee; --muted: #9aa1ad;
    --line: #272b33; --accent: #7fa8ff; --accent-soft: #1d2a44; --brand: #2c4f80;
    --known: #4ade80; --star: #fbbf24;
    --g1: #86efac; --g1-bg: rgba(34, 197, 94, .14); --g2: #93c5fd; --g2-bg: rgba(59, 130, 246, .16);
    --g3: #d8b4fe; --g3-bg: rgba(168, 85, 247, .16); --g0: #a3a9b4; --g0-bg: rgba(148, 163, 184, .12);
    --shadow: none;
    --topbar-bg: rgba(15, 17, 21, .82);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 16px/1.55 "HanRoots Sans", system-ui, -apple-system, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  letter-spacing: -0.01em;
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom));
}
a { color: var(--accent); text-decoration: none; }
button { font: inherit; color: inherit; }
.hanja { font-family: var(--serif); letter-spacing: 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
sup { font-size: .6em; color: var(--muted); margin-left: 1px; }
.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- splash / loading ---------- */
#splash {
  position: fixed; inset: 0; z-index: 50; background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .9rem;
  transition: opacity .3s ease;
}
#splash.done { opacity: 0; pointer-events: none; }
.splash-name { font-size: 1.35rem; font-weight: 700; }
.splash-status { font-size: .85rem; min-height: 1.3em; }
.bar { width: 180px; height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .15s linear; }

.logo {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px;
  background: var(--brand); color: #fff; font-family: var(--serif); font-size: 18px; line-height: 1;
}
.logo.big { width: 72px; height: 72px; border-radius: 20px; font-size: 42px; box-shadow: var(--shadow); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  padding: calc(.6rem + env(safe-area-inset-top)) 1rem .7rem;
  background: var(--topbar-bg); backdrop-filter: saturate(1.6) blur(14px); -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid transparent; transition: border-color .2s;
}
body:not([data-view="home"]) .topbar { border-bottom-color: var(--line); }
.brand { display: flex; align-items: center; gap: .55rem; margin-bottom: .6rem; }
.brand-name { font-weight: 700; font-size: 1.05rem; }
body:not([data-view="home"]) .brand { display: none; }
body[data-view="home"] .topbar { padding-top: calc(1.4rem + env(safe-area-inset-top)); }
body[data-view="home"] .brand { margin-bottom: 1rem; }
body[data-view="home"] .brand .logo { width: 38px; height: 38px; font-size: 23px; border-radius: 11px; }
body[data-view="home"] .brand-name { font-size: 1.45rem; letter-spacing: -0.02em; }
.pill-btn {
  margin-left: auto; border: 1px solid var(--line); background: var(--surface); border-radius: 99px;
  padding: .2rem .7rem; font-size: .8rem; font-weight: 600; color: var(--muted); cursor: pointer;
}

#search { position: relative; display: flex; align-items: center; }
#search > .i { position: absolute; left: .85rem; color: var(--muted); pointer-events: none; }
#q {
  width: 100%; font: inherit; font-size: 1.05rem; color: var(--fg);
  padding: .7rem 2.6rem .7rem 2.6rem; border-radius: 14px;
  border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow);
  outline: none; transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none; appearance: none;
}
#q::-webkit-search-cancel-button { display: none; }
#q:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
body[data-view="home"] #q { font-size: 1.15rem; padding-top: .95rem; padding-bottom: .95rem; border-radius: 16px; }
#clear[hidden], .suggest[hidden] { display: none; }
#clear {
  position: absolute; right: .4rem; border: 0; background: none; color: var(--muted);
  width: 2.2rem; height: 2.2rem; display: grid; place-items: center; cursor: pointer;
}

.suggest {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 20;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .12); overflow: hidden;
}
.suggest a {
  display: flex; align-items: baseline; gap: .5rem; padding: .6rem .9rem; color: var(--fg);
  border-top: 1px solid var(--line);
}
.suggest a:first-child { border-top: 0; }
.suggest a:active { background: var(--surface-2); }
.suggest .sw { font-weight: 600; white-space: nowrap; }
.suggest .sh { color: var(--muted); font-size: .85rem; white-space: nowrap; }
.suggest .sg { color: var(--muted); font-size: .85rem; margin-left: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* ---------- main ---------- */
main { padding: .9rem 1rem 1rem; max-width: 46rem; margin: 0 auto; }
main.enter { animation: enter .22s ease-out; }
@keyframes enter { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { main.enter { animation: none; } }

h1 { font-size: 1.9rem; line-height: 1.2; margin: 0; letter-spacing: -0.03em; font-weight: 700; }
h2 { font-size: 1.05rem; margin: 1.6rem .2rem .6rem; font-weight: 700; letter-spacing: -0.02em; }
.page-title { font-size: 1.5rem; margin: .4rem .2rem .3rem; }
.hint { color: var(--muted); font-size: .9rem; margin: 0 .2rem .8rem; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1rem 1.1rem; margin: .75rem 0;
}
.card.flush { padding: .2rem 1.1rem; }

/* ---------- pills, chips, buttons ---------- */
.pill {
  display: inline-flex; align-items: center; font-size: .75rem; font-weight: 600;
  padding: .12rem .55rem; border-radius: 99px; background: var(--g0-bg); color: var(--g0); white-space: nowrap;
}
.pill.g1 { background: var(--g1-bg); color: var(--g1); }
.pill.g2 { background: var(--g2-bg); color: var(--g2); }
.pill.g3 { background: var(--g3-bg); color: var(--g3); }
.pills { display: flex; flex-wrap: wrap; gap: .35rem; }

.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip {
  display: inline-flex; align-items: baseline; gap: .35rem; padding: .45rem .85rem;
  border-radius: 99px; background: var(--surface); border: 1px solid var(--line); color: var(--fg);
  box-shadow: var(--shadow); font-weight: 600;
}
.chip small { color: var(--muted); font-weight: 500; font-size: .75rem; }

.filter-row {
  display: flex; gap: .4rem; overflow-x: auto; scrollbar-width: none; padding: .1rem 1.5rem .3rem .1rem;
  margin: 0 -.1rem;
  /* fade at the right edge hints that the row scrolls */
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
  mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
}
.filter-row::-webkit-scrollbar { display: none; }
.fchip {
  flex: none; border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  border-radius: 99px; padding: .35rem .8rem; font-size: .85rem; font-weight: 600; cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.fchip.on { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.fchip.g1.on { background: var(--g1-bg); color: var(--g1); }
.fchip.g2.on { background: var(--g2-bg); color: var(--g2); }
.fchip.g3.on { background: var(--g3-bg); color: var(--g3); }
.fchip .i { width: 14px; height: 14px; vertical-align: -2px; margin-right: .2rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  border: 1px solid var(--line); background: var(--surface); color: var(--fg);
  padding: .6rem 1rem; border-radius: 12px; font-weight: 600; font-size: .92rem; cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { background: #dc2626; border-color: #dc2626; color: #fff; }
.fchip:disabled { opacity: .4; cursor: default; }
@media (prefers-color-scheme: dark) { .btn.primary { color: #0f1115; } }
.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; margin: .6rem 0; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 3px; }
.seg button { border: 0; background: none; padding: .45rem 1rem; border-radius: 10px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--fg); box-shadow: var(--shadow); }

/* ---------- home ---------- */
.lead { font-size: 1rem; color: var(--muted); margin: .2rem .2rem 1rem; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; margin: 1.2rem 0 .4rem; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow);
  padding: .8rem .9rem; color: var(--fg); display: flex; flex-direction: column;
}
.stat b { font-size: 1.35rem; letter-spacing: -0.02em; }
.stat span { color: var(--muted); font-size: .8rem; }
.stat.k b { color: var(--known); } .stat.s b { color: var(--star); }

/* ---------- entry ---------- */
.entry h1 sup { font-size: .5em; }
.pron { color: var(--muted); font-size: .95rem; margin-left: .15rem; }
.entry-hanja { font-size: 1.7rem; margin: .15rem 0 .55rem; color: var(--fg); }
.actions { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: .45rem; margin: .9rem 0 .3rem; }
.act {
  display: inline-flex; align-items: center; justify-content: center; gap: .3rem; border: 1px solid var(--line);
  background: var(--surface); border-radius: 12px; padding: .55rem .3rem; font-size: .82rem; white-space: nowrap;
  font-weight: 600; color: var(--muted); cursor: pointer; transition: background .15s, color .15s, border-color .15s;
}
.act .i { width: 18px; height: 18px; }
.act.k.on { background: var(--g1-bg); color: var(--known); border-color: transparent; }
.act.s.on { background: rgba(245, 158, 11, .14); color: var(--star); border-color: transparent; }
.act.k.on .i circle { fill: var(--known); stroke: var(--known); }
.act.k.on .i path { stroke: var(--surface); }
.act.s.on .i path { fill: var(--star); stroke: var(--star); }
.act.off { opacity: .4; }
ol.senses { padding-left: 1.3rem; margin: 1rem 0 .4rem; }
ol.senses > li { margin: 0 0 1rem; padding-left: .15rem; }
ol.senses > li::marker { color: var(--muted); font-weight: 600; }
.meaning { font-size: 1.12rem; font-weight: 700; line-height: 1.35; margin-bottom: .2rem; }
.def { font-weight: 500; }
.en { color: var(--muted); font-size: .9rem; margin-top: .15rem; }
.ex {
  font-size: .9rem; margin-top: .45rem; padding: .45rem .7rem; background: var(--surface-2);
  border-radius: 10px;
}
.ex b { color: var(--accent); font-weight: 700; }
.homs { display: flex; align-items: center; flex-wrap: wrap; gap: .4rem; margin-top: .4rem; font-size: .85rem; color: var(--muted); }
.homs .chip { box-shadow: none; padding: .3rem .7rem; font-size: .9rem; }
.ext { display: inline-flex; align-items: center; gap: .25rem; font-size: .85rem; margin-top: .6rem; }
.ext .i { width: 14px; height: 14px; }

/* ---------- hanja family card ---------- */
.fam-top { display: flex; gap: .5rem; align-items: stretch; }
/* Reading and character get equal, separate tiles: 강 | 強 */
.tile {
  flex: none; width: 64px; min-height: 72px; border-radius: 16px; background: var(--accent-soft);
  display: grid; place-items: center; font-size: 2.2rem; line-height: 1; color: var(--fg);
}
.tile.syl { font-weight: 700; }
.fam-info { margin-left: .4rem; }
.fam-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .2rem; }
.fam-meaning { font-weight: 600; line-height: 1.35; }
.fam-meta { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; font-size: .8rem; color: var(--muted); }
.progress { height: 5px; border-radius: 99px; background: var(--line); overflow: hidden; margin-top: auto; }
.progress span { display: block; height: 100%; background: var(--known); border-radius: 99px; }
.fam-count { font-size: .78rem; color: var(--muted); }
.gist { font-size: .88rem; color: var(--muted); margin: .7rem 0 .1rem; display: grid; gap: .2rem; }
.gist a { font-weight: 600; margin-right: .3rem; }

/* ---------- word rows ---------- */
ul.words { list-style: none; padding: 0; margin: .5rem 0 0; }
ul.words li { display: flex; align-items: center; gap: .25rem; padding: .55rem 0; border-top: 1px solid var(--line); }
ul.words li:first-child { border-top: 0; }
.card.flush ul.words { margin: 0; }
.row-main { flex: 1; min-width: 0; color: var(--fg); }
.row-top { display: flex; align-items: center; gap: .4rem; }
.row-w { font-weight: 600; font-size: 1.02rem; white-space: nowrap; }
.row-h { color: var(--muted); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-top .pill { margin-left: auto; font-size: .68rem; padding: .05rem .45rem; }
.row-gl { display: block; color: var(--muted); font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
li.known .row-w { color: var(--known); }
li.self { background: var(--accent-soft); margin: 0 -.6rem; padding-left: .6rem; padding-right: .6rem; border-radius: 12px; border-top-color: transparent; }
li.self + li { border-top-color: transparent; }
mark { background: none; color: var(--accent); }
.empty { color: var(--muted); font-size: .9rem; padding: .8rem 0; }

.ic {
  flex: none; width: 38px; height: 38px; border: 0; background: none; border-radius: 99px;
  display: grid; place-items: center; color: var(--muted); cursor: pointer; opacity: .55;
  transition: opacity .15s, color .15s, transform .15s;
}
.ic.on { opacity: 1; }
.ic.k.on { color: var(--known); }
.ic.k.on .i circle { fill: var(--known); }
.ic.k.on .i path { stroke: var(--surface); }
.ic.s.on { color: var(--star); }
.ic.s.on .i path { fill: var(--star); }
.pop { animation: pop .28s ease-out; }
@keyframes pop { 40% { transform: scale(1.25); } }

.more {
  width: 100%; margin-top: .4rem; border: 0; border-top: 1px solid var(--line); background: none;
  color: var(--accent); font-weight: 600; font-size: .9rem; padding: .7rem 0 .2rem; cursor: pointer;
}

/* ---------- settings ---------- */
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .3rem 0; }
.set-label { font-weight: 600; }
.folder { font-weight: 600; word-break: break-all; }

/* ---------- tab bar, toast, footer ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--topbar-bg); backdrop-filter: saturate(1.6) blur(14px); -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-top: 1px solid var(--line);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); font-size: .72rem; font-weight: 600;
}
.tabbar .i { width: 23px; height: 23px; }
body[data-view="home"] .tabbar [data-tab="home"],
body[data-view="list"] .tabbar [data-tab="list"],
body[data-view="settings"] .tabbar [data-tab="settings"] { color: var(--accent); }
body[data-view="list"] .tabbar [data-tab="list"] .i path { fill: var(--accent); }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 14px); z-index: 30;
  transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
  background: #1f2937; color: #fff; padding: .55rem 1rem; border-radius: 99px; font-size: .88rem; font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .2); transition: opacity .2s, transform .2s; white-space: nowrap;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (prefers-color-scheme: dark) { #toast { background: #e5e7eb; color: #111827; } }

.attribution { color: var(--muted); font-size: .72rem; text-align: center; padding: 1rem 1.5rem 1.5rem; line-height: 1.6; }
.attribution a { color: inherit; text-decoration: underline; }

/* ---------- review ---------- */
.tabbar { grid-template-columns: repeat(4, 1fr); }
body[data-view="review"] .tabbar [data-tab="review"],
body[data-view="session"] .tabbar [data-tab="review"] { color: var(--accent); }
body[data-view="session"] .tabbar, body[data-view="session"] .topbar, body[data-view="session"] .attribution { display: none; }
body[data-view="session"] { padding-bottom: 0; }
.seg.wide { display: flex; margin: .3rem 0 .2rem; }
.seg.wide button { flex: 1; }
.stats.two { grid-template-columns: repeat(2, 1fr); }
.btn.big { width: 100%; padding: .9rem 1rem; font-size: 1.05rem; border-radius: 14px; margin-top: .6rem; }
.done-card { text-align: center; padding: 1.4rem 1rem; }
.big-check { color: var(--known); display: grid; place-items: center; margin-bottom: .4rem; }
.big-check .i { width: 48px; height: 48px; }
.big-check .i circle { fill: var(--known); } .big-check .i path { stroke: var(--surface); }

.boxes { display: grid; grid-template-columns: repeat(8, 1fr); gap: .3rem; align-items: end; }
.box { display: flex; flex-direction: column; align-items: center; gap: .2rem; min-width: 0; }
.box .bt { width: 100%; height: 84px; background: var(--surface-2); border-radius: 8px; display: flex; align-items: flex-end; overflow: hidden; }
.box .bt span { width: 100%; background: var(--accent); border-radius: 8px 8px 0 0; min-height: 2px; }
.box .bn { font-size: .78rem; font-weight: 700; }
.box .bl { font-size: .66rem; color: var(--muted); white-space: nowrap; }

.study-top { display: flex; align-items: center; gap: .7rem; padding: calc(.3rem + env(safe-area-inset-top)) 0 .4rem; }
.study-top .close { color: var(--muted); display: grid; place-items: center; width: 36px; height: 36px; margin-left: -.4rem; }
.bar.grow { flex: 1; width: auto; }
.flash { padding: 1.6rem 1.2rem 1.2rem; min-height: 180px; }
.f-word { font-size: 2.6rem; font-weight: 700; text-align: center; letter-spacing: -0.03em; line-height: 1.2; margin: .8rem 0 .6rem; }
.f-meaning { font-size: 1.6rem; font-weight: 700; text-align: center; line-height: 1.3; margin: .6rem 0 .4rem; }
.f-sub { text-align: center; color: var(--muted); font-size: .95rem; margin-bottom: .5rem; }
.pills.center { justify-content: center; }
.back { border-top: 1px solid var(--line); margin-top: 1.1rem; padding-top: 1rem; }
.b-head { display: flex; align-items: baseline; gap: .5rem; }
.b-word { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.03em; }
.b-hanja { font-size: 1.5rem; margin: .1rem 0 .3rem; }
ol.senses.compact { margin: .6rem 0 .3rem; }
ol.senses.compact > li { margin-bottom: .55rem; }
.groups { display: grid; gap: .6rem; margin-top: .9rem; }
.g-row { display: flex; gap: .4rem; align-items: flex-start; }
.tile.sm { width: 44px; min-height: 48px; font-size: 1.45rem; border-radius: 12px; }
.g-body { flex: 1; min-width: 0; margin-left: .3rem; }
.g-mean { font-weight: 600; font-size: .9rem; line-height: 1.35; }
.g-words { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .3rem; }
.mini { font-size: .82rem; padding: .1rem .5rem; border-radius: 99px; background: var(--surface-2); }
.mini.known { background: var(--g1-bg); color: var(--g1); }

.rate { display: grid; grid-template-columns: repeat(4, 1fr); gap: .4rem; margin-top: .6rem; position: sticky; bottom: calc(.6rem + env(safe-area-inset-bottom)); }
.rate button {
  border: 0; border-radius: 14px; padding: .65rem .2rem; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: .1rem; font-size: .92rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .08);
}
.rate button span { font-size: .75rem; opacity: .8; }
.rate .r0 { background: #fee2e2; color: #b91c1c; }
.rate .r1 { background: #fef3c7; color: #b45309; }
.rate .r2 { background: var(--g1-bg); color: var(--g1); }
.rate .r3 { background: var(--g2-bg); color: var(--g2); }
@media (prefers-color-scheme: dark) {
  .rate .r0 { background: rgba(239, 68, 68, .18); color: #fca5a5; }
  .rate .r1 { background: rgba(245, 158, 11, .18); color: #fcd34d; }
}

/* ---------- native / loanword / English search ---------- */
.pill.kind { background: var(--surface-2); color: var(--muted); }
.entry-hanja.loan, .b-hanja.loan { font-size: 1.2rem; color: var(--muted); font-style: italic; }
h3.sub { font-size: .9rem; margin: 1rem .2rem .3rem; color: var(--muted); font-weight: 700; }

/* ---------- review session: fixed header and rating bar, card scrolls between ---------- */
body[data-view="session"] main { height: 100vh; height: 100dvh; display: flex; flex-direction: column; padding-top: 0; padding-bottom: 0; }
.session { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.session .study-top { flex: none; }
.session-scroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; margin: 0 -.2rem; padding: 0 .2rem; }
.session-scroll .flash { margin-top: .2rem; }
.session-actions { flex: none; padding: .5rem 0 calc(.8rem + env(safe-area-inset-bottom)); }
.session-actions .rate { position: static; margin-top: 0; }
.session-actions .btn.big { margin-top: 0; }
.linkish { border: 0; background: none; color: var(--accent); font-weight: 600; font-size: .85rem; cursor: pointer; padding: .3rem .2rem; }
.resume { border-color: var(--accent); }

/* ---------- word page additions ---------- */
.sp { font-size: .85rem; color: var(--accent); background: var(--accent-soft); display: inline-block; padding: .1rem .55rem; border-radius: 8px; margin: .15rem 0 .3rem; }
.slot { font-size: .95em; margin: 0 1px; }
.related { display: grid; gap: .6rem; }
.rel-row { display: flex; gap: .6rem; align-items: baseline; }
.rel-label { flex: none; width: 4.5rem; font-size: .85rem; font-weight: 700; color: var(--muted); }
.rel-words { display: flex; flex-wrap: wrap; gap: .4rem; }
.rel-words .chip { box-shadow: none; padding: .3rem .7rem; }
.pill.bad { background: #fee2e2; color: #b91c1c; }
@media (prefers-color-scheme: dark) { .pill.bad { background: rgba(239, 68, 68, .18); color: #fca5a5; } }

/* ---------- home ---------- */
.explore { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin-top: .6rem; }
.linkcard { display: flex; align-items: center; justify-content: space-between; gap: .5rem; color: var(--fg); flex-wrap: wrap; }
.explore .linkcard { flex-direction: column; align-items: flex-start; margin: 0; }
.update { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- picker ---------- */
.picker { margin: .2rem 0 .6rem; }
.pk-label { font-size: .8rem; font-weight: 700; color: var(--muted); margin: .5rem 0 .3rem; }
.themes-pick { border: 1px solid var(--line); border-radius: 12px; padding: .5rem .8rem; background: var(--surface); }
.themes-pick summary { cursor: pointer; font-weight: 600; font-size: .92rem; }
.tgroups { max-height: 50vh; overflow-y: auto; margin-top: .5rem; }
.tg { margin-bottom: .6rem; }
.tg-title { font-size: .78rem; font-weight: 700; color: var(--muted); margin: .4rem 0 .2rem; position: sticky; top: 0; background: var(--surface); }
.tcheck { display: flex; align-items: center; gap: .5rem; padding: .3rem 0; font-size: .92rem; }
.tcheck input { width: 18px; height: 18px; accent-color: var(--accent); }
.tcheck small { margin-left: auto; color: var(--muted); }
details.scope summary { cursor: pointer; display: flex; gap: .5rem; align-items: baseline; }
.btn:disabled { opacity: .45; cursor: default; }

/* ---------- hanja ---------- */
.hk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: .5rem; }
.hk { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: .6rem .5rem; color: var(--fg);
  display: flex; flex-direction: column; align-items: center; gap: .2rem; box-shadow: var(--shadow); }
.hk-h { font-size: 2rem; line-height: 1.1; }
.hk-r { font-size: .8rem; font-weight: 700; color: var(--accent); }
.hk .progress { width: 100%; margin-top: .2rem; }
.hk-c { font-size: .72rem; color: var(--muted); }
.hd-top { display: flex; gap: 1rem; align-items: center; }
.hd-h { font-size: 4rem; line-height: 1; width: 92px; height: 92px; display: grid; place-items: center; background: var(--accent-soft); border-radius: 20px; flex: none; }
.hd-info { flex: 1; min-width: 0; display: grid; gap: .25rem; }
.hd-r { font-size: 1.3rem; font-weight: 700; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin: 1rem 0 .5rem; }
.facts div { background: var(--surface-2); border-radius: 12px; padding: .5rem .6rem; }
.facts dt { font-size: .72rem; color: var(--muted); font-weight: 700; }
.facts dd { margin: 0; font-weight: 700; font-size: 1.05rem; }

/* ---------- charts ---------- */
.chart { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; align-items: end; }
.chart .col { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; }
.chart .ct { width: 100%; height: 80px; background: var(--surface-2); border-radius: 5px; display: flex; align-items: flex-end; overflow: hidden; }
.chart .ct span { width: 100%; background: var(--accent); border-radius: 5px 5px 0 0; }
.chart.thin .ct span { background: var(--known); }
.chart .cv { font-size: .62rem; color: var(--muted); min-height: .9em; }
.chart .cl { font-size: .6rem; color: var(--muted); white-space: nowrap; min-height: .9em; }
.streak { margin-bottom: .6rem; } .streak b { font-size: 1.4rem; color: var(--known); }

/* ---------- about ---------- */
.about h3 { font-size: .95rem; margin: 1rem 0 .3rem; } .about h3:first-child { margin-top: 0; }
.about p { margin: .3rem 0; font-size: .9rem; }
.filter-row.wrap { flex-wrap: wrap; overflow: visible; -webkit-mask-image: none; mask-image: none; padding-right: .1rem; }
.tgroups { padding-right: .9rem; scrollbar-gutter: stable; }
.card-rel { margin-top: .7rem; }
.set-row { flex-wrap: wrap; row-gap: .4rem; }
.set-label { flex: 1 1 9rem; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-tag { font-size: .72rem; color: var(--muted); font-weight: 500; }
body:not([data-view="home"]) .brand-tag { display: none; }
body[data-view="home"] .brand-tag { font-size: .8rem; margin-top: .15rem; }
.splash-tag { font-size: .85rem; margin-top: -.5rem; }
.native-note { margin: .8rem 0 .2rem; padding: .6rem .8rem; border-radius: 12px; background: var(--g1-bg); color: var(--g1); font-size: .9rem; }
