/* app.css: how the fianka app looks (src/ui/app.ts and the modules it
 * builds on); the board's own looks are in board.css. Colours are tokens
 * on :root, swapped for dark mode when the system is dark (unless the
 * page says data-theme="light") or the page says data-theme="dark".
 *
 * Layout, by the .app element's data attributes:
 *   data-layout  docked | floating | full   (700 px and wider)
 *   data-sheet   peek (down: the board), half (mid: the chat under the board) or full (up)
 *   data-drawer  the sessions drawer is open (narrower than 1800 px)
 *   data-overlay the board is open over the full-screen chat
 * Under 700 px the board sits on top and the chat is a sheet; from
 * 1800 px the sessions are a rail on the left. */

/* Typefaces, self-hosted (fonts/, SIL Open Font License: fonts/LICENSE.txt).
 * Each file is a variable font: one file covers the weights used. */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url(fonts/inter-latin-ext.woff2) format('woff2');
  unicode-range:
    U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
    U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F,
    U+A720-A7FF;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url(fonts/inter-latin.woff2) format('woff2');
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 500 600;
  font-display: swap;
  src: url(fonts/space-grotesk-latin-ext.woff2) format('woff2');
  unicode-range:
    U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
    U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F,
    U+A720-A7FF;
}
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 500 600;
  font-display: swap;
  src: url(fonts/space-grotesk-latin.woff2) format('woff2');
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400 500;
  font-display: swap;
  src: url(fonts/jetbrains-mono-latin-ext.woff2) format('woff2');
  unicode-range:
    U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
    U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F,
    U+A720-A7FF;
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400 500;
  font-display: swap;
  src: url(fonts/jetbrains-mono-latin.woff2) format('woff2');
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #f4f5f1;
  --panel: #ffffff;
  --raised: #fafbf8;
  --ink: #1a1e1b;
  --muted: #59615b;
  --line: #e2e5de;
  --accent: #2d6a4f;
  --accentInk: #ffffff;
  --soft: #e6efe9;
  --danger: #b42318;
  --shadow: rgba(0, 0, 0, 0.14);
  --sans: Inter, system-ui, sans-serif;
  --display: 'Space Grotesk', Inter, system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0f1211;
    --panel: #161a18;
    --raised: #1c211f;
    --ink: #e6eae6;
    --muted: #9ba59e;
    --line: #2a312d;
    --accent: #7cc49c;
    --accentInk: #0f1211;
    --soft: #1f2b25;
    --danger: #f97066;
    --shadow: rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #0f1211;
  --panel: #161a18;
  --raised: #1c211f;
  --ink: #e6eae6;
  --muted: #9ba59e;
  --line: #2a312d;
  --accent: #7cc49c;
  --accentInk: #0f1211;
  --soft: #1f2b25;
  --danger: #f97066;
  --shadow: rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

/* Board colours other than sage, the default (board.css). */
:root[data-board='walnut'] .board {
  --board-light: #eedcbf;
  --board-dark: #a8794f;
}
:root[data-board='slate'] .board {
  --board-light: #dfe5ec;
  --board-dark: #7b8ea6;
}
:root[data-board='paper'] .board {
  --board-light: #f4f1ea;
  --board-dark: #b9b2a3;
}

/* Basics. */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
}
/* Quick taps (stepping through a game) never zoom the page; pinch zoom still works. */
html {
  touch-action: manipulation;
}
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 var(--sans);
  -webkit-text-size-adjust: 100%;
}
h1,
h2,
h3 {
  font-family: var(--display);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
}
/* On a touch screen, iOS zooms in on a focused field whose text is under 16px. */
@media (pointer: coarse) {
  input,
  select,
  textarea {
    font-size: 16px !important;
  }
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
[hidden] {
  display: none !important;
}
.muted {
  color: var(--muted);
}
.mono {
  font-family: var(--mono);
  font-size: 13.5px;
}
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.tag {
  font: 600 11px var(--sans);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}
.tag.muted {
  color: var(--muted);
}
.logo rect {
  fill: var(--accent);
}
.logo path {
  stroke: var(--accentInk);
  stroke-width: 2;
  stroke-linecap: round;
}
.logo circle {
  fill: var(--accentInk);
}

/* Buttons: icon buttons, plain and primary buttons, chips. Every one is
 * at least 44 px tall, for fingers. */
.icon {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ib {
  width: 44px;
  height: 44px;
  flex: none;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.ib:hover {
  background: var(--soft);
  color: var(--ink);
}
.ib.on {
  background: var(--soft);
  color: var(--accent);
}
.btn {
  display: inline-flex;
  text-decoration: none;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font: 500 14px var(--sans);
  white-space: nowrap;
}
.btn:hover {
  border-color: var(--accent);
}
.btn:disabled {
  opacity: 0.5;
  cursor: default;
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accentInk);
}
.btn.danger {
  color: var(--danger);
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
  background: var(--panel);
}
.chip .icon {
  width: 14px;
  height: 14px;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* The page: the rail, then the header above the stage (board and chat). */
.app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  overflow: hidden;
}
.work {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.bar {
  height: 60px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px 0 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.bar h1 {
  font-size: 20px;
}
.brand,
.rail-head {
  display: flex;
  align-items: center;
  gap: 10px;
}
.name {
  font: 600 19px var(--display);
  letter-spacing: -0.02em;
}
.sep {
  width: 1px;
  height: 24px;
  background: var(--line);
  margin: 0 6px;
}
.grow {
  flex: 1;
}
.session-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  height: 44px;
  padding: 0 10px;
  border: 0;
  border-radius: 12px;
  background: none;
  font-weight: 500;
}
.session-title span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.session-title:hover {
  background: var(--soft);
}
.stage {
  flex: 1;
  min-height: 0;
  display: flex;
  position: relative;
}

/* The sessions: a drawer over the page, or (wide) a rail beside it. Its
 * inner edge is a grip (ui/railgrip.ts) that sets --rail-w. */
.rail {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  width: min(var(--rail-w, 340px), 100vw);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  box-shadow: 0 0 40px var(--shadow);
  transform: translateX(-105%);
  visibility: hidden;
  transition:
    transform 0.2s,
    visibility 0.2s;
}
.app[data-drawer='true'] .rail {
  transform: none;
  visibility: visible;
}
.rail-grip {
  position: absolute;
  top: 0;
  bottom: 0;
  right: -4px;
  width: 8px;
  z-index: 2;
  padding: 0;
  border: 0;
  background: none;
  cursor: col-resize;
  touch-action: none;
}
.rail-grip::after {
  content: '';
  position: absolute;
  inset: 0 3px;
  border-radius: 2px;
  transition: background 0.15s;
}
.rail-grip:hover::after,
.rail-grip:focus-visible::after,
.rail.resizing .rail-grip::after {
  background: var(--accent);
}
.rail-grip:focus-visible {
  outline: none;
}
.rail.resizing {
  transition: none;
  user-select: none;
}
.scrim {
  display: none;
}
.app[data-drawer='true'] .scrim {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 29;
  background: rgba(0, 0, 0, 0.3);
}
.rail-head {
  padding: 4px 4px 4px 8px;
}
.rail-head .name {
  flex: 1;
}
.wide-only {
  display: none;
}
.sessions {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
/* The search box: a magnifier, the field, and a "/" that says the key. */
.ses-find {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 10px 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--raised);
  color: var(--muted);
  cursor: text;
  transition:
    border-color 0.15s,
    background 0.15s;
}
.ses-find:focus-within {
  border-color: var(--accent);
  background: var(--panel);
}
.ses-find .icon {
  width: 17px;
  height: 17px;
  flex: none;
}
.ses-search {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  background: none;
  color: var(--ink);
  font-size: 14px;
}
.ses-search:focus {
  outline: none;
}
.ses-search::placeholder {
  color: var(--muted);
}
.ses-search::-webkit-search-cancel-button {
  cursor: pointer;
}
.ses-find kbd {
  font: 500 11.5px var(--mono);
  min-width: 20px;
  padding: 1px 6px;
  text-align: center;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  color: var(--muted);
}
.ses-find:focus-within kbd {
  display: none;
}
@media (hover: none) {
  .ses-find kbd {
    display: none;
  }
}
.ses-actions {
  display: flex;
  gap: 8px;
}
.new-session {
  flex: 1;
  justify-content: center;
}
/* The rail's way into the library (games, positions, lessons). */
.rail-library {
  justify-content: center;
  padding: 0 14px;
}
.ses-list {
  overflow-x: hidden;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  margin: 0 -6px;
  padding: 0 6px 12px;
}
.grp {
  display: flex;
  align-items: center;
  gap: 6px;
  font: 500 13px var(--sans);
  letter-spacing: 0;
  color: var(--muted);
  padding: 16px 10px 6px;
}
.grp:first-child {
  padding-top: 4px;
}
.grp .icon {
  width: 14px;
  height: 14px;
  color: var(--accent);
}
/* A session: its board, title and when; the active one has a green edge. */
.ses {
  position: relative;
  display: flex;
  align-items: center;
  border-radius: 12px;
  transition:
    background 0.15s,
    transform 0.15s;
}
.ses:hover {
  background: var(--raised);
}
/* While searching, the result Up and Down picked is the one marked. */
.ses.hit.on:not(.picked) {
  background: none;
}
.ses.hit.picked {
  background: var(--soft);
}
@media (hover: hover) {
  .ses:not(.on, .menu-open):hover {
    transform: translateX(2px);
  }
}
/* The row with its menu open stays above the rows after it. */
.ses.menu-open {
  z-index: 6;
}
.ses.on {
  background: var(--soft);
}
.ses.on::before {
  content: '';
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--edge, #6f9a74);
}
.ses-open {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px 8px 12px;
  border: 0;
  border-radius: 12px;
  background: none;
  color: inherit;
  text-align: left;
}
.ses.hit {
  cursor: pointer;
}
.ses-thumb {
  flex: none;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  overflow: hidden;
  background: var(--soft);
}
.ses-thumb .thumb-board {
  width: 100%;
}
.ses-thumb .board {
  border-radius: 0;
  box-shadow: none;
}
/* Softer squares, in the board colours chosen, so the pieces read at this size. */
.ses-thumb .board {
  filter: contrast(0.8) brightness(1.06);
}
.ses-thumb .logo {
  opacity: 0.55;
}
.ses-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.ses-title,
.ses-sub {
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ses-title {
  font-weight: 500;
  line-height: 1.35;
}
.ses.on .ses-title {
  font-weight: 600;
}
.ses-sub {
  font-size: 12.5px;
  color: var(--muted);
}
.ses mark {
  background: none;
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline 1.5px;
  text-underline-offset: 3px;
}
/* The "..." button sits over the end of the title, on the row's own colour (--row),
 * shown on hover or focus; always on a touch screen, beside the title. */
.ses {
  --row: var(--raised);
}
.ses.on {
  --row: var(--soft);
}
.ses-more {
  position: absolute;
  right: 6px;
  width: 34px;
  height: 34px;
  background: var(--row);
  box-shadow: -14px 0 12px -2px var(--row);
  opacity: 0;
  transition: opacity 0.15s;
}
.ses-more:hover {
  background: var(--line);
}
.ses:hover .ses-more,
.ses:focus-within .ses-more,
.ses.menu-open .ses-more {
  opacity: 1;
}
@media (hover: none) {
  .ses-more {
    position: static;
    margin-right: 4px;
    background: none;
    box-shadow: none;
    opacity: 1;
  }
}
.ses-menu {
  position: absolute;
  z-index: 5;
  right: 6px;
  top: calc(100% - 4px);
  min-width: 180px;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 32px var(--shadow);
  animation: ses-menu-in 0.12s ease-out;
}
@keyframes ses-menu-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
}
.ses-menu [role='menuitem'] {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.ses-menu [role='menuitem'] .icon {
  color: var(--muted);
}
.ses-menu [role='menuitem'].danger {
  margin-top: 4px;
  color: var(--danger);
  box-shadow: 0 -1px 0 var(--line);
  border-radius: 0 0 8px 8px;
}
.ses-menu [role='menuitem'].danger .icon {
  color: inherit;
}
.ses-menu [role='menuitem']:hover,
.ses-menu [role='menuitem']:focus-visible {
  background: var(--soft);
  outline: none;
}
.ses-open.editing {
  padding-right: 6px;
}
.ses-open.editing .rename {
  height: 36px;
}
.ses-open.editing .rename:focus-visible {
  outline: none;
}
.ses:has(.editing) .ses-more {
  display: none;
}
.ses-hello,
.ses-none {
  margin: 0;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}
/* A project's heading: a fold arrow and its name; its sessions sit a step in under it. */
.proj-head {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 10px 6px;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
}
.proj-head .icon {
  flex: none;
  width: 16px;
  height: 16px;
  color: var(--muted);
  transition: transform 0.15s;
}
.proj-head[aria-expanded='false'] .icon {
  transform: rotate(-90deg);
}
.ses.inside {
  margin-left: 14px;
}
/* New project: quiet, like a heading, until hovered. */
.proj-add {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 12px;
  background: none;
  color: var(--muted);
  font: 500 13px var(--sans);
  text-align: left;
}
.proj-add .icon {
  width: 16px;
  height: 16px;
}
.proj-add:hover {
  color: var(--ink);
  background: var(--raised);
}
/* The project form in its sheet: a field a row, the label above. */
.proj-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.proj-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 14px;
  color: var(--muted);
}
.proj-form .field {
  width: 100%;
}
.proj-form textarea.field {
  height: auto;
  padding: 10px 12px;
  resize: vertical;
}
/* Read by screen readers alone. */
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.stats {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
}
.stat-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}
.stat-row dt {
  color: var(--muted);
}
.stat-row dd {
  margin: 0;
  text-align: right;
}
.rename {
  flex: 1;
  min-width: 0;
  height: 40px;
  border: 2px solid var(--accent);
  border-radius: 10px;
  padding: 0 10px;
  font-weight: 600;
  background: var(--panel);
}

/* The spotlight: head, board, controls and moves in a column, or, when
 * its area is wide enough, the board on the left and the rest beside it.
 * --bs is the board's size, the largest that fits. */
.spot-area {
  flex: 1;
  min-width: 0;
  container-type: size;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
}
.spotlight {
  --bs: max(200px, min(100cqw, 100cqh - 260px));
  position: relative;
  display: grid;
  grid-template-columns: var(--bs);
  grid-template-areas: 'head' 'board' 'controls' 'moves' 'note';
  gap: 12px;
}
.spotlight:has(.move-note) {
  --bs: max(200px, min(100cqw, 100cqh - 360px));
}
.spot-head {
  grid-area: head;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
@container (min-width: 760px) {
  .spot-head {
    flex-direction: column;
  }
}
.spot-title {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.spot-title h2 {
  font-size: 22px;
}
.spot-board {
  grid-area: board;
}
.spot-controls {
  grid-area: controls;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
/* The moves, under the game graph when there is one (ui/graph.ts). */
.moves-area {
  grid-area: moves;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
}
.moves-box {
  flex: 1 1 auto;
  max-height: 120px;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}
@container (min-width: 760px) {
  .spotlight {
    --bs: min(100cqh, 100cqw - 312px, 960px);
    grid-template-columns: var(--bs) 280px;
    grid-template-rows: auto auto 1fr auto;
    grid-template-areas: 'board head' 'board controls' 'board moves' 'board note';
    column-gap: 32px;
  }
  .spotlight:has(.move-note) {
    --bs: min(100cqh, 100cqw - 312px, 960px);
  }
  .moves-box {
    max-height: calc(var(--bs) - 200px);
  }
  .moves-area:has(.game-graph) .moves-box {
    max-height: calc(var(--bs) - 270px);
  }
}
.move-note {
  grid-area: note;
  margin: 0;
  max-height: 6.5em;
  overflow: auto;
  padding: 8px 12px;
  border-left: 3px solid var(--accent);
  border-radius: 0 10px 10px 0;
  background: var(--soft);
  font-size: 13.5px;
  line-height: 1.45;
}
.moves {
  margin: 0;
  padding: 0;
  list-style: none;
  font-family: var(--mono);
  font-size: 13.5px;
}
.moves li {
  display: grid;
  grid-template-columns: 3em 1fr 1fr;
  align-items: center;
}
.mv-n {
  color: var(--muted);
}
.mv {
  justify-self: start;
  min-height: 28px;
  padding: 2px 8px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--ink);
  font: inherit;
}
.mv:hover {
  background: var(--soft);
}
.mv.cur {
  background: var(--accent);
  color: var(--accentInk);
}
.mv.none {
  color: var(--muted);
}
/* A move the coach annotated (annotate.ts): underlined, dotted; its note is the tooltip. */
.mv.noted {
  text-decoration: underline dotted;
  text-underline-offset: 4px;
}
.move-note > p {
  margin: 0;
}
/* The coach's note on the move, in its voice, under the game's own comment. */
.move-note > p + .coach-note {
  margin-top: 6px;
}
.coach-note .who {
  display: block;
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.no-moves {
  margin: 0;
}
.picker {
  position: absolute;
  z-index: 10;
  top: 56px;
  right: 0;
  width: min(440px, 100%);
  max-height: 70%;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 12px 32px var(--shadow);
}
.picker-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 10px;
}
.pick {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  font: 500 13px var(--sans);
  text-align: left;
}
/* A board in the picker, with its rename button in the corner. */
.pick-box {
  position: relative;
  display: grid;
}
.pick-rename {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 32px;
  height: 32px;
  background: var(--panel);
  border: 1px solid var(--line);
}
/* The spotlight's title: a button that looks like the heading, renamed in place. */
.title-edit {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
  text-align: left;
  cursor: text;
  border-bottom: 1px dashed transparent;
}
.title-edit:hover,
.title-edit:focus-visible {
  border-bottom-color: var(--muted);
}
.rename.title-field {
  flex: none;
  font: 600 22px var(--display);
  color: var(--ink);
  background: var(--panel);
}
/* Every thumbnail fills its column, so the grid stays even. */
.pick .thumb-board {
  width: 100%;
  aspect-ratio: 1;
}
.pick span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pick.on,
.card.sel {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--soft);
}
.overlay-close {
  display: none;
}

/* The handle between the board and the docked chat. */
.dock-handle {
  width: 9px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: col-resize;
  touch-action: none;
}
.dock-handle span {
  width: 3px;
  height: 40px;
  border-radius: 3px;
  background: var(--line);
}
.dock-handle:hover span,
.dock-handle:focus-visible span {
  background: var(--accent);
}

/* The chat. */
.chat {
  width: var(--chat-w, 470px);
  flex: none;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-left: 1px solid var(--line);
}
.chat-head {
  height: 56px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 8px 0 20px;
  border-bottom: 1px solid var(--line);
}
.chat-head h3 {
  font-size: 16px;
  flex: 1;
}
.grip {
  display: none;
  color: var(--muted);
}
.grip .icon {
  stroke-width: 3.5;
  width: 16px;
}
.sheet-handle {
  display: none;
}
.transcript {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px 20px 44px;
  scroll-padding-bottom: 44px;
}
.to-bottom {
  position: sticky;
  bottom: 0;
  height: 0;
  margin-top: -18px;
  align-self: flex-end;
  z-index: 2;
}
/* At the corner, small, over a soft backdrop, so it hides little of the text. */
.to-bottom .ib {
  position: absolute;
  bottom: 8px;
  right: -4px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 85%, transparent);
  backdrop-filter: blur(4px);
  color: var(--ink);
}
.to-bottom .ib .icon {
  width: 16px;
}
.you {
  align-self: flex-end;
  max-width: 82%;
  background: var(--soft);
  border-radius: 18px 18px 6px 18px;
  padding: 10px 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.coach {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.who {
  font: 600 12.5px var(--sans);
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.empty {
  margin: auto;
  max-width: 320px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.empty h2 {
  font-size: 20px;
}
.empty p {
  margin: 0;
}
.error {
  margin: 0;
  color: var(--danger);
}
/* A turn that failed, in the transcript, with a way to try it again. */
.turn-failed {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}
.turn-failed .error {
  flex: 1 1 auto;
}
/* Replies to tap instead of typing: ways to start, or what the coach suggests. */
.says {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.btn.say {
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  white-space: normal;
  text-align: left;
}
/* How a game against Stockfish ended, with replies to tap (ui/ending.ts). */
.game-end p {
  margin: 0 0 8px;
  font-weight: 600;
}
/* A chess term in the coach's reply that explains itself (ui/glossary.ts). */
.term {
  text-decoration: underline dotted var(--muted);
  text-underline-offset: 3px;
  cursor: help;
}
.term:focus-visible {
  outline: 2px solid var(--accent);
  border-radius: 3px;
}
.term-pop {
  position: fixed;
  z-index: 40;
  width: min(260px, calc(100vw - 16px));
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 32px var(--shadow);
  font-size: 14px;
}
.term-pop p {
  margin: 6px 0;
}
.term-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.term-head span {
  color: var(--muted);
  font-size: 12px;
}
.term-board {
  width: 140px;
  margin: 8px auto;
}
.term-pop .link,
.ex-note .link,
.rep-left .link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
}
/* What the user said while the coach was busy, waiting its turn. */
.you.queued {
  opacity: 0.7;
  border: 1px dashed var(--accent);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.you.queued .tag {
  color: var(--muted);
}
/* Signs of life while the coach works: a spinner, its thinking, the tool running. */
.spin {
  width: 12px;
  height: 12px;
  flex: none;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@media (prefers-reduced-motion: reduce) {
  .spin {
    animation-duration: 3s;
  }
}
.working {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}
.chip.running {
  color: var(--ink);
  border-color: var(--accent);
}
.chip .secs {
  font: 12px var(--mono);
  color: var(--muted);
}
.thinking {
  font-size: 13px;
  color: var(--muted);
  border-left: 2px solid var(--line);
  padding-left: 10px;
}
.thinking summary {
  cursor: pointer;
  font-weight: 600;
}
.think-text {
  white-space: pre-wrap;
  margin-top: 4px;
  max-height: 240px;
  overflow-y: auto;
}
/* A slash command's note, a small line of its own. */
.note {
  align-self: center;
  font: 12.5px var(--mono);
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 999px;
  padding: 3px 12px;
}

/* A move in the chat's text, and the board it shows on hover. */
.mref {
  display: inline;
  font: 600 0.92em var(--mono);
  color: var(--accent);
  background: var(--soft);
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 3px;
  cursor: pointer;
}
.mref:hover,
.mref:focus-visible {
  border-color: var(--accent);
}
.peek {
  position: fixed;
  z-index: 40;
  width: 176px;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 32px var(--shadow);
  pointer-events: none;
}

/* The coach's rich text. */
.md {
  overflow-wrap: anywhere;
}
.md > :first-child {
  margin-top: 0;
}
.md > :last-child {
  margin-bottom: 0;
}
.md p {
  margin: 0 0 10px;
  white-space: pre-line;
}
.md ul,
.md ol {
  margin: 0 0 10px;
  padding-left: 22px;
}
.md li + li {
  margin-top: 4px;
}
.md h3,
.md h4,
.md h5 {
  margin: 14px 0 6px;
  font-size: 16px;
}
.md h3 {
  font-size: 18px;
}
.md code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--soft);
  border-radius: 5px;
  padding: 1px 5px;
}
.md pre {
  margin: 0 0 10px;
  padding: 10px 12px;
  background: var(--soft);
  border-radius: 10px;
  overflow-x: auto;
}
.md pre code {
  padding: 0;
  background: none;
}
.md a {
  color: var(--accent);
}

/* Cards: a position (a button with a thumbnail) or a live board. */
.card {
  display: flex;
  gap: 14px;
  align-items: center;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--raised);
  padding: 12px;
  color: var(--ink);
}
button.card:hover {
  border-color: var(--accent);
}
.card .thumb-board {
  width: 120px;
  flex: none;
}
.card-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.card-title {
  font-weight: 600;
}
.card.live {
  flex-direction: column;
  align-items: stretch;
}
.card-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-height: 44px;
  border: 0;
  background: none;
  padding: 0;
  text-align: left;
}
.live-board {
  width: min(100%, 320px);
}

/* Diagrams (ui/diagram.ts): those in a row side by side when the chat is
 * wide enough, stacked on a phone; the caption under the board, the Share
 * button over the caption's corner. */
.diagrams {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}
.diagram-card {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  height: 100%;
}
.card-wrap > .card.diagram-card {
  padding-right: 12px;
}
.diagram-card .thumb-board {
  width: 100%;
  max-width: 320px;
  align-self: center;
}
.diagram-caption {
  padding-right: 28px;
  font-size: 14px;
  line-height: 1.35;
}
.card-wrap.diagram-wrap > .share-btn {
  top: auto;
  bottom: 6px;
}
@media (max-width: 699px) {
  .diagrams {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* A diagram in the spotlight: laid over the spotlight in the same grid, which
 * stays in place, unseen, so the board keeps its size and the phone's sheet its stops. */
.spotlight.viewing > :not(.diagram-spot, .picker) {
  visibility: hidden;
}
.diagram-spot {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: inherit;
  grid-template-rows: inherit;
  grid-template-areas: inherit;
  gap: inherit;
}
.diagram-head {
  grid-area: head;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.diagram-head h2 {
  font-size: 18px;
}
@media (max-width: 699px) {
  .diagram-head {
    grid-area: moves;
  }
  .diagram-head h2 {
    font-size: 16px;
  }
}

/* The composer, and the list of suggestions anchored at its caret. */
.composer {
  position: relative;
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
  margin: 12px 16px 16px;
  padding: 6px 6px 6px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--bg);
}
.composer .chips {
  flex: 0 0 100%;
  margin: 0;
}
.chip button {
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
  padding: 0;
  font-size: 15px;
  line-height: 1;
}
.composer:focus-within {
  border-color: var(--accent);
}
.composer textarea {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 11px 0;
  border: 0;
  background: transparent;
  resize: none;
  line-height: 22px;
  outline: none;
}
.composer textarea::placeholder {
  color: var(--muted);
}
/* What Enter does, in the margin under the box while there is text to send. */
.enter-hint {
  display: none;
  position: absolute;
  left: 14px;
  top: 100%;
  font-size: 11px;
  line-height: 16px;
  color: var(--muted);
  pointer-events: none;
}
.composer textarea:focus:not(:placeholder-shown) ~ .enter-hint {
  display: block;
}
.send,
.send:hover {
  background: var(--accent);
  color: var(--accentInk);
}
.suggest {
  position: absolute;
  z-index: 5;
  min-width: 200px;
  max-width: 320px;
  margin: 0 0 6px;
  padding: 6px;
  list-style: none;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 32px var(--shadow);
}
.suggest li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.suggest li[aria-selected='true'] {
  background: var(--soft);
}
.notice {
  position: absolute;
  z-index: 4;
  left: 10px;
  right: 10px;
  bottom: calc(100% + 6px);
  margin: 0;
  padding: 8px 12px;
  font-size: 13.5px;
  white-space: pre-line;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 8px 24px var(--shadow);
}
.notice.error {
  border-color: var(--danger);
}

/* Floating: the chat is a window over the board, which keeps to the left. */
.app[data-layout='floating'] .spot-area {
  justify-content: flex-start;
  padding-left: clamp(24px, 8vw, 120px);
}
.app[data-layout='floating'] .dock-handle {
  display: none;
}
.app[data-layout='floating'] .chat {
  position: fixed;
  z-index: 20;
  left: var(--fx);
  top: var(--fy);
  width: var(--fw);
  height: var(--fh);
  min-width: 300px;
  min-height: 300px;
  max-width: calc(100vw - 16px);
  max-height: calc(100vh - 76px);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow:
    0 24px 60px var(--shadow),
    0 2px 6px var(--shadow);
  overflow: hidden;
  resize: both;
}
.app[data-layout='floating'] .chat-head {
  cursor: grab;
  touch-action: none;
  padding-left: 12px;
}
.app[data-layout='floating'] .grip {
  display: inline-flex;
}

/* Full screen: the chat alone, read in a column; a card opens the board over it. */
.app[data-layout='full'] .spot-area,
.app[data-layout='full'] .dock-handle {
  display: none;
}
.app[data-layout='full'] .chat {
  flex: 1;
  border-left: 0;
}
.app[data-layout='full'] .transcript > *,
.app[data-layout='full'] .composer {
  width: min(760px, calc(100% - 32px));
  align-self: center;
}
.app[data-layout='full'] .composer {
  margin: 12px auto 20px;
}
.app[data-layout='full'] .you {
  align-self: center;
  width: min(760px, 100%);
  display: flex;
  justify-content: flex-end;
  background: none;
  padding: 0;
}
.app[data-layout='full'] .you > * {
  max-width: 82%;
  background: var(--soft);
  border-radius: 18px 18px 6px 18px;
  padding: 10px 14px;
}
.app[data-layout='full'][data-overlay='true'] .spot-area {
  display: flex;
  position: fixed;
  inset: 0;
  z-index: 40;
  background: var(--bg);
}
.app[data-layout='full'][data-overlay='true'] .overlay-close {
  display: inline-flex;
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1;
}

/* A phone: the board on top, the chat a sheet over the bottom. */
.phone-only {
  display: none;
}
@media (max-width: 699px) {
  .phone-only {
    display: inline-flex;
  }
  .desk-only,
  .brand,
  .sep,
  .chat-head,
  .dock-handle {
    display: none !important;
  }
  .bar.top {
    height: 56px;
    gap: 4px;
    padding: 0 6px;
    border-bottom: 0;
    background: var(--bg);
  }
  .session-title {
    flex: 1;
    padding: 0 4px;
  }
  .grow {
    display: none;
  }
  .rail {
    width: 100vw;
  }
  .rail-grip {
    display: none;
  }
  /* The page fits what shows of the screen (--vh, from the top --vt, set by app.ts), so the
   * keyboard lifts the sheet rather than panning the page. */
  .app {
    --peek: 104px;
    position: fixed;
    top: var(--vt, 0px);
    left: 0;
    width: 100%;
    height: var(--vh, 100dvh);
  }
  /* The spotlight fills what the lowered sheet leaves: the board, the controls, then the moves. */
  .spot-area,
  .app[data-layout='full'] .spot-area {
    display: flex;
    align-items: stretch;
    padding: 4px 16px calc(var(--peek) + 8px);
  }
  .spotlight {
    --bs: min(100cqw, 100cqh - 120px);
    grid-template-columns: minmax(0, var(--bs));
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    grid-template-areas: 'board' 'controls' 'moves' 'note';
    gap: 6px;
  }
  .spotlight:has(.move-note) {
    --bs: min(100cqw, 100cqh - 210px);
  }
  .move-note {
    max-height: 4.4em;
  }
  .spot-head {
    position: absolute;
    top: 0;
    right: 0;
    height: 0;
  }
  .spot-title,
  .picker-btn,
  .spot-controls [aria-label='Start'],
  .spot-controls [aria-label='End'] {
    display: none;
  }
  .spot-board {
    width: var(--bs);
  }
  .moves-box {
    max-height: none;
    overflow-x: hidden;
  }
  .moves {
    display: flex;
    flex-wrap: wrap;
    column-gap: 6px;
  }
  .moves li {
    display: flex;
    align-items: center;
    white-space: nowrap;
  }
  .mv-n {
    padding-left: 6px;
  }
  .picker {
    top: 0;
    left: 0;
    width: auto;
  }
  /* The open picker sits over the chat's sheet, which would hide its lower rows; the rest of the
   * spotlight stays under the sheet. */
  .spot-area:has(.picker) {
    z-index: 30;
  }
  .spot-area:has(.picker) .spotlight > :not(.picker) {
    visibility: hidden;
  }
  .chat,
  .app[data-layout] .chat {
    position: absolute;
    z-index: 20;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    width: auto;
    min-width: 0;
    max-width: none;
    resize: none;
    border: 0;
    border-top: 1px solid var(--line);
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -12px 32px var(--shadow);
    overflow: hidden;
    transition: height 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
  }
  /* Three heights: down (the board, and the composer), mid (the chat under the board; --mid, set by
   * app.ts) or up (the chat, under the header). */
  .app[data-sheet] .chat {
    height: 100%;
  }
  .app[data-sheet='half'] .chat {
    height: var(--mid, 100%);
  }
  .app[data-sheet='peek'] .chat {
    height: var(--peek);
  }
  .app[data-sheet='peek'] .transcript {
    padding: 0;
    overflow: hidden;
  }
  .sheet-handle {
    position: relative;
    display: flex;
    flex: none;
    justify-content: center;
    align-items: center;
    height: 32px;
    width: 100%;
    border: 0;
    background: none;
    touch-action: none;
  }
  .sheet-handle .grab {
    width: 40px;
    height: 5px;
    border-radius: 3px;
    background: var(--line);
  }
  .sheet-handle .label {
    position: absolute;
    right: 16px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--muted);
  }
  .transcript {
    padding: 8px 16px;
    gap: 14px;
  }
  .composer {
    margin: 4px 12px 16px;
  }
  /* One line, so the empty composer fits the lowered sheet. */
  .composer textarea::placeholder {
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .settings-nav {
    display: none !important;
  }
}

/* Ultrawide: the sessions are a rail, and the header's work moves into it. */
@media (min-width: 1800px) {
  .rail {
    position: relative;
    transform: none;
    visibility: visible;
    box-shadow: none;
    width: var(--rail-w, 300px);
    flex: none;
  }
  .app[data-drawer] .scrim,
  .drawer-only,
  .bar.top {
    display: none;
  }
  .wide-only {
    display: inline-flex;
  }
  .chat-head {
    height: 60px;
  }
}

/* The settings page. */
.settings {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.settings .bar {
  position: sticky;
  top: 0;
  z-index: 1;
}
.settings-body {
  display: flex;
  gap: 32px;
  padding: 28px clamp(16px, 4vw, 40px);
}
.settings-nav {
  width: 200px;
  flex: none;
  position: sticky;
  top: 88px;
  align-self: flex-start;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.settings-nav a {
  display: flex;
  align-items: center;
  height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
}
.settings-nav a:hover {
  background: var(--soft);
  color: var(--accent);
}
.sections {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 440px), 1fr));
  gap: 20px;
  align-content: start;
}
.sec {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-margin-top: 88px;
}
.sec h2 {
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.later .line {
  opacity: 0.7;
}
.range {
  display: flex;
  align-items: center;
  gap: 10px;
}
.range input {
  width: 180px;
  accent-color: var(--accent);
}
.range output {
  min-width: 4ch;
}
.soon {
  font: 500 12px var(--sans);
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 999px;
  padding: 2px 10px;
}
.line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 16px;
  min-height: 44px;
}
.lbl {
  flex: 1;
  min-width: 160px;
  display: flex;
  flex-direction: column;
}
.lbl > :last-child {
  font-size: 13px;
  color: var(--muted);
}
/* The personal-token fallback to Connect Lichess, folded under its line (ui/settings.ts). */
.paste-token {
  font-size: 13px;
  color: var(--muted);
}
.paste-token summary {
  cursor: pointer;
  min-height: 32px;
}
.paste-token ol {
  margin: 4px 0 8px;
  padding-left: 20px;
}
.paste-token .field {
  max-width: 320px;
}
.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 3px;
  gap: 2px;
  background: var(--bg);
}
.seg:has(> :nth-child(4)) {
  flex-wrap: wrap; /* a long row of choices (the coach's voices) wraps on a phone */
}
.seg button {
  height: 38px;
  padding: 0 14px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font: 500 14px var(--sans);
}
.seg button.on {
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 1px 3px var(--shadow);
}
.field {
  height: 44px;
  width: 240px;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 12px;
  background: var(--bg);
  color: var(--ink);
}
.swatches {
  display: flex;
  gap: 8px;
}
.sw {
  width: 52px;
  height: 52px;
  padding: 0;
  border-radius: 10px;
  overflow: hidden;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border: 2px solid transparent;
  background: none;
}
.sw.on {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--soft);
}

/* A pasted PGN's offer, above the composer. */
.notice.offer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.notice.offer span {
  flex: 1;
}
.notice.offer .btn {
  height: 36px;
}

/* The Games page: the bar, the load box, the tabs and search, the list. */
.games-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.games-page .bar {
  position: sticky;
  top: 0;
  z-index: 1;
}
.games-page .bar .btn {
  margin-left: auto;
}
.games-body {
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.games-body .notice {
  position: static;
  box-shadow: none;
}
.pgn-paste {
  width: 100%;
  height: auto;
  padding: 10px 12px;
  font: 13px var(--mono);
  resize: vertical;
}
.load-actions,
.games-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.load-actions label {
  cursor: pointer;
}
.games-tools .search {
  flex: 1;
  min-width: 200px;
  width: auto;
}
.seg .count {
  color: var(--muted);
  font-size: 12px;
}
.game-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  overflow: hidden;
}
.game-list li + li {
  border-top: 1px solid var(--line);
}
.game-row {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 16px;
  border: 0;
  background: none;
  color: var(--ink);
  text-align: left;
  font: inherit;
}
.game-row:hover {
  background: var(--soft);
}
.g-top {
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.g-players {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.g-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  color: var(--muted);
  font-size: 13px;
}
.more {
  align-self: center;
}
@media (max-width: 699px) {
  /* The tabs scroll inside their own row; they never widen the page. */
  .games-tools .seg {
    width: 100%;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }
  .games-tools .seg::-webkit-scrollbar {
    display: none;
  }
  .games-tools .seg button {
    flex: none;
    scroll-snap-align: center;
    padding: 0 10px;
    font-size: 13px;
    white-space: nowrap;
  }
  /* Search, ? and Order share the rows below without overflowing. */
  .games-tools .search {
    min-width: 0;
  }
  .games-tools .order {
    flex: 1 1 100%;
  }
  /* The bar's buttons are icons only. */
  .games-page .bar .lbl {
    display: none;
  }
  .games-page .bar .btn {
    padding: 0 12px;
  }
  .games-page .bar .btn + .btn {
    margin-left: 0;
  }
}
/* The game being played on the spotlight board, with Resign. */
.game-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 0;
  font-size: 13px;
  font-weight: 600;
}
.game-badge .btn {
  height: 26px;
  padding: 0 10px;
  font-size: 12px;
}
/* Where a board's game came from (Lichess masters, a classic's book, the student's own). */
.source-badge {
  align-self: flex-start;
  padding: 1px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 11px;
  color: var(--muted);
}

/* Thumbs under the coach's finished turn (ui/feedback.ts): quiet until hovered or pressed. */
.feedback {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  margin-top: 4px;
}
.feedback .ib {
  width: 32px;
  height: 32px;
  opacity: 0.55;
}
.feedback .ib .icon {
  width: 16px;
  height: 16px;
}
.feedback .ib:hover,
.feedback .ib[aria-pressed='true'] {
  opacity: 1;
  color: var(--accent);
}
/* The box to say why: the reply's full width, three lines growing to eight, Send below it. */
.feedback .why {
  flex-basis: 100%;
  display: grid;
  gap: 6px;
  margin-top: 4px;
}
.feedback .why .field {
  width: 100%;
  height: auto;
  padding: 8px 12px;
  font-size: 13px;
  line-height: 20px;
  resize: none;
}
.feedback .why-foot {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}
.feedback .muted {
  margin-left: 6px;
  font-size: 13px;
}

/* Settings: the account's error in place, the usage table, the privacy note (ui/account.ts). */
.sec .notice {
  position: static;
  margin-top: 8px;
  box-shadow: none;
}
/* An email field and its button side by side (the recovery email, a lost passkey). */
.email-form {
  display: flex;
  gap: 8px;
}
.usage {
  width: 100%;
  margin: 4px 0 8px;
  border-collapse: collapse;
  font-size: 13.5px;
}
.usage caption {
  text-align: left;
  padding: 4px 0;
}
.usage th {
  text-align: left;
  font-weight: 500;
  padding: 4px 0;
}
.usage td {
  text-align: right;
  padding: 4px 0;
}
.usage tr + tr {
  border-top: 1px solid var(--line);
}
.about h3 {
  font-size: 15px;
  margin: 8px 0 -8px;
}
.about p {
  margin: 0;
}
.facts {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.small {
  font-size: 13px;
}

/* Settings → Credits: the month's bar of what is left (ui/credits.ts). */
.credits-month {
  padding: 10px 0;
}
.credits-month p {
  margin: 8px 0 0;
}
.meter {
  height: 10px;
  border-radius: 5px;
  background: var(--soft);
  overflow: hidden;
}
.meter span {
  display: block;
  height: 100%;
  background: var(--accent);
}
.meter.low span {
  background: var(--danger);
}

/* The admin page (ui/admin.ts): wide tables scroll sideways in their box. */
.admin-page .games-body {
  max-width: 1200px;
}
.table-box {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  white-space: nowrap;
}
.admin-table th,
.admin-table td {
  padding: 6px 10px;
  text-align: left;
}
.admin-table thead th {
  background: var(--raised);
  font-weight: 500;
}
.admin-table tr + tr,
.admin-table tbody tr {
  border-top: 1px solid var(--line);
}
.admin-table tr.open {
  cursor: pointer;
}
.admin-table tr.open:hover {
  background: var(--soft);
}
.admin-table .sort {
  border: 0;
  padding: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.admin-page .row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.admin-page .field.num {
  width: 110px;
}

/* The "Saved" toast (ui/toast.ts): a pill near the bottom, clear of the
   update bar (pwa.css); on a phone it is at the top, under that bar. */
.toast {
  position: fixed;
  z-index: 60;
  inset-inline: 0;
  bottom: calc(88px + env(safe-area-inset-bottom));
  margin-inline: auto;
  width: fit-content;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 6px 20px var(--shadow);
  font-size: 14px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  pointer-events: none;
  transition:
    opacity 0.2s,
    transform 0.2s,
    visibility 0.2s;
}
.toast.show {
  opacity: 1;
  visibility: visible;
  transform: none;
}
.toast span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.toast .icon {
  color: var(--accent);
}
@media (max-width: 699px) {
  .toast {
    bottom: auto;
    top: calc(80px + env(safe-area-inset-top));
    transform: translateY(-8px);
  }
}
@media (prefers-reduced-motion: reduce) {
  .toast {
    transition: none;
    transform: none;
  }
}

/* The admin Overview tab (ui/overview.ts): big numbers and a sparkline. */
.tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.tile {
  display: flex;
  flex-direction: column;
  min-width: 120px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}
.tile b {
  font: 600 22px var(--display);
}
.tile span {
  font-size: 12px;
  color: var(--muted);
}
.sparkline {
  display: block;
  width: 100%;
  max-width: 400px;
  height: 48px;
  margin-bottom: 8px;
}

/* Sharing (ui/share.ts): the Share button over a card's corner and under
 * the coach's turn, the share sheet, and the links in Settings → Account. */
.card-wrap,
.card.live {
  position: relative;
}
.card-wrap > .share-btn,
.card.live > .share-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 32px;
  height: 32px;
  opacity: 0.6;
}
.card-wrap > .share-btn .icon,
.card.live > .share-btn .icon,
.turn-foot .share-btn .icon {
  width: 16px;
  height: 16px;
}
.card-wrap > .share-btn:hover,
.card.live > .share-btn:hover,
.turn-foot .share-btn:hover {
  opacity: 1;
  color: var(--accent);
}
.card-wrap > .card {
  padding-right: 40px;
}
.turn-foot {
  display: flex;
  align-items: center;
  gap: 2px;
}
.turn-foot .share-btn {
  width: 32px;
  height: 32px;
  margin-top: 4px;
  opacity: 0.55;
}
.share-sheet {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.share-preview {
  width: 100%;
  height: auto;
  border-radius: 10px;
  border: 1px solid var(--line);
}
.share-words {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.share-words textarea {
  resize: vertical;
  height: auto;
  font: inherit;
}
.share-words .muted {
  font-size: 13px;
  align-self: flex-end;
}
.share-link {
  display: flex;
  gap: 8px;
}
.share-link input {
  flex: 1;
  min-width: 0;
}
.share-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.shared-links ul {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}
.shared-links li {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  border-top: 1px solid var(--line);
}
.shared-links li a {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Side lines in the move list: under the pair they branch from, as a
 * scoresheet shows a variation: running text, indented, smaller and muted,
 * its moves still buttons; a line within a line is bracketed and indented
 * one step more. */
.moves li.var {
  display: block;
  margin: 2px 0 4px 3em;
  padding-left: 8px;
  border-left: 2px solid var(--line);
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.7;
  white-space: normal;
}
.moves li.var .mv {
  display: inline;
  min-height: 0;
  margin-right: 3px;
  padding: 1px 3px;
  color: inherit;
}
.moves li.var .mv.cur {
  color: var(--accentInk);
}
.side-name {
  margin-right: 4px;
  font-family: var(--sans);
  font-style: italic;
}
.side .sub {
  display: block;
  margin-left: 12px;
}
@media (max-width: 699px) {
  .moves li.var {
    flex-basis: 100%;
    margin-left: 6px;
  }
}

/* The web pages a reply cites (ui/sources.ts): a small numbered list under it. */
.sources {
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--muted);
}
.sources ol {
  margin: 2px 0 0;
  padding-left: 20px;
}
.sources li {
  overflow-wrap: anywhere;
}
.sources a {
  color: var(--accent);
}
.sources .host {
  margin-left: 4px;
}

/* Quotes in rich text, in the coach's replies and the user's messages. */
.you {
  white-space: normal;
}
.md blockquote {
  margin: 0 0 10px;
  padding: 2px 0 2px 12px;
  border-left: 3px solid var(--line);
  color: var(--muted);
}
.md blockquote > :last-child {
  margin-bottom: 0;
}

/* The bar that floats under selected text in a reply (ui/select.ts). */
.ask-bar {
  position: fixed;
  z-index: 40;
  display: flex;
  gap: 6px;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 8px 24px var(--shadow);
}

/* Claims that point at their explanation in the same reply (ui/marker.ts). */
.md a.claim {
  color: inherit;
  text-decoration: underline dotted var(--accent);
  text-underline-offset: 3px;
}
.md a.claim::after {
  content: '↓';
  margin-left: 2px;
  font-size: 0.8em;
  color: var(--accent);
}
.md .hot {
  background: var(--soft);
  outline: 2px solid var(--line);
  outline-offset: 3px;
  border-radius: 6px;
}
.md .flash {
  animation: flash 1.4s ease-out;
}
@keyframes flash {
  from {
    background: color-mix(in srgb, var(--accent) 30%, transparent);
  }
}
.claim-tip {
  position: fixed;
  z-index: 40;
  max-width: 280px;
  padding: 8px 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 24px var(--shadow);
  font-size: 13px;
  pointer-events: none;
}

/* The engine's view (ui/analysis.ts): with the toggle on, a row for its panel
 * under the controls; the evaluation bar upright beside the board, or across
 * the panel on a phone; the best move's arrow over the board. */
.spotlight:has(.engine-panel) {
  --bs: max(200px, min(100cqw, 100cqh - 390px));
  grid-template-areas: 'head' 'board' 'controls' 'engine' 'moves' 'note';
}
@container (min-width: 760px) {
  .spotlight:has(.engine-panel) {
    --bs: min(100cqh, 100cqw - 312px, 960px);
    grid-template-rows: auto auto auto 1fr auto;
    grid-template-areas: 'board head' 'board controls' 'board engine' 'board moves' 'board note';
  }
}
.spot-board {
  position: relative;
}
.ib:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.engine-arrow {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
  pointer-events: none;
  opacity: 0.75;
}
.eval-bar {
  display: flex;
  overflow: hidden;
  border-radius: 3px;
  background: #3a3d3b;
  box-shadow: 0 0 0 1px var(--line);
}
.eval-bar[hidden] {
  display: none;
}
.eval-white {
  background: #f2f2ee;
  transition: flex-basis 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
/* A side mates: the bar stays lit. A big swing: it glows once. */
.eval-bar.mate {
  box-shadow:
    0 0 0 1px var(--accent),
    0 0 8px var(--accent);
}
.eval-bar.swing {
  animation: eval-swing 0.9s ease-out;
}
@keyframes eval-swing {
  30% {
    box-shadow:
      0 0 0 2px var(--accent),
      0 0 14px 2px var(--accent);
  }
}
@media (prefers-reduced-motion: reduce) {
  .eval-white {
    transition: none;
  }
  .eval-bar.swing {
    animation: none;
  }
}
.eval-v {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -20px;
  width: 12px;
  flex-direction: column-reverse;
}
.eval-v.flipped {
  flex-direction: column;
}
.eval-h {
  display: none;
  flex: 1;
  height: 8px;
}
.eval-h.flipped {
  flex-direction: row-reverse;
}
.engine-panel {
  grid-area: engine;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  font-size: 14px;
}
.engine-head {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 28px;
  overflow: hidden;
}
.engine-depth {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.eval-num {
  min-width: 3.2em;
  font-variant-numeric: tabular-nums;
}
/* One 28px row per line asked for, each cut off rather than wrapped. */
.engine-lines {
  list-style: none;
  margin: 0;
  padding: 0;
  height: calc(var(--n, 1) * 28px);
  overflow: hidden;
}
.engine-lines li {
  display: flex;
  align-items: center;
  height: 28px;
  overflow: hidden;
  white-space: nowrap;
}
.eng-score {
  min-width: 3.2em;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
@media (max-width: 699px) {
  .spotlight:has(.engine-panel) {
    --bs: min(100cqw, 100cqh - 120px);
    grid-template-rows: auto auto auto minmax(0, 1fr) auto;
    grid-template-areas: 'board' 'controls' 'engine' 'moves' 'note';
  }
  .eval-v,
  .eval-v[hidden] {
    display: none;
  }
  .eval-h {
    display: flex;
  }
  .engine-panel {
    gap: 2px;
  }
}

/* Chess accounts: what to import from an account. */
.opts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  justify-content: flex-end;
  align-items: center;
}
.chk {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* The coach's words as they stream in (ui/pace.ts): the newest fade in, a soft caret ends them. */
.md .fresh {
  animation: fresh 150ms ease-out backwards;
}
@keyframes fresh {
  from {
    opacity: 0;
    transform: translateY(2px);
  }
}
.md .caret {
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 2px;
  vertical-align: text-bottom;
  border-radius: 1px;
  background: currentColor;
  opacity: 0.4;
}

/* The "/" button at the composer's left and its menu of commands (ui/slash.ts). */
.composer:has(.slash) {
  padding-left: 6px;
}
.slash {
  flex: none;
}
.slash-btn {
  font: 600 18px var(--mono);
}
.slash-menu {
  position: absolute;
  z-index: 6;
  left: 6px;
  bottom: calc(100% + 6px);
  width: min(360px, calc(100vw - 32px));
  max-height: min(60vh, 480px);
  overflow-y: auto;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 32px var(--shadow);
}
.slash-group {
  margin: 6px 10px 2px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.slash-menu [role='menuitem'] {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.slash-menu [role='menuitem'] > span:first-child {
  font-family: var(--mono);
}
.slash-menu [role='menuitem'] .muted {
  font-size: 12.5px;
}
.slash-menu [role='menuitem']:hover,
.slash-menu [role='menuitem']:focus-visible {
  background: var(--soft);
  outline: none;
}

/* A fact saved about the student, in the transcript, with Undo (ui/memory.ts). */
.fact-saved {
  align-self: center;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin: 0;
  padding: 4px 6px 4px 14px;
  font-size: 13.5px;
  border: 1px dashed var(--line);
  border-radius: 16px;
}
/* The facts kept, numbered, each to edit or delete. */
.facts-kept {
  margin: 8px 0 12px;
  padding: 0;
  list-style: none;
}
.fact {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  padding: 4px 0;
  border-bottom: 1px solid var(--line);
}
.fact .n {
  min-width: 2ch;
  color: var(--muted);
  font-family: var(--mono);
}
.fact .text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow-wrap: anywhere;
}
.fact .field {
  flex: 1;
  min-width: 0;
}
.fact .error {
  flex: 0 0 100%;
}

/* The games library (ui/games.ts, ui/game-detail.ts): results, tags, the search's help,
 * the form to add a game played over the board, and one game's page. */
.g-result.win {
  color: var(--accent);
}
.g-result.loss {
  color: var(--danger);
}
.game-row .chips .chip {
  padding: 0 8px;
  font-size: 11.5px;
}
a.source-badge {
  text-decoration: none;
}
a.source-badge:hover {
  color: var(--ink);
  border-color: var(--muted);
}
.games-tools .order {
  width: auto;
}
.search-help {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  padding: 8px 12px;
  font-size: 13px;
  overflow-x: auto;
}
.search-help td {
  padding: 3px 12px 3px 0;
  vertical-align: top;
}
.add-fields {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}
.add-fields label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
}
/* One game's page (ui/game-detail.ts): the head, then the board beside a
 * column of cards (moves and notes, details, chats), stacked on phones.
 * --bs is the board's side: as big as the window allows under the head
 * and beside the column. */
.games-body:has(> .game-detail) {
  max-width: 1440px;
}
/* Adding and loading games are the list's: a game's page has its own head. */
.games-page:has(.game-detail) .bar .btn {
  display: none;
}
.game-detail {
  --bs: min(100vh - 290px, 100vw - 600px, 880px);
  width: min(100%, var(--bs) + 548px);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.gd-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px 12px;
  align-items: start;
}
.gd-back {
  margin: -2px 0 0 -10px;
}
.gd-heading {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.gd-title {
  margin: 0;
  font: 600 28px/1.2 var(--display);
  overflow-wrap: anywhere;
}
.gd-title .title-edit {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.gd-title .pencil {
  display: inline-flex;
  color: var(--muted);
  opacity: 0.5;
  transition: opacity 0.15s;
}
.gd-title .title-edit:hover .pencil,
.gd-title .title-edit:focus-visible .pencil {
  opacity: 1;
}
.gd-title .rename.title-field {
  width: min(100%, 640px);
  height: 44px;
  padding: 0 10px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  font-size: 26px;
}
.gd-players {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  margin: 2px 0 0;
  font-size: 15px;
}
.gd-player {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.gd-name {
  font-weight: 600;
}
.gd-player .elo {
  color: var(--muted);
  font-size: 13px;
}
.disc {
  flex: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 1.5px solid var(--muted);
}
.disc.white {
  background: #f6f6f2;
}
.disc.black {
  background: #1b1d1c;
}
.gd-result {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: 6px;
  font-weight: 600;
}
.gd-outcome {
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--raised);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--muted);
  font: 600 11px var(--sans);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.gd-outcome.win {
  background: var(--soft);
  box-shadow: none;
  color: var(--accent);
}
.gd-outcome.loss {
  color: var(--danger);
}
.gd-facts {
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
}
.gd-facts .chip {
  background: var(--raised);
}
.gd-facts b {
  color: var(--ink);
  font-weight: 500;
}
.gd-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}
.gd-cols {
  display: grid;
  grid-template-columns: var(--bs) minmax(320px, 520px);
  justify-content: center;
  align-items: start;
  gap: 28px;
}
.gd-play {
  position: sticky;
  top: 80px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.gd-controls {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}
.gd-at {
  flex: 1;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}
.gd-side {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}
.gd-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
}
.gd-card h3 {
  margin: 0;
  font: 600 15px var(--display);
}
.gd-moves .game-graph {
  height: 72px;
}
.gd-moves .moves-box {
  max-height: max(200px, var(--bs) * 0.45);
}
/* The moves as a scoresheet: two columns of numbered pairs, down then across. */
.gd-moves .moves {
  columns: 2;
  column-gap: 20px;
}
.gd-moves .moves li {
  grid-template-columns: 2.6em 1fr 1fr;
  break-inside: avoid;
}
/* A move the student or coach wrote a note on (gamemeta.ts): a dot after it. */
.mv.marked::after {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  margin: 0 0 2px 5px;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: middle;
}
.mv.cur.marked::after {
  background: var(--accentInk);
}
.gd-notes {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.gd-comment,
.gd-note {
  margin: 0;
  padding: 8px 12px;
  border-left: 3px solid var(--muted);
  border-radius: 0 10px 10px 0;
  background: var(--raised);
  font-size: 13.5px;
  line-height: 1.45;
}
.gd-note {
  display: flex;
  align-items: flex-start;
  gap: 2px;
  padding-right: 4px;
}
.gd-note > :first-child {
  flex: 1;
  min-width: 0;
}
.gd-note.coach {
  border-left-color: var(--accent);
  background: var(--soft);
}
.gd-note p {
  margin: 0;
  white-space: pre-wrap;
}
.gd-note .who {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.ib.sm {
  width: 32px;
  height: 32px;
  border-radius: 8px;
}
.ib.sm .icon {
  width: 16px;
  height: 16px;
}
.btn.gd-add {
  align-self: flex-start;
  height: 36px;
  padding: 0 12px;
  border-style: dashed;
  color: var(--muted);
  font-size: 13.5px;
}
.btn.gd-add:hover {
  color: var(--ink);
}
.gd-edit {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.gd-edit-bar {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.gd-edit-bar .btn {
  height: 36px;
}
.gd-editor,
.gd-row textarea.field {
  width: 100%;
  height: auto;
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  line-height: 1.45;
  resize: vertical;
}
.gd-details {
  display: block;
}
.gd-details summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 24px;
  list-style: none;
  cursor: pointer;
}
.gd-details summary::-webkit-details-marker {
  display: none;
}
.gd-details summary .icon {
  color: var(--muted);
  transition: transform 0.15s;
}
.gd-details:not([open]) summary .icon {
  transform: rotate(-90deg);
}
.gd-fields {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}
.gd-row {
  display: grid;
  grid-template-columns: 6.5em minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}
.gd-row.top {
  align-items: start;
}
.gd-row.top .gd-label {
  padding-top: 10px;
}
.gd-label {
  color: var(--muted);
  font-size: 13px;
}
.gd-row .field {
  width: 100%;
  height: 40px;
  font-size: 14px;
}
.tag-chip {
  padding-right: 6px;
  border-color: transparent;
  background: var(--soft);
  color: var(--ink);
}
.tag-chip button {
  display: inline-flex;
  color: var(--muted);
}
.tag-chip button:hover {
  color: var(--danger);
}
.gd-tag-input {
  width: 116px;
  height: 27px;
  padding: 0 10px;
  border: 1px dashed var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 12.5px;
}
.gd-tag-input:focus {
  width: 170px;
  border: 1px solid var(--accent);
  outline: none;
}
.gd-chats ul {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0 -8px;
  padding: 0;
  list-style: none;
}
.gd-chats p {
  margin: 0;
  font-size: 13.5px;
}
.gd-chat {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 6px 8px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}
.gd-chat:hover {
  background: var(--soft);
}
.gd-chat .icon {
  width: 16px;
  height: 16px;
  color: var(--accent);
}
.gd-chat span:first-of-type {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gd-chat .muted {
  font-size: 12.5px;
}
@media (max-width: 899px) {
  .game-detail {
    --bs: min(100vw - 32px, 640px);
    width: 100%;
  }
  .gd-head {
    grid-template-columns: auto minmax(0, 1fr);
  }
  .gd-actions {
    grid-column: 1 / -1;
  }
  .gd-actions .btn {
    flex: 1 1 auto;
    justify-content: center;
  }
  .gd-title {
    font-size: 22px;
  }
  .gd-cols {
    grid-template-columns: minmax(0, var(--bs));
  }
  .gd-play {
    position: static;
  }
  .gd-moves .moves-box {
    max-height: 220px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .gd-title .pencil,
  .gd-details summary .icon {
    transition: none;
  }
}

/* Saved positions: the Games page's Positions tab, and a review in a sheet (ui/snapshots.ts). */
.snap-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.snap {
  display: flex;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--raised);
}
.snap .thumb-board {
  width: 120px;
  flex: none;
}
.snap-text {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.snap-notes .field,
.practise .field {
  width: 100%;
  margin-top: 6px;
}
.snap-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.practise {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.practise-board {
  width: min(100%, 360px);
  align-self: center;
}
/* A repertoire's tree (ui/repertoire.ts): taller than a game page's list. */
.rep .rep-moves {
  max-height: 30vh;
}

/* Endgames (ui/endgames.ts): the curriculum, a row per position, a tick
 * before the ones done. */
.end-list {
  margin: 0;
  padding: 0;
  list-style: none;
}
.end-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 4px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.end-row:hover {
  background: var(--soft);
}
.end-tick {
  display: inline-flex;
  width: 20px;
  flex: none;
}
.end-name {
  flex: 1;
}
@media (max-width: 480px) {
  .snap .thumb-board {
    width: 88px;
  }
}

/* Lessons (ui/lessons.ts): the Lessons tab's rows, the Save as lesson
 * sheet, and the "3 to practise" line. */
.lesson-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.lesson {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--raised);
}
.lesson-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.practice-nudge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 8px 0;
}

/* A study's preview in the Publish sheet (ui/study.ts): exactly what the
 * page will hold, scrolling inside the sheet. */
.study-preview {
  max-height: 40vh;
  overflow: auto;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow-wrap: anywhere;
}
.study-preview h3 {
  margin: 0;
}
.study-preview ul {
  padding-left: 18px;
}
.study-turn p {
  margin: 4px 0;
  white-space: pre-wrap;
}
.study-turn b {
  font-size: 13px;
  color: var(--muted);
}

/* The game graph (ui/graph.ts): White's winning chances, light over dark as
 * on the evaluation bar; the errors as dots (?! amber, ? orange, ?? red), a
 * tick through the move the game turned on, the ply shown in green, which
 * reads on light and dark alike. */
.game-graph {
  flex: none;
  height: 56px;
  border-radius: 6px;
  overflow: hidden;
  background: #3a3d3b;
  box-shadow: 0 0 0 1px var(--line);
  cursor: pointer;
  touch-action: none;
}
.game-graph:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.game-graph svg {
  display: block;
  width: 100%;
  height: 100%;
}
.game-graph path,
.game-graph line {
  vector-effect: non-scaling-stroke;
}
.game-graph .area {
  fill: #f2f2ee;
}
.game-graph .top {
  fill: none;
  stroke: #9aa19b;
  stroke-width: 1;
}
.game-graph .mid {
  stroke: #8a8f8b;
  stroke-dasharray: 3 3;
}
.game-graph .mark,
.game-graph .dot {
  stroke-linecap: round;
  stroke-width: 7;
}
.game-graph .inaccuracy {
  stroke: #e0b000;
}
.game-graph .mistake {
  stroke: #ef7d16;
}
.game-graph .blunder {
  stroke: #d92d20;
}
.game-graph .turn {
  stroke: #d92d20;
  stroke-opacity: 0.5;
  stroke-dasharray: 2 2;
}
/* The moments' flags at the top (ui/graph.ts): small, apart from the error
 * dots by shape and colour, a blue dot for an only move, a purple bar for
 * a treacherous position. */
.game-graph .only {
  stroke: #5aa9e6;
  stroke-linecap: round;
  stroke-width: 5;
}
.game-graph .treacherous {
  stroke: #b07ce8;
  stroke-width: 3;
}
.game-graph .now {
  stroke: #3fb27f;
  stroke-width: 2;
}
.game-graph .dot {
  stroke: #3fb27f;
  stroke-width: 8;
}
@media (max-width: 699px) {
  .game-graph {
    height: 40px;
  }
}

/* The analysis column (ui/explorer.ts, ui/spotlight.ts): on a wide spotlight
 * the column beside the board widens to hold the engine, the opening
 * explorer, the graph and the moves, and the session's boards run in a
 * strip under the board in place of the picker. Narrower ones show neither. */
.explorer,
.board-strip {
  display: none;
}
@container (min-width: 1600px) and (min-height: 760px) {
  .spotlight,
  .spotlight:has(.move-note),
  .spotlight:has(.engine-panel) {
    --strip: 140px;
    --bs: min(100cqh - var(--strip) - 12px, 100cqw - 432px, 960px);
    height: calc(var(--bs) + 12px + var(--strip));
    grid-template-columns: var(--bs) minmax(400px, 640px);
    grid-template-rows: auto auto auto auto auto minmax(0, 1fr) var(--strip);
    grid-template-areas:
      'board head' 'board controls' 'board engine' 'board explorer' 'board note'
      'board moves' 'strip moves';
  }
  .moves-box,
  .moves-area:has(.game-graph) .moves-box {
    max-height: none;
  }
  .game-graph {
    height: 80px;
  }
  .moves {
    max-width: 380px;
  }
  .explorer {
    grid-area: explorer;
    display: flex;
    flex-direction: column;
  }
  /* The explorer's rows, scrolling inside it; the grip under them sets its height (ui/explorer.ts). */
  .ex-box {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    align-items: start;
    gap: 8px 24px;
    height: calc(var(--bs) * 0.42);
    overflow: auto;
    overscroll-behavior: contain;
    transition: height 0.2s ease;
  }
  .ex-box.dragging {
    transition: none;
  }
  .board-strip {
    grid-area: strip;
    display: flex;
    gap: 10px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    padding: 2px 3px 6px;
  }
  .board-strip .pick {
    flex: none;
    width: 104px;
  }
}
.ex-part {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ex-part h3 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ex-list {
  margin: 0;
  padding: 0;
  list-style: none;
}
/* A move of the explorer: its name, its games, and a bar of how they ended. */
.ex-move {
  width: 100%;
  min-height: 28px;
  display: grid;
  grid-template-columns: 4.5em 3.5em 1fr;
  align-items: center;
  gap: 8px;
  padding: 2px 6px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--ink);
  font: 13.5px var(--sans);
  text-align: left;
}
.ex-move:hover {
  background: var(--soft);
}
.ex-san {
  font: 600 13.5px var(--mono);
}
.ex-games {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
/* White's wins, draws and Black's wins, light to dark as on the evaluation bar. */
.wdl {
  display: flex;
  height: 16px;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--line);
  font: 600 10.5px/16px var(--sans);
  text-align: center;
}
.wdl > span {
  flex-grow: 0;
  flex-shrink: 0;
  overflow: hidden;
}
.wdl-white {
  background: #f2f2ee;
  color: #3a3d3b;
}
.wdl-draw {
  background: #9aa19b;
  color: #1f2220;
}
.wdl-black {
  background: #3a3d3b;
  color: #f2f2ee;
}
.ex-note {
  margin: 0;
  font-size: 13px;
}
/* The last answer, dimmed while the next loads, with a pulsing dot in its heading. */
.ex-part {
  transition: opacity 0.2s ease;
}
.ex-part.stale {
  opacity: 0.45;
}
.ex-part.stale h3::after {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-left: 8px;
  border-radius: 50%;
  background: var(--muted);
  animation: ex-pulse 1s ease-in-out infinite;
}
.ex-part.fresh {
  animation: ex-in 0.2s ease;
}
@keyframes ex-pulse {
  50% {
    opacity: 0.2;
  }
}
@keyframes ex-in {
  from {
    opacity: 0.45;
  }
}
@media (prefers-reduced-motion: reduce) {
  .ex-box,
  .ex-part {
    transition: none;
  }
  .ex-part.fresh,
  .ex-part.stale h3::after {
    animation: none;
  }
}
/* The grip on the explorer's bottom edge: a short bar, dragged up or down. */
.ex-grip {
  flex: none;
  position: relative;
  height: 12px;
  padding: 0;
  border: 0;
  background: none;
  cursor: ns-resize;
  touch-action: none;
}
.ex-grip::after {
  content: '';
  position: absolute;
  top: 5px;
  left: calc(50% - 18px);
  width: 36px;
  height: 3px;
  border-radius: 2px;
  background: var(--line);
}
.ex-grip:hover::after,
.ex-grip:focus-visible::after {
  background: var(--muted);
}

/* The chat's quick settings: a popover under its button, a bottom sheet on a phone. */
.quick-pop {
  position: fixed;
  top: var(--qt, 60px);
  right: var(--qr, 8px);
  z-index: 40;
  width: min(340px, calc(100vw - 16px));
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 8px 28px rgb(0 0 0 / 0.25);
}
.quick-pop[hidden] {
  display: none;
}
.quick-pop .line {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}
.quick-pop .range input {
  flex: 1;
  width: auto;
  min-width: 0;
}
.quick-pop .seg {
  align-self: stretch;
}
.quick-pop .seg button {
  flex: 1;
}
.quick-pop > a {
  align-self: flex-end;
  font-size: 14px;
}
@media (max-width: 699px) {
  .quick-pop {
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: auto;
    border-radius: 16px 16px 0 0;
    padding-bottom: max(14px, env(safe-area-inset-bottom));
  }
}

/* Admin → Live rooms: each room a padded row, its title an app link, its
   actions on the right. */
.room-list {
  margin-top: 12px;
}
.room-list li.line {
  padding: 12px 16px;
  gap: 16px;
  align-items: center;
}
.room-list .lbl {
  gap: 2px;
}
.room-list a {
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
}
.room-list a:hover {
  text-decoration: underline;
}
.room-list .row {
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.sec .field[aria-label='Lichess broadcast round'] {
  min-width: 260px;
}
