/* ==========================================================================
   Per-view styles
   ========================================================================== */

/* ---------- home ---------- */
.hero { padding-block: clamp(40px, 7vw, 88px) clamp(26px, 4vw, 48px); position: relative; overflow: hidden; }
.hero-in { position: relative; z-index: 2; }
.hero h1 { font-size: var(--fs-hero); letter-spacing: -0.032em; line-height: 1.05; max-width: 17ch; }
.hero h1 .dim { color: var(--ink-4); }
.hero-sub { margin-top: 18px; font-size: clamp(1.0625rem, 2vw, 1.25rem); color: var(--ink-3); max-width: 56ch; line-height: 1.5; letter-spacing: -0.01em; }
.hero-acts { margin-top: 26px; }
.hero-fine { margin-top: 16px; font-size: var(--fs-small); color: var(--ink-4); display: flex; gap: 16px; flex-wrap: wrap; }
.hero-fine span { display: inline-flex; align-items: center; gap: 6px; }
.hero-fine svg { width: 14px; height: 14px; }
.hero-demo { margin-top: clamp(24px, 4vw, 40px); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(124px, 100%), 1fr)); border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); overflow: hidden; }
.stat { padding: 15px 17px; border-left: 1px solid var(--line); min-width: 0; }
.stat:first-child { border-left: 0; }
.stat b { display: block; font-size: 1.55rem; font-weight: 650; letter-spacing: -0.03em; color: var(--ink); font-variant-numeric: tabular-nums; }
.stat span { font-size: var(--fs-fine); color: var(--ink-3); }
@media (max-width: 620px) { .stat { border-left: 0; border-top: 1px solid var(--line); } .stat:first-child { border-top: 0; } }

.feat { display: grid; gap: clamp(18px, 3.4vw, 42px); align-items: center; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .feat { grid-template-columns: minmax(0,1fr) minmax(0,1.2fr); } .feat[data-flip] .feat-vis { order: -1; } }
.feat + .feat { margin-top: clamp(38px, 6vw, 74px); }
.feat-txt, .feat-vis { min-width: 0; }
.feat-txt h3 { font-size: clamp(1.4rem, 2.8vw, 1.9rem); letter-spacing: -0.024em; }
.feat-txt p { margin-top: 11px; color: var(--ink-3); font-size: var(--fs-read); line-height: 1.56; max-width: 46ch; }
.feat-txt ul { margin: 14px 0 0; padding-left: 0; list-style: none; display: flex; flex-direction: column; gap: 7px; }
.feat-txt li { display: flex; gap: 10px; font-size: var(--fs-body); color: var(--ink-2); }
.feat-txt li::before { content: ""; width: 5px; height: 5px; border-radius: 99px; background: var(--accent); margin-top: .58em; flex: none; }

/* ---------- roadmap ---------- */
.stage-row + .stage-row { margin-top: 10px; }
.stage-card { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; transition: border-color var(--t-mid) var(--ease); }
.stage-card:hover { border-color: var(--line-2); }
.stage-bar { display: flex; align-items: center; gap: 13px; width: 100%; padding: 15px 17px; text-align: left; min-width: 0; }
.stage-idx { width: 29px; height: 29px; border-radius: 99px; flex: none; display: grid; place-items: center; font-family: var(--mono); font-size: var(--fs-fine); font-weight: 680; background: var(--hue, var(--accent)); background: oklch(from var(--hue, var(--accent)) min(l, var(--text-lmax)) c h); color: var(--on-hue); }
.stage-meta { flex: 1; min-width: 0; }
.stage-meta h3 { font-size: var(--fs-read); letter-spacing: -0.016em; }
.stage-meta p { font-size: var(--fs-small); color: var(--ink-3); margin-top: 2px; }
.stage-right { display: flex; align-items: center; gap: 12px; flex: none; }
.stage-count { font-size: var(--fs-fine); color: var(--ink-4); font-variant-numeric: tabular-nums; }
.stage-chev { width: 16px; height: 16px; color: var(--ink-4); transition: transform var(--t-mid) var(--ease); }
.stage-card[data-open="1"] .stage-chev { transform: rotate(90deg); }
.stage-body { display: grid; grid-template-rows: 0fr; transition: grid-template-rows var(--t-slow) var(--ease); }
.stage-card[data-open="1"] .stage-body { grid-template-rows: 1fr; }
.stage-body > div { overflow: hidden; }
.stage-inner { padding: 4px 17px 17px; border-top: 1px solid var(--line); display: grid; gap: 12px; min-width: 0; }
.stage-note { font-size: var(--fs-small); color: var(--ink-3); padding-top: 13px; max-width: 64ch; }
.stage-track { display: grid; gap: 7px; min-width: 0; }
.stage-track h4 { font-size: var(--fs-fine); text-transform: uppercase; letter-spacing: .07em; color: var(--hue, var(--ink-4)); color: oklch(from var(--hue, var(--ink-4)) min(l, var(--text-lmax)) c h); font-weight: 680; }
.rm-list { display: grid; gap: 5px; grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr)); }
.rm-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; border: 1px solid transparent; color: var(--ink-2); font-size: var(--fs-small); transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease); min-width: 0; }
.rm-item:hover { background: var(--surface-2); border-color: var(--line); text-decoration: none; color: var(--ink); transform: translateX(2px); }
.rm-item .rm-t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rm-item .rm-m { font-size: var(--fs-micro); color: var(--ink-4); flex: none; }

/* ---------- topic ---------- */
.topic-shell { display: grid; gap: clamp(20px, 3.4vw, 40px); grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 1040px) { .topic-shell { grid-template-columns: minmax(0, 1fr) 226px; } }
.topic-shell > * { min-width: 0; }
.topic-head { border-bottom: 1px solid var(--line); padding-bottom: 20px; margin-bottom: 24px; }
.crumb { display: flex; align-items: center; gap: 7px; font-size: var(--fs-fine); color: var(--ink-4); margin-bottom: 11px; flex-wrap: wrap; }
.crumb a { color: var(--ink-3); } .crumb a:hover { color: var(--ink); }
.crumb .sep { opacity: .5; }
.topic-head h1 { font-size: clamp(1.8rem, 3.8vw, 2.5rem); letter-spacing: -0.028em; }
.topic-tag { margin-top: 11px; font-size: var(--fs-lead); color: var(--ink-3); max-width: 58ch; line-height: 1.45; letter-spacing: -0.01em; }
.topic-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 16px; }

.obj { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); padding: 15px 17px; max-width: var(--measure); }
.obj .obj-h { font-size: var(--fs-micro); text-transform: uppercase; letter-spacing: .08em; color: var(--ink-4); margin-bottom: 8px; }
.obj ul { margin: 0; padding-left: 1.1em; display: flex; flex-direction: column; gap: 5px; font-size: var(--fs-body); color: var(--ink-2); }

.topic-body { min-width: 0; }
.topic-body > * + * { margin-top: clamp(18px, 2.4vw, 28px); }
.topic-body > * { max-width: 100%; }
.topic-body > h2 { font-size: var(--fs-h2); color: var(--ink); margin-top: clamp(34px, 4.6vw, 54px) !important; scroll-margin-top: 76px; }
.topic-body > h2:first-child { margin-top: 0 !important; }
.topic-body > h3 { font-size: var(--fs-h3); color: var(--ink); margin-top: clamp(24px, 2.8vw, 32px) !important; scroll-margin-top: 76px; }
.topic-body p, .topic-body ul, .topic-body ol { max-width: var(--measure); font-size: var(--fs-read); line-height: 1.62; color: var(--ink-2); }
.topic-body ul, .topic-body ol { padding-left: 1.25em; display: flex; flex-direction: column; gap: .5em; }
.topic-body li::marker { color: var(--ink-4); }
.topic-body strong { color: var(--ink); font-weight: 620; }
.topic-body code { background: var(--surface-2); padding: .12em .38em; border-radius: 5px; border: 1px solid var(--line); font-size: .86em; color: var(--ink); }
.topic-body a { text-decoration: underline; text-decoration-color: var(--accent-line); text-underline-offset: 2.5px; }

.rail { position: sticky; top: calc(var(--chrome-h) + env(safe-area-inset-top, 0px) + 18px); display: flex; flex-direction: column; gap: 18px; min-width: 0; }
@media (max-width: 1039px) { .rail { position: static; } }
.rail-sec .rail-h { font-size: var(--fs-micro); text-transform: uppercase; letter-spacing: .08em; color: var(--ink-4); margin-bottom: 8px; }
.toc { display: flex; flex-direction: column; gap: 1px; border-left: 1px solid var(--line); }
.toc a { font-size: var(--fs-small); color: var(--ink-3); padding: 5px 0 5px 12px; border-left: 2px solid transparent; margin-left: -1px; transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease); }
.toc a:hover { color: var(--ink); text-decoration: none; }
.toc a[data-active="1"] { color: var(--ink); border-left-color: var(--accent); font-weight: 560; }
.toc a[data-sub="1"] { padding-left: 24px; font-size: var(--fs-fine); }
.rail-actions { display: flex; flex-direction: column; gap: 6px; }
.rail-actions .btn { justify-content: flex-start; width: 100%; height: auto; min-height: 34px; padding-block: 7px; white-space: normal; text-align: left; line-height: 1.3; }

.pager { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); margin-top: clamp(34px, 5vw, 56px); padding-top: 24px; border-top: 1px solid var(--line); }
.pager a { border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px 16px; color: var(--ink); background: var(--surface); transition: all var(--t-mid) var(--ease); display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.pager a:hover { text-decoration: none; border-color: var(--line-2); box-shadow: var(--lift-2); transform: translateY(-2px); }
.pager small { font-size: var(--fs-micro); text-transform: uppercase; letter-spacing: .07em; color: var(--ink-4); }
.pager b { font-size: var(--fs-body); font-weight: 620; letter-spacing: -0.012em; }

.reflist { display: flex; flex-direction: column; gap: 2px; max-width: var(--measure); }
.reflink { display: flex; align-items: baseline; gap: 10px; padding: 8px 10px; border-radius: 9px; color: var(--ink-2); font-size: var(--fs-body); transition: background var(--t-fast) var(--ease); min-width: 0; }
.reflink:hover { background: var(--surface-2); text-decoration: none; }
.reflink .rk { font-size: var(--fs-micro); text-transform: uppercase; letter-spacing: .06em; color: var(--ink-4); font-weight: 680; flex: none; width: 56px; }
.reflink .rt { flex: 1; min-width: 0; }
.reflink .ra { font-size: var(--fs-fine); color: var(--ink-4); flex: none; }

/* ---------- library / filters ---------- */
.lib-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.lib-filters { display: flex; gap: 6px; flex-wrap: wrap; min-width: 0; }
.lib-count { font-size: var(--fs-small); color: var(--ink-4); margin-left: auto; font-variant-numeric: tabular-nums; }

/* ---------- pattern pages ---------- */
.pat-hero { display: grid; gap: 18px; grid-template-columns: minmax(0,1fr); align-items: start; }
@media (min-width: 900px) { .pat-hero { grid-template-columns: minmax(0,1.3fr) minmax(0,1fr); } }
.pat-hero > * { min-width: 0; }

.trainer-shell { max-width: 780px; margin: 0 auto; min-width: 0; }
.tr-meta { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; font-size: var(--fs-small); color: var(--ink-3); flex-wrap: wrap; }
.tr-score { display: flex; gap: 14px; align-items: center; }
.tr-score b { color: var(--ink); font-variant-numeric: tabular-nums; }
.streakless { font-size: var(--fs-fine); color: var(--ink-4); }

/* ---------- recall ---------- */
.recall-wrap { max-width: 720px; margin: 0 auto; min-width: 0; }
.card-face {
  border: 1px solid var(--line); border-radius: var(--r-xl); background: var(--surface);
  padding: clamp(24px, 4.6vw, 42px); min-height: 240px;
  display: flex; flex-direction: column; justify-content: center; gap: 16px; box-shadow: var(--lift-2);
}
.card-face .cf-q { font-size: clamp(1.1rem, 2.4vw, 1.4rem); color: var(--ink); letter-spacing: -0.018em; line-height: 1.35; text-wrap: balance; }
.card-face .cf-a { font-size: var(--fs-read); color: var(--ink-2); line-height: 1.6; border-top: 1px solid var(--line); padding-top: 16px; animation: revealUp var(--t-mid) var(--ease) both; }
@keyframes revealUp { from { opacity: 0; transform: translateY(7px) } to { opacity: 1; transform: none } }
.card-face[data-flip="in"] { animation: cardIn var(--t-mid) var(--ease) both; }
@keyframes cardIn { from { opacity: 0; transform: translateY(12px) scale(.985) } to { opacity: 1; transform: none } }
.grade-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(92px, 100%), 1fr)); gap: 8px; margin-top: 14px; }
.grade { padding: 11px 8px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; align-items: center; gap: 3px; transition: all var(--t-fast) var(--ease); }
.grade:hover { border-color: var(--line-2); transform: translateY(-2px); box-shadow: var(--lift-2); }
.grade b { font-size: var(--fs-small); font-weight: 620; }
.grade span { font-size: var(--fs-micro); color: var(--ink-4); font-variant-numeric: tabular-nums; }
.grade[data-g="0"] b { color: var(--bad); } .grade[data-g="1"] b { color: var(--warn); }
.grade[data-g="2"] b { color: var(--ink); } .grade[data-g="3"] b { color: var(--good-text); }
.recall-meta { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 16px; font-size: var(--fs-small); color: var(--ink-3); flex-wrap: wrap; }

/* ---------- notes ---------- */
.notes-shell { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 960px) { .notes-shell { grid-template-columns: 210px minmax(0,1fr); } }
.notes-shell > * { min-width: 0; }
.notes-side { display: flex; flex-direction: column; gap: 14px; }
.notes-list { display: flex; flex-direction: column; gap: 1px; max-height: 340px; overflow-y: auto; }
.notes-list a { padding: 8px 10px; border-radius: 8px; font-size: var(--fs-small); color: var(--ink-3); display: flex; gap: 8px; align-items: center; min-width: 0; }
.notes-list a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.notes-list a[data-active="1"] { background: var(--accent-soft); color: var(--ink); font-weight: 560; }
.notes-list .nl-dot { width: 6px; height: 6px; border-radius: 99px; background: var(--good); flex: none; }

.pad { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; min-width: 0; }
.pad-bar { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); flex-wrap: wrap; }
.pad-pens { display: flex; gap: 4px; }
.pen { width: 27px; height: 27px; border-radius: 99px; border: 1.5px solid var(--line-2); display: grid; place-items: center; transition: transform var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease); }
.pen i { width: 13px; height: 13px; border-radius: 99px; display: block; }
.pen[aria-pressed="true"] { border-color: var(--ink); transform: scale(1.08); }
.pen-erase i { background: repeating-linear-gradient(45deg, var(--line-2) 0 3px, transparent 3px 6px); border: 1px solid var(--line-2); }
.pad-sizes { display: flex; gap: 4px; }
.psz { width: 25px; height: 25px; border-radius: 7px; display: grid; place-items: center; border: 1px solid var(--line); transition: all var(--t-fast) var(--ease); }
.psz i { background: var(--ink-3); border-radius: 99px; display: block; }
.psz[aria-pressed="true"] { background: var(--surface); border-color: var(--ink-4); box-shadow: var(--lift-1); }
.psz[aria-pressed="true"] i { background: var(--ink); }
.pad-right { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.pad-canvas-wrap { position: relative; background: var(--surface); }
.pad-canvas { display: block; width: 100%; touch-action: none; cursor: crosshair; }
.pad-foot { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-top: 1px solid var(--line); font-size: var(--fs-fine); color: var(--ink-4); flex-wrap: wrap; }
.cue-strip { display: flex; gap: 8px; flex-wrap: wrap; padding: 11px 12px; border-bottom: 1px solid var(--line); background: var(--surface); }
.cue { font-size: var(--fs-fine); padding: 4px 10px; border-radius: 99px; background: var(--surface-2); border: 1px dashed var(--line-2); color: var(--ink-3); }

/* ---------- progress ---------- */
.pg-grid { display: grid; gap: 13px; grid-template-columns: repeat(auto-fit, minmax(min(226px, 100%), 1fr)); }
.pg-track { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); padding: 14px 15px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.pg-track .pt-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.pg-track .pt-head b { font-size: var(--fs-body); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pg-track .pt-n { font-size: var(--fs-fine); color: var(--ink-4); font-variant-numeric: tabular-nums; flex: none; }
.heat { display: grid; grid-template-columns: repeat(auto-fill, minmax(11px, 1fr)); gap: 3px; }
.heat i { aspect-ratio: 1; border-radius: 3px; background: var(--surface-sunk); display: block; }
.heat i[data-v="1"] { background: color-mix(in srgb, var(--good) 32%, var(--surface-sunk)); }
.heat i[data-v="2"] { background: color-mix(in srgb, var(--good) 62%, var(--surface-sunk)); }
.heat i[data-v="3"] { background: var(--good); }

.panel > h2 { letter-spacing: -0.01em; }
.panel { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); padding: 17px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }

/* ---------- references ---------- */
.ref-sec + .ref-sec { margin-top: 30px; }
.ref-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(min(270px, 100%), 1fr)); }
.refcard { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); padding: 14px 15px; display: flex; flex-direction: column; gap: 5px; color: var(--ink); transition: all var(--t-mid) var(--ease); min-width: 0; }
.refcard:hover { text-decoration: none; border-color: var(--line-2); box-shadow: var(--lift-2); transform: translateY(-2px); }
.refcard b { font-size: var(--fs-body); font-weight: 620; letter-spacing: -0.012em; }
.refcard span { font-size: var(--fs-small); color: var(--ink-3); }
.refcard .rc-meta { margin-top: auto; padding-top: 8px; display: flex; gap: 8px; align-items: center; font-size: var(--fs-micro); color: var(--ink-4); text-transform: uppercase; letter-spacing: .06em; min-width: 0; }
