/* Tool pages: header, page layout, interactive board, trainers */
body.tool { background: var(--background); min-height: 100vh; display: flex; flex-direction: column; }
.tool-header { border-bottom: 1px solid var(--border-subtle); background: color-mix(in oklch, var(--background) 92%, transparent); backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 20; }
.tool-header .nav-pill { color: var(--text-secondary); background: transparent; border-color: transparent; }
.tool-header .nav-pill:hover { background: var(--surface-hover); }
.nav-pill.is-active { background: var(--surface-strong) !important; color: var(--text-primary) !important; border-color: var(--border-subtle) !important; }
.burger-btn { display: none; }
.mobile-menu { display: grid; padding: 8px 16px 14px; gap: 2px; border-bottom: 1px solid var(--border-subtle); background: var(--background); position: sticky; top: 61px; z-index: 19; }
.mobile-menu a { padding: 10px 4px; border-bottom: 1px solid var(--border-subtle); font-weight: 500; }
@media (max-width: 560px) { .burger-btn { display: grid; } }
@media (min-width: 561px) { .mobile-menu { display: none !important; } }
.tool-header .community-btn span { display: inline; }
.page { width: 100%; max-width: 1180px; margin: 0 auto; padding: 24px 16px 40px; flex: 1; }
.page-head { margin-bottom: 20px; }
.page-head h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); font-weight: 900; letter-spacing: -.04em; line-height: 1.1; }
.page-head p { color: var(--text-secondary); margin-top: 6px; max-width: 44rem; }
.page-head .eyebrow { color: var(--brand); margin-bottom: 8px; letter-spacing: .18em; }

.board-layout { display: grid; grid-template-columns: minmax(0, 560px) minmax(280px, 1fr); gap: 20px; align-items: start; }
.board-col { min-width: 0; }
.side-col { display: grid; gap: 12px; min-width: 0; }
.board-frame { display: grid; grid-template-columns: 22px 1fr; gap: 8px; }
.board-frame.no-bar { grid-template-columns: 1fr; }
.board { position: relative; }
.sq.check::before { content: ""; position: absolute; inset: 0; background: radial-gradient(circle, color-mix(in oklch, var(--loss) 90%, transparent) 0%, color-mix(in oklch, var(--loss) 40%, transparent) 45%, transparent 75%); }
.sq.hint:has(.pc)::after { width: 88%; height: 88%; background: transparent; border: 4px solid oklch(0% 0 0 / .22); }
.drag-piece { position: fixed; z-index: 100; pointer-events: none; display: grid; place-items: center; font-family: "Apple Symbols", "Segoe UI Symbol", "DejaVu Sans", serif; line-height: 1; filter: drop-shadow(0 6px 8px oklch(0% 0 0 / .4)); }
.drag-piece span { grid-area: 1 / 1; }
.promo-overlay { position: absolute; inset: 0; z-index: 10; background: oklch(0% 0 0 / .55); display: grid; place-items: center; }
.promo-box { display: flex; gap: 6px; padding: 8px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border-subtle); }
.promo-box button { width: 64px; height: 64px; border-radius: 8px; border: 1px solid var(--border-subtle); background: var(--chess-light-sq); font-size: 52px; display: grid; place-items: center; container-type: inline-size; }
.promo-box .pc { font-size: 52px; }

.panel { border-radius: 14px; border: 1px solid var(--border-subtle); background: var(--surface); padding: 14px; }
.panel h3 { font-size: .9375rem; font-weight: 700; margin-bottom: 8px; }
.row-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.field { display: grid; gap: 4px; font-size: .8125rem; color: var(--text-secondary); }
.field .input { height: 38px; }
.lines { display: grid; gap: 6px; }
.line { display: grid; grid-template-columns: 58px 1fr; gap: 8px; align-items: start; font-size: .8125rem; padding: 6px 8px; border-radius: 8px; background: var(--background); border: 1px solid var(--border-subtle); cursor: pointer; }
.line:hover { border-color: color-mix(in oklch, var(--brand) 40%, transparent); }
.line .sc { font-family: var(--font-mono); font-weight: 700; text-align: center; border-radius: 5px; padding: 1px 0; }
.line .sc.pos { background: oklch(95% 0 0); color: oklch(15% 0 0); } .line .sc.neg { background: oklch(25% 0 0); color: #fff; }
.line .pv { color: var(--text-secondary); line-height: 1.5; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.moves-flow { display: flex; flex-wrap: wrap; gap: 2px 4px; font-size: .8125rem; max-height: 220px; overflow-y: auto; padding: 8px; border-radius: 8px; background: var(--background); border: 1px solid var(--border-subtle); }
.moves-flow .no { color: var(--text-muted); margin-left: 4px; }
.moves-flow .m { padding: 1px 5px; border-radius: 4px; cursor: pointer; }
.moves-flow .m:hover { background: var(--surface-hover); }
.moves-flow .m.cur { background: color-mix(in oklch, var(--brand) 25%, transparent); }
.mono { font-family: var(--font-mono); font-size: .75rem; }
.palette { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.palette button { aspect-ratio: 1; border-radius: 6px; border: 1px solid var(--border-subtle); background: var(--chess-light-sq); display: grid; place-items: center; container-type: inline-size; padding: 0; }
.palette button .pc { font-size: 80cqi; }
.palette button[aria-pressed="true"] { outline: 2px solid var(--brand); outline-offset: 1px; }
.palette .trash { background: var(--surface-strong); color: var(--text-primary); font-size: 18px; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: .8125rem; font-weight: 600; background: var(--surface-strong); }
.status-pill.ok { background: color-mix(in oklch, var(--win) 20%, transparent); color: var(--win); }
.status-pill.bad { background: color-mix(in oklch, var(--loss) 20%, transparent); color: var(--loss); }
.big-num { font-size: 2.25rem; font-weight: 900; letter-spacing: -.04em; font-variant-numeric: tabular-nums; line-height: 1; }

/* Hub cards */
.hub { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.hub a { display: grid; gap: 6px; padding: 18px; border-radius: 14px; border: 1px solid var(--border-subtle); background: var(--surface); transition: transform .2s, border-color .2s; }
.hub a:hover { transform: translateY(-2px); border-color: color-mix(in oklch, var(--brand) 40%, transparent); }
.hub .hi { font-size: 26px; color: var(--brand); }
.tile b.gold, .metric b.gold { color: var(--gold); }
.hub b { font-size: 1rem; }
.hub span { font-size: .8125rem; color: var(--text-muted); line-height: 1.5; }

/* Coordinate trainer */
.coord-target { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; z-index: 5; font-size: 22cqi; font-weight: 900; color: oklch(100% 0 0 / .85); text-shadow: 0 4px 20px oklch(0% 0 0 / .6); }

/* Knightdoku */
.kd-grid { display: grid; gap: 3px; width: 100%; max-width: 480px; aspect-ratio: 1; }
.kd-cell { display: grid; place-items: center; border-radius: 6px; font-weight: 800; font-size: clamp(14px, 3.5vw, 22px); border: 0; background: var(--chess-light-sq); color: oklch(20% 0 0); position: relative; }
.kd-cell.d { background: var(--chess-dark-sq); }
.kd-cell.wall { background: var(--surface-strong); }
.kd-cell.visited { background: color-mix(in oklch, var(--brand) 55%, transparent); }
.kd-cell.current { background: var(--brand); }
.kd-cell.reach { box-shadow: inset 0 0 0 3px color-mix(in oklch, var(--win) 90%, transparent); cursor: pointer; }
.kd-cell .kn { font-size: 1.6em; line-height: 1; }

/* Wrapped */
.story { position: relative; max-width: 420px; margin: 0 auto; aspect-ratio: 9 / 16; border-radius: 24px; overflow: hidden; border: 1px solid var(--border-subtle); box-shadow: 0 30px 80px oklch(0% 0 0 / .5); }
.slide { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; padding: 32px 28px; gap: 12px; color: #fff; opacity: 0; transform: scale(.98); transition: opacity .4s, transform .4s; pointer-events: none; }
.slide.on { opacity: 1; transform: none; pointer-events: auto; }
.slide .k { font-size: .75rem; letter-spacing: .2em; text-transform: uppercase; opacity: .8; font-weight: 700; }
.slide .huge { font-size: 4.5rem; font-weight: 900; letter-spacing: -.05em; line-height: .95; }
.slide .mid { font-size: 1.75rem; font-weight: 800; letter-spacing: -.03em; line-height: 1.15; }
.slide p { font-size: 1rem; opacity: .9; line-height: 1.5; }
.story-bars { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; gap: 4px; z-index: 3; }
.story-bars span { flex: 1; height: 3px; border-radius: 3px; background: oklch(100% 0 0 / .3); overflow: hidden; }
.story-bars span i { display: block; height: 100%; width: 0; background: #fff; }
.story-bars span.done i { width: 100%; }
.story-nav { position: absolute; inset: 0; display: grid; grid-template-columns: 1fr 2fr; z-index: 2; }
.story-nav button { background: transparent; border: 0; }

/* Learn */
.learn-layout { display: grid; grid-template-columns: 240px 1fr; gap: 32px; align-items: start; }
.learn-toc { position: sticky; top: 84px; display: grid; gap: 2px; font-size: .8125rem; }
.learn-toc a { padding: 6px 10px; border-radius: 8px; color: var(--text-secondary); }
.learn-toc a:hover, .learn-toc a.on { background: var(--surface-hover); color: var(--text-primary); }
.article { max-width: 44rem; }
.article h2 { font-size: 1.75rem; font-weight: 800; letter-spacing: -.03em; margin: 8px 0 12px; scroll-margin-top: 90px; }
.article h3 { font-size: 1.125rem; font-weight: 700; margin: 22px 0 8px; }
.article p, .article li { color: var(--text-secondary); line-height: 1.75; font-size: .9875rem; }
.article p + p { margin-top: 12px; }
.article ul, .article ol { padding-left: 20px; display: grid; gap: 6px; }
.article section { padding-bottom: 40px; margin-bottom: 40px; border-bottom: 1px solid var(--border-subtle); }
.article .cta { display: inline-flex; margin-top: 16px; }
.article strong { color: var(--text-primary); }

/* Profile metrics (analyze app) */
.metric-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.metric { padding: 14px; border-radius: 12px; border: 1px solid var(--border-subtle); background: var(--surface); display: grid; gap: 6px; }
.metric .tl { font-size: .6875rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); font-weight: 600; }
.metric b { font-size: 1.375rem; font-weight: 800; letter-spacing: -.02em; }
.metric p { font-size: .75rem; color: var(--text-muted); line-height: 1.5; }
.meter { height: 6px; border-radius: 99px; background: var(--surface-strong); overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.goal { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: var(--background); border: 1px solid var(--border-subtle); font-size: .8125rem; }
.goal .ck { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--border-subtle); display: grid; place-items: center; font-size: 11px; flex-shrink: 0; }
.goal.done .ck { background: var(--win); border-color: var(--win); color: #000; }
.goal.done span { color: var(--text-muted); text-decoration: line-through; }
.goals-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px; }

@media (max-width: 900px) {
  .board-layout, .learn-layout { grid-template-columns: 1fr; }
  .learn-toc { position: static; grid-template-columns: repeat(2, 1fr); }
}
.slide.on.top { z-index: 3; }
ul.prep { margin: 0; padding-left: 18px; display: grid; gap: 8px; font-size: .875rem; color: var(--text-secondary); line-height: 1.6; }
ul.prep b { color: var(--text-primary); }
.star { position: absolute; z-index: 2; font-size: 7cqi; color: var(--brand); text-shadow: 0 2px 6px oklch(0% 0 0 / .5); animation: star-pulse 1.6s ease-in-out infinite; }
@keyframes star-pulse { 50% { transform: scale(1.15); } }
.lesson-list { display: flex; flex-wrap: wrap; gap: 6px; }
.lesson-list .chip { display: inline-flex; align-items: center; gap: 4px; }
.lesson-list .pc { container-type: normal; }
