:root {
  color-scheme: dark;
  --board-size: 720px;
  --bg: #111318;
  --panel: #181b22;
  --panel-2: #20242d;
  --panel-3: #262b35;
  --border: #2b303a;
  --text: #e6e8ee;
  --muted: #8b93a7;
  --accent: #7aa2f7;
  --accent-strong: #a8c3ff;
  --danger: #ef6b73;
  --danger-soft: rgba(239, 107, 115, 0.12);
  --square-light: #e2c993;
  --square-dark: #b37a45;
  --square-light-soft: #f0dfb5;
  --square-dark-soft: #965f32;
  --surface: var(--panel);
  --ink: var(--text);
  --line: var(--border);
  --light-square: var(--square-light);
  --dark-square: var(--square-dark);
  --dark-square-hover: #c08a51;
  --white-piece: #f8f4e8;
  --white-piece-edge: #c6b083;
  --black-piece: #20242d;
  --black-piece-edge: #080a0f;
  --button-bg: #20242d;
  --button-hover: #28313e;
  --button-active: rgba(122, 162, 247, 0.14);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
  --shadow-soft: 0 16px 42px rgba(0, 0, 0, 0.24);
  --radius: 10px;
  --radius-sm: 7px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  font: inherit;
}

.app {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

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

.topbar > div {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  max-width: min(760px, 62vw);
  margin-bottom: 0;
  overflow: hidden;
  font-size: clamp(1.8rem, 3vw, 3rem);
  line-height: 1;
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-title {
  display: block;
}

.app-subtitle {
  max-width: min(720px, 52vw);
  margin: 4px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status {
  margin: 0;
  min-width: 190px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
  text-align: center;
  font-weight: 700;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(430px, 520px);
  gap: 24px;
  align-items: start;
}

.board-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.board-toolbar {
  width: min(74vmin, 720px);
  max-width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.mode-button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.mode-button:hover:not(:disabled),
.mode-button:focus-visible,
.mode-button.active {
  border-color: var(--accent);
  color: var(--accent-strong);
  outline: none;
}

.mode-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.flying-position-controls {
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  min-width: min(100%, 520px);
}

.flying-position-label {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
  text-transform: uppercase;
}

.flying-position-select,
.book-position-select {
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-size: 0.84rem;
}

.flying-position-button {
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 850;
  white-space: nowrap;
}

.flying-position-select:focus,
.book-position-select:focus,
.flying-position-button:hover:not(:disabled),
.flying-position-button:focus-visible {
  border-color: var(--accent);
  color: var(--accent-strong);
  outline: none;
}

.board-editor-layout {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 14px;
}

.analysis-scale {
  position: relative;
  width: 22px;
  height: min(74vmin, 720px);
  min-height: 220px;
  flex: 0 0 22px;
  overflow: hidden;
  border: 1px solid #263238;
  border-radius: 7px;
  background: #263238;
  box-shadow: 0 10px 24px rgba(27, 43, 47, 0.12);
}

.analysis-scale-fill {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 50%;
  background: #f6f1e4;
  transition: height 0.2s ease;
}

.analysis-scale-fill.empty {
  background: rgba(246, 241, 228, 0.36);
}

.analysis-scale::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 0;
  left: 0;
  height: 1px;
  background: rgba(22, 121, 111, 0.75);
}

.analysis-scale-text {
  position: absolute;
  right: 50%;
  bottom: 8px;
  transform: translateX(50%) rotate(-90deg);
  transform-origin: center;
  color: var(--ink);
  font-size: 0.68rem;
  font-weight: 900;
  white-space: nowrap;
}

.board-quick-actions {
  width: min(74vmin, 720px);
  max-width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.board-save-button {
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 800;
}

.board-save-button:hover:not(:disabled),
.board-save-button:focus-visible,
.board-save-button.active {
  border-color: var(--accent);
  color: var(--accent-strong);
  outline: none;
}

.board-save-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.board-icon-button {
  width: 36px;
  min-width: 36px;
  padding: 0;
  font-size: 1rem;
}

.analysis-panel {
  width: min(74vmin, 720px);
  max-width: 100%;
  display: grid;
  gap: 9px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 12px 34px rgba(27, 43, 47, 0.08);
}

.analysis-heading,
.analysis-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.analysis-heading h2 {
  margin: 0;
  font-size: 0.96rem;
}

.analysis-thinking {
  color: var(--accent-strong);
  font-size: 0.76rem;
  font-weight: 900;
}

.analysis-grid {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 5px 10px;
  align-items: center;
}

.analysis-label {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

.analysis-value {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 0.86rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.analysis-depth-label {
  justify-self: start;
}

.analysis-depth-select {
  min-height: 28px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f7f9f8;
  color: var(--ink);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 800;
}

.analysis-depth-select:focus {
  border-color: var(--accent);
  outline: none;
}

.analysis-pv {
  min-height: 18px;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.analysis-button {
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f7f9f8;
  color: var(--ink);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 800;
}

.analysis-button.primary {
  background: #e8f4f1;
  color: var(--accent-strong);
}

.analysis-button:hover:not(:disabled),
.analysis-button:focus-visible {
  border-color: var(--accent);
  color: var(--accent-strong);
  outline: none;
}

.analysis-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.board {
  width: min(74vmin, 720px);
  max-width: 100%;
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  border: 10px solid #263238;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
  user-select: none;
  touch-action: none;
}

.board.editor-board {
  box-shadow: 0 18px 50px rgba(22, 121, 111, 0.18);
}

.square {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
}

.square.light {
  background: var(--light-square);
  --coord-color: rgba(29, 37, 40, 0.58);
}

.square.dark {
  background: var(--dark-square);
  --coord-color: rgba(255, 255, 255, 0.72);
}

.coord-label {
  position: absolute;
  z-index: 3;
  color: var(--coord-color);
  font-size: clamp(0.58rem, 1.15vw, 0.82rem);
  font-weight: 800;
  line-height: 1;
  pointer-events: none;
}

.coord-label.rank {
  top: 7%;
  left: 8%;
}

.coord-label.file {
  right: 8%;
  bottom: 7%;
}

.square.selected-square {
  background: var(--dark-square-hover);
  outline: 3px solid rgba(255, 255, 255, 0.86);
  outline-offset: -5px;
}

.square.move-target {
  cursor: pointer;
}

.editor-board .square.dark {
  cursor: crosshair;
}

.editor-board .square.light {
  cursor: not-allowed;
}

.target-marker {
  position: absolute;
  z-index: 0;
  width: 34%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.38);
  box-shadow: inset 0 0 0 2px rgba(14, 94, 86, 0.38);
}

.target-marker.capture {
  width: 48%;
  background: rgba(255, 235, 184, 0.52);
  box-shadow: inset 0 0 0 3px rgba(187, 62, 62, 0.45);
}

.piece {
  position: relative;
  z-index: 2;
  width: 72%;
  aspect-ratio: 1;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  box-shadow: 0 10px 18px rgba(13, 22, 25, 0.24);
  transition: transform 140ms ease, box-shadow 140ms ease, outline-color 140ms ease;
}

.piece:hover,
.piece:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 14px 22px rgba(13, 22, 25, 0.28);
  outline: none;
}

.piece::before {
  content: "";
  width: 64%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2px solid currentColor;
  opacity: 0.28;
}

.piece.white {
  color: #6f633f;
  background:
    radial-gradient(circle at 35% 30%, #ffffff 0 18%, var(--white-piece) 42%, var(--white-piece-edge) 100%);
  border: 2px solid #efe6ce;
}

.piece.black {
  color: #c0ccd0;
  background:
    radial-gradient(circle at 34% 28%, #4a555a 0 12%, var(--black-piece) 44%, var(--black-piece-edge) 100%);
  border: 2px solid #30393e;
}

.piece.selected {
  outline: 4px solid rgba(255, 255, 255, 0.84);
  outline-offset: 3px;
}

.piece.king::after {
  content: "★";
  position: absolute;
  color: currentColor;
  font-size: clamp(1rem, 2.3vw, 1.45rem);
  line-height: 1;
}

.editor-panel {
  width: 184px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 12px 34px rgba(27, 43, 47, 0.08);
}

.editor-panel[hidden] {
  display: none;
}

.editor-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.editor-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.piece-tools {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.tool-button,
.side-button,
.editor-action {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9f8;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.tool-button:hover,
.tool-button:focus-visible,
.tool-button.active,
.side-button:hover,
.side-button:focus-visible,
.side-button.active,
.editor-action:hover,
.editor-action:focus-visible {
  border-color: var(--accent);
  color: var(--accent-strong);
  outline: none;
}

.tool-button {
  min-height: 42px;
  display: grid;
  place-items: center;
  padding: 0;
}

.tool-piece {
  position: relative;
  width: 26px;
  aspect-ratio: 1;
  border-radius: 50%;
  box-shadow: 0 5px 10px rgba(13, 22, 25, 0.18);
}

.tool-piece.white {
  background:
    radial-gradient(circle at 35% 30%, #ffffff 0 18%, var(--white-piece) 42%, var(--white-piece-edge) 100%);
  border: 2px solid #efe6ce;
}

.tool-piece.black {
  background:
    radial-gradient(circle at 34% 28%, #4a555a 0 12%, var(--black-piece) 44%, var(--black-piece-edge) 100%);
  border: 2px solid #30393e;
}

.tool-piece.king::after {
  content: "★";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: currentColor;
  font-size: 0.78rem;
  line-height: 1;
}

.tool-piece.white.king {
  color: #6f633f;
}

.tool-piece.black.king {
  color: #c0ccd0;
}

.erase-tool {
  color: var(--danger);
  font-size: 1.35rem;
  line-height: 1;
}

.side-tools,
.editor-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.side-button,
.editor-action {
  min-height: 36px;
  padding: 0 10px;
}

.editor-action.primary {
  background: #e8f4f1;
  color: var(--accent-strong);
}

.saved-panel {
  width: min(74vmin, 720px);
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 12px 34px rgba(27, 43, 47, 0.08);
}

.saved-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.saved-heading h2 {
  margin: 0;
  font-size: 1rem;
}

.saved-count {
  min-width: 30px;
  min-height: 26px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: #e7f0ed;
  color: var(--accent-strong);
  font-weight: 800;
}

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

.saved-action {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9f8;
  color: var(--ink);
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 800;
}

.saved-action.primary {
  background: #e8f4f1;
  color: var(--accent-strong);
}

.saved-action:hover:not(:disabled),
.saved-action:focus-visible {
  border-color: var(--accent);
  color: var(--accent-strong);
  outline: none;
}

.saved-action:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.saved-list {
  max-height: 190px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-x: hidden;
  overflow-y: auto;
  padding-right: 4px;
}

.saved-position {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.saved-position.active {
  border-color: #9dc8bd;
  background: #e8f4f1;
}

.saved-position-name {
  min-width: 0;
  margin: 0 0 4px;
  overflow: hidden;
  color: var(--ink);
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.saved-position-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.saved-position-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.saved-small-action {
  min-height: 30px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 800;
}

.saved-small-action:hover,
.saved-small-action:focus-visible {
  border-color: var(--accent);
  color: var(--accent-strong);
  outline: none;
}

.saved-small-action.danger {
  color: var(--danger);
}

.saved-empty {
  margin: 0;
  color: var(--muted);
  text-align: center;
}

.moves-panel {
  height: min(74vmin, 720px);
  min-height: 420px;
  max-height: calc(100vh - 84px);
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: hidden;
}

.notation-panel,
.variant-library {
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 12px 34px rgba(27, 43, 47, 0.08);
}

.notation-panel {
  flex: 1 1 auto;
  min-height: 0;
}

.right-panel.library-open .notation-panel {
  display: flex;
}

.right-panel.library-open {
  gap: 10px;
}

.library-toggle {
  min-height: 34px;
  align-self: stretch;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9f8;
  color: var(--ink);
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 800;
  text-align: left;
}

.library-toggle:hover,
.library-toggle:focus-visible,
.library-toggle.active {
  border-color: var(--accent);
  color: var(--accent-strong);
  outline: none;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.panel-heading h2 {
  margin-bottom: 0;
  font-size: 1.18rem;
}

.current-library-title {
  max-width: 260px;
  margin: 4px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.current-library-title[hidden] {
  display: none;
}

.move-count {
  min-width: 34px;
  min-height: 28px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: #e7f0ed;
  color: var(--accent-strong);
  font-weight: 800;
}

.controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.library-actions {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 2px;
}

.library-action,
.variant-nav-button,
.variant-open-button {
  min-height: 28px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f7f9f8;
  color: var(--ink);
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 800;
}

.library-action.primary {
  background: #e8f4f1;
  color: var(--accent-strong);
}

.library-action:hover:not(:disabled),
.library-action:focus-visible,
.library-action.active,
.variant-nav-button:hover:not(:disabled),
.variant-nav-button:focus-visible,
.variant-open-button:hover,
.variant-open-button:focus-visible {
  border-color: var(--accent);
  color: var(--accent-strong);
  outline: none;
}

.library-action:disabled,
.variant-nav-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.variant-title-form {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.board-title-form {
  width: min(74vmin, 720px);
  max-width: 100%;
  margin-bottom: 0;
}

.variant-title-form[hidden] {
  display: none;
}

.variant-title-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.variant-title-input {
  min-height: 34px;
  width: 100%;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

.variant-title-input:focus {
  border-color: var(--accent);
  outline: none;
}

.variant-title-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.variant-title-button {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9f8;
  color: var(--ink);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 800;
}

.variant-title-button.primary {
  background: #e8f4f1;
  color: var(--accent-strong);
}

.variant-title-button:hover,
.variant-title-button:focus-visible {
  border-color: var(--accent);
  color: var(--accent-strong);
  outline: none;
}

.library-panel {
  flex: 1 1 360px;
  height: 100%;
  gap: 8px;
  min-height: 0;
  padding: 10px;
}

.right-panel.library-open .library-panel {
  flex: 1 1 auto;
}

.library-panel[hidden],
.library-panel.collapsed {
  display: none;
}

#variantLibraryPanel.library-panel {
  position: fixed;
  top: 72px;
  right: 24px;
  bottom: 24px;
  z-index: 24;
  width: min(430px, calc(100vw - 32px));
  height: auto;
  max-height: calc(100vh - 96px);
  box-shadow: 0 24px 70px rgba(27, 43, 47, 0.2);
}

.variant-library-heading {
  flex: 0 0 auto;
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.variant-library-heading > div {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.variant-library-heading h3 {
  margin: 0;
  font-size: 0.9rem;
}

.variant-count {
  min-width: 24px;
  min-height: 20px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: #e7f0ed;
  color: var(--accent-strong);
  font-size: 0.76rem;
  font-weight: 800;
}

.library-density-toggle {
  width: 28px;
  min-width: 28px;
  min-height: 26px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f7f9f8;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 900;
}

.library-density-toggle:hover,
.library-density-toggle:focus-visible,
.library-density-toggle.active {
  border-color: var(--accent);
  background: #e8f4f1;
  color: var(--accent-strong);
  outline: none;
}

.variant-nav {
  display: flex;
  gap: 6px;
}

.library-folder-tabs {
  flex: 0 0 auto;
  min-height: 30px;
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 1px;
}

.library-folder-tab {
  min-height: 28px;
  max-width: 132px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f7f9f8;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 800;
  white-space: nowrap;
}

.library-folder-tab:hover,
.library-folder-tab:focus-visible,
.library-folder-tab.active {
  border-color: var(--accent);
  background: #e8f4f1;
  color: var(--accent-strong);
  outline: none;
}

.library-folder-tab.add-folder {
  width: 28px;
  min-width: 28px;
  justify-content: center;
  padding: 0;
  font-size: 0.94rem;
}

.library-folder-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.library-folder-count {
  min-width: 18px;
  min-height: 18px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(22, 121, 111, 0.1);
  color: inherit;
  font-size: 0.66rem;
}

.library-folder-tab-actions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.library-folder-tab:hover .library-folder-tab-actions,
.library-folder-tab:focus-within .library-folder-tab-actions {
  opacity: 1;
}

.library-folder-inline-action {
  min-width: 18px;
  min-height: 18px;
  display: inline-grid;
  place-items: center;
  border-radius: 5px;
  color: var(--muted);
  font-size: 0.78rem;
}

.library-folder-inline-action:hover {
  background: rgba(22, 121, 111, 0.12);
  color: var(--accent-strong);
}

.variant-library-body {
  min-height: 0;
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 6px;
}

.variant-library-body[hidden] {
  display: none;
}

.variant-library-list {
  min-height: 0;
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding-right: 2px;
}

.library-search-input {
  width: 100%;
  min-height: 28px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfb;
  color: var(--ink);
  font: inherit;
  font-size: 0.78rem;
}

.library-search-input:focus {
  border-color: var(--accent);
  outline: none;
}

.library-folder {
  display: grid;
  gap: 8px;
}

.library-folder-toggle {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9f8;
  color: var(--ink);
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 800;
  text-align: left;
}

.library-folder-toggle:hover,
.library-folder-toggle:focus-visible {
  border-color: var(--accent);
  color: var(--accent-strong);
  outline: none;
}

.library-folder-list {
  display: grid;
  gap: 8px;
  padding-left: 8px;
}

.library-folder-list[hidden] {
  display: none;
}

.variant-library-item {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) 62px;
  gap: 6px;
  align-items: center;
  min-height: 30px;
  padding: 3px 6px;
  border: 0;
  border-bottom: 1px solid rgba(214, 222, 217, 0.82);
  border-radius: 0;
  background: var(--surface);
  cursor: pointer;
  line-height: 1.1;
}

.variant-library-item:hover {
  background: #f4f8f6;
}

.variant-library-item.active {
  background: #e8f4f1;
}

.variant-library-icon {
  color: #6f807f;
  font-size: 0.76rem;
  text-align: center;
}

.variant-library-info {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.variant-library-name {
  min-width: 0;
  max-width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  overflow: hidden;
  display: block;
  font-size: 0.8rem;
  font-weight: 800;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.variant-library-name:hover,
.variant-library-name:focus-visible {
  color: var(--accent-strong);
  outline: none;
}

.variant-library-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.variant-library-comment {
  display: -webkit-box;
  margin: 3px 0 0;
  overflow: hidden;
  color: #607074;
  font-size: 0.72rem;
  line-height: 1.3;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
}

.variant-library-comment[hidden] {
  display: none;
}

.library-item-actions {
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-end;
  gap: 2px;
  width: 62px;
  min-width: 62px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.variant-library-item:hover .library-item-actions,
.variant-library-item:focus-within .library-item-actions {
  opacity: 1;
  pointer-events: auto;
}

.variant-open-button {
  width: 18px;
  min-width: 18px;
  height: 18px;
  min-height: 18px;
  padding: 0;
  border-radius: 5px;
  font-size: 0.72rem;
  line-height: 1;
}

.variant-open-button.danger {
  color: #9b3931;
}

.variant-open-button.danger:hover,
.variant-open-button.danger:focus-visible {
  border-color: #c98b84;
  color: #822a24;
}

.variant-library-empty {
  margin: 4px 0 0;
  color: var(--muted);
  text-align: center;
}

.variant-library.compact .variant-library-item {
  height: 28px;
  min-height: 28px;
  padding: 2px 6px;
}

.variant-library.compact .variant-library-comment {
  display: none;
}

.control-button {
  width: 42px;
  min-width: 42px;
  min-height: 42px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9f8;
  color: var(--ink);
  cursor: pointer;
  font-size: 1.22rem;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.control-button:hover:not(:disabled),
.control-button:focus-visible {
  border-color: var(--accent);
  color: var(--accent-strong);
  outline: none;
}

.control-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.reset-button {
  color: var(--danger);
}

.move-list {
  min-height: 0;
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
  margin: 0;
  padding: 4px 6px 12px 2px;
}

.variation-tree {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.variation-block {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.main-line,
.variation-line {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  line-height: 1.45;
}

.main-line {
  color: var(--ink);
}

.variation-line {
  color: #657478;
  font-size: 0.9rem;
}

.variation-branches {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.variation-branch-group {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-left: min(calc(var(--branch-depth) * 16px), 72px);
  padding-left: 10px;
  border-left: 2px solid #dce4df;
}

.side-variation {
  padding: 8px 10px;
  border-radius: 8px;
  background: #f6f8f7;
}

.side-variation .variation-line::before,
.side-variation .variation-line::after {
  color: #8a989b;
  font-weight: 800;
}

.side-variation .variation-line::before {
  content: "(";
}

.side-variation .variation-line::after {
  content: ")";
}

.move-turn {
  max-width: 100%;
  min-height: 32px;
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.move {
  max-width: 100%;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 3px 6px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 0.94rem;
  font-weight: 750;
  line-height: 1.1;
  white-space: normal;
  overflow-wrap: anywhere;
}

.variation-line .move {
  font-size: 0.88rem;
}

.move:hover:not(:disabled),
.move:focus-visible {
  border-color: #b7cac3;
  background: #eef5f2;
  color: var(--accent-strong);
  outline: none;
}

.move.active {
  border-color: #9dc8bd;
  background: #e8f4f1;
  color: var(--accent-strong);
  box-shadow: 0 0 0 2px rgba(22, 121, 111, 0.12);
  font-weight: 800;
}

.move.line:not(.active) {
  color: var(--accent-strong);
}

.move:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.move-index {
  flex: 0 0 auto;
  color: var(--muted);
  font-weight: 800;
}

.variation-line .move-index {
  color: #7b898d;
}

.move-comment {
  max-width: 100%;
  color: #68777a;
  font-size: 0.84rem;
  font-style: italic;
  font-weight: 650;
  line-height: 1.25;
  overflow-wrap: anywhere;
  white-space: normal;
}

.move-comment-before {
  color: #5f7372;
}

.move-comment-after {
  color: #738083;
}

.move-context-menu,
.library-context-menu {
  position: fixed;
  z-index: 30;
  min-width: 250px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 16px 36px rgba(25, 40, 45, 0.18);
}

.move-context-menu[hidden],
.library-context-menu[hidden] {
  display: none;
}

.move-context-action,
.library-context-action {
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 800;
  text-align: left;
}

.move-context-action:hover:not(:disabled),
.move-context-action:focus-visible,
.library-context-action:hover:not(:disabled),
.library-context-action:focus-visible {
  background: #eef5f2;
  color: var(--accent-strong);
  outline: none;
}

.move-context-action.danger,
.library-context-action.danger {
  color: var(--danger);
}

.move-context-action:disabled,
.library-context-action:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.move-context-confirm {
  margin: 2px 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.25;
}

.move-context-confirm[hidden] {
  display: none;
}

.comment-dialog,
.position-save-dialog {
  position: fixed;
  inset: 0;
  z-index: 28;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(29, 37, 40, 0.22);
}

.comment-dialog[hidden],
.position-save-dialog[hidden] {
  display: none;
}

.comment-dialog-card,
.position-save-card {
  width: min(420px, 100%);
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 18px 44px rgba(25, 40, 45, 0.22);
}

.position-save-card {
  width: min(480px, 100%);
}

.position-save-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.position-save-heading h2 {
  margin: 0;
  font-size: 1.08rem;
}

.position-save-close {
  width: 32px;
  min-width: 32px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9f8;
  color: var(--ink);
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: 800;
}

.position-save-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.position-save-input,
.position-save-select,
.position-save-textarea {
  width: 100%;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  color: var(--ink);
  font: inherit;
  text-transform: none;
}

.position-save-input,
.position-save-select {
  min-height: 36px;
}

.position-save-textarea {
  min-height: 96px;
  padding-top: 10px;
  resize: vertical;
  line-height: 1.35;
}

.position-save-input:focus,
.position-save-select:focus,
.position-save-textarea:focus,
.position-save-close:hover,
.position-save-close:focus-visible {
  border-color: var(--accent);
  color: var(--accent-strong);
  outline: none;
}

.position-save-update {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 700;
}

.position-save-update[hidden] {
  display: none;
}

.position-save-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.position-save-button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9f8;
  color: var(--ink);
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 800;
}

.position-save-button.primary {
  background: #e8f4f1;
  color: var(--accent-strong);
}

.position-save-button:hover,
.position-save-button:focus-visible {
  border-color: var(--accent);
  color: var(--accent-strong);
  outline: none;
}

.comment-dialog-title {
  color: var(--ink);
  font-weight: 800;
}

.comment-input {
  min-height: 120px;
  resize: vertical;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  color: var(--ink);
  font: inherit;
  line-height: 1.35;
}

.comment-input:focus {
  border-color: var(--accent);
  outline: none;
}

.comment-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.comment-dialog-button {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9f8;
  color: var(--ink);
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 800;
}

.comment-dialog-button.primary {
  background: #e8f4f1;
  color: var(--accent-strong);
}

.comment-dialog-button:hover,
.comment-dialog-button:focus-visible {
  border-color: var(--accent);
  color: var(--accent-strong);
  outline: none;
}

.pdn-import-dialog {
  position: fixed;
  inset: 0;
  z-index: 29;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(29, 37, 40, 0.24);
}

.pdn-import-dialog[hidden] {
  display: none;
}

.pdn-import-card {
  width: min(680px, 100%);
  max-height: min(86vh, 760px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 20px 54px rgba(25, 40, 45, 0.24);
}

.pdn-import-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.pdn-import-heading h2 {
  margin: 0;
  font-size: 1.08rem;
}

.pdn-import-close {
  width: 34px;
  min-width: 34px;
  min-height: 34px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9f8;
  color: var(--ink);
  cursor: pointer;
  font-size: 1.2rem;
  font-weight: 800;
  line-height: 1;
}

.pdn-import-label,
.pdn-import-field,
.pdn-import-file {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.pdn-import-text {
  min-height: 220px;
  resize: vertical;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  color: var(--ink);
  font: 0.9rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  line-height: 1.45;
}

.pdn-import-options {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}

.pdn-import-field,
.pdn-import-file {
  display: grid;
  gap: 6px;
}

.pdn-import-select,
.pdn-import-file input {
  min-height: 34px;
  width: 100%;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9f8;
  color: var(--ink);
  font: inherit;
}

.pdn-import-note,
.pdn-import-preview,
.pdn-import-error {
  margin: 0;
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.35;
}

.pdn-import-note {
  background: #f6f8f7;
  color: var(--muted);
}

.pdn-import-preview {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  background: #e8f4f1;
  color: var(--accent-strong);
}

.pdn-import-summary {
  margin-bottom: 8px;
}

.pdn-import-debug {
  margin: 0 0 8px;
  padding: 8px;
  border-radius: 6px;
  background: rgba(44, 62, 80, 0.08);
  color: var(--muted);
  white-space: pre-wrap;
}

.pdn-game-preview {
  display: grid;
  gap: 8px;
  padding: 9px;
  border: 1px solid rgba(49, 130, 115, 0.24);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
}

.pdn-game-preview + .pdn-game-preview {
  margin-top: 8px;
}

.pdn-game-preview.has-error {
  border-color: rgba(179, 48, 48, 0.32);
  background: rgba(255, 240, 240, 0.76);
}

.pdn-game-preview-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pdn-game-preview-details {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 4px 8px;
  margin: 0;
}

.pdn-game-preview-details dt {
  color: var(--muted);
}

.pdn-game-preview-details dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.pdn-game-preview-warnings {
  margin: 0;
  padding-left: 18px;
  color: #8a6519;
}

.pdn-game-preview-errors pre {
  margin: 0;
  padding: 8px;
  overflow-x: auto;
  border-radius: 6px;
  background: rgba(179, 48, 48, 0.1);
  color: var(--danger);
  white-space: pre-wrap;
}

.pdn-import-error {
  background: #fff0f0;
  color: var(--danger);
}

.pdn-import-actions {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.pdn-import-button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9f8;
  color: var(--ink);
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 800;
}

.pdn-import-button.primary {
  background: #e8f4f1;
  color: var(--accent-strong);
}

.pdn-import-close:hover,
.pdn-import-close:focus-visible,
.pdn-import-button:hover,
.pdn-import-button:focus-visible,
.pdn-import-select:focus,
.pdn-import-text:focus {
  border-color: var(--accent);
  color: var(--accent-strong);
  outline: none;
}

.empty-state {
  margin: 22px 0 0;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 900px) {
  .app {
    width: min(100% - 20px, 760px);
    padding: 18px 0;
  }

  .topbar {
    align-items: start;
    flex-direction: column;
    gap: 12px;
  }

  .status {
    width: 100%;
  }

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

  .board {
    width: min(94vw, 680px);
  }

	  .board-toolbar {
	    width: min(94vw, 680px);
	  }

	  .board-quick-actions,
	  .book-playback-actions,
	  .board-title-form,
	  .analysis-panel {
	    width: min(94vw, 680px);
	  }

	  .analysis-scale {
	    display: none;
	  }

  .saved-panel {
    width: min(94vw, 680px);
  }

  .board-editor-layout {
    flex-direction: column;
    align-items: center;
  }

  .editor-panel {
    width: min(94vw, 680px);
  }

  .piece-tools {
    grid-template-columns: repeat(5, minmax(42px, 1fr));
  }

  .side-tools,
  .editor-actions {
    flex-direction: row;
    flex-wrap: wrap;
  }

	  .moves-panel {
	    height: auto;
	    min-height: 0;
	    max-height: none;
	  }

	  .notation-panel {
	    min-height: 320px;
	    max-height: 480px;
	  }

	  .variant-library {
	    flex-basis: auto;
	    max-height: 320px;
	  }

	  .library-toggle {
	    width: 100%;
	  }

	  .pdn-import-options {
	    grid-template-columns: 1fr;
	  }
	}

@media (max-width: 480px) {
  .controls {
    justify-content: center;
  }

  .variation-branch-group {
    margin-left: min(calc(var(--branch-depth) * 10px), 42px);
  }

  .saved-position {
    grid-template-columns: 1fr;
  }

  .saved-position-actions {
    justify-content: flex-start;
  }
}

/* Unified dark analyzer interface */
html {
  background: var(--bg);
}

body {
  background:
    radial-gradient(circle at 18% -10%, rgba(122, 162, 247, 0.12), transparent 34rem),
    linear-gradient(180deg, #151821 0%, var(--bg) 42%);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  transition:
    background-color 0.16s ease,
    border-color 0.16s ease,
    color 0.16s ease,
    box-shadow 0.16s ease,
    transform 0.16s ease;
}

button:not(:disabled):active {
  transform: translateY(1px);
}

::selection {
  background: rgba(122, 162, 247, 0.28);
  color: var(--text);
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.03);
}

::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: #3a414f;
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background: #465166;
  background-clip: padding-box;
}

.app {
  width: min(1380px, calc(100% - 36px));
  padding: 18px 0 24px;
}

.topbar {
  min-height: 58px;
  align-items: center;
  margin-bottom: 12px;
  padding: 9px 12px;
  border: 1px solid rgba(122, 162, 247, 0.12);
  border-radius: var(--radius);
  background: rgba(24, 27, 34, 0.92);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(12px);
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.eyebrow {
  color: var(--accent);
  letter-spacing: 0;
}

h1 {
  max-width: min(720px, 52vw);
  color: var(--text);
  font-size: clamp(1.1rem, 1.9vw, 1.55rem);
  font-weight: 850;
}

.status {
  min-height: 30px;
  min-width: 120px;
  padding: 5px 9px;
  border-color: var(--border);
  background: var(--panel-2);
  color: var(--muted);
  font-size: 0.82rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.workspace {
  grid-template-columns: minmax(520px, 1fr) minmax(390px, 520px);
  gap: 18px;
  align-items: start;
}

.board-area {
  min-width: 0;
  gap: 10px;
}

.board-toolbar,
.board-quick-actions,
.board-title-form {
  width: min(74vmin, 720px);
}

.board-toolbar {
  justify-content: space-between;
}

.board-editor-layout {
  gap: 10px;
}

.button,
.icon-button,
.button-primary,
.button-danger,
.button-ghost,
.mode-button,
.board-save-button,
.control-button,
.analysis-button,
.library-toggle,
.library-action,
.variant-nav-button,
.variant-open-button,
.tool-button,
.side-button,
.editor-action,
.library-density-toggle,
.library-folder-tab,
.library-folder-toggle,
.variant-title-button,
.position-save-button,
.comment-dialog-button,
.pdn-import-button,
.position-save-close,
.pdn-import-close {
  border-color: var(--border);
  background: var(--button-bg);
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

.button,
.mode-button,
.board-save-button,
.analysis-button,
.library-toggle,
.library-action,
.variant-nav-button,
.variant-title-button,
.position-save-button,
.comment-dialog-button,
.pdn-import-button {
  min-height: 32px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 800;
}

.icon-button,
.board-icon-button,
.control-button,
.library-density-toggle,
.position-save-close,
.pdn-import-close {
  width: 34px;
  min-width: 34px;
  min-height: 34px;
  border-radius: var(--radius-sm);
}

.button-primary,
.analysis-button.primary,
.editor-action.primary,
.library-action.primary,
.variant-title-button.primary,
.position-save-button.primary,
.comment-dialog-button.primary,
.pdn-import-button.primary {
  border-color: rgba(122, 162, 247, 0.34);
  background: linear-gradient(180deg, rgba(122, 162, 247, 0.24), rgba(122, 162, 247, 0.13));
  color: var(--accent-strong);
}

.button-danger,
.reset-button,
.erase-tool,
.saved-small-action.danger,
.variant-open-button.danger,
.move-context-action.danger,
.library-context-action.danger {
  color: var(--danger);
}

.button-ghost {
  background: transparent;
}

.mode-button:hover:not(:disabled),
.mode-button:focus-visible,
.mode-button.active,
.board-save-button:hover:not(:disabled),
.board-save-button:focus-visible,
.board-save-button.active,
.control-button:hover:not(:disabled),
.control-button:focus-visible,
.analysis-button:hover:not(:disabled),
.analysis-button:focus-visible,
.library-toggle:hover,
.library-toggle:focus-visible,
.library-toggle.active,
.library-action:hover:not(:disabled),
.library-action:focus-visible,
.library-action.active,
.variant-nav-button:hover:not(:disabled),
.variant-nav-button:focus-visible,
.variant-open-button:hover,
.variant-open-button:focus-visible,
.tool-button:hover,
.tool-button:focus-visible,
.tool-button.active,
.side-button:hover,
.side-button:focus-visible,
.side-button.active,
.editor-action:hover,
.editor-action:focus-visible,
.library-density-toggle:hover,
.library-density-toggle:focus-visible,
.library-density-toggle.active,
.library-folder-tab:hover,
.library-folder-tab:focus-visible,
.library-folder-tab.active,
.library-folder-toggle:hover,
.library-folder-toggle:focus-visible,
.position-save-button:hover,
.position-save-button:focus-visible,
.comment-dialog-button:hover,
.comment-dialog-button:focus-visible,
.pdn-import-button:hover,
.pdn-import-button:focus-visible,
.position-save-close:hover,
.position-save-close:focus-visible,
.pdn-import-close:hover,
.pdn-import-close:focus-visible {
  border-color: rgba(122, 162, 247, 0.58);
  background: var(--button-hover);
  color: var(--accent-strong);
  box-shadow: 0 0 0 3px rgba(122, 162, 247, 0.08);
  outline: none;
}

.mode-button:disabled,
.board-save-button:disabled,
.control-button:disabled,
.analysis-button:disabled,
.library-action:disabled,
.variant-nav-button:disabled,
.move:disabled,
.move-context-action:disabled,
.library-context-action:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.topbar .library-toggle {
  width: auto;
  min-width: 130px;
  align-self: auto;
  text-align: center;
}

.board-quick-actions {
  justify-content: center;
  gap: 7px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(24, 27, 34, 0.7);
}

.board-save-button {
  padding: 0 10px;
}

.control-button {
  width: 34px;
  min-width: 34px;
  min-height: 34px;
  font-size: 1rem;
}

#goToStartButton,
#goToEndButton {
  width: auto;
  min-width: 82px;
  padding: 0 10px;
  font-size: 0.78rem;
  line-height: 1;
  white-space: nowrap;
}

.analysis-scale {
  width: 20px;
  height: min(74vmin, 720px);
  flex-basis: 20px;
  border-color: var(--border);
  background: linear-gradient(180deg, #171a21 0%, #0d0f13 100%);
  box-shadow: var(--shadow-soft);
}

.analysis-scale-fill {
  background: linear-gradient(180deg, #f2ead8 0%, #b9a98b 100%);
}

.analysis-scale-fill.empty {
  background: rgba(185, 169, 139, 0.36);
}

.analysis-scale::after {
  background: rgba(122, 162, 247, 0.62);
}

.analysis-scale-text {
  color: #0e1117;
}

.analysis-panel,
.notation-panel,
.variant-library,
.editor-panel,
.saved-panel {
  border-color: var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  box-shadow: var(--shadow-soft);
}

.analysis-panel {
  gap: 8px;
  padding: 12px;
}

.right-panel .analysis-panel {
  width: auto;
  max-width: none;
  flex: 0 0 auto;
  gap: 7px;
  padding: 10px;
  border-radius: 9px;
  background: linear-gradient(180deg, #1d222c, #171b22);
}

.right-panel.library-open .analysis-panel {
  display: none;
}

.right-panel .analysis-heading h2 {
  font-size: 0.92rem;
}

.right-panel .analysis-grid {
  grid-template-columns: auto minmax(0, 1fr);
  gap: 4px 8px;
}

.right-panel .analysis-label {
  font-size: 0.68rem;
}

.right-panel .analysis-value,
.right-panel .analysis-pv {
  font-size: 0.78rem;
}

.right-panel .analysis-depth-select {
  min-height: 26px;
  padding: 0 7px;
  font-size: 0.76rem;
}

.right-panel .analysis-button {
  min-height: 28px;
  padding: 0 8px;
  font-size: 0.76rem;
}

.analysis-heading h2,
.panel-heading h2,
.variant-library-heading h3,
.saved-heading h2,
.position-save-heading h2,
.pdn-import-heading h2 {
  color: var(--text);
  letter-spacing: 0;
}

.analysis-label,
.editor-label,
.variant-title-label,
.position-save-field,
.pdn-import-label,
.pdn-import-field,
.pdn-import-file {
  color: var(--muted);
  letter-spacing: 0;
}

.analysis-value,
.analysis-pv,
.current-library-title,
.empty-state,
.variant-library-empty,
.move-count,
.variant-count {
  color: var(--muted);
}

.analysis-depth-select,
.library-search-input,
.variant-title-input,
.position-save-input,
.position-save-select,
.position-save-textarea,
.comment-input,
.pdn-import-text,
.pdn-import-select,
.pdn-import-file input {
  border-color: var(--border);
  background: #12151b;
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025);
}

.analysis-depth-select:focus,
.library-search-input:focus,
.variant-title-input:focus,
.position-save-input:focus,
.position-save-select:focus,
.position-save-textarea:focus,
.comment-input:focus,
.pdn-import-select:focus,
.pdn-import-text:focus {
  border-color: rgba(122, 162, 247, 0.7);
  color: var(--text);
  outline: none;
  box-shadow: 0 0 0 3px rgba(122, 162, 247, 0.1);
}

.board {
  width: min(74vmin, 720px);
  border: 10px solid #6d4b2e;
  border-radius: 8px;
  background: #6d4b2e;
  box-shadow:
    0 24px 58px rgba(0, 0, 0, 0.38),
    inset 0 0 0 1px rgba(255, 236, 194, 0.28);
}

.board.editor-board {
  box-shadow:
    0 24px 58px rgba(0, 0, 0, 0.38),
    0 0 0 3px rgba(122, 162, 247, 0.18),
    inset 0 0 0 1px rgba(255, 236, 194, 0.28);
}

.square {
  transition: none;
}

.square.light {
  background:
    linear-gradient(135deg, rgba(255, 248, 220, 0.32), transparent 46%),
    linear-gradient(45deg, var(--square-light-soft), var(--square-light));
  --coord-color: rgba(56, 35, 18, 0.62);
}

.square.dark {
  background:
    linear-gradient(135deg, rgba(255, 217, 150, 0.18), transparent 48%),
    linear-gradient(45deg, var(--square-dark), var(--square-dark-soft));
  --coord-color: rgba(255, 238, 205, 0.78);
}

.square.selected-square {
  background:
    linear-gradient(135deg, rgba(255, 217, 150, 0.24), transparent 48%),
    linear-gradient(45deg, #c38b52, #9c6538);
  outline: 3px solid rgba(122, 162, 247, 0.76);
  outline-offset: -6px;
}

.coord-label {
  font-size: clamp(0.58rem, 1.15vw, 0.82rem);
  text-shadow: none;
}

.target-marker {
  display: block;
  width: 30%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(122, 162, 247, 0.55);
  box-shadow:
    0 0 0 5px rgba(122, 162, 247, 0.12),
    inset 0 0 0 1px rgba(255, 255, 255, 0.28);
}

.target-marker.capture {
  display: block;
  width: 52%;
  background: transparent;
  border: 3px solid rgba(239, 107, 115, 0.72);
  box-shadow:
    0 0 0 5px rgba(239, 107, 115, 0.12),
    inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.piece {
  width: 72%;
  box-shadow:
    0 12px 20px rgba(35, 21, 10, 0.26),
    inset 0 2px 4px rgba(255, 255, 255, 0.22),
    inset 0 -5px 10px rgba(0, 0, 0, 0.16);
  transition: transform 140ms ease, box-shadow 140ms ease, outline-color 140ms ease;
}

.piece:hover,
.piece:focus-visible {
  transform: translateY(-1px);
  box-shadow:
    0 15px 24px rgba(35, 21, 10, 0.3),
    0 0 0 3px rgba(122, 162, 247, 0.18),
    inset 0 2px 4px rgba(255, 255, 255, 0.22),
    inset 0 -5px 10px rgba(0, 0, 0, 0.16);
  outline: none;
}

.piece.white {
  color: #7a6236;
  border: 2px solid #f3ead3;
  background:
    radial-gradient(circle at 35% 30%, #fffdf5 0 17%, var(--white-piece) 44%, var(--white-piece-edge) 100%);
}

.piece.black {
  color: #c8d0dd;
  border: 2px solid #343b48;
  background:
    radial-gradient(circle at 34% 28%, #4d5667 0 12%, var(--black-piece) 46%, var(--black-piece-edge) 100%);
}

.piece.selected {
  outline: 4px solid rgba(122, 162, 247, 0.85);
  outline-offset: 3px;
}

.piece.king::after,
.tool-piece.king::after {
  content: "★";
}

.tool-piece.white,
.piece.white {
  --piece-glow: transparent;
}

.tool-piece.black,
.piece.black {
  --piece-glow: transparent;
}

.piece-tools {
  gap: 8px;
}

.tool-piece.white {
  background:
    radial-gradient(circle at 35% 30%, #ffffff 0 18%, var(--white-piece) 42%, var(--white-piece-edge) 100%);
}

.tool-piece.black {
  background:
    radial-gradient(circle at 34% 28%, #4a555a 0 12%, var(--black-piece) 44%, var(--black-piece-edge) 100%);
}

.moves-panel {
  height: min(70vmin, 680px);
  min-height: 430px;
  max-height: calc(100vh - 112px);
  gap: 10px;
}

.right-panel.library-open {
  gap: 0;
}

.right-panel.library-open .library-panel {
  height: 100%;
}

.panel-heading {
  margin-bottom: 10px;
}

.move-count,
.variant-count,
.saved-count {
  background: rgba(122, 162, 247, 0.13);
  color: var(--accent-strong);
}

.move-list {
  padding: 3px 4px 12px 0;
}

.variation-tree {
  gap: 8px;
}

.variation-block {
  gap: 6px;
}

.main-line {
  color: var(--text);
}

.variation-line {
  color: #a0a9bb;
}

.variation-branch-group {
  gap: 6px;
  margin-left: min(calc(var(--branch-depth) * 12px), 56px);
  border-left-color: rgba(122, 162, 247, 0.2);
}

.side-variation {
  padding: 4px 0 4px 10px;
  border-radius: 0;
  background: transparent;
}

.side-variation .variation-line::before,
.side-variation .variation-line::after {
  color: #788397;
}

.move {
  border-radius: 6px;
  color: inherit;
}

.move:hover:not(:disabled),
.move:focus-visible {
  border-color: rgba(122, 162, 247, 0.35);
  background: rgba(122, 162, 247, 0.13);
  color: var(--accent-strong);
}

.move.active {
  border-color: rgba(122, 162, 247, 0.68);
  background: rgba(122, 162, 247, 0.18);
  color: var(--accent-strong);
  box-shadow: 0 0 0 2px rgba(122, 162, 247, 0.12);
}

.move.line:not(.active) {
  color: var(--accent-strong);
}

.move-comment {
  color: #7f8aa1;
}

.move-comment-before {
  color: #90a0bc;
}

.move-comment-after {
  color: #7b8598;
}

.library-panel {
  padding: 10px;
}

.variant-library-heading {
  padding-bottom: 2px;
}

.library-folder-tabs {
  min-height: 28px;
}

.library-folder-tab {
  min-height: 26px;
  border-radius: 6px;
  background: #1d2129;
  color: var(--muted);
}

.library-folder-tab:hover,
.library-folder-tab:focus-visible,
.library-folder-tab.active {
  background: rgba(122, 162, 247, 0.14);
  color: var(--accent-strong);
}

.library-folder-count {
  background: rgba(255, 255, 255, 0.07);
}

.library-folder-inline-action:hover {
  background: rgba(122, 162, 247, 0.14);
  color: var(--accent-strong);
}

.variant-library-body {
  gap: 6px;
}

.variant-library-list {
  padding-right: 3px;
}

.variant-library-item {
  grid-template-columns: 16px minmax(0, 1fr) 62px;
  height: 29px;
  min-height: 29px;
  padding: 2px 6px;
  border-bottom-color: rgba(255, 255, 255, 0.06);
  background: transparent;
}

.variant-library.compact .variant-library-item {
  height: 27px;
  min-height: 27px;
}

.variant-library-item:hover {
  background: rgba(122, 162, 247, 0.1);
}

.variant-library-item.active {
  background: rgba(122, 162, 247, 0.16);
}

.variant-library-icon {
  color: #7f8aa1;
}

.variant-library-name {
  color: var(--text);
  font-size: 0.79rem;
}

.variant-library-name:hover,
.variant-library-name:focus-visible {
  color: var(--accent-strong);
}

.variant-library-meta {
  color: var(--muted);
}

.variant-library-comment {
  color: #7b8598;
}

.variant-open-button {
  background: transparent;
  color: var(--muted);
  opacity: 0.84;
}

.variant-open-button.danger {
  color: var(--danger);
}

.variant-open-button.danger:hover,
.variant-open-button.danger:focus-visible {
  border-color: rgba(239, 107, 115, 0.5);
  background: var(--danger-soft);
  color: #ff9aa0;
}

.move-context-menu,
.library-context-menu {
  min-width: 240px;
  border-color: var(--border);
  border-radius: var(--radius-sm);
  background: #171a21;
  box-shadow: 0 22px 54px rgba(0, 0, 0, 0.48);
  animation: menu-pop 0.12s ease-out;
}

.move-context-action,
.library-context-action {
  min-height: 30px;
  color: var(--text);
}

.move-context-action:hover:not(:disabled),
.move-context-action:focus-visible,
.library-context-action:hover:not(:disabled),
.library-context-action:focus-visible {
  background: rgba(122, 162, 247, 0.12);
  color: var(--accent-strong);
}

.move-context-confirm {
  color: var(--muted);
}

.comment-dialog,
.position-save-dialog,
.pdn-import-dialog {
  background: rgba(8, 10, 14, 0.72);
  backdrop-filter: blur(8px);
}

.comment-dialog-card,
.position-save-card,
.pdn-import-card {
  border-color: var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  box-shadow: 0 28px 76px rgba(0, 0, 0, 0.54);
}

.position-save-close,
.pdn-import-close {
  color: var(--muted);
}

.position-save-update,
.comment-dialog-title {
  color: var(--text);
}

.pdn-import-note {
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
}

.pdn-import-preview {
  background: rgba(122, 162, 247, 0.12);
  color: var(--accent-strong);
}

.pdn-import-actions {
  border-top-color: var(--border);
  background: var(--panel);
}

.pdn-import-debug {
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
}

.pdn-game-preview {
  border-color: rgba(122, 162, 247, 0.22);
  background: rgba(255, 255, 255, 0.04);
}

.pdn-game-preview.has-error {
  border-color: rgba(255, 154, 160, 0.34);
  background: rgba(255, 154, 160, 0.08);
}

.pdn-game-preview-warnings {
  color: #f5d38b;
}

.pdn-import-error {
  background: var(--danger-soft);
  color: #ff9aa0;
}

.saved-position,
.variant-title-form {
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.035);
}

.saved-position.active {
  border-color: rgba(122, 162, 247, 0.45);
  background: rgba(122, 162, 247, 0.12);
}

.saved-position-name {
  color: var(--text);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.app-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  overflow: hidden;
  padding: 18px 14px;
  border-right: 1px solid var(--border);
  background: rgba(17, 19, 24, 0.96);
  box-shadow: 12px 0 36px rgba(0, 0, 0, 0.18);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 8px;
}

.sidebar-brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(122, 162, 247, 0.34);
  border-radius: 8px;
  background: rgba(122, 162, 247, 0.14);
  color: var(--accent-strong);
  font-weight: 900;
}

.sidebar-brand-text {
  min-width: 0;
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 900;
  line-height: 1.1;
}

.sidebar-nav {
  display: grid;
  gap: 8px;
}

.sidebar-nav-item {
  min-height: 42px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 850;
  text-align: left;
}

.sidebar-nav-item:hover,
.sidebar-nav-item:focus-visible {
  border-color: rgba(122, 162, 247, 0.3);
  background: rgba(122, 162, 247, 0.1);
  color: var(--accent-strong);
  outline: none;
}

.sidebar-nav-item.active {
  border-color: rgba(122, 162, 247, 0.48);
  background: rgba(122, 162, 247, 0.16);
  color: var(--accent-strong);
  box-shadow: inset 3px 0 0 var(--accent);
}

.sidebar-library {
  min-height: 0;
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 9px;
  overflow: hidden;
}

.sidebar-library[hidden] {
  display: none;
}

.sidebar-library-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sidebar-library-heading h2 {
  margin: 0;
  color: var(--text);
  font-size: 0.92rem;
}

.sidebar-library-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

.sidebar-library-actions .library-action,
.sidebar-library > .library-action {
  width: 100%;
  justify-content: center;
}

.sidebar-library-field {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.sidebar-library .library-folder-tabs {
  flex-wrap: wrap;
  max-height: 104px;
  overflow-y: auto;
}

.sidebar-library .library-folder-tab {
  max-width: 100%;
}

.sidebar-library-list {
  flex: 1;
  min-height: 120px;
  padding-right: 3px;
}

.position-card-info {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid rgba(122, 162, 247, 0.14);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.035);
}

.position-card-field {
  display: grid;
  gap: 3px;
}

.position-card-field span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 850;
  text-transform: uppercase;
}

.position-card-field strong {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 0.86rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.position-card-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.position-card-stats span {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(122, 162, 247, 0.11);
  color: var(--accent-strong);
  font-size: 0.74rem;
  font-weight: 850;
}

.position-card-comment {
  margin: 0;
  color: #9aa7bd;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.35;
  white-space: pre-wrap;
}

.position-card-comment[hidden] {
  display: none;
}

.analysis-view .analysis-scale {
  display: none;
}

.analysis-view .board-toolbar {
  display: flex;
}

.analysis-view .board-editor-layout {
  gap: 0;
}

.analysis-view .board-quick-actions {
  justify-content: center;
  gap: 6px;
}

.control-text-button {
  width: auto;
  min-width: 86px;
  padding: 0 12px;
  font-size: 0.84rem;
}

.board-quick-actions .board-icon-button {
  width: 42px;
  min-width: 42px;
  min-height: 42px;
  padding: 0;
}

.compact-sidebar-library {
  gap: 10px;
}

.sidebar-random-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
}

.sidebar-random-select {
  min-width: 0;
  min-height: 34px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 750;
}

.sidebar-random-select:focus {
  border-color: var(--accent);
  outline: none;
}

.library-folder-tree {
  min-height: 0;
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  max-height: 190px;
  padding-right: 2px;
}

.sidebar-library .library-folder-tree .library-folder-tab {
  width: 100%;
  max-width: 100%;
  justify-content: flex-start;
  padding-left: calc(8px + (var(--folder-level, 0) * 14px));
}

.sidebar-library-list[hidden] {
  display: none;
}

.sidebar-library-list {
  flex: 1 1 160px;
  max-height: none;
  min-height: 0;
}

.sidebar-positions-heading {
  margin-top: 2px;
}

.import-choice-card {
  width: min(420px, 100%);
}

.import-choice-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.position-panel-heading {
  align-items: flex-start;
  margin-bottom: 10px;
}

.position-title-block {
  min-width: 0;
}

.position-title-block h2 {
  max-width: 100%;
  margin: 0;
  overflow: hidden;
  font-size: 1rem;
  line-height: 1.18;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.position-heading-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.info-toggle-button {
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 850;
}

.info-toggle-button:hover,
.info-toggle-button:focus-visible,
.info-toggle-button.active {
  border-color: var(--accent);
  color: var(--accent-strong);
  outline: none;
}

.current-move-comment {
  display: grid;
  gap: 5px;
  margin-bottom: 10px;
  padding: 9px;
  border: 1px solid rgba(122, 162, 247, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}

.current-move-comment span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 850;
  text-transform: uppercase;
}

.current-move-comment .position-card-comment {
  margin: 0;
}

.position-card-comment.empty {
  color: var(--muted);
  font-weight: 650;
}

.position-card-info[hidden],
.engine-panel[hidden] {
  display: none;
}

.engine-toggle-button {
  min-width: 82px;
  justify-content: center;
  text-align: center;
}

.engine-panel {
  border-color: rgba(122, 162, 247, 0.24);
}

.compact-text-import-grid .position-save-field:first-child,
.compact-text-import-grid .position-save-field:nth-child(7) {
  grid-column: auto;
}

.text-import-hidden-field[hidden] {
  display: none;
}

.text-import-card {
  width: min(760px, 100%);
  max-height: min(88vh, 820px);
  overflow: auto;
}

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

.text-import-grid .position-save-field:first-child,
.text-import-grid .position-save-field:nth-child(7),
.text-import-fen-field {
  grid-column: 1 / -1;
}

.text-import-textarea {
  min-height: 230px;
  font: 0.9rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.text-import-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.text-import-preview {
  white-space: pre-wrap;
}

.text-import-preview-summary {
  margin: 0;
  white-space: pre-wrap;
  font: inherit;
}

.text-import-preview-section {
  display: grid;
  gap: 7px;
  margin-top: 10px;
}

.text-import-preview-section h3 {
  margin: 0;
  color: var(--text);
  font-size: 0.86rem;
}

.text-import-preview-section ul {
  display: grid;
  gap: 5px;
  margin: 0;
  padding-left: 18px;
}

.text-import-preview-section fieldset {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.text-import-preview-section legend {
  padding: 0 4px;
  color: var(--text);
  font-weight: 850;
}

.text-import-preview-section label {
  display: flex;
  align-items: center;
  gap: 6px;
}

.app-section[hidden] {
  display: none !important;
}

.book-workspace {
  align-items: start;
}

.book-board-area {
  gap: 14px;
}

.book-board .book-piece {
  cursor: default;
  pointer-events: none;
}

.book-board .book-move-square {
  outline: 3px solid rgba(122, 162, 247, 0.86);
  outline-offset: -6px;
}

.book-playback-actions {
  width: min(74vmin, 720px);
  max-width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.book-nav-button {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 850;
  white-space: nowrap;
}

.book-nav-button:hover:not(:disabled),
.book-nav-button:focus-visible {
  border-color: var(--accent);
  color: var(--accent-strong);
  outline: none;
}

.book-nav-button.danger {
  color: var(--danger);
}

.book-nav-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.book-panel {
  gap: 12px;
}

.book-input-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.book-moves-input {
  width: 100%;
  min-height: 150px;
  resize: vertical;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  line-height: 1.45;
}

.book-moves-input:focus {
  border-color: var(--accent);
  outline: none;
}

.book-primary-button {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(122, 162, 247, 0.14);
  color: var(--accent-strong);
  cursor: pointer;
  font-weight: 850;
}

.book-secondary-button {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--ink);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 850;
  white-space: nowrap;
}

.book-primary-button:hover,
.book-primary-button:focus-visible,
.book-secondary-button:hover:not(:disabled),
.book-secondary-button:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.book-secondary-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.book-error {
  padding: 10px 12px;
  border: 1px solid rgba(239, 107, 115, 0.42);
  border-radius: 8px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 0.86rem;
  font-weight: 750;
  line-height: 1.35;
}

.book-error.warning {
  border-color: rgba(245, 188, 87, 0.48);
  background: rgba(245, 188, 87, 0.12);
  color: #f5bc57;
}

.book-current-move {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.book-current-move strong {
  color: var(--text);
}

.book-move-list {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
}

.book-move-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) minmax(0, 1fr);
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}

.book-move-number {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 900;
  text-align: right;
}

.book-move-item {
  min-height: 34px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
  text-align: left;
}

.book-move-placeholder {
  min-height: 34px;
}

.book-move-item:hover,
.book-move-item:focus-visible,
.book-move-item.active {
  border-color: var(--accent);
  color: var(--accent-strong);
  outline: none;
}

.online-game-view,
.game-route-view {
  min-height: calc(100vh - 42px);
}

.online-shell,
.game-route-card {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 28px 0;
}

.online-heading {
  margin-bottom: 24px;
}

.online-heading h1,
.game-route-card h1 {
  max-width: none;
  margin-bottom: 10px;
  white-space: normal;
}

.online-heading p:not(.eyebrow),
.game-route-card > p {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 700;
}

.online-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}

.invite-button {
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid rgba(122, 162, 247, 0.48);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(122, 162, 247, 0.32), rgba(122, 162, 247, 0.18));
  color: var(--accent-strong);
  cursor: pointer;
  font-size: 0.94rem;
  font-weight: 900;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.24);
}

.invite-button:hover,
.invite-button:focus-visible {
  border-color: rgba(168, 195, 255, 0.72);
  background: linear-gradient(180deg, rgba(122, 162, 247, 0.42), rgba(122, 162, 247, 0.24));
  outline: none;
}

.online-invite-hint {
  max-width: 360px;
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 750;
  line-height: 1.35;
}

.game-link-card,
.game-route-card {
  display: grid;
  gap: 16px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  box-shadow: var(--shadow-soft);
}

.game-link-card h2 {
  margin: 0 0 4px;
  color: var(--text);
  font-size: 1rem;
}

.game-link-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.game-link-output {
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #12151b;
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 800;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.game-link-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.open-game-button,
.copy-link-button {
  min-height: 36px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--button-bg);
  color: var(--text);
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 850;
}

.open-game-button {
  border-color: rgba(122, 162, 247, 0.48);
  background: rgba(122, 162, 247, 0.15);
  color: var(--accent-strong);
}

.open-game-button:hover:not(:disabled),
.open-game-button:focus-visible,
.copy-link-button:hover:not(:disabled),
.copy-link-button:focus-visible {
  border-color: rgba(122, 162, 247, 0.58);
  color: var(--accent-strong);
  outline: none;
}

.open-game-button:disabled,
.copy-link-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.copy-link-status {
  min-height: 20px;
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 800;
}

.game-room-code {
  color: var(--text);
  font-size: 1rem;
  font-weight: 850;
  overflow-wrap: anywhere;
}

body.board-theme-classic {
  --square-light: #d8c9aa;
  --square-dark: #8a6f4d;
  --square-light-soft: #eee1c4;
  --square-dark-soft: #715437;
  --board-frame: #5f4b35;
}

body.board-theme-wooden {
  --square-light: #e2c993;
  --square-dark: #b37a45;
  --square-light-soft: #f0dfb5;
  --square-dark-soft: #965f32;
  --board-frame: #6d4b2e;
}

body.board-theme-dark {
  --square-light: #7b8190;
  --square-dark: #2f3542;
  --square-light-soft: #9299a8;
  --square-dark-soft: #242936;
  --board-frame: #181c25;
}

body.board-theme-light {
  --square-light: #f0e1bd;
  --square-dark: #c9aa74;
  --square-light-soft: #fff0ce;
  --square-dark-soft: #b99661;
  --board-frame: #8f7249;
}

body.board-theme-blue {
  --square-light: #c9d8eb;
  --square-dark: #5d7fa6;
  --square-light-soft: #e0ecf8;
  --square-dark-soft: #456b93;
  --board-frame: #314b68;
}

body.board-theme-green {
  --square-light: #cddbb8;
  --square-dark: #6b8a5a;
  --square-light-soft: #e1ebcf;
  --square-dark-soft: #567345;
  --board-frame: #405a34;
}

body.board-theme-classic .board,
body.board-theme-wooden .board,
body.board-theme-dark .board,
body.board-theme-light .board,
body.board-theme-blue .board,
body.board-theme-green .board {
  border-color: var(--board-frame);
  background: var(--board-frame);
}

.last-move-square {
  box-shadow: inset 0 0 0 999px rgba(250, 222, 125, 0.2);
}

.last-move-to {
  box-shadow:
    inset 0 0 0 999px rgba(250, 222, 125, 0.24),
    inset 0 0 0 3px rgba(250, 222, 125, 0.45);
}

body.hide-last-move-highlight .last-move-square,
body.hide-last-move-highlight .last-move-to {
  box-shadow: none;
}

body.hide-legal-move-hints .target-marker {
  display: none;
}

body.hide-selected-piece-highlight .square.selected-square {
  outline: none;
}

body.hide-selected-piece-highlight .piece.selected {
  outline: none;
}

body.pieces-style-classic .piece,
body.pieces-style-classic .tool-piece {
  border-width: 2px;
  box-shadow:
    0 10px 18px rgba(35, 21, 10, 0.22),
    inset 0 2px 4px rgba(255, 255, 255, 0.18),
    inset 0 -4px 8px rgba(0, 0, 0, 0.15);
}

body.pieces-style-flat .piece,
body.pieces-style-flat .tool-piece {
  border-width: 2px;
  box-shadow: 0 5px 10px rgba(0, 0, 0, 0.18);
}

body.pieces-style-flat .piece.white,
body.pieces-style-flat .tool-piece.white {
  background: #f4ead4;
}

body.pieces-style-flat .piece.black,
body.pieces-style-flat .tool-piece.black {
  background: #20242d;
}

body.pieces-style-glossy .piece,
body.pieces-style-glossy .tool-piece {
  box-shadow:
    0 13px 22px rgba(35, 21, 10, 0.28),
    inset 0 3px 5px rgba(255, 255, 255, 0.28),
    inset 0 -6px 12px rgba(0, 0, 0, 0.18);
}

body.pieces-style-minimal .piece,
body.pieces-style-minimal .tool-piece {
  border-width: 1px;
  box-shadow: none;
}

body.pieces-style-minimal .piece.white,
body.pieces-style-minimal .tool-piece.white {
  background: #f5f0e3;
}

body.pieces-style-minimal .piece.black,
body.pieces-style-minimal .tool-piece.black {
  background: #252a34;
}

.right-panel .notation-panel {
  flex: 1 1 auto;
  min-height: 0;
  padding: 14px;
}

.right-panel .analysis-panel {
  max-height: none;
  overflow: visible;
  flex-shrink: 0;
}

.right-panel .analysis-heading {
  min-height: 20px;
}

.right-panel .analysis-grid {
  gap: 3px 7px;
}

.right-panel .analysis-pv {
  min-height: 16px;
}

.right-panel .analysis-actions {
  gap: 6px;
  justify-content: flex-start;
  flex-wrap: wrap;
  overflow: visible;
}

.right-panel .analysis-button {
  flex: 0 0 auto;
}

.move-list {
  padding: 2px 2px 10px 0;
  font-size: 13px;
  line-height: 1.24;
  letter-spacing: 0;
  word-spacing: 1px;
}

.variation-tree,
.variation-block {
  gap: 0;
}

.main-line,
.variation-line {
  gap: 2px 4px;
  align-items: baseline;
  line-height: 1.24;
}

.variation-line {
  font-size: 0.88rem;
}

.move-turn {
  min-height: 22px;
  gap: 2px;
  align-items: baseline;
}

.move {
  min-height: 20px;
  padding: 1px 3px;
  border-radius: 4px;
  font-size: 0.83rem;
  line-height: 1.12;
}

.variation-line .move {
  font-size: 0.8rem;
}

.move-index {
  margin-right: 1px;
  font-size: 0.79rem;
}

.variation-branch-group {
  flex: 1 0 100%;
  gap: 1px;
  margin: 1px 0 1px min(calc(var(--branch-depth) * 12px), 64px);
  padding-left: 8px;
  border-left-width: 1px;
}

.side-variation {
  padding: 0;
}

.move-comment {
  margin: 0 1px;
  font-size: 0.78rem;
  line-height: 1.15;
}

.board-settings-dialog {
  position: fixed;
  inset: 0;
  z-index: 35;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(4, 6, 10, 0.58);
  backdrop-filter: blur(8px);
}

.board-settings-dialog[hidden] {
  display: none;
}

.board-settings-card {
  width: min(420px, 100%);
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  box-shadow: var(--shadow);
}

.board-settings-heading,
.board-settings-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.board-settings-heading h2 {
  margin: 0;
  font-size: 1rem;
}

.board-settings-close {
  width: 30px;
  min-width: 30px;
  min-height: 30px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--button-bg);
  color: var(--muted);
  cursor: pointer;
}

.board-settings-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.board-settings-select {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #12151b;
  color: var(--text);
  font: inherit;
  font-weight: 750;
}

.board-settings-options {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
}

.board-settings-check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 700;
}

.board-settings-action {
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--button-bg);
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
}

.board-settings-action.primary {
  border-color: rgba(122, 162, 247, 0.55);
  background: rgba(122, 162, 247, 0.16);
  color: var(--accent-strong);
}

.board-settings-action:hover,
.board-settings-close:hover {
  border-color: rgba(122, 162, 247, 0.42);
  background: var(--button-hover);
}

@keyframes menu-pop {
  from {
    opacity: 0;
    transform: translateY(-3px) scale(0.985);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .app-sidebar {
    position: static;
    height: auto;
    max-height: none;
    padding: 10px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .sidebar-brand {
    min-height: 34px;
  }

  .sidebar-nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .sidebar-nav-item {
    justify-content: center;
    text-align: center;
  }

  .app {
    width: min(100% - 18px, 760px);
  }

  .topbar {
    align-items: stretch;
  }

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

  h1 {
    max-width: 100%;
  }

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

  .board,
  .board-toolbar,
  .board-quick-actions,
  .book-playback-actions,
  .board-title-form,
  .analysis-panel {
    width: min(94vw, 680px);
  }

  .moves-panel {
    height: auto;
    max-height: none;
  }

  .notation-panel {
    min-height: 360px;
  }

  .variant-library {
    max-height: 520px;
  }

  .sidebar-library {
    max-height: 420px;
  }

  .text-import-grid {
    grid-template-columns: 1fr;
  }

  .text-import-grid .position-save-field:first-child,
  .text-import-grid .position-save-field:nth-child(7),
  .text-import-fen-field {
    grid-column: auto;
  }
}

@media (max-width: 560px) {
  .sidebar-brand-text {
    font-size: 0.84rem;
  }

  .topbar-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar .library-toggle,
  .status {
    width: 100%;
  }

  .flying-position-controls {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .board-quick-actions {
    justify-content: flex-start;
  }

  .board-save-button:not(.board-icon-button) {
    flex: 1 1 auto;
  }

  .online-shell,
  .game-route-card {
    padding: 18px 0;
  }

  .online-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .online-invite-hint {
    max-width: none;
  }

  .game-link-actions {
    align-items: stretch;
    flex-direction: column;
  }
}


.analysis-multipv {
  margin-top: 0.5rem;
  padding: 0.55rem 0.65rem;
  border-radius: 0.75rem;
  background: rgba(255, 255, 255, 0.06);
  font-size: 0.86rem;
  line-height: 1.35;
}

.analysis-multipv-title {
  margin-bottom: 0.25rem;
  font-weight: 700;
  opacity: 0.9;
}

.analysis-multipv-row {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.92;
}

/* Premium dark dashboard theme. Visual overrides only. */
:root {
  --bg-main: #030712;
  --bg-layer: rgba(8, 13, 24, 0.88);
  --bg-panel: rgba(15, 23, 42, 0.86);
  --bg-card: rgba(17, 24, 39, 0.82);
  --bg-card-hover: rgba(30, 41, 59, 0.92);
  --accent: #1677ff;
  --accent-hover: #3b8cff;
  --accent-soft: rgba(22, 119, 255, 0.14);
  --accent-glow: rgba(22, 119, 255, 0.34);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-soft: #cbd5e1;
  --border: rgba(148, 163, 184, 0.18);
  --border-strong: rgba(203, 213, 225, 0.28);
  --good: #22c55e;
  --bad: #ef4444;
  --draw: #a78bfa;
  --warning: #f59e0b;
  --radius-panel: 14px;
  --radius-card: 10px;
  --radius-button: 8px;
  --shadow-panel: 0 22px 70px rgba(0, 0, 0, 0.42);
  --shadow-card: 0 14px 44px rgba(0, 0, 0, 0.32);
  --shadow-blue: 0 0 0 1px rgba(22, 119, 255, 0.22), 0 18px 52px rgba(22, 119, 255, 0.13);
  --board-dark: #1a2233;
  --board-light: #c9c8c2;
  --board-frame: #07111f;
  --board-border: rgba(255, 255, 255, 0.14);
  --bg: var(--bg-main);
  --panel: var(--bg-panel);
  --panel-2: var(--bg-card);
  --panel-3: var(--bg-card-hover);
  --surface: var(--bg-card);
  --ink: var(--text-main);
  --text: var(--text-main);
  --muted: var(--text-muted);
  --line: var(--border);
  --accent-strong: var(--accent-hover);
  --danger: var(--bad);
  --danger-soft: rgba(239, 68, 68, 0.14);
  --square-light: var(--board-light);
  --square-dark: var(--board-dark);
  --square-light-soft: #d8d6cf;
  --square-dark-soft: #111827;
  --light-square: var(--square-light);
  --dark-square: var(--square-dark);
  --dark-square-hover: #22314a;
  --white-piece: #ebe7db;
  --white-piece-edge: #a9a095;
  --black-piece: #11151d;
  --black-piece-edge: #05070b;
  --button-bg: rgba(15, 23, 42, 0.88);
  --button-hover: rgba(30, 64, 120, 0.82);
  --button-active: var(--accent-soft);
  --shadow: var(--shadow-panel);
  --shadow-soft: var(--shadow-card);
  --radius: var(--radius-panel);
  --radius-sm: var(--radius-button);
}

html {
  background: var(--bg-main);
}

body {
  background:
    radial-gradient(circle at 12% 8%, rgba(22, 119, 255, 0.18), transparent 30%),
    radial-gradient(circle at 78% 14%, rgba(20, 184, 166, 0.1), transparent 28%),
    radial-gradient(circle at 50% 92%, rgba(245, 158, 11, 0.08), transparent 34%),
    #030712;
  color: var(--text-main);
}

body.board-theme-classic,
body.board-theme-wooden,
body.board-theme-dark,
body.board-theme-light,
body.board-theme-blue,
body.board-theme-green {
  --square-light: var(--board-light);
  --square-dark: var(--board-dark);
  --square-light-soft: #d8d6cf;
  --square-dark-soft: #111827;
  --dark-square-hover: #22314a;
}

.app-shell {
  background: transparent;
}

.app-sidebar {
  border-right-color: var(--border);
  background:
    linear-gradient(180deg, rgba(8, 13, 24, 0.96), rgba(10, 16, 29, 0.92)),
    var(--bg-layer);
  box-shadow: 18px 0 58px rgba(0, 0, 0, 0.32);
}

.sidebar-brand-mark {
  border-color: rgba(22, 119, 255, 0.42);
  background: linear-gradient(180deg, rgba(22, 119, 255, 0.26), rgba(22, 119, 255, 0.1));
  color: var(--text-main);
  box-shadow: var(--shadow-blue);
}

.sidebar-brand-text,
h1,
h2,
.analysis-best-move,
.current-library-title,
.saved-position-name,
.variant-library-name,
.book-current-move strong {
  color: var(--text-main);
}

.app-subtitle,
.status,
.online-heading p:not(.eyebrow),
.game-route-card > p,
.online-invite-hint,
.game-link-card p,
.variant-library-meta,
.variant-library-empty,
.saved-position-meta,
.book-input-label,
.book-error,
.pdn-import-note,
.position-card-field span,
.analysis-label,
.analysis-multipv-row {
  color: var(--text-muted);
}

.eyebrow {
  color: #60a5fa;
}

.sidebar-nav-item {
  border-radius: var(--radius-button);
  color: var(--text-muted);
}

.sidebar-nav-item:hover,
.sidebar-nav-item:focus-visible {
  border-color: rgba(22, 119, 255, 0.32);
  background: rgba(22, 119, 255, 0.1);
  color: var(--text-main);
}

.sidebar-nav-item.active {
  border-color: rgba(22, 119, 255, 0.52);
  background: linear-gradient(90deg, rgba(22, 119, 255, 0.22), rgba(22, 119, 255, 0.08));
  color: var(--text-main);
  box-shadow: inset 3px 0 0 var(--accent), var(--shadow-blue);
}

.topbar,
.analysis-panel,
.notation-panel,
.variant-library,
.editor-panel,
.saved-panel,
.sidebar-library,
.book-panel,
.book-reader-panel,
.game-link-card,
.game-route-card,
.comment-dialog-card,
.position-save-card,
.pdn-import-card,
.board-settings-card,
.text-import-card,
.import-choice-card,
.current-move-comment,
.position-card-info,
.book-current-move,
.analysis-multipv {
  border: 1px solid var(--border);
  border-radius: var(--radius-panel);
  background:
    linear-gradient(180deg, rgba(17, 24, 39, 0.92), rgba(15, 23, 42, 0.84)),
    var(--bg-panel);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(14px);
}

.topbar {
  padding: 16px 18px;
}

.sidebar-library {
  padding: 12px;
}

.status,
.position-card-info,
.current-move-comment,
.book-current-move,
.analysis-multipv {
  background: rgba(15, 23, 42, 0.64);
}

.board-toolbar,
.board-quick-actions,
.board-title-form {
  border-color: var(--border);
  background: rgba(15, 23, 42, 0.74);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.22);
}

.mode-button,
.board-save-button,
.control-button,
.analysis-button,
.library-toggle,
.library-action,
.library-density-toggle,
.library-folder-tab,
.library-folder-toggle,
.library-folder-inline-action,
.saved-action,
.saved-small-action,
.variant-nav-button,
.variant-open-button,
.tool-button,
.side-button,
.editor-action,
.position-save-button,
.position-save-close,
.comment-dialog-button,
.pdn-import-button,
.pdn-import-close,
.book-nav-button,
.book-primary-button,
.book-secondary-button,
.flying-position-button,
.invite-button,
.open-game-button,
.copy-link-button,
.board-settings-action,
.board-settings-close,
.move-context-action,
.library-context-action {
  border-color: var(--border);
  border-radius: var(--radius-button);
  background: var(--button-bg);
  color: var(--text-soft);
  box-shadow: none;
}

.mode-button:hover:not(:disabled),
.mode-button:focus-visible,
.mode-button.active,
.board-save-button:hover:not(:disabled),
.board-save-button:focus-visible,
.board-save-button.active,
.control-button:hover:not(:disabled),
.control-button:focus-visible,
.analysis-button:hover:not(:disabled),
.analysis-button:focus-visible,
.analysis-button.active,
.library-toggle:hover,
.library-toggle:focus-visible,
.library-toggle.active,
.library-action:hover:not(:disabled),
.library-action:focus-visible,
.library-action.active,
.library-density-toggle:hover,
.library-density-toggle:focus-visible,
.library-density-toggle.active,
.library-folder-tab:hover,
.library-folder-tab:focus-visible,
.library-folder-tab.active,
.library-folder-toggle:hover,
.library-folder-toggle:focus-visible,
.saved-action:hover:not(:disabled),
.saved-action:focus-visible,
.saved-small-action:hover,
.saved-small-action:focus-visible,
.variant-nav-button:hover:not(:disabled),
.variant-nav-button:focus-visible,
.variant-open-button:hover:not(:disabled),
.variant-open-button:focus-visible,
.tool-button:hover:not(:disabled),
.tool-button:focus-visible,
.tool-button.active,
.side-button:hover:not(:disabled),
.side-button:focus-visible,
.side-button.active,
.editor-action:hover:not(:disabled),
.editor-action:focus-visible,
.position-save-button:hover:not(:disabled),
.position-save-button:focus-visible,
.position-save-close:hover,
.position-save-close:focus-visible,
.comment-dialog-button:hover,
.comment-dialog-button:focus-visible,
.pdn-import-button:hover:not(:disabled),
.pdn-import-button:focus-visible,
.pdn-import-close:hover,
.pdn-import-close:focus-visible,
.book-nav-button:hover:not(:disabled),
.book-nav-button:focus-visible,
.book-primary-button:hover:not(:disabled),
.book-primary-button:focus-visible,
.book-secondary-button:hover:not(:disabled),
.book-secondary-button:focus-visible,
.flying-position-button:hover:not(:disabled),
.flying-position-button:focus-visible,
.invite-button:hover,
.invite-button:focus-visible,
.open-game-button:hover:not(:disabled),
.open-game-button:focus-visible,
.copy-link-button:hover:not(:disabled),
.copy-link-button:focus-visible,
.board-settings-action:hover,
.board-settings-close:hover,
.move-context-action:hover:not(:disabled),
.move-context-action:focus-visible,
.library-context-action:hover:not(:disabled),
.library-context-action:focus-visible {
  border-color: rgba(22, 119, 255, 0.48);
  background: var(--button-hover);
  color: var(--text-main);
  box-shadow: 0 0 0 3px rgba(22, 119, 255, 0.12);
  outline: none;
}

.library-action.primary,
.saved-action.primary,
.position-save-button.primary,
.comment-dialog-button.primary,
.pdn-import-button.primary,
.book-primary-button,
.board-settings-action.primary,
.invite-button,
.open-game-button {
  border-color: rgba(22, 119, 255, 0.58);
  background: linear-gradient(180deg, rgba(22, 119, 255, 0.92), rgba(29, 78, 216, 0.9));
  color: #ffffff;
  box-shadow: var(--shadow-blue);
}

.reset-button,
.book-nav-button.danger,
.saved-small-action.danger,
.library-context-action.danger,
.move-context-action.danger {
  color: #fca5a5;
}

input,
select,
textarea,
.analysis-depth-select,
.library-search-input,
.sidebar-random-select,
.position-save-input,
.position-save-select,
.position-save-textarea,
.comment-input,
.pdn-import-text,
.pdn-import-select,
.book-moves-input,
.book-position-select,
.flying-position-select,
.board-settings-select,
.game-link-output {
  border-color: var(--border);
  border-radius: var(--radius-button);
  background: rgba(3, 7, 18, 0.72);
  color: var(--text-main);
}

input:focus,
select:focus,
textarea:focus,
.analysis-depth-select:focus,
.library-search-input:focus,
.sidebar-random-select:focus,
.position-save-input:focus,
.position-save-select:focus,
.position-save-textarea:focus,
.comment-input:focus,
.pdn-import-text:focus,
.pdn-import-select:focus,
.book-moves-input:focus,
.book-position-select:focus,
.flying-position-select:focus,
.board-settings-select:focus {
  border-color: rgba(22, 119, 255, 0.62);
  box-shadow: 0 0 0 3px rgba(22, 119, 255, 0.16);
  outline: none;
}

input::placeholder,
textarea::placeholder {
  color: rgba(148, 163, 184, 0.72);
}

.board {
  border: 10px solid var(--board-frame);
  border-radius: 12px;
  background: var(--board-frame);
  box-shadow:
    0 0 0 1px var(--board-border),
    0 24px 54px rgba(0, 0, 0, 0.42),
    inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

body.board-theme-classic .board,
body.board-theme-wooden .board,
body.board-theme-dark .board,
body.board-theme-light .board,
body.board-theme-blue .board,
body.board-theme-green .board {
  border-color: var(--board-frame);
  background: var(--board-frame);
}

.square {
  color: rgba(15, 23, 42, 0.74);
}

.square.light {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.34), transparent 42%),
    linear-gradient(315deg, rgba(86, 78, 65, 0.16), transparent 54%),
    var(--board-light);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
}

.square.dark {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.055), transparent 38%),
    linear-gradient(315deg, rgba(0, 0, 0, 0.28), transparent 58%),
    var(--board-dark);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.035);
}

.square.selected-square {
  background:
    linear-gradient(135deg, rgba(22, 119, 255, 0.22), transparent 42%),
    var(--dark-square-hover);
  outline: 3px solid rgba(96, 165, 250, 0.88);
  outline-offset: -5px;
  box-shadow:
    inset 0 0 0 999px rgba(22, 119, 255, 0.11),
    inset 0 0 0 2px rgba(22, 119, 255, 0.46),
    0 0 18px rgba(22, 119, 255, 0.22);
}

.target-marker {
  width: 27%;
  background: rgba(96, 165, 250, 0.9);
  box-shadow:
    0 0 0 5px rgba(22, 119, 255, 0.14),
    0 0 18px rgba(22, 119, 255, 0.36);
}

.target-marker.capture {
  width: 48%;
  border: 3px solid rgba(248, 113, 113, 0.9);
  background: rgba(239, 68, 68, 0.2);
  box-shadow:
    0 0 0 5px rgba(239, 68, 68, 0.12),
    0 0 20px rgba(239, 68, 68, 0.32),
    inset 0 0 0 999px rgba(245, 158, 11, 0.08);
}

.last-move-square {
  box-shadow: inset 0 0 0 999px rgba(245, 158, 11, 0.18);
}

.last-move-to {
  box-shadow:
    inset 0 0 0 999px rgba(245, 158, 11, 0.22),
    inset 0 0 0 3px rgba(245, 158, 11, 0.46);
}

.coord-label {
  color: rgba(15, 23, 42, 0.72);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.16);
}

.square.dark .coord-label {
  color: rgba(226, 232, 240, 0.52);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.26);
}

.piece,
body.pieces-style-classic .piece,
body.pieces-style-flat .piece,
body.pieces-style-glossy .piece,
body.pieces-style-minimal .piece,
.tool-piece,
body.pieces-style-classic .tool-piece,
body.pieces-style-flat .tool-piece,
body.pieces-style-glossy .tool-piece,
body.pieces-style-minimal .tool-piece {
  border-width: 2px;
  border-radius: 50%;
  box-shadow:
    0 13px 22px rgba(0, 0, 0, 0.34),
    inset 0 3px 5px rgba(255, 255, 255, 0.2),
    inset 0 -7px 12px rgba(0, 0, 0, 0.24);
}

.piece:hover,
.piece:focus-visible {
  transform: translateY(-2px);
  box-shadow:
    0 17px 28px rgba(0, 0, 0, 0.38),
    0 0 0 3px rgba(22, 119, 255, 0.12),
    inset 0 3px 5px rgba(255, 255, 255, 0.24),
    inset 0 -7px 12px rgba(0, 0, 0, 0.24);
}

.piece::before,
.tool-piece::before {
  width: 62%;
  border: 2px solid currentColor;
  opacity: 0.26;
  box-shadow: inset 0 0 0 5px rgba(255, 255, 255, 0.04);
}

.piece.white,
body.pieces-style-flat .piece.white,
body.pieces-style-minimal .piece.white,
.tool-piece.white,
body.pieces-style-flat .tool-piece.white,
body.pieces-style-minimal .tool-piece.white {
  color: rgba(83, 75, 62, 0.84);
  border-color: #f3efe3;
  background:
    radial-gradient(circle at 34% 26%, #ffffff 0 14%, #f4f0e5 34%, var(--white-piece) 58%, var(--white-piece-edge) 100%);
}

.piece.black,
body.pieces-style-flat .piece.black,
body.pieces-style-minimal .piece.black,
.tool-piece.black,
body.pieces-style-flat .tool-piece.black,
body.pieces-style-minimal .tool-piece.black {
  color: rgba(203, 213, 225, 0.86);
  border-color: #2f3747;
  background:
    radial-gradient(circle at 35% 28%, #4b5567 0 12%, #242b38 34%, var(--black-piece) 60%, var(--black-piece-edge) 100%);
}

.piece.selected {
  outline: 4px solid rgba(96, 165, 250, 0.88);
  outline-offset: 3px;
  box-shadow:
    0 0 0 6px rgba(22, 119, 255, 0.16),
    0 18px 34px rgba(0, 0, 0, 0.42),
    inset 0 3px 5px rgba(255, 255, 255, 0.22),
    inset 0 -7px 12px rgba(0, 0, 0, 0.24);
}

.piece.king::after {
  color: currentColor;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.34);
}

body.hide-last-move-highlight .last-move-square,
body.hide-last-move-highlight .last-move-to {
  box-shadow: none;
}

body.hide-legal-move-hints .target-marker {
  display: none;
}

body.hide-selected-piece-highlight .square.selected-square {
  outline: none;
  box-shadow: none;
}

body.hide-selected-piece-highlight .piece.selected {
  outline: none;
  box-shadow:
    0 13px 22px rgba(0, 0, 0, 0.34),
    inset 0 3px 5px rgba(255, 255, 255, 0.2),
    inset 0 -7px 12px rgba(0, 0, 0, 0.24);
}

.move-list,
.variant-library-list,
.sidebar-library-list,
.book-move-list,
.pdn-import-preview,
.text-import-preview {
  scrollbar-color: rgba(96, 165, 250, 0.36) rgba(15, 23, 42, 0.6);
}

.variation-line {
  color: var(--text-muted);
}

.variation-branch-group {
  border-left-color: rgba(96, 165, 250, 0.26);
}

.side-variation {
  border: 1px solid rgba(148, 163, 184, 0.12);
  background: rgba(15, 23, 42, 0.64);
}

.move {
  color: inherit;
}

.move:hover:not(:disabled),
.move:focus-visible {
  border-color: rgba(22, 119, 255, 0.42);
  background: rgba(22, 119, 255, 0.13);
  color: var(--text-main);
}

.move.active {
  border-color: rgba(22, 119, 255, 0.58);
  background: rgba(22, 119, 255, 0.2);
  color: #bfdbfe;
  box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.15);
}

.move-comment,
.variant-library-comment,
.position-card-comment,
.current-move-comment p {
  color: var(--text-muted);
}

.move-comment {
  background: rgba(15, 23, 42, 0.56);
  border-color: rgba(148, 163, 184, 0.14);
}

.variant-library-item,
.saved-position,
.library-folder-toggle,
.book-move-item,
.pdn-import-preview-item,
.text-import-preview-item {
  border-color: var(--border);
  border-radius: var(--radius-card);
  background: rgba(15, 23, 42, 0.62);
}

.variant-library-item:hover,
.variant-library-item:focus-within,
.saved-position:hover,
.book-move-item:hover {
  border-color: rgba(22, 119, 255, 0.34);
  background: var(--bg-card-hover);
}

.variant-library-item.active,
.saved-position.active,
.book-move-item.active {
  border-color: rgba(22, 119, 255, 0.52);
  background: rgba(22, 119, 255, 0.16);
  box-shadow: var(--shadow-blue);
}

.variant-library-icon,
.library-folder-count,
.position-card-stats span {
  border-color: rgba(22, 119, 255, 0.28);
  background: rgba(22, 119, 255, 0.12);
  color: #93c5fd;
}

.book-error,
.pdn-import-error {
  border-color: rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.12);
  color: #fecaca;
}

.pdn-import-note,
.pdn-import-preview,
.text-import-preview,
.game-link-output {
  background: rgba(3, 7, 18, 0.72);
}

.copy-link-status {
  color: #86efac;
}

.analysis-score.good,
.score-good,
.book-result-win {
  color: var(--good);
}

.analysis-score.bad,
.score-bad,
.book-result-loss {
  color: #fca5a5;
}

.analysis-score.draw,
.score-draw,
.book-result-draw {
  color: var(--draw);
}

/* Board and piece theme presets. Visual only. */
body.board-theme-classic {
  --square-light: #d8c9aa;
  --square-dark: #8a6f4d;
  --square-light-soft: #eee1c4;
  --square-dark-soft: #715437;
  --board-frame: #5f4b35;
}

body.board-theme-wooden {
  --square-light: #e2c993;
  --square-dark: #b37a45;
  --square-light-soft: #f0dfb5;
  --square-dark-soft: #965f32;
  --board-frame: #6d4b2e;
}

body.board-theme-dark {
  --square-light: #7b8190;
  --square-dark: #2f3542;
  --square-light-soft: #9299a8;
  --square-dark-soft: #242936;
  --board-frame: #181c25;
}

body.board-theme-light {
  --square-light: #f0e1bd;
  --square-dark: #c9aa74;
  --square-light-soft: #fff0ce;
  --square-dark-soft: #b99661;
  --board-frame: #8f7249;
}

body.board-theme-blue,
body.board-theme-lid-blue {
  --square-light: #dee3e6;
  --square-dark: #7890a8;
  --square-light-soft: #f0f4f7;
  --square-dark-soft: #607a95;
  --board-frame: #3c5068;
}

body.board-theme-green,
body.board-theme-lid-green {
  --square-light: #e8ead1;
  --square-dark: #7a9a69;
  --square-light-soft: #f5f6df;
  --square-dark-soft: #658653;
  --board-frame: #4d643f;
}

body.board-theme-lid-brown {
  --square-light: #f0d9b5;
  --square-dark: #b58863;
  --square-light-soft: #f6e3c4;
  --square-dark-soft: #9d744f;
  --board-frame: #7b5739;
}

body.board-theme-lid-grey {
  --square-light: #d6d6d6;
  --square-dark: #8c8c8c;
  --square-light-soft: #ededed;
  --square-dark-soft: #737373;
  --board-frame: #565656;
}

body.board-theme-lid-purple {
  --square-light: #d7c7df;
  --square-dark: #8c6799;
  --square-light-soft: #eadcf0;
  --square-dark-soft: #765585;
  --board-frame: #50385d;
}

body.board-theme-lid-marble {
  --square-light: #ece8dd;
  --square-dark: #9a9286;
  --square-light-soft: #faf7ef;
  --square-dark-soft: #81796f;
  --board-frame: #5f5a52;
}

body.board-theme-lid-metal {
  --square-light: #cfd6dc;
  --square-dark: #65727f;
  --square-light-soft: #e8edf0;
  --square-dark-soft: #505d69;
  --board-frame: #303944;
}

body.board-theme-lid-newspaper {
  --square-light: #f2eedf;
  --square-dark: #b9b09a;
  --square-light-soft: #fffbed;
  --square-dark-soft: #9f967f;
  --board-frame: #746b5a;
}

body.board-theme-classic .board,
body.board-theme-wooden .board,
body.board-theme-dark .board,
body.board-theme-light .board,
body.board-theme-blue .board,
body.board-theme-green .board,
body.board-theme-lid-blue .board,
body.board-theme-lid-brown .board,
body.board-theme-lid-green .board,
body.board-theme-lid-grey .board,
body.board-theme-lid-purple .board,
body.board-theme-lid-marble .board,
body.board-theme-lid-metal .board,
body.board-theme-lid-newspaper .board {
  border-color: var(--board-frame);
  background: var(--board-frame);
}

body.board-theme-lid-marble .square.light,
body.board-theme-lid-marble .square.dark {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.28), transparent 32%),
    linear-gradient(45deg, rgba(90, 80, 70, 0.1) 0 12%, transparent 12% 30%, rgba(255, 255, 255, 0.12) 30% 44%, transparent 44%),
    var(--square-light);
}

body.board-theme-lid-marble .square.dark {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.18), transparent 32%),
    linear-gradient(45deg, rgba(45, 38, 32, 0.18) 0 12%, transparent 12% 30%, rgba(255, 255, 255, 0.08) 30% 44%, transparent 44%),
    var(--square-dark);
}

body.board-theme-lid-metal .square.light,
body.board-theme-lid-metal .square.dark {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.28), transparent 38%),
    linear-gradient(315deg, rgba(0, 0, 0, 0.16), transparent 58%),
    var(--square-light);
}

body.board-theme-lid-metal .square.dark {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.14), transparent 38%),
    linear-gradient(315deg, rgba(0, 0, 0, 0.26), transparent 58%),
    var(--square-dark);
}

body.board-theme-lid-newspaper .square.light,
body.board-theme-lid-newspaper .square.dark {
  box-shadow:
    inset 0 0 0 1px rgba(72, 62, 48, 0.12),
    inset 0 0 18px rgba(72, 62, 48, 0.08);
}

body.pieces-style-lid-flat .piece,
body.pieces-style-lid-flat .tool-piece {
  border-width: 2px;
  box-shadow: 0 5px 12px rgba(0, 0, 0, 0.24);
}

body.pieces-style-lid-flat .piece::before,
body.pieces-style-lid-flat .tool-piece::before {
  width: 58%;
  opacity: 0.34;
  box-shadow: none;
}

body.pieces-style-lid-flat .piece.white,
body.pieces-style-lid-flat .tool-piece.white {
  color: #8a7c68;
  border-color: #f7f3e8;
  background: #f4efe1;
}

body.pieces-style-lid-flat .piece.black,
body.pieces-style-lid-flat .tool-piece.black {
  color: #cbd5e1;
  border-color: #293241;
  background: #151b24;
}

body.pieces-style-fabirovsky .piece,
body.pieces-style-fabirovsky .tool-piece {
  border-width: 2px;
  box-shadow:
    0 7px 16px rgba(0, 0, 0, 0.24),
    inset 0 0 0 5px rgba(255, 255, 255, 0.04);
}

body.pieces-style-fabirovsky .piece::before,
body.pieces-style-fabirovsky .tool-piece::before {
  width: 34%;
  border-width: 2px;
  opacity: 0.72;
  box-shadow: none;
}

body.pieces-style-fabirovsky .piece.white,
body.pieces-style-fabirovsky .tool-piece.white {
  color: #4b5563;
  border-color: #ffffff;
  background: #f8fafc;
}

body.pieces-style-fabirovsky .piece.black,
body.pieces-style-fabirovsky .tool-piece.black {
  color: #e5e7eb;
  border-color: #111827;
  background: #111827;
}

body.pieces-style-lid-outline .piece,
body.pieces-style-lid-outline .tool-piece {
  border-width: 3px;
  background: transparent;
  box-shadow:
    0 7px 16px rgba(0, 0, 0, 0.26),
    inset 0 0 0 5px rgba(255, 255, 255, 0.06);
}

body.pieces-style-lid-outline .piece::before,
body.pieces-style-lid-outline .tool-piece::before {
  width: 50%;
  opacity: 0.7;
}

body.pieces-style-lid-outline .piece.white,
body.pieces-style-lid-outline .tool-piece.white {
  color: #f8fafc;
  border-color: #f8fafc;
}

body.pieces-style-lid-outline .piece.black,
body.pieces-style-lid-outline .tool-piece.black {
  color: #111827;
  border-color: #111827;
}

body.pieces-style-lid-wood .piece,
body.pieces-style-lid-wood .tool-piece {
  border-width: 2px;
  box-shadow:
    0 12px 20px rgba(37, 22, 12, 0.28),
    inset 0 3px 5px rgba(255, 255, 255, 0.22),
    inset 0 -7px 12px rgba(0, 0, 0, 0.2);
}

body.pieces-style-lid-wood .piece.white,
body.pieces-style-lid-wood .tool-piece.white {
  color: #8b6d45;
  border-color: #f4dfb8;
  background:
    radial-gradient(circle at 35% 28%, #fff3cf 0 13%, #dfb878 42%, #9f6f3b 100%);
}

body.pieces-style-lid-wood .piece.black,
body.pieces-style-lid-wood .tool-piece.black {
  color: #d7b27a;
  border-color: #4f3320;
  background:
    radial-gradient(circle at 35% 28%, #8a5c35 0 12%, #4b2f1f 42%, #1c120c 100%);
}

/* Neutral board/piece presets. These override the dark shell board defaults. */
body.board-theme-ocean,
body.board-theme-lid-blue {
  --square-light: #e8edf1;
  --square-dark: #7b94ad;
  --square-light-soft: #f6f9fb;
  --square-dark-soft: #63809c;
  --board-frame: #40566d;
}

body.board-theme-walnut,
body.board-theme-lid-brown {
  --square-light: #f0d9b5;
  --square-dark: #b58863;
  --square-light-soft: #f7e5c8;
  --square-dark-soft: #9b714f;
  --board-frame: #755235;
}

body.board-theme-forest,
body.board-theme-lid-green {
  --square-light: #e9edcf;
  --square-dark: #7fa06b;
  --square-light-soft: #f6f8e2;
  --square-dark-soft: #668953;
  --board-frame: #50693f;
}

body.board-theme-slate,
body.board-theme-lid-grey {
  --square-light: #d8dce0;
  --square-dark: #7d8791;
  --square-light-soft: #edf0f2;
  --square-dark-soft: #646f7a;
  --board-frame: #4a535c;
}

body.board-theme-berry,
body.board-theme-lid-purple {
  --square-light: #e3d2e8;
  --square-dark: #9871a5;
  --square-light-soft: #f0e2f4;
  --square-dark-soft: #805b8f;
  --board-frame: #60436c;
}

body.board-theme-marble,
body.board-theme-lid-marble {
  --square-light: #eee9dd;
  --square-dark: #a1988c;
  --square-light-soft: #fbf7ee;
  --square-dark-soft: #867b70;
  --board-frame: #635c52;
}

body.board-theme-steel,
body.board-theme-lid-metal {
  --square-light: #d2d8dd;
  --square-dark: #647381;
  --square-light-soft: #e8edf0;
  --square-dark-soft: #4f5d69;
  --board-frame: #303943;
}

body.board-theme-paper,
body.board-theme-lid-newspaper {
  --square-light: #f4efdf;
  --square-dark: #b9ae98;
  --square-light-soft: #fff9e9;
  --square-dark-soft: #9d927d;
  --board-frame: #756b5a;
}

body.board-theme-classic,
body.board-theme-wooden,
body.board-theme-dark,
body.board-theme-light,
body.board-theme-blue,
body.board-theme-green,
body.board-theme-ocean,
body.board-theme-walnut,
body.board-theme-forest,
body.board-theme-slate,
body.board-theme-berry,
body.board-theme-marble,
body.board-theme-steel,
body.board-theme-paper,
body.board-theme-lid-blue,
body.board-theme-lid-brown,
body.board-theme-lid-green,
body.board-theme-lid-grey,
body.board-theme-lid-purple,
body.board-theme-lid-marble,
body.board-theme-lid-metal,
body.board-theme-lid-newspaper {
  --board-light: var(--square-light);
  --board-dark: var(--square-dark);
  --light-square: var(--square-light);
  --dark-square: var(--square-dark);
  --dark-square-hover: var(--square-dark-soft);
}

body.board-theme-classic .board,
body.board-theme-wooden .board,
body.board-theme-dark .board,
body.board-theme-light .board,
body.board-theme-blue .board,
body.board-theme-green .board,
body.board-theme-ocean .board,
body.board-theme-walnut .board,
body.board-theme-forest .board,
body.board-theme-slate .board,
body.board-theme-berry .board,
body.board-theme-marble .board,
body.board-theme-steel .board,
body.board-theme-paper .board,
body.board-theme-lid-blue .board,
body.board-theme-lid-brown .board,
body.board-theme-lid-green .board,
body.board-theme-lid-grey .board,
body.board-theme-lid-purple .board,
body.board-theme-lid-marble .board,
body.board-theme-lid-metal .board,
body.board-theme-lid-newspaper .board {
  border-color: var(--board-frame);
  background: var(--board-frame);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.18),
    0 24px 54px rgba(0, 0, 0, 0.42),
    inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

body.board-theme-classic .square.light,
body.board-theme-wooden .square.light,
body.board-theme-dark .square.light,
body.board-theme-light .square.light,
body.board-theme-blue .square.light,
body.board-theme-green .square.light,
body.board-theme-ocean .square.light,
body.board-theme-walnut .square.light,
body.board-theme-forest .square.light,
body.board-theme-slate .square.light,
body.board-theme-berry .square.light,
body.board-theme-marble .square.light,
body.board-theme-steel .square.light,
body.board-theme-paper .square.light {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.26), transparent 42%),
    linear-gradient(315deg, rgba(65, 55, 45, 0.12), transparent 58%),
    var(--board-light);
}

body.board-theme-classic .square.dark,
body.board-theme-wooden .square.dark,
body.board-theme-dark .square.dark,
body.board-theme-light .square.dark,
body.board-theme-blue .square.dark,
body.board-theme-green .square.dark,
body.board-theme-ocean .square.dark,
body.board-theme-walnut .square.dark,
body.board-theme-forest .square.dark,
body.board-theme-slate .square.dark,
body.board-theme-berry .square.dark,
body.board-theme-marble .square.dark,
body.board-theme-steel .square.dark,
body.board-theme-paper .square.dark {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.12), transparent 38%),
    linear-gradient(315deg, rgba(0, 0, 0, 0.18), transparent 58%),
    var(--board-dark);
}

body.board-theme-marble .square.light,
body.board-theme-marble .square.dark,
body.board-theme-lid-marble .square.light,
body.board-theme-lid-marble .square.dark {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.26), transparent 32%),
    linear-gradient(45deg, rgba(90, 80, 70, 0.1) 0 12%, transparent 12% 30%, rgba(255, 255, 255, 0.1) 30% 44%, transparent 44%),
    var(--board-light);
}

body.board-theme-marble .square.dark,
body.board-theme-lid-marble .square.dark {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.18), transparent 32%),
    linear-gradient(45deg, rgba(45, 38, 32, 0.18) 0 12%, transparent 12% 30%, rgba(255, 255, 255, 0.08) 30% 44%, transparent 44%),
    var(--board-dark);
}

body.pieces-style-classic .piece,
body.pieces-style-classic .tool-piece,
body.pieces-style-glossy .piece,
body.pieces-style-glossy .tool-piece,
body.pieces-style-tournament .piece,
body.pieces-style-tournament .tool-piece,
body.pieces-style-fabirovsky .piece,
body.pieces-style-fabirovsky .tool-piece {
  border-width: 2px;
  box-shadow:
    0 10px 18px rgba(0, 0, 0, 0.28),
    inset 0 2px 4px rgba(255, 255, 255, 0.22),
    inset 0 -5px 10px rgba(0, 0, 0, 0.18);
}

body.pieces-style-classic .piece::before,
body.pieces-style-classic .tool-piece::before,
body.pieces-style-glossy .piece::before,
body.pieces-style-glossy .tool-piece::before,
body.pieces-style-tournament .piece::before,
body.pieces-style-tournament .tool-piece::before,
body.pieces-style-fabirovsky .piece::before,
body.pieces-style-fabirovsky .tool-piece::before {
  width: 48%;
  border-width: 2px;
  opacity: 0.42;
  box-shadow: none;
}

body.pieces-style-classic .piece.white,
body.pieces-style-classic .tool-piece.white,
body.pieces-style-glossy .piece.white,
body.pieces-style-glossy .tool-piece.white,
body.pieces-style-tournament .piece.white,
body.pieces-style-tournament .tool-piece.white,
body.pieces-style-fabirovsky .piece.white,
body.pieces-style-fabirovsky .tool-piece.white {
  color: #7b6f60;
  border-color: #ffffff;
  background:
    radial-gradient(circle at 34% 26%, #ffffff 0 14%, #f7f2e8 36%, #e4d8c8 64%, #b7aa99 100%);
}

body.pieces-style-classic .piece.black,
body.pieces-style-classic .tool-piece.black,
body.pieces-style-glossy .piece.black,
body.pieces-style-glossy .tool-piece.black,
body.pieces-style-tournament .piece.black,
body.pieces-style-tournament .tool-piece.black,
body.pieces-style-fabirovsky .piece.black,
body.pieces-style-fabirovsky .tool-piece.black {
  color: #d7dde6;
  border-color: #222b36;
  background:
    radial-gradient(circle at 34% 26%, #5b6675 0 13%, #2d3644 36%, #151b24 66%, #070b10 100%);
}

body.pieces-style-flat-ring .piece,
body.pieces-style-flat-ring .tool-piece,
body.pieces-style-lid-flat .piece,
body.pieces-style-lid-flat .tool-piece {
  border-width: 2px;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.24);
}

body.pieces-style-flat-ring .piece::before,
body.pieces-style-flat-ring .tool-piece::before,
body.pieces-style-lid-flat .piece::before,
body.pieces-style-lid-flat .tool-piece::before {
  width: 56%;
  opacity: 0.36;
  box-shadow: none;
}

body.pieces-style-flat-ring .piece.white,
body.pieces-style-flat-ring .tool-piece.white,
body.pieces-style-lid-flat .piece.white,
body.pieces-style-lid-flat .tool-piece.white {
  color: #786d5d;
  border-color: #fffaf0;
  background: #f3eadc;
}

body.pieces-style-flat-ring .piece.black,
body.pieces-style-flat-ring .tool-piece.black,
body.pieces-style-lid-flat .piece.black,
body.pieces-style-lid-flat .tool-piece.black {
  color: #d4dbe5;
  border-color: #26303d;
  background: #151b24;
}

body.pieces-style-outline .piece,
body.pieces-style-outline .tool-piece,
body.pieces-style-lid-outline .piece,
body.pieces-style-lid-outline .tool-piece {
  border-width: 4px;
  background: transparent;
  box-shadow:
    0 8px 14px rgba(0, 0, 0, 0.24),
    inset 0 0 0 5px rgba(255, 255, 255, 0.05);
}

body.pieces-style-outline .piece::before,
body.pieces-style-outline .tool-piece::before,
body.pieces-style-lid-outline .piece::before,
body.pieces-style-lid-outline .tool-piece::before {
  width: 48%;
  border-width: 3px;
  opacity: 0.72;
}

body.pieces-style-outline .piece.white,
body.pieces-style-outline .tool-piece.white,
body.pieces-style-lid-outline .piece.white,
body.pieces-style-lid-outline .tool-piece.white {
  color: #ffffff;
  border-color: #ffffff;
}

body.pieces-style-outline .piece.black,
body.pieces-style-outline .tool-piece.black,
body.pieces-style-lid-outline .piece.black,
body.pieces-style-lid-outline .tool-piece.black {
  color: #101820;
  border-color: #101820;
}

body.pieces-style-wood .piece,
body.pieces-style-wood .tool-piece,
body.pieces-style-lid-wood .piece,
body.pieces-style-lid-wood .tool-piece {
  border-width: 2px;
  box-shadow:
    0 11px 18px rgba(42, 25, 12, 0.28),
    inset 0 3px 5px rgba(255, 255, 255, 0.22),
    inset 0 -6px 12px rgba(0, 0, 0, 0.2);
}

body.pieces-style-wood .piece.white,
body.pieces-style-wood .tool-piece.white,
body.pieces-style-lid-wood .piece.white,
body.pieces-style-lid-wood .tool-piece.white {
  color: #8b6d45;
  border-color: #f4dfb8;
  background:
    radial-gradient(circle at 35% 28%, #fff4ce 0 13%, #ddb878 42%, #9e7040 100%);
}

body.pieces-style-wood .piece.black,
body.pieces-style-wood .tool-piece.black,
body.pieces-style-lid-wood .piece.black,
body.pieces-style-lid-wood .tool-piece.black {
  color: #d8b77c;
  border-color: #4f3320;
  background:
    radial-gradient(circle at 35% 28%, #8b5d35 0 12%, #4b2f1f 42%, #1c120c 100%);
}

/* Feature fixes: editor layout, exports, IDF columns, and position search. */
.board-toolbar {
  flex-wrap: nowrap;
  justify-content: flex-start;
}

.mode-button {
  width: 38px;
  min-width: 38px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  font-size: 1rem;
}

.analysis-view.editor-mode-active .board-editor-layout {
  width: min(74vmin, 720px);
  max-width: 100%;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

.analysis-view.editor-mode-active .board {
  width: 100%;
}

.analysis-view.editor-mode-active .editor-panel {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(150px, 0.8fr);
  gap: 12px;
}

.analysis-view.editor-mode-active .editor-actions {
  grid-column: 1 / -1;
}

.flying-position-controls {
  flex: 1 1 auto;
  min-width: 0;
  grid-template-columns: auto minmax(150px, 1fr) 54px 38px 38px;
}

.flying-icon-button {
  width: 38px;
  min-width: 38px;
  padding: 0;
  text-align: center;
  font-size: 1rem;
}

.library-search-mode-select {
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-button);
  background: rgba(3, 7, 18, 0.72);
  color: var(--text-main);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 800;
}

.library-search-mode-select:focus {
  border-color: rgba(22, 119, 255, 0.62);
  box-shadow: 0 0 0 3px rgba(22, 119, 255, 0.16);
  outline: none;
}

.flying-column-field {
  display: grid;
  grid-template-columns: 54px;
  gap: 0;
  align-items: center;
  color: var(--text-soft);
  font-size: 0.74rem;
  font-weight: 850;
  text-transform: uppercase;
}

.flying-column-input {
  width: 54px;
  min-height: 38px;
  padding: 0 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-button);
  background: rgba(3, 7, 18, 0.72);
  color: var(--text-main);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 900;
  text-align: center;
}

.flying-column-input:focus {
  border-color: rgba(22, 119, 255, 0.58);
  box-shadow: 0 0 0 3px rgba(22, 119, 255, 0.16);
  outline: none;
}

.board-export-menu-wrap {
  position: relative;
  display: inline-flex;
}

.board-export-menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 24;
  min-width: 148px;
  display: grid;
  gap: 4px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-button);
  background:
    linear-gradient(180deg, rgba(17, 24, 39, 0.96), rgba(15, 23, 42, 0.94)),
    var(--bg-panel);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.34);
}

.board-export-menu[hidden] {
  display: none;
}

.board-export-action {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 850;
  text-align: left;
}

.board-export-action:hover:not(:disabled),
.board-export-action:focus-visible {
  border-color: rgba(22, 119, 255, 0.42);
  background: rgba(22, 119, 255, 0.14);
  color: var(--text-main);
  outline: none;
}

.board-export-action:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.library-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

.library-search-controls {
  display: grid;
  grid-template-columns: minmax(92px, auto) minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.library-search-mode-select {
  width: 100%;
  padding: 0 8px;
}

.library-search-input:disabled {
  cursor: default;
  opacity: 0.78;
}

.book-purpose {
  max-width: 720px;
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

@media (max-width: 1180px) {
  .flying-position-controls {
    grid-template-columns: auto minmax(150px, 1fr) 54px 38px 38px;
  }

  .flying-position-button {
    grid-column: auto;
  }
}

@media (max-width: 900px) {
  .analysis-view.editor-mode-active .editor-panel {
    grid-template-columns: 1fr;
  }

  .analysis-view.editor-mode-active .editor-actions {
    grid-column: auto;
  }

  .flying-position-controls {
    grid-template-columns: auto minmax(120px, 1fr) 54px 38px 38px;
  }

  .flying-position-label,
  .flying-position-select {
    grid-column: auto;
  }

  .flying-position-button {
    width: 38px;
  }

  .flying-column-field {
    grid-column: auto;
    grid-template-columns: 54px;
  }
}

/* Layout controls: collapsible sidebar, compact topbar, and board size setting. */
.app-shell {
  transition: grid-template-columns 180ms ease;
}

.sidebar-brand {
  position: relative;
}

.sidebar-collapse-button,
.sidebar-expand-button {
  width: 30px;
  min-width: 30px;
  min-height: 30px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.7);
  color: var(--text-soft);
  cursor: pointer;
  font: inherit;
  font-size: 1rem;
  font-weight: 900;
}

.sidebar-collapse-button {
  margin-left: auto;
}

.sidebar-expand-button {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 42;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.32);
}

.sidebar-expand-button[hidden] {
  display: none;
}

.sidebar-collapse-button:hover,
.sidebar-collapse-button:focus-visible,
.sidebar-expand-button:hover,
.sidebar-expand-button:focus-visible {
  border-color: rgba(22, 119, 255, 0.48);
  background: var(--button-hover);
  color: var(--text-main);
  outline: none;
}

.app-shell.sidebar-collapsed {
  grid-template-columns: 0 minmax(0, 1fr);
}

.app-shell.sidebar-collapsed .app-sidebar {
  width: 280px;
  pointer-events: none;
  opacity: 0;
  transform: translateX(-100%);
}

.app-shell.sidebar-collapsed .app {
  width: min(1540px, calc(100% - 28px));
}

.analysis-view .workspace {
  grid-template-columns: minmax(520px, var(--board-size)) minmax(390px, 1fr);
}

.app-shell.sidebar-collapsed .analysis-view .workspace {
  grid-template-columns: minmax(520px, var(--board-size)) minmax(500px, 1fr);
}

.topbar {
  min-height: 44px;
  margin-bottom: 8px;
  padding: 6px 10px;
  gap: 10px;
}

.topbar-actions {
  gap: 6px;
}

.topbar .eyebrow {
  margin-bottom: 1px;
  font-size: 0.64rem;
  line-height: 1;
}

.topbar h1 {
  font-size: clamp(1rem, 1.35vw, 1.25rem);
  line-height: 1.05;
}

.topbar .app-subtitle {
  margin-top: 2px;
  font-size: 0.72rem;
  line-height: 1.1;
}

.topbar .status {
  min-height: 26px;
  min-width: 112px;
  padding: 3px 8px;
  font-size: 0.74rem;
}

.topbar .library-toggle {
  min-height: 28px;
  padding: 0 9px;
  font-size: 0.76rem;
}

.board,
.board-editor-layout,
.board-toolbar,
.board-quick-actions,
.board-title-form,
.analysis-panel,
.analysis-view.editor-mode-active .board-editor-layout {
  width: min(var(--board-size), 100%);
}

.moves-panel {
  height: min(var(--board-size), calc(100vh - 104px));
  min-height: 420px;
  max-height: calc(100vh - 86px);
}

.analysis-scale {
  height: min(var(--board-size), calc(100vh - 104px));
}

.board-size-field {
  gap: 8px;
}

.board-size-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.board-size-heading output {
  color: var(--text-main);
  font-weight: 900;
  text-transform: none;
}

.board-size-range {
  width: 100%;
  accent-color: var(--accent);
}

@media (max-width: 900px) {
  .app-shell,
  .app-shell.sidebar-collapsed {
    grid-template-columns: 1fr;
  }

  .app-shell.sidebar-collapsed .app-sidebar {
    width: auto;
    height: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-bottom: 0;
    transform: translateY(-100%);
  }

  .app-shell.sidebar-collapsed .app {
    width: min(100% - 20px, 760px);
  }

  .app-shell.sidebar-collapsed .analysis-view .workspace {
    grid-template-columns: 1fr;
  }

  .board,
  .board-editor-layout,
  .board-toolbar,
  .board-quick-actions,
  .board-title-form,
  .analysis-panel,
  .analysis-view.editor-mode-active .board-editor-layout {
    width: min(var(--board-size), 94vw);
  }

  .moves-panel {
    height: auto;
    min-height: 360px;
    max-height: none;
  }
}

/* ===== Тренажёр дебютов ===== */
.opening-trainer-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  min-width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--button-bg);
  color: var(--text);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.opening-trainer-toggle:hover,
.opening-trainer-toggle:focus-visible {
  border-color: rgba(122, 162, 247, 0.58);
  background: var(--button-hover);
  box-shadow: 0 0 0 3px rgba(122, 162, 247, 0.08);
  outline: none;
}

.opening-trainer-toggle.active {
  border-color: rgba(122, 162, 247, 0.6);
  background: linear-gradient(180deg, rgba(122, 162, 247, 0.26), rgba(122, 162, 247, 0.14));
  color: var(--accent-strong);
}

.opening-trainer-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border: 1px solid rgba(122, 162, 247, 0.32);
  border-radius: var(--radius);
  background: rgba(122, 162, 247, 0.06);
}

.opening-trainer-title {
  margin: 0;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.opening-trainer-prompt {
  margin: 0;
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.35;
}

.opening-trainer-form {
  display: flex;
  gap: 8px;
}

.opening-trainer-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  color: var(--text);
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}

.opening-trainer-input:focus-visible {
  border-color: rgba(122, 162, 247, 0.58);
  outline: none;
  box-shadow: 0 0 0 3px rgba(122, 162, 247, 0.08);
}

.opening-trainer-button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--button-bg);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

.opening-trainer-button:hover,
.opening-trainer-button:focus-visible {
  border-color: rgba(122, 162, 247, 0.58);
  background: var(--button-hover);
  color: var(--accent-strong);
  outline: none;
}

.opening-trainer-button.primary {
  border-color: rgba(122, 162, 247, 0.34);
  background: linear-gradient(180deg, rgba(122, 162, 247, 0.24), rgba(122, 162, 247, 0.13));
  color: var(--accent-strong);
}

.opening-trainer-feedback {
  margin: 0;
  min-height: 1.1em;
  font-size: 0.85rem;
  font-weight: 700;
}

.opening-trainer-feedback.correct {
  color: #6fcf97;
}

.opening-trainer-feedback.incorrect {
  color: var(--danger);
}

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

.opening-trainer-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  padding: 8px 12px;
  border: 1px solid rgba(122, 162, 247, 0.3);
  border-radius: var(--radius-sm);
  background: rgba(122, 162, 247, 0.08);
}

.opening-trainer-banner-text {
  font-size: 0.85rem;
  font-weight: 700;
}

.opening-trainer-banner-text.correct {
  color: #6fcf97;
}

.opening-trainer-banner-text.revealed {
  color: var(--muted);
}

.move.trainer-answer {
  border-color: rgba(111, 207, 151, 0.7);
  box-shadow: 0 0 0 2px rgba(111, 207, 151, 0.35);
}

/* Побочные варианты читаются как полноценная нотация, а не тусклый серый текст.
   Единый читаемый цвет для всей ветки — чтобы все ходы вариантов выглядели
   одинаково (раньше часть оставалась тусклой). Иерархию задают скобки,
   отступ и рамка слева, а не приглушённость. */
.variation-line {
  color: var(--text);
}
