/* Light pages: sidebar shell, page content, sign-in. Tokens come from base.css. */
body.site { --sbw: 272px; }

.skip { position: absolute; left: -999px; top: 8px; background: var(--accent); color: var(--accent-ink); padding: 8px 12px; border-radius: 6px; z-index: 50; }
.skip:focus { left: 8px; }

/* ---------- brand */
.brand { font-weight: 700; letter-spacing: -.01em; text-decoration: none; display: inline-flex; gap: 10px; align-items: center; }
.brand .mark { width: 22px; height: 22px; border-radius: 6px; background: var(--accent); position: relative; flex: none; }
.brand .mark::after { content: ""; position: absolute; inset: 6px; border: 2px solid var(--accent-ink); border-radius: 50%; }

/* ---------- shell and sidebar */
.shell { display: grid; grid-template-columns: var(--sbw) minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.sb-top { display: flex; align-items: center; justify-content: space-between; padding: 18px 18px 10px; }
.sb-close { display: none; background: none; border: 0; font-size: 1.6rem; line-height: 1; color: var(--muted); }
.sb-nav { flex: 1; padding: 4px 10px 16px; }
.sb-link { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 7px; text-decoration: none; font-size: .93rem; }
.sb-link:hover, .sb-track summary:hover { background: var(--accent-soft); }
.sb-link[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sb-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-section { margin-top: 18px; }
.sb-head { display: flex; justify-content: space-between; align-items: baseline; padding: 0 10px 6px; font-size: .72rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.sb-all { text-transform: none; letter-spacing: 0; font-weight: 600; color: var(--accent); text-decoration: none; font-size: .8rem; }
.sb-track summary { list-style: none; cursor: pointer; display: flex; gap: 8px; padding: 7px 10px; border-radius: 7px; font-size: .9rem; font-weight: 600; }
.sb-track summary::-webkit-details-marker { display: none; }
.sb-track summary::before { content: "▸"; color: var(--muted); transition: transform .15s; }
.sb-track[open] summary::before { transform: rotate(90deg); }
.sb-track summary > span:first-child { flex: 1; }
.sb-sub { font-size: .86rem; padding: 5px 10px 5px 30px; color: var(--muted); }
.sb-sub.case { padding-left: 12px; }
.sb-count { font-size: .74rem; color: var(--muted); font-family: var(--mono); }
.sb-check { color: var(--good); font-weight: 700; font-size: .85rem; }
.sb-lock { font-size: .72rem; opacity: .7; }
.sb-empty { color: var(--muted); font-size: .85rem; padding: 4px 10px; }
.sb-user { border-top: 1px solid var(--line); padding: 12px 14px; display: flex; gap: 8px; align-items: center; }
.sb-who { display: flex; gap: 10px; align-items: center; text-decoration: none; flex: 1; min-width: 0; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 700; flex: none; }
.sb-name { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.sb-name b, .sb-name small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-name small { color: var(--muted); }
.sb-out { background: none; border: 1px solid var(--line); color: var(--muted); border-radius: 6px; padding: 4px 9px; font-size: .8rem; }
.sb-out:hover { color: var(--ink); }
.mobilebar, .scrim { display: none; }

/* ---------- page content */
.main { min-width: 0; }
.view { max-width: 1440px; margin: 0 auto; padding: 34px 40px 64px; outline: none; }
.page-head { margin-bottom: 26px; }
.page-head h1 { font-size: clamp(1.6rem, 3.4vw, 2.2rem); letter-spacing: -.02em; line-height: 1.15; margin: 6px 0 8px; }
.page-head p { color: var(--muted); margin: 0; max-width: 64ch; font-size: 1.02rem; }
.sec-block { margin-top: 36px; }
h2.sec { font-size: 1.15rem; letter-spacing: -.01em; margin: 0 0 12px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.panel > h3 { margin: 0 0 12px; font-size: .78rem; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.panel.summary { margin-bottom: 28px; display: grid; gap: 12px; }
.narrow { max-width: 460px; margin-bottom: 20px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 10px; text-decoration: none; transition: transform .12s, border-color .12s, box-shadow .12s; height: 100%; }
a.card:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: var(--shadow); }
a.card[aria-disabled="true"] { opacity: .6; pointer-events: none; }
.card h3 { margin: 0; font-size: 1.08rem; letter-spacing: -.01em; }
.card p { margin: 0; color: var(--muted); font-size: .93rem; }
.card .bar { margin-top: auto; }

/* home: main column + right column, like a problem-site landing page */
.home { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 28px; align-items: start; }
.home-main { display: grid; grid-template-columns: minmax(0, 1fr); gap: 30px; min-width: 0; }
.home-side { display: grid; gap: 16px; position: sticky; top: 20px; }
.home-side .panel { display: grid; gap: 12px; padding: 16px; }
.home-side .panel > h3 { margin: 0; }
.home-sec { display: grid; gap: 12px; min-width: 0; }
.home-sec h2.sec { margin: 0; }
.sec-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.sec-row a.more { margin: 0; }

.hello { display: flex; justify-content: space-between; align-items: center; gap: 18px; flex-wrap: wrap; }
.hello h1 { margin: 0 0 4px; font-size: clamp(1.4rem, 2.6vw, 1.85rem); letter-spacing: -.02em; }
.hello p { margin: 0; }
.hello-stats { display: flex; gap: 8px; flex-wrap: wrap; }
.hstat { display: grid; grid-template-columns: auto auto; column-gap: 7px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 7px 12px; }
.hstat .hicon { grid-row: span 2; font-size: 1.05rem; color: var(--accent); }
.hstat b { font-size: .98rem; line-height: 1.2; font-variant-numeric: tabular-nums; }
.hstat span:last-child { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; }

/* study plan cards: coloured, scroll sideways when they don't fit */
.t-teal { --g1: #0e7c74; --g2: #0a4f5c; } .t-indigo { --g1: #4256c9; --g2: #26307a; } .t-violet { --g1: #7a45c4; --g2: #42246f; }
.t-amber { --g1: #c7771a; --g2: #7d3f0b; } .t-rose { --g1: #c2415f; --g2: #6e1e36; }
.plan-strip { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x mandatory; }
.splan { scroll-snap-align: start; position: relative; display: flex; flex-direction: column; gap: 8px; min-height: 220px; padding: 16px 16px 14px 20px;
  margin-top: 11px; color: var(--ink); text-decoration: none; background: var(--surface); border: 1px solid var(--line); border-radius: 2px 10px 10px 10px;
  box-shadow: inset 4px 0 0 var(--g1); transition: transform .12s, border-color .12s; }
.splan::before { content: ""; position: absolute; left: -1px; top: -11px; width: 42%; height: 11px; background: var(--g1); border-radius: 6px 10px 0 0; }
.splan:hover { transform: translateY(-2px); border-color: var(--g1); }
.splan-role { font: 700 .68rem/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.splan h3 { margin: 0; font-size: 1.08rem; line-height: 1.25; letter-spacing: -.01em; }
.splan p { margin: 0; font-size: .84rem; color: var(--muted); flex: 1; }
.splan-foot { display: flex; justify-content: space-between; gap: 8px; font-size: .8rem; color: var(--muted); }
.splan-pro { font: 700 .62rem/1.4 var(--mono); letter-spacing: .06em; color: var(--pro-ink); background: var(--pro-soft); padding: 0 5px; border-radius: 3px; align-self: center; }
.splan-bar { height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.splan-bar i { display: block; height: 100%; background: var(--g1); }
.splan-done { font: .72rem/1 var(--mono); color: var(--muted); }
.plan-banner { display: flex; gap: 22px; align-items: center; flex-wrap: wrap; border-radius: 4px 12px 12px 12px; padding: 18px 22px; margin-bottom: 16px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: inset 5px 0 0 var(--g1); }
.plan-banner .grow { flex: 1 1 320px; }
.plan-banner h2 { margin: 2px 0 4px; font-size: 1.35rem; letter-spacing: -.01em; }
.plan-banner p { margin: 0; color: var(--muted); max-width: 70ch; }
.plan-banner-side { display: grid; gap: 8px; min-width: 240px; }
.plan-banner .bar > i { background: var(--g1); }

.topic-cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.topic { display: inline-flex; align-items: center; gap: 7px; padding: 5px 12px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); text-decoration: none; font-size: .88rem; }
.topic:hover { border-color: var(--accent); color: var(--accent); }
.topic.tag-on { font: inherit; font-size: .88rem; cursor: pointer; border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.topic.more-btn { font: inherit; font-size: .88rem; color: var(--accent); cursor: pointer; }
.topic .n { font-family: var(--mono); font-size: .72rem; color: var(--muted); background: var(--accent-soft); border-radius: 99px; padding: 0 7px; }

.keep { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.keep-card { display: grid; gap: 6px; align-content: start; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; text-decoration: none; transition: border-color .12s, transform .12s; }
.keep-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.keep-card b { line-height: 1.3; }
.keep-card .bar { margin-top: 4px; }

/* daily-problem calendar */
.cal-daily { display: grid; gap: 4px; padding: 12px; border-radius: 10px; text-decoration: none; background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); }
.cal-daily:hover b { color: var(--accent); }
.cal-daily.done .kicker { color: var(--good); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; font-size: .8rem; }
.cal-h { color: var(--muted); font-size: .7rem; font-weight: 700; padding-bottom: 2px; }
.cal-d { aspect-ratio: 1; display: grid; place-items: center; border-radius: 3px; font: .76rem/1 var(--mono); border: 1px solid transparent; }
.cal-d.future { color: var(--muted); opacity: .55; }
.cal-d.active { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.cal-d.daily { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.cal-d.today { border: 1px dashed var(--ink); font-weight: 700; }
.cal-legend { display: flex; gap: 14px; color: var(--muted); font-size: .76rem; }
.cal-legend span { display: inline-flex; align-items: center; gap: 5px; }
.lg { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.lg.daily { background: var(--good); } .lg.active { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.cal-foot { border-top: 1px solid var(--line); padding-top: 10px; font-size: .9rem; }

.rank-mini { display: grid; gap: 6px; padding-top: 10px; border-top: 1px solid var(--line); }
.home-side .progress-row { gap: 16px; }
.home-side .progress-row { flex-direction: column; align-items: stretch; gap: 12px; }
.home-side .tiers { min-width: 0; }
.home-side .tally-total { justify-content: start; }
.home-side .tier-row { grid-template-columns: 78px 1fr auto; }

.lb { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.lb li { display: grid; grid-template-columns: 26px 1fr auto; gap: 8px; align-items: center; padding: 6px 8px; margin: 0 -8px; border-radius: 7px; font-size: .9rem; }
.lb li.you { background: var(--accent-soft); font-weight: 600; }
.lb-place { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: .74rem; font-weight: 700; color: var(--muted); background: var(--line); }
.lb-place.p1 { background: #f5c542; color: #3a2a00; } .lb-place.p2 { background: #c9d1d9; color: #26303a; } .lb-place.p3 { background: #d49a6a; color: #3a1f08; }
.lb-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; gap: 6px; align-items: center; }
.lb-name small { color: var(--muted); font-weight: 400; }
.lb-pts { font-family: var(--mono); font-size: .82rem; color: var(--muted); }
.lb-you { font-size: .86rem; color: var(--muted); border-top: 1px solid var(--line); padding-top: 8px; }

.trend { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.trend li { display: grid; gap: 2px; }
.trend a { text-decoration: none; font-weight: 600; font-size: .92rem; display: flex; gap: 6px; align-items: center; }
.trend a:hover { color: var(--accent); }

/* cases first: featured case, case files, casework panel */
.case-hero { display: flex; gap: 28px; align-items: center; flex-wrap: wrap; color: #e8f3f1; border-radius: 16px; padding: 26px 28px;
  background: radial-gradient(circle at 85% 10%, rgba(95, 201, 184, .28), transparent 50%), radial-gradient(circle at 0% 100%, rgba(66, 86, 201, .25), transparent 55%), linear-gradient(140deg, #0f2a2e, #0b1720); }
.case-hero .grow { flex: 1 1 380px; display: grid; gap: 8px; }
.case-hero .kicker { color: #6fd8c6; }
.case-hero h2 { margin: 0; font-size: clamp(1.4rem, 2.6vw, 1.9rem); letter-spacing: -.02em; }
.case-hero p { margin: 0; color: #b9cfcb; max-width: 62ch; }
.hero-meta { color: #9cb7b2; font-size: .86rem; }
.hero-side { display: grid; gap: 10px; min-width: 220px; }
.hero-prog { display: flex; align-items: baseline; gap: 8px; }
.hero-prog b { font-size: 1.6rem; letter-spacing: -.02em; }
.hero-prog span { color: #9cb7b2; font-size: .85rem; }
.case-hero .bar { background: rgba(255, 255, 255, .15); } .case-hero .bar > i { background: #6fd8c6; }
.hero-btn { background: #6fd8c6; color: #062420; padding: 11px 20px; }
.case-hero.done .btn.ghost { color: #fff; }
.case-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.case-card .sp { flex: 1; }
.case-card.st-locked { background: linear-gradient(160deg, rgba(255, 217, 120, .10), transparent 50%), var(--surface); }
.case-card.st-locked h3 { color: var(--muted); }
.case-card.st-closed { border-color: color-mix(in srgb, var(--good) 40%, var(--line)); }
.warmup { padding-top: 24px; border-top: 1px dashed var(--line); gap: 18px; }
.warm-sub { margin: 2px 0 0; }
.home-sub { display: grid; gap: 10px; min-width: 0; }
h3.subsec { margin: 0; font-size: .82rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.warmup .splan { min-height: 190px; }
.case-mini { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.case-mini li { display: grid; gap: 4px; }
.case-mini a { display: flex; gap: 8px; align-items: center; text-decoration: none; font-size: .9rem; }
.case-mini a:hover .cm-title { color: var(--accent); }
.cm-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.case-mini .ok { color: var(--good); font-weight: 700; }
.case-mini .bar { height: 4px; }
.case-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 20px; }
.case-stat { display: grid; gap: 6px; }
.case-stat b { font-size: 1.4rem; letter-spacing: -.02em; }

@media (max-width: 1200px) {
  .home { grid-template-columns: minmax(0, 1fr); }
  .home-side { position: static; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); align-items: start; }
}

/* side rail layout (Learn, lesson) */
.with-rail { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 32px; align-items: start; }
.rail { position: sticky; top: 24px; display: grid; gap: 16px; max-height: calc(100vh - 48px); overflow-y: auto; }
.rail .panel { display: grid; gap: 10px; padding: 16px; align-content: start; }
.rail .panel > h3 { margin: 0; }
.big-num { font-size: 2.2rem; font-weight: 700; letter-spacing: -.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.rail-next { display: grid; gap: 6px; margin-top: 6px; padding-top: 12px; border-top: 1px solid var(--line); }
.rail-next .btn { margin-top: 4px; }
.track-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.track-list a { display: grid; gap: 6px; padding: 8px 10px; margin: 0 -10px; border-radius: 8px; text-decoration: none; font-size: .9rem; }
.track-list a:hover, .track-list a[aria-current] { background: var(--accent-soft); }
.rail-case { display: grid; gap: 8px; text-decoration: none; }
.rail-case:hover b { color: var(--accent); }

/* learn */
.track { margin-bottom: 36px; scroll-margin-top: 20px; }
.track-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.track-head h2 { margin: 0; font-size: 1.2rem; letter-spacing: -.01em; }
.track > p { color: var(--muted); margin: 4px 0 14px; max-width: 75ch; }
.lesson-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.lesson-tile { display: flex; flex-direction: column; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; text-decoration: none; transition: transform .12s, border-color .12s, box-shadow .12s; }
.lesson-tile:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: var(--shadow); }
.lesson-tile .num { width: 28px; height: 28px; border-radius: 50%; border: 1.5px solid var(--line); display: grid; place-items: center; font-size: .8rem; font-family: var(--mono); color: var(--muted); }
.lesson-tile.done { border-color: color-mix(in srgb, var(--good) 45%, var(--line)); }
.lesson-tile.done .num { background: var(--good); border-color: var(--good); color: #fff; }
.lesson-tile h3 { margin: 4px 0 0; font-size: 1.02rem; line-height: 1.3; }
.lesson-tile p { margin: 0; color: var(--muted); font-size: .9rem; }

/* lesson */
.lesson-page { max-width: 1200px; margin: 0 auto; }
.read-progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 40; pointer-events: none; }
.read-progress i { display: block; height: 100%; width: 0; background: var(--accent); }
.crumbs { font-size: .85rem; color: var(--muted); }
.crumbs a { color: var(--accent); text-decoration: none; }
.lesson-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 48px; align-items: start; }
.lesson-layout > div { max-width: 800px; }
.rail-done { justify-items: start; }
.rail .toc { gap: 0; }
.rail .toc > h3 { margin-bottom: 8px; }
.toc a { display: block; color: var(--muted); text-decoration: none; padding: 4px 0 4px 10px; border-left: 2px solid var(--line); font-size: .87rem; }
.toc a:hover { color: var(--ink); border-left-color: var(--accent); }
.track-lessons { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; counter-reset: l; }
.track-lessons a { display: grid; grid-template-columns: 20px 1fr; gap: 8px; padding: 6px 8px; margin: 0 -8px; border-radius: 7px; text-decoration: none; font-size: .88rem; color: var(--muted); }
.track-lessons a:hover { background: var(--accent-soft); color: var(--ink); }
.track-lessons a[aria-current] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.track-lessons .tick { color: var(--good); font-weight: 700; }
.prose { font-size: 1.02rem; line-height: 1.7; }
.prose h2 { font-size: 1.3rem; letter-spacing: -.01em; margin: 2em 0 .5em; scroll-margin-top: 20px; }
.prose h3 { font-size: 1.06rem; margin: 1.6em 0 .4em; }
.prose p, .prose ul, .prose ol { margin: 0 0 1em; }
.prose li { margin: .25em 0; }
.prose a { color: var(--accent); }
.prose code { font-family: var(--mono); font-size: .88em; background: var(--accent-soft); padding: 1px 5px; border-radius: 4px; }
.prose pre.code { background: #0d1116; color: #dfe6ee; border-radius: 8px; padding: 14px 16px; overflow-x: auto; font: 13px/1.6 var(--mono); margin: 0 0 1.2em; }
.prose pre.code code { background: none; padding: 0; color: inherit; font-size: inherit; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
.prose .tablewrap { overflow-x: auto; margin: 0 0 1.2em; }
.prose table { border-collapse: collapse; font-size: .92rem; min-width: 100%; }
.prose th, .prose td { border: 1px solid var(--line); padding: 7px 10px; text-align: left; vertical-align: top; }
.prose th { background: var(--accent-soft); }
.callout { margin: 0 0 1.2em; padding: 12px 16px; border-left: 4px solid var(--line); background: var(--surface); border-radius: 0 8px 8px 0; }
.callout > :last-child { margin-bottom: 0; }
.callout.tip { border-left-color: var(--accent); }
.callout.warn { border-left-color: #d08a17; }
.callout.try { border-left-color: #6b5fd0; }
.callout.note { border-left-color: var(--muted); }
.lesson-foot { margin-top: 36px; padding-top: 22px; border-top: 1px solid var(--line); display: grid; gap: 16px; }
.done-box { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.pn { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pn a { display: block; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; text-decoration: none; background: var(--surface); }
.pn a:hover { border-color: var(--accent); }
.pn small { color: var(--muted); display: block; }
.pn .next { text-align: right; grid-column: 2; }

/* dashboard */
.rank { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.rank-name { font-size: 1.25rem; font-weight: 700; letter-spacing: -.01em; }
.rank .grow { flex: 1; min-width: 220px; display: grid; gap: 6px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin-top: 16px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.tile .k { color: var(--muted); font-size: .8rem; }
.tile .v { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.tile .s { color: var(--muted); font-size: .8rem; }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; margin-top: 16px; }
.dash-grid .col { display: grid; gap: 16px; align-content: start; }
.scroll-x { overflow-x: auto; }
.ctable { width: 100%; border-collapse: collapse; font-size: .92rem; }
.ctable th { text-align: left; color: var(--muted); font-weight: 600; font-size: .78rem; padding: 0 8px 8px; border-bottom: 1px solid var(--line); }
.ctable td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.ctable tr:last-child td { border-bottom: 0; }
.ctable a { text-decoration: none; font-weight: 600; }
.ctable a:hover { color: var(--accent); }
.ctable .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.trk { margin-bottom: 12px; display: grid; gap: 5px; }
.trk:last-child { margin-bottom: 0; }
.trk a { text-decoration: none; font-size: .9rem; }
.spark { display: grid; grid-template-columns: repeat(28, 1fr); gap: 3px; align-items: end; height: 72px; }
.spark i { display: block; background: var(--accent); border-radius: 2px 2px 0 0; min-height: 2px; }
.spark i.zero { background: var(--line); }
.spark-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: .74rem; margin-top: 6px; }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: .9rem; align-items: baseline; }
.feed li:last-child { border-bottom: 0; }
.feed a { flex: 1; text-decoration: none; min-width: 0; }
.feed a:hover { color: var(--accent); }
.feed .when { color: var(--muted); font-size: .8rem; white-space: nowrap; }
.feed .pts { color: var(--good); font-family: var(--mono); font-size: .8rem; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; font-size: .92rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- problems */
.sb-pro { display: flex; align-items: center; gap: 8px; margin: 0 12px 12px; padding: 10px 12px; border-radius: 8px; text-decoration: none; font-size: .86rem; font-weight: 600;
  background: var(--pro-soft); border: 1px solid color-mix(in srgb, var(--pro) 40%, transparent); color: var(--pro-ink); }
.sb-pro span:nth-child(2) { flex: 1; }
.sb-name b { display: flex; gap: 6px; align-items: center; }
.sb-dn { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-name b .pro-tag { flex: none; }
.btn.pro { background: var(--pro); color: #fff; }
.prob-top { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1fr); gap: 14px; margin-bottom: 22px; }
.prob-top .panel { display: grid; align-content: start; gap: 10px; }
.prob-top .panel > h3 { margin: 0; }
.progress-row { display: flex; gap: 22px; align-items: center; flex-wrap: wrap; }
/* clearance tally (replaces a progress ring): big count, then a square per drill per tier */
.tally-total { display: grid; grid-template-columns: auto auto; align-items: baseline; column-gap: 6px; flex: none; min-width: 92px; }
.tally-total b { font: 700 2.2rem/1 var(--mono); letter-spacing: -.03em; }
.tally-total span { color: var(--muted); font: .9rem var(--mono); }
.tally-total small { grid-column: 1 / -1; color: var(--muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; margin-top: 4px; }
.tiers { flex: 1; min-width: 200px; display: grid; gap: 8px; }
.tier-row { display: grid; grid-template-columns: 84px 1fr auto; gap: 10px; align-items: center; }
.squares { display: flex; flex-wrap: wrap; gap: 3px; }
.squares i { width: 11px; height: 11px; border-radius: 2px; border: 1px solid var(--line); }
.squares i.on.l1 { background: var(--l1); border-color: var(--l1); } .squares i.on.l2 { background: var(--l2); border-color: var(--l2); }
.squares i.on.l3 { background: var(--l3); border-color: var(--l3); }
.daily { display: grid; gap: 8px; justify-items: start; }
.daily-date { color: var(--muted); font-size: .84rem; }
.daily-title { font-size: 1.15rem; font-weight: 700; text-decoration: none; letter-spacing: -.01em; }
.daily-title:hover { color: var(--accent); }
.pro-card { position: relative; overflow: hidden; display: grid; gap: 8px; justify-items: start;
  background: linear-gradient(160deg, var(--pro-soft), transparent 65%), var(--surface); border-color: color-mix(in srgb, var(--pro) 45%, transparent); }
.pro-card h3 { margin: 0; font-size: 1.1rem; text-transform: none; letter-spacing: -.01em; color: var(--ink); } .pro-card p { margin: 0; color: var(--muted); font-size: .92rem; }
.cat-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.cat-tabs button { background: var(--surface); border: 1px solid var(--line); color: var(--ink); border-radius: 99px; padding: 6px 14px; font-size: .9rem; display: inline-flex; gap: 8px; align-items: center; }
.cat-tabs button[aria-selected="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.cat-tabs .n { font-size: .76rem; opacity: .7; font-family: var(--mono); }
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.filters .sp { flex: 1; }
.filters .search { flex: 1 1 220px; max-width: 340px; }
.filters input, .filters select { background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: inherit; font-size: .92rem; }
.filters input:focus, .filters select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.filters .btn { padding: 7px 14px; }
.ptable-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.ptable { width: 100%; border-collapse: collapse; font-size: .94rem; }
.ptable th { text-align: left; color: var(--muted); font-weight: 600; font-size: .78rem; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.ptable td { padding: 11px 14px; vertical-align: middle; }
.ptable tbody td { border-top: 1px solid var(--line); }
.ptable tbody tr:hover td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.ptable .mark { display: inline-block; width: 10px; height: 10px; border-radius: 2px; border: 1.5px solid var(--line); vertical-align: middle; }
.ptable tr.st-solved .mark { background: var(--good); border-color: var(--good); }
.ptable tr.st-attempted .mark { border-color: var(--warn); background: linear-gradient(135deg, var(--warn) 50%, transparent 50%); }
.ptable tbody tr:hover td { background: var(--accent-soft); }
.ptable .st { width: 34px; text-align: center; }
.ptable .num { text-align: right; font-variant-numeric: tabular-nums; }
.ptable a.ptitle { font-weight: 600; text-decoration: none; margin-right: 8px; }
.ptable a.ptitle:hover { color: var(--accent); }
.ptable tr.locked a.ptitle { color: var(--muted); }
.ptags { color: var(--muted); font-size: .78rem; margin-top: 2px; }
.empty-row { text-align: center; color: var(--muted); padding: 28px !important; }
a.more { font-size: .88rem; color: var(--accent); text-decoration: none; justify-self: start; margin-top: 4px; display: inline-block; }
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; max-width: 900px; }
.plan { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 22px; display: grid; gap: 12px; align-content: start; }
.plan.featured { border: 2px solid var(--pro); box-shadow: var(--shadow); }
.plan h3 { margin: 0; font-size: 1.2rem; }
.price { font-size: 1.8rem; font-weight: 800; letter-spacing: -.02em; display: grid; }
.price small { font-size: .82rem; font-weight: 400; color: var(--muted); letter-spacing: 0; }
.plan ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.plan li::before { content: "✓"; color: var(--good); font-weight: 700; margin-right: 8px; }
.pro-list { display: grid; gap: 8px; max-width: 900px; }
a.pro-item { text-decoration: none; } a.pro-item:hover { border-color: var(--accent); }
.pro-item { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; }
@media (max-width: 1100px) { .prob-top { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .prob-top > :first-child { grid-column: 1 / -1; } }
@media (max-width: 700px) { .prob-top { grid-template-columns: minmax(0, 1fr); } .hide-s { display: none; } }

/* ---------- admin (owners only) */
.sb-admin { margin-top: 2px; }
.admin-tabs { margin-bottom: 18px; }
.mt16 { margin-top: 16px; }
.btn.sm { padding: 5px 11px; font-size: .84rem; }
.btn.armed { border-color: var(--warn); color: var(--warn); }
.btn.danger.armed, .btn.danger:hover { border-color: var(--bad); color: var(--bad); }
.tier { display: inline-block; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 1px 7px; border-radius: 5px; margin-right: 4px;
  background: var(--line); color: var(--muted); }
.tier.pro { background: var(--pro-soft); color: var(--pro-ink); } .tier.owner { background: var(--ink); color: var(--bg); }
.tier.disabled, .tier.st-revoked, .tier.st-expired { background: var(--hard-bg); color: var(--hard); }
.tier.st-active { background: var(--easy-bg); color: var(--easy); } .tier.st-used-up { background: var(--mid-bg); color: var(--mid); }
.admin-split { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(320px, 1fr); gap: 16px; align-items: start; }
.admin-table td, .admin-table th { padding: 9px 12px; white-space: nowrap; }
.admin-table td:last-child { white-space: normal; }
.admin-table tbody tr { cursor: default; }
.admin-split .admin-table tbody tr { cursor: pointer; }
.admin-table tr.sel td { background: var(--accent-soft) !important; }
.admin-table tr.disabled td, .admin-table tr.dim td { opacity: .6; }
.pager { margin-top: 10px; }
.udetail { display: grid; gap: 12px; position: sticky; top: 20px; }
.udetail h3 { margin: 0; font-size: 1.1rem; text-transform: none; letter-spacing: 0; color: var(--ink); }
.udetail h4 { margin: 6px 0 0; font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.uactions { gap: 8px; }
.invite-form { display: grid; grid-template-columns: 120px minmax(160px, 1fr) 90px 140px auto; gap: 10px; align-items: end; }
.invite-form .field { margin: 0; }
.invite-form select, .invite-form input { font: inherit; width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); }
.newcode { margin-top: 6px; padding: 14px; border: 1px dashed var(--accent); border-radius: 10px; background: var(--accent-soft); display: grid; gap: 8px; }
code.code { font-family: var(--mono); font-size: 1.25rem; letter-spacing: .08em; font-weight: 700; user-select: all; }
.admin-spark { height: 90px; grid-template-columns: repeat(30, 1fr); }
.qbars { display: flex; gap: 3px; align-items: end; height: 28px; min-width: 120px; }
.qbars i { flex: 1; background: var(--accent); border-radius: 2px 2px 0 0; min-height: 2px; }
@media (max-width: 1100px) { .admin-split { grid-template-columns: minmax(0, 1fr); } .udetail { position: static; } }
@media (max-width: 760px) { .invite-form { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .invite-form .btn { grid-column: 1 / -1; } }

/* ---------- progression: rank, level, credentials, leaderboard tabs */
.dash-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.rankblock { display: grid; gap: 8px; }
.rank-title { font-size: 1.25rem; letter-spacing: -.01em; }
.lvl-badge { display: grid; justify-items: center; line-height: 1; padding: 6px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--accent-soft); color: var(--accent); }
.lvl-badge small { font-size: .62rem; text-transform: uppercase; letter-spacing: .1em; }
.lvl-badge b { font: 700 1.4rem/1.1 var(--mono); }
.creds { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.creds li { display: flex; gap: 12px; align-items: center; opacity: .75; }
.creds li.earned { opacity: 1; }
.cred-badge { flex: none; width: 38px; height: 38px; display: grid; place-items: center; font: 700 .9rem var(--mono); border-radius: 8px;
  border: 1.5px dashed var(--line); color: var(--muted); }
.creds li.earned .cred-badge { border: 1.5px solid var(--accent); background: var(--accent-soft); color: var(--accent); }
.lb-tabs { display: flex; gap: 4px; }
.lb-tabs button { border: 1px solid var(--line); background: none; color: var(--muted); border-radius: 6px; padding: 3px 10px; font-size: .8rem; }
.lb-tabs button[aria-selected="true"] { background: var(--accent-soft); color: var(--accent); border-color: transparent; font-weight: 600; }
.lb-gap { text-align: center; color: var(--muted); line-height: 1; }
.lb-count { font-size: .76rem; }
@media (max-width: 1000px) { .dash-top { grid-template-columns: minmax(0, 1fr); } }

/* ---------- footer and theme switch */
.main { display: flex; flex-direction: column; min-height: 100vh; }
.main > .view { flex: 1; width: 100%; }
.site-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px 24px; flex-wrap: wrap;
  max-width: 1440px; width: 100%; margin: 0 auto; padding: 18px 40px calc(18px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line); font-size: .84rem; }
.foot-l { display: grid; gap: 2px; }
.foot-r { display: flex; align-items: center; gap: 10px; }
.theme-pick { display: inline-flex; padding: 2px; gap: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.theme-pick button { border: 0; background: none; color: var(--muted); font-size: .8rem; padding: 4px 10px; border-radius: 6px; }
.theme-pick button:hover { color: var(--ink); }
.theme-pick button[aria-checked="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.auth-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; width: 100%; max-width: 380px;
  color: var(--muted); font-size: .8rem; }
@media (max-width: 900px) { .site-foot { padding-inline: 16px; } }

/* ---------- sign-in (bare layout) */
body.bare .view { max-width: none; padding: 0; }
.auth { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); min-height: 100vh; }
.auth-pitch { background: #0d1f22; color: #e6f2ef; padding: 40px 56px; display: flex; flex-direction: column; justify-content: space-between; gap: 32px;
  background-image: radial-gradient(circle at 20% 0%, rgba(95, 201, 184, .18), transparent 55%), radial-gradient(circle at 100% 100%, rgba(95, 201, 184, .1), transparent 50%); }
.auth-pitch .brand .mark { background: #5fc9b8; }
.auth-pitch .brand .mark::after { border-color: #0d1f22; }
.auth-pitch .eyebrow { color: #5fc9b8; }
.auth-pitch h2 { font-size: clamp(1.7rem, 3.2vw, 2.6rem); line-height: 1.12; letter-spacing: -.02em; margin: 10px 0 28px; max-width: 18ch; }
.auth-pitch .meta { color: #8fb3ad; }
.features { list-style: none; padding: 0; margin: 0; display: grid; gap: 18px; max-width: 46ch; }
.features li { display: grid; gap: 2px; padding-left: 18px; border-left: 2px solid rgba(95, 201, 184, .5); }
.features span { color: #a9c6c1; font-size: .95rem; }
.auth-panel { display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 28px; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h1 { font-size: 1.6rem; letter-spacing: -.02em; margin: 0 0 4px; }
.auth-card > .meta { margin: 0 0 22px; font-size: .95rem; }
.auth-form .btn { margin-top: 4px; padding: 12px; }
.switch { margin-top: 18px; color: var(--muted); font-size: .92rem; text-align: center; }

/* ---------- responsive */
@media (max-width: 1150px) { .lesson-layout { grid-template-columns: minmax(0, 1fr); } .lesson-rail { display: none; } }
@media (max-width: 1400px) {
  .with-rail { grid-template-columns: minmax(0, 1fr); }
  .with-rail > .rail { order: -1; position: static; max-height: none; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
}
@media (max-width: 1000px) { .dash-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 860px) {
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-pitch { padding: 28px 20px; }
  .auth-pitch h2 { margin-bottom: 18px; }
  .features, .auth-pitch > .meta { display: none; }
}
@media (max-width: 700px) { .with-rail > .rail > .panel:not(:first-child) { display: none; } }
@media (max-width: 900px) {
  .shell { display: block; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: min(86vw, 300px); z-index: 30; transform: translateX(-100%); transition: transform .2s; padding-top: env(safe-area-inset-top, 0px); }
  body.sb-open .sidebar { transform: none; box-shadow: var(--shadow); }
  body.sb-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 20; }
  .sb-close { display: block; }
  .mobilebar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top, 0px)); border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 10; }
  .menu-btn { background: none; border: 0; display: grid; gap: 4px; padding: 6px; }
  .menu-btn span { display: block; width: 20px; height: 2px; background: var(--ink); border-radius: 2px; }
  .view, .skeleton { padding: 24px 16px 48px; }
}
