/* LexDecks 2 — calm, precise, mobile-first.
   One accent, warm neutrals, serif for the law, sans for the interface. */
:root {
  --accent: #2f55d4;
  --accent-hover: #2749bd;
  --accent-ink: #ffffff;
  --accent-soft: #edf1fd;
  --accent-line: #cdd8f8;
  --bg: #f6f6f3;
  --surface: #ffffff;
  --surface-2: #fbfbf9;
  --text: #16171a;
  --text-2: #3a3c42;
  --muted: #6c6f77;
  --faint: #9a9da5;
  --line: #e8e7e2;
  --line-strong: #d9d8d2;
  --good: #1f7a4d;
  --good-soft: #e7f4ec;
  --warn: #9a5b00;
  --warn-soft: #fbf1e0;
  --danger: #bf3228;
  --danger-soft: #fbeceb;
  --radius: 16px;
  --radius-sm: 11px;
  --shadow: 0 1px 1px rgba(22, 23, 26, .03), 0 2px 6px rgba(22, 23, 26, .04);
  --shadow-lg: 0 24px 64px rgba(15, 17, 25, .18), 0 2px 8px rgba(15, 17, 25, .06);
  --sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Charter, "Bitstream Charter", Georgia, "Noto Serif", "DejaVu Serif", serif;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 0px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --accent: #8fa6ff;
  --accent-hover: #a5b7ff;
  --accent-ink: #0b1026;
  --accent-soft: #1b2140;
  --accent-line: #2d3766;
  --bg: #0f1012;
  --surface: #17181b;
  --surface-2: #1b1c20;
  --text: #ededeb;
  --text-2: #cfd0d3;
  --muted: #a1a3aa;
  --faint: #73767e;
  --line: #27282d;
  --line-strong: #34363c;
  --good: #6fd19b;
  --good-soft: #15291f;
  --warn: #f0b561;
  --warn-soft: #2a2114;
  --danger: #ff8a80;
  --danger-soft: #2c1716;
  --shadow: none;
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, .55);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body { background: var(--bg); color: var(--text); font: 16px/1.55 var(--sans); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; min-height: 100vh; min-height: 100dvh; overflow-x: hidden; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
h1 { font-size: 1.85rem; line-height: 1.15; letter-spacing: -.025em; margin: 0 0 .5rem; font-weight: 700; }
h2 { font-size: 1.1rem; line-height: 1.3; letter-spacing: -.01em; margin: 0; font-weight: 650; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.eyebrow { font-size: .74rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 650; margin: 0 0 .3rem; }
.sub { color: var(--muted); margin: .1rem 0 0; font-size: .95rem; }
.fine { color: var(--faint); font-size: .8rem; margin-top: 1.5rem; line-height: 1.5; }
.linklike { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: .35rem; }
.linklike:hover { text-decoration: underline; }

/* ---------- top bar & navigation ---------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 1rem; padding: .65rem max(1rem, calc((100vw - 760px) / 2)); background: color-mix(in srgb, var(--bg) 84%, transparent); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px); border-bottom: 1px solid transparent; }
.brand { display: flex; align-items: center; gap: .55rem; text-decoration: none; font-weight: 700; font-size: 1.05rem; letter-spacing: -.015em; margin-right: auto; }
.brand img { border-radius: 7px; }
.topnav { display: none; gap: .25rem; }
.topnav a { text-decoration: none; color: var(--muted); font-weight: 600; font-size: .93rem; padding: .45rem .8rem; border-radius: 10px; transition: color .15s, background .15s; }
.topnav a:hover { color: var(--text); }
.topnav a[aria-current="page"] { color: var(--text); background: var(--surface); box-shadow: var(--shadow); }
:root[data-theme="dark"] .topnav a[aria-current="page"] { background: var(--line); }
.icon-btn { display: inline-grid; place-items: center; width: 42px; height: 42px; flex: 0 0 auto; border-radius: 12px; border: 0; background: transparent; color: var(--muted); cursor: pointer; text-decoration: none; transition: background .15s, color .15s; }
.icon-btn:hover { background: color-mix(in srgb, var(--text) 6%, transparent); color: var(--text); }
.icon-btn[aria-current="page"] { color: var(--text); }
.icon-btn:disabled { opacity: .3; cursor: default; background: transparent; }
.icon-btn.inline { width: 34px; height: 34px; vertical-align: middle; margin-left: .15rem; }
body.studying .topbar, body.studying .tabbar { display: none; }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(3, 1fr); padding: .35rem .5rem calc(.35rem + var(--safe-b)); background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: saturate(1.4) blur(16px); -webkit-backdrop-filter: saturate(1.4) blur(16px); border-top: 1px solid var(--line); }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: .1rem; padding: .3rem 0; text-decoration: none; color: var(--faint); font-size: .7rem; font-weight: 600; letter-spacing: .01em; border-radius: 12px; transition: color .15s; }
.tabbar a[aria-current="page"] { color: var(--accent); }
body { --tabbar-h: calc(62px + var(--safe-b)); }
@media (min-width: 720px) {
  .topnav { display: flex; }
  .tabbar { display: none; }
  body { --tabbar-h: 0px; }
}

main { max-width: 760px; margin: 0 auto; padding: .75rem 1.25rem calc(4rem + var(--tabbar-h)); outline: none; }
main.enter > section { animation: enter .32s var(--ease) both; }
@keyframes enter { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.boot { padding: 4rem 0; text-align: center; color: var(--muted); }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 44px; padding: .55rem 1.1rem; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer; text-decoration: none; font-weight: 600; font-size: .95rem; white-space: nowrap; transition: transform .08s var(--ease), background .15s, border-color .15s, box-shadow .15s, filter .15s; }
.btn:hover { border-color: color-mix(in srgb, var(--text) 22%, var(--line)); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 1px 2px color-mix(in srgb, var(--accent) 30%, transparent), inset 0 1px 0 rgba(255, 255, 255, .12); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.soft { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.btn.soft:hover { border-color: var(--accent-line); }
.btn.quiet { background: transparent; border-color: transparent; color: var(--muted); padding: .5rem .7rem; }
.btn.quiet:hover { color: var(--text); background: color-mix(in srgb, var(--text) 5%, transparent); }
.btn.added { color: var(--good); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--accent); white-space: normal; }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.big { min-height: 54px; font-size: 1.02rem; padding: .8rem 1.5rem; border-radius: 14px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn-sub { font-weight: 500; opacity: .78; font-size: .88rem; margin-left: .15rem; }
.btn-sub::before { content: "·"; margin-right: .45rem; }
.dot-spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
.back { display: inline-flex; align-items: center; gap: .2rem; color: var(--muted); text-decoration: none; font-weight: 550; font-size: .93rem; margin: .25rem 0 .9rem -.3rem; min-height: 36px; padding: 0 .3rem; border-radius: 8px; }
.back:hover { color: var(--text); }

/* ---------- home ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin: 1.1rem 0 1.4rem; }
.page-head h1 { margin: 0; }
.page-head.tight { margin-top: 0; }
.decks, .decks ul { list-style: none; margin: 0; padding: 0; }
.decks > li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: .75rem; overflow: hidden; }
.decks ul { border-top: 1px solid var(--line); }
.decks ul li + li { border-top: 1px solid var(--line); }
.deck-row { display: flex; align-items: center; gap: .5rem; padding: .8rem 1rem; padding-left: calc(.5rem + var(--depth, 0) * 1.1rem); }
.caret, .caret-space { flex: 0 0 30px; width: 30px; height: 30px; }
.caret { border: 0; background: transparent; border-radius: 8px; cursor: pointer; color: var(--faint); display: grid; place-items: center; transition: transform .2s var(--ease), background .15s; }
.caret[aria-expanded="true"] { transform: rotate(90deg); }
.caret:hover { background: var(--bg); color: var(--text); }
.deck-main { flex: 1; min-width: 0; display: flex; flex-direction: column; text-decoration: none; padding: .15rem 0; }
.deck-name { font-weight: 620; letter-spacing: -.005em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deck-meta { color: var(--muted); font-size: .84rem; font-variant-numeric: tabular-nums; }
.deck-meta b { color: var(--accent); font-weight: 650; }
.deck-row .btn.study { min-width: 84px; min-height: 40px; padding: .45rem .9rem; }
.deck-row .btn.done { color: var(--faint); background: transparent; border-color: transparent; cursor: default; }
.home-foot { text-align: center; margin-top: 2rem; color: var(--faint); }

/* exam countdown */
.countdown { display: flex; gap: 1.1rem; align-items: center; text-decoration: none; background: linear-gradient(135deg, var(--accent-soft), color-mix(in srgb, var(--accent-soft) 40%, var(--surface))); border: 1px solid var(--accent-line); border-radius: var(--radius); padding: 1rem 1.15rem; margin: .75rem 0 .5rem; transition: transform .15s var(--ease); }
.countdown:hover { transform: translateY(-1px); }
.countdown + .countdown { margin-top: .6rem; }
.cd-num { flex: 0 0 auto; width: 64px; text-align: center; color: var(--accent); }
.cd-num b { display: block; font-size: 2.1rem; line-height: 1; font-weight: 700; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.cd-num span { font-size: .75rem; font-weight: 650; text-transform: uppercase; letter-spacing: .08em; }
.cd-body { flex: 1; min-width: 0; }
.cd-body .eyebrow { color: var(--accent); margin: 0; }
.cd-title { font-weight: 650; margin: .05rem 0 .5rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cd-meta { font-size: .82rem; color: var(--muted); margin: .4rem 0 0; font-variant-numeric: tabular-nums; }
.meter { height: 6px; border-radius: 99px; background: color-mix(in srgb, var(--accent) 14%, transparent); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width .6s var(--ease); }
.meter.small { display: inline-block; width: 44px; height: 5px; vertical-align: middle; margin-right: .5rem; background: color-mix(in srgb, var(--danger) 14%, transparent); }
.meter.small i { background: var(--danger); }

/* empty state */
.empty { text-align: center; padding: 2.5rem 0 1rem; }
.empty h1 { margin: 1.25rem auto .6rem; font-size: 2rem; max-width: 22rem; }
.empty .lead { color: var(--muted); max-width: 29rem; margin: 0 auto 1.75rem; font-size: 1.02rem; }
.empty-alt { display: flex; gap: .6rem; justify-content: center; align-items: center; flex-wrap: wrap; margin: 1.25rem 0 .5rem; }
.empty-alt a { color: var(--accent); font-weight: 600; text-decoration: none; }
.empty-alt a:hover { text-decoration: underline; }
.empty-alt span { color: var(--faint); }
.empty-card { text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 2.25rem 1.5rem; }
.empty-card h2 { margin: .9rem 0 .4rem; }
.empty-card .tile-ic { margin: 0 auto; }
.dropzone { border: 2px dashed var(--line); border-radius: 18px; padding: 2rem 1.25rem; background: var(--surface); }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- library ---------- */
.subject { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.subject-head { padding: 1.2rem 1.25rem .9rem; }
.subject-head h2 { font-size: 1.35rem; letter-spacing: -.02em; }
.lib-decks { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.lib-decks li { display: flex; align-items: center; gap: 1rem; padding: 1rem 1.25rem; }
.lib-decks li + li { border-top: 1px solid var(--line); }
.lib-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .1rem; }
.lib-title { font-weight: 650; }
.lib-desc { color: var(--text-2); font-size: .9rem; line-height: 1.4; }
.lib-meta { color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums; }
.lib-decks .btn { min-width: 96px; }
details.inside { border-top: 1px solid var(--line); padding: 0 1.25rem; }
details.inside > summary { cursor: pointer; list-style: none; padding: .9rem 0; color: var(--muted); font-weight: 600; font-size: .9rem; display: flex; align-items: center; gap: .4rem; }
details.inside > summary::-webkit-details-marker { display: none; }
details.inside > summary::after { content: ""; width: 7px; height: 7px; border-right: 1.8px solid currentColor; border-bottom: 1.8px solid currentColor; transform: rotate(45deg) translateY(-2px); margin-left: .2rem; transition: transform .2s var(--ease); }
details.inside[open] > summary::after { transform: rotate(-135deg) translateY(-1px); }
details.inside[open] { padding-bottom: .6rem; }
details.inside a { color: var(--accent); }
section > details.inside { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin: 1.25rem 0; }
.soon { margin: 1.5rem .25rem; color: var(--muted); font-size: .9rem; }
.soon .eyebrow { display: block; }

/* ---------- practice ---------- */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.tile { display: flex; flex-direction: column; gap: .25rem; padding: 1.1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); text-decoration: none; transition: transform .15s var(--ease), border-color .15s; min-height: 150px; }
.tile:hover { transform: translateY(-2px); border-color: var(--accent-line); }
.tile-ic { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); margin-bottom: .5rem; }
.tile-t { font-weight: 650; letter-spacing: -.01em; }
.tile-d { color: var(--muted); font-size: .86rem; line-height: 1.45; }
.lookup { margin-top: 1.25rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; }
.lookup label { display: flex; align-items: center; gap: .45rem; font-weight: 650; margin-bottom: .6rem; color: var(--text); }
.lookup label svg { color: var(--accent); }
.lookup-row { display: flex; gap: .5rem; align-items: center; }
.lookup-pre { color: var(--muted); font-family: var(--serif); font-size: 1.05rem; }
.lookup-row .input { flex: 1; min-width: 0; font-variant-numeric: tabular-nums; }

/* syllabus */
.title-lg { font-size: 1.55rem; margin-bottom: 1.25rem; }
.modules, .topics, .weak-list, .case-list { list-style: none; margin: 0; padding: 0; }
.modules { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.modules li + li, .topics li + li, .weak-list li + li { border-top: 1px solid var(--line); }
.mod-row { display: flex; align-items: center; gap: .9rem; padding: .9rem 1rem; text-decoration: none; }
a.mod-row:hover, a.topic:hover { background: var(--surface-2); }
.mod-row.off { opacity: .55; }
.mod-id { flex: 0 0 auto; min-width: 2.4rem; height: 2.4rem; padding: 0 .4rem; border-radius: 10px; display: grid; place-items: center; background: var(--bg); color: var(--muted); font-weight: 700; font-size: .82rem; font-family: var(--serif); }
a.mod-row .mod-id { background: var(--accent-soft); color: var(--accent); }
.mod-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mod-title { font-weight: 600; line-height: 1.35; font-size: .95rem; }
.mod-meta { color: var(--muted); font-size: .8rem; margin-top: .15rem; font-variant-numeric: tabular-nums; }
.chev { color: var(--faint); display: inline-flex; }
.pill { font-size: .75rem; font-weight: 650; color: var(--accent); background: var(--accent-soft); padding: .2rem .6rem; border-radius: 99px; }
.topics { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.topics li { display: flex; align-items: center; }
.topic { flex: 1; min-width: 0; display: grid; grid-template-columns: auto 1fr; grid-template-areas: "art meta" "text text"; gap: .2rem .75rem; padding: .85rem 1rem; text-decoration: none; }
.topic-art { grid-area: art; font-family: var(--serif); font-weight: 700; color: var(--accent); font-size: .98rem; }
.topic-text { grid-area: text; color: var(--text-2); font-size: .9rem; line-height: 1.45; font-family: var(--serif); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.topic-text.strong { font-family: var(--sans); font-weight: 600; color: var(--text); font-size: .95rem; }
.topic-meta { grid-area: meta; justify-self: end; color: var(--muted); font-size: .78rem; display: inline-flex; align-items: center; gap: .25rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.topic-meta svg { width: 14px; height: 14px; color: var(--good); }
.bar-row { grid-template-areas: "text meta"; grid-template-columns: 1fr auto; align-items: center; }
.bar-row .topic-text { -webkit-line-clamp: 2; }
.topics .read { margin-right: .5rem; color: var(--faint); }
.topics .read:hover { color: var(--accent); }
.case-list { padding: 0 0 .5rem; columns: 1; }
.case-list li { font-size: .88rem; color: var(--text-2); padding: .3rem 0; border-top: 1px solid var(--line); }
.diff { text-transform: capitalize; font-weight: 650; font-size: .74rem; letter-spacing: .02em; padding: .1rem .5rem; border-radius: 99px; background: var(--good-soft); color: var(--good); }
.diff.medium { background: var(--warn-soft); color: var(--warn); }
.diff.hard { background: var(--danger-soft); color: var(--danger); }
.eyebrow .diff { letter-spacing: .02em; }

/* weak spots */
.weak-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 1.25rem; counter-reset: w; }
.weak-list li { display: grid; grid-template-columns: auto 1fr; grid-template-areas: "art meta" "text text"; gap: .25rem .75rem; padding: .85rem 1rem; align-items: center; }
.weak-art { grid-area: art; justify-self: start; border: 0; background: none; padding: 0; font: 700 .98rem var(--serif); color: var(--accent); cursor: pointer; text-decoration: underline dotted 1.5px; text-underline-offset: 3px; }
.weak-text { grid-area: text; color: var(--text-2); font: .9rem/1.45 var(--serif); }
.weak-meta { grid-area: meta; justify-self: end; font-size: .8rem; color: var(--danger); font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.sticky-cta { position: sticky; bottom: calc(var(--tabbar-h) + .75rem); box-shadow: 0 10px 30px color-mix(in srgb, var(--accent) 25%, transparent); }

/* ---------- recitation ---------- */
.recit-panel { padding: 1.4rem; }
.recit-top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .75rem; }
.recit-top .eyebrow { margin: 0; color: var(--accent); }
.steps-dots { display: inline-flex; gap: 5px; }
.steps-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); transition: background .2s, transform .2s var(--ease); }
.steps-dots i.done { background: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.steps-dots i.on { background: var(--accent); transform: scale(1.25); }
.recit-q { font-family: var(--serif); font-size: 1.28rem; line-height: 1.5; letter-spacing: -.005em; margin: 0 0 1rem; }
.recit-hint { margin: 0 0 1rem; }
.recit-a { border-top: 1px solid var(--line); padding-top: 1rem; margin-bottom: 1rem; font-family: var(--serif); font-size: 1.06rem; line-height: 1.62; color: var(--text-2); animation: enter .28s var(--ease) both; }
.recit-a .eyebrow { font-family: var(--sans); }
.recit-actions { margin-top: .5rem; position: sticky; bottom: calc(var(--tabbar-h) + .5rem); z-index: 2; }
.recit-actions::before { content: ""; position: absolute; inset: -1.25rem -.5rem -.5rem; background: linear-gradient(to top, var(--surface) 65%, transparent); z-index: -1; pointer-events: none; }
#recitDlg .recit-actions { bottom: 0; }
.rate3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.recit-done { text-align: center; padding: 1rem 0 .25rem; }
.recit-done .badge { width: 60px; height: 60px; margin: 0 auto 1rem; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.recit-done h2 { font-size: 1.3rem; margin-bottom: .35rem; }
.recit-end { display: grid; gap: .6rem; max-width: 22rem; margin: 1.25rem auto 0; justify-items: center; }
.recit-pill { display: flex; align-items: center; gap: .6rem; width: 100%; margin: 1.5rem 0 0; padding: .8rem 1rem; border: 1px solid var(--line); background: var(--surface); border-radius: 14px; cursor: pointer; text-align: left; font-weight: 600; color: var(--text); animation: enter .3s var(--ease) both; transition: border-color .15s; }
.recit-pill:hover { border-color: var(--accent-line); }
.recit-pill > svg { color: var(--accent); flex: 0 0 auto; }
.recit-pill > span:first-of-type { flex: 1; }
.art-ref { border: 0; background: none; padding: 0; font: inherit; color: var(--accent); font-weight: 650; cursor: pointer; text-decoration: underline dotted 1.5px; text-underline-offset: 3px; }
.art-ref:hover { text-decoration-style: solid; }

/* ---------- bar practice ---------- */
.facts { font-family: var(--serif); font-size: 1.08rem; line-height: 1.65; color: var(--text-2); margin: .75rem 0 1rem; }
.bar-q { font-family: var(--serif); font-size: 1.15rem; line-height: 1.55; font-weight: 700; margin: 0 0 1.4rem; }
.answer-box { min-height: 12rem; resize: vertical; line-height: 1.6; background: var(--surface); padding: .85rem 1rem; font-size: 1rem; }
.answer-box.done { color: var(--text-2); background: var(--surface-2); }
.alac { display: grid; gap: .6rem; }
.alac-row { display: grid; grid-template-columns: 34px 1fr; gap: .85rem; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: .95rem 1rem; }
.alac-l { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font: 700 .95rem var(--serif); }
.alac-k { font-size: .74rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 650; margin: 0 0 .25rem; font-family: var(--sans); }
.alac-row p:not(.alac-k), .callout p:not(.alac-k) { font-family: var(--serif); line-height: 1.6; margin: 0 0 .4rem; }
.points { margin: 0; padding: 0 0 .25rem 1.1rem; font-size: .93rem; color: var(--text-2); }
.points li { margin: .3rem 0; }
.callout { background: var(--warn-soft); border-radius: 14px; padding: .95rem 1rem; margin: 1rem 0; }
.callout .alac-k { color: var(--warn); }
.grader-notes { list-style: none; margin: 0 0 .9rem; padding: 0; display: grid; gap: .4rem; }
.grader-notes li { font-size: .88rem; color: var(--text-2); background: var(--surface); border: 1px dashed var(--line-strong); border-radius: 10px; padding: .55rem .8rem; }
.checklist { display: grid; gap: .5rem; }
.check { display: flex; gap: .8rem; align-items: flex-start; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: .85rem 1rem; cursor: pointer; transition: border-color .15s, background .15s; }
.check input { position: absolute; opacity: 0; pointer-events: none; }
.check .box { flex: 0 0 auto; width: 24px; height: 24px; border-radius: 8px; border: 1.8px solid var(--line-strong); display: grid; place-items: center; color: transparent; transition: all .15s var(--ease); margin-top: 1px; }
.check .box svg { width: 15px; height: 15px; }
.check input:checked + .box { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.check input:focus-visible + .box { outline: 2px solid var(--accent); outline-offset: 2px; }
.check:has(input:checked) { border-color: var(--accent-line); background: color-mix(in srgb, var(--accent-soft) 45%, var(--surface)); }
.check b { display: block; font-weight: 650; }
.check small { color: var(--muted); font-size: .84rem; }
.score { font-weight: 650; margin: 1rem 0 0; color: var(--text-2); }
.form-actions.end { justify-content: flex-end; }

/* ---------- deck page ---------- */
.crumbs { color: var(--muted); font-size: .85rem; margin: 0 0 .25rem; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; margin: 1.4rem 0; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .95rem .75rem; text-align: center; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 1.65rem; font-weight: 700; line-height: 1.1; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: .8rem; }
.stat.accent b { color: var(--accent); }
.links { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin: 1.25rem 0; overflow: hidden; box-shadow: var(--shadow); }
.links a, .links button.linkrow { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: .95rem 1.1rem; text-decoration: none; font-weight: 550; border: 0; background: none; cursor: pointer; text-align: left; }
.links > * + * { border-top: 1px solid var(--line) !important; }
.links a:hover, .links button.linkrow:hover { background: var(--surface-2); }
.links .chev { color: var(--faint); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.15rem 1.2rem; margin: .9rem 0; box-shadow: var(--shadow); }
.panel h2 { margin-bottom: .35rem; font-size: 1rem; }
.panel > .muted:last-child { margin-bottom: 0; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.nowrap { flex-wrap: nowrap; }
.field-label { display: block; font-weight: 600; font-size: .9rem; margin: 0 0 .35rem; }
.field-label.with-ic { display: inline-flex; align-items: center; gap: .45rem; margin: 0; }
.field-label.with-ic svg { color: var(--accent); }
.exam-panel .muted { margin: .6rem 0 0; }
.input { width: 100%; min-height: 44px; padding: .55rem .8rem; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--bg); transition: border-color .15s, box-shadow .15s; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.input.num { width: 7rem; }
.input.date { width: auto; min-width: 0; font-variant-numeric: tabular-nums; }
.row .input { flex: 1; min-width: 10rem; }
.row .input.num { flex: 0 0 7rem; min-width: 0; }
.row .input.date { flex: 0 1 auto; min-width: 0; }
.section-title { margin: 2rem 0 .7rem; font-size: .74rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 650; }
details.more { margin-top: 1.5rem; }
details.more > summary { list-style: none; cursor: pointer; color: var(--muted); font-weight: 600; font-size: .92rem; padding: .6rem 0; display: inline-flex; align-items: center; gap: .45rem; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::after { content: ""; width: 7px; height: 7px; border-right: 1.8px solid currentColor; border-bottom: 1.8px solid currentColor; transform: rotate(45deg) translateY(-2px); transition: transform .2s var(--ease); }
details.more[open] > summary::after { transform: rotate(-135deg) translateY(-1px); }
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 3px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: .5rem .95rem; border-radius: 9px; cursor: pointer; font-weight: 580; color: var(--muted); min-height: 38px; transition: background .15s, color .15s; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }
:root[data-theme="dark"] .seg button[aria-pressed="true"] { background: var(--line-strong); }

/* ---------- browse ---------- */
.search { position: relative; margin: 1rem 0 .5rem; }
.search svg { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search .input { padding-left: 2.5rem; background: var(--surface); }
.note-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.note-list li + li { border-top: 1px solid var(--line); }
.note-list a { display: grid; grid-template-columns: 1fr auto; gap: .15rem 1rem; padding: .85rem 1rem; text-decoration: none; }
.note-list a:hover { background: var(--surface-2); }
.note-list .q { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-list .a { color: var(--muted); font-size: .875rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; grid-column: 1; }
.note-list .st { grid-row: 1 / span 2; grid-column: 2; align-self: center; font-size: .78rem; color: var(--muted); white-space: nowrap; }
.note-list .st.new { color: var(--accent); }
.list-empty { padding: 2rem; text-align: center; color: var(--muted); }

/* ---------- editor ---------- */
.editor .fld { margin: 0 0 1rem; }
.rich { min-height: 3.2rem; padding: .7rem .85rem; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); font-family: var(--serif); font-size: 1.1rem; line-height: 1.55; overflow-wrap: anywhere; }
.rich:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.rich:empty::before { content: attr(data-placeholder); color: var(--faint); }
.rich img { max-width: 100%; height: auto; }
.toolbar { display: flex; gap: .35rem; margin: 0 0 .75rem; flex-wrap: wrap; }
.toolbar button { min-width: 40px; height: 38px; border: 1px solid var(--line-strong); background: var(--surface); border-radius: 9px; cursor: pointer; padding: 0 .7rem; font-weight: 600; }
.toolbar .cloze-btn { color: var(--accent); }
.form-actions { display: flex; gap: .75rem; align-items: center; justify-content: space-between; margin-top: 1.5rem; flex-wrap: wrap; }

/* ---------- study ---------- */
body.studying main { max-width: none; padding: 0; }
.study-screen { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
.study-bar { position: sticky; top: 0; z-index: 5; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: .5rem max(.5rem, calc((100vw - 760px) / 2)); background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.study-bar .left-count { font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; font-size: .92rem; text-align: center; }
.focus-title { color: var(--text); }
.study-bar .end { justify-self: end; }
.study-body { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; padding: 1.75rem 1.5rem calc(9rem + var(--safe-b)); }
.practice-note { display: inline-block; font-size: .78rem; font-weight: 600; color: var(--warn); background: var(--warn-soft); padding: .25rem .65rem; border-radius: 99px; margin: 0 0 1rem; }
.card-host { display: block; min-height: 38vh; animation: enter .25s var(--ease) both; }
.study-actions { position: fixed; left: 0; right: 0; bottom: 0; padding: .75rem max(.75rem, calc((100vw - 760px) / 2)) calc(.75rem + var(--safe-b)); background: linear-gradient(to top, var(--bg) 72%, color-mix(in srgb, var(--bg) 0%, transparent)); }
.reveal { width: 100%; min-height: 58px; font-size: 1.05rem; border-radius: 16px; }
.kbd { font-size: .72rem; opacity: .55; font-weight: 500; margin-left: .4rem; border: 1px solid currentColor; border-radius: 5px; padding: 0 .3rem; line-height: 1.4; }
.answers { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; }
.ans { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .05rem; min-height: 62px; border-radius: 15px; border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer; font-weight: 650; padding: .4rem .25rem; transition: transform .08s var(--ease), border-color .15s; }
.ans:hover { border-color: color-mix(in srgb, var(--text) 25%, var(--line)); }
.ans:active { transform: scale(.96); }
.ans .ivl { font-size: .76rem; color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.ans.again .lbl { color: var(--danger); }
.ans.hard .lbl { color: var(--warn); }
.ans.good { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.ans.good .lbl { color: var(--accent-ink); }
.ans.good .ivl { color: color-mix(in srgb, var(--accent-ink) 75%, transparent); }
.rate3 .ans { min-height: 54px; }
.finish { text-align: center; padding: 16vh 1.25rem 2rem; max-width: 30rem; margin: 0 auto; }
.finish .badge { width: 72px; height: 72px; margin: 0 auto 1.25rem; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); animation: pop .4s var(--ease) both; }
@keyframes pop { from { transform: scale(.7); opacity: 0; } to { transform: none; opacity: 1; } }
.finish h1 { margin-bottom: .5rem; }

/* ---------- dialogs & reader sheet ---------- */
dialog.sheet { border: 0; border-radius: 22px; padding: 0; width: min(520px, calc(100vw - 2rem)); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
dialog.sheet.small { width: min(420px, calc(100vw - 2rem)); }
dialog[open] { animation: dlg-in .28s var(--ease) both; }
@keyframes dlg-in { from { opacity: 0; transform: translateY(12px) scale(.985); } to { opacity: 1; transform: none; } }
dialog::backdrop { background: rgba(12, 14, 22, .42); backdrop-filter: blur(2px); }
dialog.reader { width: min(640px, calc(100vw - 2rem)); max-height: min(86vh, 900px); overflow: hidden; }
.reader-inner { display: flex; flex-direction: column; max-height: inherit; }
.sheet-head { display: flex; align-items: center; gap: .5rem; padding: .85rem .85rem .6rem 1.25rem; border-bottom: 1px solid var(--line); position: relative; }
.sheet-title { flex: 1; min-width: 0; }
.sheet-title .eyebrow { margin: 0; }
.sheet-title h2 { font-size: 1.3rem; letter-spacing: -.02em; font-family: var(--serif); }
.grab { display: none; }
.sheet-body { overflow-y: auto; padding: 1.1rem 1.35rem 1.4rem; overscroll-behavior: contain; }
.where { color: var(--muted); font-size: .8rem; margin: 0 0 .9rem; line-height: 1.45; }
.codal-text { font-family: var(--serif); font-size: 1.1rem; line-height: 1.7; color: var(--text); }
.codal-text p { margin: 0 0 .85rem; }
.art-no { font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: .45rem; }
.chip { border: 1px solid var(--line-strong); background: var(--surface); border-radius: 99px; padding: .4rem .85rem; cursor: pointer; font-weight: 600; font-size: .88rem; font-family: var(--serif); color: var(--accent); transition: border-color .15s, background .15s; }
.chip:hover { border-color: var(--accent-line); background: var(--accent-soft); }
#recitDlg .sheet-body { padding-top: 1.25rem; }
.dlg { padding: 1.5rem; }
.dlg h2 { font-size: 1.25rem; margin-bottom: .5rem; }
.dlg .actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.5rem; flex-wrap: wrap; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; margin: 1.5rem auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.ok-badge { width: 52px; height: 52px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; margin-bottom: 1rem; }
.warn { background: var(--warn-soft); border-radius: 10px; padding: .6rem .8rem; font-size: .875rem; margin-top: .75rem; }
.err { color: var(--danger); }

.drop-overlay { position: fixed; inset: 0; z-index: 50; background: color-mix(in srgb, var(--accent) 14%, transparent); display: grid; place-items: center; pointer-events: none; }
.drop-overlay div { background: var(--surface); padding: 1.25rem 1.75rem; border-radius: 16px; box-shadow: var(--shadow-lg); border: 2px dashed var(--accent); font-size: 1.05rem; }

.toast { position: fixed; left: 50%; bottom: calc(1.5rem + var(--tabbar-h)); transform: translateX(-50%); z-index: 60; background: var(--text); color: var(--bg); padding: .7rem 1.1rem; border-radius: 12px; font-weight: 550; font-size: .93rem; box-shadow: 0 8px 30px rgba(0, 0, 0, .2); max-width: calc(100vw - 2rem); animation: toast .25s var(--ease) both; }
@keyframes toast { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
body.studying .toast { bottom: calc(7rem + var(--safe-b)); }

.prose p { color: var(--text); }
.prose .muted { color: var(--muted); }

/* ---------- phone ---------- */
@media (max-width: 560px) {
  main { padding: .5rem 1rem calc(3rem + var(--tabbar-h)); }
  h1 { font-size: 1.6rem; }
  .empty h1 { font-size: 1.7rem; }
  .page-head { margin: .75rem 0 1.1rem; }
  .hide-sm { display: none; }
  .deck-row { padding: .7rem .75rem; padding-left: calc(.25rem + var(--depth, 0) * .8rem); }
  .deck-row .btn.study { min-width: 72px; padding: .45rem .75rem; }
  .stats { gap: .5rem; }
  .stat { padding: .8rem .5rem; }
  .tiles { gap: .6rem; }
  .tile { padding: .95rem; min-height: 0; }
  .tile-d { font-size: .82rem; }
  .lib-decks li { flex-wrap: wrap; gap: .75rem; }
  .lib-decks .btn { min-width: 0; }
  .study-body { padding: 1.1rem 1.15rem calc(9rem + var(--safe-b)); }
  .ans { min-height: 66px; }
  .recit-panel { padding: 1.1rem; }
  .recit-q { font-size: 1.16rem; }
  .row.between { align-items: flex-start; }
  /* reader becomes a bottom sheet */
  dialog.reader { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 22px 22px 0 0; max-height: 90vh; padding-bottom: var(--safe-b); }
  dialog.reader[open] { animation: sheet-up .32s var(--ease) both; }
  .grab { display: block; position: absolute; top: 6px; left: 50%; width: 38px; height: 4px; border-radius: 99px; background: var(--line-strong); transform: translateX(-50%); }
  .sheet-head .grab { position: absolute; }
  .sheet-head { padding-top: 1rem; }
  .codal-text { font-size: 1.06rem; }
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
@media (max-width: 380px) { .tiles { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
@media (hover: none) { .kbd { display: none; } }
