:root {
  color-scheme: light;
  --bg: #f3f1ec;
  --surface: #fcfcfb;
  --surface-2: #efede7;
  --border: #dedbd2;
  --text: #1b1a18;
  --text-2: #52514e;
  --muted: #7c7a73;
  --accent: #2f6fb8;
  --accent-ink: #fff;
  --good: #1f8a3b;
  --good-bg: #e5f4e8;
  --warn: #a86a00;
  --warn-bg: #fbf0d9;
  --bad: #c0392b;
  --bad-bg: #fbe5e2;
  --info-bg: #eaf1fa;
  --beam: #3b3a36;
  --load: #c0392b;
  --udl: #e07b39;
  --ink: #1f5fbf;
  --sol: #1f8a3b;
  --guide: #b9b5ab;
  --area: #f7f6f2;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --grid: #e6e3dc;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 4px 16px rgba(0, 0, 0, .05);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #161512;
    --surface: #211f1c;
    --surface-2: #2a2825;
    --border: #3a3733;
    --text: #ecebe6;
    --text-2: #c3c2b7;
    --muted: #8f8c84;
    --accent: #4a8ad6;
    --good: #4cc26a;
    --good-bg: #1d3323;
    --warn: #e0a53a;
    --warn-bg: #3a2f17;
    --bad: #ec6d5f;
    --bad-bg: #3d1f1b;
    --info-bg: #1e2a38;
    --beam: #d9d6cc;
    --load: #ec6d5f;
    --udl: #e8955a;
    --ink: #6aa7f0;
    --sol: #4cc26a;
    --guide: #57534c;
    --area: #1c1a18;
    --series-1: #3987e5;
    --series-2: #d95926;
    --grid: #33302c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}
:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }
html, body { margin: 0; }
/* always keep the scrollbar's room: switching between a short and a long page (tabs, Admin
   sub-tabs) must not shift the centred layout sideways */
html { scrollbar-gutter: stable; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--accent); }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); margin: 4px 0 10px; }

/* ---------- header ---------- */
.top {
  /* one line, one text size: brand, tabs and stats all share 14px and a common centre line */
  display: flex; align-items: center; gap: 22px; flex-wrap: nowrap; white-space: nowrap;
  padding: 8px 20px; background: var(--surface); border-bottom: 1px solid var(--border);
  font-size: 14px; line-height: 20px;
}
.top * { font-size: inherit; line-height: inherit; }
.brand { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.brand .logo { color: var(--ink); }
.brand small { font-weight: 400; color: var(--muted); }
.beta { display: inline-block; font-size: 10px; font-weight: 800; letter-spacing: .08em; line-height: 1; padding: 3px 6px 2px;
  border-radius: 5px; color: var(--accent); border: 1.5px solid var(--accent); vertical-align: middle; cursor: default; }
h1 .beta { font-size: 11px; margin-left: 4px; vertical-align: 3px; }
nav { display: flex; gap: 4px; }
.tab {
  border: 0; background: none; color: var(--text-2); font: inherit; font-weight: 600;
  padding: 6px 12px; border-radius: 8px; cursor: pointer;
}
@media (max-width: 900px) {
  .top { flex-wrap: wrap; row-gap: 6px; }
  .brand small { display: none; }
  .hdr-stats { margin-left: 0; flex-wrap: wrap; column-gap: 14px; row-gap: 2px; }
}
/* phones: the menu takes its own full-width row and wraps, so no page is wider than the screen
   (otherwise the browser zooms the whole site out to fit the menu) */
@media (max-width: 640px) {
  nav { flex: 1 1 100%; flex-wrap: wrap; gap: 2px; min-width: 0; }
  .tab { padding: 6px 9px; white-space: nowrap; }
  .subtabs { flex-wrap: wrap; }
}
.tab:hover { background: var(--surface-2); }
/* something waits for an administrator (new sign-ups, open puzzle reports): a red count on the
   tab's corner - placed over it, so the header doesn't move when it comes and goes */
.tab { position: relative; }
.notif-badge { position: absolute; top: -4px; right: -6px; min-width: 17px; height: 17px; padding: 0 5px;
  border-radius: 9px; background: #d93a2b; color: #fff; font: 700 11px/17px system-ui, sans-serif;
  text-align: center; box-shadow: 0 0 0 2px var(--bg); pointer-events: none; }
.notif-badge.inline { position: static; display: inline-block; vertical-align: 3px; margin-left: 6px; box-shadow: none; }
.notif-badge[hidden] { display: none; }
.tab.active { background: var(--surface-2); color: var(--text); }
.hdr-stats { margin-left: auto; display: flex; align-items: center; gap: 18px; color: var(--text-2); }
.hdr-stats b { color: var(--text); }

/* ---------- views ---------- */
.train, .stats, .leaders, .admin, .prefs, .home, .about { display: none; }
body.view-about .about { display: block; }
.about { padding: 22px 20px 30px; max-width: 760px; width: 100%; margin: 0 auto; flex: 1; }
.about-body { padding: 22px 26px; line-height: 1.6; font-size: 15px; }
.about-body h1 { font-size: 24px; margin: 0 0 4px; }
.about-body h2 { font-size: 16px; margin: 20px 0 6px; text-transform: none; letter-spacing: 0; color: var(--text); }
.about-body p, .about-body li { color: var(--text-2); }
.about-body ul { padding-left: 20px; }
.about-lead { font-size: 16.5px; color: var(--muted) !important; margin-top: 0; }
.about-body a { color: var(--accent); text-underline-offset: 3px; }
.about-body a[target=_blank]::after { content: ' ↗'; font-size: .8em; }
.about-links { margin-top: -4px; }
.about-ext li { margin: 6px 0; }
.about-disclaimer { font-size: 13.5px; border-left: 3px solid var(--warn); padding: 6px 12px; background: var(--warn-bg); border-radius: 0 8px 8px 0; color: var(--text-2) !important; }
body.view-home .home { display: block; }
.home { padding: 22px 20px 30px; max-width: 1100px; width: 100%; margin: 0 auto; flex: 1; }
.home-head h1 { font-size: 26px; margin: 0 0 4px; }
.home-head p { margin: 0 0 18px; max-width: 760px; }
.home-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.home-card { display: grid; grid-template-columns: 46px 1fr; grid-template-rows: 1fr auto; gap: 4px 14px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px; box-shadow: var(--shadow); cursor: pointer;
  transition: border-color .15s, transform .15s; }
.home-card:hover, .home-card:focus-visible { border-color: var(--accent); transform: translateY(-1px); outline: none; }
.home-card.primary { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); background: color-mix(in srgb, var(--accent) 5%, var(--surface)); }
.home-ico { grid-row: 1 / span 2; width: 46px; height: 46px; border-radius: 12px; background: var(--surface-2); display: grid; place-items: center;
  font-size: 22px; font-weight: 800; color: var(--accent); }
.home-body h3 { margin: 0 0 4px; font-size: 16px; text-transform: none; letter-spacing: 0; color: var(--text); }
.home-body p { margin: 0; font-size: 13.5px; color: var(--text-2); line-height: 1.45; }
.home-stat { margin-top: 8px; font-size: 13px; color: var(--muted); }
.home-stat b { font-size: 20px; color: var(--text); font-variant-numeric: tabular-nums; margin-right: 2px; }
.home-go { grid-column: 2; justify-self: start; margin-top: 10px; }
.brand { cursor: pointer; }
body.view-prefs .prefs { display: block; }
.prefs { padding: 18px 20px; max-width: 640px; width: 100%; margin: 0 auto; flex: 1; }
.prefs .card { margin-bottom: 12px; }
.prefs .card h3 { margin-top: 0; }
.prefs-form { display: flex; flex-direction: column; gap: 10px; }
.prefs-form .field { display: grid; grid-template-columns: 110px 1fr; align-items: center; gap: 10px; }
.prefs-form input, .prefs-form select { font: inherit; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.prefs .auth-err.ok { color: var(--good); }
.danger-zone { border-color: color-mix(in srgb, var(--bad) 40%, var(--border)); }
/* the name in the header: a menu (preferences, language, sign out) */
.dd { position: relative; }
.who-btn { font-weight: 700; display: inline-flex; align-items: center; gap: 6px; }
.who-btn .caret { font-size: 10px; color: var(--muted); }
.dd-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 60; min-width: 190px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow); padding: 6px; display: flex; flex-direction: column; }
.dd-menu[hidden] { display: none; }
.dd-item { border: 0; background: none; font: inherit; color: var(--text); text-align: left; padding: 7px 10px; border-radius: 6px; cursor: pointer; }
.dd-item:hover, .dd-item:focus-visible { background: var(--surface-2); outline: none; }
.dd-item.on::after { content: ' ✓'; color: var(--accent); font-weight: 700; }
.dd-label { font-size: 11.5px; color: var(--muted); padding: 6px 10px 2px; text-transform: uppercase; letter-spacing: .04em; }
.dd-sep { height: 1px; background: var(--border); margin: 5px 2px; }
.dialog.bug-dialog { max-width: 520px; }
.history-box { margin-top: 12px; }
.upd-msg { font-weight: 600; }
.upd-msg.bad { color: var(--bad); }
.upd-btns { justify-content: flex-start; flex-wrap: wrap; }
.upd-commits { margin: 4px 0 10px; padding-left: 20px; font-size: 13px; }
.upd-log pre { max-height: 260px; overflow: auto; background: var(--surface-2); padding: 8px 10px; border-radius: 8px; font-size: 12px; white-space: pre-wrap; }
.spin { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.8s linear infinite; vertical-align: -1px; margin-right: 4px; }
@keyframes spin { to { transform: rotate(360deg); } }
.history-box summary { cursor: pointer; }
.history-box[open] summary { margin-bottom: 8px; }
.dialog textarea { font: inherit; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.bug-shot { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-2); }
.bug-preview { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.bug-preview img { max-width: 160px; max-height: 100px; border: 1px solid var(--border); border-radius: 6px; }
.bug-preview[hidden] { display: none; }
body.view-admin .admin { display: block; }
.admin { padding: 18px 20px; max-width: 1200px; width: 100%; margin: 0 auto; flex: 1; }
body.view-train .train { display: grid; }
body.view-stats .stats { display: block; }
body.view-leaders .leaders { display: block; }
.leaders { padding: 18px 20px; max-width: 1200px; width: 100%; margin: 0 auto; flex: 1; }
.leaders .filter-row .opt { margin: 0; }
.tbl tr.me td { background: var(--info-bg); font-weight: 700; }
.tbl tr.gap td { text-align: center; color: var(--muted); padding: 2px; }
.medal { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; font-size: 12px; font-weight: 800; color: #fff; }
.medal.m1 { background: #c9a227; } .medal.m2 { background: #8f969c; } .medal.m3 { background: #b0703c; }

.train {
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 20px; padding: 18px 20px; flex: 1; align-items: start;
  max-width: 1200px; width: 100%; margin: 0 auto;
}
@media (max-width: 900px) { .train { grid-template-columns: 1fr; padding: 12px 16px; } }

.board-col { display: flex; flex-direction: column; align-items: center; min-width: 0; }
.board-tools {
  display: flex; align-items: center; gap: 8px; margin-top: 12px; width: 100%; max-width: 720px; flex-wrap: wrap;
}
/* ---------- side panel ---------- */
.side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); }
.pz-title { font-size: 18px; display: flex; align-items: center; gap: 8px; }
.pz-sub { color: var(--muted); font-size: 13px; margin: 2px 0 12px; }
.feedback { border-radius: 10px; padding: 11px 13px; font-size: 14px; border-left: 4px solid transparent; min-height: 64px; }
.feedback .fb-title { font-weight: 650; }
.feedback .fb-body { margin-top: 4px; color: var(--text-2); }
.feedback.info { background: var(--info-bg); border-color: var(--accent); }
.feedback.good { background: var(--good-bg); border-color: var(--good); }
.feedback.good .fb-title { color: var(--good); }
.feedback.warn { background: var(--warn-bg); border-color: var(--warn); }
.feedback.bad { background: var(--bad-bg); border-color: var(--bad); }
.feedback.bad .fb-title { color: var(--bad); }
.feedback .sol { font: 600 14px ui-monospace, Consolas, monospace; margin: 4px 0; color: var(--text); }
.result-meta { margin-top: 8px; font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.chip { font-size: 11.5px; padding: 1px 8px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); color: var(--text-2); }

.row-btns { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.btn.block { display: flex; width: 100%; justify-content: center; margin-top: 8px; padding: 10px 14px; font-size: 15px; }
.adaptive-status { font-size: 12.5px; color: var(--accent); margin-top: 8px; }
.adaptive-status:empty { display: none; }

.btn {
  font: inherit; font-size: 14px; font-weight: 550; cursor: pointer;
  padding: 7px 13px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text);
  display: inline-flex; align-items: center; gap: 4px;
}
.btn:hover:not(:disabled) { filter: brightness(.96); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.big { padding: 9px 20px; font-size: 15px; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.danger { color: var(--bad); }
[hidden] { display: none !important; }

.field { display: grid; grid-template-columns: 82px 1fr; align-items: center; gap: 8px; margin: 8px 0; font-size: 14px; }
.field > span { color: var(--text-2); }
select {
  font: inherit; font-size: 14px; padding: 6px 8px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); width: 100%; min-width: 0;
}
.opt { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; margin: 7px 0; cursor: pointer; }
.opt input { margin-top: 3px; }
.opt small { color: var(--muted); }
#filters h3 + .opt { margin-top: 0; }
#filters h3:not(:first-child) { margin-top: 16px; }
.pills { display: flex; gap: 5px; }
.pills.dim { opacity: .4; pointer-events: none; }
.pill input { display: none; }
.pill span {
  display: inline-grid; place-items: center; width: 34px; height: 30px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface-2); font-weight: 600;
}
.pill input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }

.help summary { cursor: pointer; font-weight: 600; }
.help ol { padding-left: 20px; margin: 10px 0; font-size: 14px; }
.help li { margin: 4px 0; }
.k { font-weight: 700; }
.k.ink { color: var(--ink); }
.k.sol { color: var(--sol); }

/* ---------- stats ---------- */
.stats { padding: 18px 20px; max-width: 1200px; width: 100%; margin: 0 auto; flex: 1; }
.stats .card { margin-bottom: 14px; }
.filter-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filter-row select { width: auto; }
.filter-row .spacer { flex: 1; }
/* Admin > Puzzles: the figures stretch to the table's width, one line each */
#pz-kpis, #lb-kpis { display: flex; flex-wrap: wrap; gap: 10px; }
#pz-kpis .tile, #lb-kpis .tile { flex: 1 1 200px; min-width: 0; }
/* one line each: a longer note (e.g. "by avg match") must not make a tile taller and push the table down */
#pz-kpis .tile-label, #pz-kpis .tile-value, #pz-kpis .tile-sub,
#lb-kpis .tile-label, #lb-kpis .tile-value, #lb-kpis .tile-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Admin > Puzzles: the puzzle number opens a preview */
.pz-link { border: 0; background: none; padding: 0; font: inherit; font-weight: 700; color: var(--accent); cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }
.pz-link:hover { text-decoration-style: solid; }
.dialog.pz-view-dialog { max-width: 900px; }
.pz-view-dialog .dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pz-view-dialog .dlg-head h3 { margin: 0; }
.pz-view-dialog .board-box { margin: 6px 0; }
.pz-view-dialog .dlg-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#pzv-board .area-grip { display: none; } /* the preview never resizes the drawing space */
/* thumbs up / down under a result */
.vote-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border); }
.vote-btn { font-size: 17px; line-height: 1; padding: 5px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2); cursor: pointer; filter: grayscale(1); opacity: .75; }
.vote-btn:hover { filter: none; opacity: 1; }
.vote-btn.on { filter: none; opacity: 1; border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, var(--surface-2)); }
.vote-off { filter: grayscale(1); opacity: .5; }
/* Statistics > Recent puzzles: page size and page buttons */
.pager { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 10px; }
.pager:empty { display: none; }
.pager .spacer { flex: 1; }
.pager .seg button { padding: 4px 10px; font-size: 13px; }
.pager .btn:disabled { opacity: .45; cursor: default; }
.empty { text-align: center; padding: 40px; color: var(--muted); }

.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-bottom: 14px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.tile-label { font-size: 12.5px; color: var(--text-2); font-weight: 600; }
.tile-value { font-size: 26px; font-weight: 700; margin: 2px 0; font-variant-numeric: tabular-nums; }
.tile-sub { font-size: 12px; color: var(--muted); }
.tile.warn .tile-value { color: var(--warn); }

.grid2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 14px; }
.grid2 > .card { margin-bottom: 14px; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }

.legend { display: flex; gap: 16px; font-size: 13px; color: var(--text-2); margin-bottom: 4px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; }
.sw.s1 { background: var(--series-1); }
.sw.s2 { background: var(--series-2); }
.chart-wrap { position: relative; }
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.s1 { stroke: var(--series-1); }
.chart .line.s2 { stroke: var(--series-2); }
.chart .end-label { fill: var(--text-2); font-size: 12px; font-weight: 600; }
.chart .xhair { stroke: var(--muted); stroke-dasharray: 3 3; }
.chart .hdot { stroke: var(--surface); stroke-width: 2; }
.chart .hdot.s1 { fill: var(--series-1); }
.chart .hdot.s2 { fill: var(--series-2); }
.chart .hit { fill: transparent; cursor: crosshair; }
.tip {
  position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 10px; font-size: 12.5px; box-shadow: var(--shadow); width: 220px; color: var(--text);
}

.err-row { display: grid; grid-template-columns: 1fr 110px 32px; gap: 10px; align-items: center; margin: 10px 0; font-size: 14px; }
.err-name small { display: block; color: var(--muted); font-size: 12px; }
.bar { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--series-1); border-radius: 4px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.scroll { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.tbl th { text-align: left; font-size: 12px; color: var(--text-2); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl td { padding: 6px 8px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
.cellbar { position: relative; width: 120px; height: 20px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.cellbar span { position: absolute; inset: 0 auto 0 0; background: color-mix(in srgb, var(--series-1) 40%, transparent); }
.cellbar em { position: relative; font-style: normal; font-size: 12.5px; padding-left: 6px; line-height: 20px; }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 10px; font-weight: 600; }
.tag.good { background: var(--good-bg); color: var(--good); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.bad { background: var(--bad-bg); color: var(--bad); }

.foot { text-align: center; padding: 14px; }

/* ---------- rating ---------- */
:root { --gain: #2a78d6; --loss: #e34948; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --gain: #3987e5; --loss: #e66767; } }
.pos { color: var(--gain); }
.neg { color: var(--loss); }
.hdr-rating { position: relative; }
.hdr-rating .flash {
  font-style: normal; font-weight: 700; margin-left: 6px; padding: 0 6px; border-radius: 8px;
  animation: flash 3.5s ease-out forwards;
}
.hdr-rating .flash.up { color: #fff; background: var(--gain); }
.hdr-rating .flash.down { color: #fff; background: var(--loss); }
@keyframes flash { 0% { transform: scale(1.35); } 12% { transform: scale(1); } 75% { opacity: 1; } 100% { opacity: 0; } }

.rating-change {
  display: flex; align-items: center; gap: 12px; margin-top: 10px; padding: 8px 10px;
  border-radius: 8px; background: var(--surface); border: 1px solid var(--border); font-size: 13.5px; color: var(--text-2);
}
.rating-change .delta { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; min-width: 54px; }
.rating-change.up .delta { color: var(--gain); }
.rating-change.down .delta { color: var(--loss); }
.rating-change.none .delta { color: var(--muted); }
.rating-change b { color: var(--text); }

h2.section { font-size: 15px; margin: 22px 0 10px; color: var(--text); }
h2.section:first-child { margin-top: 0; }
.tile.hero .tile-value { font-size: 34px; color: var(--series-1); }
.tile.pos .tile-value { color: var(--gain); }
.tile.neg .tile-value { color: var(--loss); }

.chart .rd-band { fill: var(--series-1); opacity: .1; }
.sw.band { background: var(--series-1); opacity: .2; height: 10px; }
.chart .line.thin { stroke-width: 1.5; opacity: .85; }
.chart .grid.zero { stroke: var(--muted); }
.chart .bar-up { fill: var(--gain); }
.chart .bar-down { fill: var(--loss); }
.chart .hitbar { fill: transparent; }
.btn:disabled.primary { opacity: .45; }
.feedback .sol-inline { font: 600 13px ui-monospace, Consolas, monospace; color: var(--text); }

/* rating history strip + daily chart hover */
.sub-h { margin-top: 18px; }
.history { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 760px) { .history { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.hist {
  font: inherit; text-align: left; cursor: pointer; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px;
  display: flex; flex-direction: column; gap: 1px; min-width: 0;
}
.hist:hover { border-color: var(--muted); }
.hist.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--surface); }
.hist-label { font-size: 12px; font-weight: 700; color: var(--text-2); }
.hist-delta { font-size: 20px; font-weight: 750; font-variant-numeric: tabular-nums; }
.hist-sub { font-size: 11.5px; color: var(--muted); line-height: 1.35; }
.chart.daily { user-select: none; }
.chart.daily .hitbar { fill: transparent; }
.chart.daily.hovering .dbar:not(.on) .drect { opacity: .35; }
.chart.daily .dbar.on .drect { stroke: var(--text); stroke-width: 1.5; }
.casual-badge { font-weight: 700; padding: 0 8px; border-radius: 10px; background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn); }

/* sortable tables */
.tbl.sortable th[data-col] { cursor: pointer; user-select: none; }
.tbl.sortable th[data-col]:hover { color: var(--text); }
.tbl .sort-ind { display: inline-block; width: 10px; margin-left: 3px; font-style: normal; color: var(--accent); }
.tbl th.asc .sort-ind::after { content: '▲'; font-size: 9px; }
.tbl th.desc .sort-ind::after { content: '▼'; font-size: 9px; }
.review-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); flex-wrap: wrap; }

.chart .tick { stroke: var(--muted); }
.chart .pt { fill: var(--series-1); stroke: var(--surface); stroke-width: 1.2; }

/* =====================================================================
   Structural puzzles: board, drawing tools, result, sign-in
   ===================================================================== */
.board-box { width: 100%; max-width: 820px; user-select: none; }
.board { width: 100%; height: auto; display: block; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); touch-action: none; }
.board .beam { stroke: var(--beam); stroke-width: 7; stroke-linecap: butt; }
.board .support { fill: var(--surface-2); stroke: var(--beam); stroke-width: 2; }
.board .ground { stroke: var(--beam); stroke-width: 2; }
.board .hatch { stroke: var(--beam); stroke-width: 1.2; }
.board .sup-label { fill: var(--text-2); font: 600 14px system-ui, sans-serif; text-anchor: middle; }
.board .load { stroke: var(--load); stroke-width: 3; fill: none; }
.board .load-head { fill: var(--load); }
.board .load-label { fill: var(--load); font: 700 15px system-ui, sans-serif; text-anchor: middle; }
/* trusses: members marked T (tension, blue) / C (compression, red) / 0 (zero force, grey dashed) */
body:not(.truss-mode) .truss-tools { display: none; }
body.truss-mode .draw-tools { display: none !important; }
.tt.on { background: var(--accent); color: var(--accent-ink); }
.board .hanger { stroke: var(--load); stroke-width: 2; stroke-dasharray: 3 3; }
.board .truss-m { stroke: var(--text-2); stroke-width: 5; stroke-linecap: round; opacity: .55; }
.board .truss-m.hover { opacity: 1; stroke: var(--accent); }
.board .truss-m.st-T { stroke: #2f6fd6; opacity: 1; }
.board .truss-m.st-C { stroke: #d24b3e; opacity: 1; }
.board .truss-m.st-Z { stroke: var(--muted); opacity: 1; stroke-dasharray: 8 7; }
.board .truss-wrong { stroke: #f0a020; stroke-width: 15; stroke-linecap: round; opacity: .5; }
.board .truss-node { fill: var(--surface); stroke: var(--text); stroke-width: 2.5; }
.board .truss-name { font: 700 15px system-ui, sans-serif; fill: var(--text); text-anchor: middle; }
.board .truss-tag { fill: var(--surface); stroke: var(--border); stroke-width: 1.5; }
.board .truss-tag.st-T { stroke: #2f6fd6; } .board .truss-tag.st-C { stroke: #d24b3e; } .board .truss-tag.st-Z { stroke: var(--muted); }
.board .truss-tag.wrong { stroke-width: 3; }
.board .truss-tag-text { font: 700 12.5px system-ui, sans-serif; fill: var(--text); text-anchor: middle; }
.board .truss-hint { fill: none; stroke: var(--accent); stroke-width: 3; stroke-dasharray: 4 3; }
.truss-why { margin: 8px 0 0; padding-left: 18px; }
.truss-why li { margin: 4px 0; }
.truss-why .st-T { color: #2f6fd6; } .truss-why .st-C { color: #d24b3e; } .truss-why .st-Z { color: var(--muted); }
/* an internal hinge: an open circle on the beam */
.board .hinge { fill: var(--surface); stroke: var(--text); stroke-width: 3; }
/* point moments: a curved arrow round the point */
.board .moment-arc { stroke: var(--load); stroke-width: 3; fill: none; }
.board .moment-head, .board .moment-dot { fill: var(--load); }
.board .udl-box { fill: color-mix(in srgb, var(--udl) 14%, transparent); stroke: none; }
.board .udl-line { stroke: var(--udl); stroke-width: 2.5; fill: none; }
.board .udl-arrow { stroke: var(--udl); stroke-width: 1.6; }
.board .udl-head { fill: var(--udl); }
.board .udl-label { fill: var(--udl); font: 700 15px system-ui, sans-serif; text-anchor: middle; }
.board .dim { stroke: var(--muted); stroke-width: 1; }
.board .dim-text { fill: var(--text-2); font: 13px system-ui, sans-serif; text-anchor: middle; }
.board .dim-total { fill: var(--text); font: 600 13px system-ui, sans-serif; text-anchor: middle; }
.board .area { fill: var(--area); stroke: var(--border); stroke-width: 1; }
.board .axis-line { stroke: var(--beam); stroke-width: 2; }
.board .ruler { stroke: var(--muted); stroke-width: 1.2; }
.board .ruler-grid { stroke: var(--guide); stroke-width: 1; stroke-dasharray: 1 5; opacity: .7; }
.board .ruler-val { fill: var(--muted); font-size: 11px; text-anchor: end; font-variant-numeric: tabular-nums; }
.board .ruler-unit { fill: var(--muted); font-size: 11px; font-weight: 600; }
.board .axis-label { fill: var(--muted); font: italic 600 18px Georgia, 'Times New Roman', serif; }
.board .area-hint { fill: var(--muted); font: 13px system-ui, sans-serif; text-anchor: middle; }
.board .guide { stroke: var(--guide); stroke-width: 1; stroke-dasharray: 4 5; }
.board .ink { stroke: var(--ink); stroke-width: 3.2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.board .ink.preview { opacity: .55; stroke-dasharray: 6 5; }
.board .vertex { fill: var(--ink); }
/* free points (Points tool): a ringed dot; lines and curves through one share it */
.board .free-pt { fill: var(--surface); stroke: var(--ink); stroke-width: 2.2; }
.board .free-pt.hover { stroke: var(--accent); }
.board .free-pt.selected { stroke: var(--bad); fill: color-mix(in srgb, var(--bad) 25%, var(--surface)); stroke-width: 2.8; }
.board .snap { fill: none; stroke: var(--ink); stroke-width: 1.5; }
.board .sol-fill { fill: color-mix(in srgb, var(--sol) 16%, transparent); stroke: none; }
.board .sol-line { stroke: var(--sol); stroke-width: 3; fill: none; stroke-linejoin: round; }
.board .sol-val { fill: var(--sol); font: 700 13px system-ui, sans-serif; text-anchor: middle; paint-order: stroke; stroke: var(--surface); stroke-width: 4px; }
.board .key-mark { stroke-width: 2; }
.board .key-mark.ref { stroke: var(--sol); }
.board .key-mark.user { stroke: var(--ink); stroke-dasharray: 3 3; }
.board.drawing { cursor: crosshair; }
.board.done .ink { opacity: .7; }

.question { width: 100%; max-width: 820px; margin-top: 12px; }
.q-title { font-size: 19px; font-weight: 700; }
.q-text { color: var(--text-2); margin-top: 2px; }
.q-notes { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.board-tools { max-width: 820px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; background: var(--surface-2); }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.on { background: var(--accent); color: var(--accent-ink); }
.tools-spacer { flex: 1; }

.match { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.match .pct { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; }
.match .bar { flex: 1; height: 10px; }
.match .bar span { background: var(--good); }
.match.mid .bar span { background: var(--warn); }
.match.low .bar span { background: var(--bad); }
.parts { display: grid; grid-template-columns: auto 1fr auto; gap: 3px 10px; font-size: 13px; margin-top: 8px; align-items: center; }
.parts .bar { height: 6px; }
.keyvals { font-size: 13px; margin-top: 8px; color: var(--text-2); }
.keyvals b { color: var(--text); font-variant-numeric: tabular-nums; }

.pills.wide .pill span { width: auto; padding: 0 10px; font-weight: 600; font-size: 13px; }
.pills { flex-wrap: wrap; }

/* user menu */
.user-menu { display: flex; align-items: center; gap: 8px; }
.user-menu .who { font-weight: 700; color: var(--text); }

/* sign-in screen */
.auth { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 50; padding: 16px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h1 { font-size: 22px; margin: 0 0 4px; }
.auth-card form { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.auth-card input[type=text], .auth-card input[type=password], .auth-card input[type=email], .auth-card select, .dialog input {
  font: inherit; padding: 9px 11px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.auth-tabs { display: flex; gap: 4px; margin-top: 14px; }
.auth-names { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.auth-names input { min-width: 0; }
.auth-card select:invalid, .auth-card select option[value=""] { color: var(--muted); }
.auth-card [hidden] { display: none !important; }
.auth-err { color: var(--bad); font-size: 13.5px; min-height: 18px; }
.auth-note { font-size: 13.5px; color: var(--text-2); background: var(--surface-2); border-radius: 8px; padding: 8px 10px; }
.auth-note.ok { color: var(--good); }
body.signed-out > header, body.signed-out > main, body.signed-out > footer { visibility: hidden; }
.dialog { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); padding: 18px; max-width: 360px; width: calc(100% - 32px); }
.dialog::backdrop { background: rgba(0, 0, 0, .35); }
.dialog form { display: flex; flex-direction: column; gap: 10px; }
.dialog .row-btns { justify-content: flex-end; }

@media (max-width: 1280px) { .brand small { display: none; } .top { gap: 14px; } }
/* the tagline needs room: without it up to 1700 px; whatever is left wraps instead of running off the edge */
@media (max-width: 1700px) { .brand small { display: none; } }
.top { flex-wrap: wrap; row-gap: 6px; }
@media (max-width: 1080px) { .top { flex-wrap: wrap; row-gap: 6px; } .hdr-stats { flex-wrap: wrap; column-gap: 14px; } }
@media (max-width: 900px) {
  .top { gap: 10px; padding: 8px 16px; }
  .user-menu { margin-left: auto; }
  .train, .stats { padding: 12px 16px; }
  .field { grid-template-columns: 76px 1fr; }
}
.chip.tip-chip { border-color: var(--accent); color: var(--accent); }

.tab.donate { color: #c0392b; text-decoration: none; display: inline-flex; align-items: center; }
.tab.donate:hover { background: color-mix(in srgb, #c0392b 10%, var(--surface-2)); }

.dialog select, .dialog textarea { font: inherit; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); width: 100%; }
.dialog textarea { resize: vertical; }
.report-note { margin-top: 8px; color: var(--good); }

.board .ink.hover { stroke: var(--accent); stroke-width: 5; }
.board .ink.selected { stroke: var(--bad); stroke-width: 5; stroke-dasharray: 9 5; }
.board .par-ref { stroke: var(--ink); stroke-width: 7; opacity: .22; stroke-linecap: round; }

.board .area-grip { cursor: ns-resize; }
.board .area-grip line { stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.board .area-grip:hover line { stroke: var(--accent); }

.board .hint-line { stroke: #d98a14; stroke-width: 1.6; stroke-dasharray: 7 5; }
.board .hint-label { fill: #b86e00; font: 700 12.5px system-ui, sans-serif; paint-order: stroke; stroke: var(--area); stroke-width: 4px; }
.hint-badge { color: #b86e00; font-weight: 600; }

/* ---------- free mode (no account) ---------- */
body:not(.guest) .guest-only { display: none !important; }
body.guest .signed-only { display: none !important; }
.auth-or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; margin: 4px 0 10px; }
.auth-or::before, .auth-or::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.guest-note { border-color: var(--warn); background: var(--warn-bg); }

/* ---------- puzzle settings (cog wheel) ---------- */
.pz-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.pz-head .pz-title { flex-wrap: wrap; }
.btn.cog { font-size: 18px; line-height: 1; padding: 5px 8px; flex: none; }
.pz-head-btns { display: flex; gap: 6px; flex: none; }
.pz-head-btns .btn.cog { width: 32px; height: 32px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.btn.help-btn { font-weight: 700; }

/* Help: how the diagram on screen works, with drawn examples */
.dialog.help-dialog { max-width: 1000px; max-height: calc(100vh - 40px); overflow: auto; }
.help-dialog .dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.help-dialog .dlg-head h3 { margin: 0; }
.help-pick { margin: 10px 0 0; flex-wrap: wrap; }
.help-body h4 { margin: 14px 0 4px; font-size: 17px; }
.help-body > p { margin: 0 0 10px; color: var(--text-2); font-size: 14.5px; }
.help-figs { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 12px; }
.help-ex { margin: 0; background: var(--area); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px 10px; }
.help-ex figcaption { font-size: 13px; color: var(--text-2); line-height: 1.4; }
.help-fig { width: 100%; height: auto; display: block; }
.help-tips { margin: 12px 0 6px; padding-left: 20px; font-size: 14px; }
.help-tips li { margin: 4px 0; }
.help-dialog .help { margin-top: 10px; border-top: 1px solid var(--border); padding-top: 8px; }
.help-fig text { font-family: system-ui, sans-serif; text-anchor: middle; }
.help-fig .h-beam { stroke: var(--beam); stroke-width: 4; stroke-linecap: round; }
.help-fig .h-sup { fill: none; stroke: var(--beam); stroke-width: 1.4; }
.help-fig .h-ground { stroke: var(--beam); stroke-width: 1.4; }
.help-fig .h-hatch { stroke: var(--muted); stroke-width: 1; }
.help-fig .h-load { stroke: var(--load); stroke-width: 2; }
.help-fig .h-load-head { fill: var(--load); }
.help-fig .h-udl { stroke: var(--udl); stroke-width: 1.2; }
.help-fig .h-udl-head { fill: var(--udl); }
.help-fig .h-udl-box { fill: color-mix(in srgb, var(--udl) 12%, transparent); }
.help-fig .h-lbl { font-size: 10.5px; font-weight: 700; }
.help-fig .h-lbl.load { fill: var(--load); }
.help-fig .h-lbl.udl { fill: var(--udl); }
.help-fig .h-axis { stroke: var(--muted); stroke-width: 1.2; }
.help-fig .h-sym { fill: var(--muted); font: italic 600 13px Georgia, serif; }
.help-fig .h-guide { stroke: var(--guide); stroke-width: 1; stroke-dasharray: 3 4; }
.help-fig .h-fill { fill: color-mix(in srgb, var(--sol) 14%, transparent); }
.help-fig .h-diag { fill: none; stroke: var(--sol); stroke-width: 2.4; stroke-linejoin: round; }
.help-fig .h-val { fill: var(--text); font-size: 10.5px; font-weight: 700; }
.help-fig .h-note { fill: var(--muted); font-size: 10px; font-style: italic; text-anchor: start; }
.help-fig .h-m { stroke: var(--text-2); stroke-width: 3; stroke-linecap: round; }
.help-fig .h-m.st-T { stroke: #2f6fd6; }
.help-fig .h-m.st-C { stroke: #d24b3e; }
.help-fig .h-m.st-Z { stroke: var(--muted); stroke-dasharray: 5 4; stroke-width: 2.2; }
.help-fig .h-tag { stroke: none; }
.help-fig .h-tag.st-T { fill: #2f6fd6; }
.help-fig .h-tag.st-C { fill: #d24b3e; }
.help-fig .h-tag.st-Z { fill: var(--muted); }
.help-fig .h-tag-t { fill: #fff; font-size: 8.5px; font-weight: 700; }
.help-fig .h-val.st-T { fill: #2f6fd6; }
.help-fig .h-val.st-C { fill: #d24b3e; }
.help-fig .h-joint { fill: var(--surface); stroke: var(--beam); stroke-width: 1.4; }
.help-fig .h-force { stroke: var(--text); stroke-width: 1.6; }
.help-fig .h-force-head { fill: var(--text); }
.settings-summary { margin-top: 8px; cursor: pointer; line-height: 1.35; }
.settings-summary:hover { color: var(--accent); }
.settings-dialog { max-width: 560px; }
.settings-dialog .dlg-head { display: flex; align-items: center; justify-content: space-between; }
.settings-dialog h3 { margin: 0; }
.settings-dialog h4 { margin: 14px 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.settings-dialog h4:first-child { margin-top: 4px; }
.settings-dialog .field { grid-template-columns: 90px 1fr; }
.settings-dialog .dlg-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; border-top: 1px solid var(--border); padding-top: 10px; }
.settings-dialog select { width: auto; max-width: 100%; }

/* ---------- puzzle history: session strip + tiles, coloured by result (like Lichess) ---------- */
:root { --h-win: #23913f; --h-pass: #6aa83a; --h-part: #d99a1e; --h-miss: #cf4436; --h-shown: #8c3a30; --h-current: #2f6fb8; }
.session { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.board-col .session { width: 100%; max-width: 820px; border-top: 0; padding-top: 0; } /* under the drawing space */
.session-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.session-strip { display: flex; flex-wrap: wrap; gap: 4px; }
.hchip { min-width: 34px; height: 24px; padding: 0 6px; border: 0; border-radius: 5px; color: #fff; font: 700 12px/24px system-ui, sans-serif;
  text-align: center; cursor: pointer; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .18); }
button.hchip:hover { filter: brightness(1.1); transform: translateY(-1px); }
.h-win { background: var(--h-win); }
.h-pass { background: var(--h-pass); }
.h-part { background: var(--h-part); }
.h-miss { background: var(--h-miss); }
.h-shown { background: var(--h-shown); }
.hchip.h-current { background: var(--h-current); cursor: default; animation: hpulse 1.6s ease-in-out infinite; }
@keyframes hpulse { 50% { opacity: .55; } }
.hlegend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--text-2); margin-bottom: 8px; }
.hlegend small { color: var(--muted); }
.hdot { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.tile-day { font-size: 12.5px; font-weight: 600; color: var(--muted); margin: 10px 0 5px; }
.tile-row { display: flex; flex-wrap: wrap; gap: 6px; }
.htile { width: 78px; padding: 5px 4px 4px; border: 0; border-radius: 7px; color: #fff; cursor: pointer; display: flex; flex-direction: column;
  align-items: center; gap: 1px; font: 12px/1.2 system-ui, sans-serif; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .18); }
.htile:hover { filter: brightness(1.1); transform: translateY(-1px); }
.htile b { font-size: 12.5px; }
.htile span { opacity: .9; font-size: 11px; }
.htile em { font-style: normal; font-weight: 700; font-size: 13px; }

.board .ink.seg { fill: none; stroke-linecap: round; }

/* quick options on the puzzle card: Rated, Jump to next puzzle */
.level-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-size: 14px; }
.level-row span { color: var(--muted); }
.level-row select { flex: 1; min-width: 0; }
.quick-opts { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 10px; font-size: 14px; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch i { width: 34px; height: 19px; border-radius: 10px; background: var(--border); position: relative; transition: background .15s; flex: none; }
.switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 15px; height: 15px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: left .15s; }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { left: 17px; }
.switch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }
.jump-note { margin-top: 6px; }

/* ---------- admin ---------- */
.tbl.adm td.adm-actions { display: flex; gap: 4px; flex-wrap: wrap; white-space: normal; }
.tbl.adm td.wrap { white-space: normal; max-width: 320px; }
.tbl.adm td.adm-act-cell { padding-top: 3px; padding-bottom: 3px; }
/* Admin › Player stats: one hue (each chart shows one measure), values on hover */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); gap: 12px; margin-bottom: 12px; }
.stat-grid.three { grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); }
.stat-card { position: relative; margin-bottom: 12px; }
.stat-grid .stat-card { margin-bottom: 0; }
.stat-card h3 { margin-top: 0; }
.stat-card .tip { z-index: 5; width: auto; max-width: 300px; white-space: nowrap; }
.chart .bar-s1 { fill: var(--series-1); }
.chart .area-s1 { fill: color-mix(in srgb, var(--series-1) 12%, transparent); }
.chart .day-hit rect { fill: transparent; }
.chart .day-guide, .chart .day-dot { visibility: hidden; }
.chart .day-hit.hover .day-guide { visibility: visible; stroke: var(--muted); stroke-dasharray: 3 3; }
.chart .day-hit.hover .day-dot { visibility: visible; fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }
.stat-controls { gap: 10px; margin: 4px 0 12px; }
.dialog.player-dialog { max-width: 760px; max-height: calc(100vh - 40px); overflow: auto; }
.player-dialog .dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.player-dialog .dlg-head h3 { margin: 0; }
.player-dialog .kpis { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }

.chart .bar-hit { fill: transparent; }
.chart .bar-hit.hover { fill: color-mix(in srgb, var(--series-1) 10%, transparent); }
.rank-bars { display: flex; flex-direction: column; gap: 6px; }
.rank-row { display: grid; grid-template-columns: minmax(90px, 40%) 1fr 34px; align-items: center; gap: 8px; font-size: 13px; padding: 1px 4px; border-radius: 6px; }
.rank-row.hover { background: var(--surface-2); }
.rank-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.rank-track { height: 10px; }
.rank-bar { display: block; height: 10px; border-radius: 0 4px 4px 0; background: var(--series-1); }
.rank-bar.muted { background: var(--guide); }
.rank-val { text-align: right; font-variant-numeric: tabular-nums; color: var(--text); }
.hm-tbl td, .hm-tbl th { text-align: center; padding: 4px 6px; }
.hm-tbl td:first-child, .hm-tbl th:first-child { text-align: left; }
.hm-tbl td.hm { min-width: 30px; font-variant-numeric: tabular-nums; background: color-mix(in srgb, var(--series-1) var(--hm, 0%), transparent);
  border: 2px solid var(--surface); border-radius: 6px; }
.hm-tbl td.hm.zero { color: var(--muted); }
.hm-tbl td.hm.hover { outline: 2px solid var(--text-2); outline-offset: -2px; }
.hm-tbl tfoot td { color: var(--text-2); border-top: 1px solid var(--border); }
.adm-act { font: inherit; font-size: 13px; padding: 3px 6px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; }
.tbl.adm tr.off td { color: var(--muted); }
.role-badge { font-size: 11.5px; font-weight: 700; padding: 1px 8px; border-radius: 10px; background: var(--info-bg); color: var(--accent); }
.you { font-size: 11px; color: var(--muted); }
.tag { font-size: 11.5px; font-weight: 600; padding: 1px 8px; border-radius: 10px; border: 1px solid; }
.tag.good { color: var(--good); background: var(--good-bg); }
.tag.warn { color: var(--warn); background: var(--warn-bg); }
.tag.bad { color: var(--bad); background: var(--bad-bg); }
.admin .card .opt { margin: 4px 0 10px; }
.adm-donate { grid-template-columns: 100px 1fr; max-width: 620px; }
.adm-donate input { font: inherit; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); width: calc(100% - 70px); }
.dlg .dlg-field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-2); }
.dlg .dlg-text { font-size: 14px; color: var(--text-2); }
.dlg h3 { margin: 0; }

/* Hint / Show solution / Try again / Report span the card, like Start training below them */
.puzzle-card .row-btns .btn { flex: 1 1 auto; justify-content: center; text-align: center; white-space: nowrap; }
.board .vertex.hot { fill: none; stroke: var(--accent); stroke-width: 2.5; }

/* ---------- puzzle streak ---------- */
body.mode-streak .training-only { display: none !important; }
body:not(.mode-streak) .streak-only { display: none !important; }
.streak-head { display: flex; align-items: center; gap: 12px; }
.streak-flame { font-size: 30px; line-height: 1; }
.streak-now { font-size: 40px; font-weight: 800; line-height: 1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.streak-head .small { margin-top: 2px; }
.streak-card .session-strip { margin: 12px 0 14px; }
/* three figures in one row, split by thin rules: no boxes */
.streak-stats { display: grid; grid-template-columns: repeat(3, 1fr); padding: 10px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.streak-stat { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; }
.streak-stat + .streak-stat { border-left: 1px solid var(--border); }
.streak-stat span { font-size: 11.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.streak-stat b { font-size: 22px; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }
.streak-recent-head { margin: 12px 0 6px; font-size: 11.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.streak-runs { display: flex; flex-wrap: wrap; gap: 6px; }
.run-pill { display: inline-flex; align-items: baseline; gap: 5px; padding: 3px 9px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); font-size: 13px; }
.run-pill b { font-variant-numeric: tabular-nums; }
.run-pill small { color: var(--muted); font-size: 11.5px; }
.run-pill.best { border-color: var(--accent); }
.streak-about { margin: 14px 0 0; font-size: 12.5px; line-height: 1.45; color: var(--muted); }
.streak-line { margin-top: 10px; padding: 8px 10px; border-radius: 8px; font-size: 14px; }
.streak-line.up { background: var(--good-bg); color: var(--good); }
.streak-line.down { background: var(--bad-bg); color: var(--bad); }

/* breakdown tables (Statistics): one fixed column grid for all of them */
.tbl.breakdown { table-layout: fixed; min-width: 900px; }
.tbl.breakdown td:first-child { white-space: normal; overflow-wrap: anywhere; }
.tbl.breakdown th { white-space: normal; vertical-align: bottom; }
.tbl.breakdown .cellbar { width: min(120px, 100%); }

.lb-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.lb-rank { font-size: 13px; color: var(--text-2); }
.lb-medals { letter-spacing: -3px; margin-right: 6px; font-size: 1.05em; }
.tbl.lb-tbl { table-layout: fixed; }
.tbl.lb-tbl th.num, .tbl.lb-tbl td.num { text-align: right; }
.tbl.lb-tbl td, .tbl.lb-tbl th { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-rank select { width: auto; margin-left: 4px; }
.leaders .card + .card { margin-top: 14px; }
.series-badge { color: var(--accent); font-weight: 600; }

/* admin: sub-tabs and the puzzle table */
.subtabs { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.pz-search { font: inherit; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); min-width: 190px; }
.pz-bulk { margin-top: -4px; }
.tbl.pz-tbl { table-layout: fixed; min-width: 1458px; } /* columns from the <colgroup>, whatever the rows */
.tbl.pz-tbl th, .tbl.pz-tbl td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbl.pz-tbl th[data-key] { cursor: pointer; user-select: none; }
.tbl.pz-tbl th[data-key]:hover { color: var(--text); }
.tbl.pz-tbl td.adm-actions { display: table-cell; white-space: nowrap; } /* stays a cell, so it keeps its column width */
.tbl.pz-tbl td.adm-actions .btn + .btn { margin-left: 4px; }
