/* =========================================================
   CHESS TUTOR — DESIGN SYSTEM
   Adapted from Chess Tutor Style Guide v1.0
   Modern minimal · cool neutrals · warm board
   ========================================================= */

:root {
  /* Neutrals — cool slate, low saturation */
  --ink-950: oklch(18% 0.01 250);
  --ink-900: oklch(24% 0.01 250);
  --ink-800: oklch(32% 0.012 250);
  --ink-700: oklch(42% 0.012 250);
  --ink-600: oklch(52% 0.01 250);
  --ink-500: oklch(62% 0.008 250);
  --ink-400: oklch(74% 0.006 250);
  --ink-300: oklch(84% 0.005 250);
  --ink-200: oklch(91% 0.004 250);
  --ink-150: oklch(95% 0.003 250);
  --ink-100: oklch(97.5% 0.002 250);
  --ink-50:  oklch(99% 0.002 250);

  /* Board — warm wooden, low sat */
  --board-light: oklch(92% 0.018 80);
  --board-dark:  oklch(52% 0.045 55);
  --board-edge:  oklch(28% 0.02 55);

  /* Accents */
  --amber-500: oklch(72% 0.14 65);
  --amber-400: oklch(80% 0.12 65);
  --amber-100: oklch(94% 0.05 75);

  --teal-600: oklch(55% 0.09 195);
  --teal-400: oklch(72% 0.08 195);
  --teal-100: oklch(94% 0.03 195);

  --crimson-600: oklch(55% 0.16 25);
  --crimson-100: oklch(94% 0.04 25);

  --moss-600: oklch(55% 0.1 145);
  --moss-100: oklch(94% 0.04 145);

  /* Semantic — light theme */
  --bg: var(--ink-50);
  --surface: #ffffff;
  --surface-2: var(--ink-100);
  --surface-3: var(--ink-150);
  --border: var(--ink-200);
  --border-strong: var(--ink-300);
  --text: var(--ink-950);
  --text-muted: var(--ink-600);
  --text-subtle: var(--ink-500);

  /* Type */
  --font-display: 'Instrument Serif', 'Iowan Old Style', Georgia, serif;
  --font-ui: 'Geist', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', monospace;

  /* Spacing (4px base) */
  --s-1: 4px;  --s-2: 8px;   --s-3: 12px; --s-4: 16px;
  --s-5: 24px; --s-6: 32px;  --s-7: 48px; --s-8: 64px; --s-9: 96px;

  /* Radii */
  --r-xs: 4px; --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-xl: 22px;

  /* Shadows — soft, cool-tinted */
  --shadow-xs: 0 1px 0 0 oklch(20% 0.01 250 / .04);
  --shadow-sm: 0 1px 2px 0 oklch(20% 0.01 250 / .06), 0 1px 0 0 oklch(20% 0.01 250 / .03);
  --shadow-md: 0 4px 12px -2px oklch(20% 0.01 250 / .08), 0 2px 4px -1px oklch(20% 0.01 250 / .04);
  --shadow-lg: 0 18px 40px -12px oklch(20% 0.01 250 / .18), 0 6px 12px -4px oklch(20% 0.01 250 / .06);

  /* Motion */
  --ease: cubic-bezier(.2, .7, .2, 1);
  --dur-fast: 120ms;
  --dur: 200ms;
  --dur-slow: 360ms;
}

/* ============================ base ============================ */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-ui);
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "cv11";
}

a { color: var(--ink-900); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--amber-500); }

/* typography */
h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: -0.01em;
  line-height: 1.05;
  margin: 0 0 var(--s-5) 0;
}
h1 { font-size: 56px; }
h2 { font-size: 32px; margin-top: var(--s-6); }
h3 { font-size: 22px; margin-top: var(--s-5); }
h1 em, h2 em, h3 em { font-style: italic; color: var(--ink-700); }

p { margin: 0 0 var(--s-4) 0; }

.display   { font-family: var(--font-display); font-weight: 400; letter-spacing: -0.01em; line-height: 1; }
.display-xl { font-size: 88px; }
.display-l  { font-size: 56px; }
.display-m  { font-size: 40px; }
.display-s  { font-size: 28px; }

.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-subtle);
}
.label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--text-muted); }
.subtle { color: var(--text-subtle); }

/* ============================ layout shell ============================ */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* shared brand block (used by rail head and unauth header) */
.brand { display: flex; align-items: center; gap: var(--s-3); text-decoration: none; color: inherit; min-width: 0; }
.brand-mark {
  width: 36px; height: 36px;
  border: 1px solid var(--ink-800);
  border-radius: 8px;
  display: grid; place-items: center;
  background: var(--ink-950);
  color: var(--ink-50);
  flex-shrink: 0;
}
.brand-mark svg { width: 22px; height: 22px; }
.brand-name {
  font-family: var(--font-display);
  font-size: 24px;
  letter-spacing: -0.01em;
  line-height: 1;
  white-space: nowrap;
}
.brand-name em { font-style: italic; color: var(--ink-700); }

/* unauthenticated top header (kept for /account/* etc.) */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-4) var(--s-6);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.app-header-nav { display: flex; align-items: center; gap: var(--s-3); }
.app-header-nav a { color: var(--text-muted); text-decoration: none; font-size: 14px; }
.app-header-nav a:hover { color: var(--text); }

/* main column — same constraints regardless of layout variant */
.app-main {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: var(--s-7) var(--s-6);
}
.app-main.app-main-wide { max-width: 1440px; }

/* ============================ left rail (authenticated) ============================ */
:root {
  --rail-w-collapsed: 64px;
  --rail-w-expanded: 240px;
}

.app-shell-rail {
  flex-direction: row;
  align-items: stretch;
}
.app-shell-rail .app-main {
  /* rail is fixed-positioned, so the main column needs left padding to clear it */
  padding-left: calc(var(--rail-w-collapsed) + var(--s-6));
  transition: padding-left var(--dur) var(--ease);
}
.rail-pinned .app-shell-rail .app-main {
  padding-left: calc(var(--rail-w-expanded) + var(--s-6));
}

.app-rail {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--rail-w-collapsed);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: var(--s-4) 0;
  overflow: hidden;
  z-index: 30;
  transition: width var(--dur) var(--ease);
}
/* expand on hover (desktop) or when pinned (touch / explicit toggle) */
.app-rail:hover,
.rail-pinned .app-rail {
  width: var(--rail-w-expanded);
  box-shadow: var(--shadow-md);
}

.rail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  padding: 0 14px var(--s-4);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--s-3);
  height: 56px;
  flex-shrink: 0;
}
.rail-head .brand { gap: var(--s-2); }
.rail-head .brand-name {
  font-size: 18px;
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
}
.app-rail:hover .rail-head .brand-name,
.rail-pinned .rail-head .brand-name { opacity: 1; }

.rail-pin {
  background: transparent;
  border: 0;
  color: var(--text-subtle);
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: 6px;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--dur) var(--ease), background-color var(--dur-fast);
  flex-shrink: 0;
}
.rail-pin:hover { background: var(--surface-2); color: var(--text); }
.app-rail:hover .rail-pin,
.rail-pinned .rail-pin { opacity: 1; }
.rail-pinned .rail-pin { color: var(--amber-500); }

.rail-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 12px;
}

.rail-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.rail-group-label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--text-subtle);
  padding: var(--s-2) 12px 4px;
  height: 24px;
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
  white-space: nowrap;
  overflow: hidden;
}
.app-rail:hover .rail-group-label,
.rail-pinned .rail-group-label { opacity: 1; }

.rail-link,
.rail-link-button {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px;
  border-radius: 8px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: background-color var(--dur-fast), color var(--dur-fast), padding var(--dur) var(--ease);
  background: transparent;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  width: 100%;
  text-align: left;
}
.app-rail:hover .rail-link,
.app-rail:hover .rail-link-button,
.rail-pinned .rail-link,
.rail-pinned .rail-link-button { padding: 4px 8px; }
.rail-link:hover,
.rail-link-button:hover { background: var(--surface-2); color: var(--text); }
.rail-link.active {
  background: var(--ink-950);
  color: var(--ink-50);
}
.rail-link.active:hover { background: var(--ink-800); color: var(--ink-50); }

.rail-ico {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.rail-ico svg { width: 18px; height: 18px; }

.rail-label {
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.app-rail:hover .rail-label,
.rail-pinned .rail-label { opacity: 1; }

.rail-foot {
  flex-shrink: 0;
  padding: var(--s-3) 12px 0;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.rail-account {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 13px;
}
.rail-avatar {
  background: var(--ink-150);
  border-radius: 50%;
  width: 28px; height: 28px;
  font-family: var(--font-display);
  font-size: 14px;
  color: var(--text);
}
.rail-account-name {
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12.5px;
}
.rail-signout { display: contents; }

/* mobile: rail collapses to a top bar with hamburger-via-pin */
@media (max-width: 768px) {
  .app-shell-rail { flex-direction: column; }
  .app-rail {
    position: sticky;
    top: 0;
    width: 100%;
    height: 56px;
    flex-direction: row;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    padding: 0 var(--s-4);
    align-items: center;
  }
  .app-rail:hover { width: 100%; box-shadow: none; }
  .rail-pinned .app-rail {
    width: 100%;
    height: auto;
    flex-direction: column;
    align-items: stretch;
    padding: var(--s-3) var(--s-4) var(--s-4);
    box-shadow: var(--shadow-md);
  }
  .rail-head { border-bottom: 0; margin-bottom: 0; padding: 0; height: auto; flex: 1; }
  .rail-head .brand-name,
  .rail-pin,
  .rail-group-label,
  .rail-label { opacity: 1; }
  .rail-pin { width: 36px; height: 36px; }
  .rail-nav,
  .rail-foot {
    display: none;
  }
  .rail-pinned .rail-nav,
  .rail-pinned .rail-foot { display: flex; }
  .rail-pinned .rail-nav { padding: var(--s-3) 0 0; }
  .app-shell-rail .app-main { padding-left: var(--s-5); padding-right: var(--s-5); }
  .rail-pinned .app-shell-rail .app-main { padding-left: var(--s-5); }
}

/* ============================ buttons ============================ */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  font-family: var(--font-ui); font-size: 14px; font-weight: 500;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
  letter-spacing: -0.005em;
  text-decoration: none;
  line-height: 1;
}
.btn:disabled, .btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn-primary {
  background: var(--ink-950); color: var(--ink-50);
  border-color: var(--ink-950);
  box-shadow: inset 0 1px 0 oklch(100% 0 0 / .1), var(--shadow-sm);
}
.btn-primary:hover:not(:disabled) { background: var(--ink-800); color: var(--ink-50); }
.btn-secondary {
  background: var(--surface); color: var(--text);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); }
.btn-ghost {
  background: transparent; color: var(--text);
}
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn-accent {
  background: var(--amber-500); color: oklch(20% 0.04 60);
  border-color: oklch(62% 0.15 65);
}
.btn-accent:hover:not(:disabled) { filter: brightness(1.03); }
.btn-link {
  background: transparent; color: var(--ink-900);
  padding: 0; border: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
  box-shadow: none;
}
.btn-link:hover:not(:disabled) { color: var(--amber-500); }
.btn-danger {
  background: var(--crimson-600); color: white;
  border-color: var(--crimson-600);
  box-shadow: var(--shadow-sm);
}

.btn-group { display: inline-flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }

/* ============================ pills ============================ */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  font-family: var(--font-mono); font-size: 11px; font-weight: 500;
  letter-spacing: .04em;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  line-height: 1.4;
}
.pill-amber   { background: var(--amber-100);   color: oklch(40% 0.1 65);  border-color: oklch(80% 0.08 65 / .6); }
.pill-teal    { background: var(--teal-100);    color: oklch(35% 0.08 195); border-color: oklch(75% 0.06 195 / .6); }
.pill-moss    { background: var(--moss-100);    color: oklch(35% 0.08 145); border-color: oklch(75% 0.06 145 / .6); }
.pill-crimson { background: var(--crimson-100); color: oklch(38% 0.12 25); border-color: oklch(75% 0.1 25 / .6); }

.kbd {
  display: inline-grid; place-items: center;
  min-width: 22px; height: 22px;
  padding: 0 6px;
  font-family: var(--font-mono); font-size: 11px; font-weight: 600;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface);
  color: var(--text-muted);
}

/* ============================ card / frame ============================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-5);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--s-3);
}

.frame {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  padding: var(--s-6);
}
.frame-cap {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--s-5);
}

/* ============================ forms ============================ */
.form-stack { display: flex; flex-direction: column; gap: var(--s-4); }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.form-field small { font-size: 12.5px; color: var(--text-subtle); }
.form-field input[type="text"],
.form-field input[type="email"],
.form-field input[type="password"],
.form-field input[type="search"],
.form-input {
  appearance: none;
  font-family: var(--font-ui);
  font-size: 14px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--text);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.form-field input[type="text"]:focus,
.form-field input[type="email"]:focus,
.form-field input[type="password"]:focus,
.form-field input[type="search"]:focus,
.form-input:focus {
  outline: none;
  border-color: var(--ink-900);
  box-shadow: 0 0 0 3px oklch(80% 0.01 250 / .35);
}
.form-input.mono { font-family: var(--font-mono); letter-spacing: .02em; }

.form-check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text-muted); }

/* auth card — centered narrow form */
.auth-shell {
  display: flex;
  justify-content: center;
  padding: var(--s-8) var(--s-4);
  min-height: calc(100vh - 72px);
  background: var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-7);
  box-shadow: var(--shadow-md);
}
.auth-card h1 { font-size: 36px; margin-bottom: var(--s-2); }
.auth-card .lede { color: var(--text-muted); margin-bottom: var(--s-6); }
.auth-card .form-stack { margin-bottom: var(--s-4); }
.auth-card .btn { width: 100%; justify-content: center; padding: 12px 16px; }
.auth-card .alt { margin-top: var(--s-4); text-align: center; font-size: 13.5px; color: var(--text-muted); }

/* ============================ alert / feedback ============================ */
.alert {
  border-radius: var(--r-md);
  padding: var(--s-4);
  border: 1px solid;
  font-size: 13.5px;
  line-height: 1.55;
}
.alert-danger   { background: var(--crimson-100); border-color: oklch(82% 0.1 25 / .5);  color: oklch(30% 0.12 25); }
.alert-warning  { background: var(--amber-100);   border-color: oklch(82% 0.08 70 / .5); color: oklch(32% 0.08 65); }
.alert-info     { background: var(--teal-100);    border-color: oklch(80% 0.06 195 / .5); color: oklch(28% 0.08 195); }
.alert-success  { background: var(--moss-100);    border-color: oklch(82% 0.08 145 / .5); color: oklch(28% 0.1 145); }

.feedback {
  border-radius: var(--r-md);
  padding: var(--s-4);
  border: 1px solid;
  display: flex; flex-direction: column; gap: var(--s-3);
}
.feedback.wrong {
  background: var(--crimson-100);
  border-color: oklch(82% 0.1 25 / .5);
  color: oklch(30% 0.12 25);
}
.feedback.correct {
  background: var(--moss-100);
  border-color: oklch(82% 0.08 145 / .5);
  color: oklch(28% 0.1 145);
}
.feedback-head {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-display);
  font-size: 20px; font-style: italic;
  line-height: 1;
}
.feedback-ico {
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--font-ui); font-style: normal; font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}
.wrong .feedback-ico   { background: oklch(58% 0.16 25);  color: #fff; }
.correct .feedback-ico { background: oklch(55% 0.14 145); color: #fff; }
.feedback-body { font-family: var(--font-ui); font-style: normal; font-size: 13.5px; line-height: 1.55; }
.feedback-body .mono { background: oklch(95% 0.04 25 / .6); padding: 1px 5px; border-radius: 3px; }
.correct .feedback-body .mono { background: oklch(95% 0.04 145 / .6); }

/* ============================ coach block ============================ */
.coach {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--amber-500);
  border-radius: 0 var(--r-md) var(--r-md) 0;
  padding: var(--s-4);
  display: flex; flex-direction: column; gap: var(--s-2);
}
.coach-head {
  display: flex; align-items: center; gap: var(--s-2);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: oklch(48% 0.1 65);
}
.coach-body { font-size: 14px; line-height: 1.55; white-space: pre-wrap; }

/* ============================ prompt ============================ */
.prompt {
  padding: var(--s-4);
  background: var(--amber-100);
  border: 1px solid oklch(82% 0.06 70 / .7);
  border-radius: var(--r-md);
  display: flex; gap: var(--s-3);
}
.prompt-ico {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--amber-500);
  display: grid; place-items: center;
  color: oklch(20% 0.04 60);
  flex-shrink: 0;
  font-family: var(--font-display); font-style: italic; font-size: 16px;
}
.prompt-body { font-size: 14px; line-height: 1.5; color: oklch(28% 0.06 60); }
.prompt-body strong { color: oklch(20% 0.06 60); }

/* ============================ stat block ============================ */
.stat-block {
  display: flex; flex-direction: column; gap: var(--s-2);
  padding: var(--s-4);
  background: var(--surface-2);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
}
.stat-row { display: flex; justify-content: space-between; align-items: baseline; }
.stat-val {
  font-family: var(--font-display);
  font-size: 32px;
  line-height: 1;
}
.stat-delta { font-family: var(--font-mono); font-size: 11px; color: var(--moss-600); }
.stat-delta.down { color: var(--crimson-600); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--s-4); }

/* ============================ data table ============================ */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.data-table thead th {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-subtle);
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-weight: 500;
}
.data-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: baseline;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.data-table .dim { color: var(--text-muted); }

/* ============================ board ============================ */
.board-wrap {
  display: inline-grid;
  grid-template-columns: 20px 1fr;
  grid-template-rows: 1fr 20px;
  gap: 6px;
  padding: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
}
.rank-labels, .file-labels {
  display: grid;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  color: var(--text-subtle);
  letter-spacing: .05em;
}
.rank-labels { grid-template-rows: repeat(8, 1fr); }
.file-labels { grid-template-columns: repeat(8, 1fr); grid-column: 2; }
.rank-labels span, .file-labels span { display: grid; place-items: center; }

.board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: 480px;
  height: 480px;
  border-radius: var(--r-md);
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 0 0 1px oklch(20% 0.01 250 / .08);
}
.board.board-sm { width: 320px; height: 320px; }

.sq {
  position: relative;
  display: grid;
  place-items: center;
  user-select: none;
  cursor: pointer;
  transition: box-shadow var(--dur-fast);
}
.sq.lt { background: var(--board-light); }
.sq.dk { background: var(--board-dark); }

/* coordinates in corner squares */
.sq .coord {
  position: absolute;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .03em;
  opacity: .55;
}
.sq.lt .coord { color: var(--board-dark); }
.sq.dk .coord { color: var(--board-light); }
.sq .coord.file { bottom: 3px; right: 5px; }
.sq .coord.rank { top: 3px; left: 5px; }

/* last-move highlight (translucent amber wash) */
.sq.last { box-shadow: inset 0 0 0 999px oklch(80% 0.12 75 / .45); }

/* currently selected piece (3px amber inset ring) */
.sq.sel { box-shadow: inset 0 0 0 3px var(--amber-500); }

/* solution-walk hint squares (3px moss-green inset ring) */
.sq.hint { box-shadow: inset 0 0 0 3px oklch(72% 0.18 145); }
.sq.hint.last { box-shadow: inset 0 0 0 999px oklch(80% 0.12 75 / .45), inset 0 0 0 3px oklch(72% 0.18 145); }

/* Coach-suggestion preview overlay (3px violet ring on the source piece and
   destination square; capture variant adds a translucent violet wash). The
   colour is deliberately distinct from amber (.sel/.last) and moss-green
   (.hint) so "I'm investigating" never reads as "I've selected my own
   piece" or "this was the last move played". */
.sq.preview-from { box-shadow: inset 0 0 0 3px oklch(60% 0.20 295); }
.sq.preview-to   { box-shadow: inset 0 0 0 3px oklch(60% 0.20 295); }
.sq.preview-to.capture-preview {
  box-shadow:
    inset 0 0 0 999px oklch(60% 0.20 295 / .25),
    inset 0 0 0 3px  oklch(60% 0.20 295);
}

/* Single straight arrow drawn over the board (viewBox 0 0 8 8 so it scales
   to both the 480px standard and 320px .board-sm variants). Sits above the
   pieces (z-index 3) but ignores pointer events so squares stay clickable. */
.preview-arrow {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
  color: oklch(60% 0.20 295);
  opacity: .8;
}

/* Lesson-loading skeleton primitives. The page renders a faint, pulsing
   silhouette of the final layout while Bedrock generates and Stockfish
   verifies — replaces the previous "Bedrock typically takes 5-15 s" wall
   of text with something that telegraphs the shape of what's coming. */
.skel {
  background: linear-gradient(90deg,
    var(--surface-2) 0%,
    var(--surface-3, oklch(94% 0.005 250)) 50%,
    var(--surface-2) 100%);
  background-size: 200% 100%;
  animation: skel-pulse 1.4s ease-in-out infinite;
  border-radius: 6px;
}
.skel-display { height: 56px; width: 86%; }
.skel-h3      { height: 22px; width: 38%; margin-bottom: 10px; }
.skel-line    { height: 14px; margin-bottom: 8px; }
.skel-board   { height: 220px; width: 220px; border-radius: 8px; }

@keyframes skel-pulse {
  0%   { background-position:  100% 0; }
  100% { background-position: -100% 0; }
}

/* legal move indicators */
.sq .dot {
  width: 24%; aspect-ratio: 1;
  border-radius: 999px;
  background: oklch(20% 0.01 250 / .28);
  pointer-events: none;
  position: absolute;
  z-index: 1;
}
.sq.capture .dot {
  width: 86%;
  background: transparent;
  border: 3px solid oklch(20% 0.01 250 / .28);
}
/* when there's a piece on a legal-dest square, the ring goes around it */
.sq.capture .piece { z-index: 2; }

/* Piece sprites — Cburnett set (CC-BY-SA 3.0, via Wikimedia Commons).
   Each square is an 8th of the board; the piece scales to ~85% so there's
   visual breathing room around the glyph. */
.piece {
  width: 85%;
  aspect-ratio: 1;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  filter: drop-shadow(0 1px 1px oklch(20% 0.01 250 / .22));
  pointer-events: none;
}
.piece.w.king   { background-image: url(pieces/lk.svg); }
.piece.w.queen  { background-image: url(pieces/lq.svg); }
.piece.w.rook   { background-image: url(pieces/lr.svg); }
.piece.w.bishop { background-image: url(pieces/lb.svg); }
.piece.w.knight { background-image: url(pieces/ln.svg); }
.piece.w.pawn   { background-image: url(pieces/lp.svg); }
.piece.b.king   { background-image: url(pieces/dk.svg); }
.piece.b.queen  { background-image: url(pieces/dq.svg); }
.piece.b.rook   { background-image: url(pieces/dr.svg); }
.piece.b.bishop { background-image: url(pieces/db.svg); }
.piece.b.knight { background-image: url(pieces/dn.svg); }
.piece.b.pawn   { background-image: url(pieces/dp.svg); }

/* ============================ utilities ============================ */
.hstack { display: flex; gap: var(--s-3); align-items: center; flex-wrap: wrap; }
.vstack { display: flex; flex-direction: column; gap: var(--s-3); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-6); }
.split { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s-4); flex-wrap: wrap; }
.divider { border: 0; border-top: 1px solid var(--border); margin: var(--s-6) 0; }

/* focus default */
:focus-visible { outline: 2px solid var(--amber-400); outline-offset: 2px; border-radius: 4px; }

/* ============================ blazor error UI overrides ============================ */
h1:focus { outline: none; }
.valid.modified:not([type=checkbox]) { outline: 1px solid var(--moss-600); }
.invalid { outline: 1px solid var(--crimson-600); }
.validation-message { color: var(--crimson-600); font-size: 12.5px; }
