/* App + report components */
[hidden] { display: none !important; }
.brand { color: var(--brand); }
.mt { margin-top: 14px; }
.pad { padding: 16px; }
.card-h { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-h b { font-size: .9375rem; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.select { height: 30px; border-radius: 6px; border: 1px solid var(--border-subtle); background: var(--surface); padding: 0 8px; font-size: .8125rem; }
.progress-line { display: grid; gap: 6px; margin-bottom: 12px; }
.progress { height: 4px; border-radius: 99px; background: var(--surface-strong); overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--brand); transition: width .25s; }

/* W/D/L bar */
.wdl { display: flex; width: 100%; border-radius: 99px; overflow: hidden; background: var(--surface-strong); }
.wdl span { display: block; min-width: 0; }
.wdl .w { background: var(--win); } .wdl .d { background: var(--draw); } .wdl .l { background: var(--loss); }
.side-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; border: 1px solid var(--border-subtle); }
.side-dot.w { background: oklch(95% 0 0); } .side-dot.b { background: oklch(22% 0 0); }

.kv { display: grid; grid-template-columns: minmax(0, 1.4fr) auto minmax(60px, 1fr) 44px; gap: 10px; align-items: center; font-size: .8125rem; padding: 6px 0; border-top: 1px solid var(--border-subtle); }
.kv:first-of-type { border-top: 0; }
.kv > b { text-align: right; font-variant-numeric: tabular-nums; }
.blown-sum { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.blown-sum > div { text-align: center; padding: 12px; border-radius: 10px; background: var(--background); border: 1px solid var(--border-subtle); }
.blown-sum b { display: block; font-size: 1.75rem; font-weight: 800; }
.blown-sum span { font-size: .75rem; color: var(--text-muted); }

/* Tiles */
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.tile { padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border-subtle); background: var(--surface); display: grid; gap: 2px; }
.tile .tl { font-size: .6875rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); font-weight: 600; }
.tile b { font-size: 1.375rem; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }

/* Period report */
.period-tabs { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.period { height: 40px; border-radius: 10px; border: 1px solid var(--border-subtle); background: var(--surface); color: var(--text-secondary); font-size: .875rem; }
.period:hover { background: var(--surface-hover); }
.period.active { background: var(--surface-strong); color: var(--text-primary); border-color: color-mix(in oklch, var(--text-primary) 25%, transparent); }
.grade-card { display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: center; padding: 18px; overflow: hidden; }
.grade { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; font-size: 1.375rem; font-weight: 800; border: 2px solid currentColor; }
.grade.gA { color: var(--win); } .grade.gB { color: oklch(76% .15 140); } .grade.gC { color: var(--brand); } .grade.gD { color: var(--c-mistake); } .grade.gF { color: var(--loss); }
.wdl-big { font-size: 2rem; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; }
.grade-foot { grid-column: 1 / -1; margin: 6px -18px -18px; padding: 10px 18px; border-top: 1px solid var(--border-subtle); background: var(--background); font-size: .8125rem; }
.rating-svg { width: 100%; height: 140px; display: block; }
.blown-list { display: grid; gap: 6px; }
.blown { display: grid; grid-template-columns: auto 1fr auto auto auto; gap: 12px; align-items: center; text-align: left; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--border-subtle); background: var(--background); font-size: .8125rem; }
.blown:hover { background: var(--surface-hover); }

/* Tables */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.toolbar .seg { justify-content: flex-start; }
.table-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid var(--border-subtle); background: var(--surface); }
.tbl { width: 100%; border-collapse: collapse; font-size: .8125rem; }
.tbl th { text-align: left; font-weight: 600; color: var(--text-muted); font-size: .75rem; padding: 10px 12px; border-bottom: 1px solid var(--border-subtle); white-space: nowrap; }
.tbl th.sortable { cursor: pointer; } .tbl th.sortable:hover { color: var(--text-primary); }
.tbl td { padding: 9px 12px; border-top: 1px solid var(--border-subtle); vertical-align: middle; }
.tbl tr:first-child td { border-top: 0; }
.tbl tbody tr:hover td { background: var(--surface-hover); }
.tbl .n { text-align: right; font-variant-numeric: tabular-nums; }
.tbl td .wdl { margin-bottom: 4px; }
.tbl .players { line-height: 1.35; }
.tbl .players .op { color: var(--text-muted); font-size: .75rem; }
.acc-num { font-weight: 800; font-size: .9375rem; }

/* Tree */
.tree { display: grid; grid-template-columns: minmax(220px, 340px) 1fr; gap: 18px; align-items: start; }
.tree-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.crumbs { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; font-size: .8125rem; margin-bottom: 10px; min-height: 26px; }
.crumb { border: 0; background: var(--surface-strong); border-radius: 5px; padding: 2px 7px; font-size: .75rem; }
.crumb:hover { background: color-mix(in oklch, var(--brand) 25%, transparent); }
.tree-rows { border-radius: 10px; border: 1px solid var(--border-subtle); overflow: hidden; background: var(--surface); }
.tree-row { display: grid; grid-template-columns: 90px 60px 1fr 54px; gap: 12px; align-items: center; width: 100%; padding: 8px 12px; border: 0; border-top: 1px solid var(--border-subtle); background: transparent; text-align: left; font-size: .8125rem; }
.tree-row.head { border-top: 0; font-size: .6875rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.tree-row.foot { background: var(--background); }
button.tree-row:hover { background: var(--surface-hover); }
.tree-row .n { text-align: right; font-variant-numeric: tabular-nums; }
.mv-san { font-weight: 700; }

/* Heatmap */
.hm-scroll { overflow-x: auto; padding-bottom: 4px; }
.hm-months { display: grid; grid-template-columns: repeat(53, 13px); gap: 3px; font-size: .625rem; color: var(--text-muted); height: 14px; min-width: max-content; }
.hm-months span { white-space: nowrap; }
.heatmap { display: grid; grid-template-rows: repeat(7, 13px); grid-auto-flow: column; grid-auto-columns: 13px; gap: 3px; min-width: max-content; }
.hm-cell { display: inline-block; width: 13px; height: 13px; border-radius: 3px; background: var(--surface-strong); vertical-align: middle; }
.hm-cell.empty { background: transparent; }
.hm-cell.l1 { background: color-mix(in oklch, var(--brand) 30%, transparent); } .hm-cell.l2 { background: color-mix(in oklch, var(--brand) 50%, transparent); } .hm-cell.l3 { background: color-mix(in oklch, var(--brand) 75%, transparent); } .hm-cell.l4 { background: var(--brand); }
.bars { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; height: 130px; align-items: end; }
.bar-col { position: relative; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; padding-bottom: 16px; }
.bar-col span { display: block; border-radius: 3px 3px 0 0; min-height: 2px; }
.bar-col i { position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); font-style: normal; font-size: .625rem; color: var(--text-muted); white-space: nowrap; }

/* Review */
.review { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.rv-left { min-width: 0; }
.rv-nav { display: flex; gap: 6px; justify-content: center; margin: 4px 0 10px; }
.rv-nav .btn { min-width: 44px; }
.rv-summary { padding: 14px; margin-top: 10px; font-size: .8125rem; color: var(--text-secondary); line-height: 1.6; }
.rv-summary ul { margin: 8px 0 0; padding-left: 18px; }
.rv-summary b { color: var(--text-primary); }
.rv-explain { padding: 14px; min-height: 96px; }
.rv-explain-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.rv-note { font-size: .875rem; color: var(--text-secondary); line-height: 1.6; }
.rv-cols { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 10px; margin-top: 10px; }
.movelist .row { grid-template-columns: 28px minmax(0, 1fr) minmax(0, 1fr); }
.movelist .mv { white-space: nowrap; min-width: 0; padding: 4px 4px; gap: 4px; }
.movelist .mv span:not(.ev):not(.cls-icon) { overflow: hidden; text-overflow: ellipsis; }
.movelist .mv .ev { font-size: .625rem; }
.rv-cols .movelist { max-height: 440px; }
.rv-acc { padding: 8px 4px; }
.review .board-wrap .evalbar { min-height: 100%; }

/* ---------------- App shell ---------------- */
.app { display: grid; grid-template-columns: 76px 1fr; min-height: 100vh; background: var(--background); }
.rail { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 6px; border-right: 1px solid var(--border-subtle); background: color-mix(in oklch, var(--background) 85%, #000); }
:root[data-theme="light"] .rail { background: var(--surface); }
.rail .logo-mark { width: 36px; height: 36px; font-size: 21px; margin-bottom: 12px; }
.rail-btn { width: 64px; padding: 7px 2px; border-radius: 10px; border: 0; background: transparent; display: grid; justify-items: center; gap: 3px; font-size: .6875rem; color: var(--text-muted); text-align: center; }
.rail-btn .ri { font-size: 19px; line-height: 1; color: var(--text-secondary); }
.rail-btn:hover { background: var(--surface-hover); color: var(--text-primary); }
.rail-btn.active { background: var(--surface-strong); color: var(--text-primary); }
.rail-btn.active .ri { color: var(--brand); }
.rail-spacer { flex: 1; }
.main { min-width: 0; padding: 16px 20px 80px; max-width: 1240px; width: 100%; margin: 0 auto; }
.app-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.app-form .input { height: 38px; flex: 1 1 220px; }
.profile { padding: 16px; display: grid; gap: 14px; }
.profile-top { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.avatar { width: 52px; height: 52px; border-radius: 12px; background: var(--surface-strong); display: grid; place-items: center; font-size: 26px; border: 1px solid var(--border-subtle); }
.profile h1 { font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.badge { font-size: .6875rem; font-weight: 600; padding: 2px 7px; border-radius: 6px; border: 1px solid var(--border-subtle); background: var(--surface-strong); color: var(--text-secondary); }
.badge.brand { color: var(--brand); border-color: color-mix(in oklch, var(--brand) 40%, transparent); background: color-mix(in oklch, var(--brand) 10%, transparent); }
.profile-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.deep { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; padding: 10px 14px; border-radius: 12px; border: 1px solid color-mix(in oklch, var(--brand) 25%, transparent); background: color-mix(in oklch, var(--brand) 6%, transparent); margin-top: 12px; font-size: .8125rem; }
.deep .progress { width: 100%; }
.tabs { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 16px 0; padding-bottom: 2px; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: 1 0 auto; display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--border-subtle); background: var(--surface); font-size: .875rem; font-weight: 500; color: var(--text-secondary); white-space: nowrap; }
.tab:hover { background: var(--surface-hover); color: var(--text-primary); }
.tab.active { background: var(--surface-strong); color: var(--text-primary); border-color: color-mix(in oklch, var(--text-primary) 22%, transparent); }
.tab .count { font-size: .6875rem; padding: 0 6px; border-radius: 99px; background: color-mix(in oklch, var(--brand) 20%, transparent); color: var(--brand); }
.panel-head { display: flex; justify-content: space-between; align-items: end; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.panel-head h2 { font-size: 1.0625rem; font-weight: 700; }
.panel-head p { font-size: .8125rem; color: var(--text-muted); }
.empty-state { text-align: center; padding: 56px 20px; }
.empty-state h2 { font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; margin-bottom: 8px; }
.empty-state p { color: var(--text-secondary); max-width: 34rem; margin: 0 auto 18px; }
.loader { display: grid; gap: 10px; justify-items: center; padding: 60px 20px; text-align: center; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--surface-strong); border-top-color: var(--brand); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { border-radius: 12px; background: linear-gradient(90deg, var(--surface) 0%, var(--surface-hover) 50%, var(--surface) 100%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
.notice { padding: 10px 14px; border-radius: 10px; border: 1px solid color-mix(in oklch, var(--loss) 40%, transparent); background: color-mix(in oklch, var(--loss) 8%, transparent); font-size: .875rem; }

/* Puzzles */
.puzzle { display: grid; grid-template-columns: minmax(0, 460px) 1fr; gap: 20px; align-items: start; }
.puzzle-side { display: grid; gap: 12px; }
.puzzle-status { padding: 14px; border-radius: 12px; border: 1px solid var(--border-subtle); background: var(--surface); }
.puzzle-status h3 { font-size: 1.0625rem; font-weight: 700; margin-bottom: 4px; }
.puzzle-status.ok { border-color: color-mix(in oklch, var(--win) 50%, transparent); background: color-mix(in oklch, var(--win) 8%, transparent); }
.puzzle-status.bad { border-color: color-mix(in oklch, var(--loss) 50%, transparent); background: color-mix(in oklch, var(--loss) 8%, transparent); }
.puzzle-list { display: flex; flex-wrap: wrap; gap: 6px; }
.pz-dot { width: 26px; height: 26px; border-radius: 6px; border: 1px solid var(--border-subtle); background: var(--surface); font-size: .6875rem; }
.pz-dot.cur { border-color: var(--brand); color: var(--brand); }
.pz-dot.solved { background: color-mix(in oklch, var(--win) 25%, transparent); } .pz-dot.failed { background: color-mix(in oklch, var(--loss) 25%, transparent); }

@media (max-width: 1000px) {
  .review { grid-template-columns: 1fr; }
  .period-tabs { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .rail { position: fixed; z-index: 30; top: auto; bottom: 0; left: 0; right: 0; height: auto; flex-direction: row; justify-content: space-around; padding: 4px; border-right: 0; border-top: 1px solid var(--border-subtle); }
  .rail .logo-mark, .rail-spacer, .rail .rail-extra { display: none; }
  .rail-btn { width: auto; flex: 1; }
  .main { padding: 12px 16px 90px; }
  .two-col, .tree, .puzzle, .rv-cols { grid-template-columns: 1fr; }
  .tree-board { max-width: 360px; }
  .kv { grid-template-columns: minmax(0, 1fr) auto 60px 40px; }
  .blown { grid-template-columns: auto 1fr auto; }
  .blown > :nth-child(4), .blown > :nth-child(5) { display: none; }
  .profile-actions { margin-left: 0; }
}
.rail { overflow-y: auto; scrollbar-width: none; }
.rail::-webkit-scrollbar { display: none; }
@media (min-width: 761px) and (max-height: 900px) { .rail-btn { padding: 5px 2px; } .rail .logo-mark { margin-bottom: 4px; } }

.gold { color: var(--gold); }
.goal.done .ck { background: var(--brand); border-color: var(--brand); color: var(--brand-fg); }

/* ---- analysis app: v2 ---- */
.stack { display: grid; gap: 14px; }
.toolrow { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin: 12px 0 0; }
.cmdk { position: relative; flex: 1 1 320px; max-width: 520px; }
.cmdk .input { height: 38px; padding-right: 44px; }
.cmdk kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-size: .6875rem; padding: 2px 6px; border-radius: 5px; border: 1px solid var(--border-subtle); color: var(--text-muted); background: var(--background); }
.colpick { position: relative; }
.colmenu { position: absolute; right: 0; top: 36px; z-index: 20; display: grid; gap: 8px; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border-subtle); background: var(--surface); box-shadow: 0 12px 30px oklch(0% 0 0 / .4); font-size: .8125rem; min-width: 180px; }
.sortbar, .filterbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; }
.sortchip { border: 0; background: transparent; color: var(--text-muted); font-size: .8125rem; padding: 4px 8px; border-radius: 6px; }
.sortchip:hover { color: var(--text-primary); }
.sortchip[aria-pressed="true"] { color: var(--brand); background: color-mix(in oklch, var(--brand) 14%, transparent); font-weight: 600; }
.pz-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.pz-card { display: grid; gap: 8px; align-content: start; text-align: left; padding: 18px; border-radius: 16px; border: 1px solid var(--border-subtle); background: var(--surface); transition: transform .2s, border-color .2s; }
.pz-card:hover { transform: translateY(-2px); border-color: color-mix(in oklch, var(--brand) 45%, transparent); }
.pz-card b { font-size: 1.0625rem; } .pz-card p { font-size: .8125rem; color: var(--text-secondary); line-height: 1.55; }
.pz-card ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; font-size: .75rem; color: var(--text-muted); }
.pz-card .badge { justify-self: start; }
.pz-ic { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font-size: 20px; color: var(--brand); background: color-mix(in oklch, var(--brand) 14%, transparent); }
.mode-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.mode-card { display: grid; gap: 2px; text-align: left; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border-subtle); background: var(--surface); }
.mode-card span { font-size: .75rem; color: var(--text-muted); }
.mode-card[aria-pressed="true"] { border-color: var(--brand); background: color-mix(in oklch, var(--brand) 10%, var(--surface)); }
.tree-controls { margin-top: 12px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; align-items: start; }
.tree-controls .ctl { display: grid; gap: 6px; } .tree-controls input[type=range] { accent-color: var(--brand); width: 100%; }
.graph-wrap { position: relative; border-radius: 12px; border: 1px solid var(--border-subtle); background: var(--background); overflow: hidden; }
.graph-svg { width: 100%; height: 480px; display: block; cursor: grab; touch-action: none; }
.graph-ctl { position: absolute; right: 10px; bottom: 10px; display: flex; gap: 4px; }
.graph-ctl button { min-width: 34px; height: 30px; border-radius: 6px; border: 1px solid var(--border-subtle); background: var(--surface); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; vertical-align: -1px; margin: 0 2px 0 8px; }
.dot.good { background: var(--win); } .dot.even { background: var(--draw); } .dot.losing { background: var(--loss); }
.trouble { padding: 10px 0; border-top: 1px solid var(--border-subtle); } .trouble:first-of-type { border-top: 0; }
.mt { margin-top: 14px; }
@media (max-width: 900px) { .tree-controls { grid-template-columns: 1fr 1fr; } }
.rv-tools { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin: 8px 0; }
.rv-tools input[type=range] { accent-color: var(--brand); vertical-align: middle; }
.rv-lines { padding: 12px; margin-top: 10px; }
.expl { margin: 6px 0 10px; padding-left: 18px; display: grid; gap: 6px; font-size: .8125rem; color: var(--text-secondary); line-height: 1.55; }
.link-btn { background: none; border: 0; padding: 0; color: var(--brand); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.rv-explain-head { flex-wrap: wrap; gap: 8px; }
