/* Szlem — single-dummy solver */

:root {
  --bg: #f2f1ec;
  --panel: #ffffff;
  --panel-2: #faf9f6;
  --ink: #1c1b19;
  --ink-2: #5d5a54;
  --ink-3: #8d8980;
  --line: #dcd9d1;
  --line-2: #eae7e0;
  --accent: #1f6f4a;
  --accent-ink: #ffffff;
  --accent-soft: #e4efe8;
  --warn: #a8560f;
  --bad: #a32c2c;
  --spade: #1c1b19;
  --heart: #b02020;
  --diamond: #b02020;
  --club: #1c1b19;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(28, 27, 25, .06), 0 4px 14px rgba(28, 27, 25, .05);
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

body.fourcolour {
  --heart: #b02020;
  --diamond: #c2660a;
  --club: #1c6b3a;
  --spade: #1c1b19;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --panel: #1b1e24;
    --panel-2: #21252c;
    --ink: #eceae5;
    --ink-2: #a8a49c;
    --ink-3: #767269;
    --line: #2e333b;
    --line-2: #262b32;
    --accent: #4fbb85;
    --accent-ink: #0f1114;
    --accent-soft: #1d3329;
    --warn: #dd9a4e;
    --bad: #e06c6c;
    --spade: #eceae5;
    --heart: #f0706e;
    --diamond: #f0706e;
    --club: #eceae5;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  }
  body.fourcolour {
    --heart: #f0706e;
    --diamond: #eaa14e;
    --club: #5cc088;
    --spade: #eceae5;
  }
}

* { box-sizing: border-box; }

/* Class rules below set `display`, which would otherwise beat the UA's
   [hidden] { display: none } and leave hidden elements on screen. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 600; }
h2 { font-size: 13px; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-2); }

button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
button:disabled { cursor: not-allowed; opacity: .45; }

/* ── suit pips ───────────────────────────────────────────────────── */
.pip.s { color: var(--spade); }
.pip.h { color: var(--heart); }
.pip.d { color: var(--diamond); }
.pip.c { color: var(--club); }

/* ── top bar ─────────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; gap: 20px;
  padding: 10px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 650; font-size: 16px; letter-spacing: -.01em; }
.tabs { display: flex; gap: 2px; }
.tab {
  padding: 6px 14px; border-radius: 999px; color: var(--ink-2);
  font-size: 13px; font-weight: 500;
}
.tab:hover { background: var(--line-2); }
.tab.is-active { background: var(--accent-soft); color: var(--accent); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.queue-chip {
  font-size: 12px; padding: 3px 9px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-variant-numeric: tabular-nums;
}

/* ── layout ──────────────────────────────────────────────────────── */
main { padding: 16px; }
.view { display: grid; grid-template-columns: minmax(340px, 420px) minmax(0, 1fr); gap: 16px; align-items: start; }
.column { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

@media (max-width: 980px) {
  .view { grid-template-columns: 1fr; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 12px; flex-wrap: wrap;
}
.hint { font-size: 12px; color: var(--ink-3); }

/* ── buttons ─────────────────────────────────────────────────────── */
.primary, .secondary, .ghost {
  border-radius: 8px; padding: 7px 14px; font-size: 13px; font-weight: 500;
  border: 1px solid transparent; transition: background .12s, border-color .12s;
}
.primary { background: var(--accent); color: var(--accent-ink); }
.primary:hover:not(:disabled) { filter: brightness(1.08); }
.secondary { background: var(--accent-soft); color: var(--accent); }
.secondary:hover:not(:disabled) { filter: brightness(.97); }
.ghost { border-color: var(--line); color: var(--ink-2); background: var(--panel); }
.ghost:hover:not(:disabled) { background: var(--panel-2); color: var(--ink); }
.small { padding: 4px 10px; font-size: 12px; }

/* ── segmented controls ──────────────────────────────────────────── */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button {
  padding: 6px 11px; font-size: 13px; color: var(--ink-2);
  border-right: 1px solid var(--line); min-width: 34px; font-weight: 500;
}
.seg button:last-child { border-right: 0; }
.seg button:hover { background: var(--panel-2); }
.seg button.is-active { background: var(--accent); color: var(--accent-ink); }
.seg button.is-active.pip { color: var(--accent-ink); }
.seg.small button { padding: 4px 9px; font-size: 12px; }
.seg button.pip { font-size: 15px; }

.contract-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.contract-row:last-child { margin-bottom: 0; }
.field-label { font-size: 12px; color: var(--ink-3); }

/* ── card grid ───────────────────────────────────────────────────── */
.target-tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.target {
  flex: 1; display: flex; flex-direction: column; gap: 1px; align-items: flex-start;
  padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel);
}
.target:hover { background: var(--panel-2); }
.target.is-active { border-color: var(--accent); background: var(--accent-soft); }
.t-name { font-size: 12px; font-weight: 500; }
.t-count { font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.target.is-active .t-name, .target.is-active .t-count { color: var(--accent); }
.target.is-full .t-count { color: var(--accent); font-weight: 600; }

.grid { display: flex; flex-direction: column; gap: 4px; }
.grid-row { display: grid; grid-template-columns: 22px repeat(13, minmax(0, 1fr)); gap: 3px; align-items: center; }
.grid-suit { font-size: 16px; text-align: center; }
.cardbtn {
  aspect-ratio: 3 / 4; min-height: 30px;
  border: 1px solid var(--line); border-radius: 5px;
  background: var(--panel-2); color: var(--ink-2);
  font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
  display: flex; align-items: center; justify-content: center;
  transition: transform .08s, background .1s, border-color .1s;
}
.cardbtn:hover { transform: translateY(-2px); border-color: var(--ink-3); }
.cardbtn.declarer { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.cardbtn.dummy { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.cardbtn.lead { background: var(--warn); border-color: var(--warn); color: #fff; }
.cardbtn.played { background: transparent; color: var(--ink-3); border-style: dashed; opacity: .55; }
.cardbtn.played:hover { transform: none; }

/* ── constraints ─────────────────────────────────────────────────── */
.con-block { border-top: 1px solid var(--line-2); padding-top: 10px; margin-top: 10px; }
.con-block:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.con-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.con-title { font-weight: 600; font-size: 13px; }
.con-sub { font-size: 11px; color: var(--ink-3); }
.con-toggles { margin-left: auto; display: flex; gap: 6px; }
.chip {
  font-size: 11px; padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--ink-2);
}
.chip.is-on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.con-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.con-row label { font-size: 12px; color: var(--ink-3); min-width: 30px; }
.num {
  width: 46px; padding: 4px 6px; font-size: 12px; text-align: center;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--panel-2); color: var(--ink); font-variant-numeric: tabular-nums;
}
.num:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.suitline { display: grid; grid-template-columns: 20px 1fr 8px 1fr; gap: 5px; align-items: center; }
.dash { color: var(--ink-3); text-align: center; }
.layouts-line { margin-top: 10px; font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.layouts-line.bad { color: var(--bad); }

/* ── the table diagram ───────────────────────────────────────────── */
.panel-table { min-height: 0; }
.diagram {
  display: grid;
  grid-template-columns: 1fr 1.1fr 1fr;
  grid-template-rows: auto auto auto;
  gap: 8px; align-items: center; justify-items: center;
  background: var(--panel-2); border: 1px solid var(--line-2);
  border-radius: var(--radius); padding: 12px;
}
.hand { min-width: 132px; }
.hand-north { grid-area: 1 / 2; }
.hand-west  { grid-area: 2 / 1; }
.hand-east  { grid-area: 2 / 3; }
.hand-south { grid-area: 3 / 2; }
.hand-mid   { grid-area: 2 / 2; }

.hand-label {
  font-size: 11px; font-weight: 600; letter-spacing: .06em; color: var(--ink-3);
  margin-bottom: 3px; display: flex; gap: 6px; align-items: center;
}
.hand-label .role { font-weight: 500; letter-spacing: 0; text-transform: none; }
.hand-label.turn { color: var(--accent); }
.hand-label.turn::after {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
}
.hand-suits { font-family: var(--mono); font-size: 13px; line-height: 1.45; }
.hand-suits div { white-space: nowrap; }
.hand-suits .sym { display: inline-block; width: 14px; }
.hand-hidden { color: var(--ink-3); font-size: 12px; font-style: italic; }
.hand-label .role-note { font-weight: 400; letter-spacing: 0; }
/* A defender's played cards: a long suit wraps under its own ranks. */
.hand-played div { white-space: normal; padding-left: 14px; text-indent: -14px; }
.hand-played .void {
  font-family: system-ui, sans-serif; font-size: 11px; font-style: italic;
  color: var(--ink-3); margin-left: 6px;
}
.table-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.trick-centre {
  display: grid; grid-template-columns: repeat(3, 30px); grid-template-rows: repeat(3, 24px);
  place-items: center; font-family: var(--mono); font-size: 13px; font-weight: 600;
}
.trick-centre .tc-n { grid-area: 1 / 2; }
.trick-centre .tc-w { grid-area: 2 / 1; }
.trick-centre .tc-e { grid-area: 2 / 3; }
.trick-centre .tc-s { grid-area: 3 / 2; }

.trickbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin-top: 10px; font-size: 12px; color: var(--ink-2);
}
.score { font-variant-numeric: tabular-nums; }
.score b { color: var(--ink); font-size: 14px; }
.tricklog { display: flex; gap: 3px; flex-wrap: wrap; }
.tricklog i {
  width: 13px; height: 13px; border-radius: 3px; border: 1px solid var(--line);
  display: inline-block;
}
.tricklog i.won { background: var(--accent); border-color: var(--accent); }
.tricklog i.lost { background: var(--bad); border-color: var(--bad); }

/* ── analysis results ────────────────────────────────────────────── */
.analysis-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.status { font-size: 12px; color: var(--ink-2); min-height: 18px; margin-bottom: 8px; }
.status.err { color: var(--bad); }

.cards-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.cards-table th {
  text-align: right; font-size: 11px; font-weight: 500; color: var(--ink-3);
  padding: 0 8px 6px; text-transform: uppercase; letter-spacing: .04em;
}
.cards-table th:first-child, .cards-table td:first-child { text-align: left; }
.cards-table td { padding: 5px 8px; border-top: 1px solid var(--line-2); text-align: right; }
.cards-table tr.best td { background: var(--accent-soft); }
.cards-table tr.playable { cursor: pointer; }
.cards-table tr.playable:hover td { background: var(--line-2); }
.cards-table tr.best.playable:hover td { background: var(--accent-soft); filter: brightness(.97); }

.cardcell { font-family: var(--mono); font-size: 15px; font-weight: 600; }
.bar { position: relative; height: 7px; border-radius: 4px; background: var(--line-2); min-width: 90px; }
.bar span { position: absolute; inset: 0 auto 0 0; border-radius: 4px; background: var(--accent); }
.bar.low span { background: var(--warn); }
.bar.zero span { background: var(--bad); }
.pct { font-weight: 600; font-size: 14px; }
.se { font-size: 11px; color: var(--ink-3); }
.delta { font-size: 11px; color: var(--ink-3); }

.linebox { margin-top: 4px; }
.line-step {
  display: grid; grid-template-columns: 42px 26px 42px 1fr;
  gap: 8px; align-items: center;
  padding: 4px 8px; border-top: 1px solid var(--line-2); font-size: 13px;
}
.line-step.decision { background: var(--panel-2); }
.line-step .ls-trick { font-size: 11px; color: var(--ink-3); }
.line-step .ls-seat { font-size: 11px; color: var(--ink-3); font-weight: 600; }
.line-step .ls-card { font-family: var(--mono); font-weight: 600; }
.line-step .ls-pct { font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: 12px; }
.line-verdict { margin: 10px 0 4px; font-size: 14px; font-weight: 600; }
.line-verdict.made { color: var(--accent); }
.line-verdict.down { color: var(--bad); }

.defence-prompt { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 6px 0; }
.defence-cards { display: flex; gap: 3px; flex-wrap: wrap; }
.defence-cards button {
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  padding: 3px 7px; border: 1px solid var(--line); border-radius: 5px; background: var(--panel-2);
}
.defence-cards button:hover { border-color: var(--accent); color: var(--accent); }

/* ── caveat ──────────────────────────────────────────────────────── */
.caveat { margin-top: 14px; border-top: 1px solid var(--line-2); padding-top: 10px; }
.caveat summary {
  cursor: pointer; font-size: 12px; color: var(--warn); font-weight: 500; list-style: none;
}
.caveat summary::before { content: "△ "; }
.caveat summary::-webkit-details-marker { display: none; }
.caveat-body { font-size: 12px; color: var(--ink-2); line-height: 1.6; }
.caveat-body p { margin: 8px 0 0; }
.caveat-body .ex { padding: 8px 10px; background: var(--panel-2); border-radius: 7px; border-left: 2px solid var(--warn); }

/* ── library ─────────────────────────────────────────────────────── */
#view-library { grid-template-columns: 1fr; }
.library-list { display: flex; flex-direction: column; }
.lib-row {
  display: grid; grid-template-columns: 1fr auto auto auto;
  gap: 12px; align-items: center;
  padding: 10px 4px; border-top: 1px solid var(--line-2);
}
.lib-row:first-child { border-top: 0; }
.lib-title { font-weight: 500; }
.lib-notes { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.lib-meta { font-size: 12px; color: var(--ink-3); }
.lib-empty { color: var(--ink-3); font-size: 13px; padding: 12px 0; }

/* ── gate, toast, dialog ─────────────────────────────────────────── */
.gate {
  position: fixed; inset: 0; z-index: 100; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
}
.gate-box {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 32px; width: min(340px, 90vw); box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 10px; text-align: center;
}
.gate-box h1 { font-size: 26px; }
.gate-box p { margin: 0 0 8px; color: var(--ink-3); font-size: 13px; }
.gate-box input {
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel-2); color: var(--ink); font-size: 14px;
}
.gate-box button { background: var(--accent); color: var(--accent-ink); padding: 9px; border-radius: 8px; font-weight: 500; }
.gate-error { color: var(--bad); font-size: 12px; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 9px 16px; border-radius: 8px;
  font-size: 13px; z-index: 60; box-shadow: var(--shadow);
}

.dialog {
  border: 1px solid var(--line); border-radius: 12px; padding: 20px;
  background: var(--panel); color: var(--ink); width: min(420px, 92vw);
  box-shadow: var(--shadow);
}
.dialog::backdrop { background: rgba(0, 0, 0, .35); }
.dialog h3 { margin-bottom: 14px; }
.dialog label { display: block; font-size: 12px; color: var(--ink-3); margin-bottom: 10px; }
.dialog input, .dialog textarea {
  display: block; width: 100%; margin-top: 4px; padding: 7px 10px;
  border: 1px solid var(--line); border-radius: 7px;
  background: var(--panel-2); color: var(--ink); font: inherit; resize: vertical;
}
.dialog menu { display: flex; justify-content: flex-end; gap: 8px; padding: 0; margin: 16px 0 0; }

/* ── line summary: from the start vs from this moment ───────────── */
.linesum {
  margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line-2);
  display: grid; gap: 4px;
}
.ls-row { display: grid; grid-template-columns: 122px 66px minmax(0, 1fr); gap: 10px; align-items: baseline; }
.ls-label { font-size: 12px; color: var(--ink-2); font-weight: 500; cursor: help; }
.ls-value { font-size: 17px; font-weight: 650; font-variant-numeric: tabular-nums; text-align: right; }
.ls-note { font-size: 12px; color: var(--ink-3); }
.ls-actions { display: flex; justify-content: flex-end; }

.line-start { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 8px; font-size: 13px; }
.scroll-x { overflow-x: auto; }
.review-table th, .review-table td { white-space: nowrap; }
.review-table tr.off td { background: color-mix(in srgb, var(--warn) 13%, transparent); }

/* ── equal cards: each rank playable on its own ─────────────────── */
.rank {
  font-family: var(--mono); font-weight: 600; font-size: 15px;
  padding: 0 2px; border-radius: 4px; color: inherit;
}
.rank:hover { background: var(--accent); color: var(--accent-ink); }

/* ── defence: show-outs, ruffs, discards ────────────────────────── */
.showout { margin: 6px 0 2px; font-size: 13px; }
.odds b { font-variant-numeric: tabular-nums; }
.defence-group { margin: 8px 0; }
.dg-label { font-size: 12px; color: var(--ink-2); font-weight: 500; margin-bottom: 4px; }

/* ── αμ table: double dummy alongside ───────────────────────────── */
.cards-table td.dd { color: var(--ink-3); }
.cards-table td.peek { color: var(--warn); font-size: 12px; }

/* ── folds under the table: trick list, saved lines ─────────────── */
.fold { margin-top: 10px; border-top: 1px solid var(--line-2); padding-top: 8px; }
.fold > summary {
  cursor: pointer; font-size: 12px; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--ink-2); list-style: none; display: flex; gap: 8px; align-items: center;
}
.fold > summary::before { content: "▸"; font-size: 11px; color: var(--ink-3); transition: transform .12s; }
.fold[open] > summary::before { transform: rotate(90deg); }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary .hint { text-transform: none; letter-spacing: 0; font-weight: 500; }
.fold > div { margin-top: 8px; }

.ls-split { font-size: 12px; color: var(--ink-3); margin: -2px 0 4px; line-height: 1.5; }

.tricks-table td, .lines-table td { vertical-align: top; }
.tricks-table td.tn { color: var(--ink-3); font-variant-numeric: tabular-nums; text-align: left; width: 22px; }
.tricks-table td.tcards, .lines-table td.lcards { text-align: left; }
.tricks-table td.pct { font-weight: 600; white-space: nowrap; }
.tricks-table td.share, .lines-table td.share { color: var(--ink-3); white-space: nowrap; }
.tricks-table tr.won td.tn { border-left: 3px solid var(--accent); }
.tricks-table tr.lost td.tn { border-left: 3px solid var(--bad); }
.tricks-table tr.pending td { color: var(--ink-2); }
.tc { display: inline-block; font-family: var(--mono); font-size: 13px; margin-right: 10px; white-space: nowrap; }
.tc.won { font-weight: 700; }
.tc-seat { font-family: system-ui, sans-serif; font-size: 10px; color: var(--ink-3); margin-right: 2px; vertical-align: 1px; }
.trick-events, .trick-decisions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.event {
  font-size: 11px; padding: 2px 7px; border-radius: 999px;
  background: color-mix(in srgb, var(--warn) 12%, transparent); color: var(--ink-2);
}
.event b { color: var(--warn); }
.decision { font-size: 11px; padding: 2px 7px; border-radius: 999px; background: var(--panel-2); color: var(--ink-2); }
.decision.off { background: color-mix(in srgb, var(--bad) 12%, transparent); }
.tricks-actions { display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }

.lines-table td.ltitle { text-align: left; white-space: nowrap; }
.lines-table td.lcards { font-family: var(--mono); font-size: 12px; line-height: 1.6; }
.lines-table td.lactions { white-space: nowrap; }
.tricks-table .few { color: var(--ink-3); border-bottom: 1px dotted var(--ink-3); }

/* ── where the line's chance comes from ─────────────────────────── */
.ls-why { margin-top: 6px; }
.ls-why > summary { cursor: pointer; font-size: 12px; color: var(--ink-2); }
.ls-why > summary:hover { color: var(--ink); }
.ls-why .hint { display: block; margin-top: 4px; }
.scen-table { margin-top: 6px; }
.scen-table td { vertical-align: top; }
.scen-table td.sc-what { text-align: left; }
.scen-table td.sc-what .hint { display: inline; margin: 0; }
.scen-table td.pct, .scen-table td.share { white-space: nowrap; }
.scen-table tr.sc-on td { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.scen-table tr.sc-small td { color: var(--ink-3); }
.scen-table tfoot td { font-weight: 700; border-top: 1px solid var(--line-2); text-align: right; }
.scen-table tfoot td:first-child { text-align: left; }

/* ── defenders' hand patterns: one line until unfolded ─────────────── */
.shape-pick { margin-top: 2px; }
.shape-pick > summary {
  cursor: pointer; list-style: none; display: flex; align-items: baseline; gap: 8px;
  font-size: 12px; color: var(--ink-3);
}
.shape-pick > summary::-webkit-details-marker { display: none; }
.shape-pick > summary::after { content: "▸"; font-size: 10px; color: var(--ink-3); transition: transform .12s; }
.shape-pick[open] > summary::after { transform: rotate(90deg); }
.sp-label { min-width: 30px; }
.sp-value { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.sp-share { font-size: 11px; }
.sp-chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0 4px; }
.sp-chip {
  display: inline-flex; flex-direction: column; align-items: center; min-width: 42px;
  padding: 3px 4px 2px; border: 1px solid var(--line); border-radius: 6px; line-height: 1.1;
  background: var(--panel-2); color: var(--ink-2);
  font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; cursor: pointer;
}
.sp-chip small { font-size: 9.5px; font-weight: 500; color: var(--ink-3); }
.sp-chip.is-on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.sp-chip.is-on small { color: inherit; opacity: .85; }
.sp-chip.impossible { opacity: .45; }
.sp-chip.is-off {
  background: color-mix(in srgb, var(--bad) 10%, var(--panel-2)); border-color: var(--bad); color: var(--bad);
  text-decoration: line-through; text-decoration-thickness: 1.5px;
}
.sp-chip.is-off small { text-decoration: none; color: inherit; opacity: .8; }
.sp-mode { display: inline-flex; margin-top: 6px; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.sp-mode button {
  background: var(--panel-2); border: 0; padding: 3px 9px; cursor: pointer;
  font-size: 11px; color: var(--ink-2);
}
.sp-mode button + button { border-left: 1px solid var(--line); }
.sp-mode button.is-active { background: var(--ink); color: var(--panel); font-weight: 600; }
.sp-mode button:focus-visible, .sp-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.sp-actions { display: flex; flex-wrap: wrap; gap: 2px 12px; }
.sp-actions button {
  background: none; border: 0; padding: 0; cursor: pointer;
  font-size: 11px; color: var(--accent); text-decoration: underline; text-underline-offset: 2px;
}

/* ── where two cards of the table part ways ─────────────────────── */
.cards-table th.pick, .cards-table td.pick { width: 24px; padding-right: 0; }
.cards-table td.pick input { width: 15px; height: 15px; margin: 0; accent-color: var(--accent); cursor: pointer; vertical-align: middle; }
.compare-bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 14px;
  margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line);
}
.dialog-wide { width: min(1000px, 96vw); max-height: 90vh; overflow: auto; padding: 20px 24px 16px; }
.diff-close { position: sticky; top: 0; float: right; margin: -4px -8px 0 12px; z-index: 1; }
.diff-head { display: grid; gap: 6px; }
.diff-head h3 { margin: 0; font-size: 18px; }
.diff-head p { margin: 0; }
.diff-known { display: flex; flex-wrap: wrap; gap: 4px 18px; font-family: var(--mono); font-size: 12.5px; color: var(--ink-2); }
.diff-known b { font-family: system-ui, sans-serif; font-size: 11px; color: var(--ink-3); margin-right: 4px; }
.diff-wait, .diff-error { margin: 8px 0; }
.diff-wait::after { content: attr(data-elapsed); margin-left: 8px; color: var(--ink-3); font-size: 12px; }
.diff-error { color: var(--bad); }
.diff-dir { display: grid; gap: 8px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line-2); }
.diff-dir h4 { margin: 0; font-size: 15px; }
.diff-dir > p { margin: 0; }
.families { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.families li {
  display: inline-flex; align-items: baseline; gap: 6px; font-size: 12px;
  padding: 3px 10px; border: 1px solid var(--line-2); border-radius: 999px; background: var(--panel-2);
}
.diff-num { font-weight: 600; font-variant-numeric: tabular-nums; }
.deals { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 270px), 1fr)); gap: 10px; }
.deal { display: grid; gap: 8px; align-content: start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); }
.deal:has(> details[open]) { grid-column: 1 / -1; }
.dh-grid {
  display: grid; grid-template-columns: auto auto auto; justify-content: space-between; gap: 0 10px;
  grid-template-areas: ". n ." "w . e" ". s .";
  max-width: 300px;
}
.dh-n { grid-area: n; } .dh-e { grid-area: e; } .dh-s { grid-area: s; } .dh-w { grid-area: w; }
.deal .gone { color: var(--ink-3); opacity: .55; }
.deal .gone mark { background: none; color: inherit; }
.deal-more > summary { cursor: pointer; font-size: 12px; color: var(--accent); width: fit-content; }
.play-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); gap: 6px 18px; margin-top: 8px; }
.pl-head { font-size: 12px; font-weight: 600; margin-bottom: 2px; }
.pl-row {
  display: grid; grid-template-columns: 2.2em 1.4em 1fr; align-items: baseline;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.6; border-radius: 4px; padding-inline: 4px; margin-inline: -4px;
}
.pl-row.split { background: var(--accent-soft); }
.pl-n { color: var(--ink-3); font-size: 11px; font-variant-numeric: tabular-nums; }
.pl-lead { color: var(--ink-3); font-size: 11px; font-family: system-ui, sans-serif; }
.pl-cards { white-space: nowrap; }
.pl-cards b { font-weight: 800; }
.pl-cards mark { background: var(--accent-soft); color: inherit; border-radius: 3px; padding: 0 1px; }
.open-mark { color: var(--warn); font-weight: 700; margin-right: 2px; }
.pl-note, .pl-legend { margin: 4px 0 0; font-size: 11.5px; }
.deal header { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; font-weight: 600; }
.dh-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dh-seat { font-size: 11px; font-weight: 600; color: var(--ink-3); margin-bottom: 2px; }
.dh-row { font-family: var(--mono); font-size: 12.5px; line-height: 1.55; white-space: nowrap; }
.dh-row .pip { display: inline-block; width: 1.15em; }
.dh-row.hl { background: var(--accent-soft); border-radius: 4px; margin-inline: -4px; padding-inline: 4px; }
.deal mark { background: var(--accent-soft); color: var(--accent); font-weight: 700; border-radius: 3px; padding: 0 1px; }
.deal footer { display: flex; flex-wrap: wrap; gap: 2px 10px; font-size: 12px; }
.deal .ok { color: var(--accent); font-weight: 600; }
.deal .no { color: var(--bad); font-weight: 600; }
.diff-foot { margin: 14px 0 0; }

/* ── comparing two lines ─────────────────────────────────────────── */
.lines-table th.pick, .lines-table td.pick { width: 24px; padding-right: 0; }
.lines-table td.pick input { width: 15px; height: 15px; margin: 0; accent-color: var(--accent); cursor: pointer; vertical-align: middle; }
.diff-lines { display: grid; gap: 4px; font-size: 13px; }
.diff-lines .seq { font-family: var(--mono); font-size: 12.5px; }
.diff-lines mark { background: var(--accent-soft); color: inherit; border-radius: 3px; padding: 0 2px; }
.deal-lines { display: grid; gap: 2px; }
.dh-row u { text-decoration-thickness: 2px; text-underline-offset: 2px; }

/* ── hidden options: analysis length ─────────────────────────────── */
.adv-opts { margin: -4px 0 6px; }
.adv-opts > summary { cursor: pointer; width: fit-content; font-size: 12px; color: var(--ink-3); list-style: none; display: flex; align-items: center; gap: 8px; }
.adv-opts > summary::-webkit-details-marker { display: none; }
.adv-opts > summary::after { content: "▸"; font-size: 10px; transition: transform .12s; }
.adv-opts[open] > summary::after { transform: rotate(90deg); }
.adv-body { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-top: 6px; }
.adv-label { font-size: 12px; color: var(--ink-2); }
.adv-body .hint { flex-basis: 100%; margin: 0; max-width: 68ch; }
.opts-badge { font-size: 11px; font-weight: 700; color: var(--warn); border: 1px solid currentColor; border-radius: 999px; padding: 0 7px; }

/* ── phones ────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .topbar {
    flex-wrap: wrap; gap: 6px 10px;
    padding: calc(8px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right)) 8px calc(12px + env(safe-area-inset-left));
  }
  .brand { white-space: nowrap; }
  .tab { padding: 5px 11px; }
  .topbar-right .ghost { padding: 4px 9px; font-size: 12px; }
  main { padding: 10px calc(10px + env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) calc(10px + env(safe-area-inset-left)); }
  .view, .column { gap: 10px; }
  .panel { padding: 12px; }

  /* The table: three hands side by side have to fit in ~350px. */
  .diagram { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 6px; padding: 8px; }
  .hand { min-width: 0; }
  .hand-suits { font-size: 12px; }
  .hand-suits .sym { width: 12px; }
  .hand-played div { padding-left: 12px; text-indent: -12px; }
  .hand-label { font-size: 10px; flex-wrap: wrap; gap: 2px 4px; }
  .trick-centre { grid-template-columns: repeat(3, 26px); grid-template-rows: repeat(3, 22px); font-size: 12px; }

  .cards-table th, .cards-table td { padding-left: 5px; padding-right: 5px; }
  .dialog-wide { padding: 14px 12px 12px; width: 100vw; max-width: 100vw; max-height: 100dvh; border-radius: 0; }
  .deals { grid-template-columns: minmax(0, 1fr); }
}

/* ── moving data between two Szlems ───────────────────────────────── */
.transfer { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line-2); display: grid; gap: 8px; }
.transfer h3 { font-size: 13px; }
.transfer > .hint { margin: 0; max-width: 72ch; }
.transfer-opt { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 6px; font-size: 13px; cursor: pointer; }
.transfer-opt input { accent-color: var(--accent); }
.transfer-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.transfer-status { margin: 0; font-size: 13px; color: var(--ink-2); }
.transfer-status.bad { color: var(--bad); }
