/* Blundermine — the app's one stylesheet.
 *
 * Tokens first, then the shell (sidebar on wide screens, tab bar on narrow
 * ones), then the pieces every screen is built from, then the screens. */

:root {
  color-scheme: dark;
  --bg: #0f1013;
  --surface: #17181c;
  --surface-2: #1e2026;
  --surface-3: #262931;
  --line: #262a33;
  --line-2: #343945;
  --text: #eceef2;
  --text-2: #a8afbc;
  --text-3: #6f7787;
  --accent: #f2b63d;
  --accent-ink: #1c1300;
  --accent-soft: rgba(242, 182, 61, 0.14);
  --tactic: #f2b63d;
  --tactic-soft: rgba(242, 182, 61, 0.14);
  --only: #62b4ff;
  --only-soft: rgba(98, 180, 255, 0.14);
  --blunder: #ff6473;
  --blunder-soft: rgba(255, 100, 115, 0.14);
  --opening: #b69cff;
  --opening-soft: rgba(182, 156, 255, 0.15);
  --good: #4cc474;
  --good-soft: rgba(76, 196, 116, 0.14);
  --graph-white: rgba(236, 238, 242, 0.2);
  --graph-black: rgba(0, 0, 0, 0.5);
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 10px 30px rgba(0, 0, 0, 0.35);
  --r-lg: 16px;
  --r-md: 12px;
  --r-sm: 8px;
  --nav-w: 232px;
  --font: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f3ef;
  --surface: #ffffff;
  --surface-2: #f6f5f1;
  --surface-3: #ecebe5;
  --line: #e5e3dc;
  --line-2: #d3d0c7;
  --text: #17181c;
  --text-2: #575d69;
  --text-3: #8b909b;
  --accent: #d19a12;
  --accent-ink: #1c1300;
  --accent-soft: rgba(209, 154, 18, 0.14);
  --tactic: #b8830a;
  --tactic-soft: rgba(184, 131, 10, 0.12);
  --only: #1f7fd8;
  --only-soft: rgba(31, 127, 216, 0.12);
  --blunder: #d8404f;
  --blunder-soft: rgba(216, 64, 79, 0.12);
  --opening: #7a4fd6;
  --opening-soft: rgba(122, 79, 214, 0.12);
  --good: #1f9c50;
  --good-soft: rgba(31, 156, 80, 0.12);
  --graph-white: #f1ecdc;
  --graph-black: #4a4d56;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 10px 30px rgba(20, 20, 20, 0.07);
}

* {
  box-sizing: border-box;
}
html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  font-feature-settings: "tnum" 0;
  -webkit-font-smoothing: antialiased;
}
a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
[hidden] {
  display: none !important;
}
h1,
h2,
h3,
p {
  margin: 0;
}
svg {
  display: block;
}
.icon {
  display: inline-flex;
  flex: none;
}
.icon svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.num {
  font-variant-numeric: tabular-nums;
}
.muted {
  color: var(--text-2);
}
.faint {
  color: var(--text-3);
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* ---- shell ------------------------------------------------------------ */

.app {
  display: grid;
  grid-template-columns: var(--nav-w) minmax(0, 1fr);
  min-height: 100vh;
}
.nav {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 22px 14px 18px;
  border-right: 1px solid var(--line);
  background: var(--bg);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 20px;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}
.brand:hover {
  text-decoration: none;
}
.brand .mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
}
.brand span {
  color: var(--accent);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--text-2);
  font-weight: 500;
  text-align: left;
}
.nav-item:hover {
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}
.nav-item[aria-current="page"] {
  background: var(--surface-2);
  color: var(--text);
}
.nav-item[aria-current="page"] .icon {
  color: var(--accent);
}
.nav-spacer {
  flex: 1;
}
.nav-user {
  padding: 12px 12px 0;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--text-3);
}
.nav-user .email {
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--text-3);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.link-btn:hover {
  color: var(--text);
}

.main {
  min-width: 0;
}
.screen {
  max-width: 1080px;
  margin: 0 auto;
  padding: 30px 32px 72px;
}
.screen-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.screen-head h1 {
  font-size: 27px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.15;
}
.screen-head p {
  margin-top: 4px;
  color: var(--text-2);
}
.screen-head .actions {
  display: flex;
  gap: 8px;
  flex: none;
}

.topbar,
.tabbar {
  display: none;
}

@media (max-width: 880px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
  }
  .nav {
    display: none;
  }
  .topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: env(safe-area-inset-top, 0px) 8px 0;
    height: calc(52px + env(safe-area-inset-top, 0px));
    background: color-mix(in srgb, var(--bg) 84%, transparent);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--line);
  }
  .topbar h1 {
    flex: 1;
    font-size: 16.5px;
    font-weight: 600;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .topbar .slot {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .topbar .slot button {
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 10px;
    background: none;
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .screen {
    padding: 16px 16px calc(88px + env(safe-area-inset-bottom, 0px));
  }
  .screen-head {
    margin-bottom: 14px;
  }
  .screen-head h1 {
    display: none;
  }
  .screen-head p {
    margin-top: 0;
  }
  .tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
  }
  .tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px 4px;
    border: 0;
    border-radius: 10px;
    background: none;
    color: var(--text-3);
    font-size: 11px;
    font-weight: 500;
  }
  .tab .icon svg {
    width: 23px;
    height: 23px;
  }
  .tab[aria-current="page"] {
    color: var(--accent);
  }
}

/* ---- pieces ----------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}
.card.pad {
  padding: 18px 20px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, filter 0.12s;
}
.btn:hover:not(:disabled) {
  background: var(--surface-3);
  text-decoration: none;
}
.btn:disabled {
  opacity: 0.5;
  cursor: default;
}
.btn .icon svg {
  width: 18px;
  height: 18px;
}
.btn-primary {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-ink);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent);
  filter: brightness(1.07);
}
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-2);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--text);
}
/* A choice that will probably hurt: red, so it is not clicked in passing. */
.btn-danger {
  color: var(--blunder);
}
.btn-danger:hover:not(:disabled) {
  background: var(--blunder-soft);
  color: var(--blunder);
}
.btn-sm {
  height: 34px;
  padding: 0 12px;
  font-size: 13.5px;
}
.btn-lg {
  height: 46px;
  padding: 0 22px;
  font-size: 16px;
}
.btn-block {
  width: 100%;
}
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.field {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  transition: border-color 0.12s;
}
.field::placeholder {
  color: var(--text-3);
}
.field:focus {
  outline: 0;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea.field {
  resize: none;
  min-height: 46px;
  line-height: 1.45;
  font-family: var(--mono);
  font-size: 13.5px;
}
.label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}
.help {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-3);
}
.help code {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text-2);
}

.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
}
.seg button {
  flex: 1;
  height: 32px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--text-2);
  font-weight: 500;
  white-space: nowrap;
}
.seg button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}
.seg.block {
  display: flex;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
}
.chip[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--text);
  background: var(--accent-soft);
}
.chip .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}
.chip.tactic .dot {
  background: var(--tactic);
}
.chip.only_move .dot {
  background: var(--only);
}
.chip.blunder .dot {
  background: var(--blunder);
}
.chip.opening .dot {
  background: var(--opening);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.badge.tactic {
  background: var(--tactic-soft);
  color: var(--tactic);
}
.badge.only_move {
  background: var(--only-soft);
  color: var(--only);
}
.badge.blunder {
  background: var(--blunder-soft);
  color: var(--blunder);
}
.badge.opening {
  background: var(--opening-soft);
  color: var(--opening);
}
.badge.solved {
  background: var(--good-soft);
  color: var(--good);
}
.badge.neutral {
  background: var(--surface-3);
  color: var(--text-2);
}
.badge .icon svg {
  width: 14px;
  height: 14px;
  stroke-width: 2.4;
}
.tag {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
}

.notice {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text-2);
  font-size: 14px;
}
.notice.error {
  border-color: color-mix(in srgb, var(--blunder) 55%, transparent);
  color: var(--text);
}
.notice.accent {
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
}
.notice .btn-row {
  margin-top: 10px;
}
.notice strong {
  color: var(--text);
}

.empty {
  padding: 40px 24px;
  text-align: center;
  color: var(--text-2);
}
.empty h2 {
  margin-bottom: 6px;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}
.empty .btn-row {
  justify-content: center;
  margin-top: 16px;
}

.progress {
  height: 6px;
  overflow: hidden;
  border-radius: 3px;
  background: var(--surface-3);
}
.progress > div {
  height: 100%;
  width: 0;
  border-radius: 3px;
  background: var(--accent);
  transition: width 0.35s ease;
}
.progress.indeterminate > div {
  width: 30%;
  animation: slide 1.2s ease-in-out infinite;
}
@keyframes slide {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(400%);
  }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  z-index: 40;
  transform: translate(-50%, 8px);
  padding: 10px 16px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity 0.18s, transform 0.18s;
  pointer-events: none;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
@media (max-width: 880px) {
  .toast {
    bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  }
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--line-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.loading-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 24px 0;
  color: var(--text-2);
}

/* ---- puzzle panel (train and game screens) ----------------------------- */

.puzzle {
  display: grid;
  grid-template-columns: minmax(280px, 520px) minmax(240px, 1fr);
  grid-template-areas:
    "board head"
    "board foot";
  grid-template-rows: auto 1fr;
  gap: 18px 28px;
  align-items: start;
}
.puzzle-board {
  grid-area: board;
  min-width: 0;
}
.puzzle-board iframe {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  color-scheme: normal;
}
.puzzle-board iframe:not(.sized) {
  aspect-ratio: 1 / 1.12;
}
.puzzle-head {
  grid-area: head;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.puzzle-foot {
  grid-area: foot;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.puzzle-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.puzzle-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.puzzle-title .san {
  font-weight: 700;
}
.puzzle-evals {
  color: var(--text-2);
  font-size: 14px;
}
.puzzle-evals b {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.puzzle-why {
  color: var(--text-2);
  font-size: 14px;
}
.puzzle-prompt {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.puzzle-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.puzzle-game {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  font-size: 13px;
  color: var(--text-3);
}
.puzzle-game a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.puzzle-game .icon svg {
  width: 14px;
  height: 14px;
}
.puzzle-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.puzzle-answer {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
}
.puzzle-answer summary {
  padding: 10px 14px;
  cursor: pointer;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.puzzle-answer summary::-webkit-details-marker {
  display: none;
}
.puzzle-answer summary .icon svg {
  width: 16px;
  height: 16px;
  transition: transform 0.15s;
}
.puzzle-answer[open] summary .icon svg {
  transform: rotate(90deg);
}
.puzzle-answer .lines {
  padding: 0 14px 12px;
}
.puzzle-answer .line {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}
.puzzle-answer .line + .line {
  margin-top: 4px;
  color: var(--text-2);
  font-weight: 500;
}
.puzzle.solved .puzzle-board {
  position: relative;
}

@media (max-width: 880px) {
  .puzzle {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "head"
      "board"
      "foot";
    gap: 14px;
  }
  .puzzle-title {
    font-size: 19px;
  }
  .puzzle-actions .btn {
    flex: 1;
  }
}

/* ---- train ------------------------------------------------------------- */

.train-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  margin-bottom: 18px;
}
.train-stats {
  display: flex;
  align-items: baseline;
  gap: 14px;
  color: var(--text-2);
  font-size: 14px;
}
.train-stats b {
  color: var(--text);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}
.train-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.train-pos {
  font-size: 13px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.train-stage {
  margin-top: 6px;
}

/* ---- games list -------------------------------------------------------- */

.games-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  margin-bottom: 14px;
}
.day {
  margin: 20px 0 8px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-3);
}
.day:first-child {
  margin-top: 4px;
}
.game-list {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
}
.game-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 11px 14px;
  border: 0;
  border-top: 1px solid var(--line);
  background: none;
  color: var(--text);
  text-align: left;
}
.game-row:first-child {
  border-top: 0;
}
.game-row:hover {
  background: var(--surface-2);
}
.res {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  font-size: 12.5px;
  font-weight: 700;
  background: var(--surface-3);
  color: var(--text-2);
}
.res.won {
  background: var(--good-soft);
  color: var(--good);
}
.res.lost {
  background: var(--blunder-soft);
  color: var(--blunder);
}
.game-main {
  min-width: 0;
}
.game-opp {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.game-sub {
  margin-top: 1px;
  font-size: 12.5px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.game-side {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.count {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 12.5px;
}
.count .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}
.count.tactic {
  background: var(--tactic-soft);
  color: var(--tactic);
}
.count.tactic .dot {
  background: var(--tactic);
}
.count.only_move {
  background: var(--only-soft);
  color: var(--only);
}
.count.only_move .dot {
  background: var(--only);
}
.count.blunder {
  background: var(--blunder-soft);
  color: var(--blunder);
}
.count.blunder .dot {
  background: var(--blunder);
}
.count.opening {
  background: var(--opening-soft);
  color: var(--opening);
}
.count.opening .dot {
  background: var(--opening);
}
.count.due {
  background: var(--accent-soft);
  color: var(--accent);
}
.count.neutral {
  background: var(--surface-3);
  color: var(--text-2);
}
.count.done {
  color: var(--good);
  background: var(--good-soft);
}
.count.clean {
  color: var(--text-3);
  background: var(--surface-3);
}
.game-row .chev {
  color: var(--text-3);
}
.game-row .chev svg {
  width: 16px;
  height: 16px;
}
@media (max-width: 560px) {
  .game-row {
    grid-template-columns: 30px minmax(0, 1fr) auto;
    gap: 10px;
    padding: 10px 12px;
  }
  .game-side {
    gap: 4px;
  }
  .game-row .chev {
    display: none;
  }
}

/* ---- game report ------------------------------------------------------- */

.game-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px 16px;
  margin-bottom: 16px;
}
.game-head h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.game-head .meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  margin-top: 4px;
  color: var(--text-2);
  font-size: 14px;
}
.game-head .meta .res {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  font-size: 11px;
}
.back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 12px;
  color: var(--text-3);
  font-size: 13.5px;
  font-weight: 500;
}
.back .icon svg {
  width: 16px;
  height: 16px;
}
@media (max-width: 880px) {
  .back {
    display: none;
  }
  .game-head h1 {
    font-size: 20px;
  }
}

.graph {
  position: relative;
  padding: 10px 12px 6px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
}
.graph svg {
  width: 100%;
  height: 112px;
  display: block;
}
.graph circle.mark {
  cursor: pointer;
}
.graph .caption {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-3);
}

.pills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 16px 0 14px;
}
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 36px;
  height: 32px;
  padding: 0 10px;
  border: 1.5px solid var(--line-2);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font-weight: 600;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}
.pill.tactic {
  border-color: color-mix(in srgb, var(--tactic) 60%, transparent);
  color: var(--tactic);
}
.pill.only_move {
  border-color: color-mix(in srgb, var(--only) 60%, transparent);
  color: var(--only);
}
.pill.blunder {
  border-color: color-mix(in srgb, var(--blunder) 60%, transparent);
  color: var(--blunder);
}
.pill.opening {
  border-color: color-mix(in srgb, var(--opening) 60%, transparent);
  color: var(--opening);
}
.pill.done {
  background: var(--good-soft);
  border-color: transparent;
  color: var(--good);
}
.pill[aria-current="true"] {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}
.pill .icon svg {
  width: 14px;
  height: 14px;
  stroke-width: 2.6;
}
.pills .spacer {
  flex: 1;
}
.pills .pos {
  font-size: 13px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.finished {
  padding: 28px 20px;
  text-align: center;
}
.finished h2 {
  font-size: 20px;
  margin-bottom: 4px;
}

/* ---- analyse ----------------------------------------------------------- */

.analyse-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.analyse-options {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
}
.analyse-options .opt {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.analyse-status {
  margin-top: 18px;
}
.stage-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.stage-row b {
  font-weight: 600;
}
.kinds {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 22px;
}
.kind {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
}
.kind h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}
.kind p {
  font-size: 13px;
  color: var(--text-2);
}
@media (max-width: 720px) {
  .kinds {
    grid-template-columns: 1fr;
  }
}

/* ---- settings ---------------------------------------------------------- */

.settings {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 720px;
}
.settings .card {
  padding: 4px 20px;
}
.settings h2 {
  padding: 16px 0 6px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-3);
}
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}
.row:first-of-type {
  border-top: 0;
}
.row .row-main {
  min-width: 0;
  flex: 1;
}
.row .row-title {
  font-weight: 600;
}
.row .row-sub {
  margin-top: 2px;
  font-size: 13px;
  color: var(--text-2);
}
.row .row-ctl {
  flex: none;
}
.row.stack {
  flex-direction: column;
  align-items: stretch;
}
.row.stack .row-ctl {
  margin-top: 10px;
}
.inline-form {
  display: flex;
  gap: 8px;
}
.inline-form .field {
  flex: 1;
  min-width: 0;
}
.board-options {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 10px;
}
.board-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px 8px;
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
}
.board-option svg {
  width: 64px;
  height: 64px;
  border-radius: 6px;
}
.board-option[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--text);
  background: var(--accent-soft);
}
.credits {
  padding: 12px 0 14px;
  font-size: 13px;
  color: var(--text-3);
  line-height: 1.6;
}
@media (max-width: 560px) {
  .row {
    flex-wrap: wrap;
  }
  .row .row-ctl {
    width: 100%;
  }
  .row .row-ctl .seg {
    display: flex;
  }
}

/* ---- sign-in ----------------------------------------------------------- */

.gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.gate-card {
  width: 100%;
  max-width: 400px;
  padding: 32px 28px;
  text-align: center;
}
.gate-card .brand {
  justify-content: center;
  padding: 0 0 16px;
  font-size: 24px;
}
.gate-card p {
  margin-bottom: 22px;
  color: var(--text-2);
}
.gate-card #gbutton {
  display: flex;
  justify-content: center;
  min-height: 44px;
}
.gate-card .denied {
  margin: 16px 0 0;
  color: var(--blunder);
  font-size: 13.5px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

/* ---- openings: shared ---------------------------------------------------- */

.nav-item .nav-badge,
.tab .nav-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.nav-item .nav-badge {
  margin-left: auto;
}
.tab {
  position: relative;
}
.tab .nav-badge {
  position: absolute;
  top: 1px;
  left: calc(50% + 6px);
}

.screen-head.many {
  flex-wrap: wrap;
}
.screen-head.many .actions {
  flex-wrap: wrap;
}
@media (max-width: 880px) {
  .screen-head.many .actions {
    width: 100%;
  }
  .screen-head.many .actions .btn {
    flex: 1 1 auto;
  }
  /* Four kinds and a speed select do not fit a phone on one line; they scroll
     sideways rather than wrapping into a second row above the board. */
  .train-filters {
    flex-wrap: nowrap;
    width: 100%;
    min-width: 0;
  }
  .train-filters .chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    min-width: 0;
    flex: 1;
    margin: -2px 0;
    padding: 2px 0;
  }
  .train-filters .chips::-webkit-scrollbar {
    display: none;
  }
  .train-filters .chip {
    flex: none;
  }
  .train-bar > div:first-child {
    width: 100%;
  }
}
.train-drill a {
  font-weight: 600;
}

.puzzle-opening-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}
.puzzle-comment {
  color: var(--text-2);
  font-size: 14px;
  font-style: italic;
}
.puzzle-stats {
  color: var(--text-3);
  font-size: 13px;
}
.puzzle-why b {
  color: var(--text);
}
.answer-comment {
  display: block;
  font-weight: 400;
  font-size: 13.5px;
  color: var(--text-2);
}

.opening-line {
  margin-top: 4px;
  color: var(--text-2);
  font-size: 13.5px;
  line-height: 1.55;
}
.opening-line .sep {
  white-space: pre;
}
.opening-line .opening-name {
  color: var(--opening);
  font-weight: 500;
}
.opening-line .opening-left {
  color: var(--text);
}
.graph .book-band {
  fill: var(--opening);
  opacity: 0.09;
}

.res.side-mark {
  font-size: 20px;
  line-height: 1;
}
.game-head .meta .res.side-mark {
  font-size: 16px;
}

.view-board {
  flex: none;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface-2);
}
.view-board .cm-chessboard .marker.last-move,
.view-board .cm-chessboard .marker.last-move use {
  fill: rgba(155, 199, 0, 0.41);
}
.view-board-error {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-3);
  font-size: 14px;
}

.book-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.book-panel .loading-row {
  padding: 12px 0;
}
.book-panel.loading {
  opacity: 0.45;
  transition: opacity 0.15s;
}
.book-name {
  font-weight: 600;
  color: var(--opening);
}
.book-sub {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 12px;
  font-size: 13px;
  color: var(--text-2);
}
.book-sub b {
  color: var(--text);
  font-weight: 600;
}
.book-moves {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.book-moves th {
  padding: 4px 6px;
  font-size: 11.5px;
  font-weight: 600;
  text-align: right;
  color: var(--text-3);
  white-space: nowrap;
}
.book-moves td {
  padding: 5px 6px;
  border-top: 1px solid var(--line);
  text-align: right;
  color: var(--text-2);
  white-space: nowrap;
}
.book-moves th:first-child,
.book-moves td:first-child {
  text-align: left;
  padding-left: 0;
}
.book-moves td.san {
  font-weight: 600;
  color: var(--text);
}
.book-more {
  align-self: flex-start;
  font-size: 13px;
}

/* ---- openings: learn ------------------------------------------------------ */

.learn {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
  gap: 20px;
  align-items: start;
}
.learn-list {
  min-width: 0;
}
.learn-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 10px;
}
.learn-count {
  margin-bottom: 8px;
  font-size: 13px;
}
.families {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.family {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
}
.family-head {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 11px 14px;
  border: 0;
  background: none;
  color: var(--text);
  text-align: left;
}
.family-head:hover {
  background: var(--surface-2);
}
.family-head .chev svg {
  width: 16px;
  height: 16px;
  color: var(--text-3);
  transition: transform 0.15s;
}
.family-head[aria-expanded="true"] .chev svg {
  transform: rotate(90deg);
}
.family-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 8px;
  min-width: 0;
}
.family-name {
  font-weight: 600;
  min-width: 0;
}
.family-head .spacer {
  flex: 1;
}
.family-meta {
  font-size: 12.5px;
  white-space: nowrap;
}
.family-lines {
  border-top: 1px solid var(--line);
}
.line-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 9px 14px 9px 38px;
  border: 0;
  border-top: 1px solid var(--line);
  background: none;
  color: var(--text);
  text-align: left;
}
.line-row:first-child {
  border-top: 0;
}
.line-row:hover {
  background: var(--surface-2);
}
.line-row[aria-pressed="true"] {
  background: var(--opening-soft);
}
.line-main {
  flex: 1;
  min-width: 0;
}
.line-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 500;
}
.dot-gambit {
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--opening);
}
.line-moves {
  margin-top: 1px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.line-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-size: 12.5px;
  white-space: nowrap;
}
.learn-more {
  margin-top: 4px;
}
.learn-panel {
  position: sticky;
  top: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}
.learn-panel-head {
  position: relative;
  padding-right: 56px;
}
.learn-panel-head h2 {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.3;
}
.learn-panel-head .line-moves {
  white-space: normal;
}
.learn-close {
  position: absolute;
  top: -6px;
  right: -8px;
}
.learn-empty {
  padding: 28px 8px;
  text-align: center;
  color: var(--text-3);
  font-size: 14px;
}
.learn-build {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.learn-build .help {
  margin-top: 0;
}
@media (max-width: 880px) {
  .learn {
    grid-template-columns: minmax(0, 1fr);
  }
  .learn-panel {
    position: static;
    max-height: none;
    order: -1;
  }
  .learn-panel.placeholder {
    display: none;
  }
  .learn-panel {
    scroll-margin-top: calc(64px + env(safe-area-inset-top, 0px));
  }
  .line-row {
    padding-left: 14px;
  }
}

/* ---- openings: import ----------------------------------------------------- */

.import-result {
  margin-top: 18px;
}
.import-summary {
  font-size: 15px;
  color: var(--text-2);
}
.import-summary b {
  color: var(--text);
}
.chapters {
  margin: 10px 0 0;
  padding-left: 22px;
  color: var(--text-2);
  font-size: 14px;
}
.chapters li {
  padding: 3px 0;
}
.chapters li span + span {
  margin-left: 8px;
}
.import-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 24px;
  margin-top: 16px;
}
.import-name {
  flex: 1;
  min-width: 200px;
}

/* ---- openings: repertoire ------------------------------------------------- */

.rep-row .count {
  white-space: nowrap;
}
@media (max-width: 560px) {
  /* A repertoire has more counts than a game; they go under the name. */
  .rep-row {
    grid-template-columns: 30px minmax(0, 1fr);
  }
  .rep-row .game-side {
    grid-column: 2;
    flex-wrap: wrap;
    justify-content: flex-start;
  }
  .family-count {
    display: none;
  }
}
@media (max-width: 880px) {
  .train-stats {
    flex-wrap: wrap;
    gap: 2px 12px;
  }
}
.rep-layout {
  display: grid;
  grid-template-columns: minmax(280px, 400px) minmax(0, 1fr);
  gap: 16px 24px;
  align-items: start;
}
/* The position column stays put; the tabs column scrolls past it. Taller
   than the window, it scrolls inside itself rather than pushing the board
   out of reach. */
.rep-side {
  position: sticky;
  top: 20px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.rep-board {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.rep-here {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.rep-book-button {
  display: none;
}
.rep-book {
  min-width: 0;
  padding: 0;
  overflow: hidden;
}
.rep-book > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px 11px 16px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.rep-book > summary::-webkit-details-marker {
  display: none;
}
.rep-book > summary:hover {
  background: var(--surface-2);
}
.rep-book-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-3);
}
.rep-book-sub {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  color: var(--text-2);
}
.rep-book-chev {
  flex: none;
  color: var(--text-3);
  transition: transform 0.15s;
}
.rep-book-chev svg {
  width: 18px;
  height: 18px;
}
.rep-book[open] > summary .rep-book-chev {
  transform: rotate(90deg);
}
/* Open, the table has the numbers; the row only needs to say what it is. */
.rep-book[open] > summary .rep-book-sub {
  visibility: hidden;
}
.rep-book[open] > summary {
  border-bottom: 1px solid var(--line);
}
.rep-book-body {
  padding: 10px 16px 14px;
}
.rep-main {
  min-width: 0;
}
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: none;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}
.tab-btn[aria-selected="true"] {
  color: var(--text);
  border-bottom-color: var(--accent);
}
.tab-count {
  padding: 0 7px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-3);
  font-size: 11.5px;
  line-height: 18px;
}
.tab-btn[aria-selected="true"] .tab-count {
  background: var(--opening-soft);
  color: var(--opening);
}
.rep-main .rep-list {
  margin-top: 0;
}
/* The book as a sheet, on a phone. */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
}
.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
}
.sheet-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 72vh;
  overflow-y: auto;
  padding: 10px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  border-radius: 16px 16px 0 0;
  background: var(--surface);
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.25);
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.rep-caption {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 14px;
}
.rep-caption-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
}
.rep-caption p {
  margin: 0;
  font-size: 13.5px;
}
.rep-here-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
/* A small menu for what is done to the whole repertoire. */
.menu {
  position: relative;
}
.menu > summary {
  list-style: none;
  cursor: pointer;
  min-width: 36px;
  padding: 0 10px;
  font-size: 18px;
  line-height: 1;
}
.menu > summary::-webkit-details-marker {
  display: none;
}
.menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 30;
  min-width: 200px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}
.menu-item {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--text);
  font-size: 14px;
  text-align: left;
}
.menu-item:hover {
  background: var(--surface-2);
}
.menu-item.danger {
  color: var(--blunder);
}
.rep-tree {
  min-width: 0;
  padding: 14px 16px;
}
.rep-book h2,
.rep-list h2 {
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-3);
}
.tree {
  font-size: 14.5px;
  line-height: 2;
  word-break: break-word;
}
.tree .mv {
  display: inline;
  margin: 0 1px;
  padding: 2px 4px;
  border: 0;
  border-radius: 5px;
  background: none;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.tree .mv.yours {
  color: var(--text);
  font-weight: 600;
}
.tree .mv:hover {
  background: var(--surface-2);
}
.tree .mv.at {
  background: var(--text);
  color: var(--bg);
}
.tree .mv .mv-num {
  margin-right: 3px;
  color: var(--text-3);
  font-weight: 400;
}
.tree .mv.at .mv-num {
  color: inherit;
}
.tree .mv.learned:not(.at) {
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--good) 70%, transparent);
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}
.tree .mv.trap:not(.at) {
  color: var(--opening);
}
.tree .mv.flag-unsound:not(.at) {
  color: var(--blunder);
}
.tree .mv.flag-dubious:not(.at) {
  color: var(--tactic);
}
.tree .nag {
  margin-left: 1px;
}
.tree .tree-row {
  display: block;
}
.tree .variations {
  margin: 2px 0 6px 10px;
  padding-left: 12px;
  border-left: 2px solid var(--line-2);
  line-height: 1.9;
}
.tree .variation {
  margin: 1px 0;
}
.tree .node-name {
  display: inline-block;
  margin: 0 6px 0 2px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--opening-soft);
  color: var(--opening);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 20px;
}
.tree .transposes {
  font-size: 13px;
}
.move-mark {
  display: inline-block;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  line-height: 18px;
}
.move-mark.trap {
  background: var(--opening-soft);
  color: var(--opening);
}
.move-mark.flag {
  background: var(--blunder-soft);
  color: var(--blunder);
}
.rep-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.rep-list-head h2 {
  margin: 0;
}
.rep-list {
  margin-top: 16px;
  padding: 14px 16px 6px;
}
.rep-list .help {
  margin: -4px 0 8px;
}
.rep-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.rep-more {
  margin: 4px 0 10px;
  font-size: 13px;
}
.rep-item-main {
  flex: 1;
  min-width: 220px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text);
  text-align: left;
}
.rep-item-title {
  font-weight: 600;
}
.rep-item-sub {
  font-size: 13px;
  color: var(--text-2);
}
.rep-item-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 6px;
  font-size: 13px;
}
.rep-item-dates {
  display: inline-flex;
  gap: 8px;
  margin-right: 6px;
  font-size: 12.5px;
}
@media (max-width: 560px) {
  /* Dates on their own line, so the three buttons stay together. */
  .rep-item-dates {
    flex-basis: 100%;
    margin-right: 0;
  }
}
@media (max-width: 880px) {
  .rep-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  /* On a phone the board alone stays in view, with the move and its actions;
     the book is behind a button, as a sheet, and the tabs scroll under. */
  /* The board has to stick against the whole page, not against the column
     that wraps it on a desktop — so on a phone that column is dissolved. */
  .rep-side {
    display: contents;
  }
  .rep-board {
    position: sticky;
    top: calc(52px + env(safe-area-inset-top, 0px));
    z-index: 5;
    align-items: center;
    padding: 8px 0;
    background: var(--bg);
  }
  .rep-board .view-board {
    width: 200px;
  }
  .rep-where {
    justify-content: center;
  }
  .rep-book {
    display: none;
  }
  .rep-book-button {
    display: inline-flex;
  }
  .rep-here {
    justify-content: center;
  }
  .rep-caption {
    align-items: center;
    text-align: center;
  }
  /* The note stays, but a long one must not push the board's actions off
     the screen while the board is stuck at the top. */
  .rep-caption .rep-note {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
}

/* ---- openings: drill ------------------------------------------------------ */

.drill-path {
  font-family: var(--mono);
  font-size: 13px;
  word-break: break-word;
}
.drill-note {
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  font-size: 14px;
  color: var(--text-2);
}
.drill-note p {
  margin-top: 4px;
}
.drill-note-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  color: var(--text);
  font-weight: 500;
}
.drill-note-title.good {
  color: var(--good);
  font-weight: 600;
}
.drill-note-title .icon svg {
  width: 16px;
  height: 16px;
  stroke-width: 2.4;
}
.drill-note-next {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}
.drill-note .bad {
  color: var(--blunder);
}
.drill-done {
  padding: 10px 14px;
  border-radius: var(--r-md);
  background: var(--good-soft);
  color: var(--text);
  font-size: 14px;
}
.drill-done b {
  color: var(--good);
}

/* A branch point in the tree: folded away until it is asked for. */
.more-lines {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 19px;
  min-width: 22px;
  justify-content: center;
  margin: 0 2px 0 6px;
  padding: 0 6px 0 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-3);
  font-size: 11.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.more-lines:hover {
  color: var(--text);
  border-color: var(--text-3);
}
.more-lines.open {
  background: var(--surface-3);
  color: var(--text-2);
}
.rep-tree .rep-list-head {
  margin-bottom: 8px;
}
.rep-tree .rep-list-head h2 {
  margin: 0;
  font-size: 15px;
}

.rep-head-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}
.book-add {
  width: 28px;
  text-align: right;
}

.book-add-help {
  margin-top: 6px;
}

.more-lines .caret {
  font-size: 10px;
  line-height: 1;
}

/* Two moves on the view board: the line's, and the one that keeps happening. */
.view-board .cm-chessboard .marker.good-move,
.view-board .cm-chessboard .marker.good-move use {
  fill: color-mix(in srgb, var(--good) 45%, transparent) !important;
}
.view-board .cm-chessboard .marker.bad-move,
.view-board .cm-chessboard .marker.bad-move use {
  fill: color-mix(in srgb, var(--blunder) 45%, transparent) !important;
}
.mark-key {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  vertical-align: -1px;
}
.mark-key.good {
  background: color-mix(in srgb, var(--good) 60%, transparent);
}
.mark-key.bad {
  background: color-mix(in srgb, var(--blunder) 60%, transparent);
}

/* Moves as buttons under the board: the line, walked one click at a time. */
.rep-where {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  color: var(--text-2);
}
.mv-chip {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.mv-chip:hover {
  border-color: var(--text-3);
  background: var(--surface-2);
}
.mv-chip.theirs {
  font-weight: 500;
  color: var(--text-2);
}
.mv-chip.good {
  border-color: color-mix(in srgb, var(--good) 50%, transparent);
  background: color-mix(in srgb, var(--good) 12%, transparent);
}
.mv-chip.bad {
  border-color: color-mix(in srgb, var(--blunder) 50%, transparent);
  background: color-mix(in srgb, var(--blunder) 10%, transparent);
}
.mv-chip.trap {
  color: var(--opening);
}
.mv-chip.flag-unsound {
  color: var(--blunder);
}
.mv-chip.flag-dubious {
  color: var(--tactic);
}
/* The small + that carries a line on: beside the moves under the board, and
   at the end of every line in the tree. */
.plus {
  justify-content: center;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}
.mv-chip.plus {
  width: 26px;
  padding: 0;
  color: var(--text-2);
  font-size: 16px;
}
.mv-chip.plus.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}
.mv-chip.plus.primary:hover {
  filter: brightness(1.06);
  background: var(--accent);
  border-color: var(--accent);
}
.grow-line {
  display: inline-flex;
  align-items: center;
  width: 19px;
  height: 19px;
  margin-left: 6px;
  padding: 0 0 1px;
  border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 14px;
  vertical-align: middle;
}
.grow-line:hover {
  background: var(--accent);
  color: var(--accent-ink);
}
.plus.busy {
  animation: plus-pulse 0.9s ease-in-out infinite;
  cursor: progress;
}
@keyframes plus-pulse {
  50% {
    opacity: 0.35;
  }
}

/* The evaluation of the position on the board, from White's side. */
.eval-pill {
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid var(--line-2);
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
  cursor: help;
}
.eval-pill.white {
  background: #ffffff;
  color: #16171a;
}
.eval-pill.black {
  background: #16171a;
  border-color: #000000;
  color: #ffffff;
}
.eval-pill.none {
  background: none;
  color: var(--text-3);
  font-weight: 500;
}

.mv-chip.ghost {
  border-color: transparent;
  background: none;
  color: var(--text-3);
  font-weight: 500;
}

/* ---- learn: your openings ------------------------------------------------ */
.mine {
  margin-bottom: 16px;
  padding: 14px 16px 10px;
}
.mine .rep-list-head {
  flex-wrap: wrap;
  gap: 8px 12px;
}
.mine .rep-list-head h2 {
  margin: 0;
  font-size: 15px;
}
.mine .help {
  margin: 4px 0 10px;
}
.mine .chips {
  margin-bottom: 10px;
}
.mine-families {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--line);
}
.mine-family {
  border-bottom: 1px solid var(--line);
}
.mine-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 10px 2px;
  border: 0;
  background: none;
  color: var(--text);
  text-align: left;
}
.mine-head:hover {
  background: var(--surface-2);
}
.mine-head-main,
.mine-line-main {
  min-width: 0;
}
.mine-head-side,
.mine-line-side {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}
.mine-head .chev {
  color: var(--text-3);
}
.mine-head .chev svg {
  width: 16px;
  height: 16px;
  transition: transform 0.15s;
}
.mine-head[aria-expanded="true"] .chev svg {
  transform: rotate(90deg);
}
.mine-lines {
  padding: 0 0 8px 14px;
  border-left: 2px solid var(--line-2);
  margin: 0 0 8px 8px;
}
.mine-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 4px;
}
.mine-line-main {
  flex: 1;
  border: 0;
  background: none;
  color: var(--text);
  text-align: left;
  padding: 0;
}
.mine-line-main:disabled {
  color: var(--text-2);
}
.mine-line-main:not(:disabled):hover .line-name {
  text-decoration: underline;
  text-underline-offset: 3px;
}
@media (max-width: 560px) {
  .mine-head,
  .mine-line {
    flex-wrap: wrap;
  }
  .mine-head-side,
  .mine-line-side {
    width: 100%;
    justify-content: flex-start;
  }
}
