:root {
  color-scheme: light;
  --ink: #17201b;
  --muted: #68716b;
  --paper: #f7f5ef;
  --white: #fffefa;
  --forest: #1f5942;
  --forest-dark: #163e30;
  --mint: #d9ead8;
  --mint-light: #edf4ea;
  --coral: #e66045;
  --amber: #e8ae45;
  --line: #dcded6;
  --board-light: #eee9db;
  --board-dark: #70947b;
  --shadow: 0 16px 42px rgba(23, 32, 27, 0.1);
  --arrow-green: rgba(31, 89, 66, 0.82);
  --arrow-blue: rgba(43, 108, 176, 0.82);
  --arrow-red: rgba(197, 58, 42, 0.82);
  --arrow-amber: rgba(198, 140, 30, 0.85);
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--paper); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
  font-family: "Avenir Next", Avenir, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
  letter-spacing: 0;
}

button, input, textarea, select { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
[hidden] { display: none !important; }

h1, h2, h3, p { margin-top: 0; }
h1, h2, h3, .brand { font-family: "Avenir Next", Avenir, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
h1 { font-size: clamp(2rem, 5vw, 3.35rem); line-height: 1.08; margin-bottom: 0.65rem; }
h2 { line-height: 1.15; }

.topbar {
  height: 68px;
  padding: 0 20px;
  display: none;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(247, 245, 239, 0.96);
  position: sticky;
  top: 0;
  z-index: 30;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  padding: 0;
  background: none;
  font-size: 1.24rem;
  font-weight: 800;
  cursor: pointer;
}

.brand img { width: 37px; height: 37px; object-fit: cover; border-radius: 6px; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.streak-pill { border: 0; background: var(--mint-light); border-radius: 999px; display: flex; gap: 5px; align-items: center; padding: 6px 12px 6px 10px; cursor: pointer; color: var(--forest-dark); }
.streak-pill b { font-weight: 800; font-size: 0.95rem; }
.flame { font-size: 1rem; line-height: 1; }
.streak-word { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.02em; color: var(--forest); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--forest); color: white; display: grid; place-items: center; text-decoration: none; font-weight: 700; }
/* Auth state: logged out shows a Sign in button; signed in shows streak + avatar.
   `signed-in` is toggled on <body> once /api/me confirms a session. */
.signin-btn { display: inline-flex; align-items: center; padding: 8px 16px; border-radius: 999px; background: var(--forest); color: #fff; text-decoration: none; font-weight: 700; font-size: 0.9rem; }
#homeBoard { cursor: pointer; }
.top-actions .streak-pill, .top-actions .avatar { display: none; }
body.signed-in .signin-btn { display: none; }
body.signed-in .top-actions .streak-pill { display: flex; }
body.signed-in .top-actions .avatar { display: grid; }

.side-nav {
  position: fixed;
  inset: 0 auto 0 0;
  width: 242px;
  border-right: 1px solid var(--line);
  background: #f1f0e9;
  padding: 30px 22px;
  display: flex;
  flex-direction: column;
  z-index: 40;
}

.side-brand { padding: 0 10px 30px; }
.side-nav nav { display: grid; gap: 7px; }
.side-nav .side-tools { margin-top: 16px; }
.nav-item {
  border: 0;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 12px 14px;
  border-radius: 7px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  color: #58615b;
}
.nav-item:hover { background: rgba(31, 89, 66, 0.07); color: var(--forest); }
.nav-item.active { background: var(--mint); color: var(--forest-dark); }
.nav-icon { width: 22px; text-align: center; font-size: 1.25rem; line-height: 1; }

/* Logged out: a prominent Sign in button (desktop sidebar). Signed in: JS
   rebuilds it as the user's initial avatar + "Settings" (see .sync-link-account),
   and body.signed-in strips the button styling back to a link. */
.sync-link { margin: auto 10px 12px; padding: 11px 14px; border-radius: 10px; background: var(--forest); color: #fff; text-align: center; font-size: 0.86rem; font-weight: 700; text-decoration: none; }
body.signed-in .sync-link { padding: 0; background: transparent; color: var(--forest); font-size: 0.82rem; }
body.signed-in .sync-link-account { display: flex; align-items: center; gap: 9px; padding: 6px 8px; text-align: left; font-weight: 700; }
.sync-avatar { flex: none; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--forest); color: #fff; font-size: 0.72rem; font-weight: 800; }
.side-legal { display: flex; gap: 12px; margin: 12px 10px 0; }
.side-legal a, .app-legal a { color: var(--muted); font-size: 0.7rem; text-decoration: none; }
.side-legal a:hover, .app-legal a:hover { color: var(--forest); text-decoration: underline; }

main { margin-left: 242px; min-height: 100vh; }
.view { width: min(1080px, calc(100% - 64px)); margin: 0 auto; padding: 64px 0 96px; }
.view.preview-mode > :not(.access-preview) { display: none !important; }
.view.preview-mode { width: min(1080px, calc(100% - 64px)); min-height: 100vh; height: auto; padding: 64px 0 96px; display: block; overflow: visible; }
.access-preview { min-height: min(560px, calc(100vh - 128px)); padding-top: clamp(42px, 8vh, 96px); display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start; max-width: 680px; box-sizing: border-box; }
.access-preview h1 { min-height: 2.4em; max-width: 650px; margin-bottom: 18px; }
.access-preview .lede { min-height: 4.95em; max-width: 590px; line-height: 1.65; }
.access-preview-layout { width: min(100%, 640px); min-height: 132px; margin: 27px 0 24px; padding: 12px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--white); box-shadow: 0 10px 25px rgba(23,32,27,0.05); }
.access-preview-panel { min-height: 106px; padding: 11px; display: grid; grid-template-rows: 7px 2.4em 5px 5px; align-content: start; gap: 8px; border: 1px solid #dce2da; border-radius: 4px; background: var(--paper); }
.access-preview-panel b { display: flex; align-items: flex-start; margin: 0; color: var(--forest-dark); font-size: 0.69rem; line-height: 1.2; }
.access-preview-panel span { display: block; width: 35%; height: 7px; border-radius: 3px; background: var(--mint); }
.access-preview-panel i { display: block; width: 82%; height: 5px; margin: 0; border-radius: 3px; background: #d9dfd8; }
.access-preview-panel i:last-child { width: 60%; }
.access-preview-features { display: flex; flex-wrap: wrap; gap: 8px; margin: 26px 0 32px; }
.access-preview-features span { padding: 8px 11px; border: 1px solid var(--line); border-radius: 5px; color: var(--forest); background: var(--white); font-size: 0.74rem; font-weight: 700; }
.access-preview .primary-btn { min-width: 190px; }
.home-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 32px; margin-bottom: 35px; }
.lede { color: var(--muted); font-size: 1.04rem; margin-bottom: 0; }
.home-heading .home-hero-support { margin: 10px 0 0; color: var(--ink); font-size: 0.95rem; font-weight: 600; }
.home-heading .ai-note { margin: 9px 0 0; color: var(--muted); font-size: 0.82rem; font-weight: 600; }
.home-heading .ai-note span { color: var(--forest); }
.eyebrow { color: var(--forest); font-size: 0.7rem; font-weight: 800; letter-spacing: 0.12em; margin-bottom: 10px; }

.week-streak { display: flex; gap: 8px; padding-bottom: 5px; }
.day-dot { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.day-dot span { width: 28px; height: 28px; border: 1px solid #ced1ca; border-radius: 50%; display: grid; place-items: center; font-size: 0.7rem; color: white; }
.day-dot small { color: #8b918d; font-size: 0.62rem; text-transform: uppercase; }
.day-dot.done span { background: var(--forest); border-color: var(--forest); }
.day-dot.today span { box-shadow: 0 0 0 3px var(--mint); border-color: var(--forest); }

.daily-lesson {
  min-height: 390px;
  border-radius: 8px;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  background: var(--forest);
  color: white;
  box-shadow: var(--shadow);
}
.lesson-copy { padding: 48px 54px; display: flex; flex-direction: column; align-items: flex-start; }
.lesson-kicker { font-size: 0.7rem; font-weight: 800; letter-spacing: 0.12em; color: #cfe2d1; margin-bottom: 38px; }
.pulse-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--coral); margin-right: 8px; box-shadow: 0 0 0 5px rgba(230, 96, 69, 0.16); }
.lesson-meta { font-size: 0.69rem; color: #b9d3c1; letter-spacing: 0.08em; font-weight: 700; margin-bottom: 12px; }
.lesson-copy h2 { font-size: clamp(2rem, 4vw, 3rem); margin-bottom: 14px; }
.lesson-variation { color: #fff !important; font: 700 0.78rem ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.02em; margin: 0 0 12px; }
.lesson-copy > p:not(.lesson-meta) { max-width: 520px; color: #e3eee5; }
.lesson-stats { display: flex; gap: 22px; font-size: 0.78rem; color: #bfd5c5; margin: 6px 0 24px; }
.lesson-stats span + span { border-left: 1px solid rgba(255,255,255,0.22); padding-left: 22px; }
.primary-btn, .secondary-btn {
  border-radius: 6px;
  padding: 12px 18px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
}
.primary-btn { border: 1px solid var(--ink); background: var(--ink); color: white; }
.primary-btn:hover { background: #000; }
.lesson-copy .primary-btn { margin-top: auto; background: var(--white); color: var(--forest-dark); border-color: var(--white); }
.lesson-copy .primary-btn:hover { background: var(--mint-light); }
.secondary-btn { border: 1px solid var(--line); background: var(--white); color: var(--ink); }
.secondary-btn:hover { border-color: var(--forest); color: var(--forest); }

.lesson-board-col { align-self: center; justify-self: center; display: flex; flex-direction: column; align-items: center; max-width: 100%; }
.lesson-board-task { margin: 0 0 14px; color: #fff; font-weight: 800; font-size: 0.82rem; letter-spacing: 0.05em; text-transform: uppercase; text-align: center; }
.lesson-board { width: min(360px, 80vw); aspect-ratio: 1; display: grid; grid-template-columns: repeat(8, 1fr); box-shadow: 0 14px 38px rgba(0,0,0,0.22); }
/* pan-y (not none) lets a vertical swipe scroll the dashboard instead of grabbing
   a piece — the mobile scroll trap. Tap-to-move and horizontal drags still work. */
.lesson-board.interactive { touch-action: pan-y; cursor: pointer; }
.lesson-board .square { font-size: clamp(1.1rem, 3vw, 2.4rem); }
.lesson-board-context { margin: 16px 0 0; color: #b9d3c1; font: 700 0.72rem ui-monospace, SFMono-Regular, Menlo, monospace; text-align: center; }
.lesson-board-hint { margin: 8px 0 0; color: #cfe2d1; font-size: 0.76rem; line-height: 1.45; text-align: center; max-width: 320px; }
/* Always clearly visible. Needs the .lesson-copy prefix to out-specify the later
   `.text-btn { color: var(--forest) }` rule — otherwise the dark-green text was
   invisible on the dark card until :hover (higher specificity) turned it white. */
.lesson-copy .lesson-open-link { margin-top: auto; display: inline-flex; align-items: center; gap: 9px; padding: 13px 26px; border: 2px solid #fff; border-radius: 9px; background: transparent; color: #fff; font-size: 1rem; font-weight: 800; text-decoration: none; cursor: pointer; }
.lesson-copy .lesson-open-link:hover { background: #fff; color: var(--forest-dark); }
.lesson-open-link span { display: inline-block; transition: transform 0.15s ease; }
.lesson-open-link:hover span { transform: translateX(3px); }
/* Success modal — covers the board after a correct move, non-dismissible, and
   funnels straight into the lesson. Stacks the BOOK! badge above the Next! button
   (both visible at once). */
.lesson-next-modal { position: absolute; inset: 0; z-index: 4; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; background: rgba(15, 43, 33, 0.9); border-radius: 4px; animation: lessonNextIn 0.25s ease both; }
.lesson-next-modal[hidden] { display: none; }
/* The BOOK! badge inside the modal is in-flow (not the board-overlay variant) and
   pops in, then HOLDS (no fade) so it stays stacked above the button. */
.lesson-next-modal .comic-pop { position: relative; inset: auto; top: auto; left: auto; width: min(46%, 168px); animation: comic-pop-hold 0.5s cubic-bezier(0.2, 1.3, 0.4, 1) both; }
.lesson-next-btn { position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 10px; padding: 16px 36px; border: 0; border-radius: 11px; background: #fff; color: var(--forest-dark); font-size: 1.2rem; font-weight: 800; cursor: pointer; box-shadow: 0 14px 34px rgba(0, 0, 0, 0.35); }
.lesson-next-btn span { display: inline-block; transition: transform 0.15s ease; }
.lesson-next-btn:hover span { transform: translateX(4px); }
@keyframes lessonNextIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes comic-pop-hold {
  0% { transform: scale(0) rotate(-16deg); opacity: 0; }
  55% { transform: scale(1.12) rotate(4deg); opacity: 1; }
  75% { transform: scale(0.98) rotate(-1deg); }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) { .lesson-next-modal, .lesson-next-modal .comic-pop { animation: none; } }
.opening-brief { margin-top: 28px; }
.opening-brief-heading { margin-bottom: 15px; }
.opening-brief-heading h2 { margin: 0; font-size: 1.45rem; }
.opening-brief-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.opening-brief-grid article { min-height: 142px; padding: 17px; border: 1px solid var(--line); border-radius: 7px; background: var(--white); }
.opening-brief-grid article span { color: var(--forest); font-size: 0.62rem; font-weight: 800; letter-spacing: 0.1em; }
.opening-brief-grid article p { margin: 11px 0 0; color: var(--muted); font-size: 0.79rem; line-height: 1.5; }
/* Visual "What matters" cards: a mini-board of the key position, annotated for
   the concept, above a one-line caption. */
.opening-brief-grid .brief-card-visual { display: flex; flex-direction: column; min-height: 0; }
.brief-board { width: 100%; max-width: 160px; aspect-ratio: 1; margin: 11px auto 0; display: grid; grid-template-columns: repeat(8, 1fr); position: relative; border-radius: 4px; overflow: hidden; box-shadow: 0 6px 18px rgba(23,32,27,0.12); }
.brief-board .square { font-size: 0; }
.brief-card-visual p { margin-top: 11px; font-size: 0.76rem; text-align: center; }

.section-heading { display: flex; align-items: end; justify-content: space-between; margin: 55px 0 18px; }
.section-heading .eyebrow { margin-bottom: 5px; }
.section-heading h2 { font-size: 1.55rem; margin-bottom: 0; }
.text-btn { border: 0; background: transparent; color: var(--forest); font-weight: 700; cursor: pointer; padding: 8px 0; }
.practice-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.practice-card { min-height: 145px; border: 1px solid var(--line); border-radius: 7px; padding: 18px; display: grid; grid-template-columns: auto 1fr auto; grid-template-rows: auto 1fr; gap: 14px; text-align: left; background: var(--white); cursor: pointer; }
.practice-card:hover { border-color: var(--forest); transform: translateY(-2px); box-shadow: 0 10px 25px rgba(23,32,27,0.07); }
.practice-number { font-size: 0.65rem; font-weight: 800; color: #a0a59f; }
.practice-piece { font-size: 2rem; color: var(--forest); grid-row: 2; }
.practice-copy { display: flex; flex-direction: column; grid-row: 2; overflow: hidden; }
.practice-copy small { color: var(--muted); text-transform: uppercase; font-size: 0.61rem; letter-spacing: 0.07em; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.practice-copy b { margin: 4px 0; font-size: 0.96rem; }
.practice-copy em { font-size: 0.7rem; color: var(--forest); font-style: normal; }
/* User-specific status: due (needs attention) stands out; progress/new are calm. */
.practice-status { margin-top: 2px; }
.practice-status-due { color: var(--coral); font-weight: 700; }
.practice-status-due::before { content: "● "; font-size: 0.7em; }
.practice-status-new { color: var(--muted); }
.practice-bar { margin-top: 7px; height: 4px; border-radius: 2px; background: var(--mint); overflow: hidden; }
.practice-bar i { display: block; height: 100%; background: var(--forest); border-radius: 2px; transition: width 0.3s; }
.card-arrow { grid-column: 3; grid-row: 2; align-self: center; color: var(--forest); }
.review-strip, .sync-card { margin-top: 20px; border: 1px solid var(--line); border-radius: 7px; padding: 20px 22px; display: flex; align-items: center; gap: 17px; background: var(--mint-light); }
.review-strip div:nth-child(2), .sync-card div { flex: 1; }
.review-strip p, .sync-card p { margin: 3px 0 0; color: var(--muted); font-size: 0.83rem; }
.review-icon { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; color: var(--forest); background: white; font-size: 1.25rem; }
.review-icon-bird { padding: 4px; }
.review-icon-bird img { width: 100%; height: 100%; object-fit: contain; }
.lesson-board-col { position: relative; }
/* Comic POP reactions — a starburst + bird silhouette + a punchy word, popped in
   on an earned moment (a found book move on the home board). Reusable: swap the
   word + colour for SNAP/TRAP/FORK/MATE/BOOM at other high-value moments. */
.lesson-board-stage { position: relative; align-self: center; width: min(360px, 80vw); }
.lesson-board-stage .lesson-board { width: 100%; }
.comic-pop { position: absolute; top: 46%; left: 50%; width: 52%; aspect-ratio: 1; display: grid; place-items: center; pointer-events: none; z-index: 6; animation: comic-pop 2.4s cubic-bezier(0.2, 1.3, 0.4, 1) both; }
.comic-pop[hidden] { display: none; }
.comic-pop-burst { position: absolute; inset: 0; background: var(--pop-color, #f4c541); filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.3)); clip-path: polygon(50% 0%, 58.3% 19.1%, 75% 6.7%, 72.6% 27.4%, 93.3% 25%, 80.9% 41.7%, 100% 50%, 80.9% 58.3%, 93.3% 75%, 72.6% 72.6%, 75% 93.3%, 58.3% 80.9%, 50% 100%, 41.7% 80.9%, 25% 93.3%, 27.4% 72.6%, 6.7% 75%, 19.1% 58.3%, 0% 50%, 19.1% 41.7%, 6.7% 25%, 27.4% 27.4%, 25% 6.7%, 41.7% 19.1%); }
.comic-pop-bird { position: relative; z-index: 1; width: 44%; margin-top: 14%; filter: brightness(0); }
.comic-pop-word { position: absolute; z-index: 2; top: 20%; font: italic 900 clamp(1rem, 5.5vw, 1.6rem)/1 system-ui, -apple-system, sans-serif; letter-spacing: -0.02em; color: #17201b; transform: rotate(-7deg); }
.pop-book { --pop-color: #f4c541; }
.pop-snap { --pop-color: #4f9cf0; }
.pop-trap { --pop-color: #e5533c; }
.pop-fork { --pop-color: #57c08a; }
.pop-mate { --pop-color: #7c4dff; }
.pop-boom { --pop-color: #f0913a; }
.pop-miss { --pop-color: #e5533c; }
@keyframes comic-pop {
  0% { transform: translate(-50%, -50%) scale(0) rotate(-16deg); opacity: 0; }
  16% { transform: translate(-50%, -50%) scale(1.12) rotate(4deg); opacity: 1; }
  28% { transform: translate(-50%, -50%) scale(0.98) rotate(-1deg); }
  36% { transform: translate(-50%, -50%) scale(1) rotate(0); opacity: 1; }
  82% { opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1) rotate(0); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .comic-pop { animation-duration: 0.01ms; } }

/* Drill */
.train-view { width: min(1160px, calc(100% - 48px)); padding-top: 28px; }
.drill-topline { display: grid; grid-template-columns: 42px 1fr 42px; align-items: center; gap: 22px; margin-bottom: 28px; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--white); cursor: pointer; font-size: 1.3rem; }
.icon-btn:hover { border-color: var(--forest); color: var(--forest); }
.drill-progress { height: 6px; background: #dee0d9; border-radius: 10px; overflow: hidden; }
.drill-progress span { display: block; height: 100%; background: var(--forest); border-radius: inherit; transition: width 250ms ease; }
.drill-layout { display: grid; grid-template-columns: minmax(420px, 660px) minmax(290px, 380px); gap: 46px; justify-content: center; align-items: start; }
.turn-banner { display: flex; gap: 13px; align-items: center; margin: 0 0 14px; }
.turn-banner p { margin: 0 0 2px; font-size: 0.62rem; color: var(--forest); letter-spacing: 0.1em; font-weight: 800; }
.turn-banner b { font-size: 1.02rem; }
.turn-color { width: 31px; height: 31px; border-radius: 50%; border: 2px solid var(--ink); background: #f8f6ef; box-shadow: inset 0 0 0 4px white; }
.turn-color.black { background: var(--ink); }
.chessboard { width: 100%; aspect-ratio: 1; display: grid; grid-template-columns: repeat(8, 1fr); border: 8px solid var(--ink); background: var(--ink); box-shadow: 0 18px 45px rgba(23,32,27,0.15); position: relative; }
.chessboard.interactive { touch-action: none; overscroll-behavior: contain; }
.board-arrows { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 5; }
/* #13: the primary (green "move now") arrow is dominant; plan/threat arrows are
   thinner and translucent so the eye follows the recommendation first. */
.board-arrow { stroke-width: 0.18; stroke-linecap: round; fill: none; }
.arrow-green { stroke: var(--arrow-green); stroke-width: 0.28; }
.arrow-blue { stroke: var(--arrow-blue); opacity: 0.72; }
.arrow-red { stroke: var(--arrow-red); opacity: 0.72; }
.arrow-amber { stroke: var(--arrow-amber); opacity: 0.72; }
.coach-arrow-key { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 9px 0 0; flex-wrap: wrap; }
.arrow-key-legend { display: flex; gap: 13px; flex-wrap: wrap; }
.arrow-key-item { display: inline-flex; align-items: center; gap: 5px; font-size: 0.68rem; font-weight: 700; color: var(--muted); }
.arrow-key-dot { width: 10px; height: 10px; border-radius: 2px; }
.arrow-key-green { background: var(--arrow-green); }
.arrow-key-blue { background: var(--arrow-blue); }
.arrow-key-red { background: var(--arrow-red); }
.arrow-key-amber { background: var(--arrow-amber); }
.arrow-key-toggle { border: 1px solid var(--forest); color: var(--forest); background: transparent; border-radius: 999px; padding: 3px 12px; font-size: 0.68rem; font-weight: 700; cursor: pointer; }
.arrow-key-toggle:hover { background: var(--mint-light); }
.square.hl-green { box-shadow: inset 0 0 0 4px var(--arrow-green); }
.square.hl-blue { box-shadow: inset 0 0 0 4px var(--arrow-blue); }
.square.hl-red { box-shadow: inset 0 0 0 4px var(--arrow-red); }
.square.hl-amber { box-shadow: inset 0 0 0 4px var(--arrow-amber); }
.square { min-width: 0; min-height: 0; aspect-ratio: 1; border: 0; padding: 0; position: relative; display: grid; place-items: center; line-height: 1; }
button.square { cursor: pointer; }
.square.light { background: var(--board-light); }
.square.dark { background: var(--board-dark); }
/* Two-tone like .coord (dark mark on light squares, light on dark) so the dot
   reads on both colours, and larger (22%) than the old faint 16% grey. */
.square.legal-target { background-image: radial-gradient(circle, rgba(23, 32, 27, 0.32) 0 22%, transparent 23%); }
.dark.square.legal-target { background-image: radial-gradient(circle, rgba(240, 244, 240, 0.5) 0 22%, transparent 23%); }
.square.capture-target { background-image: none; box-shadow: inset 0 0 0 5px rgba(23, 32, 27, 0.38); }
.dark.square.capture-target { box-shadow: inset 0 0 0 5px rgba(240, 244, 240, 0.5); }
.square.last-move::after { content: ""; position: absolute; inset: 0; background: rgba(232,174,69,0.34); pointer-events: none; }
.square.selected::after { content: ""; position: absolute; inset: 3px; border: 4px solid var(--coral); pointer-events: none; z-index: 2; }
.square.hinted::before { content: ""; position: absolute; width: 28%; aspect-ratio: 1; border-radius: 50%; background: rgba(230,96,69,0.75); z-index: 3; }
.piece { width: 88%; height: 88%; object-fit: contain; z-index: 1; user-select: none; -webkit-user-drag: none; pointer-events: none; }
.square.drag-origin .piece { opacity: 0.18; }
.drag-piece {
  position: fixed;
  inset: 0 auto auto 0;
  z-index: 1000;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  filter: drop-shadow(0 10px 8px rgba(23, 32, 27, 0.28));
  will-change: transform;
}
body.piece-dragging, body.piece-dragging * { cursor: grabbing !important; user-select: none !important; }
.coord { position: absolute; z-index: 4; font: 700 0.57rem "Avenir Next", sans-serif; }
.rank-coord { left: 3px; top: 3px; }
.file-coord { right: 3px; bottom: 2px; }
.light .coord { color: var(--board-dark); }
.dark .coord { color: var(--board-light); }
.board-caption { margin-top: 10px; display: flex; justify-content: space-between; color: var(--muted); font-size: 0.72rem; }
/* End-of-lesson card: variations of the finished opening to review with the coach,
   instead of dropping back to Home. */
.lesson-complete { position: fixed; inset: 0; z-index: 60; place-items: center; padding: 20px; background: rgba(23, 32, 27, 0.55); }
.lesson-complete:not([hidden]) { display: grid; }
.lesson-complete-card { width: min(440px, 100%); max-height: calc(100dvh - 40px); overflow-y: auto; background: var(--paper); border-radius: 12px; padding: 30px 26px; text-align: center; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.32); }
.lesson-complete-bird { width: 56px; height: 56px; object-fit: contain; background: var(--white); border-radius: 50%; padding: 8px; box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12); }
.lesson-complete-card .eyebrow { margin-top: 13px; color: var(--forest); }
.lesson-complete-card h2 { margin: 4px 0 8px; font-size: 1.55rem; }
.lesson-complete-card > p { color: var(--muted); font-size: 0.88rem; margin: 0 auto 18px; max-width: 320px; }
.lesson-complete-suggestions { display: flex; flex-direction: column; gap: 8px; text-align: left; }
.lesson-complete-suggestion { display: flex; flex-direction: column; gap: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--white); padding: 12px 14px; cursor: pointer; }
.lesson-complete-suggestion:hover { border-color: var(--forest); background: var(--mint-light); }
.lesson-complete-suggestion b { font-size: 0.9rem; }
.lesson-complete-suggestion span { color: var(--muted); font-size: 0.74rem; }
.lesson-complete-home { margin-top: 15px; color: var(--muted); }
.lesson-complete-home:hover { color: var(--forest); }
.coach-panel { background: var(--white); border: 1px solid var(--line); border-radius: 8px; padding: 24px; margin-top: 58px; min-height: 410px; display: flex; flex-direction: column; }
.coach-head { display: flex; align-items: center; gap: 11px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.coach-head img { width: 42px; height: 42px; object-fit: cover; border-radius: 6px; }
.coach-head div { display: flex; flex-direction: column; }
.coach-head span { font-size: 0.7rem; color: var(--muted); }
.coach-link { align-self: flex-start; border: 0; padding: 0; margin: 0 0 18px; background: transparent; color: var(--forest); font-size: 0.76rem; font-weight: 800; cursor: pointer; }
.coach-link span { display: inline-block; margin-left: 5px; transition: transform 160ms ease; }
.coach-link:hover span { transform: translateX(3px); }
.coach-message { padding: 24px 0 15px; }
.coach-label { color: var(--forest); font-size: 0.63rem; letter-spacing: 0.11em; font-weight: 800; margin-bottom: 8px; }
.coach-message p:last-child { font-size: 1.02rem; line-height: 1.55; }
.move-line { min-height: 48px; padding: 12px 14px; border-radius: 6px; background: var(--paper); display: flex; flex-wrap: wrap; align-items: center; gap: 7px 11px; font-size: 0.85rem; }
.move-number, .line-empty { color: var(--muted); font-weight: 400; }
.feedback { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 18px; }
.feedback-title { display: flex; align-items: center; gap: 9px; }
.feedback-title span { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--forest); color: white; }
.feedback.wrong .feedback-title span { background: var(--coral); }
/* The "you're ready to add this" milestone — Coach Bird marks the mastery moment. */
.feedback.ready .feedback-title span { background: var(--forest) url("/assets/birdchess-mark.png") center/72% no-repeat; }
.feedback p { color: var(--muted); font-size: 0.85rem; margin: 9px 0 0; }
.full { width: 100%; margin-top: 18px; }
.hint-btn { border: 0; background: none; color: var(--forest); font-weight: 700; padding: 13px 0 0; cursor: pointer; margin-top: auto; }
.shake { animation: shake 240ms ease; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

/* Library and progress */
.page-heading { margin-bottom: 34px; max-width: 700px; }
.segmented { display: inline-flex; padding: 4px; background: #e8e8e1; border-radius: 7px; margin-bottom: 24px; }
.segmented button { border: 0; border-radius: 5px; padding: 8px 20px; background: transparent; cursor: pointer; color: var(--muted); font-size: 0.82rem; font-weight: 700; }
.segmented button.selected { background: var(--white); color: var(--ink); box-shadow: 0 1px 4px rgba(23,32,27,0.1); }
.guide-picker { display: grid; grid-template-columns: repeat(auto-fit, minmax(185px, 1fr)); gap: 9px; margin-bottom: 18px; }
/* Mobile choice-first block (hidden on desktop): repertoire label, a chessy
   branch dropdown, and the current line as move chips — all above the board. */
.response-choice { display: none; margin-bottom: 18px; }
.response-choice-title { margin: 0 0 7px; color: var(--forest); font-size: 0.68rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }

/* Custom branch dropdown — a chess row, not a form control. Trigger and rows
   share the same layout: piece glyph, notation (lead), name, status badge. */
.branch-select { position: relative; }
.branch-select-trigger { width: 100%; display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--white); padding: 9px 12px; cursor: pointer; text-align: left; }
.branch-select-trigger:focus-visible { outline: 2px solid var(--mint); border-color: var(--forest); }
.branch-option-glyph { flex: none; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 6px; background: var(--mint-light); font-size: 1.3rem; line-height: 1; color: var(--ink); }
.branch-option-glyph.piece-knight { background: #e2ecf4; }
.branch-option-glyph.piece-bishop { background: #f4edda; }
.branch-option-glyph.piece-queen, .branch-option-glyph.piece-rook, .branch-option-glyph.piece-king { background: #efe6f1; }
.branch-option-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.branch-option-main b { font: 700 0.9rem ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--ink); }
.branch-option-main span { font-size: 0.76rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.branch-option-status { flex: none; font-size: 0.58rem; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase; padding: 3px 8px; border-radius: 999px; }
.status-new { background: #ece9e2; color: var(--muted); }
.status-learning { background: #fbeed6; color: #986a15; }
.status-familiar { background: #d9ebf3; color: #2b6b86; }
.status-strong { background: var(--mint); color: var(--forest-dark); }
.branch-select-caret { flex: none; color: var(--muted); font-size: 0.7rem; transition: transform 0.15s; }
.branch-select-trigger[aria-expanded="true"] .branch-select-caret { transform: rotate(180deg); }
.branch-select-menu { position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 40; max-height: 62vh; overflow-y: auto; overscroll-behavior: contain; padding: 6px; background: var(--white); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 16px 40px rgba(23,32,27,0.18); }
.branch-group-label { padding: 9px 10px 4px; color: var(--forest); font-size: 0.58rem; font-weight: 800; letter-spacing: 0.07em; text-transform: uppercase; }
.branch-option { width: 100%; display: flex; align-items: center; gap: 10px; border: 0; background: transparent; border-radius: 6px; padding: 7px 10px; cursor: pointer; text-align: left; }
.branch-option:hover { background: var(--mint-light); }
.branch-option.selected { background: var(--mint); }

/* Line strip: labelled ("Main line"), consistent move numbers, the chosen
   branch move as the one strong active chip; trunk muted. */
.response-choice-strip { margin-top: 12px; }
.response-choice-strip-label { display: block; margin-bottom: 6px; color: var(--forest); font-size: 0.58rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.response-choice-line { display: flex; align-items: center; gap: 5px; overflow-x: auto; overscroll-behavior-inline: contain; scrollbar-width: thin; padding-bottom: 2px; }
.choice-move-chip { white-space: nowrap; border-radius: 5px; padding: 4px 9px; font: 700 0.74rem ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--white); border: 1px solid var(--line); color: var(--ink); }
.choice-move-chip.trunk { background: var(--mint-light); border-color: transparent; color: var(--forest-dark); }
.choice-move-chip.active { background: var(--forest); border-color: var(--forest); color: #fff; }
.guide-picker button { min-width: 0; border: 1px solid var(--line); border-radius: 7px; background: var(--white); padding: 13px 14px; display: flex; align-items: center; gap: 10px; text-align: left; cursor: pointer; }
.guide-picker button:hover { border-color: var(--forest); }
.guide-picker button.selected { color: white; background: var(--forest); border-color: var(--forest); }
.guide-picker button > span { font-size: 1.55rem; }
.guide-picker button div { display: flex; flex-direction: column; overflow: hidden; }
.guide-picker button b { font-size: 0.78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.guide-picker button small { margin-top: 2px; font-size: 0.62rem; color: var(--muted); }
.guide-picker button.selected small { color: #c7dbcc; }
.response-lab { display: grid; grid-template-columns: minmax(300px, 0.78fr) minmax(430px, 1.22fr); gap: 38px; padding: 30px 0 44px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.response-board-wrap { align-self: start; }
.response-board { width: 100%; aspect-ratio: 1; display: grid; grid-template-columns: repeat(8, 1fr); border: 7px solid var(--ink); box-shadow: 0 16px 36px rgba(23,32,27,0.13); }
.response-position-label { color: var(--muted); font-size: 0.72rem; margin-top: 10px; }
.response-content { min-width: 0; }
.response-context { display: flex; justify-content: space-between; gap: 20px; align-items: center; margin-bottom: 13px; }
.response-context span { color: var(--forest); font-size: 0.64rem; font-weight: 800; letter-spacing: 0.1em; }
.response-context p { color: var(--muted); font-size: 0.75rem; margin: 0; }
.response-tabs { display: grid; grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); gap: 6px; padding: 2px 2px 10px; }
.response-tabs button { min-width: 0; min-height: 74px; border: 1px solid var(--line); border-radius: 6px; background: var(--white); padding: 7px 10px; display: flex; flex-direction: column; text-align: left; cursor: pointer; }
.response-tabs button:hover { border-color: var(--forest); }
.response-tabs button.selected { background: var(--mint); border-color: var(--forest); }
.response-tabs button b { font-size: 0.82rem; }
.response-tabs button span { color: var(--muted); font-size: 0.6rem; line-height: 1.25; }
.response-tabs button i { display: block; width: 100%; height: 3px; margin-top: auto; background: #e2e4dd; border-radius: 3px; overflow: hidden; }
.response-tabs button i em { display: block; height: 100%; background: var(--forest); border-radius: inherit; }
.response-tabs button small { color: var(--muted); font-size: 0.55rem; margin-top: 3px; }
.response-title-row { display: flex; justify-content: space-between; align-items: end; gap: 20px; padding: 16px 0 13px; }
.response-title-row h2 { margin: 5px 0 0; font-size: 1.65rem; }
.response-tag { color: var(--coral); font-size: 0.62rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.response-title-row > strong { font: 800 2rem "Avenir Next", sans-serif; color: var(--forest); }
.response-insights { border-top: 1px solid var(--line); }
.insight { display: grid; grid-template-columns: 28px 1fr; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.insight > span { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--mint); color: var(--forest); font-weight: 800; }
.insight.weakness > span { background: #f4ded8; color: #9b402e; }
.insight.plan > span { background: #f4e8c9; color: #795714; }
.insight b { font-size: 0.77rem; }
.insight p { color: var(--muted); font-size: 0.78rem; line-height: 1.43; margin: 2px 0 0; }
/* Branch chooser under the repertoire tabs, above the board (desktop). */
.line-tree { margin: 0 0 20px; padding: 0 0 16px; border-bottom: 1px solid var(--line); }
.line-tree-heading { display: flex; justify-content: space-between; gap: 18px; align-items: baseline; margin-bottom: 13px; }
.line-tree-heading > span, .line-tree-stage { color: var(--forest); font-size: 0.57rem; font-weight: 800; letter-spacing: 0.1em; }
.line-tree-heading small { color: var(--muted); font-size: 0.62rem; }
.line-tree-trunk { display: grid; grid-template-columns: 82px 1fr; gap: 10px; align-items: center; }
.line-tree-moves { min-width: 0; display: flex; flex-wrap: wrap; gap: 5px; }
.line-move { min-height: 29px; border: 1px solid var(--line); border-radius: 4px; padding: 4px 8px; background: var(--white); color: var(--ink); cursor: pointer; font-size: 0.68rem; font-weight: 700; }
.line-move:hover { border-color: var(--forest); color: var(--forest); }
.line-move.current { border-color: var(--coral); box-shadow: inset 0 0 0 1px var(--coral); }
.line-tree-junction { display: grid; grid-template-columns: 1fr auto 1fr; gap: 9px; align-items: center; margin: 12px 0 0; color: var(--muted); }
.line-tree-junction span { height: 1px; background: var(--line); }
.line-tree-junction b { font-size: 0.58rem; font-weight: 700; }
.line-tree-branches { position: relative; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(122px, 1fr); gap: 6px; padding: 13px 2px 3px; overflow-x: auto; overscroll-behavior-inline: contain; scrollbar-width: thin; }
.line-tree-branches::before { content: ""; position: absolute; inset: 5px 4% auto; height: 1px; background: var(--line); }
.line-branch { position: relative; min-height: 70px; border: 1px solid var(--line); border-radius: 5px; padding: 9px 10px; display: flex; flex-direction: column; align-items: flex-start; background: var(--white); color: var(--ink); text-align: left; cursor: pointer; }
.line-branch::before { content: ""; position: absolute; width: 1px; height: 8px; left: 50%; top: -9px; background: var(--line); }
.line-branch:hover { border-color: var(--forest); }
.line-branch.selected { border-color: var(--forest); background: var(--forest); color: white; }
.line-branch strong { font-size: 0.72rem; }
.line-branch span { margin-top: 2px; font-size: 0.65rem; line-height: 1.25; }
.line-branch small { margin-top: auto; color: var(--muted); font-size: 0.55rem; }
.line-branch.selected small { color: #c7dbcc; }
.line-tree-continuation { min-width: 0; display: grid; grid-template-columns: auto 22px minmax(0, 1fr); align-items: center; gap: 5px; margin-top: 11px; padding-top: 11px; border-top: 1px dashed var(--line); }
.line-tree-rail { height: 1px; background: var(--forest); }
.line-tree-continuation .branch-root { border-color: var(--forest); background: var(--mint-light); color: var(--forest-dark); }

/* Castled King Lab */
.attack-heading { max-width: none; display: flex; align-items: end; justify-content: space-between; gap: 32px; }
.attack-course-progress { min-width: 150px; padding: 0 0 7px 22px; border-left: 1px solid var(--line); display: flex; flex-direction: column; }
.attack-course-progress strong { color: var(--forest); font-size: 1.6rem; line-height: 1.1; }
.attack-course-progress span { margin-top: 3px; color: var(--muted); font-size: 0.7rem; }
.attack-modules { display: grid; grid-template-columns: repeat(6, minmax(120px, 1fr)); gap: 7px; margin-bottom: 34px; overflow-x: auto; scrollbar-width: thin; }
.attack-modules button { min-width: 120px; min-height: 78px; padding: 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--white); display: flex; align-items: flex-start; gap: 9px; text-align: left; cursor: pointer; }
.attack-modules button:hover { border-color: var(--forest); }
.attack-modules button.selected { border-color: var(--forest); background: var(--forest); color: white; }
.attack-modules button > span { color: var(--coral); font-size: 0.62rem; font-weight: 800; }
.attack-modules button div { min-width: 0; display: flex; flex-direction: column; }
.attack-modules button b { font-size: 0.68rem; line-height: 1.25; }
.attack-modules button small { margin-top: 5px; color: var(--muted); font-size: 0.57rem; }
.attack-modules button.selected small { color: #c7dbcc; }
.attack-workspace { display: grid; grid-template-columns: minmax(340px, 0.9fr) minmax(390px, 1.1fr); gap: 54px; align-items: start; padding: 36px 0 48px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.attack-board-column { min-width: 0; }
.attack-position-meta { margin-bottom: 11px; display: flex; justify-content: space-between; gap: 16px; color: var(--muted); font-size: 0.59rem; font-weight: 800; letter-spacing: 0.08em; }
.attack-position-meta span:first-child { color: var(--forest); }
.attack-position-nav { display: flex; align-items: center; gap: 8px; }
.attack-position-nav button { width: 23px; height: 23px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: var(--white); display: grid; place-items: center; cursor: pointer; font-size: 1rem; line-height: 1; }
.attack-position-nav button:hover:not(:disabled) { border-color: var(--forest); color: var(--forest); }
.attack-position-nav button:disabled { cursor: default; opacity: 0.35; }
.attack-board { width: 100%; }
.attack-principle { margin: 14px 0 0; padding-left: 13px; border-left: 3px solid var(--amber); color: var(--muted); font-size: 0.78rem; line-height: 1.55; }
.attack-decision { padding-top: 25px; }
.attack-decision h2 { margin: 8px 0 15px; font-size: 2rem; }
.attack-prompt { max-width: 560px; margin-bottom: 22px; font-size: 1.05rem; line-height: 1.55; }
.attack-choices { display: grid; gap: 8px; }
.attack-choices button { width: 100%; min-height: 54px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 6px; background: var(--white); display: grid; grid-template-columns: 30px 1fr; gap: 11px; align-items: center; text-align: left; cursor: pointer; }
.attack-choices button:hover { border-color: var(--forest); }
.attack-choices button > span { width: 28px; height: 28px; border-radius: 50%; background: var(--paper); display: grid; place-items: center; color: var(--muted); font-size: 0.68rem; font-weight: 800; }
.attack-choices button b { font-size: 0.83rem; }
.attack-choices button.chosen.correct { border-color: var(--forest); background: var(--mint-light); }
.attack-choices button.chosen.correct > span { background: var(--forest); color: white; }
.attack-choices button.chosen.wrong { border-color: var(--coral); background: #fff3ef; }
.attack-choices button.chosen.wrong > span { background: var(--coral); color: white; }
.attack-feedback { margin-top: 17px; padding: 14px 16px; border-left: 3px solid var(--forest); background: var(--mint-light); }
.attack-feedback.wrong { border-left-color: var(--coral); background: #fff3ef; }
.attack-feedback b { font-size: 0.78rem; }
.attack-feedback p { margin: 4px 0 0; color: var(--muted); font-size: 0.78rem; line-height: 1.5; }
.attack-decision > .primary-btn { width: 100%; margin-top: 16px; }

.library-heading { margin-top: 48px; }
/* The course library is collapsed by default so the view is just the core loop:
   opponent's reply -> what it gains/concedes -> choose a response -> train. */
.library-disclosure { margin-top: 48px; border-top: 1px solid var(--line); }
.library-summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 24px 0 4px; }
.library-summary::-webkit-details-marker { display: none; }
.library-summary h2 { display: inline-flex; align-items: center; gap: 10px; }
.library-summary h2::after { content: "▾"; font-size: 0.8em; color: var(--muted); transition: transform 0.15s; }
.library-disclosure[open] .library-summary h2::after { transform: rotate(180deg); }
.library-summary-hint { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.library-disclosure .opening-filters { margin-top: 20px; }
.opening-filters { margin-bottom: 24px; display: flex; flex-wrap: wrap; gap: 8px; }
.opening-filters .segmented { margin-bottom: 0; }
.opening-list { display: grid; gap: 10px; }
.opening-row { display: grid; grid-template-columns: 60px minmax(210px, 1fr) 190px 80px; gap: 20px; align-items: center; padding: 20px; border: 1px solid var(--line); border-radius: 7px; background: var(--white); }
.opening-emblem { width: 52px; height: 52px; border-radius: 6px; background: var(--mint-light); display: grid; place-items: center; font-size: 2rem; color: var(--forest); }
.opening-emblem.black { background: #e8e2dc; color: var(--ink); }
.opening-info small { color: var(--forest); font-size: 0.63rem; text-transform: uppercase; letter-spacing: 0.08em; }
.opening-info h2 { font-size: 1.05rem; margin: 4px 0 2px; }
.opening-info p { color: var(--muted); font-size: 0.8rem; margin: 0; }
.opening-attributes { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 5px 12px; }
.opening-attributes span { color: var(--muted); font-size: 0.61rem; }
.opening-attributes span::before { content: ""; width: 5px; height: 5px; margin-right: 5px; border-radius: 50%; background: var(--amber); display: inline-block; vertical-align: 1px; }
.opening-empty { margin: 0; padding: 28px 0; border-block: 1px solid var(--line); color: var(--muted); font-size: 0.82rem; }
.opening-mastery span { font-size: 0.7rem; color: var(--muted); }
.opening-mastery div, .mastery-bar { display: block; height: 5px; background: #e2e4dd; border-radius: 5px; overflow: hidden; margin-top: 7px; }
.opening-mastery i, .mastery-bar i { height: 100%; background: var(--forest); display: block; border-radius: inherit; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat-block { border: 1px solid var(--line); background: var(--white); border-radius: 7px; padding: 22px; display: flex; flex-direction: column; }
.stat-block > span { color: var(--muted); font-size: 0.74rem; }
.stat-block strong { font: 800 1.75rem "Avenir Next", sans-serif; margin: 8px 0; }
.stat-block small { color: var(--forest); }
.mastery-section { margin-top: 12px; }
.mastery-row { width: 100%; display: grid; grid-template-columns: 40px minmax(150px, 1fr) minmax(100px, 240px) 45px; gap: 16px; align-items: center; padding: 16px 4px; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; cursor: pointer; }
.mastery-piece { font-size: 1.7rem; color: var(--forest); }
.mastery-row span:nth-child(2) { display: flex; flex-direction: column; }
.mastery-row small { color: var(--muted); }
.mastery-bar { margin: 0; }
.mastery-row strong { color: var(--forest); font-size: 0.8rem; text-align: right; }
.pattern-progress { margin-top: 34px; padding-top: 2px; border-top: 1px solid var(--line); }
.pattern-progress .section-heading { align-items: end; }
.pattern-mastery-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.pattern-mastery-grid button { min-width: 0; padding: 15px; border: 1px solid var(--line); border-radius: 6px; background: var(--white); display: grid; grid-template-columns: 26px minmax(0, 1fr) 38px; gap: 10px; align-items: center; text-align: left; cursor: pointer; }
.pattern-mastery-grid button:hover { border-color: var(--forest); }
.pattern-mastery-grid button > span { color: var(--coral); font-size: 0.65rem; font-weight: 800; }
.pattern-mastery-grid button div { min-width: 0; display: flex; flex-direction: column; }
.pattern-mastery-grid b { font-size: 0.78rem; }
.pattern-mastery-grid small { margin-top: 2px; color: var(--muted); font-size: 0.62rem; }
.pattern-mastery-grid i { height: 4px; margin-top: 8px; border-radius: 4px; background: #e2e4dd; overflow: hidden; }
.pattern-mastery-grid em { display: block; height: 100%; border-radius: inherit; background: var(--forest); }
.pattern-mastery-grid button > strong { color: var(--forest); font-size: 0.72rem; text-align: right; }
.review-due-copy { margin: 12px 0 0; color: var(--muted); font-size: 0.72rem; }
.sync-card img { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; }
.app-legal { display: flex; justify-content: center; gap: 18px; margin-top: 24px; }

.bottom-nav { display: none; }

/* Coach room */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.coach-room-view { width: min(1240px, calc(100% - 48px)); padding-top: 30px; }
.coach-room-header { min-height: 70px; margin-bottom: 18px; display: grid; grid-template-columns: 1fr auto; gap: 20px; align-items: end; }
.coach-room-header .eyebrow { margin-bottom: 4px; }
.coach-room-header h1 { margin: 0; font-size: 2rem; }
.coach-room-header > span { padding-bottom: 4px; color: var(--forest); font-size: 0.68rem; font-weight: 800; letter-spacing: 0.1em; }
.coach-room-close { display: none; }
.coach-room-layout { display: grid; grid-template-columns: minmax(420px, 0.95fr) minmax(350px, 1.05fr); gap: 32px; align-items: start; }
.coach-board-area { min-width: 0; }
.coach-board-tools { min-height: 43px; margin-bottom: 10px; display: grid; grid-template-columns: auto minmax(0, 1fr) 38px 38px; gap: 7px; align-items: center; }
.coach-board-tools label, .coach-fen-row label { color: var(--muted); font-size: 0.68rem; font-weight: 800; }
.coach-board-tools select, .coach-fen-row input {
  min-width: 0;
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--white);
  color: var(--ink);
}
.coach-board-tools select:focus, .coach-fen-row input:focus, .coach-compose textarea:focus { outline: 2px solid var(--mint); border-color: var(--forest); }
.tool-btn { width: 38px; height: 38px; padding: 0; border: 1px solid var(--line); border-radius: 5px; background: var(--white); display: grid; place-items: center; cursor: pointer; font-size: 1.05rem; }
.tool-btn:hover:not(:disabled) { border-color: var(--forest); color: var(--forest); }
.tool-btn:disabled { cursor: default; opacity: 0.35; }
.coach-fen-row { margin: -2px 0 10px; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 7px; align-items: center; }
.coach-fen-row .secondary-btn { height: 40px; padding: 8px 12px; }
.coach-board { width: 100%; max-width: 620px; }
.coach-move-line { min-height: 38px; padding: 9px 11px; border: 1px solid var(--line); border-top: 0; background: var(--white); color: var(--muted); font-size: 0.72rem; line-height: 1.4; overflow-wrap: anywhere; }
.coach-demo-controls { padding: 10px; border: 1px solid var(--line); border-top: 0; background: var(--mint-light); display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.coach-demo-controls > div:first-child { min-width: 0; display: flex; flex-direction: column; }
.coach-demo-controls b { overflow: hidden; font-size: 0.72rem; text-overflow: ellipsis; white-space: nowrap; }
.coach-demo-controls span { color: var(--muted); font-size: 0.6rem; }
.coach-demo-controls > div:last-child { display: flex; gap: 5px; }
.coach-demo-controls .tool-btn { width: 34px; height: 34px; font-size: 0.85rem; }
.coach-demo-controls .secondary-btn { min-height: 34px; padding: 6px 9px; font-size: 0.65rem; white-space: nowrap; }
.coach-chat { height: min(690px, calc(100vh - 150px)); min-height: 530px; border: 1px solid var(--line); border-radius: 7px; background: var(--white); display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto auto; overflow: hidden; }
.coach-chat-head { min-height: 67px; padding: 12px 15px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 40px 1fr auto; gap: 10px; align-items: center; }
.coach-chat-head img { width: 40px; height: 40px; border-radius: 5px; object-fit: cover; }
.coach-chat-head div { min-width: 0; display: flex; flex-direction: column; }
.coach-chat-head b { font-size: 0.84rem; }
.coach-chat-head span, .coach-chat-head small { color: var(--muted); font-size: 0.62rem; }
.coach-chat-head small { white-space: nowrap; }
.coach-transcript { min-height: 0; padding: 18px; display: flex; flex-direction: column; gap: 13px; overflow-y: auto; overscroll-behavior: contain; }
.coach-bubble { max-width: 88%; }
.coach-bubble span { display: block; margin-bottom: 4px; color: var(--forest); font-size: 0.56rem; font-weight: 800; letter-spacing: 0.09em; }
.coach-bubble p { margin: 0; padding: 11px 13px; border-radius: 6px; background: var(--mint-light); font-size: 0.82rem; line-height: 1.55; white-space: pre-line; }
.coach-bubble-user { margin-left: auto; }
.coach-bubble-user span { color: var(--muted); text-align: right; }
.coach-bubble-user p { background: var(--ink); color: white; }
/* Answers grounded on a position the board has since moved past. Greyed so they
   don't read as advice for the current position. */
.coach-bubble-stale { opacity: 0.5; }
.coach-bubble-stale span::after { content: " · previous position"; font-weight: 600; color: var(--muted); }
/* Layered coaching card — Plan / Next / Then / Watch, with the model line and
   deeper analysis behind actions rather than a wall of text. */
.coach-card .coach-card-plan { font-weight: 600; }
.coach-card-rows { margin: 8px 0 0; display: grid; grid-template-columns: auto 1fr; gap: 5px 12px; align-items: baseline; }
.coach-card-rows dt { color: var(--forest); font-weight: 800; font-size: 0.54rem; letter-spacing: 0.08em; text-transform: uppercase; white-space: nowrap; }
.coach-card-rows dd { margin: 0; font-size: 0.8rem; line-height: 1.45; }
.coach-card-rows dd.coach-card-move { font-weight: 700; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--forest-dark); }
.coach-card-actions { margin-top: 11px; display: flex; flex-wrap: wrap; gap: 8px; }
.coach-card-action { border: 1px solid var(--forest); color: var(--forest); background: transparent; border-radius: 999px; padding: 5px 13px; font-size: 0.72rem; font-weight: 700; cursor: pointer; }
.coach-card-action:hover:not(:disabled) { background: var(--mint-light); }
.coach-card-action:disabled { opacity: 0.45; cursor: default; }
.coach-card-detail { margin-top: 9px; }
/* #10: engine candidate-move chips under the answer — tap to ask "Why <move>?" */
.coach-candidates { margin-top: 11px; display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.coach-candidates-label { color: var(--muted); font-size: 0.62rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }
.coach-candidate-chip { border: 1px solid var(--line); background: var(--white); color: var(--ink); border-radius: 999px; padding: 4px 11px; font: 700 0.74rem ui-monospace, SFMono-Regular, Menlo, monospace; cursor: pointer; }
.coach-candidate-chip:hover { border-color: var(--forest); color: var(--forest); background: var(--mint-light); }
.coach-suggestions { padding: 0 14px 10px; display: flex; gap: 6px; overflow-x: auto; }
.coach-suggestions button { flex: 0 0 auto; min-height: 31px; padding: 5px 9px; border: 1px solid var(--line); border-radius: 5px; background: var(--white); color: var(--forest); cursor: pointer; font-size: 0.67rem; font-weight: 700; }
.coach-suggestions button:hover { border-color: var(--forest); }
.coach-compose { padding: 10px 12px; border-top: 1px solid var(--line); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: end; }
.coach-compose textarea { width: 100%; min-height: 47px; max-height: 110px; padding: 10px 11px; border: 1px solid var(--line); border-radius: 5px; resize: vertical; }
.coach-compose .primary-btn { min-height: 47px; padding-inline: 15px; }
.coach-compose .primary-btn:disabled { cursor: wait; opacity: 0.55; }
.coach-chat-status { min-height: 20px; margin: 0; padding: 0 13px 7px; color: #9b402e; font-size: 0.68rem; }
/* Bottom-sheet affordances — mobile only; hidden on the desktop two-column grid. */
.coach-chat-dock, .coach-chat-collapse { display: none; }

/* Game review */
.games-heading { max-width: 760px; }
.game-importer { padding: 24px 0 30px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.game-source-tabs { margin-bottom: 18px; }
.game-import-panel > label, .username-import > label { display: block; margin-bottom: 8px; font-size: 0.76rem; font-weight: 800; }
.game-import-panel textarea { width: 100%; min-height: 150px; padding: 13px; border: 1px solid var(--line); border-radius: 6px; background: var(--white); resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.76rem; line-height: 1.5; }
.game-import-panel textarea:focus, .username-import input:focus { outline: 2px solid var(--mint); border-color: var(--forest); }
.game-import-actions { margin-top: 9px; display: flex; justify-content: flex-end; gap: 8px; }
.file-btn { cursor: pointer; }
#pgnFile { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.username-import > div { max-width: 620px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.username-import input { min-width: 0; height: 46px; padding: 0 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--white); }
.username-import p { margin: 8px 0 0; color: var(--muted); font-size: 0.72rem; }
.game-import-status { min-height: 20px; margin: 10px 0 -10px; color: var(--muted); font-size: 0.75rem; }
.game-import-status.success { color: var(--forest); }
.game-import-status.error { color: #9b402e; }
.game-review { margin-top: 34px; display: grid; grid-template-columns: 190px minmax(350px, 0.9fr) minmax(300px, 1.1fr); gap: 24px; align-items: start; }
.game-review-list { max-height: 650px; border-right: 1px solid var(--line); padding-right: 13px; overflow-y: auto; }
.game-review-list-head { min-height: 32px; margin-bottom: 7px; display: flex; justify-content: space-between; color: var(--muted); font-size: 0.57rem; letter-spacing: 0.09em; }
.game-review-list-head b { color: var(--forest); }
.game-review-list > div:last-child { display: grid; gap: 5px; }
.game-review-list button { width: 100%; min-width: 0; padding: 9px 8px; border: 1px solid transparent; border-radius: 5px; background: transparent; display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 7px; text-align: left; cursor: pointer; }
.game-review-list button:hover { background: var(--mint-light); }
.game-review-list button.selected { border-color: var(--forest); background: var(--mint); }
.game-review-list button > span { color: var(--coral); font-size: 0.6rem; font-weight: 800; }
.game-review-list button div { min-width: 0; display: flex; flex-direction: column; }
.game-review-list button b { overflow: hidden; font-size: 0.68rem; text-overflow: ellipsis; white-space: nowrap; }
.game-review-list button small { margin-top: 2px; color: var(--muted); font-size: 0.57rem; }
.game-review-board-column { min-width: 0; }
.game-review-meta { min-height: 38px; display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.game-review-meta div { min-width: 0; display: flex; flex-direction: column; }
.game-review-meta b { overflow: hidden; font-size: 0.76rem; text-overflow: ellipsis; white-space: nowrap; }
.game-review-meta span { color: var(--muted); font-size: 0.6rem; }
.game-review-meta > span { flex: 0 0 auto; color: var(--forest); font-weight: 800; }
.game-review-board { width: 100%; border-width: 6px; }
.game-replay-controls { min-height: 48px; padding: 8px 0; display: grid; grid-template-columns: repeat(4, 38px) 1fr; gap: 6px; }
.game-replay-controls .secondary-btn { justify-self: end; min-height: 38px; padding: 7px 11px; }
.game-review-notes { min-width: 0; padding-top: 38px; }
.game-analysis { margin-bottom: 24px; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.game-analysis-head { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.game-analysis-head > div { min-width: 0; }
.game-analysis-head span { color: var(--coral); font-size: 0.57rem; font-weight: 800; }
.game-analysis-head h2, .game-review-notes .game-analysis-head h2 { margin: 4px 0 0; font-size: 1.08rem; }
.game-analysis-head .secondary-btn { flex: 0 0 auto; min-height: 34px; padding: 6px 9px; font-size: 0.65rem; }
.game-analysis > p { margin: 9px 0 0; color: var(--muted); font-size: 0.7rem; line-height: 1.5; }
.game-analysis-progress { height: 4px; margin-top: 12px; overflow: hidden; background: var(--line); }
.game-analysis-progress span { display: block; width: 0; height: 100%; background: var(--coral); transition: width 160ms ease; }
.game-turning-points { display: grid; gap: 7px; margin-top: 13px; }
.turning-point { width: 100%; border: 1px solid var(--line); border-radius: 5px; background: var(--white); overflow: hidden; }
.turning-point:hover, .turning-point.current { border-color: var(--forest); }
.turning-point-main { width: 100%; padding: 10px; border: 0; background: transparent; text-align: left; cursor: pointer; }
.turning-point.current .turning-point-main { background: var(--mint-light); }
.turning-point-top { display: flex; justify-content: space-between; gap: 10px; color: var(--forest); font-size: 0.61rem; font-weight: 800; }
.turning-point strong { display: block; margin: 6px 0 3px; font-size: 0.78rem; }
.turning-point p { margin: 0; color: var(--muted); font-size: 0.65rem; line-height: 1.45; }
.turning-point-line { margin-top: 5px; color: var(--forest); font-size: 0.62rem; }
.turning-point-actions { min-height: 35px; padding: 5px 7px; border-top: 1px solid var(--line); display: flex; gap: 4px; background: #fafaf6; }
.turning-point-actions button { min-height: 25px; padding: 3px 6px; border: 0; background: transparent; color: var(--forest); cursor: pointer; font-size: 0.61rem; font-weight: 800; }
.turning-point-actions button:hover:not(:disabled) { text-decoration: underline; }
.turning-point-actions button:last-child { margin-left: auto; }
.turning-point-actions button:disabled { color: var(--muted); cursor: default; }
.game-review-notes h2 { margin: 6px 0 10px; font-size: 1.55rem; }
.game-review-notes > p { color: var(--muted); font-size: 0.8rem; line-height: 1.55; }
.game-checkpoints { margin: 18px 0; border-top: 1px solid var(--line); }
.game-checkpoints div { padding: 10px 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 94px 1fr; gap: 10px; }
.game-checkpoints dt { color: var(--forest); font-size: 0.65rem; font-weight: 800; }
.game-checkpoints dd { margin: 0; color: var(--muted); font-size: 0.72rem; line-height: 1.45; }
.review-course-link { margin: 0; padding: 0; border: 0; background: transparent; cursor: pointer; font-size: 0.72rem; text-align: left; text-decoration: underline; text-underline-offset: 2px; }
.game-move-list { max-height: 112px; margin-bottom: 15px; padding: 9px; border: 1px solid var(--line); background: var(--white); display: flex; flex-wrap: wrap; align-content: flex-start; gap: 4px; overflow-y: auto; }
.game-move-list button { min-height: 26px; padding: 3px 6px; border: 1px solid transparent; border-radius: 3px; background: transparent; cursor: pointer; font-size: 0.65rem; }
.game-move-list button:hover { color: var(--forest); }
.game-move-list button.current { border-color: var(--coral); color: var(--forest); font-weight: 800; }
.game-review-notes > .primary-btn { width: 100%; }

/* Profile */
.profile-identity { margin-bottom: 32px; padding: 22px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 54px 1fr auto; gap: 16px; align-items: center; }
.profile-initial { width: 52px; height: 52px; border-radius: 50%; background: var(--forest); color: white; display: grid; place-items: center; font-size: 1.25rem; font-weight: 800; }
.profile-identity h2 { margin: 0 0 2px; font-size: 1.1rem; }
.profile-identity p { margin: 0; color: var(--muted); font-size: 0.78rem; }
.profile-identity > span { padding: 5px 9px; border: 1px solid var(--forest); border-radius: 4px; color: var(--forest); font-size: 0.62rem; font-weight: 800; }
.profile-plan { margin: -12px 0 38px; padding: 24px 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: minmax(220px, 1fr) minmax(340px, 1.3fr) auto; gap: 32px; align-items: center; }
.profile-plan h2 { margin: 4px 0 5px; font-size: 1.3rem; }
.profile-plan > div > p:not(.eyebrow) { max-width: 380px; margin: 0; color: var(--muted); font-size: 0.75rem; line-height: 1.5; }
.plan-usage { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px 22px; }
.plan-usage div { min-width: 0; }
.plan-usage dt { color: var(--muted); font-size: 0.64rem; }
.plan-usage dd { margin: 2px 0 0; color: var(--forest); font-size: 0.78rem; font-weight: 800; }
.plan-action { min-width: 148px; display: grid; gap: 7px; justify-items: stretch; text-align: center; }
.plan-action > b { color: var(--forest); font-size: 0.82rem; }
.plan-action .primary-btn { white-space: nowrap; }
.plan-action p { min-height: 16px; max-width: 190px; margin: 0; color: #9b402e; font-size: 0.62rem; }
.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 50px; }
.profile-section { min-width: 0; }
.profile-section-heading { margin-bottom: 22px; }
.profile-section-heading .eyebrow { margin-bottom: 5px; }
.profile-section-heading h2 { margin: 0; font-size: 1.4rem; }
.profile-section form { display: grid; gap: 9px; }
.profile-section label, .delete-confirm label { margin-top: 8px; font-size: 0.72rem; font-weight: 800; }
.profile-section select, .delete-confirm input { width: 100%; height: 44px; padding: 0 12px; border: 1px solid #c7ccc6; border-radius: 5px; background: white; color: var(--ink); font: inherit; }
.profile-section select:focus, .delete-confirm input:focus { outline: 2px solid var(--mint); border-color: var(--forest); }
.profile-section form .primary-btn { margin-top: 10px; }
.profile-status { min-height: 20px; margin: 0; color: var(--muted); font-size: 0.72rem; }
.profile-status.success { color: var(--forest); }
.profile-status.error, #deleteStatus { color: #9b402e; }
.profile-summary { margin: 0 0 20px; border-top: 1px solid var(--line); }
.profile-summary div { padding: 12px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 20px; align-items: baseline; }
.profile-summary dt { color: var(--muted); font-size: 0.75rem; }
.profile-summary dd { margin: 0; color: var(--forest); font-size: 1.1rem; font-weight: 800; }
.profile-export { width: 100%; }
.text-link { margin-top: 15px; display: inline-block; color: var(--forest); font-size: 0.78rem; font-weight: 700; }
/* Sign out is the common action — make it the prominent primary button. */
.profile-signout { width: 100%; min-height: 48px; margin-top: 4px; font-size: 0.95rem; }
/* Delete account is deliberately de-emphasized (still accessible + functional). */
.danger-zone { margin-top: 40px; padding: 16px 0 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center; opacity: 0.72; }
.danger-zone:hover, .danger-zone:focus-within { opacity: 1; }
.danger-zone .danger-copy span { color: var(--muted); font-size: 0.78rem; font-weight: 700; }
.danger-zone p { margin: 3px 0 0; color: var(--muted); font-size: 0.72rem; }
.danger-deemph { padding: 5px 4px; border: 0; background: transparent; color: var(--muted); font-size: 0.72rem; font-weight: 700; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.danger-deemph:hover { color: #9b402e; }
.danger-btn { min-height: 40px; padding: 8px 13px; border: 1px solid var(--coral); border-radius: 5px; background: white; color: #9b402e; cursor: pointer; font-weight: 800; }
.danger-btn:hover:not(:disabled) { background: #fff3ef; }
.danger-btn:disabled { cursor: not-allowed; opacity: 0.45; }

/* Pro Bird upgrade modal — shown when a free limit is hit. */
.pro-modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(23, 32, 27, 0.55); }
.pro-modal[hidden] { display: none; }
.pro-modal-card { position: relative; width: 100%; max-width: 380px; background: var(--white); border-radius: 18px; padding: 30px 26px 20px; text-align: center; box-shadow: 0 24px 60px rgba(23,32,27,0.32); max-height: calc(100dvh - 40px); overflow-y: auto; }
.pro-modal-close { position: absolute; top: 10px; right: 12px; border: 0; background: none; font-size: 1.5rem; line-height: 1; color: var(--muted); cursor: pointer; }
.pro-modal-mark { width: 54px; height: 54px; border-radius: 12px; margin-bottom: 10px; }
.pro-modal-card h2 { font-size: 1.7rem; margin: 2px 0 8px; }
.pro-modal-lede { color: var(--muted); margin-bottom: 18px; }
.pro-modal-benefits { list-style: none; padding: 0; margin: 0 0 20px; text-align: left; display: grid; gap: 9px; }
.pro-modal-benefits li { position: relative; padding-left: 26px; font-weight: 600; font-size: 0.92rem; }
.pro-modal-benefits li::before { content: "✓"; position: absolute; left: 0; top: 0; color: var(--forest); font-weight: 800; }
.pro-modal-plans { margin-bottom: 12px; }
.pro-modal-price { display: block; font-size: 1.5rem; color: var(--forest-dark); margin-bottom: 14px; }
.pro-modal-upgrade { width: 100%; }
.pro-modal-status:not(:empty) { margin: 8px 0 2px; color: var(--coral); font-size: 0.85rem; }
.pro-modal-later { display: block; margin: 8px auto 0; color: var(--muted); }

/* Opening-mistake callout at the top of an imported game's analysis. */
.opening-mistake { border: 1px solid var(--coral); border-radius: 12px; background: #fff3ef; padding: 16px 18px; margin-bottom: 14px; }
.opening-mistake .eyebrow { color: #9b402e; }
.opening-mistake b { display: block; margin: 4px 0 6px; font-size: 1.02rem; }
.opening-mistake p:not(.eyebrow) { color: var(--muted); margin: 0 0 12px; font-size: 0.9rem; }
.opening-mistake .primary-btn.full { width: 100%; }
.delete-confirm { grid-column: 1 / -1; padding: 18px; background: #fff3ef; display: grid; gap: 9px; }
.delete-confirm > div { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.delete-confirm p { min-height: 18px; margin: 0; }

/* Authentication */
.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--paper);
}

.auth-page main { margin-left: 0; }

.auth-shell {
  width: min(100% - 32px, 470px);
  min-height: auto;
  padding: 48px 0;
}

.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 24px 4px;
  color: var(--ink);
  font-size: 1.2rem;
  font-weight: 800;
  text-decoration: none;
}

.auth-brand img { width: 38px; height: 38px; object-fit: contain; }

.auth-panel {
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  box-shadow: var(--shadow);
}

.auth-panel h1 { margin-bottom: 10px; font-size: 2rem; }
.auth-copy { margin: 0 0 28px; color: var(--muted); }
.auth-form label { display: block; margin-bottom: 8px; font-size: 0.78rem; font-weight: 800; }
.auth-email-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }

.auth-email-row input {
  min-width: 0;
  height: 46px;
  padding: 0 13px;
  border: 1px solid #c7ccc6;
  border-radius: 6px;
  background: white;
  color: var(--ink);
  font: inherit;
}

.auth-email-row input:focus { outline: 2px solid var(--mint); border-color: var(--forest); }
.auth-email-row .primary-btn { min-height: 46px; white-space: nowrap; }
.auth-email-row .primary-btn:disabled { cursor: wait; opacity: 0.65; }
.auth-status { min-height: 20px; margin: 10px 0 0; color: var(--muted); font-size: 0.78rem; }
.auth-status.success { color: var(--forest); }
.auth-status.error { color: #9b402e; }

.auth-divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--muted);
  font-size: 0.72rem;
}

.auth-divider::before, .auth-divider::after { content: ""; height: 1px; background: var(--line); }

.google-auth-btn {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid #c7ccc6;
  border-radius: 6px;
  background: white;
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
}

.google-auth-btn:hover { border-color: var(--forest); }
.google-auth-btn.disabled { pointer-events: none; opacity: 0.48; }
.google-auth-btn span { width: 22px; font-size: 1.05rem; text-align: center; }
.auth-legal { margin: 18px 0 0; color: var(--muted); font-size: 0.72rem; line-height: 1.5; text-align: center; }
.auth-legal a { color: var(--forest); }
.auth-back { display: block; margin-top: 20px; color: var(--forest); font-size: 0.82rem; font-weight: 700; text-align: center; }

/* Legal */
.legal-page { min-height: 100vh; background: var(--white); }
.legal-header {
  min-height: 72px;
  padding: 0 max(24px, calc((100% - 920px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}
.legal-header .auth-brand { margin: 0; }
.legal-return { color: var(--forest); font-size: 0.82rem; font-weight: 700; text-decoration: none; }
.legal-return:hover { text-decoration: underline; }
.legal-main { width: min(100% - 40px, 760px); min-height: 0; margin: 0 auto; padding: 64px 0 40px; }
.legal-document h1 { max-width: 650px; margin-bottom: 8px; font-size: clamp(2.25rem, 6vw, 3.2rem); }
.legal-updated { margin-bottom: 38px; color: var(--muted); font-size: 0.8rem; }
.legal-document h2 { margin: 40px 0 12px; font-size: 1.35rem; }
.legal-document h3 { margin: 24px 0 9px; font-size: 1rem; }
.legal-document p, .legal-document li { color: #39423d; line-height: 1.7; }
.legal-document ul { margin: 0; padding-left: 22px; }
.legal-document li + li { margin-top: 8px; }
.legal-document a { color: var(--forest); text-underline-offset: 2px; }
.legal-caps { font-size: 0.86rem; }
.legal-footer {
  margin-top: 56px;
  padding-top: 22px;
  display: flex;
  gap: 20px;
  border-top: 1px solid var(--line);
}
.legal-footer a { color: var(--muted); font-size: 0.76rem; text-decoration: none; }
.legal-footer a:hover, .legal-footer a[aria-current="page"] { color: var(--forest); text-decoration: underline; }

/* About */
.about-main { width: min(100% - 48px, 920px); margin: 0 auto; padding: 64px 0 40px; }
.about-intro { max-width: 720px; margin-bottom: 34px; }
.about-intro h1 { margin-bottom: 8px; font-size: clamp(3rem, 8vw, 5.6rem); }
.about-intro .about-tagline { margin: 0; color: var(--forest); font-size: clamp(1.25rem, 3vw, 1.75rem); font-weight: 700; }
.about-intro .about-lede { max-width: 610px; margin: 18px 0 22px; color: var(--muted); font-size: 1.05rem; line-height: 1.65; }
.about-intro .primary-btn { display: inline-flex; text-decoration: none; }
.about-visual { display: block; width: 100%; aspect-ratio: 1200 / 630; object-fit: cover; border: 1px solid var(--line); }
.about-statement { display: grid; grid-template-columns: 190px 1fr; column-gap: 48px; margin: 72px 0 50px; padding-top: 28px; border-top: 1px solid var(--line); }
.about-statement .eyebrow { grid-row: 1 / span 2; }
.about-statement h2 { margin-bottom: 14px; font-size: clamp(1.8rem, 4vw, 2.8rem); }
.about-statement > p:last-child { max-width: 650px; color: #39423d; font-size: 1.03rem; line-height: 1.75; }
.about-engine > p { max-width: 650px; color: #39423d; font-size: 1.03rem; line-height: 1.75; }
.about-engine-split { grid-column: 2; margin: 24px 0 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; }
.about-engine-split li { display: flex; flex-direction: column; gap: 7px; padding: 18px 20px; border: 1px solid var(--line); border-radius: 8px; background: var(--white); }
.about-engine-split b { font-size: 0.95rem; }
.about-engine-split span { color: #39423d; font-size: 0.92rem; line-height: 1.55; }
.about-roles { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.about-roles article { min-width: 0; padding: 30px 26px 34px 0; }
.about-roles article + article { padding-left: 26px; border-left: 1px solid var(--line); }
.about-roles span { color: var(--coral); font-size: 0.68rem; font-weight: 800; }
.about-roles h3 { margin: 18px 0 9px; font-size: 1.08rem; }
.about-roles p { margin: 0; color: var(--muted); font-size: 0.84rem; line-height: 1.65; }
.about-games { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(260px, 0.85fr); gap: 72px; margin: 72px 0; padding: 48px; background: var(--mint-light); }
.about-games h2 { margin-bottom: 14px; font-size: clamp(1.8rem, 4vw, 2.6rem); }
.about-games p:not(.eyebrow) { max-width: 520px; margin: 0; color: #39423d; line-height: 1.7; }
.about-games ul { margin: 4px 0 0; padding: 0; list-style: none; }
.about-games li { position: relative; padding: 12px 0 12px 26px; border-bottom: 1px solid #cbdcca; font-size: 0.9rem; font-weight: 700; }
.about-games li::before { content: "✓"; position: absolute; left: 0; color: var(--forest); font-weight: 900; }
.about-pops { display: grid; grid-template-columns: minmax(220px, 0.7fr) minmax(420px, 1.3fr); gap: 48px; align-items: center; margin: 72px 0; }
.about-pops h2 { margin-bottom: 9px; font-size: 2rem; }
.about-pops p:not(.eyebrow) { color: var(--muted); line-height: 1.7; }
.about-pop-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 18px; }
.about-pop-row strong { min-height: 68px; display: grid; place-items: center; clip-path: polygon(50% 0, 61% 19%, 82% 8%, 86% 31%, 100% 42%, 83% 55%, 94% 78%, 68% 77%, 57% 100%, 44% 79%, 17% 91%, 20% 63%, 0 51%, 18% 38%, 10% 14%, 37% 21%); color: var(--ink); font-size: 0.86rem; font-style: italic; }
.about-pop-row strong:nth-child(1) { background: #f4cf45; }
.about-pop-row strong:nth-child(2) { background: #4596d7; }
.about-pop-row strong:nth-child(3) { background: #ef5d58; }
.about-pop-row strong:nth-child(4) { background: #58be89; }
.about-pop-row strong:nth-child(5) { background: #8b5bd2; }
.about-pop-row strong:nth-child(6) { background: #f58b3d; }
.about-loop { padding: 54px; background: var(--forest); color: white; }
.about-loop .eyebrow { color: #b9d3c1; }
.about-loop h2 { max-width: 700px; margin-bottom: 16px; font-size: clamp(1.8rem, 4vw, 2.7rem); }
.about-loop > p:not(.eyebrow) { max-width: 650px; color: #dbe9de; line-height: 1.7; }
.about-loop ol { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; margin: 30px 0 28px; padding: 0; list-style: none; border-block: 1px solid rgba(255, 255, 255, 0.22); }
.about-loop li { min-width: 0; padding: 22px 18px 22px 0; font-size: 0.86rem; font-weight: 700; line-height: 1.45; }
.about-loop li + li { padding-left: 18px; border-left: 1px solid rgba(255, 255, 255, 0.22); }
.about-loop li span { display: block; margin-bottom: 10px; color: #b9d3c1; font-size: 0.66rem; }
.about-loop .primary-btn { margin-top: 12px; border-color: white; background: white; color: var(--forest-dark); }
.about-main .legal-footer { margin-top: 42px; }

@media (max-width: 900px) {
  .side-nav { display: none; }
  .topbar { display: flex; }
  main { margin-left: 0; }
  .view { width: min(100% - 36px, 720px); padding-top: 34px; }
  .daily-lesson { grid-template-columns: 1fr 0.85fr; }
  .lesson-copy { padding: 36px; }
  .lesson-kicker { margin-bottom: 28px; }
  .practice-grid { grid-template-columns: 1fr; }
  .practice-card { min-height: 115px; }
  .drill-layout { grid-template-columns: minmax(0, 600px); gap: 18px; }
  .coach-panel { margin-top: 0; min-height: 0; }
  .opening-row { grid-template-columns: 54px 1fr 80px; }
  .opening-mastery { display: none; }
  .guide-picker { grid-template-columns: repeat(2, 1fr); }
  .response-lab { grid-template-columns: minmax(260px, 0.8fr) minmax(360px, 1.2fr); gap: 24px; }
  .attack-workspace { grid-template-columns: minmax(280px, 0.85fr) minmax(340px, 1.15fr); gap: 28px; }
  .coach-room-layout { grid-template-columns: minmax(360px, 0.9fr) minmax(330px, 1.1fr); gap: 22px; }
  .game-review { grid-template-columns: 145px minmax(330px, 0.9fr) minmax(270px, 1.1fr); gap: 18px; }
}

@media (max-width: 520px) {
  .auth-shell { padding: 28px 0; }
  .auth-panel { padding: 26px 22px; }
  .auth-email-row { grid-template-columns: 1fr; }
  .auth-email-row .primary-btn { width: 100%; }
  .legal-header { min-height: 64px; padding: 0 18px; }
  .legal-header .auth-brand { font-size: 1.05rem; }
  .legal-header .auth-brand img { width: 34px; height: 34px; }
  .legal-return { font-size: 0.74rem; }
  .legal-main { width: calc(100% - 36px); padding-top: 42px; }
  .legal-document h2 { margin-top: 34px; }
}

@media (max-width: 640px) {
  body { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
  body.auth-page { padding-bottom: 0; }
  body.in-drill, body.in-coach { height: 100dvh; padding-bottom: 0; overflow: hidden; overscroll-behavior: none; }
  .in-drill .app-shell, .in-drill main, .in-coach .app-shell, .in-coach main { height: 100%; min-height: 0; overflow: hidden; }
  .topbar { height: 60px; padding: 0 16px; }
  .brand img { width: 34px; height: 34px; }
  .brand span { font-size: 1.08rem; }
  .view { width: calc(100% - 30px); padding: 27px 0 40px; }
  .view.preview-mode { width: calc(100% - 30px); padding: 27px 0 40px; }
  .home-heading { display: block; margin-bottom: 16px; }
  h1 { font-size: 1.9rem; }
  .home-heading h1 { max-width: 320px; }
  .home-heading .lede { display: none; }
  .week-streak { margin-top: 16px; justify-content: space-between; }
  .day-dot span { width: 30px; height: 30px; }
  /* column-reverse puts the playable board (DOM order: copy, then board col)
     above the fold — the board is the primary action. */
  .daily-lesson { min-height: 0; display: flex; flex-direction: column-reverse; }
  .lesson-board-col { width: 100%; }
  .lesson-board-stage { width: min(72vw, 290px); }
  .lesson-board { width: 100%; margin: 0 auto; transform: none; box-shadow: none; }
  .lesson-board .square { font-size: clamp(1.4rem, 7vw, 2.2rem); }
  .lesson-board-task { font-size: 0.78rem; margin-bottom: 10px; }
  /* Compact card under the board: opening name first, then variation/description;
     the secondary "Open the full lesson" link sits last. */
  .lesson-copy { padding: 18px 22px 20px; display: flex; flex-direction: column; }
  .lesson-copy .lesson-kicker { order: 1; margin-bottom: 10px; }
  .lesson-copy h2 { order: 2; font-size: 1.85rem; margin-bottom: 2px; }
  .lesson-copy .lesson-meta { order: 3; }
  .lesson-copy .lesson-variation { order: 5; margin-top: 16px; }
  .lesson-copy #dailyDescription { order: 6; margin-top: 8px; }
  .lesson-copy .lesson-stats { order: 7; }
  .lesson-copy .lesson-open-link { order: 8; margin-top: 12px; }
  .opening-brief { margin-top: 22px; }
  .opening-brief-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .opening-brief-grid article { min-height: 125px; padding: 13px; }
  .opening-brief-grid article p { font-size: 0.73rem; }
  .access-preview-layout { grid-template-columns: 1fr; gap: 6px; }
  .access-preview-panel { min-height: 58px; grid-template-rows: 7px 2.4em 5px 5px; gap: 5px; }
  .section-heading { margin-top: 42px; }
  .review-strip { align-items: flex-start; flex-wrap: wrap; }
  .review-strip .secondary-btn { width: 100%; }
  .bottom-nav { position: fixed; display: grid; grid-template-columns: repeat(6, 1fr); inset: auto 0 0; height: calc(64px + env(safe-area-inset-bottom)); padding: 5px 4px env(safe-area-inset-bottom); border-top: 1px solid var(--line); background: rgba(255,254,250,0.97); z-index: 50; }
  .bottom-nav .nav-item { flex-direction: column; justify-content: center; gap: 3px; padding: 4px; border-radius: 4px; font-size: 0.65rem; }
  .bottom-nav .nav-item.active { background: transparent; color: var(--forest); }
  .bottom-nav .nav-icon { font-size: 1.2rem; }
  .in-drill .topbar, .in-drill .bottom-nav, .in-coach .topbar, .in-coach .bottom-nav { display: none; }
  .train-view { width: 100%; height: 100%; padding: max(8px, env(safe-area-inset-top)) 0 env(safe-area-inset-bottom); display: grid; grid-template-rows: auto minmax(0, 1fr); overflow: hidden; }
  .drill-topline { grid-template-columns: 38px 1fr 38px; gap: 12px; margin: 0 15px 8px; }
  .drill-layout { min-height: 0; grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); gap: 0; overflow: hidden; }
  .board-column { min-height: 0; display: grid; grid-template-rows: auto auto auto; align-content: start; }
  .icon-btn { width: 36px; height: 36px; }
  .turn-banner { margin: 0 15px 8px; }
  .chessboard { width: min(100vw, calc(100dvh - 300px)); border-width: 0; box-shadow: none; justify-self: center; }
  .board-caption { margin: 8px 15px 0; }
  .coach-panel { min-height: 0; margin-top: 8px; border: 0; border-top: 1px solid var(--line); border-radius: 0; padding: 16px 18px max(10px, env(safe-area-inset-bottom)); overflow-y: auto; overscroll-behavior: contain; }
  .coach-head { padding-bottom: 13px; }
  .coach-message { padding: 17px 0 8px; }
  .coach-message p:last-child { margin-bottom: 8px; font-size: 0.94rem; }
  .move-line { min-height: 42px; }
  .feedback { margin-top: 13px; padding-top: 13px; }
  .coach-panel:has(#nextMove:not([hidden])) { padding-bottom: calc(74px + env(safe-area-inset-bottom)); }
  .in-drill #nextMove:not([hidden]) { position: fixed; inset: auto 16px max(12px, env(safe-area-inset-bottom)); z-index: 80; width: calc(100% - 32px); margin: 0; box-shadow: 0 10px 30px rgba(23, 32, 27, 0.2); }
  .page-heading { margin-bottom: 25px; }
  .segmented { display: flex; }
  .segmented button { flex: 1; padding-inline: 12px; }
  .opening-filters { display: grid; }
  .opening-filters .segmented { min-width: 0; overflow-x: auto; }
  .opening-filters .segmented button { min-width: max-content; }
  .opening-filters .segmented:first-child button { min-width: 0; }
  /* Mobile: choice architecture comes before the board. Tabs -> the choice-first
     block (title, dropdown, branch, line chips); the board then illustrates it. */
  .guide-picker { display: none; }
  .response-choice { display: block; }
  .response-lab { grid-template-columns: 1fr; gap: 16px; padding-top: 2px; }
  /* The choice now lives above the board, so the full branch chooser and the
     redundant context/title are removed on mobile. */
  .line-tree,
  .response-content .response-context,
  .response-content .response-title-row { display: none; }
  .response-board-wrap { margin-inline: 0; }
  .response-board { border-width: 0; box-shadow: none; }
  .response-board { width: calc(100% - 2px); margin-inline: auto; }
  .response-position-label { padding: 0; }
  .response-context { align-items: flex-start; flex-direction: column; gap: 3px; }
  .response-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .response-title-row h2 { font-size: 1.45rem; }
  .response-title-row > strong { font-size: 1.65rem; }
  .response-content .primary-btn { width: 100%; }
  .attack-heading { display: block; }
  .attack-course-progress { margin-top: 20px; padding: 0; border-left: 0; }
  .attack-modules { margin: 0 -15px 23px; padding: 0 15px 8px; grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 145px; }
  .attack-workspace { grid-template-columns: 1fr; gap: 8px; padding-top: 20px; }
  .attack-board { border-width: 0; box-shadow: none; }
  .attack-principle { margin-bottom: 20px; }
  .attack-decision { padding-top: 12px; }
  .attack-decision h2 { font-size: 1.65rem; }
  .attack-prompt { font-size: 0.96rem; }
  .opening-row { grid-template-columns: 48px 1fr; gap: 12px; padding: 16px; }
  .opening-emblem { width: 46px; height: 46px; }
  .opening-attributes { grid-column: 1 / -1; }
  .opening-row .secondary-btn { grid-column: 1 / -1; width: 100%; }
  .stat-grid { grid-template-columns: 1fr; }
  .mastery-row { grid-template-columns: 34px 1fr 42px; gap: 10px; }
  .mastery-bar { grid-column: 2 / -1; grid-row: 2; }
  .pattern-progress .section-heading { align-items: flex-start; gap: 18px; }
  .pattern-progress .section-heading .secondary-btn { white-space: nowrap; }
  .pattern-mastery-grid { grid-template-columns: 1fr; }
  .profile-grid { grid-template-columns: 1fr; gap: 38px; }
  .profile-plan { grid-template-columns: 1fr; gap: 22px; align-items: start; }
  .plan-usage { grid-template-columns: 1fr 1fr; width: 100%; }
  .plan-action { width: 100%; text-align: left; }
  .plan-action p { max-width: none; }
  .danger-zone { grid-template-columns: 1fr; }
  .danger-zone > .danger-btn { width: 100%; }
  .delete-confirm { grid-column: 1; }
  .delete-confirm > div { grid-template-columns: 1fr; }
  .sync-card { flex-wrap: wrap; }
  .sync-card .secondary-btn { width: 100%; }
  .about-main { width: calc(100% - 30px); padding-top: 36px; }
  .about-intro { margin-bottom: 24px; }
  .about-intro h1 { font-size: 3rem; }
  .about-visual { width: calc(100% + 30px); margin-left: -15px; border-inline: 0; }
  .about-statement { grid-template-columns: 1fr; gap: 0; margin: 52px 0 34px; }
  .about-statement .eyebrow { grid-row: auto; }
  .about-engine-split { grid-column: auto; grid-template-columns: 1fr; }
  .about-roles { grid-template-columns: 1fr; }
  .about-roles article, .about-roles article + article { padding: 24px 0; border-left: 0; }
  .about-roles article + article { border-top: 1px solid var(--line); }
  .about-games { grid-template-columns: 1fr; gap: 24px; margin: 52px -15px; padding: 38px 24px; }
  .about-pops { grid-template-columns: 1fr; gap: 18px; margin: 52px 0; }
  .about-pop-row { gap: 9px; }
  .about-pop-row strong { min-height: 62px; font-size: 0.74rem; }
  .about-loop { margin-inline: -15px; padding: 38px 24px; }
  .about-loop ol { grid-template-columns: 1fr 1fr; }
  .about-loop li:nth-child(3) { border-left: 0; border-top: 1px solid rgba(255, 255, 255, 0.22); }
  .about-loop li:nth-child(4) { border-top: 1px solid rgba(255, 255, 255, 0.22); }
  .game-import-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .username-import > div { grid-template-columns: 1fr; }
  .username-import .primary-btn { width: 100%; }
  .game-review { grid-template-columns: 1fr; gap: 18px; }
  .game-review-list { max-height: none; margin: 0 -15px; padding: 0 15px 8px; border-right: 0; display: flex; gap: 6px; overflow-x: auto; }
  .game-review-list-head { min-width: 80px; display: flex; flex-direction: column; justify-content: center; }
  .game-review-list > div:last-child { display: flex; gap: 6px; }
  .game-review-list button { min-width: 158px; }
  .game-review-meta { padding: 0 2px; }
  .game-review-board { width: calc(100% + 30px); margin-left: -15px; border-width: 0; box-shadow: none; }
  .game-review-notes { padding-top: 0; }
  .game-review-notes h2 { font-size: 1.4rem; }
  .game-analysis { margin: 0 -15px 24px; padding: 4px 15px 22px; }
  .game-analysis-head h2, .game-review-notes .game-analysis-head h2 { font-size: 1.08rem; }
  .game-checkpoints div { grid-template-columns: 82px 1fr; }
  .coach-room-view { width: 100%; height: 100%; padding: max(8px, env(safe-area-inset-top)) 0 env(safe-area-inset-bottom); display: grid; grid-template-rows: auto minmax(0, 1fr); overflow: hidden; }
  .coach-room-header { min-height: 40px; margin: 0 14px 7px; grid-template-columns: 38px 1fr auto; gap: 9px; align-items: center; }
  .coach-room-header .coach-room-close { display: grid; }
  .coach-room-header .eyebrow { margin: 0; }
  .coach-room-header h1 { display: none; }
  .coach-room-header > span { padding: 0; font-size: 0.58rem; }
  /* Board-primary layout: the board fills the screen and the chat is a bottom
     sheet (fixed, out of flow). Collapsed it is a docked bar (avatar + latest
     coach line + Ask); tapping expands it over the board. Because the compose
     box now lives in an on-demand sheet — never in the scroll flow — the old
     overflow-hides-the-controls bug is structurally impossible. */
  .coach-room-layout { min-height: 0; display: flex; flex-direction: column; gap: 0; overflow: hidden; }
  .coach-board-area { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: stretch; padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
  .coach-board-area > * { flex: none; }
  .coach-board-tools { min-height: 37px; margin: 0 12px 6px; grid-template-columns: minmax(0, 1fr) 36px 36px; }
  .coach-board-tools label { display: none; }
  .coach-board-tools select { height: 36px; font-size: 0.72rem; }
  .coach-board-tools .tool-btn { width: 36px; height: 36px; }
  .coach-fen-row { margin: 0 12px 6px; grid-template-columns: minmax(0, 1fr) auto; }
  .coach-fen-row label { display: none; }
  .coach-fen-row input, .coach-fen-row .secondary-btn { height: 34px; font-size: 0.68rem; }
  /* Square board sized to fit the height left after the tools/move-line/dock.
     Explicit width == height (viewport math) makes the grid height DEFINITE, so
     the 1fr rows divide evenly instead of growing to content and overriding the
     aspect ratio. The chat is an out-of-flow sheet now, so this budget only
     covers the board chrome + the collapsed dock and stays within any phone. */
  .coach-board { --coach-board-size: min(100vw, calc(100dvh - 214px)); width: var(--coach-board-size); height: var(--coach-board-size); min-height: 0; margin: auto; grid-template-rows: repeat(8, 1fr); border-width: 0; box-shadow: none; }
  .coach-board-area:has(.coach-demo-controls:not([hidden])) .coach-board { --coach-board-size: min(100vw, calc(100dvh - 252px)); }
  .coach-move-line { min-height: 28px; max-height: 44px; padding: 6px 12px; border-inline: 0; font-size: 0.62rem; overflow-y: auto; }
  .coach-demo-controls { padding: 6px 10px; border-inline: 0; }
  .coach-demo-controls > div:first-child { display: none; }
  .coach-demo-controls > div:last-child { width: 100%; justify-content: center; }
  .coach-demo-controls .secondary-btn { margin-left: auto; }

  .coach-chat { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; height: auto; min-height: 0; max-height: 92dvh; border: 0; border-top: 1px solid var(--line); border-radius: 16px 16px 0 0; background: var(--white); box-shadow: 0 -10px 30px rgba(23, 32, 27, 0.16); display: flex; flex-direction: column; transition: height 0.28s ease; }
  .coach-chat.open { height: min(86dvh, 640px); }
  /* Collapsed: docked bar only. */
  .coach-chat .coach-chat-dock { display: flex; }
  .coach-chat .coach-chat-head,
  .coach-chat .coach-transcript,
  .coach-chat .coach-suggestions,
  .coach-chat .coach-compose,
  .coach-chat .coach-chat-status { display: none; }
  /* Expanded: full conversation. */
  .coach-chat.open .coach-chat-dock { display: none; }
  .coach-chat.open .coach-chat-head { display: grid; grid-template-columns: 34px 1fr auto auto; }
  .coach-chat.open .coach-transcript { display: flex; flex: 1 1 auto; min-height: 0; }
  .coach-chat.open .coach-suggestions { display: flex; }
  .coach-chat.open .coach-compose { display: grid; }
  .coach-chat.open .coach-chat-status { display: block; }

  .coach-chat-dock { align-items: center; gap: 11px; width: 100%; min-height: 60px; padding: 9px 14px calc(9px + env(safe-area-inset-bottom)); border: 0; background: transparent; text-align: left; cursor: pointer; }
  .coach-chat-dock-avatar { flex: none; width: 36px; height: 36px; border-radius: 6px; object-fit: cover; }
  .coach-chat-dock-body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
  .coach-chat-dock-name { color: var(--forest); font-size: 0.56rem; font-weight: 800; letter-spacing: 0.09em; text-transform: uppercase; }
  .coach-chat-dock-preview { overflow: hidden; color: var(--ink); font-size: 0.82rem; line-height: 1.3; white-space: nowrap; text-overflow: ellipsis; }
  .coach-chat-dock-cta { flex: none; display: inline-flex; align-items: center; gap: 5px; padding: 8px 14px; border-radius: 999px; background: var(--forest); color: #fff; font-size: 0.72rem; font-weight: 800; }
  .coach-chat-dock-chevron { font-size: 0.58rem; }
  @keyframes coachDockPulse { 0% { box-shadow: 0 0 0 0 rgba(43, 122, 71, 0.5); } 100% { box-shadow: 0 0 0 13px rgba(43, 122, 71, 0); } }
  .coach-chat-dock.pulse .coach-chat-dock-avatar { animation: coachDockPulse 0.9s ease-out 2; }

  .coach-chat-collapse { width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 6px; background: var(--white); place-items: center; cursor: pointer; color: var(--muted); font-size: 0.85rem; }
  .coach-chat.open .coach-chat-collapse { display: grid; }
  .coach-chat-head { min-height: 48px; padding: 6px 12px; }
  .coach-chat-head img { width: 34px; height: 34px; }
  .coach-transcript { padding: 10px 13px; gap: 9px; }
  .coach-bubble p { padding: 8px 10px; font-size: 0.76rem; }
  .coach-suggestions { padding: 0 11px 6px; }
  .coach-compose { padding: 7px 10px max(7px, env(safe-area-inset-bottom)); }
  .coach-compose textarea { min-height: 42px; resize: none; font-size: 0.8rem; }
  .coach-compose .primary-btn { min-height: 42px; }
  .coach-chat-status { padding-inline: 11px; }
  @media (prefers-reduced-motion: reduce) {
    .coach-chat { transition: none; }
    .coach-chat-dock.pulse .coach-chat-dock-avatar { animation: none; }
  }
}

@media (max-height: 600px) and (orientation: landscape) and (pointer: coarse) {
  body.in-drill { height: 100dvh; padding: 0; overflow: hidden; overscroll-behavior: none; }
  .in-drill .app-shell, .in-drill main { height: 100%; min-height: 0; margin: 0; overflow: hidden; }
  .in-drill .topbar, .in-drill .side-nav, .in-drill .bottom-nav { display: none; }
  .train-view { width: 100%; height: 100%; padding: max(6px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); display: grid; grid-template-rows: auto minmax(0, 1fr); overflow: hidden; }
  .drill-topline { grid-template-columns: 36px 1fr 36px; gap: 10px; margin: 0 0 6px; }
  .icon-btn { width: 34px; height: 34px; }
  .drill-layout { min-height: 0; grid-template-columns: minmax(0, 1fr) minmax(250px, 38vw); grid-template-rows: minmax(0, 1fr); gap: 14px; overflow: hidden; }
  .board-column { min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
  .turn-banner { margin: 0 0 5px; }
  .chessboard { width: auto; height: 100%; max-width: 100%; border-width: 0; box-shadow: none; justify-self: center; }
  .board-caption { margin: 4px 0 0; }
  .coach-panel { min-height: 0; margin: 0; padding: 12px 14px; border-radius: 0; overflow-y: auto; overscroll-behavior: contain; }
  .coach-head { padding-bottom: 8px; }
  .coach-message { padding: 9px 0 5px; }
  .move-line { min-height: 36px; padding: 8px 10px; }
  .feedback { margin-top: 8px; padding-top: 8px; }
  .full { margin-top: 8px; }
  .coach-panel:has(#nextMove:not([hidden])) { padding-bottom: 12px; }
  .in-drill #nextMove:not([hidden]) { position: static; width: 100%; margin-top: 8px; box-shadow: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
