:root {
  --bg: #f4f1ea;
  --card: #ffffff;
  --ink: #1f2a24;
  --muted: #6b726d;
  --line: #e2ddd2;
  --accent: #2f6b45;
  --accent-ink: #ffffff;
  --mine: #15803d;
  --theirs: #2563eb;
  --light: #f0d9b5;
  --dark: #b58863;
  --last: rgba(155, 199, 0, 0.42);
  --sel: rgba(20, 85, 30, 0.5);
  --danger: #b42318;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: env(safe-area-inset-bottom);
}
button { font: inherit; color: inherit; cursor: pointer; }

/* ---- header ---- */
.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: var(--ink); color: #fff;
}
.brand { font-weight: 700; letter-spacing: 0.02em; }
.seg { display: flex; background: rgba(255,255,255,0.12); border-radius: 10px; padding: 3px; }
.seg button {
  border: 0; background: transparent; color: #fff; padding: 6px 16px; border-radius: 8px; font-weight: 600;
}
.seg button.on { background: #fff; color: var(--ink); }

/* ---- layout ---- */
.layout { max-width: 560px; margin: 0 auto; padding: 12px 12px 24px; }
@media (min-width: 900px) {
  .layout { max-width: 1100px; display: grid; grid-template-columns: minmax(0, 560px) minmax(0, 1fr); gap: 20px; align-items: start; }
  .board-col { position: sticky; top: 12px; }
}

/* ---- board ---- */
.board { position: relative; width: 100%; aspect-ratio: 1; touch-action: none; user-select: none; -webkit-user-select: none; border-radius: 4px; overflow: hidden; box-shadow: 0 2px 10px rgba(0,0,0,0.18); }
.board .grid { display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); width: 100%; height: 100%; }
.sq { position: relative; }
.sq.light { background: var(--light); }
.sq.dark { background: var(--dark); }
.sq.last::before, .sq.sel::before { content: ""; position: absolute; inset: 0; }
.sq.last::before { background: var(--last); }
.sq.sel::before { background: var(--sel); }
.sq.check { background: radial-gradient(circle, #ff3b30 0%, rgba(231,0,0,0.6) 35%, rgba(169,0,0,0) 75%), var(--dark); }
.sq.light.check { background: radial-gradient(circle, #ff3b30 0%, rgba(231,0,0,0.6) 35%, rgba(169,0,0,0) 75%), var(--light); }
.sq.target::after { content: ""; position: absolute; left: 36%; top: 36%; width: 28%; height: 28%; border-radius: 50%; background: rgba(20, 85, 30, 0.45); }
.sq.capture::after { content: ""; position: absolute; inset: 0; border-radius: 50%; box-shadow: inset 0 0 0 5px rgba(20, 85, 30, 0.45); }
.sq .pc { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none; }
.sq .rank, .sq .file { position: absolute; font-size: 10px; font-weight: 700; z-index: 2; pointer-events: none; }
.sq .rank { top: 2px; left: 3px; }
.sq .file { bottom: 1px; right: 3px; }
.sq.light .rank, .sq.light .file { color: var(--dark); }
.sq.dark .rank, .sq.dark .file { color: var(--light); }
.board .arrows { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; }
.ghost { position: fixed; z-index: 50; pointer-events: none; transform: scale(1.15); }
.promo { position: absolute; inset: 0; z-index: 5; background: rgba(0,0,0,0.45); display: flex; align-items: center; justify-content: center; gap: 8px; }
.promo button { width: 20%; aspect-ratio: 1; border: 0; border-radius: 50%; background: #fff; padding: 6px; box-shadow: 0 2px 8px rgba(0,0,0,0.3); }
.promo img { width: 100%; height: 100%; }

/* ---- nav ---- */
.nav { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 10px; }
.nav button { border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 10px 0; font-size: 18px; }
.nav button:active { background: var(--line); }

/* ---- path ---- */
.path-row { display: flex; align-items: flex-start; gap: 10px; margin: 12px 0 10px; }
@media (min-width: 900px) { .path-row { margin-top: 0; } }
.path { flex: 1; min-width: 0; line-height: 1.9; font-size: 15px; }
.path .num { color: var(--muted); margin-right: 2px; }
.path .mv { border: 0; background: none; padding: 1px 5px; border-radius: 6px; font-weight: 600; margin-right: 2px; }
.path .mv.unsaved { color: var(--muted); font-style: italic; font-weight: 400; border: 1px dashed #c9c2b3; }
.path .mv.cur { background: var(--ink); color: #fff; }
.path .empty { color: var(--muted); }
.primary { border: 0; background: var(--accent); color: var(--accent-ink); border-radius: 10px; padding: 8px 14px; font-weight: 600; white-space: nowrap; }

/* ---- panels ---- */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.panel h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0; }
.hint { color: var(--muted); font-size: 13px; margin: 0; }
.moves { list-style: none; margin: 0; padding: 0; }
.moves li { display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--line); }
.moves li:first-child { border-top: 0; }
.moves .play { flex: 1; display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 10px 0; text-align: left; min-width: 0; }
.moves .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.moves .san { font-weight: 700; font-size: 17px; }
.moves .tag { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--mine); }
.moves .count { color: var(--muted); font-size: 13px; margin-left: auto; }
.moves .act { border: 0; background: none; color: var(--muted); padding: 8px; font-size: 16px; }
.moves .act.del:active { color: var(--danger); }
.moves .none { color: var(--muted); padding: 6px 0; font-size: 14px; }
textarea { width: 100%; font: inherit; font-size: 16px; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; resize: vertical; background: #fbfaf7; color: var(--ink); }
.stats { color: var(--muted); font-size: 13px; text-align: center; margin: 4px 0 0; }

/* ---- header button + PGN sheet ---- */
.top { gap: 10px; }
.top .seg { margin-left: auto; }
.icon-btn { border: 0; background: rgba(255,255,255,0.12); color: #fff; width: 38px; height: 34px; border-radius: 10px; font-size: 20px; line-height: 1; }
.icon-btn.dark { background: var(--line); color: var(--ink); font-size: 16px; }
.sheet-wrap { position: fixed; inset: 0; z-index: 40; background: rgba(15, 20, 17, 0.45); overflow-y: auto; }
.sheet { background: var(--card); margin: 0 auto; max-width: 560px; border-radius: 0 0 16px 16px; padding: calc(env(safe-area-inset-top) + 12px) 16px 16px; box-shadow: 0 8px 30px rgba(0,0,0,0.25); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet h2 { margin: 0; font-size: 18px; }
.sheet h3 { margin: 16px 0 4px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.sheet section + section { border-top: 1px solid var(--line); margin-top: 14px; }
.sheet .hint { margin-bottom: 10px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.btn { display: inline-block; border: 1px solid var(--line); background: #fbfaf7; border-radius: 10px; padding: 8px 14px; font-weight: 600; cursor: pointer; }
.btn:active { background: var(--line); }
#paste-box textarea { margin-top: 10px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 16px; }
.field { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; font-weight: 600; }
.field select { font: inherit; font-size: 16px; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: #fbfaf7; color: var(--ink); }
.preview { background: var(--bg); border-radius: 8px; padding: 8px 10px; font-size: 14px; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); top: calc(env(safe-area-inset-top) + 64px); z-index: 60; background: var(--ink); color: #fff; border-radius: 12px; padding: 10px 14px; display: flex; gap: 14px; align-items: center; box-shadow: 0 6px 20px rgba(0,0,0,0.3); max-width: calc(100% - 32px); font-size: 14px; }
.toast[hidden] { display: none; }
.toast button { border: 0; background: none; color: #9be3b4; font-weight: 700; padding: 0; }

/* ---- line table: one W/B column pair per line, rows are move numbers ---- */
.mini-seg { display: flex; background: var(--bg); border-radius: 8px; padding: 2px; }
.mini-seg button { border: 0; background: none; padding: 4px 10px; border-radius: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.mini-seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,0.12); }
.lines-panel { padding-left: 0; padding-right: 0; padding-bottom: 6px; }
.lines-panel .panel-head { padding: 0 14px; }
.lines-panel .hint { padding: 6px 14px 0; }
.lines-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-top: 1px solid var(--line); }
.lt { border-collapse: separate; border-spacing: 0; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
.lt th, .lt td { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 0; height: 30px; }
.lt .no { position: sticky; left: 0; z-index: 2; background: #f6f3ec; color: var(--muted); text-align: center; width: 30px; min-width: 30px; font-size: 11px; border-right: 2px solid #d6cfc0; }
.lt thead .no { z-index: 3; }
.lt .lname { background: #f6f3ec; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: 12px; font-weight: 700; color: var(--muted); padding: 0 6px; white-space: nowrap; text-align: left; border-right: 2px solid #d6cfc0; }
.lt .lname.act { background: var(--ink); color: #fff; }
.lt .lname.unsaved { background: #fbfaf7; border-bottom: 1px dashed #c9c2b3; font-style: italic; }
.lt .wb { background: #f6f3ec; color: var(--muted); font-size: 10px; height: 20px; font-family: -apple-system, BlinkMacSystemFont, sans-serif; font-weight: 600; }
.lt td.c { min-width: 50px; text-align: center; cursor: pointer; position: relative; white-space: nowrap; padding: 0 5px; }
.lt td.c.pb, .lt .wb.pb { border-right: 2px solid #d6cfc0; }
.lt td.c.mine { color: var(--mine); font-weight: 700; }
.lt td.c.rep { color: #b9b2a4; font-weight: 400; }
.lt td.c.branch { background: #fef3c7; color: #6b4a00; }
.lt td.c.actcol { background: #eef4ef; }
.lt td.c.actcol.branch { background: #fde68a; }
.lt td.c.cur { box-shadow: inset 0 0 0 2px var(--ink); }
.lt td.c.note::after { content: ""; position: absolute; top: 4px; right: 4px; width: 5px; height: 5px; border-radius: 50%; background: #d4a017; }
.lt td.c.unsaved { color: var(--muted); font-style: italic; }
.lt td.c:active { background: var(--line); }
.lines-empty { color: var(--muted); font-size: 14px; padding: 10px 14px 4px; margin: 0; }

/* ---- mini board when the main board is scrolled away (phone) ---- */
.mini { position: fixed; bottom: calc(env(safe-area-inset-bottom) + 12px); right: 12px; z-index: 30; width: 128px; padding: 0; border: 2px solid #fff; border-radius: 6px; background: #fff; box-shadow: 0 6px 20px rgba(0,0,0,0.3); }
.mini[hidden] { display: none; }
.mini .board { box-shadow: none; border-radius: 3px; }
.mini .sq .rank, .mini .sq .file { display: none; }

.tip { margin: 8px 0 0; padding-top: 8px; border-top: 1px dashed var(--line); color: var(--muted); font-size: 13px; }
.tip:empty { display: none; }
.tip b { color: var(--ink); }

/* ---- training ---- */
body:not(.training) .train-only, body.training .build-only,
body:not(.viewing) .view-only, body.viewing .build-only { display: none !important; }
.train-bar { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
@media (min-width: 900px) { .train-bar { margin-top: 0; } }
.train-bar .due { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.train-bar .due b { font-size: 16px; }
.train-bar .primary:disabled { opacity: 0.4; }
.train-panel { margin-top: 12px; }
@media (min-width: 900px) { .train-panel { margin-top: 0; } }
.train-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.t-prompt { font-size: 22px; font-weight: 700; margin: 10px 0 4px; }
.t-feedback { margin: 0 0 8px; font-size: 15px; font-weight: 600; min-height: 1.4em; }
.t-feedback.ok { color: var(--mine); }
.t-feedback.bad { color: var(--danger); }
.t-feedback.alt { color: #92610a; }
.t-note { margin: 0 0 10px; background: #fef9e7; border-left: 3px solid #d4a017; padding: 8px 10px; border-radius: 6px; font-size: 14px; white-space: pre-wrap; }
.t-note:empty { display: none; }
.t-summary { font-size: 15px; margin: 0 0 10px; }

/* ---- study: master games + theory ---- */
.study .mini-seg button { padding: 4px 8px; }
.g-sum { font-size: 13px; color: var(--muted); margin: 0 0 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.chip { font-size: 13px; padding: 3px 8px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); font-weight: 600; }
.chip small { color: var(--muted); font-weight: 400; margin-left: 3px; }
.chip.mine { border-color: var(--mine); color: var(--mine); background: #eef6f0; }
.glist { list-style: none; margin: 0; padding: 0; }
.glist li { border-top: 1px solid var(--line); }
.glist button { width: 100%; border: 0; background: none; text-align: left; padding: 9px 0; display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; }
.glist .who { font-weight: 700; }
.glist .res { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; color: var(--muted); align-self: center; grid-row: span 2; }
.glist .res.w { color: var(--ink); }
.glist .meta { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.more { margin-top: 8px; }
.theory h3 { font-size: 15px; margin: 12px 0 4px; }
.theory p { margin: 0 0 8px; font-size: 15px; line-height: 1.5; }
.theory ul { margin: 0 0 8px; padding-left: 20px; font-size: 15px; }
.theory .src { font-size: 12px; color: var(--muted); margin-top: 8px; }
.theory .src a { color: var(--accent); }
.theory .clip { max-height: 360px; overflow: hidden; position: relative; }
.theory .clip::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 50px; background: linear-gradient(transparent, var(--card)); }

/* ---- game viewer ---- */
.viewer { margin-top: 12px; }
@media (min-width: 900px) { .viewer { margin-top: 0; } }
.v-title { display: flex; flex-direction: column; min-width: 0; }
.v-title b { font-size: 17px; }
.v-status { font-size: 14px; margin: 8px 0; color: var(--muted); }
.v-status b { color: var(--ink); }
.v-nav { grid-template-columns: repeat(4, 1fr); margin: 0 0 10px; }
.v-moves { max-height: 220px; overflow-y: auto; line-height: 1.9; font-size: 15px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 6px 0; margin-bottom: 8px; }
.v-moves .num { color: var(--muted); margin-right: 2px; }
.v-moves button { border: 0; background: none; padding: 1px 4px; border-radius: 6px; font-weight: 600; }
.v-moves button.in { color: var(--mine); }
.v-moves button.cur { background: var(--ink); color: #fff; }
@media (max-width: 899px) { .layout { padding-bottom: 150px; } }

/* ---- opening names ---- */
.opening { margin: 12px 0 -4px; font-size: 13px; font-weight: 700; color: var(--accent); letter-spacing: 0.01em; }
.opening:empty { display: none; }
@media (min-width: 900px) { .opening { margin-top: 0; } }
.jump { display: block; margin: 0 14px 10px; width: calc(100% - 28px); font: inherit; font-size: 16px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: #fbfaf7; color: var(--ink); }
.lt .fam { background: #ebe5d8; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: 12px; font-weight: 700; color: var(--ink); text-align: left; padding: 0 6px; white-space: nowrap; height: 26px; border-right: 2px solid #d6cfc0; }
.lt .fam span { position: sticky; left: 36px; }
.lt .fam.act { background: var(--accent); color: #fff; }
.lt .lname { height: auto; padding: 4px 6px; vertical-align: top; white-space: normal; max-width: 128px; }
.lt .lname .vn { display: block; font-size: 11px; line-height: 1.25; color: var(--ink); font-weight: 700; }
.lt .lname .bl { display: block; font-size: 11px; font-weight: 400; margin-top: 2px; font-family: ui-monospace, Menlo, Consolas, monospace; }
.lt .lname.act .vn { color: #fff; }

/* ---- master sync ---- */
.field input { font: inherit; font-size: 16px; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: #fbfaf7; color: var(--ink); min-width: 0; width: 60%; }
.linkbtn { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 600; text-decoration: underline; font-size: inherit; }
.banner { position: sticky; top: 0; z-index: 35; background: #fef9e7; border-bottom: 2px solid #d4a017; padding: 10px 16px 12px; }
.banner p { margin: 0; font-size: 15px; }
.banner .row { margin-top: 8px; }
.status-ok { color: var(--mine); }
.status-bad { color: var(--danger); }

/* ---- header stays on screen while scrolling ---- */
.top { position: sticky; top: 0; z-index: 36; }
.banner { top: var(--head-h, 54px); }
.panel { scroll-margin-top: calc(var(--head-h, 54px) + 8px); }
@media (min-width: 900px) { .board-col { top: calc(var(--head-h, 54px) + 12px); } }

/* ---- training chooser ---- */
.train-start { margin-top: 12px; }
@media (min-width: 900px) { .train-start { margin-top: 0; } }
.ts-scope { display: inline-flex; }
.ts-scope button:disabled { opacity: 0.4; }
.ts-name { margin: 6px 0 10px; }
.ts-modes { display: grid; gap: 8px; }
.ts-mode { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; border: 1px solid var(--line); background: #fbfaf7; border-radius: 12px; padding: 10px 12px; }
.ts-mode b { font-size: 16px; }
.ts-mode span { font-size: 13px; color: var(--muted); }
.ts-mode:not(:disabled):active { background: var(--line); }
.ts-mode:disabled { opacity: 0.45; }
.ts-rule { margin: 10px 0 0; font-size: 12px; }

/* ---- note from the end of a training line ---- */
.t-end:not(:has(button:not([hidden]))) { display: none; }
.t-note-edit { margin-top: 10px; }

/* ---- remembered Lichess links ---- */
.links { margin-top: 12px; }
.links h4 { margin: 0 0 4px; font-size: 13px; color: var(--muted); font-weight: 600; }
.links ul { list-style: none; margin: 0; padding: 0; }
.links li { display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--line); padding: 6px 0; }
.links li span { flex: 1; min-width: 0; font-size: 14px; }
.links li small { display: block; color: var(--muted); font-size: 12px; }
.links li .linkbtn { font-size: 13px; }

/* ---- line table export ---- */
.lines-foot-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 0 14px; }
.lines-foot-row .hint { padding: 6px 0 0; }
.lines-foot-row .linkbtn { font-size: 13px; white-space: nowrap; }

/* ---- engine tab ---- */
.ev { display: flex; align-items: center; gap: 10px; margin: 2px 0 8px; }
.ev-score { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 700; font-size: 18px; min-width: 64px; }
.ev-bar { flex: 1; height: 14px; border-radius: 7px; background: #3a3a3a; overflow: hidden; border: 1px solid #b8b0a0; }
.ev-bar span { display: block; height: 100%; background: #f4f1ea; transition: width 0.3s; }
.ev-lines { list-style: none; margin: 0; padding: 0; }
.ev-lines li { border-top: 1px solid var(--line); }
.ev-lines button { width: 100%; display: flex; gap: 10px; align-items: baseline; border: 0; background: none; text-align: left; padding: 8px 0; }
.ev-lines .s { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 700; min-width: 54px; font-size: 14px; }
.ev-lines .pv { font-size: 14px; line-height: 1.4; }
.ev-lines .pv b { color: var(--accent); }
.ev-foot { font-size: 12px; color: var(--muted); margin: 6px 0 0; }

/* ---- model games ---- */
.study .panel-head { flex-wrap: wrap; }
.v-model { background: #fef9e7; border-left: 3px solid #d4a017; border-radius: 6px; padding: 8px 10px; margin-bottom: 8px; }
.v-model-head { margin: 0 0 6px; font-weight: 700; color: #92610a; display: flex; justify-content: space-between; }
.v-model textarea { background: #fffdf5; }
.mlist { list-style: none; margin: 0; padding: 0; }
.mlist li { border-top: 1px solid var(--line); }
.mlist button.open { width: 100%; border: 0; background: none; text-align: left; padding: 9px 0; display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; }
.mlist .who { font-weight: 700; }
.mlist .who::before { content: "★ "; color: #d4a017; }
.mlist .res { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; color: var(--muted); align-self: center; grid-row: span 3; }
.mlist .meta { font-size: 13px; color: var(--muted); }
.mlist .why { font-size: 13px; font-style: italic; color: var(--ink); }
.m-add { margin-top: 10px; }
.m-add summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: 14px; }
.m-add textarea { margin-top: 8px; font-family: ui-monospace, Menlo, Consolas, monospace; }
.lt .lname .star { color: #d4a017; font-weight: 700; margin-left: 4px; }
.lt .lname.act .star { color: #ffd65c; }
.t-models { margin: 0 0 10px; }
.t-models p { margin: 0 0 4px; font-size: 13px; font-weight: 700; color: #92610a; }
.t-models button { display: block; width: 100%; text-align: left; border: 1px solid #ecdca8; background: #fffaf0; border-radius: 8px; padding: 6px 10px; margin-bottom: 4px; font-size: 14px; }
.t-models button small { display: block; color: var(--muted); font-style: italic; }
body.viewing .train-only { display: none !important; }

/* ---- engine line check ---- */
.foot-btns { display: flex; flex-wrap: wrap; gap: 4px 14px; justify-content: flex-end; }
.check { margin-top: 12px; }
@media (min-width: 900px) { .check { margin-top: 0; margin-bottom: 12px; } }
.check-list { list-style: none; margin: 0; padding: 0; }
.check-list li { border-top: 1px solid var(--line); }
.check-list button { width: 100%; border: 0; background: none; text-align: left; padding: 8px 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.check-list .mv { font-weight: 700; font-family: ui-monospace, Menlo, Consolas, monospace; min-width: 70px; }
.check-list small { flex-basis: 100%; color: var(--muted); font-size: 13px; }
.check-list .pending { color: var(--muted); font-size: 13px; }
.vb { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; color: #fff; }
.vb.best { background: #15803d; } .vb.solid { background: #0d9488; } .vb.playable { background: #b7791f; }
.vb.risky { background: #ea580c; } .vb.mistake { background: #dc2626; }
.vb.surprise { background: #fef3c7; color: #92610a; border: 1px solid #d4a017; }
.vb.sideline { background: #eef2ff; color: #3730a3; border: 1px solid #a5b4fc; }
.lt td.c.chk-best { box-shadow: inset 0 -3px 0 #15803d; }
.lt td.c.chk-solid { box-shadow: inset 0 -3px 0 #0d9488; }
.lt td.c.chk-playable { box-shadow: inset 0 -3px 0 #d4a017; }
.lt td.c.chk-risky { box-shadow: inset 0 -3px 0 #ea580c; }
.lt td.c.chk-mistake { box-shadow: inset 0 -3px 0 #dc2626; }
.lt td.c.cur { box-shadow: inset 0 0 0 2px var(--ink); }
.lt td.c.chk-surprise::before { content: "★"; position: absolute; top: 1px; left: 3px; font-size: 9px; color: #d4a017; }

.version { margin: 14px 0 0; text-align: center; font-size: 12px; color: var(--muted); }

/* ---- menu panel: controls never push the panel wider than the screen ---- */
.sheet-wrap { overflow-x: hidden; }
.sheet { width: 100%; }
.field { min-width: 0; }
.field select, .field input { min-width: 0; max-width: 65%; text-overflow: ellipsis; }
@media (max-width: 520px) {
  .field { flex-direction: column; align-items: stretch; gap: 4px; }
  .field select, .field input { max-width: 100%; width: 100%; }
}
