:root {
  --bg: #0f1216; --bg2: #161b22; --bg3: #1d232c; --line: #2a323d;
  --fg: #e6edf3; --dim: #8b949e; --accent: #3b82f6;
  --green: #2ea043; --red: #da3633; --amber: #d29922;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 13px/1.5 -apple-system, "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  display: flex; flex-direction: column; height: 100vh; overflow: hidden;
}

header {
  display: flex; align-items: center; gap: 16px;
  padding: 8px 14px; background: var(--bg2); border-bottom: 1px solid var(--line); flex: 0 0 auto;
}
.brand { display: flex; align-items: baseline; gap: 7px; font-weight: 600; font-size: 15px; }
.brand .logo { font-size: 18px; color: var(--accent); }
.brand .ver { font-size: 10px; color: var(--dim); font-weight: 400; }
.mode-switch { display: flex; gap: 4px; background: var(--bg); padding: 3px; border-radius: 8px; border: 1px solid var(--line); }
.head-actions { margin-left: auto; display: flex; gap: 8px; }

.btn {
  background: var(--bg3); color: var(--fg); border: 1px solid var(--line);
  padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 13px;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: #252d38; border-color: #3d4a59; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: #2f6fd0; }
.btn.active { background: #1b2b42; border-color: var(--accent); color: #cfe3ff; }
.btn.small { padding: 3px 9px; font-size: 12px; }
.btn.big { padding: 10px 22px; font-size: 14px; }
.btn.mode { border-color: transparent; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.file { display: inline-flex; align-items: center; }

.paste-panel {
  position: absolute; inset: 58px 16px auto 16px; z-index: 50;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; box-shadow: 0 12px 40px rgba(0,0,0,.6);
}
/* account chip in the header */
.who { display: flex; align-items: center; gap: 8px; margin-left: 10px; position: relative; }
.who .chip-user {
  display: flex; align-items: center; gap: 8px; padding: 5px 10px;
  background: var(--bg3); border: 1px solid var(--line); border-radius: 999px;
  font-size: 12px; cursor: pointer; white-space: nowrap;
  color: var(--fg);              /* buttons do not inherit body colour */
}
.who .chip-user:hover { border-color: #3d4a59; }
.who .nm { font-weight: 600; color: #fff; }
.who .bal { color: var(--green); font-family: ui-monospace, monospace; }
.who .bal.low { color: var(--red); }
.who .menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 80; min-width: 132px;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 4px;
  box-shadow: 0 10px 30px rgba(0,0,0,.6);
}
.who .menu button {
  display: block; width: 100%; text-align: left; border: 0; background: transparent;
  color: var(--fg); font-size: 12px; padding: 7px 10px; border-radius: 6px; cursor: pointer;
}
.who .menu button:hover { background: var(--bg3); }
.who .menu.hidden { display: none; }

.paste-panel textarea {
  width: 100%; height: 220px; background: var(--bg); color: var(--fg);
  border: 1px solid var(--line); border-radius: 6px; padding: 10px;
  font-family: ui-monospace, Consolas, monospace; font-size: 12px; resize: vertical;
}
.paste-actions { display: flex; gap: 8px; margin-top: 10px; }

main {
  flex: 1 1 auto; display: grid; min-height: 0;
  grid-template-columns: var(--left-w, 236px) minmax(280px, 1fr) 6px var(--solver-w, 452px);
}

.col { min-height: 0; overflow: auto; border-right: 1px solid var(--line); }
.col:last-child { border-right: none; }
.col-title {
  position: sticky; top: 0; z-index: 2; padding: 9px 14px;
  font-size: 10px; letter-spacing: .09em; text-transform: uppercase;
  color: var(--dim); background: var(--bg2); border-bottom: 1px solid var(--line);
}
.col-title span { color: var(--fg); }
.sec-title {
  font-size: 10px; letter-spacing: .09em; text-transform: uppercase;
  color: var(--dim); margin: 18px 0 8px;
}

.hand-list { padding: 6px; }
.hand-item { padding: 8px 10px; border-radius: 6px; cursor: pointer; margin-bottom: 4px; border: 1px solid transparent; background: var(--bg2); }
.hand-item:hover { border-color: var(--line); }
.hand-item.active { border-color: var(--accent); background: #17263d; }
.hand-item .hid { font-family: ui-monospace, monospace; font-size: 11px; color: var(--dim); }
.hand-item .hboard { font-family: ui-monospace, monospace; letter-spacing: 1px; font-size: 13px; }

.empty { padding: 28px 20px; color: var(--dim); text-align: center; }
.dim { color: var(--dim); }
.tiny { font-size: 11px; }
.hidden { display: none !important; }

#detail { padding: 14px 16px 40px; }

/* ---------- builder ---------- */
.builder { display: flex; flex-direction: column; gap: 14px; }
.slot-row { display: flex; gap: 18px; align-items: flex-end; flex-wrap: wrap; }
.slot-group { display: flex; gap: 4px; align-items: flex-end; }
.slot-cap { font-size: 10px; color: var(--dim); text-transform: uppercase; letter-spacing: .06em; position: absolute; }
.slot-group { position: relative; padding-top: 16px; }
.slot-cap { position: absolute; top: 0; left: 0; }
.slot { cursor: pointer; display: inline-block; }
.slot.blocked { opacity: .28; pointer-events: none; }

.cards { display: inline-flex; gap: 3px; }
.card {
  display: inline-flex; align-items: center; justify-content: center; gap: 1px;
  min-width: 34px; height: 46px; padding: 0 5px; border-radius: 6px;
  background: #f5f6f8; color: #16181d; font-weight: 700; font-size: 16px;
  font-family: ui-monospace, Consolas, monospace; user-select: none; border: 1px solid #cfd4da;
}
/* four-colour deck; contrast measured against the #f5f6f8 card face */
.card.spade   { color: #16181d; }   /* 16.4:1 */
.card.heart   { color: #a81b26; }   /*  6.8:1 */
.card.diamond { color: #1a4fb8; }   /*  6.8:1 */
.card.club    { color: #16703b; }   /*  5.7:1 */
.card.small { min-width: 26px; height: 34px; font-size: 12px; border-radius: 4px; }
.card.empty { background: #1a2029; border: 1px dashed #38424f; color: #4a5665; }

.deck { display: flex; flex-direction: column; gap: 3px; background: var(--bg2); padding: 8px; border-radius: 8px; border: 1px solid var(--line); }
.deck-row { display: grid; grid-template-columns: repeat(13, 1fr); gap: 3px; }
.dcard {
  display: flex; align-items: center; justify-content: center; gap: 1px;
  height: 30px; border-radius: 4px; cursor: pointer; font-weight: 700; font-size: 12px;
  background: #f2f4f6; color: #16181d; border: 1px solid #c8ced5;
  font-family: ui-monospace, Consolas, monospace; padding: 0;
  transition: transform .08s, background .1s;
}
.dcard .s { font-size: .95em; }
.dcard.spade   { color: #16181d; }
.dcard.heart   { color: #a81b26; }
.dcard.diamond { color: #1a4fb8; }
.dcard.club    { color: #16703b; }
.dcard:hover:not(:disabled) { background: #fff; transform: translateY(-1px); }
.dcard.used { opacity: .18; cursor: default; }

.cfg { display: grid; grid-template-columns: auto 1fr; gap: 7px 10px; align-items: center; }
.cfg label { color: var(--dim); font-size: 12px; white-space: nowrap; }
.cfg input, .cfg select, .range-head select {
  background: var(--bg); color: var(--fg); border: 1px solid var(--line);
  border-radius: 5px; padding: 5px 8px; font-size: 12px; width: 100%;
  font-family: ui-monospace, Consolas, monospace;
}

.range-block { background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.range-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 12px; color: var(--dim); }
.range-head select { width: auto; flex: 1; }
.range-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.range-cols label { display: block; font-size: 11px; color: var(--dim); margin-bottom: 4px; }
.range-cols textarea {
  width: 100%; background: var(--bg); color: var(--fg); border: 1px solid var(--line);
  border-radius: 5px; padding: 7px; font-size: 11px; resize: vertical;
  font-family: ui-monospace, Consolas, monospace; line-height: 1.45;
}

.solve-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

/* ---------- result ---------- */
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.metric { background: var(--bg2); border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; }
.metric .k { font-size: 10px; color: var(--dim); text-transform: uppercase; letter-spacing: .06em; }
.metric .v { font-size: 15px; font-weight: 600; font-family: ui-monospace, monospace; }
.metric .v.good { color: var(--green); }
.metric .v.warn { color: var(--amber); }
.metric .v.bad { color: var(--red); }

.legend { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; font-size: 11px; }
.legend .li { display: flex; align-items: center; gap: 5px; color: var(--dim); }
.legend .sw { width: 10px; height: 10px; border-radius: 2px; }

canvas.range-grid { display: block; border-radius: 6px; margin-bottom: 12px; }

.arow { display: grid; grid-template-columns: 1fr 58px; gap: 8px; align-items: center; padding: 6px 9px; background: var(--bg2); border: 1px solid var(--line); border-radius: 5px; }
.arow .lbl { display: flex; align-items: center; gap: 7px; }
.arow .pct { text-align: right; font-family: ui-monospace, monospace; font-size: 12px; }
.bar { height: 4px; border-radius: 2px; background: #1d232c; overflow: hidden; }
.bar i { display: block; height: 100%; }
.tag { font-size: 9px; text-transform: uppercase; letter-spacing: .06em; background: var(--bg3); padding: 1px 5px; border-radius: 3px; color: var(--dim); }

.evloss { margin-top: 12px; padding: 10px 12px; border-radius: 6px; border: 1px solid var(--line); background: var(--bg2); }
.evloss .big { font-size: 19px; font-weight: 700; font-family: ui-monospace, monospace; }
.evloss.good .big { color: var(--green); }
.evloss.bad .big { color: var(--red); }
.evloss.warn .big { color: var(--amber); }

.hand-stats { display: flex; gap: 14px; font-size: 11px; color: var(--dim); margin-top: 10px; flex-wrap: wrap; }

.note { font-size: 11px; color: var(--amber); background: rgba(210,153,34,.08); border: 1px solid rgba(210,153,34,.28); border-radius: 5px; padding: 6px 9px; margin-bottom: 10px; line-height: 1.45; }

.solving { padding: 30px 10px; text-align: center; color: var(--dim); display: flex; flex-direction: column; gap: 12px; align-items: center; }
.spin { width: 26px; height: 26px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: sp 0.8s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
.solving progress { width: 100%; height: 6px; }

/* ---------- hand history ---------- */
.det-head { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.det-title { font-size: 15px; font-weight: 600; }
table.streets { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
table.streets th { text-align: left; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--dim); font-weight: 500; padding: 4px 8px; border-bottom: 1px solid var(--line); }
table.streets td { padding: 6px 8px; border-bottom: 1px solid #1c2229; vertical-align: top; }
.act { padding: 2px 0; }
.act .who { color: var(--dim); }
.act.hero .who { color: var(--accent); font-weight: 600; }
.act .what { margin-left: 6px; }
.decisions { display: flex; flex-direction: column; gap: 6px; }
.dec { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--bg2); border: 1px solid var(--line); border-radius: 6px; cursor: pointer; }
.dec:hover { border-color: #3d4a59; }
.dec.active { border-color: var(--accent); background: #17263d; }
.dec .txt { flex: 1; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--bg3); border: 1px solid var(--line); color: var(--fg); padding: 10px 18px; border-radius: 8px; z-index: 100; box-shadow: 0 8px 30px rgba(0,0,0,.5); }

/* ================= v0.3 additions ================= */
main.mode-builder { --left-w: 236px; }
main.mode-hands { --left-w: 200px; }
main.mode-builder #hand-col { display: none; }
main.mode-hands #line-col { display: none; }

.line-list { padding: 8px; display: flex; flex-direction: column; gap: 5px; }
.line-street { font-size: 10px; letter-spacing: .09em; text-transform: uppercase; color: var(--dim); margin: 8px 0 2px; padding-left: 2px; }
.line-item { background: var(--bg2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 9px; }
.line-item.me { border-color: #2b4a72; background: #14213a; }
.line-item .li-head { font-size: 10px; color: var(--dim); text-transform: uppercase; letter-spacing: .06em; }
.line-item.me .li-head { color: var(--accent); }
.line-item .li-body { font-size: 12px; }
.line-empty { padding: 14px 10px; font-size: 11px; line-height: 1.6; text-align: center; }

.slot-row { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.slot-group { position: relative; padding-top: 15px; display: flex; gap: 4px; }
.slot-cap { position: absolute; top: 0; left: 0; font-size: 10px; color: var(--dim); text-transform: uppercase; letter-spacing: .06em; }
.slot { cursor: pointer; display: inline-block; }
.slot.blocked { opacity: .25; pointer-events: none; }

.side-tabs { display: flex; gap: 6px; margin-bottom: 8px; }
.btn.side { border-color: var(--line); }
.btn.side.active { background: #1b2b42; border-color: var(--accent); color: #cfe3ff; }

.range-tools { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.range-tools select { background: var(--bg); color: var(--fg); border: 1px solid var(--line); border-radius: 5px; padding: 4px 6px; font-size: 12px; max-width: 180px; }
.brush { width: 40px; height: 24px; border-radius: 4px; border: 1px solid var(--line); cursor: pointer; font-size: 11px; color: #0b0e12; font-weight: 700; }
.brush.active { outline: 2px solid var(--accent); outline-offset: 1px; }
/* the eraser is 0% weight: weightColor(0) is near-black, so give it its own look */
.brush.erase { background: #1a2029; color: #ff9b95; border-color: rgba(218,54,51,.5); }

.editor-wrap { display: flex; justify-content: center; }
canvas#range-canvas { cursor: crosshair; border-radius: 6px; touch-action: none; }
#b-rangetext { width: 100%; background: var(--bg); color: var(--dim); border: 1px solid var(--line); border-radius: 5px; padding: 6px; font-size: 10.5px; font-family: ui-monospace, Consolas, monospace; resize: vertical; margin-top: 6px; }

.grid-wrap { position: relative; margin-bottom: 10px; }
.cell-tip {
  position: absolute; z-index: 20; pointer-events: none; min-width: 160px;
  background: #0b1016; border: 1px solid #3d4a59; border-radius: 6px; padding: 7px 9px;
  box-shadow: 0 8px 24px rgba(0,0,0,.7); font-size: 11px; right: 4px; top: 4px;
}
.cell-tip .tip-title { font-weight: 700; margin-bottom: 5px; font-size: 12px; }
.cell-tip .tip-row { display: flex; align-items: center; gap: 6px; line-height: 1.7; }
.cell-tip .tip-sw { width: 9px; height: 9px; border-radius: 2px; flex: 0 0 auto; }
.cell-tip .tip-lbl { flex: 1; }
.cell-tip .tip-val { font-family: ui-monospace, monospace; font-weight: 600; }
.cell-tip .tip-ev { font-family: ui-monospace, monospace; font-size: 10px; }

.turn-banner {
  padding: 8px 12px; border-radius: 6px; margin-bottom: 10px; font-weight: 600; font-size: 13px;
  border: 1px solid var(--line); background: var(--bg2);
}
.turn-banner.me { border-color: #2b6cb0; background: #14213a; color: #cfe3ff; }
.turn-banner.them { border-color: #7c5c1a; background: #241c0d; color: #f0d9a8; }

button.arow {
  display: grid; grid-template-columns: 1fr 58px; gap: 8px; align-items: center;
  padding: 7px 9px; background: var(--bg2); border: 1px solid var(--line); border-radius: 5px;
  color: var(--fg); cursor: pointer; width: 100%; text-align: left; font-size: 13px;
  transition: border-color .1s, background .1s;
}
button.arow:hover { background: #1f2731; border-color: #3d4a59; }
.tag.best { background: #0f3d1f; color: #56d364; }
.bar-wrap { display: flex; align-items: center; gap: 8px; margin: -2px 0 8px; }
.bar-wrap .bar { flex: 1; }
.bar-wrap .ev { width: 66px; text-align: right; font-family: ui-monospace, monospace; font-size: 10px; }

.summary { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.sum-block { margin-bottom: 14px; }
.sum-head { font-size: 11px; color: var(--dim); margin-bottom: 6px; }
.sum-row { display: grid; grid-template-columns: 76px 1fr 38px; gap: 8px; align-items: center; margin-bottom: 5px; }
.sum-name { font-size: 11px; color: var(--dim); }
.sum-bars { display: flex; height: 14px; border-radius: 3px; overflow: hidden; background: #1a2029; }
.sum-bars .seg { display: block; height: 100%; }
.sum-pct { font-size: 10px; text-align: right; color: var(--dim); font-family: ui-monospace, monospace; }
.sum-list { margin: 0; padding-left: 16px; font-size: 11.5px; line-height: 1.8; color: #b9c3ce; }
.sum-list b { color: var(--fg); }

.done-box { padding: 22px 14px; text-align: center; background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; }
.done-box .big { font-size: 17px; font-weight: 700; margin-bottom: 8px; }
.note.ok { color: #56d364; background: rgba(46,160,67,.08); border-color: rgba(46,160,67,.3); }
/* ================= scrollbars (unified) ================= */
* { scrollbar-width: thin; scrollbar-color: #3a4552 transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: #3a4552; border-radius: 6px;
  border: 2px solid transparent; background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: #4e5b6b; background-clip: padding-box; }
::-webkit-scrollbar-thumb:active { background: var(--accent); background-clip: padding-box; }
::-webkit-scrollbar-corner { background: transparent; }

/* ================= progress bars (unified with scrollbars) ================= */
progress {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 6px; border: none; border-radius: 3px;
  background: #1d232c; overflow: hidden;
}
progress::-webkit-progress-bar { background: #1d232c; border-radius: 3px; }
progress::-webkit-progress-value { background: var(--accent); border-radius: 3px; }
progress::-moz-progress-bar { background: var(--accent); border-radius: 3px; }

/* ================= column resizer ================= */
.resizer {
  cursor: col-resize; background: var(--line); position: relative;
  transition: background .12s; z-index: 5;
}
.resizer::after { content: ''; position: absolute; top: 0; bottom: 0; left: -3px; right: -3px; }
.resizer:hover { background: var(--accent); }
body.resizing { user-select: none; }
body.resizing .resizer { background: var(--accent); }
body.resizing * { cursor: col-resize !important; }

/* ================= action line delete ================= */
.line-toolbar { display: flex; justify-content: flex-end; padding: 0 2px 5px; }
.line-item { position: relative; padding-right: 24px; }
.line-del {
  position: absolute; top: 3px; right: 3px;
  width: 18px; height: 18px; padding: 0; line-height: 16px;
  border-radius: 4px; border: 1px solid transparent; background: transparent;
  color: #5d6b7a; cursor: pointer; font-size: 15px; font-weight: 700;
  opacity: 0; transition: opacity .12s, background .12s, color .12s, border-color .12s;
}
.line-item:hover .line-del { opacity: 1; }
.line-del:hover { background: rgba(218, 54, 51, .2); color: #ff7b72; border-color: rgba(218, 54, 51, .45); }
.line-del:active { transform: scale(.92); }
/* ================= coach panel ================= */
.col.solver { display: flex; flex-direction: column; border-right: none; }
#solver-panel { flex: 1 1 auto; overflow: auto; }
.coach {
  flex: 0 0 auto; display: flex; flex-direction: column;
  border-top: 1px solid var(--line); background: var(--bg2);
  max-height: 46vh;
}
.coach-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.coach-title { font-weight: 600; font-size: 13px; }
.coach-tag { font-size: 10px; color: var(--dim); flex: 1; }
.coach-body { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.coach-body.hidden { display: none; }
.coach-insights { overflow: auto; padding: 8px 12px; border-bottom: 1px solid var(--line); max-height: 26vh; }
.coach-hint { padding: 10px 2px; font-size: 11.5px; line-height: 1.6; }
.ins { display: grid; grid-template-columns: 62px 1fr; gap: 8px; padding: 4px 0; font-size: 11.5px; line-height: 1.55; }
.ins-k { color: var(--dim); font-size: 10.5px; padding-top: 1px; }
.ins-v { color: #c3ccd6; }
.coach-log { overflow: auto; padding: 8px 12px; min-height: 44px; max-height: 18vh; display: flex; flex-direction: column; gap: 6px; }
.coach-log:empty { display: none; }
.msg { font-size: 12px; line-height: 1.6; padding: 6px 10px; border-radius: 8px; max-width: 92%; }
.msg.me { align-self: flex-end; background: #1b3352; border: 1px solid #2b4a72; color: #cfe3ff; }
.msg.bot { align-self: flex-start; background: #1a2029; border: 1px solid var(--line); color: #c8d1da; }
.coach-input { display: flex; gap: 8px; padding: 8px 12px 10px; }
.coach-input input {
  flex: 1; background: var(--bg); color: var(--fg); border: 1px solid var(--line);
  border-radius: 6px; padding: 7px 10px; font-size: 12.5px; font-family: inherit;
}
.coach-input input:focus { outline: none; border-color: var(--accent); }
/* ================= algorithm ladder ================= */
.algo-select {
  background: var(--bg); color: var(--fg); border: 1px solid var(--line);
  border-radius: 6px; padding: 9px 10px; font-size: 12px; max-width: 100%;
  font-family: ui-monospace, Consolas, monospace; cursor: pointer;
}
.algo-select:hover { border-color: #3d4a59; }

/* ================= simplification-cost audit ================= */
.audit { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.audit:empty { display: none; }
.audit-head { font-size: 11px; color: var(--dim); margin-bottom: 8px; }
.audit-big { font-size: 24px; font-weight: 700; font-family: ui-monospace, monospace; line-height: 1.1; }
.audit-big span { font-size: 12px; font-weight: 400; color: var(--dim); }
.audit-big.good { color: var(--green); }
.audit-big.warn { color: var(--amber); }
.audit-big.bad { color: var(--red); }
.audit-note { margin: 6px 0 8px; line-height: 1.55; }
.audit-split { margin: 8px 0 6px; }
.audit-row {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 12px; padding: 3px 0; color: #b9c3ce;
}
.audit-row b { font-family: ui-monospace, monospace; color: var(--fg); }
.audit-bar { height: 5px; border-radius: 3px; background: #1d232c; overflow: hidden; margin: 6px 0 8px; }
.audit-bar i { display: block; height: 100%; background: var(--amber); }
.audit-run { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--dim); line-height: 1.6; }
.spin.sm { width: 14px; height: 14px; border-width: 2px; flex: 0 0 auto; }
/* ================= action-line navigation ================= */
.line-item { cursor: pointer; transition: border-color .12s, background .12s, opacity .12s; }
.line-item .li-head, .line-item .li-body { pointer-events: none; }
.line-item:hover { border-color: #3d4a59; }
.line-item.done { opacity: .5; }
.line-item.cursor { border-color: var(--accent); background: #16243a; }
.line-item.cursor .li-head { color: var(--accent); }
.line-item.cursor-now { opacity: .8; border-style: dashed; cursor: default; }
.line-item.cursor-now .li-head { color: var(--green); }
/* ================= suit-aware tooltip ================= */
.cell-tip { min-width: 210px; max-width: 300px; }
.tip-badge {
  font-size: 9px; font-weight: 500; background: rgba(59,130,246,.18);
  color: #8ab4f8; border: 1px solid rgba(59,130,246,.4);
  padding: 1px 5px; border-radius: 3px; margin-left: 4px;
}
.tip-split { margin-top: 6px; padding-top: 6px; border-top: 1px solid #263040; }
.tip-combo { display: flex; align-items: center; gap: 6px; padding: 2px 0; font-size: 11px; }
.tip-card { font-family: ui-monospace, monospace; font-weight: 700; font-size: 11px; }
.tip-card + .tip-card { margin-left: -3px; }
.tip-mini { display: flex; flex: 1; height: 7px; border-radius: 3px; overflow: hidden; background: #1a2029; min-width: 46px; }
.tip-mini i { display: block; height: 100%; }
.tip-pct { font-family: ui-monospace, monospace; font-size: 10px; font-weight: 600; min-width: 44px; text-align: right; }
.tip-more { font-size: 10px; padding-top: 3px; }
/* ================= bet-size picker ================= */
.size-block { background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; }
.size-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; font-size: 11.5px; color: #b9c3ce; margin-bottom: 7px; }
.size-row { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; }
.chip {
  padding: 4px 10px; border-radius: 14px; font-size: 12px; cursor: pointer;
  background: var(--bg); color: var(--dim); border: 1px solid var(--line);
  font-family: ui-monospace, monospace; transition: all .12s;
}
.chip:hover { border-color: #3d4a59; color: var(--fg); }
.chip.on { background: #1b3352; border-color: var(--accent); color: #cfe3ff; font-weight: 600; }
.size-input {
  flex: 1; min-width: 90px; background: var(--bg); color: var(--fg);
  border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px;
  font-size: 12px; font-family: ui-monospace, monospace;
}
.slot.hole { outline: 1px dashed #3d4a59; outline-offset: 2px; border-radius: 6px; }
.slot.hole.armed { outline: 2px solid var(--accent); }

/* ================= result toolbar ================= */
.grid-hint { margin: -4px 0 10px; text-align: center; }
.grid-toolbar { display: flex; gap: 8px; margin-bottom: 8px; }
.grid-toolbar .btn.active { background: #1b2b42; border-color: var(--accent); color: #cfe3ff; }

/* ================= my hand ================= */
.hand-box {
  margin-top: 14px; padding: 10px 12px; border-radius: 8px;
  background: var(--bg2); border: 1px solid var(--line);
}
.hand-head { font-size: 13px; font-weight: 600; margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.hand-head .card { min-width: 24px; height: 32px; font-size: 12px; }
.hand-row { display: grid; grid-template-columns: 10px 1fr 46px 64px; gap: 7px; align-items: center; padding: 3px 0; font-size: 12px; }
.hand-row.best { color: var(--green); }
.hand-lbl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hand-freq { text-align: right; font-family: ui-monospace, monospace; }
.hand-ev { text-align: right; font-family: ui-monospace, monospace; font-size: 11px; }
.hand-verdict { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); font-size: 12px; line-height: 1.55; color: #c8d1da; }

.eval-banner {
  padding: 9px 12px; border-radius: 6px; margin-bottom: 10px; font-size: 12.5px; line-height: 1.5;
  border: 1px solid var(--line); background: var(--bg2);
}
.eval-banner.good { border-color: rgba(46,160,67,.45); background: rgba(46,160,67,.08); color: #b7f0c4; }
.eval-banner.bad { border-color: rgba(218,54,51,.45); background: rgba(218,54,51,.08); color: #ffc4c0; }

/* ================= report modal ================= */
.report-panel {
  position: fixed; z-index: 120; left: 50%; top: 12vh; transform: translateX(-50%);
  width: min(620px, 92vw); background: var(--bg2); border: 1px solid var(--line);
  border-radius: 10px; padding: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.65);
}
.report-head { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.report-sub { font-size: 11.5px; color: var(--dim); line-height: 1.6; margin-bottom: 10px; }
.report-sub code { background: var(--bg); padding: 1px 5px; border-radius: 3px; font-size: 11px; }
.report-panel textarea {
  width: 100%; height: 140px; background: var(--bg); color: var(--fg);
  border: 1px solid var(--line); border-radius: 6px; padding: 10px;
  font-size: 12.5px; font-family: inherit; resize: vertical; line-height: 1.6;
}
.report-actions { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
/* ================= abort button / audit CTA ================= */
.btn.abort {
  border-color: rgba(218,54,51,.5); color: #ff9b95; background: rgba(218,54,51,.1);
}
.btn.abort:hover { background: rgba(218,54,51,.22); border-color: rgba(218,54,51,.8); }
.btn.abort:disabled { opacity: .5; }
.solving .btn.abort { margin-top: 4px; }
.audit-cta { margin-top: 16px; }
.audit-cta .btn { width: 100%; }
.metric .btn.small { padding: 1px 8px; font-size: 11px; }

/* two players' hole cards need a bit more room */
.slot-row { gap: 10px 16px; }
/* ================= slot rows: hands on top, board below ================= */
.slot-row.hands-row { gap: 18px; margin-bottom: 10px; }
.slot-row.board-row { gap: 10px; align-items: center; }
.slot-row .slot-cap { font-size: 10px; letter-spacing: .04em; }
.slot-group .slot.hole { transform: scale(.94); }

/* bet-size legend swatches should read as a gradient */
.legend .sw { box-shadow: inset 0 0 0 1px rgba(0,0,0,.25); }

/* ================= phones (portrait) =================
   The desktop UI is four columns side by side.  On a phone they stack in reading
   order (行动线 → 局面 → 结果), the draggable resizer disappears, and hover is
   replaced by tap.  Everything here is layout only — no behaviour is forked.   */
.jump-pill {
  position: fixed; left: 50%; bottom: 12px; transform: translateX(-50%); z-index: 80;
  display: none; gap: 4px; padding: 4px; border-radius: 999px;
  background: rgba(22,27,34,.96); border: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(0,0,0,.6);
}
.jump-pill button {
  border: 0; background: transparent; color: var(--fg);
  font-size: 12px; padding: 7px 14px; border-radius: 999px; cursor: pointer;
}
.jump-pill button:active { background: var(--bg3); }

@media (max-width: 820px) {
  body { height: auto; min-height: 100vh; overflow-y: auto; overflow-x: hidden; }
  /* not sticky: on a 844px-tall screen a 110px header costs too much reading room */
  header { position: static; flex-wrap: wrap; gap: 5px 8px; padding: 6px 9px; }
  #detail, #solver-panel, .col.line { scroll-margin-top: 8px; }
  .brand { font-size: 13.5px; }
  .brand .ver { display: none; }
  .head-actions { margin-left: auto; gap: 6px; }
  .mode-switch { order: 4; padding: 2px; }
  .btn { padding: 5px 9px; font-size: 12px; }
  .btn.big { padding: 9px 16px; }

  main { display: flex; flex-direction: column; }
  .col { border-right: none; border-bottom: 1px solid var(--line); overflow: visible; }
  .col.line { max-height: 24vh; overflow-y: auto; }
  .col.solver { padding: 10px; }
  .resizer { display: none; }
  .col-title { position: static; padding: 7px 10px; }

  .deck { padding: 6px; gap: 2px; }
  .deck-row { grid-template-columns: repeat(13, 1fr); gap: 2px; }
  .card { min-width: 0; height: 32px; font-size: 12px; padding: 0; }
  .dcard { min-width: 0; height: 32px; font-size: 12px; }
  .card.small { min-width: 0; height: 30px; font-size: 11px; }
  .slot-row { gap: 8px 12px; }
  .range-tools { flex-wrap: wrap; gap: 6px; }
  .range-cols { grid-template-columns: 1fr; }
  .cfg { grid-template-columns: auto minmax(0, 1fr); }
  .metrics { gap: 6px; }
  /* the read-out becomes a bottom sheet so it never hides the grid it describes */
  .cell-tip {
    position: fixed; left: 8px; right: 8px; bottom: 60px; top: auto;
    max-width: none; max-height: 42vh; overflow: auto; font-size: 12px;
  }
  .grid-toolbar { gap: 6px; }
  .arow { grid-template-columns: 1fr 48px; }
  .hand-row { grid-template-columns: 8px 1fr 38px 54px; font-size: 11.5px; }
  .paste-panel { inset: auto 8px 8px 8px; }
  .report-panel { top: 8vh; width: min(620px, 94vw); padding: 12px; }
  .report-panel textarea { height: 120px; }
  .coach { display: none !important; }

  body.has-solution .jump-pill { display: flex; }
  body.has-solution { padding-bottom: 54px; }   /* keep the last card clear of the pill */
  /* no hover on a phone: the per-step delete button must always be visible */
  .line-del { opacity: .9; width: 22px; height: 22px; }
}

/* ---------------- abandoned branch (kept, never auto-deleted) ---------------- */
.line-stale-head {
  display: flex; align-items: center; gap: 6px; margin: 10px 2px 4px;
  padding-top: 8px; border-top: 1px dashed #3d4a59;
  font-size: 10px; letter-spacing: .05em; text-transform: uppercase; color: var(--dim);
}
.line-stale-head span { flex: 1; }
.line-item.stale {
  opacity: .45; border-style: dashed; background: transparent; padding-right: 9px;
  filter: grayscale(.35); cursor: default;
}
/* holding the left button can list all 12 combos: keep the panel scrollable */
.cell-tip { max-height: min(62vh, 420px); overflow-y: auto; overscroll-behavior: contain; }
.line-del.wide {
  position: static; opacity: .9; width: 20px; height: 20px;
  line-height: 18px; font-size: 13px;
}

@media (max-width: 820px) {
  /* the bottom sheet may grow to list every combo, but must leave the grid visible */
  .cell-tip { max-height: 46vh; }
}


