:root {
  color-scheme: dark;
  --bg: #10120f;
  --bg-deep: #0a0c09;
  --surface: #181b17;
  --surface-2: #1f231e;
  --surface-3: #292e27;
  --border: #394037;
  --border-soft: #292f28;
  --text: #f4f0e7;
  --text-muted: #a9afa4;
  --text-dim: #747b71;
  --accent: #94b884;
  --accent-bright: #b5d5a7;
  --accent-dark: #647f5b;
  --accent-soft: rgba(148, 184, 132, 0.12);
  --ivory-square: #e4d5b5;
  --brown-square: #947255;
  --selected: #e0be66;
  --correct: #8caf79;
  --wrong: #c7796e;
  --last-move: rgba(231, 202, 95, 0.47);
  --hint: rgba(128, 177, 116, 0.68);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.3);
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;
  --header-height: 68px;
  --content-max: 1440px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.16, 1, 0.3, 1);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f2ec;
  --bg-deep: #e9e5dc;
  --surface: #fffefa;
  --surface-2: #efebe2;
  --surface-3: #e3ded3;
  --border: #c8c0b1;
  --border-soft: #d9d2c5;
  --text: #242923;
  --text-muted: #62695f;
  --text-dim: #848a80;
  --accent: #6f9164;
  --accent-bright: #4f7048;
  --accent-dark: #57764f;
  --accent-soft: rgba(89, 116, 80, 0.11);
  --shadow: 0 20px 55px rgba(73, 63, 47, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 12% -12%, rgba(148, 184, 132, 0.1), transparent 34rem),
    radial-gradient(circle at 100% 12%, rgba(184, 151, 102, 0.045), transparent 28rem),
    var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
}

html[data-theme="light"] body {
  background:
    radial-gradient(circle at 12% -10%, rgba(89, 116, 80, 0.11), transparent 34rem),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

button,
a,
select {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  color: inherit;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid rgba(172, 193, 159, 0.72);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 10px;
  left: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--text);
  color: var(--bg-deep);
  transform: translateY(-150%);
  transition: transform 180ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.sr-only {
  position: absolute;
  overflow: hidden;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  margin: -1px;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.site-header {
  position: sticky;
  z-index: 100;
  top: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: var(--header-height);
  padding: 0 clamp(20px, 4vw, 64px);
  border-bottom: 1px solid rgba(74, 75, 68, 0.65);
  background: rgba(23, 24, 21, 0.94);
  backdrop-filter: blur(18px);
}

.header-actions {
  display: flex;
  justify-self: end;
  align-items: center;
  gap: 10px;
}

.brand {
  display: inline-flex;
  width: max-content;
  align-items: center;
  gap: 10px;
  font-family: "Newsreader", Georgia, serif;
  font-size: 23px;
  font-weight: 600;
  letter-spacing: -0.025em;
}

.brand > span:last-child > span {
  color: var(--accent-bright);
}

.brand-mark {
  display: grid;
  width: 37px;
  height: 37px;
  place-items: center;
  border: 1px solid #78886c;
  border-radius: 11px;
  background: var(--accent-soft);
  color: var(--accent-bright);
  font-family: Georgia, serif;
  font-size: 25px;
  line-height: 1;
}

.brand-mark svg {
  width: 27px;
  height: 27px;
  fill: currentColor;
  stroke: #3f4939;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  background: rgba(31, 32, 28, 0.76);
}

.main-nav a {
  padding: 8px 16px;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  transition: color 160ms ease, background 160ms ease;
}

.main-nav a:hover {
  color: var(--text);
}

.main-nav a.active {
  background: var(--surface-3);
  color: var(--text);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset;
}

.header-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.theme-toggle {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  gap: 7px;
  padding: 0 11px;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.theme-toggle:hover {
  border-color: var(--border);
  color: var(--text);
}

#theme-icon {
  font-size: 15px;
  line-height: 1;
}

.mini-progress {
  overflow: hidden;
  width: 72px;
  height: 5px;
  border-radius: 999px;
  background: var(--surface-3);
}

.mini-progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 300ms ease;
}

.page-shell {
  width: min(calc(100% - clamp(32px, 7vw, 112px)), var(--content-max));
  margin: 0 auto;
  padding: clamp(42px, 6vw, 76px) 0 80px;
}

.page-enter {
  animation: page-enter 220ms ease both;
}

@keyframes page-enter {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 13px;
  color: var(--accent-bright);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.eyebrow::before {
  width: 17px;
  height: 1px;
  background: var(--accent);
  content: "";
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2 {
  font-family: "Newsreader", Georgia, serif;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  margin-bottom: 42px;
}

.page-heading h1 {
  max-width: 760px;
  margin-bottom: 10px;
  font-size: clamp(42px, 5vw, 68px);
  font-weight: 500;
  line-height: 0.98;
  letter-spacing: -0.045em;
}

.page-heading p:not(.eyebrow) {
  max-width: 640px;
  margin-bottom: 0;
  color: var(--text-muted);
  font-size: 16px;
}

.trust-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 16px;
}

.trust-row span {
  padding: 5px 9px;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
}

.library-summary {
  display: flex;
  min-width: 250px;
  align-items: center;
  gap: 18px;
  padding: 16px 18px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: rgba(32, 33, 30, 0.55);
}

.summary-ring {
  --progress: 0deg;
  position: relative;
  display: grid;
  flex: 0 0 auto;
  width: 56px;
  height: 56px;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--accent) var(--progress), var(--surface-3) 0);
}

.summary-ring::before {
  position: absolute;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--surface);
  content: "";
}

.summary-ring strong {
  position: relative;
  z-index: 1;
  font-size: 12px;
}

.library-summary strong {
  display: block;
  margin-bottom: 2px;
  font-size: 14px;
}

.library-summary span {
  color: var(--text-muted);
  font-size: 12px;
}

.study-strip {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 17px;
  margin: -16px 0 24px;
  padding: 16px 18px;
  border: 1px solid rgba(140, 164, 124, 0.28);
  border-radius: 15px;
  background: var(--accent-soft);
}

.study-strip-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 11px;
  background: var(--accent);
  color: #172014;
  font-size: 21px;
}

.study-strip strong,
.study-strip span,
.study-strip small {
  display: block;
}

.study-strip span {
  color: var(--accent-bright);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.study-strip strong {
  margin: 2px 0;
  font-family: "Newsreader", Georgia, serif;
  font-size: 20px;
  font-weight: 600;
}

.study-strip small {
  color: var(--text-muted);
  font-size: 11px;
}

.study-strip-actions {
  display: flex;
  gap: 8px;
}

.library-tools {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 26px;
}

.search-wrap {
  position: relative;
  flex: 1 1 340px;
  max-width: 430px;
}

.search-wrap svg {
  position: absolute;
  top: 50%;
  left: 15px;
  width: 18px;
  color: var(--text-dim);
  transform: translateY(-50%);
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 46px;
  padding: 0 15px 0 44px;
  border: 1px solid var(--border);
  border-radius: 11px;
  outline: none;
  background: var(--surface);
  color: var(--text);
  transition: border 160ms ease, box-shadow 160ms ease;
}

.search-input::placeholder {
  color: var(--text-dim);
}

.search-input:focus {
  border-color: var(--accent-dark);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-chip {
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all 160ms ease;
}

.filter-chip:hover {
  border-color: var(--border);
  color: var(--text);
}

.filter-chip.active {
  border-color: rgba(140, 164, 124, 0.42);
  background: var(--accent-soft);
  color: var(--accent-bright);
}

.result-count {
  margin-left: auto;
  color: var(--text-dim);
  font-size: 12px;
  white-space: nowrap;
}

.opening-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.opening-card {
  position: relative;
  display: grid;
  overflow: hidden;
  min-height: 255px;
  grid-template-columns: minmax(0, 1fr) 138px;
  gap: 22px;
  padding: 26px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  background: linear-gradient(140deg, rgba(39, 40, 36, 0.94), rgba(30, 31, 28, 0.94));
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.025) inset;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.opening-card:hover {
  border-color: rgba(140, 164, 124, 0.48);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.15);
  transform: translateY(-2px);
}

.card-topline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}

.side-badge,
.difficulty-badge,
.mastery-badge,
.favorite-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.side-dot {
  width: 8px;
  height: 8px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 50%;
}

.side-dot.white { background: #eee9d9; }
.side-dot.black { background: #4c4d48; }

.mastery-badge {
  border-color: rgba(140, 164, 124, 0.35);
  background: var(--accent-soft);
  color: var(--accent-bright);
}

.favorite-badge {
  border-color: rgba(224, 190, 102, 0.3);
  color: var(--selected);
}

.opening-card h2 {
  margin-bottom: 7px;
  font-size: 29px;
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: -0.025em;
}

.opening-sequence {
  margin-bottom: 20px;
  color: var(--accent-bright);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
  font-size: 13px;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 23px;
}

.tag {
  padding: 4px 8px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
}

.card-progress {
  display: flex;
  align-items: center;
  gap: 11px;
}

.progress-track {
  overflow: hidden;
  flex: 1;
  height: 5px;
  border-radius: 999px;
  background: #3a3b36;
}

.progress-track > span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 300ms ease;
}

.card-progress > span {
  min-width: 27px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  text-align: right;
}

.card-visual {
  position: relative;
  display: grid;
  align-content: center;
  justify-items: center;
  min-height: 180px;
  border: 1px solid rgba(255, 255, 255, 0.045);
  border-radius: 16px;
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.025) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, 0.025) 75%),
    linear-gradient(45deg, rgba(255, 255, 255, 0.025) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, 0.025) 75%),
    #1d1e1b;
  background-position: 0 0, 12px 12px;
  background-size: 24px 24px;
}

.opening-card.side-black .card-visual {
  border-color: rgba(71, 59, 43, 0.19);
  background:
    linear-gradient(45deg, rgba(91, 72, 49, 0.11) 25%, transparent 25%, transparent 75%, rgba(91, 72, 49, 0.11) 75%),
    linear-gradient(45deg, rgba(91, 72, 49, 0.11) 25%, transparent 25%, transparent 75%, rgba(91, 72, 49, 0.11) 75%),
    #d9c7a8;
  background-position: 0 0, 12px 12px;
  background-size: 24px 24px;
}

.card-piece {
  color: #d9ceb8;
  font-family: Georgia, serif;
  font-size: 74px;
  line-height: 1;
  text-shadow: 0 12px 24px rgba(0, 0, 0, 0.35);
  transform: translateY(-4px);
}

.card-number {
  position: absolute;
  right: 11px;
  bottom: 8px;
  color: rgba(241, 237, 223, 0.2);
  font-family: "Newsreader", Georgia, serif;
  font-size: 38px;
}

.opening-card.side-black .card-number {
  color: rgba(43, 39, 31, 0.25);
}

.empty-state {
  grid-column: 1 / -1;
  padding: 70px 24px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  color: var(--text-muted);
  text-align: center;
}

.empty-state span {
  display: block;
  margin-bottom: 12px;
  color: var(--text-dim);
  font-family: Georgia, serif;
  font-size: 54px;
}

.button,
.icon-button,
.playback-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  cursor: pointer;
}

.button {
  min-height: 44px;
  gap: 8px;
  padding: 0 17px;
  border-radius: 10px;
  background: var(--accent);
  color: #172014;
  font-size: 13px;
  font-weight: 700;
  transition: transform 160ms ease, background 160ms ease;
}

.button:hover {
  background: var(--accent-bright);
  transform: translateY(-1px);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
  transform: none;
}

.button-ghost {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
}

.button-ghost:hover {
  background: var(--surface-3);
}

.button-danger {
  background: var(--wrong);
  color: #21110f;
}

.icon-button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text-muted);
}

.icon-button:hover {
  color: var(--text);
}

/* Lesson */
.lesson-shell {
  width: min(calc(100% - clamp(26px, 5vw, 76px)), 1520px);
  margin: 0 auto;
  padding: 28px 0 70px;
}

.lesson-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 23px;
  color: var(--text-dim);
  font-size: 12px;
}

.lesson-breadcrumbs a:hover {
  color: var(--text);
}

.lesson-breadcrumbs span:last-child {
  color: var(--text-muted);
}

.lesson-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 25px;
}

.lesson-title-wrap {
  display: flex;
  align-items: center;
  gap: 16px;
}

.opening-glyph {
  display: grid;
  overflow: hidden;
  flex: 0 0 auto;
  width: 54px;
  height: 54px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: var(--surface-2);
  color: var(--accent-bright);
}

.opening-glyph .vector-piece-icon {
  width: 34px;
  height: 34px;
  filter: drop-shadow(0 2px 1px rgba(32, 39, 29, 0.18));
}

.lesson-header h1 {
  margin-bottom: 1px;
  font-size: clamp(31px, 3vw, 44px);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.035em;
}

.lesson-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  color: var(--text-muted);
  font-size: 12px;
}

.lesson-meta i {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--text-dim);
}

.lesson-status {
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--text-muted);
  font-size: 12px;
}

.lesson-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.favorite-button {
  display: inline-flex;
  min-height: 39px;
  align-items: center;
  gap: 7px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
}

.favorite-button:hover,
.favorite-button.active {
  border-color: rgba(224, 190, 102, 0.42);
  background: rgba(224, 190, 102, 0.09);
  color: var(--selected);
}

.lesson-layout {
  display: grid;
  grid-template-columns: minmax(400px, 0.93fr) minmax(430px, 1.07fr);
  gap: clamp(24px, 3.5vw, 56px);
  align-items: start;
}

.board-column {
  position: sticky;
  top: calc(var(--header-height) + 22px);
  min-width: 0;
}

.board-frame {
  position: relative;
  width: min(100%, 680px);
  margin-inline: auto;
  padding: 14px;
  border: 1px solid #4b493f;
  border-radius: 18px;
  background: #262720;
  box-shadow: var(--shadow), 0 1px 0 rgba(255, 255, 255, 0.06) inset;
}

.chessboard {
  display: grid;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 1;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  border-radius: 7px;
  background: var(--ivory-square);
  box-shadow: 0 0 0 1px rgba(15, 15, 12, 0.45);
}

.square {
  position: relative;
  display: grid;
  min-width: 0;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 0;
  background: var(--ivory-square);
  cursor: pointer;
  user-select: none;
}

.square.dark {
  background: var(--brown-square);
}

.square::after {
  position: absolute;
  z-index: 1;
  inset: 0;
  background: transparent;
  content: "";
  pointer-events: none;
}

.square.last-move::after {
  background: var(--last-move);
}

.square.selected::after {
  box-shadow: inset 0 0 0 clamp(3px, 0.55vw, 6px) rgba(239, 199, 83, 0.9);
}

.square.expected::after {
  background: var(--hint);
  box-shadow: inset 0 0 0 clamp(2px, 0.4vw, 4px) rgba(225, 241, 214, 0.5);
}

.square.legal::before {
  position: absolute;
  z-index: 3;
  width: 25%;
  height: 25%;
  border-radius: 50%;
  background: rgba(42, 53, 36, 0.55);
  content: "";
  pointer-events: none;
}

.square.legal.has-piece::before {
  width: 82%;
  height: 82%;
  border: clamp(3px, 0.5vw, 6px) solid rgba(42, 53, 36, 0.55);
  background: transparent;
}

.square.key-square::after {
  background: rgba(116, 153, 105, 0.52);
  box-shadow: inset 0 0 0 3px rgba(222, 238, 212, 0.28);
}

.piece {
  position: relative;
  z-index: 2;
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  transform: translateY(-1%);
  transition: transform 180ms ease;
}

.piece.white-piece {
  --piece-stroke: #4c4b42;
  color: #f7f1df;
  filter: drop-shadow(0 2px 1.5px rgba(39, 37, 31, 0.2));
}

.piece.black-piece {
  --piece-stroke: #171a16;
  color: #2a2e28;
  filter: drop-shadow(0 2px 1.5px rgba(27, 29, 24, 0.22));
}

.piece-svg {
  display: block;
  width: 68%;
  height: 70%;
  overflow: visible;
}

/* Optical sizing keeps the silhouettes distinct and the coordinates clear. */
.piece-svg-k { width: 68%; height: 72%; }
.piece-svg-q { width: 66%; height: 68%; }
.piece-svg-r { width: 66%; height: 68%; }
.piece-svg-b { width: 64%; height: 68%; }
.piece-svg-n { width: 68%; height: 70%; }
.piece-svg-p { width: 58%; height: 62%; }

.piece-shape path {
  fill: currentColor;
  stroke: var(--piece-stroke);
  stroke-width: 1.15;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.vector-piece-icon {
  --piece-stroke: #45473f;
  display: inline-grid;
  width: 1em;
  height: 1em;
  place-items: center;
  color: currentColor;
  filter: drop-shadow(0 3px 2px rgba(0, 0, 0, 0.18));
  line-height: 1;
}

.vector-piece-icon.light {
  --piece-stroke: #4c4b42;
  color: inherit;
}

.card-piece .vector-piece-icon.light {
  color: #f4eddb;
}

.vector-piece-icon.dark {
  --piece-stroke: #121511;
  color: #2a2f29;
  filter: drop-shadow(0 4px 3px rgba(62, 48, 33, 0.22));
}

.vector-piece-icon .piece-svg {
  width: 100%;
  height: 100%;
}

.square.moved .piece {
  animation: piece-arrive 190ms ease both;
}

@keyframes piece-arrive {
  0% { opacity: 0.55; transform: scale(0.76); }
  100% { opacity: 1; transform: scale(1); }
}

.coord {
  position: absolute;
  z-index: 4;
  color: rgba(53, 48, 40, 0.72);
  font-size: clamp(8px, 0.75vw, 11px);
  font-weight: 800;
  line-height: 1;
  pointer-events: none;
}

.square.dark .coord {
  color: rgba(246, 235, 211, 0.7);
}

.coord.rank { top: 4px; left: 5px; }
.coord.file { right: 5px; bottom: 4px; }

.board-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: min(100%, 680px);
  margin: 14px auto 0;
}

.turn-indicator {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text-muted);
  font-size: 12px;
}

.turn-dot {
  width: 10px;
  height: 10px;
  border: 2px solid #55564f;
  border-radius: 50%;
  background: #eee9d9;
}

.turn-dot.black { background: #55564f; }

.board-actions {
  display: flex;
  gap: 8px;
}

.lesson-panel {
  overflow: hidden;
  min-height: 640px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  background: rgba(32, 33, 30, 0.78);
  box-shadow: 0 15px 45px rgba(0, 0, 0, 0.13);
}

.lesson-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 7px;
  border-bottom: 1px solid var(--border-soft);
}

.lesson-tab {
  position: relative;
  height: 44px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.lesson-tab:hover { color: var(--text); }

.lesson-tab.active {
  background: var(--surface-3);
  color: var(--text);
}

.panel-content {
  padding: clamp(23px, 3vw, 38px);
}

.panel-content h2 {
  margin-bottom: 13px;
  font-size: 31px;
  font-weight: 500;
  line-height: 1.08;
  letter-spacing: -0.025em;
}

.panel-lead {
  margin-bottom: 28px;
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.75;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}

.info-card {
  padding: 16px;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.018);
}

.info-card span {
  display: block;
  margin-bottom: 6px;
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.info-card strong {
  font-size: 13px;
  font-weight: 600;
}

.section-label {
  margin-bottom: 13px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.objective-list,
.plan-list,
.mistake-list {
  display: grid;
  gap: 10px;
  margin: 0 0 28px;
  padding: 0;
  list-style: none;
}

.objective-list li,
.plan-list li,
.mistake-list li {
  position: relative;
  padding-left: 25px;
  color: #d0cdc2;
  font-size: 13px;
  line-height: 1.55;
}

.objective-list li::before {
  position: absolute;
  top: 0.46em;
  left: 2px;
  width: 8px;
  height: 8px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  content: "";
}

.memory-tip {
  position: relative;
  padding: 19px 20px 19px 52px;
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--accent-soft);
  color: var(--text);
  font-family: "Newsreader", Georgia, serif;
  font-size: 18px;
  line-height: 1.45;
}

.memory-tip::before {
  position: absolute;
  top: 15px;
  left: 18px;
  color: var(--accent-bright);
  font-family: Georgia, serif;
  font-size: 24px;
  content: "✦";
}

.line-selector {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 21px;
}

.line-selector label {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.line-select {
  max-width: 280px;
  height: 40px;
  padding: 0 34px 0 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
}

.move-explanation {
  min-height: 158px;
  margin-bottom: 19px;
  padding: 23px;
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  background: #1b1c19;
}

.move-counter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 11px;
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.move-san {
  margin-bottom: 8px;
  color: var(--accent-bright);
  font-family: "Newsreader", Georgia, serif;
  font-size: 29px;
  font-weight: 600;
}

.move-explanation p {
  margin-bottom: 0;
  color: #c7c4b9;
  line-height: 1.7;
}

.move-purpose-label {
  display: inline-flex;
  margin: 1px 0 7px;
  color: var(--accent-bright);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.playback-controls {
  display: grid;
  grid-template-columns: 40px 40px 1fr 40px 40px;
  gap: 7px;
  margin-bottom: 23px;
}

.playback-button {
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 15px;
}

.playback-button:hover:not(:disabled) {
  border-color: #53544d;
  color: var(--text);
}

.playback-button.primary {
  gap: 7px;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.playback-button:disabled {
  cursor: default;
  opacity: 0.35;
}

.notation-wrap {
  overflow: hidden;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
}

.notation-title {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.notation-list {
  display: grid;
  max-height: 220px;
  grid-template-columns: 35px 1fr 1fr;
  overflow-y: auto;
}

.notation-number,
.notation-move {
  min-height: 38px;
  padding: 9px 10px;
  border-bottom: 1px solid rgba(62, 63, 57, 0.5);
  font-size: 12px;
}

.notation-number {
  color: var(--text-dim);
  text-align: center;
}

.notation-move {
  border: 0;
  border-bottom: 1px solid rgba(62, 63, 57, 0.5);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  text-align: left;
}

.notation-move:hover { background: rgba(255, 255, 255, 0.03); color: var(--text); }
.notation-move.active { background: var(--accent-soft); color: var(--accent-bright); }
.notation-move.future { color: #65665f; }
.notation-move:disabled { cursor: default; }

.ideas-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  margin-bottom: 30px;
}

.plan-block h3 {
  margin-bottom: 11px;
  font-size: 13px;
}

.plan-list li {
  padding-left: 18px;
}

.plan-list li::before {
  position: absolute;
  top: 0.52em;
  left: 1px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent-dark);
  content: "";
}

.key-squares {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 29px;
}

.key-square-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 11px;
}

.key-square-button:hover,
.key-square-button.active {
  border-color: rgba(140, 164, 124, 0.5);
  background: var(--accent-soft);
  color: var(--text);
}

.square-code {
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border-radius: 5px;
  background: var(--accent-dark);
  color: #f3efdf;
  font-family: ui-monospace, monospace;
  font-weight: 700;
}

.structure-card {
  margin-bottom: 28px;
  padding: 17px;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.018);
}

.structure-card strong {
  display: block;
  margin-bottom: 5px;
  font-size: 12px;
}

.structure-card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.6;
}

.mistake-list li::before {
  position: absolute;
  left: 2px;
  color: var(--wrong);
  font-weight: 800;
  content: "×";
}

.practice-preview {
  text-align: center;
}

.practice-preview-icon {
  display: grid;
  width: 74px;
  height: 74px;
  margin: 10px auto 20px;
  place-items: center;
  border: 1px solid rgba(140, 164, 124, 0.36);
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-bright);
  font-family: Georgia, serif;
  font-size: 39px;
}

.practice-preview .panel-lead {
  max-width: 450px;
  margin-inline: auto;
}

.practice-steps {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 25px 0;
}

.practice-steps span {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 700;
}

.practice-steps span.done,
.practice-steps span.current {
  border-color: var(--accent-dark);
  background: var(--accent-soft);
  color: var(--accent-bright);
}

.toast {
  position: fixed;
  z-index: 300;
  right: 24px;
  bottom: 24px;
  max-width: min(390px, calc(100vw - 32px));
  padding: 13px 17px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: #2a2b27;
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.dialog {
  width: min(440px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.dialog::backdrop {
  background: rgba(7, 8, 6, 0.72);
  backdrop-filter: blur(4px);
}

.dialog form {
  padding: 30px;
}

.dialog-icon {
  display: grid;
  width: 47px;
  height: 47px;
  margin-bottom: 18px;
  place-items: center;
  border-radius: 13px;
  background: rgba(199, 121, 110, 0.13);
  color: var(--wrong);
  font-size: 25px;
}

.dialog h2 {
  margin-bottom: 8px;
  font-size: 27px;
}

.dialog p {
  color: var(--text-muted);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 25px;
}

/* Practice */
.practice-coach-panel {
  overflow: hidden;
  min-height: 640px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  background: rgba(32, 33, 30, 0.78);
  box-shadow: 0 15px 45px rgba(0, 0, 0, 0.13);
}

.practice-coach-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 17px 22px;
  border-bottom: 1px solid var(--border-soft);
}

.practice-select-group {
  display: grid;
  min-width: 0;
  gap: 6px;
}

.practice-select-group:first-child {
  flex: 1 1 58%;
}

.practice-select-group:last-child {
  flex: 1 1 42%;
}

.practice-select-group .line-select {
  width: 100%;
  max-width: none;
}

.practice-coach-top label {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.practice-progress-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 15px 23px 0;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 700;
}

.practice-timer {
  flex: 0 0 auto;
  min-width: 48px;
  padding: 4px 8px;
  border: 1px solid rgba(140, 164, 124, 0.32);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-bright);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  text-align: center;
}

.practice-timer.hidden {
  display: none;
}

.practice-timer.urgent {
  border-color: rgba(199, 121, 110, 0.42);
  background: rgba(199, 121, 110, 0.1);
  color: var(--wrong);
}

.practice-progress-row .progress-track {
  height: 4px;
}

#practice-coach-content {
  padding: 23px;
}

.coach-card {
  min-height: 420px;
  padding: clamp(24px, 3vw, 40px);
  border: 1px solid var(--border-soft);
  border-radius: 17px;
  background: #1b1c19;
  text-align: center;
}

.coach-step {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 36px;
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.coach-state-icon {
  display: grid;
  width: 66px;
  height: 66px;
  margin: 0 auto 20px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-muted);
  font-family: Georgia, serif;
  font-size: 34px;
}

.coach-state-icon.correct {
  border-color: rgba(140, 175, 121, 0.45);
  background: rgba(140, 175, 121, 0.12);
  color: var(--correct);
  font-family: inherit;
  font-size: 28px;
}

.coach-state-icon.wrong {
  border-color: rgba(199, 121, 110, 0.4);
  background: rgba(199, 121, 110, 0.1);
  color: var(--wrong);
  font-family: inherit;
  font-size: 31px;
}

.coach-state-icon.hint {
  border-color: rgba(224, 190, 102, 0.4);
  background: rgba(224, 190, 102, 0.09);
  color: var(--selected);
  font-family: inherit;
  font-size: 24px;
}

.coach-state-icon.thinking {
  animation: thinking-pulse 1.1s ease-in-out infinite alternate;
  font-family: inherit;
  letter-spacing: 4px;
}

@keyframes thinking-pulse {
  from { opacity: 0.45; }
  to { opacity: 1; }
}

.coach-card h2 {
  margin-bottom: 10px;
  font-size: clamp(27px, 3vw, 36px);
  font-weight: 500;
  line-height: 1.08;
  letter-spacing: -0.025em;
}

.coach-card > p:not(.eyebrow) {
  max-width: 460px;
  margin: 0 auto;
  color: var(--text-muted);
  line-height: 1.7;
}

.coach-tip {
  display: grid;
  max-width: 470px;
  grid-template-columns: auto 1fr;
  gap: 10px 16px;
  margin: 27px auto 0;
  padding: 15px 17px;
  border: 1px solid var(--border-soft);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.02);
  text-align: left;
}

.coach-tip strong {
  color: var(--accent-bright);
  font-size: 11px;
  white-space: nowrap;
}

.coach-tip span {
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.55;
}

.coach-tip.correct-tip {
  border-color: rgba(140, 175, 121, 0.2);
  background: rgba(140, 175, 121, 0.06);
}

.completion-actions {
  display: flex;
  justify-content: center;
  gap: 9px;
  margin-top: 28px;
}

.practice-footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 0 23px 23px;
}

.board-frame.shake {
  animation: board-shake 300ms ease;
}

@keyframes board-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  50% { transform: translateX(5px); }
  75% { transform: translateX(-3px); }
}

/* Quiz */
.quiz-score-live {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  border: 1px solid var(--border-soft);
  border-radius: 11px;
  background: var(--surface);
}

.quiz-score-live span {
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.quiz-score-live strong {
  color: var(--accent-bright);
  font-size: 15px;
}

.quiz-layout {
  display: grid;
  grid-template-columns: minmax(330px, 0.78fr) minmax(450px, 1.22fr);
  gap: clamp(24px, 4vw, 64px);
  align-items: start;
}

.quiz-board-column {
  position: sticky;
  top: calc(var(--header-height) + 22px);
}

.quiz-board-label {
  display: flex;
  justify-content: space-between;
  width: min(100%, 520px);
  margin: 0 auto 10px;
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.quiz-board-frame {
  width: min(100%, 520px);
}

.quiz-board-note {
  display: flex;
  gap: 12px;
  width: min(100%, 520px);
  margin: 14px auto 0;
  padding: 13px 14px;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.018);
}

.quiz-board-note > span {
  color: var(--accent-bright);
}

.quiz-board-note p {
  margin: 0;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.55;
}

.quiz-panel {
  overflow: hidden;
  min-height: 610px;
  padding: clamp(24px, 3.5vw, 42px);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  background: rgba(32, 33, 30, 0.78);
  box-shadow: 0 15px 45px rgba(0, 0, 0, 0.13);
}

.quiz-progress-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.quiz-progress {
  height: 4px;
  margin: 12px 0 34px;
}

.quiz-question {
  position: relative;
}

.question-number {
  display: block;
  margin-bottom: 12px;
  color: rgba(172, 193, 159, 0.45);
  font-family: "Newsreader", Georgia, serif;
  font-size: 26px;
}

.quiz-question h2 {
  max-width: 680px;
  margin-bottom: 28px;
  font-size: clamp(27px, 3vw, 38px);
  font-weight: 500;
  line-height: 1.18;
  letter-spacing: -0.025em;
}

.answer-list {
  display: grid;
  gap: 9px;
}

.answer-option {
  display: grid;
  min-height: 57px;
  grid-template-columns: 34px 1fr;
  align-items: center;
  gap: 12px;
  padding: 10px 15px;
  border: 1px solid var(--border-soft);
  border-radius: 11px;
  background: #1d1e1b;
  color: #d1cec3;
  cursor: pointer;
  text-align: left;
  transition: border 160ms ease, background 160ms ease, transform 160ms ease;
}

.answer-option:hover:not(:disabled) {
  border-color: #52534c;
  background: #242520;
  transform: translateX(2px);
}

.answer-option:disabled {
  cursor: default;
}

.answer-letter {
  display: grid;
  width: 31px;
  height: 31px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
}

.answer-option.correct {
  border-color: rgba(140, 175, 121, 0.55);
  background: rgba(140, 175, 121, 0.09);
  color: var(--text);
}

.answer-option.correct .answer-letter {
  border-color: transparent;
  background: var(--correct);
  color: #172014;
}

.answer-option.incorrect {
  border-color: rgba(199, 121, 110, 0.55);
  background: rgba(199, 121, 110, 0.08);
}

.answer-option.incorrect .answer-letter {
  border-color: transparent;
  background: var(--wrong);
  color: #241311;
}

.answer-feedback {
  margin-top: 16px;
  padding: 18px;
  border: 1px solid var(--border-soft);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.018);
}

.answer-feedback.correct { border-color: rgba(140, 175, 121, 0.28); }
.answer-feedback.incorrect { border-color: rgba(199, 121, 110, 0.28); }

.feedback-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
}

.answer-feedback.correct .feedback-title span { color: var(--correct); }
.answer-feedback.incorrect .feedback-title span { color: var(--wrong); }

.answer-feedback p {
  margin-bottom: 15px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.6;
}

.quiz-results {
  padding-top: 4px;
  text-align: center;
}

.result-ring {
  --score: 0deg;
  position: relative;
  display: grid;
  width: 128px;
  height: 128px;
  margin: 0 auto 25px;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--selected) var(--score), var(--surface-3) 0);
}

.result-ring.strong {
  background: conic-gradient(var(--correct) var(--score), var(--surface-3) 0);
}

.result-ring::before {
  position: absolute;
  width: 106px;
  height: 106px;
  border-radius: 50%;
  background: var(--surface);
  content: "";
}

.result-ring > div {
  position: relative;
  z-index: 1;
}

.result-ring strong,
.result-ring span {
  display: block;
}

.result-ring strong {
  font-family: "Newsreader", Georgia, serif;
  font-size: 27px;
}

.result-ring span {
  color: var(--text-muted);
  font-size: 12px;
}

.quiz-results h2 {
  margin-bottom: 9px;
  font-size: 34px;
  font-weight: 500;
}

.quiz-results > p:not(.eyebrow) {
  max-width: 530px;
  margin: 0 auto;
  color: var(--text-muted);
}

.result-stat-row {
  display: grid;
  max-width: 430px;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 25px auto;
}

.result-stat-row > span {
  padding: 12px;
  border: 1px solid var(--border-soft);
  border-radius: 9px;
}

.result-stat-row small,
.result-stat-row strong {
  display: block;
}

.result-stat-row small {
  margin-bottom: 4px;
  color: var(--text-dim);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.return-link {
  display: inline-block;
  margin-top: 19px;
  color: var(--text-muted);
  font-size: 11px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Adaptive review */
.review-heading {
  align-items: center;
}

.review-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: -14px 0 22px;
}

.review-metrics > div {
  padding: 19px;
  border: 1px solid var(--border-soft);
  border-radius: 13px;
  background: var(--surface);
}

.review-metrics strong,
.review-metrics span {
  display: block;
}

.review-metrics strong {
  font-family: "Newsreader", Georgia, serif;
  font-size: 30px;
  line-height: 1;
}

.review-metrics span {
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 11px;
}

.training-mode-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 13px;
  margin-bottom: 30px;
}

.training-mode-card {
  position: relative;
  display: block;
  min-height: 210px;
  padding: 23px;
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  background: var(--surface);
  transition: border-color 170ms ease, transform 170ms ease;
}

.training-mode-card:hover {
  border-color: rgba(140, 164, 124, 0.5);
  transform: translateY(-2px);
}

.training-mode-card.featured {
  border-color: rgba(140, 164, 124, 0.42);
  background: linear-gradient(145deg, var(--accent-soft), var(--surface));
}

.mode-kicker {
  display: block;
  margin-bottom: 25px;
  color: var(--accent-bright);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.training-mode-card > strong {
  display: block;
  margin-bottom: 7px;
  font-family: "Newsreader", Georgia, serif;
  font-size: 29px;
  font-weight: 600;
}

.training-mode-card p {
  margin-bottom: 20px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.6;
}

.mode-link {
  color: var(--accent-bright);
  font-size: 11px;
  font-weight: 700;
}

.review-queue-section {
  overflow: hidden;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.section-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 25px;
  border-bottom: 1px solid var(--border-soft);
}

.section-heading-row h2 {
  margin: 0;
  font-size: 27px;
  font-weight: 500;
}

.section-heading-row > span {
  color: var(--text-dim);
  font-size: 11px;
}

.review-queue {
  display: grid;
}

.review-row {
  display: grid;
  min-width: 0;
  grid-template-columns: 48px minmax(190px, 1fr) 80px 76px auto;
  align-items: center;
  gap: 15px;
  min-height: 80px;
  padding: 13px 20px;
  border-bottom: 1px solid var(--border-soft);
}

.review-row:last-child {
  border-bottom: 0;
}

.review-row:hover {
  background: rgba(140, 164, 124, 0.045);
}

.review-piece {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  background: #252621;
  color: #eee7d6;
  font-size: 27px;
}

.review-piece.side-black {
  border-color: #c5b291;
  background: #dbc8a7;
}

.review-line-title,
.review-accuracy {
  min-width: 0;
}

.review-line-title strong,
.review-line-title span,
.review-accuracy strong,
.review-accuracy span {
  display: block;
}

.review-line-title strong {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.review-line-title span,
.review-accuracy span {
  color: var(--text-dim);
  font-size: 10px;
}

.review-accuracy strong {
  font-family: "Newsreader", Georgia, serif;
  font-size: 18px;
}

.review-timing {
  justify-self: start;
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
}

.review-timing.due {
  background: rgba(199, 121, 110, 0.11);
  color: var(--wrong);
}

.review-timing.new {
  background: var(--accent-soft);
  color: var(--accent-bright);
}

.review-row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
}

.review-row-actions .button {
  min-height: 38px;
  padding-inline: 13px;
}

/* Progress dashboard */
.dashboard-hero {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 24px;
  align-items: stretch;
  margin-bottom: 27px;
}

.dashboard-intro,
.mastery-card {
  padding: clamp(25px, 4vw, 44px);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.dashboard-intro h1 {
  margin-bottom: 10px;
  font-size: clamp(42px, 5vw, 64px);
  font-weight: 500;
  line-height: 0.98;
  letter-spacing: -0.04em;
}

.dashboard-intro > p:not(.eyebrow) {
  max-width: 610px;
  margin-bottom: 0;
  color: var(--text-muted);
}

.mastery-card {
  display: flex;
  align-items: center;
  gap: 24px;
  background: linear-gradient(145deg, rgba(140, 164, 124, 0.13), rgba(32, 33, 30, 0.92));
}

.mastery-ring-large {
  --progress: 0deg;
  position: relative;
  display: grid;
  flex: 0 0 auto;
  width: 104px;
  height: 104px;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--accent) var(--progress), rgba(255, 255, 255, 0.09) 0);
}

.mastery-ring-large::before {
  position: absolute;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: #242620;
  content: "";
}

.mastery-ring-large > div {
  position: relative;
  z-index: 1;
  text-align: center;
}

.mastery-ring-large strong,
.mastery-ring-large span { display: block; }
.mastery-ring-large strong { font-family: "Newsreader", Georgia, serif; font-size: 28px; }
.mastery-ring-large span { color: var(--text-muted); font-size: 9px; text-transform: uppercase; }

.mastery-card h2 {
  margin-bottom: 5px;
  font-size: 27px;
  font-weight: 500;
}

.mastery-card p { margin: 0; color: var(--text-muted); font-size: 12px; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 13px;
  margin-bottom: 27px;
}

.local-data-note {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  margin-bottom: 27px;
  padding: 18px 20px;
  border: 1px solid rgba(140, 164, 124, 0.28);
  border-radius: 14px;
  background: var(--accent-soft);
}

.local-data-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(140, 164, 124, 0.38);
  border-radius: 50%;
  color: var(--accent-bright);
  font-size: 22px;
}

.local-data-note strong {
  display: block;
  margin-bottom: 2px;
  font-size: 13px;
}

.local-data-note p {
  margin: 0;
  color: var(--text-muted);
  font-size: 11px;
}

.local-data-actions {
  display: flex;
  gap: 8px;
}

.metric-card {
  display: grid;
  grid-template-columns: 45px 1fr;
  align-items: center;
  gap: 15px;
  padding: 20px;
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  background: rgba(32, 33, 30, 0.72);
}

.metric-icon {
  display: grid;
  width: 43px;
  height: 43px;
  place-items: center;
  border-radius: 11px;
  background: var(--accent-soft);
  color: var(--accent-bright);
  font-size: 20px;
}

.metric-card strong,
.metric-card span { display: block; }
.metric-card .metric-icon { display: grid; }
.metric-card strong { font-family: "Newsreader", Georgia, serif; font-size: 26px; line-height: 1; }
.metric-card span { margin-top: 4px; color: var(--text-muted); font-size: 11px; }

.progress-table-wrap {
  overflow: hidden;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  background: rgba(32, 33, 30, 0.72);
}

.progress-table-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 25px;
  border-bottom: 1px solid var(--border-soft);
}

.progress-table-head h2 { margin: 0; font-size: 26px; font-weight: 500; }

.course-progress-list { display: grid; }

.course-progress-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) minmax(170px, 1fr) repeat(3, 82px) 90px;
  align-items: center;
  gap: 15px;
  min-height: 78px;
  padding: 13px 25px;
  border-bottom: 1px solid rgba(58, 59, 53, 0.58);
}

.course-progress-row:last-child { border-bottom: 0; }
.course-progress-row:hover { background: rgba(255, 255, 255, 0.018); }

.course-name-cell {
  display: flex;
  align-items: center;
  gap: 13px;
}

.course-mini-glyph {
  display: grid;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--accent-bright);
  font-family: Georgia, serif;
  font-size: 22px;
}

.course-name-cell strong,
.course-name-cell span { display: block; }
.course-name-cell .course-mini-glyph { display: grid; }
.course-name-cell strong { font-size: 13px; }
.course-name-cell span { color: var(--text-dim); font-size: 10px; }

.row-progress { display: flex; align-items: center; gap: 10px; }
.row-progress > span { min-width: 31px; color: var(--text-muted); font-size: 10px; text-align: right; }

.module-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
  font-size: 10px;
}

.module-status::before {
  display: grid;
  width: 18px;
  height: 18px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  content: "";
}

.module-status.done { color: var(--accent-bright); }
.module-status.done::before { border-color: var(--accent-dark); background: var(--accent-dark); color: white; content: "✓"; }

.row-action {
  justify-self: end;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
}
.row-action:hover { color: var(--accent-bright); }

/* Light theme surface tuning */
html[data-theme="light"] .site-header {
  border-bottom-color: rgba(157, 148, 132, 0.55);
  background: rgba(244, 240, 231, 0.94);
}

html[data-theme="light"] .main-nav {
  background: rgba(255, 253, 248, 0.8);
}

html[data-theme="light"] .main-nav a.active,
html[data-theme="light"] .theme-toggle,
html[data-theme="light"] .icon-button {
  box-shadow: none;
}

html[data-theme="light"] .library-summary,
html[data-theme="light"] .opening-card,
html[data-theme="light"] .lesson-panel,
html[data-theme="light"] .practice-coach-panel,
html[data-theme="light"] .quiz-panel,
html[data-theme="light"] .metric-card,
html[data-theme="light"] .progress-table-wrap {
  background: rgba(255, 253, 248, 0.88);
}

html[data-theme="light"] .opening-card {
  background: linear-gradient(140deg, rgba(255, 253, 248, 0.98), rgba(237, 232, 220, 0.96));
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.75) inset;
}

html[data-theme="light"] .opening-card:hover {
  box-shadow: 0 18px 40px rgba(80, 69, 51, 0.12);
}

html[data-theme="light"] .tag,
html[data-theme="light"] .info-card,
html[data-theme="light"] .structure-card,
html[data-theme="light"] .quiz-board-note,
html[data-theme="light"] .answer-feedback,
html[data-theme="light"] .coach-tip {
  background: rgba(72, 68, 58, 0.035);
}

html[data-theme="light"] .progress-track {
  background: #d8d1c4;
}

html[data-theme="light"] .board-frame {
  border-color: #b6a990;
  background: #d8cab0;
  box-shadow: var(--shadow), 0 1px 0 rgba(255, 255, 255, 0.65) inset;
}

html[data-theme="light"] .move-explanation,
html[data-theme="light"] .coach-card,
html[data-theme="light"] .answer-option {
  background: #f5f1e8;
}

html[data-theme="light"] .answer-option:hover:not(:disabled) {
  border-color: #aaa193;
  background: #ece6da;
}

html[data-theme="light"] .objective-list li,
html[data-theme="light"] .plan-list li,
html[data-theme="light"] .mistake-list li,
html[data-theme="light"] .move-explanation p,
html[data-theme="light"] .answer-option {
  color: #4a4f47;
}

html[data-theme="light"] .notation-move:hover,
html[data-theme="light"] .course-progress-row:hover,
html[data-theme="light"] .review-row:hover {
  background: rgba(86, 109, 76, 0.055);
}

html[data-theme="light"] .notation-move.future {
  color: #9a9c94;
}

html[data-theme="light"] .toast {
  background: #fffdf8;
}

html[data-theme="light"] .mastery-card,
html[data-theme="light"] .training-mode-card.featured {
  background: linear-gradient(145deg, rgba(89, 116, 80, 0.12), rgba(255, 253, 248, 0.96));
}

html[data-theme="light"] .mastery-ring-large::before {
  background: #fffdf8;
}

html[data-theme="light"] .side-dot {
  border-color: rgba(34, 37, 33, 0.25);
}

html[data-theme="light"] .dialog::backdrop {
  background: rgba(46, 42, 34, 0.48);
}

@media (max-width: 1120px) {
  .course-progress-row {
    grid-template-columns: minmax(190px, 1.4fr) minmax(140px, 1fr) repeat(3, 70px) 70px;
    gap: 10px;
    padding-inline: 18px;
  }
}

@media (max-width: 1120px) {
  .site-header {
    grid-template-columns: 1fr auto;
  }

  .main-nav {
    order: 3;
    grid-column: 1 / -1;
    justify-self: center;
    margin-bottom: 8px;
  }

  .header-actions {
    grid-column: 2;
    grid-row: 1;
  }

  .metric-grid,
  .review-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .opening-card {
    grid-template-columns: minmax(0, 1fr) 110px;
  }

  .lesson-layout {
    grid-template-columns: minmax(360px, 0.88fr) minmax(380px, 1.12fr);
    gap: 24px;
  }

  .board-frame { padding: 10px; }
}

@media (max-width: 860px) {
  :root { --header-height: 64px; }

  .site-header {
    display: flex;
    min-height: 64px;
    justify-content: space-between;
    padding-inline: 20px;
  }

  .header-progress { display: none; }

  .header-actions {
    margin-left: auto;
  }

  .page-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .library-summary { min-width: min(100%, 290px); }

  .opening-grid { grid-template-columns: 1fr; }

  .lesson-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .lesson-status { align-self: stretch; }

  .lesson-header-actions {
    width: 100%;
    justify-content: space-between;
  }

  .lesson-layout {
    grid-template-columns: 1fr;
  }

  .board-column {
    position: static;
  }

  .board-frame {
    width: min(100%, 660px);
  }

  .lesson-panel {
    min-height: auto;
  }

  .practice-coach-panel { min-height: auto; }

  .quiz-layout { grid-template-columns: 1fr; }
  .quiz-board-column { position: static; }
  .quiz-board-frame { width: min(100%, 620px); }
  .quiz-board-label,
  .quiz-board-note { width: min(100%, 620px); }

  .dashboard-hero { grid-template-columns: 1fr; }
  .training-mode-grid { grid-template-columns: 1fr; }
  .training-mode-card { min-height: 0; }
  .mode-kicker { margin-bottom: 14px; }
  .review-row {
    grid-template-columns: 48px minmax(160px, 1fr) 70px auto;
  }
  .review-timing { display: none; }
  .course-progress-row {
    grid-template-columns: 1.4fr 1fr repeat(3, 42px) 55px;
  }
  .module-status { justify-content: center; font-size: 0; }
  .module-status::before { font-size: 10px; }
}

@media (max-width: 620px) {
  .page-shell {
    width: min(calc(100% - 32px), var(--content-max));
    padding-top: 36px;
  }

  .page-heading {
    margin-bottom: 30px;
  }

  .page-heading h1 {
    font-size: 43px;
  }

  .library-tools {
    align-items: stretch;
    flex-direction: column;
  }

  .search-wrap { flex-basis: auto; max-width: none; }
  .result-count { margin-left: 0; }

  .filter-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 5px;
    scrollbar-width: thin;
  }

  .filter-chip { flex: 0 0 auto; }

  .study-strip {
    grid-template-columns: auto minmax(0, 1fr);
    margin-top: -8px;
  }

  .study-strip-actions {
    grid-column: 1 / -1;
  }

  .opening-card {
    min-height: 230px;
    grid-template-columns: 1fr 82px;
    gap: 14px;
    padding: 20px;
  }

  .opening-card h2 { font-size: 25px; }
  .card-visual { min-height: 145px; }
  .card-piece { font-size: 54px; }
  .card-number { display: none; }

  .lesson-shell {
    width: calc(100% - 22px);
    padding-top: 18px;
  }

  .lesson-breadcrumbs { margin-left: 4px; }

  .lesson-title-wrap { gap: 11px; }
  .opening-glyph { width: 45px; height: 45px; }
  .opening-glyph .vector-piece-icon { width: 28px; height: 28px; }
  .lesson-header h1 { font-size: 30px; }

  .board-frame {
    padding: 7px;
    border-radius: 12px;
  }

  .board-toolbar {
    flex-wrap: wrap;
  }

  .board-actions { margin: 0; }

  .lesson-tabs { overflow-x: auto; }
  .lesson-tab { min-width: 76px; }

  .panel-content { padding: 22px 17px 24px; }
  .panel-content h2 { font-size: 27px; }

  .info-grid,
  .ideas-columns { grid-template-columns: 1fr; }

  .line-selector {
    align-items: stretch;
    flex-direction: column;
  }

  .line-select { width: 100%; max-width: none; }

  .dialog form { padding: 24px; }
  .dialog-actions { align-items: stretch; flex-direction: column-reverse; }

  .practice-coach-top { align-items: stretch; flex-direction: column; }
  .practice-coach-top .line-select { width: 100%; max-width: none; }
  #practice-coach-content { padding: 16px; }
  .coach-card { min-height: 390px; padding: 25px 17px; }
  .coach-tip { grid-template-columns: 1fr; }
  .completion-actions,
  .practice-footer { align-items: stretch; flex-direction: column; }

  .quiz-panel { min-height: auto; padding: 22px 16px 25px; }
  .quiz-score-live { align-self: flex-end; }
  .answer-option { padding-inline: 11px; }
  .result-stat-row { grid-template-columns: repeat(3, 1fr); }
  .result-actions { align-items: stretch; flex-direction: column; }

  .dashboard-intro,
  .mastery-card { padding: 24px 20px; }
  .mastery-card { align-items: flex-start; flex-direction: column; }
  .metric-grid { grid-template-columns: 1fr; }
  .progress-table-head { align-items: flex-start; flex-direction: column; }
  .course-progress-row {
    grid-template-columns: 1fr auto;
    gap: 10px;
    padding: 16px;
  }
  .row-progress { grid-column: 1 / -1; }
  .module-status { display: none; }
  .row-action { grid-column: 2; grid-row: 1; }

  .review-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .review-row {
    grid-template-columns: 44px minmax(0, 1fr) auto;
    gap: 10px;
    padding: 14px;
  }
  .review-accuracy { display: none; }
  .review-row-actions { grid-column: 2 / -1; justify-content: flex-start; }
  .section-heading-row { align-items: flex-start; flex-direction: column; }

  .local-data-note {
    grid-template-columns: auto minmax(0, 1fr);
  }
  .local-data-actions {
    grid-column: 1 / -1;
    flex-wrap: wrap;
  }
}

@media (max-width: 420px) {
  .site-header { padding-inline: 13px; }
  .theme-toggle { width: 40px; padding: 0; justify-content: center; }
  #theme-label { display: none; }
  .brand { font-size: 20px; gap: 7px; }
  .brand-mark { width: 34px; height: 34px; }

  .opening-card {
    grid-template-columns: 1fr 66px;
    padding: 18px;
  }

  .card-visual { min-height: 120px; }
  .card-piece { font-size: 46px; }
  .tag-row { margin-bottom: 18px; }
  .filter-chip { padding-inline: 12px; }
  .lesson-meta { max-width: 250px; }
  .lesson-header-actions { align-items: stretch; flex-direction: column; }
  .lesson-status { justify-content: space-between; }
  .review-metrics > div { padding: 15px; }
  .review-metrics strong { font-size: 25px; }
  .study-strip-actions { align-items: stretch; flex-direction: column; }
  .local-data-actions { align-items: stretch; flex-direction: column; }
}

/* Production interaction layer */

.site-header {
  grid-template-columns: auto 1fr auto;
  min-height: var(--header-height);
  border-bottom-color: rgba(68, 75, 65, 0.62);
  background: rgba(16, 18, 15, 0.9);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.025), 0 10px 32px rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(20px) saturate(1.15);
}

.brand,
h1,
h2 {
  font-family: ui-serif, "Iowan Old Style", "Palatino Linotype", Georgia, serif;
}

.brand-mark {
  border-color: rgba(148, 184, 132, 0.42);
  border-radius: 12px;
}

.brand-mark svg {
  stroke: #43523e;
  stroke-width: 1.35;
}

.main-nav {
  justify-self: center;
  border-radius: 14px;
  background: rgba(29, 32, 27, 0.72);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.025) inset;
}

.main-nav a {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  gap: 7px;
  padding: 0 13px;
  border-radius: 10px;
  font-size: 13px;
  transition: color 180ms ease, background 180ms ease, transform 180ms var(--ease-out);
}

.main-nav svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.68;
  transition: opacity 180ms ease, transform 180ms var(--ease-out);
}

.main-nav a:hover { transform: translateY(-1px); }
.main-nav a.active svg { color: var(--accent-bright); opacity: 1; transform: scale(1.05); }

.theme-toggle {
  min-height: 40px;
  border-radius: 12px;
  transition: border-color 180ms ease, color 180ms ease, transform 180ms var(--ease-out);
}

.theme-toggle:hover { transform: translateY(-1px); }

.theme-icons,
.theme-icons svg {
  display: block;
  width: 17px;
  height: 17px;
}

.theme-icons { position: relative; }

.theme-icons svg {
  position: absolute;
  inset: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: opacity 220ms ease, transform 260ms var(--ease-spring);
}

html[data-theme="dark"] .sun-icon,
html[data-theme="light"] .moon-icon { opacity: 1; transform: rotate(0) scale(1); }

html[data-theme="dark"] .moon-icon,
html[data-theme="light"] .sun-icon { opacity: 0; transform: rotate(-35deg) scale(0.7); }

.page-enter { animation: page-enter-premium 360ms var(--ease-out) both; }

@keyframes page-enter-premium {
  from { opacity: 0; transform: translateY(9px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-heading h1 { font-size: clamp(44px, 5vw, 70px); }

.study-strip {
  border-color: rgba(148, 184, 132, 0.3);
  border-radius: 18px;
  background: linear-gradient(110deg, rgba(148, 184, 132, 0.14), rgba(148, 184, 132, 0.055)), var(--surface);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.08);
  transition: border-color 220ms ease, transform 220ms var(--ease-out), box-shadow 220ms ease;
}

.study-strip:hover {
  border-color: rgba(148, 184, 132, 0.48);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.12);
  transform: translateY(-2px);
}

.study-strip-icon { border-radius: 13px; }

.search-wrap kbd {
  position: absolute;
  top: 50%;
  right: 10px;
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--text-dim);
  font-family: inherit;
  font-size: 11px;
  transform: translateY(-50%);
  pointer-events: none;
}

.search-input {
  padding-right: 45px;
  border-radius: 13px;
  transition: border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.filter-chip {
  transition: border-color 180ms ease, background 180ms ease, color 180ms ease, transform 180ms var(--ease-out);
}

.filter-chip:hover { transform: translateY(-1px); }

.opening-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.opening-card {
  min-height: 270px;
  grid-template-columns: minmax(0, 1fr) 94px;
  gap: 18px;
  padding: 23px;
  border-radius: var(--radius-lg);
  background: linear-gradient(145deg, rgba(31, 35, 29, 0.96), rgba(23, 26, 22, 0.96));
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 16px 42px rgba(0, 0, 0, 0.08);
  content-visibility: auto;
  contain-intrinsic-size: 270px;
  transition: transform 260ms var(--ease-out), border-color 220ms ease, box-shadow 260ms ease;
}

.opening-card::before {
  position: absolute;
  z-index: 2;
  top: 0;
  right: 24px;
  left: 24px;
  height: 2px;
  border-radius: 0 0 4px 4px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  content: "";
  opacity: 0;
  transform: scaleX(0.65);
  transition: opacity 220ms ease, transform 300ms var(--ease-out);
}

.opening-card.card-animate {
  animation: card-enter 460ms var(--ease-out) both;
  animation-delay: calc(var(--card-order) * 28ms);
}

@keyframes card-enter {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.opening-card:hover {
  border-color: rgba(148, 184, 132, 0.5);
  box-shadow: 0 24px 58px rgba(0, 0, 0, 0.19);
  transform: translateY(-5px);
}

.opening-card:hover::before { opacity: 1; transform: scaleX(1); }
.card-content { min-width: 0; }
.opening-card h2 { font-size: clamp(24px, 2vw, 29px); }
.tag-row { margin-bottom: 21px; }

.card-line-count {
  flex: 0 0 auto;
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.card-progress > .card-line-count {
  min-width: auto;
  color: var(--text-dim);
  font-size: 10px;
  text-align: left;
}

.card-visual {
  min-height: 176px;
  border-radius: 18px;
  transition: background-position 500ms var(--ease-out), border-color 220ms ease, transform 280ms var(--ease-out);
}

.opening-card:hover .card-visual { background-position: 4px 4px, 16px 16px; transform: translateY(-2px); }
.opening-card.side-black:hover .card-visual { background-position: 4px 4px, 16px 16px; }

.card-piece {
  font-size: 64px;
  transform: translateY(-3px);
  transition: transform 360ms var(--ease-spring), filter 260ms ease;
}

.opening-card:hover .card-piece { transform: translateY(-5px) rotate(-2deg) scale(1.06); }

.empty-state p { margin: 6px 0 20px; }

.button {
  border-radius: 11px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.1);
  transition: border-color 180ms ease, background 180ms ease, color 180ms ease, transform 180ms var(--ease-out), box-shadow 180ms ease;
}

.button:hover { transform: translateY(-1px); }
.button-ghost { box-shadow: none; }

.icon-button {
  transition: border-color 180ms ease, background 180ms ease, color 180ms ease, transform 180ms var(--ease-out);
}

.icon-button:hover { transform: translateY(-1px); }

.favorite-button { transition: border-color 180ms ease, background 180ms ease, color 180ms ease, transform 180ms var(--ease-out); }
.favorite-button:hover { transform: translateY(-1px); }

.board-frame {
  border-radius: 20px;
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.24), 0 1px 0 rgba(255, 255, 255, 0.08) inset;
  transition: border-color 220ms ease, transform 280ms var(--ease-out), box-shadow 280ms ease;
}

.board-frame:hover { border-color: #4b5148; transform: translateY(-2px); }
.chessboard:not(.is-interactive) .square { cursor: default; }
.chessboard.is-interactive .square { cursor: pointer; }
.chessboard.is-interactive .square:hover { filter: brightness(1.045); }
.chessboard.is-interactive .square:hover .piece { transform: translateY(-2px) scale(1.025); }

.piece { transition: transform 150ms var(--ease-out), filter 150ms ease; }

.square.moved .piece { animation: piece-arrive-premium 220ms var(--ease-spring) both; }

@keyframes piece-arrive-premium {
  from { opacity: 0.55; transform: translateY(-8px) scale(0.82); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.lesson-panel,
.practice-coach-panel,
.quiz-panel {
  border-radius: var(--radius-lg);
  background: rgba(24, 27, 23, 0.84);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.16), 0 1px 0 rgba(255, 255, 255, 0.025) inset;
}

.lesson-tab {
  transition: color 180ms ease, background 180ms ease, transform 180ms var(--ease-out);
}

.lesson-tab:hover { transform: translateY(-1px); }
.lesson-tab.active { box-shadow: 0 8px 18px rgba(0, 0, 0, 0.12); }

.info-card,
.structure-card {
  transition: border-color 180ms ease, background 180ms ease, transform 180ms var(--ease-out);
}

.info-card:hover,
.structure-card:hover { border-color: var(--border); transform: translateY(-1px); }

.move-explanation {
  background: #141713;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.025) inset;
}

.playback-button,
.notation-move,
.key-square-button {
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease, transform 160ms var(--ease-out);
}

.playback-button:hover:not(:disabled),
.key-square-button:hover { transform: translateY(-1px); }

.toast {
  border-radius: 13px;
  background: #232720;
  transform: translateY(12px) scale(0.98);
  transition: opacity 200ms ease, transform 240ms var(--ease-spring);
}

.toast.show { transform: translateY(0) scale(1); }

.coach-card { transition: border-color 180ms ease, transform 240ms var(--ease-out); }
.coach-card.correct { animation: coach-confirm 320ms var(--ease-spring) both; }

@keyframes coach-confirm {
  0% { transform: scale(0.985); }
  60% { transform: scale(1.008); }
  100% { transform: scale(1); }
}

.answer-option {
  border-radius: 12px;
  transition: border-color 180ms ease, background 180ms ease, color 180ms ease, transform 180ms var(--ease-out);
}

.answer-option:hover:not(:disabled) { transform: translateX(3px); }

.review-metrics > div,
.metric-card {
  transition: border-color 180ms ease, transform 220ms var(--ease-out), box-shadow 220ms ease;
}

.review-metrics > div:hover,
.metric-card:hover { border-color: var(--border); transform: translateY(-2px); box-shadow: 0 16px 38px rgba(0, 0, 0, 0.09); }

.training-mode-card {
  overflow: hidden;
  transition: border-color 200ms ease, transform 240ms var(--ease-out), box-shadow 240ms ease;
}

.training-mode-card::after {
  position: absolute;
  right: -42px;
  bottom: -58px;
  width: 150px;
  height: 150px;
  border: 1px solid rgba(148, 184, 132, 0.13);
  border-radius: 50%;
  content: "";
  pointer-events: none;
  transition: transform 400ms var(--ease-out);
}

.training-mode-card > * { position: relative; z-index: 1; }
.training-mode-card:hover { transform: translateY(-4px); box-shadow: 0 22px 52px rgba(0, 0, 0, 0.14); }
.training-mode-card:hover::after { transform: translate(-12px, -10px) scale(1.12); }

.review-row {
  content-visibility: auto;
  contain-intrinsic-size: 82px;
  transition: background 180ms ease, transform 180ms var(--ease-out);
}

.review-row:hover { transform: translateX(2px); }

/* One restrained radius scale: controls, inner surfaces, and outer surfaces. */
.brand-mark,
.study-strip-icon,
.main-nav a,
.theme-toggle,
.button,
.icon-button,
.favorite-button,
.playback-button,
.line-select,
.mini-action,
.lesson-tab,
.key-square-button,
.module-status,
.row-action {
  border-radius: var(--radius-sm);
}

.main-nav,
.search-input,
.card-visual,
.opening-glyph,
.info-card,
.structure-card,
.move-explanation,
.notation-wrap,
.coach-card,
.answer-option,
.toast,
.dialog-icon,
.study-note,
.study-note textarea {
  border-radius: var(--radius);
}

.library-summary,
.study-strip,
.opening-card,
.board-frame,
.lesson-panel,
.practice-coach-panel,
.quiz-panel,
.dialog,
.review-metrics > div,
.metric-card,
.training-mode-card,
.local-data-note,
.mastery-card,
.dashboard-intro {
  border-radius: var(--radius-lg);
}

.chessboard,
.search-wrap kbd,
.tag {
  border-radius: var(--radius-xs);
}

.brand-mark path { vector-effect: non-scaling-stroke; }

/* Move-purpose tools and local study notes. */
.line-selector-controls {
  display: flex;
  min-width: 0;
  flex: 1;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
}

.line-selector-controls .line-select { width: auto; min-width: 0; flex: 1; }

.mini-action {
  display: inline-flex;
  min-height: 38px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  padding: 0 11px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 750;
  cursor: pointer;
  transition: border-color 170ms ease, color 170ms ease, transform 180ms var(--ease-out), background 170ms ease;
}

.mini-action:hover {
  border-color: var(--accent-dark);
  background: var(--accent-soft);
  color: var(--text);
  transform: translateY(-1px);
}

.move-themes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 17px;
}

.move-themes span {
  padding: 5px 8px;
  border: 1px solid rgba(148, 184, 132, 0.22);
  border-radius: var(--radius-pill);
  background: rgba(148, 184, 132, 0.08);
  color: var(--accent-bright);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  animation: theme-chip-enter 260ms var(--ease-out) both;
}

.move-themes span:nth-child(2) { animation-delay: 45ms; }
.move-themes span:nth-child(3) { animation-delay: 90ms; }

@keyframes theme-chip-enter {
  from { opacity: 0; transform: translateY(4px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.study-note {
  display: grid;
  gap: 10px;
  margin-top: 22px;
  padding: 15px;
  border: 1px solid var(--border-soft);
  background: var(--surface-2);
  background: color-mix(in srgb, var(--surface-2) 72%, transparent);
  transition: border-color 180ms ease, background 180ms ease, transform 200ms var(--ease-out);
}

.study-note:focus-within {
  border-color: var(--accent-dark);
  background: var(--surface-2);
  transform: translateY(-1px);
}

.study-note-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.study-note-heading strong { color: var(--text); font-size: 12px; }
.study-note-heading small { color: var(--text-dim); font-size: 10px; }

.study-note textarea {
  width: 100%;
  min-height: 96px;
  resize: vertical;
  padding: 11px 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  line-height: 1.55;
}

.study-note textarea::placeholder { color: var(--text-dim); }

/* Motion stays on compositor-friendly transform and opacity properties. */
.button span[aria-hidden="true"],
.mode-link {
  display: inline-block;
  transition: transform 190ms var(--ease-out);
}

.button:hover span[aria-hidden="true"],
.training-mode-card:hover .mode-link { transform: translateX(3px); }

.tag,
.side-badge,
.difficulty-badge {
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease, transform 180ms var(--ease-out);
}

.opening-card:hover .tag { transform: translateY(-1px); }
.opening-card:hover .tag:nth-child(2) { transition-delay: 25ms; }
.opening-card:hover .tag:nth-child(3) { transition-delay: 50ms; }

.chessboard.is-interactive .square:hover .piece {
  filter: drop-shadow(0 6px 4px rgba(20, 22, 18, 0.25));
  transform: translateY(-4px) rotate(-1deg) scale(1.065);
}

.chessboard:not(.is-interactive) .square.has-piece:hover .piece {
  filter: drop-shadow(0 5px 4px rgba(20, 22, 18, 0.2));
  transform: translateY(-2px) scale(1.035);
}

.chessboard.is-interactive .square:active .piece { transform: translateY(-1px) scale(0.96); }

.square.key-square::after { animation: key-square-breathe 1.7s ease-in-out infinite alternate; }

@keyframes key-square-breathe {
  from { opacity: 0.74; }
  to { opacity: 1; }
}

.main-nav a.active svg { animation: nav-icon-arrive 300ms var(--ease-spring) both; }

@keyframes nav-icon-arrive {
  0% { transform: translateY(2px) scale(0.86); }
  100% { transform: translateY(0) scale(1.05); }
}

.dialog[open] { animation: dialog-enter 220ms var(--ease-out) both; }

@keyframes dialog-enter {
  from { opacity: 0; transform: translateY(8px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.answer-option.correct .answer-letter { animation: answer-confirm 260ms var(--ease-spring) both; }

@keyframes answer-confirm {
  0% { transform: scale(0.78); }
  70% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

html[data-theme="light"] .site-header {
  background: rgba(244, 242, 236, 0.92);
}

html[data-theme="light"] .opening-card {
  background: linear-gradient(140deg, rgba(255, 254, 250, 0.98), rgba(239, 235, 226, 0.96));
}

html[data-theme="light"] .move-explanation { background: #f5f1e8; }

@media (max-width: 1320px) {
  .opening-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1120px) {
  .site-header { grid-template-columns: auto 1fr auto; }
  .main-nav { order: initial; grid-column: auto; justify-self: center; margin-bottom: 0; }
  .header-actions { grid-column: auto; grid-row: auto; }
  .opening-card { grid-template-columns: minmax(0, 1fr) 94px; }
}

@media (max-width: 980px) {
  .header-progress { display: none; }
  .main-nav a { padding-inline: 10px; }
}

@media (max-width: 860px) {
  body { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }

  .site-header {
    background: rgba(16, 18, 15, 0.985);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

  html[data-theme="light"] .site-header { background: rgba(244, 242, 236, 0.985); }

  .main-nav {
    position: fixed;
    z-index: 120;
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    width: 100%;
    max-width: none;
    margin: 0;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: stretch;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    border: 0;
    border-top: 1px solid var(--border);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    background: rgba(17, 19, 16, 0.94);
    box-shadow: 0 -16px 44px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(20px) saturate(1.25);
  }

  html[data-theme="light"] .main-nav { background: rgba(255, 254, 250, 0.94); }

  .main-nav a {
    min-width: 0;
    min-height: 50px;
    flex-direction: column;
    gap: 3px;
    justify-content: center;
    padding: 5px 2px;
    border-radius: var(--radius-sm);
    font-size: 10px;
  }

  .main-nav svg { width: 19px; height: 19px; }
  .main-nav a.active { background: var(--accent-soft); color: var(--accent-bright); }
  .toast { bottom: calc(82px + env(safe-area-inset-bottom)); }
  .opening-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .page-heading h1 { font-size: 43px; }
  .opening-card { min-height: 230px; grid-template-columns: 1fr 82px; gap: 14px; padding: 20px; }
  .card-visual { min-height: 145px; }
  .card-piece { font-size: 54px; }
  .line-selector-controls { flex-wrap: wrap; }
  .line-selector-controls .line-select { flex-basis: 100%; }
  .mini-action { flex: 1; }
}

@media (max-width: 420px) {
  .opening-card { grid-template-columns: 1fr 66px; padding: 18px; }
  .card-visual { min-height: 120px; }
  .card-piece { font-size: 46px; }
  .study-note-heading { align-items: flex-start; flex-direction: column; gap: 3px; }
}

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