/* DZ 中控: a dense, flat console. Light by default, dark when the system
   asks or the viewer picks it (html[data-theme]). Sections are separated by
   lines, not boxed into cards; only tables and the game canvases get a frame. */
:root {
  --bg: #fafaf9;
  --panel: #ffffff;
  --panel-2: #f2f2f0;
  --line: #e5e5e2;
  --line-soft: #efefec;
  --text: #18181b;
  --muted: #62626a;
  --accent: #0f7b5f;
  --accent-text: #ffffff;
  --link: #2557d6;
  --ok: #15803d;
  --warn: #b45309;
  --bad: #b42318;
  --hover: #f4f4f2;
  --pick: #eef6f2;
  --shadow: 0 8px 24px rgba(24, 24, 27, .12);
  --tip: #ffffff;
  --code: #3f3f46;
  --score: #9a6700;
  --nick: #62626a;
  --tag-bg: #e7f1ed;
  --tag-text: #0a5240;
  --felt: #0f5a45;
  --felt-dark: #0a3f31;
  --felt-line: rgba(255, 255, 255, .08);
  --tile: #f6f1e3;
  --tile-edge: #d9cfb5;
  --tile-side: #1c7a5e;
  --man: #c0392b;
  --sou: #1e8a4c;
  --pin: #2563c9;
  --flower: #c46a12;
  --radius: 8px;
  /* Diverging pair for ledger charts. A gain is red and a loss blue, as on the
     game's result screen; the sign is always written as well. */
  --viz-pos: #e05252;
  --viz-neg: #2f7de1;
  --gain: #c62828;
  --loss: #1d5fd1;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1116; --panel: #151a21; --panel-2: #1c222b; --line: #2a313c; --line-soft: #222831;
    --text: #e6e9ee; --muted: #9aa3af; --accent: #34b98a; --accent-text: #08130f; --link: #7aa2ff;
    --ok: #3ccf8e; --warn: #f5b84a; --bad: #ff7a72; --hover: #1a2029; --pick: #15261f;
    --shadow: 0 8px 24px rgba(0, 0, 0, .45); --tip: #0b0f15; --code: #cdd6e3; --score: #ffd466; --nick: #d9c98f;
    --tag-bg: #183428; --tag-text: #8fe0bd; --viz-pos: #e66767; --viz-neg: #3987e5; --gain: #ff8a7a; --loss: #6fb0ff;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1116; --panel: #151a21; --panel-2: #1c222b; --line: #2a313c; --line-soft: #222831;
  --text: #e6e9ee; --muted: #9aa3af; --accent: #34b98a; --accent-text: #08130f; --link: #7aa2ff;
  --ok: #3ccf8e; --warn: #f5b84a; --bad: #ff7a72; --hover: #1a2029; --pick: #15261f;
  --shadow: 0 8px 24px rgba(0, 0, 0, .45); --tip: #0b0f15; --code: #cdd6e3; --score: #ffd466; --nick: #d9c98f;
  --tag-bg: #183428; --tag-text: #8fe0bd; --viz-pos: #e66767; --viz-neg: #3987e5; --gain: #ff8a7a; --loss: #6fb0ff;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 13px/1.45 Inter, -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
.mono { font-family: var(--mono); font-size: 12px; font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

button {
  font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line);
  border-radius: 6px; height: 28px; padding: 0 10px; cursor: pointer; white-space: nowrap;
}
button:hover { background: var(--hover); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 500; }
button.primary:hover { filter: brightness(1.08); background: var(--accent); }
button.danger { color: var(--bad); }
button.ghost { background: transparent; border-color: transparent; }
button.ghost:hover { background: var(--hover); }
button.confirm { background: var(--bad); color: #fff; border-color: var(--bad); }
button:disabled { opacity: .45; cursor: default; }
button.small { height: 24px; padding: 0 8px; font-size: 12px; }
button.icon { height: 26px; min-width: 26px; padding: 0 6px; line-height: 1; background: transparent; border-color: transparent; color: var(--muted); }
button.icon:hover { color: var(--text); background: var(--hover); }
input[type="date"], input[type="text"], input[type="search"], input[type="number"], input[type="password"], input:not([type]), select {
  font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 6px; height: 28px; padding: 0 8px;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }

/* ---- Top bar ---- */
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px;
  height: 48px; padding: 0 16px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.logo {
  display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 5px;
  background: var(--accent); color: var(--accent-text); font-size: 12px; font-weight: 600;
}
.tabs { display: flex; gap: 2px; }
.tabs a { padding: 5px 10px; border-radius: 6px; color: var(--muted); white-space: nowrap; flex: none; }
.tabs a:hover { color: var(--text); }
.tabs a.active { background: var(--panel-2); color: var(--text); font-weight: 500; }
.count { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: 2px; }
.link { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.me { color: var(--text); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); flex: none; display: inline-block; }
.dot.on { background: var(--ok); }
.dot.off { background: var(--bad); }
.dot.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }

main { padding: 0 16px 24px; max-width: 1600px; margin: 0 auto; }

/* ---- 代理警告 ---- */
.alert-wrap { padding: 0 16px; max-width: 1600px; margin: 0 auto; }
.alerts {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-top: 12px; padding: 10px 14px;
  border: 1px solid color-mix(in srgb, var(--bad) 40%, transparent); border-left: 4px solid var(--bad); border-radius: var(--radius);
  background: color-mix(in srgb, var(--bad) 8%, var(--panel)); color: var(--text);
}
.alerts[hidden] { display: none; }
.alerts .alert-body { flex: 1 1 320px; display: grid; gap: 3px; min-width: 0; overflow-wrap: anywhere; }
.alerts .alert-body > b { color: var(--bad); }
.alerts .alert-body .muted { font-size: 12px; }
.alerts .alert-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.alerts a.button.small { height: 24px; padding: 0 8px; font-size: 12px; }
.empty { padding: 48px 16px; text-align: center; color: var(--muted); }
.section-head { display: flex; align-items: baseline; gap: 10px; margin: 0; padding: 14px 0 12px; }
.section-head h1 { font-size: 15px; margin: 0; font-weight: 600; }
.section-head .sub { color: var(--muted); }
.spacer { flex: 1; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.note { color: var(--muted); font-size: 12px; margin-top: 8px; }
.head-link { margin-left: auto; color: var(--link); }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table.grid { width: 100%; border-collapse: collapse; }
.grid th, .grid td { height: 40px; padding: 0 10px; border-bottom: 1px solid var(--line-soft); text-align: left; white-space: nowrap; vertical-align: middle; }
.grid thead th { height: 34px; color: var(--muted); font-weight: 500; font-size: 12px; background: var(--panel); position: sticky; top: 0; z-index: 1; border-bottom-color: var(--line); }
.grid tbody tr:hover td { background: var(--hover); }
.grid tr:last-child td { border-bottom: 0; }
.grid tr.offline td { color: var(--muted); }
.grid .num { text-align: right; font-variant-numeric: tabular-nums; }
.grid .actions { display: flex; gap: 6px; }
.grid tr.picked td { background: var(--pick); }
.badge { display: inline-block; padding: 0 7px; border-radius: 4px; font-size: 12px; line-height: 20px; background: var(--panel-2); color: var(--text); }
.badge.ok { background: color-mix(in srgb, var(--ok) 13%, transparent); color: var(--ok); }
.badge.warn { background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn); }
.badge.bad { background: color-mix(in srgb, var(--bad) 13%, transparent); color: var(--bad); }
.badge.blue { background: color-mix(in srgb, var(--link) 13%, transparent); color: var(--link); }
.room-link { color: var(--link); font-weight: 500; }
.room-link:hover { text-decoration: underline; }
.chips { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.chip { height: 26px; padding: 0 10px; border-radius: 13px; font-size: 12px; color: var(--muted); background: var(--panel); }
.chip.on { color: var(--accent); border-color: var(--accent); background: var(--pick); }
a.button { display: inline-flex; align-items: center; height: 28px; padding: 0 10px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); }
a.button:hover { background: var(--hover); }
.tag { display: inline-block; padding: 0 6px; margin-left: 4px; border-radius: 4px; font-size: 11px; line-height: 18px; background: var(--tag-bg); color: var(--tag-text); white-space: nowrap; }
.tag.plain { background: var(--panel-2); color: var(--muted); margin-left: 0; }

/* ---- Flat sections (formerly cards) ---- */
.panel { background: none; border: 0; border-radius: 0; padding: 0; }
.panel + .panel { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.panel h2 { font-size: 12px; margin: 0 0 8px; color: var(--muted); font-weight: 600; letter-spacing: .02em; }
.panel .btns { display: flex; flex-wrap: wrap; gap: 6px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; }

/* ---- Room view ---- */
.room-view { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.room-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 0; }
.room-bar h1 { font-size: 15px; margin: 0; }
.room-bar .back { color: var(--muted); }
.room-bar .persp { display: flex; gap: 4px; align-items: center; color: var(--muted); font-size: 12px; }
.room-bar .persp button { height: 24px; padding: 0 8px; }
.room-bar .persp button.on { border-color: var(--accent); color: var(--accent); }
.reporter { padding: 8px 0; border-top: 1px solid var(--line-soft); }
.reporter:first-of-type { border-top: 0; padding-top: 0; }
.reporter .row { display: flex; align-items: center; gap: 6px; }
.reporter .row.head { flex-wrap: wrap; }
.reporter .who { font-weight: 600; }
.reporter .status { color: var(--muted); font-size: 12px; margin: 3px 0 6px; }
.reporter .btns button { height: 24px; padding: 0 8px; font-size: 12px; }

.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 50; }
.toast { padding: 8px 14px; border-radius: 6px; background: var(--text); color: var(--bg); box-shadow: var(--shadow); animation: pop .2s ease-out both; }
.toast.bad { background: var(--bad); color: #fff; }
@keyframes pop { from { transform: translateY(4px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (max-width: 980px) { .room-view { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 720px) {
  .top { height: auto; flex-wrap: wrap; gap: 8px; padding: 8px 16px; }
  .tabs { order: 3; width: 100%; overflow-x: auto; }
  .link { margin-left: auto; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---- Ledger ---- */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-bottom: 12px; }
.filters .custom { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.kpis { display: grid; grid-template-columns: 1.4fr repeat(4, 1fr); margin: 0 0 16px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.kpi { padding: 12px 16px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kpi:first-child { padding-left: 0; }
.kpi + .kpi { border-left: 1px solid var(--line-soft); }
.kpi .label { color: var(--muted); font-size: 12px; }
.kpi .value { font-size: 22px; font-weight: 600; }
.kpi.hero .value { font-size: 34px; line-height: 1.1; }
.kpis.six { grid-template-columns: 1.4fr repeat(5, 1fr); }
.kpi .value .unit { margin-left: 3px; color: var(--muted); font-size: 13px; font-weight: 400; }
.section-head .sub a { color: var(--link); margin: 0 2px; }
.grid.club-cost td:first-child { width: 50%; }
.kpi .hint { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.charts { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 24px; margin-bottom: 16px; align-items: start; }
.charts .chart:only-child { grid-column: 1 / -1; }
.chart { margin: 0; }
.chart figcaption { color: var(--muted); font-size: 12px; font-weight: 600; margin-bottom: 8px; }
.chart-box { position: relative; min-height: 60px; }
.chart-box svg { display: block; overflow: visible; }
.chart-box .grid { stroke: var(--line); stroke-width: 1; }
.chart-box .zero { stroke: var(--muted); stroke-width: 1; }
.chart-box .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-box .hit { fill: transparent; cursor: default; }
.chart-box .hit.on { fill: var(--hover); }
.tip {
  position: absolute; display: none; z-index: 3; pointer-events: none; padding: 6px 10px; border-radius: 6px; white-space: nowrap;
  background: var(--tip); border: 1px solid var(--line); box-shadow: var(--shadow); font-size: 12px; line-height: 1.5;
}
.hbars { display: grid; gap: 4px; }
.hbar { display: grid; grid-template-columns: minmax(60px, 120px) 1fr 76px; align-items: center; gap: 8px; padding: 2px 0; }
.hbar:hover { background: var(--hover); border-radius: 4px; }
.hbar .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .val { text-align: right; font-variant-numeric: tabular-nums; }
.hbar .track { position: relative; height: 14px; }
.hbar .zero { position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--muted); }
.hbar .fill { position: absolute; top: 0; bottom: 0; }
.hbar .fill.pos { background: var(--viz-pos); border-radius: 0 3px 3px 0; }
.hbar .fill.neg { background: var(--viz-neg); border-radius: 3px 0 0 3px; }
.grid.ledger tr.total td { font-weight: 600; border-top: 1px solid var(--line); }
.grid td.strong { font-weight: 600; }
.grid td.tai-text { max-width: 260px; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.sub-head { margin-top: 8px; }
.sub-head h2 { font-size: 14px; margin: 0; }
.pager { display: inline-flex; gap: 6px; }
@media (max-width: 980px) {
  .kpis, .kpis.six { grid-template-columns: repeat(2, 1fr); }
  .kpi.hero { grid-column: 1 / -1; padding-left: 0; }
  .kpi + .kpi { border-left: 0; }
  .charts { grid-template-columns: minmax(0, 1fr); }
}

/* ---- History & replay ---- */
.grid td.players-cell { white-space: normal; }
.players-cell .names { display: flex; flex-wrap: wrap; gap: 2px 10px; max-width: 380px; }
/* History: the team's net per game, green when it won and red when it lost. */
.h-totals { display: flex; flex-wrap: wrap; gap: 8px 22px; align-items: baseline; padding: 10px 14px; margin-bottom: 12px;
  border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: 8px; background: var(--panel); }
.h-totals:empty { display: none; }
.h-code { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; padding: 12px 14px; margin-bottom: 12px; }
.h-code > div:first-child { display: flex; flex-direction: column; gap: 2px; flex: 1 1 220px; }
.h-code .muted { font-size: 12px; }
.h-code-result { flex: 2 1 260px; }
.h-totals.won { border-left-color: var(--ok); }
.h-totals.lost { border-left-color: var(--bad); }
.h-total { display: inline-flex; align-items: baseline; gap: 8px; }
.h-total i { font-style: normal; color: var(--muted); font-size: 12px; }
.h-total b { font-size: 18px; font-variant-numeric: tabular-nums; }
.h-total .badge { align-self: center; }
.net-won { color: var(--ok); }
.net-lost { color: var(--bad); }
.grid td.net .badge { margin-right: 6px; }
.grid tr.won td:first-child { box-shadow: inset 3px 0 var(--ok); }
.grid tr.lost td:first-child { box-shadow: inset 3px 0 var(--bad); }
.players-cell .own::before { content: "●"; color: var(--ok); margin-right: 4px; font-size: 10px; }
.players-cell .other::before { content: "●"; color: var(--warn); margin-right: 4px; font-size: 10px; }
/* Seated only before the first deal: grey, after everyone who played. */
.players-cell .early { color: var(--muted); opacity: .6; }
.players-cell .early::before { color: var(--muted); }
.player { margin-top: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.transport { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.transport button { min-width: 36px; }
.transport .play { min-width: 52px; background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.transport .r-time { color: var(--muted); font-variant-numeric: tabular-nums; margin-left: 6px; }
.transport .live-btn { margin-left: auto; color: var(--ok); }
#r-seek { width: 100%; margin: 10px 0 6px; accent-color: var(--accent); }
.hands { display: flex; flex-wrap: wrap; gap: 4px; }
.packets-panel { display: flex; flex-direction: column; gap: 8px; }
.packets-head { display: flex; gap: 6px; align-items: center; }
.packets-head select { flex: 1; min-width: 0; }
.packet-list {
  height: 360px; overflow-y: auto; border: 1px solid var(--line); border-radius: 6px; background: var(--panel);
  font: 12px/1.5 var(--mono); position: relative;
}
.pk { display: grid; grid-template-columns: 92px 24px 54px 1fr auto; gap: 6px; padding: 2px 8px; cursor: pointer; white-space: nowrap; }
.pk:hover { background: var(--hover); }
.pk .pn { overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-family: inherit; }
.pk .pl { color: var(--muted); }
.pk.tx .pd { color: var(--link); }
.pk.rx .pd { color: var(--ok); }
.pk.future { opacity: .35; }
.pk.current { background: var(--pick); }
.pk.picked { outline: 1px solid var(--accent); outline-offset: -1px; }
.hexdump {
  margin: 0; min-height: 120px; max-height: 260px; overflow: auto; padding: 8px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--panel); font: 11.5px/1.5 var(--mono); color: var(--code); white-space: pre;
}

/* ---- Play settings ---- */
.batch-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 0 0 12px; }
.batch-bar .sep { width: 1px; height: 18px; background: var(--line); }
.batch-bar .note { margin: 0; flex-basis: 100%; }
.batch-bar input { width: 120px; }
label.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--accent); margin: 0; }

/* ---- Settings (打牌參數, 配房參數): rows of name + hint | control ---- */
.set-group { margin-top: 26px; }
.set-form .set-group > h2 { font-size: 13px; font-weight: 600; margin: 0 0 4px; }
.set-note { color: var(--muted); font-size: 12px; margin: 0 0 6px; }
.set-list { container-type: inline-size; border-top: 1px solid var(--line); }
.set-row {
  display: grid; grid-template-columns: minmax(200px, 5fr) 6fr; gap: 8px 32px; align-items: start;
  padding: 12px 2px; border-bottom: 1px solid var(--line-soft);
}
.set-label b { font-weight: 500; }
.set-label p { margin: 3px 0 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.set-ctl { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
.set-row.off, .set-ctl .off { opacity: .4; }
@container (max-width: 600px) { .set-row { grid-template-columns: 1fr; } }
.set-num { display: inline-flex; align-items: center; gap: 6px; }
.set-num input { width: 84px; }
.set-ctl .unit, .set-ctl .dash { color: var(--muted); }
.set-ctl .sep { margin-left: 8px; }
.seg-radio { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 2px; border-radius: 7px; background: var(--panel-2); }
.seg-radio label { position: relative; }
.seg-radio input, .opt-list input { position: absolute; opacity: 0; pointer-events: none; }
.seg-radio span { display: inline-block; padding: 4px 12px; border-radius: 5px; color: var(--muted); cursor: pointer; }
.seg-radio input:checked + span { background: var(--panel); color: var(--text); font-weight: 500; box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
.seg-radio input:focus-visible + span, .opt-list input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.opt-list { display: grid; gap: 6px; width: 100%; }
.opt-list label { position: relative; display: block; padding: 8px 12px; border: 1px solid var(--line); border-radius: 7px; cursor: pointer; }
.opt-list label:hover { background: var(--hover); }
.opt-list label:has(input:checked) { border-color: var(--accent); background: var(--pick); }
.opt-list b { font-weight: 500; }
.opt-list small { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.set-more { margin-top: 26px; }
.set-more > summary { cursor: pointer; color: var(--muted); }
.set-more .set-group { margin-top: 10px; }

/* ---- Sign-in, users ---- */
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-card { width: min(340px, 100%); display: grid; gap: 14px; }
.login-card .brand { margin-bottom: 6px; font-size: 16px; }
.login-card label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; }
.login-card input { height: 36px; }
.login-card button { height: 36px; }
.login-error { color: var(--bad); min-height: 1em; }
.user-form { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---- Amounts (Money in app.js): sign and grouping always written ---- */
.money { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.money small { font-size: .62em; font-weight: 500; margin-left: .2em; opacity: .75; }
.money.gain, .gain { color: var(--gain); }
.money.loss, .loss { color: var(--loss); }
.money.even { color: var(--muted); }
.money.big { font-size: 28px; font-weight: 600; line-height: 1.15; letter-spacing: -.01em; }
.money.chip { font-size: 12px; padding: 0 6px; border-radius: 4px; background: var(--panel-2); height: auto; }
.kpi.hero .money.big { font-size: 34px; }
.kpi .value .money { font-size: inherit; }
.flow { display: grid; gap: 4px; margin-top: 6px; }
.flow .bar { display: flex; height: 5px; border-radius: 3px; overflow: hidden; background: var(--line); }
.flow .in { background: var(--viz-pos); }
.flow .out { background: var(--viz-neg); }
.flow .legend { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.acct-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); column-gap: 24px; margin-bottom: 16px; }
.acct-card { padding: 10px 0; border-top: 1px solid var(--line); display: grid; gap: 4px; min-width: 0; }
.acct-card .acct-top { display: flex; justify-content: space-between; gap: 8px; }
.acct-card .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-card .money.big { font-size: 22px; }
.acct-card .stats { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--muted); }
.acct-card .stats b { color: var(--text); font-weight: 600; }
.spark { width: 100%; height: 28px; display: block; }
.spark path { fill: none; stroke-width: 1.6; vector-effect: non-scaling-stroke; }
.spark.gain path { stroke: var(--viz-pos); }
.spark.loss path, .spark.even path { stroke: var(--viz-neg); }
.spark .zero { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }

/* ---- Original-art tables (table.js): 1280×720 canvases ---- */
.game-canvas { display: block; width: 100%; aspect-ratio: 16 / 9; border-radius: 8px; background: #0b3a2c; }
.canvas-wrap { min-width: 0; }
.canvas-wrap .game-canvas { box-shadow: var(--shadow); }
#replay-board-wrap .game-canvas { margin: 0 auto; width: min(100%, calc((100vh - 280px) * 16 / 9)); }

/* ---- 牌桌 grid ---- */
.wall-head { flex-wrap: wrap; align-items: center; }
.wall-grid { display: grid; gap: 20px 16px; grid-template-columns: repeat(auto-fill, minmax(460px, 1fr)); }
.wall-grid[data-cols="1"] { grid-template-columns: minmax(0, 1fr); }
.wall-grid[data-cols="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.wall-grid[data-cols="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.wall-grid > .empty { grid-column: 1 / -1; }
.wall-cell { min-width: 0; }
.cell-head { display: flex; align-items: center; gap: 10px; padding: 0 2px 6px; min-width: 0; white-space: nowrap; }
.cell-head b { font-size: 14px; }
.cell-head .where { color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.cell-head:hover b { color: var(--link); }
/* The table's state over the canvas: phase and turn, the team's net over the
   game and the settled hand, the last hand. A side bar marks a team ahead or
   behind, in the amounts' own colours. */
.cell-sum {
  display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.6fr); gap: 8px;
  padding: 6px 8px; margin-bottom: 6px; border-radius: 6px; background: var(--panel-2); box-shadow: inset 3px 0 0 transparent;
}
.wall-cell.won .cell-sum { box-shadow: inset 3px 0 0 var(--gain); }
.wall-cell.lost .cell-sum { box-shadow: inset 3px 0 0 var(--loss); }
.cell-sum > span { display: flex; flex-direction: column; min-width: 0; }
.cell-sum i { font-style: normal; font-size: 11px; color: var(--muted); white-space: nowrap; }
.cell-sum b { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-sum .money small { display: none; }
.cell-sum .dim { opacity: .45; }
/* Every seated player in fixed columns: switch, wind, name, the game's
   change, wins, self-draws, deal-ins, status. */
.seat-rows { display: grid; gap: 0; margin-top: 6px; }
.seat-row {
  display: grid; grid-template-columns: 30px 20px minmax(0, 1.3fr) 68px 22px 30px 30px minmax(0, 1.4fr); align-items: center; gap: 6px;
  padding: 4px 6px; border-bottom: 1px solid var(--line-soft); box-shadow: inset 2px 0 0 transparent;
}
.seat-row.seat-labels { padding-top: 0; padding-bottom: 2px; font-size: 11px; color: var(--muted); white-space: nowrap; }
.seat-row .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.seat-row.turn { box-shadow: inset 2px 0 0 var(--warn); }
.seat-row.out { background: color-mix(in srgb, var(--warn) 4%, transparent); }
.seat-row .switch.off { visibility: hidden; }
.seat-row .wind {
  width: 20px; height: 20px; display: grid; place-items: center; border-radius: 5px;
  background: var(--panel-2); font-size: 11px; color: var(--muted);
}
.seat-row .wind:empty { background: transparent; }
.seat-row .wind.banker { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.seat-row .who { display: flex; align-items: baseline; gap: 6px; min-width: 0; overflow: hidden; white-space: nowrap; }
.seat-row .who b { overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.seat-row.ting .who b::after { content: "聽"; margin-left: 4px; font-size: 11px; color: var(--bad); font-weight: 500; }
.seat-row .tag:empty { display: none; }
.seat-row .tag { flex: none; font-size: 11px; padding: 0 5px; border-radius: 4px; line-height: 17px; }
.seat-row .tag.own { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.seat-row .tag.out { background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn); }
.seat-row .wins, .seat-row .self, .seat-row .deal { color: var(--muted); font-size: 12px; }
.seat-row .status { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat-row.manual .status { color: var(--warn); }
@media (max-width: 560px) {
  .cell-sum { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .seat-row { grid-template-columns: 30px 20px minmax(0, 1fr) 68px minmax(0, 1fr); }
  .seat-row .wins, .seat-row .self, .seat-row .deal { display: none; }
}
.canvas-link { display: block; }
.canvas-link:hover .game-canvas { outline: 2px solid var(--link); outline-offset: 1px; }
.switch { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; color: var(--muted); user-select: none; flex: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch span { position: relative; width: 30px; height: 18px; border-radius: 9px; background: var(--line); transition: background .2s; }
.switch span::after { content: ""; position: absolute; left: 2px; top: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); transition: transform .2s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(12px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.totals { display: flex; flex-wrap: wrap; margin-bottom: 12px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.totals:empty { display: none; }
.total-card { padding: 10px 24px 10px 0; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.total-card + .total-card { padding-left: 24px; border-left: 1px solid var(--line-soft); }
.total-card .label { color: var(--muted); font-size: 12px; }
.total-card .value { font-size: 22px; font-weight: 600; line-height: 1.15; }
.total-card .hint { color: var(--muted); font-size: 12px; }
@media (max-width: 980px) { .wall-grid, .wall-grid[data-cols] { grid-template-columns: minmax(0, 1fr); } }

/* ---- Chat ---- */
.chat-list {
  max-height: 240px; min-height: 60px; overflow-y: auto; border: 1px solid var(--line); border-radius: 6px; background: var(--panel);
  line-height: 1.45; padding: 4px 0;
}
.chat-list .note { margin: 6px 8px; }
.chat { display: grid; grid-template-columns: 62px auto 1fr; gap: 6px; padding: 2px 8px; cursor: pointer; }
.chat:hover { background: var(--hover); }
.chat .ct { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; }
.chat .cw { color: var(--link); white-space: nowrap; max-width: 110px; overflow: hidden; text-overflow: ellipsis; }
.chat .cx { overflow-wrap: anywhere; }
.chat.face .cx { color: var(--warn); }
.chat.future { opacity: .35; }
.chat.current { background: var(--pick); }
.chat-compose { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line-soft); }
.chat-compose.off { opacity: .5; pointer-events: none; }
.cc-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cc-label { color: var(--muted); font-size: 12px; width: 30px; flex: none; }
.cc-chips { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; min-width: 0; }
.cc-chips .chip.outsider:not(.on) { color: var(--warn); }
.cc-input { display: flex; gap: 6px; }
.cc-input input { flex: 1; min-width: 0; }
.cc-tools { gap: 6px; }
.cc-pop { position: relative; }
.cc-pop summary {
  list-style: none; cursor: pointer; height: 26px; display: inline-flex; align-items: center; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 13px; background: var(--panel); font-size: 12px; user-select: none;
}
.cc-pop summary::-webkit-details-marker { display: none; }
.cc-pop summary::after { content: " ▾"; color: var(--muted); margin-left: 2px; }
.cc-pop[open] summary { border-color: var(--accent); }
.cc-menu, .row-menu {
  position: absolute; z-index: 30; left: 0; top: calc(100% + 4px); width: 260px; max-height: 300px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 1px; padding: 4px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow);
}
.cc-menu button, .row-menu button { text-align: left; border-color: transparent; background: none; height: 30px; padding: 0 8px; }
.cc-menu button:hover, .row-menu button:hover, .row-menu button:focus-visible { background: var(--hover); outline: none; }
.cc-grid { display: grid; grid-template-columns: repeat(4, 1fr); width: 240px; }
.cc-grid button { text-align: center; }
.cc-faces { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.cc-faces button { display: flex; flex-direction: column; align-items: center; gap: 2px; height: auto; padding: 6px 4px; font-size: 12px; }
.cc-faces button span { font-size: 20px; line-height: 1.1; }

/* ---- Live room: the board fits the window; the side column scrolls alone ---- */
.room-cmds { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.room-cmds .muted { font-size: 12px; margin-right: 2px; }
.live-room { grid-template-columns: minmax(0, 1fr) 380px; }
.live-room .game-canvas { width: min(100%, calc((100vh - 150px) * 16 / 9)); margin: 0 auto; }
.live-room > aside, #replay-side {
  position: sticky; top: 60px; max-height: calc(100vh - 76px); overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin; padding-left: 16px; border-left: 1px solid var(--line);
}
#room-badges { display: inline-flex; gap: 6px; }

/* ---- 本場玩家 ---- */
.pp-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.pp-head h2 { margin: 0; }
.pp-hand { margin-left: auto; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pp-team { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; padding: 8px 0; margin-bottom: 8px; border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); }
.pp-team span { display: flex; flex-direction: column; min-width: 0; }
.pp-team i, .pl-line i { font-style: normal; font-size: 11px; color: var(--muted); white-space: nowrap; }
.pp-team b, .pl-line b { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pp-team b { font-size: 16px; }
/* Label and value on one line, in fixed columns so changing numbers never move anything. */
.pl-line { display: grid; gap: 6px; }
.pl-nums { grid-template-columns: 1.6fr 1fr 1fr 1fr; }
.pl-think { grid-template-columns: 1.6fr 1.2fr 1.4fr; }
.pl-line span { display: flex; align-items: baseline; gap: 5px; min-width: 0; }
.pp-team .dim { opacity: .45; }
.pl-list { display: flex; flex-direction: column; }
.pl {
  position: relative; padding: 8px 8px 8px 12px; border-bottom: 1px solid var(--line-soft);
  cursor: pointer; display: flex; flex-direction: column; gap: 4px;
}
.pl:hover { background: var(--hover); }
.pl::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 2px; background: transparent; }
.pl.turn::before { background: var(--ok); }
.pl.turn.late::before { background: var(--bad); }
.pl.base { background: var(--pick); }
.pl-top { display: flex; align-items: center; gap: 6px; min-width: 0; }
.pl-wind {
  flex: none; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 5px;
  background: var(--panel-2); font-size: 12px; color: var(--muted);
}
.pl-wind.banker { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.pl-name { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-tag { flex: none; font-size: 11px; padding: 0 6px; border-radius: 4px; line-height: 18px; }
.pl-tag.own { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.pl-tag.manual { background: color-mix(in srgb, var(--link) 14%, transparent); color: var(--link); }
.pl-tag.out { background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn); }
.pl.ting .pl-name::after { content: "聽"; margin-left: 6px; font-size: 11px; color: var(--bad); font-weight: 500; }
.pl-score { margin-left: auto; flex: none; font-variant-numeric: tabular-nums; color: var(--score); font-weight: 600; }
/* The running turn: clock and time on the name line, a bar along the row's
   bottom edge; every row keeps its height. */
.pl-clock, .pl-elapsed { visibility: hidden; flex: none; font-variant-numeric: tabular-nums; }
.pl.turn .pl-clock, .pl.turn .pl-elapsed { visibility: visible; }
.pl-clock {
  width: 26px; height: 20px; display: grid; place-items: center; border-radius: 5px; font-size: 12px;
  background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); font-weight: 700;
}
.pl.late .pl-clock { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }
.pl-elapsed { width: 44px; font-size: 12px; color: var(--muted); }
.pl-bar { position: absolute; left: 12px; right: 10px; bottom: 2px; height: 3px; border-radius: 2px; overflow: hidden; visibility: hidden; }
.pl.turn .pl-bar { visibility: visible; }
.pl-bar > span { display: block; height: 100%; background: var(--ok); transition: width .1s linear; }
.pl.late .pl-bar > span { background: var(--bad); }
.pl-foot { display: flex; align-items: center; gap: 6px; min-height: 24px; }
.pl-foot.empty { display: none; }
.pl-status { flex: 1; min-width: 0; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-btns { flex: none; display: flex; gap: 3px; }
.pl-btns.hidden { display: none; }
.pl-btns button { height: 22px; padding: 0 7px; font-size: 12px; }
.pl-btns .pl-auto { min-width: 44px; }
.chat-panel .chat-list { height: 180px; max-height: none; }
@media (max-width: 1180px) {
  .live-room { grid-template-columns: minmax(0, 1fr); }
  .live-room > aside { position: static; max-height: none; padding-left: 0; border-left: 0; }
}
.replay-room { grid-template-columns: minmax(0, 1fr) 380px; }
.replay-room .packets-panel .packet-list { height: 260px; }
@media (max-width: 1180px) {
  .replay-room { grid-template-columns: minmax(0, 1fr); }
  #replay-side { position: static; max-height: none; padding-left: 0; border-left: 0; }
}

/* ---- 客戶端 ---- */
.cl-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; min-height: 52px; padding: 10px 0; }
.cl-toolbar h1 { font-size: 15px; font-weight: 600; margin: 0; }
.cl-toolbar .sep { width: 1px; height: 18px; background: var(--line); }
.cl-toolbar.batch button:not(.primary):not(.ghost) { border-color: transparent; background: transparent; }
.cl-toolbar.batch button:not(.primary):not(.ghost):hover { background: var(--hover); }
.cl-toolbar #batch-room { width: 92px; }
.seg { display: inline-flex; gap: 2px; padding: 2px; border-radius: 7px; background: var(--panel-2); }
.seg button { height: 24px; padding: 0 10px; border: 0; border-radius: 5px; background: transparent; color: var(--muted); font-size: 12px; }
.seg button.on { background: var(--panel); color: var(--text); font-weight: 500; box-shadow: 0 1px 2px rgba(0, 0, 0, .1); }
.tag-filter { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.search input { width: clamp(180px, 15vw, 260px); }
.cl-body { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 16px; }
.cl-main { flex: 999 1 640px; min-width: 0; }
.cl-pane {
  flex: 1 1 300px; max-width: 380px; position: sticky; top: 60px; max-height: calc(100vh - 76px); overflow-y: auto;
  padding-left: 16px; border-left: 1px solid var(--line); display: flex; flex-direction: column; gap: 12px;
}
.pane-head { display: flex; align-items: flex-start; gap: 8px; }
.pane-head > div { flex: 1; min-width: 0; }
.pane-head h2 { font-size: 16px; margin: 0 0 2px; }
.cl-pane .kv { padding: 10px 0; border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); }
.pane-acts, .pane-tools { display: flex; flex-wrap: wrap; gap: 6px; }
.pane-row { display: flex; gap: 6px; }
.pane-row input { flex: 1; min-width: 0; }
.pane-club { align-items: center; gap: 10px; }
.pane-club select { flex: 1; min-width: 0; }
.cl-toolbar #batch-club { max-width: 220px; }
.grid.clients .club-name { display: inline-block; max-width: calc(100% - 36px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; color: var(--muted); font-size: 12px; }
.grid.clients th.pick, .grid.clients td.pick { width: 36px; padding: 0 0 0 12px; }
.grid.clients th.acts, .grid.clients td.acts { text-align: right; }
.grid.clients .row-acts { display: flex; justify-content: flex-end; align-items: center; gap: 4px; }
.grid.clients td { height: 44px; cursor: default; }
.grid.clients tr.focused td { background: var(--pick); }
.grid.clients tr.focused td:first-child { box-shadow: inset 2px 0 0 var(--accent); }
.grid.clients .row-name { display: inline-flex; align-items: baseline; gap: 8px; height: auto; padding: 0; border: 0; background: none; text-align: left; max-width: 100%; min-width: 0; overflow: hidden; }
.grid.clients .row-name b, .grid.clients .row-name .nick { overflow: hidden; text-overflow: ellipsis; }
.grid.clients .row-name b { flex: none; max-width: 100%; }
.grid.clients .row-name:hover b { color: var(--link); }
.grid.clients .row-name .nick { color: var(--nick); font-size: 12px; }
.grid.clients td.info { color: var(--muted); }
.grid.clients td.plan { font-size: 12px; }
.plan-note { display: block; color: var(--muted); font-size: 11px; line-height: 1.3; }
.grid.clients .plan-note { overflow: hidden; text-overflow: ellipsis; }
.grid.clients tr.group-row th { height: 36px; background: var(--panel-2); border-bottom: 1px solid var(--line); border-top: 1px solid var(--line); font-weight: 400; position: static; }
.grid.clients tbody:first-of-type tr.group-row th { border-top: 0; }
.grid.clients tr.group-row:hover th { background: var(--panel-2); }
.grid.clients .group { display: flex; align-items: center; gap: 8px; }
.grid.clients .group input { margin-right: 4px; }
.grid.clients tbody.offline td { color: var(--muted); }
.grid.clients tr.none td { color: var(--muted); }
.state { display: inline-flex; align-items: center; gap: 6px; }
.state .dot { background: var(--muted); }
.state.ok .dot { background: var(--ok); }
.state.warn .dot { background: var(--warn); }
.state.blue .dot { background: var(--link); }
.row-menu { position: fixed; width: 180px; top: 0; left: 0; }
@media (max-width: 720px) { .search input { width: 100%; } .search { flex: 1 1 100%; } .cl-pane { max-width: none; position: static; max-height: none; padding-left: 0; border-left: 0; } }

/* ---- Tags and schedule dialog ---- */
.meta-dialog { width: min(480px, calc(100vw - 32px)); padding: 0; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }
.meta-dialog::backdrop { background: rgba(0, 0, 0, .35); }
.meta-dialog form { display: flex; flex-direction: column; gap: 12px; padding: 16px; }
.meta-dialog h2 { margin: 0; font-size: 15px; }
.meta-dialog .field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.meta-dialog input[type="number"] { width: 70px; }
.meta-dialog .check { display: flex; align-items: center; gap: 6px; }
.meta-dialog .sch-ranges { display: grid; grid-template-columns: repeat(5, auto); align-items: center; gap: 6px; justify-content: start; }
.meta-dialog .note { margin: 0; }
.meta-dialog .error { margin: 0; color: var(--bad); }
.meta-dialog .buttons { display: flex; gap: 6px; flex-wrap: wrap; }
.meta-dialog .suggest { margin-top: -4px; }
.meta-dialog .suggest .chip { height: 22px; }
/* Grouped by computer the 電腦 column is folded to nothing; with no cells
   at all, the fixed layout would still give it half the room left. */
.grid.clients.by-device .dev { width: 0; padding: 0; visibility: hidden; }
.grid.clients td.dev { color: var(--muted); }
.grid.clients tr.off td { color: var(--muted); }
/* 帳號池: each column keeps its width whatever its cells say (states and
   動態 change all the time); 動態 takes what is left. Text that does not fit
   ends in an ellipsis, and the whole of it is in its title. */
.grid.clients { table-layout: fixed; min-width: 1170px; }
.grid.clients:not(.by-device) { min-width: 1280px; }
.grid.clients td { overflow: hidden; text-overflow: ellipsis; }
.grid.clients th.w-name { width: 160px; }
.grid.clients th.dev { width: 110px; }
.grid.clients th.w-id { width: 84px; }
.grid.clients th.w-ip { width: 136px; }
.grid.clients th.w-state { width: 88px; }
.grid.clients th.w-plan { width: 176px; }
.grid.clients th.w-profile { width: 84px; }
.grid.clients th.w-where { width: 136px; }
.grid.clients th.acts { width: 140px; }
/* 動態 runs to two lines; the row stays as tall. */
.grid.clients td.info { white-space: normal; font-size: 12px; line-height: 1.35; }
.grid.clients td.info > span { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; }
.grid.clients td.profile .tag { max-width: 100%; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
.group-by { display: inline-flex; align-items: center; gap: 6px; }
.tag.big { font-size: 12px; line-height: 20px; padding: 0 8px; margin-left: 0; font-weight: 600; }
/* 登入 and 進房 each have their own colour, so they never read as one button. */
:root { --login: #2557d6; --join: #c2410c; }
button.btn-login, button.btn-join { color: #fff; font-weight: 500; border-color: transparent; }
button.btn-login { background: var(--login); }
button.btn-join { background: var(--join); }
button.btn-login:hover, button.btn-join:hover { filter: brightness(1.08); }
button.btn-login:hover { background: var(--login); }
button.btn-join:hover { background: var(--join); }
.row-menu .menu-head { padding: 6px 8px 4px; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-menu hr { border: 0; border-top: 1px solid var(--line-soft); margin: 3px 0; }
.row-menu { width: 200px; max-height: calc(100vh - 16px); }
/* 帳號設定 dialog */
.account-dialog { width: min(640px, calc(100vw - 32px)); }
.account-dialog form { max-height: calc(100vh - 48px); overflow-y: auto; }
.account-dialog .dlg-head { display: flex; align-items: flex-start; gap: 8px; }
.account-dialog .dlg-head h2 { flex: 1; min-width: 0; }
.account-dialog .dlg-tabs { align-self: flex-start; }
.account-dialog section { display: flex; flex-direction: column; gap: 10px; min-height: 220px; }
.account-dialog section[hidden] { display: none; }
.account-dialog .kv { padding-top: 8px; border-top: 1px solid var(--line-soft); }
.account-dialog .own-form.off { opacity: .5; }
.account-dialog .seg button { height: 26px; }
.account-dialog .group-box { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px 12px; margin: 0; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.account-dialog .group-box[disabled] { opacity: .55; }
.account-dialog .group-box legend { padding: 0 4px; }
.account-dialog .pair { display: flex; gap: 8px; flex-wrap: wrap; }
.account-dialog .pair .field { flex: 1 1 120px; }
.account-dialog .pair .field.grow { flex: 3 1 180px; }
.account-dialog .pair input { width: 100%; }
.account-dialog .field input { width: 100%; }
.account-dialog .warn-note { color: var(--warn); }
/* 新增帳號 */
.new-account .screen-wrap { display: flex; justify-content: center; background: var(--panel-2); border-radius: 8px; padding: 8px; }
.new-account .screen { height: min(600px, calc(100vh - 260px)); width: auto; max-width: 100%; aspect-ratio: 412 / 860; border-radius: 6px; background: #fff; cursor: pointer; object-fit: contain; }
.new-account .login-status { margin: 0; font-weight: 500; }
.new-account .type-row input { flex: 1 1 200px; }
.new-account .done-text { font-size: 14px; margin: 8px 0; }
/* 批次新增 */
.batch-new { width: min(980px, calc(100vw - 32px)); }
.batch-new textarea { width: 100%; font: 12px/1.5 var(--mono); color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 8px; resize: vertical; }
.batch-new code { font-family: var(--mono); font-size: 11px; background: var(--panel-2); padding: 0 4px; border-radius: 3px; }
.batch-new .preview .table-wrap { max-height: 260px; overflow: auto; }
.batch-new .bad-text { color: var(--bad); }
.batch-run { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.batch-run .queue { flex: 1 1 260px; margin: 0; padding: 0; list-style: none; max-height: 560px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.batch-run .queue li { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--line-soft); }
.batch-run .queue li.now { background: var(--pick); }
.batch-run .queue li .muted { margin-left: auto; font-size: 12px; max-width: 50%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.batch-run .queue li.failed { flex-wrap: wrap; }
.batch-run .queue li.failed .muted { flex-basis: 100%; max-width: none; margin-left: 0; white-space: normal; color: var(--bad); }
.batch-run .current { flex: 2 1 360px; display: flex; flex-direction: column; gap: 8px; }
.new-account [hidden] { display: none !important; }

/* 代理池 */
.px-picked { display: inline-flex; align-items: center; gap: 6px; }
.px-grid td.px-status { max-width: 360px; overflow: hidden; text-overflow: ellipsis; }
.px-grid .px-why { color: var(--bad); font-size: 12px; }
.px-grid td.px-users { white-space: normal; min-width: 120px; }
.px-grid td.px-users .tag { margin: 2px 4px 2px 0; }
.px-grid tr.picked td { background: var(--pick); }
.proxy-add textarea { width: 100%; font: 12px/1.5 var(--mono); color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 8px; resize: vertical; }
.proxy-assign .table-wrap { max-height: 46vh; overflow: auto; }
.proxy-assign select { max-width: 100%; }
.proxy-assign td:first-child { white-space: nowrap; }
.proxy-assign td { white-space: normal; }
.proxy-assign .queue .mono { font-size: 12px; color: var(--muted); }
.proxy-assign td.px-reason { font-size: 12px; color: var(--muted); min-width: 110px; }
.proxy-assign .px-exit { font-size: 12px; }
.proxy-assign tr.px-sep td { background: var(--panel-2); color: var(--muted); font-size: 12px; font-weight: 600; padding-top: 6px; padding-bottom: 6px; }
.proxy-assign .px-summary { margin-top: 0; }

/* 開房 */
.new-room .rules { display: flex; flex-direction: column; gap: 10px; }
.new-room .pair { display: flex; flex-wrap: wrap; gap: 8px; }
.new-room .checks { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.new-room .status, .new-room .club-line, .new-room .cost { margin: 0; }
.new-room .cost { font-weight: 500; }
.new-room .room-code { font-size: 22px; font-weight: 600; margin: 4px 0; }
.new-room [hidden] { display: none !important; }

/* Staged allocation uses the same compact controls as account settings. */
.entry-dialog { padding: 18px; max-height: calc(100vh - 48px); overflow-y: auto; }
.entry-dialog [hidden] { display: none !important; }
.entry-dialog [data-auto-status] p { margin: 0; }
.entry-dialog [data-auto-status] .note { margin-top: 4px; }
.entry-dialog .auto-run + .auto-run { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line-soft); }
.entry-dialog .auto-run button.small { margin-left: 6px; vertical-align: middle; }
.auto-rotate { display: flex; flex-direction: column; gap: 6px; }
.auto-tables { display: flex; flex-direction: column; gap: 4px; }
.auto-tables > label { font-weight: 600; display: flex; align-items: center; gap: 6px; }
.auto-tables input[type="number"] { width: 72px; }
.auto-tables-ctl { white-space: nowrap; }
.auto-tables-ctl button { min-width: 28px; padding: 0 6px; margin: 0 4px; }
.auto-rotate > label { font-weight: 600; }
.auto-rotate [data-turns] { display: flex; flex-direction: column; gap: 6px; padding-left: 22px; }
.auto-rotate .turn { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.auto-rotate .turn input[type="number"] { width: 72px; }
.auto-ctl { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; max-width: 100%; min-width: 0; }
.auto-ctl > button { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 紀錄 */
.log-view { height: calc(100vh - 128px); min-height: 240px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel); font: 12px/1.6 var(--mono); padding: 6px 0; }
.log-view .ll { display: grid; grid-template-columns: 96px 78px 1fr; gap: 10px; padding: 0 12px; }
.log-view .ll:hover { background: var(--hover); }
.log-view time { color: var(--muted); font-variant-numeric: tabular-nums; }
.log-view .src { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.log-view .txt { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); }
.log-view .lv-warn .txt { color: var(--warn); }
.log-view .lv-error .txt { color: var(--bad); font-weight: 600; }
.log-view .lv-debug .txt { color: var(--muted); }
.log-view .empty { padding: 24px 12px; }
@media (max-width: 720px) {
  .log-view .ll { grid-template-columns: 1fr; gap: 0; padding: 4px 12px; border-bottom: 1px solid var(--line); }
  .log-view .src { display: inline; }
}
.entry-dialog > * + * { margin-top: 14px; }
.entry-dialog [data-jobs] { padding: 12px 0; border-top: 1px solid var(--line); }
.entry-dialog details { padding-top: 12px; border-top: 1px solid var(--line); }
.entry-dialog summary { cursor: pointer; font-weight: 600; }
.entry-dialog details[open] > * + * { margin-top: 14px; }
.entry-dialog .set-group:first-child { margin-top: 4px; }

/* ---- 打牌參數: the 參數 Profile table and its editor ---- */
:root { --team2-bg: #eaf0fd; --team2-text: #1d47b3; --teamr-bg: #fdf3e3; --teamr-text: #8a4b0a; --head-bg: #f7f7f5; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --team2-bg: #1a2540; --team2-text: #9dbaff; --teamr-bg: #3a2a12; --teamr-text: #f5c26b; --head-bg: #181d25; }
}
:root[data-theme="dark"] { --team2-bg: #1a2540; --team2-text: #9dbaff; --teamr-bg: #3a2a12; --teamr-text: #f5c26b; --head-bg: #181d25; }
.ic { flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.team-1 { background: var(--teamr-bg); color: var(--text); }
.team-2 { background: var(--team2-bg); color: var(--team2-text); }
.team-3 { background: var(--tag-bg); color: var(--tag-text); }
.team-r { background: var(--teamr-bg); color: var(--teamr-text); }
.tab-n { min-width: 20px; padding: 0 7px; border-radius: 999px; background: var(--panel-2); color: var(--muted); font-size: 12px; font-weight: 500; text-align: center; }
.on > .tab-n { background: var(--tag-bg); color: var(--tag-text); }

.pf-page { max-width: 1200px; margin: 0 auto; padding: 22px 0 40px; display: flex; flex-direction: column; gap: 16px; }
.pf-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 16px; }
.pf-head h1 { margin: 0; font-size: 20px; font-weight: 700; }
.pf-head p { margin: 4px 0 0; color: var(--muted); }
.pf-new { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 8px; }
.pf-tabs, .pd-tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--line); }
.pf-tabs button, .pd-tabs button {
  display: inline-flex; align-items: center; gap: 8px; height: 42px; padding: 0 12px; margin-bottom: -1px;
  border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; color: var(--muted); font-weight: 600;
}
.pf-tabs button:hover, .pd-tabs button:hover { background: none; color: var(--text); }
.pf-tabs button.on, .pd-tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.pf-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; }
.pf-search {
  display: flex; align-items: center; gap: 8px; flex: 0 1 280px; min-width: 200px; height: 34px; padding: 0 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; color: var(--muted);
}
.pf-search:focus-within { border-color: var(--accent); }
.pf-search input[type="search"] { flex: 1; min-width: 0; height: 100%; padding: 0; border: 0; background: transparent; }
.pf-filter { padding: 3px; border-radius: 9px; }
.pf-filter button { height: 28px; padding: 0 14px; border-radius: 7px; font-size: 13px; }
.pf-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 1px 3px rgba(0, 0, 0, .05); overflow: hidden; }
.pf-scroll { overflow-x: auto; }
.pf-table { width: 100%; min-width: 980px; border-collapse: collapse; }
.pf-table th {
  padding: 9px 14px; text-align: left; white-space: nowrap; font-size: 12px; font-weight: 600; color: var(--muted);
  background: var(--head-bg); border-bottom: 1px solid var(--line);
}
.pf-table td { padding: 12px 14px; white-space: nowrap; vertical-align: middle; border-bottom: 1px solid var(--line-soft); }
.pf-table tbody tr:last-child td { border-bottom: 0; }
.pf-table th:first-child, .pf-table td:first-child { padding-left: 18px; }
.pf-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.pf-table .acts { text-align: right; }
.pf-row { cursor: pointer; }
.pf-row:hover td { background: var(--hover); }
.pf-row.asking td, .pf-confirm td { background: color-mix(in srgb, var(--bad) 7%, var(--panel)); }
.pf-row.asking td { border-bottom-color: transparent; }
.pf-name { display: flex; align-items: center; gap: 12px; }
.pf-name small { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 12px; }
.pf-avatar { display: inline-grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 9px; font-size: 14px; font-weight: 700; }
.pf-avatar.big { width: 46px; height: 46px; border-radius: 12px; font-size: 19px; }
button.pf-link { height: auto; padding: 0; border: 0; background: none; color: var(--text); font-size: 14px; font-weight: 600; }
button.pf-link:hover { background: none; text-decoration: underline; }
.pf-team { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pf-style { display: inline-flex; align-items: center; gap: 8px; }
.pf-style::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.pf-style.solo::before { background: var(--muted); }
.pf-count { display: flex; align-items: center; gap: 10px; }
.pf-count b { min-width: 22px; text-align: right; font-variant-numeric: tabular-nums; }
.pf-bar { width: 80px; height: 6px; border-radius: 3px; background: var(--panel-2); overflow: hidden; }
.pf-bar span { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
.pf-act { display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0; border-radius: 8px; vertical-align: middle; }
.pf-act + .pf-act { margin-left: 4px; }
button.pf-act.danger { color: var(--bad); }
span.pf-act.lock { color: var(--muted); }
.pf-confirm td { padding: 0; }
.pf-confirm div { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 2px 14px 12px 64px; white-space: normal; }
.pf-confirm span { flex: 1 1 260px; }
.pf-confirm button { height: 30px; padding: 0 14px; border-radius: 7px; }
.pf-confirm button.confirm { color: var(--accent-text); font-weight: 600; }
.pf-empty td { padding: 36px 16px; text-align: center; color: var(--muted); }
.pf-foot { display: flex; align-items: flex-start; gap: 8px; margin: 0; color: var(--muted); font-size: 12.5px; }
.pf-foot .ic { margin-top: 1px; }
.pf-foot a { color: var(--link); margin: 0 3px; }
.pf-table.pf-clubs { min-width: 600px; }
.pf-clubs .pf-name b { font-weight: 600; }
.pf-default td { background: var(--head-bg); }
.pf-avatar.club { background: var(--tag-bg); color: var(--tag-text); }
.pf-avatar.plain { background: var(--panel-2); color: var(--muted); }
.pf-price { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.pf-price input[type="number"] { width: 110px; height: 32px; text-align: right; font-variant-numeric: tabular-nums; color: var(--text); font-size: 14px; }
.pf-rule { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 20px; padding: 18px 20px; }
.pf-rule-icon { display: inline-grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 10px; background: var(--tag-bg); color: var(--tag-text); }
.pf-rule-text { flex: 1 1 320px; }
.pf-rule-text > div { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.pf-rule-text b { font-size: 14px; font-weight: 600; }
.pf-rule-text p { margin: 4px 0 0; color: var(--muted); }
.pf-state { padding: 0 8px; border-radius: 999px; background: var(--panel-2); color: var(--muted); font-size: 12px; font-weight: 600; }
.pf-state.on { background: var(--tag-bg); color: var(--tag-text); }
.nt-kinds .pf-rule + .pf-rule { border-top: 1px solid var(--line-soft); }
.nt-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.nt-form input { flex: 1 1 280px; min-width: 0; }
.nt-form button { display: inline-flex; align-items: center; gap: 6px; }
.pf-rule-foot { padding: 10px 20px; border-top: 1px solid var(--line-soft); background: var(--head-bg); color: var(--muted); font-size: 12px; }
.pf-page .switch span, .profile-dialog .switch span { width: 40px; height: 22px; border-radius: 11px; }
.pf-page .switch span::after, .profile-dialog .switch span::after { width: 18px; height: 18px; }
.pf-page .switch input:checked + span::after, .profile-dialog .switch input:checked + span::after { transform: translateX(18px); }

.meta-dialog.profile-dialog { width: min(1000px, calc(100vw - 32px)); border-radius: 14px; }
.meta-dialog.profile-dialog form { max-height: calc(100vh - 48px); padding: 0; gap: 0; }
.pd-head { display: flex; align-items: flex-start; gap: 14px; padding: 18px 14px 0 22px; }
.pd-title { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.pd-over { color: var(--muted); font-size: 12px; font-weight: 600; }
.meta-dialog.profile-dialog .pd-title h2 { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 19px; font-weight: 700; }
.pd-lock { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 12px; font-weight: 500; }
.pd-name { display: flex; flex-direction: column; gap: 3px; color: var(--muted); font-size: 12px; font-weight: 600; }
.pd-name input { width: min(380px, 100%); height: 36px; border-radius: 8px; color: var(--text); font-size: 17px; font-weight: 700; }
.pd-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pd-chips span { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 999px; background: var(--panel-2); color: var(--muted); font-size: 12px; white-space: nowrap; }
.profile-dialog button.pd-close { width: 36px; height: 36px; padding: 0; display: inline-grid; place-items: center; }
.pd-tabs { padding: 0 22px; margin-top: 12px; }
.pd-body { display: flex; height: min(600px, calc(100vh - 290px)); min-height: 260px; }
.pd-nav {
  flex: 0 0 210px; display: flex; flex-direction: column; gap: 2px; padding: 14px 10px; overflow-y: auto;
  background: var(--head-bg); border-right: 1px solid var(--line);
}
.pd-nav-title { padding: 2px 12px 8px; color: var(--muted); font-size: 12px; font-weight: 600; }
.pd-nav button {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 38px; padding: 0 12px;
  border: 0; border-radius: 8px; background: transparent; color: var(--text); text-align: left;
}
.pd-nav button:hover { background: var(--hover); }
.pd-nav button.on { background: var(--tag-bg); color: var(--tag-text); font-weight: 600; }
.pd-nav button small { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.pd-nav button.on small { color: inherit; }
.pd-nav-note { margin: auto 2px 0; padding: 10px 12px; border-radius: 8px; background: var(--panel-2); color: var(--muted); font-size: 12px; line-height: 1.6; }
.pd-main { flex: 1; min-width: 0; overflow-y: auto; padding: 2px 26px 16px; }
.pd-main section[hidden], .pd-main .set-group[hidden] { display: none; }
.pd-main .set-group { margin-top: 18px; }
.pd-main .set-group > h2 { margin: 0 0 2px; font-size: 16px; font-weight: 700; }
.pd-main .set-note { margin: 0 0 6px; font-size: 13px; }
.pd-main .set-list { border-top: 0; }
.pd-main .set-row { grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px 28px; padding: 14px 0; }
.pd-main .set-row:last-child { border-bottom: 0; }
.pd-main .set-row:has(.opt-list) { grid-template-columns: 1fr; }
.pd-main .set-label b { font-size: 13.5px; font-weight: 600; }
.pd-main .set-label p { font-size: 12.5px; }
.pd-main .set-ctl { justify-content: flex-end; }
@container (max-width: 560px) {
  .pd-main .set-row { grid-template-columns: 1fr; }
  .pd-main .set-ctl { justify-content: flex-start; }
}
.pd-tag {
  display: inline-flex; align-items: center; gap: 3px; height: 18px; margin-left: 8px; padding: 0 7px; vertical-align: 1px;
  border-radius: 999px; background: var(--panel-2); color: var(--muted); font-size: 11px; font-weight: 600;
}
.profile-dialog .set-num { gap: 0; height: 34px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); overflow: hidden; }
.profile-dialog .set-num:focus-within { border-color: var(--accent); }
.profile-dialog .set-num input[type="number"] { width: 64px; height: 100%; padding: 0 4px 0 10px; border: 0; border-radius: 0; background: transparent; text-align: right; font-variant-numeric: tabular-nums; }
.profile-dialog .set-num input[type="number"]:only-child { padding-right: 10px; }
.profile-dialog .set-num .unit { padding: 0 10px 0 4px; font-size: 12.5px; white-space: nowrap; }
.profile-dialog select { height: 34px; border-radius: 8px; }
.profile-dialog .seg-radio { padding: 3px; border-radius: 9px; }
.profile-dialog .seg-radio span { padding: 5px 14px; border-radius: 7px; }
.profile-dialog .seg-radio input:checked + span { font-weight: 600; }
.profile-dialog .opt-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.profile-dialog .opt-list label { padding: 11px 14px 11px 38px; border-radius: 10px; }
.profile-dialog .opt-list label::before {
  content: ""; position: absolute; left: 14px; top: 14px; width: 16px; height: 16px; box-sizing: border-box;
  border: 1.5px solid var(--muted); border-radius: 50%; background: var(--panel);
}
.profile-dialog .opt-list label:has(input:checked)::before { border: 5px solid var(--accent); }
.meta-dialog.profile-dialog .error { padding: 8px 22px 0; }
.meta-dialog.profile-dialog .buttons { align-items: center; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); background: var(--head-bg); }
.profile-dialog .buttons button { height: 34px; padding: 0 16px; border-radius: 8px; }
.profile-dialog .buttons button.primary { display: inline-flex; align-items: center; gap: 6px; }
.pd-note { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; }
@media (max-width: 720px) {
  .pd-body { flex-direction: column; height: calc(100vh - 250px); }
  .pd-nav { flex: none; flex-direction: row; overflow-x: auto; padding: 8px 10px; border-right: 0; border-bottom: 1px solid var(--line); }
  .pd-nav-title, .pd-nav-note { display: none; }
  .pd-main { padding: 0 16px 16px; }
  .profile-dialog .opt-list { grid-template-columns: 1fr; }
}

/* ---- 策略庫 and 回測 ------------------------------------------------------ */
/* Series colours for strategy comparisons: categorical slots 1-4 of the
   validated reference palette (light and dark steps each pass the CVD and
   normal-vision checks on their surface; light slots 3-4 sit under 3:1, so
   every chart also names its lines at their ends and the stats table repeats
   them). The real result is the reference line, in ink and dashed. */
:root { --viz-s1: #2a78d6; --viz-s2: #eb6834; --viz-s3: #1baf7a; --viz-s4: #eda100; --viz-ref: #62626a; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --viz-s1: #3987e5; --viz-s2: #d95926; --viz-s3: #199e70; --viz-s4: #c98500; --viz-ref: #9aa3af; }
}
:root[data-theme="dark"] { --viz-s1: #3987e5; --viz-s2: #d95926; --viz-s3: #199e70; --viz-s4: #c98500; --viz-ref: #9aa3af; }
.fine { font-size: 12px; }
.ellip { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note.warn { color: var(--warn); }
.head-actions { margin-left: auto; display: flex; gap: 6px; }
tr.clickable { cursor: pointer; }
.edit-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0; }
.edit-bar label { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
input.wide { flex: 1 1 220px; min-width: 160px; }
.strategy-edit .set-row { padding: 6px 0; }
.strategy-edit .set-ctl input { width: min(480px, 100%); }
textarea.code {
  display: block; width: 100%; min-height: 420px; height: 60vh; margin-top: 8px; padding: 10px 12px; resize: vertical; tab-size: 2;
  font: 12px/1.55 var(--mono); color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; white-space: pre;
}
textarea.code:focus { outline: none; border-color: var(--accent); }
.check-result { min-height: 22px; line-height: 1.6; }
.strategy-edit + .panel { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.check-result .mono { white-space: pre-wrap; margin-top: 4px; color: var(--bad); }
.swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0 0 10px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.legend-item i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; flex: none; }
.legend-item i.ref { height: 0; border-top: 2px dashed var(--viz-ref); background: none !important; }
.stat-table td:first-child { font-weight: 500; }
.chart-box .end-label { fill: var(--text); font-size: 12px; }
.chart-box .cross { stroke: var(--muted); stroke-width: 1; pointer-events: none; }
.tip-head { color: var(--muted); margin-bottom: 2px; }
.tip-row { display: flex; align-items: center; gap: 6px; }
.tip-row i { width: 10px; height: 3px; border-radius: 2px; display: inline-block; }
.tip-row b { margin-left: auto; padding-left: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---- 策略庫 editor: files, tabs, editor, panel, status bar ---------------- */
:root { --sw-side: #f4f4f1; --sw-tabs: #efefec; --sw-status: #0f7b5f; --sw-status-text: #ffffff; --sw-lua: #2557d6; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --sw-side: #11161c; --sw-tabs: #0e1217; --sw-status: #1d6b53; --sw-status-text: #e9fff6; --sw-lua: #7aa2ff; } }
:root[data-theme="dark"] { --sw-side: #11161c; --sw-tabs: #0e1217; --sw-status: #1d6b53; --sw-status-text: #e9fff6; --sw-lua: #7aa2ff; }
.sw { display: grid; grid-template-columns: 240px minmax(0, 1fr); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--panel); min-height: 440px; margin-top: 12px; position: relative; }
.sw-svg { width: 16px; height: 16px; flex: none; }
.sw-svg.lua { color: var(--sw-lua); }
.sw-svg.lock { color: var(--muted); }
.sw-sp { flex: 1; }
.sw-side { display: flex; flex-direction: column; min-height: 0; background: var(--sw-side); border-right: 1px solid var(--line); position: relative; }
.sw-side-head { display: flex; align-items: center; gap: 2px; padding: 6px 6px 6px 12px; font-size: 11px; font-weight: 600; letter-spacing: .06em; color: var(--muted); }
.sw-icon { width: 26px; height: 26px; padding: 0; display: inline-grid; place-items: center; color: var(--muted); }
.sw-icon:hover { color: var(--text); }
.sw-files { flex: 1; overflow-y: auto; padding: 2px 0 12px; }
.sw-group { padding: 10px 12px 4px; font-size: 11px; font-weight: 600; color: var(--muted); }
.sw-file { display: flex; align-items: center; gap: 7px; height: 26px; padding: 0 6px 0 14px; cursor: pointer; color: var(--text); white-space: nowrap; border-left: 2px solid transparent; }
.sw-file:hover { background: var(--hover); }
.sw-file.on { background: var(--pick); border-left-color: var(--accent); }
.sw-file:focus-visible { outline: 1px solid var(--accent); outline-offset: -1px; }
.sw-fname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.sw-ext { color: var(--muted); }
.sw-use, .sw-err { font-size: 11px; line-height: 16px; min-width: 16px; padding: 0 4px; border-radius: 8px; text-align: center; }
.sw-use { background: var(--tag-bg); color: var(--tag-text); }
.sw-err { background: color-mix(in srgb, var(--bad) 16%, transparent); color: var(--bad); }
.sw-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text); opacity: .7; }
.sw-more { width: 22px; height: 22px; padding: 0; border: 0; background: transparent; display: none; place-items: center; color: var(--muted); }
.sw-file:hover .sw-more, .sw-file.on .sw-more { display: inline-grid; }
.sw-more:hover { color: var(--text); background: var(--line-soft); }
.sw-file.editing { cursor: default; background: var(--pick); }
.sw-file.editing input { flex: 1; min-width: 0; height: 22px; padding: 0 6px; }
.sw-create { display: grid; gap: 6px; margin: 4px 8px 8px; padding: 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
.sw-create input, .sw-create select { width: 100%; min-width: 0; }
.sw-create-btns { display: flex; gap: 6px; }
.sw-drop { display: none; position: absolute; inset: 0; place-items: center; background: color-mix(in srgb, var(--accent) 12%, var(--sw-side)); border: 2px dashed var(--accent); color: var(--accent); font-weight: 600; pointer-events: none; }
.sw-side.drop .sw-drop { display: grid; }
.sw-work { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.sw-tabs { display: flex; align-items: stretch; height: 35px; flex: none; background: var(--sw-tabs); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: thin; }
.sw-side-toggle { display: none; height: 34px; width: 36px; padding: 0; border-radius: 0; place-items: center; color: var(--muted); }
.sw-tab { display: flex; align-items: center; gap: 6px; padding: 0 6px 0 12px; max-width: 220px; cursor: pointer; color: var(--muted); border-right: 1px solid var(--line); white-space: nowrap; user-select: none; }
.sw-tab:hover { background: var(--hover); }
.sw-tab.on { background: var(--panel); color: var(--text); box-shadow: inset 0 2px 0 var(--accent); margin-bottom: -1px; }
.sw-tname { overflow: hidden; text-overflow: ellipsis; }
.sw-x { width: 20px; height: 20px; padding: 0; border: 0; border-radius: 4px; background: transparent; display: inline-grid; place-items: center; color: inherit; visibility: hidden; }
.sw-x .d { display: none; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.sw-tab:hover .sw-x, .sw-tab.on .sw-x, .sw-tab.dirty .sw-x { visibility: visible; }
.sw-tab.dirty .sw-x .x { display: none; }
.sw-tab.dirty .sw-x .d { display: block; }
.sw-tab.dirty .sw-x:hover .x { display: inline; }
.sw-tab.dirty .sw-x:hover .d { display: none; }
.sw-x:hover { background: var(--line-soft); }
.sw-bar { display: flex; align-items: center; gap: 8px; min-height: 38px; flex: none; padding: 4px 10px; border-bottom: 1px solid var(--line-soft); flex-wrap: wrap; }
.sw-crumb { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.sw-crumb b { color: var(--text); font-weight: 600; }
.sw-bar input { width: min(280px, 40vw); }
.sw-restored { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--warn); }
.sw-stage { position: relative; flex: 1; min-height: 160px; }
.sw-editor { position: absolute; inset: 0; }
.sw-editor[hidden] { display: none; }
.sw-editor textarea.code { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; border: 0; border-radius: 0; resize: none; padding: 10px 14px; }
.sw-overview { position: absolute; inset: 0; overflow: auto; background: var(--panel); display: none; }
.sw.no-file .sw-overview { display: block; }
.sw.no-file .sw-bar input, .sw.no-file .sw-split, .sw.no-file .sw-panel { display: none; }
.sw-welcome { max-width: 1100px; padding: 22px 24px 32px; }
.sw-welcome h1 { margin: 0 0 6px; font-size: 20px; }
.sw-welcome > p { margin: 0 0 14px; max-width: 760px; }
.sw-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.sw-actions button, .sw-actions .button { display: inline-flex; align-items: center; gap: 6px; }
.sw-welcome .note { margin-top: 8px; }
.grid td.sw-check { white-space: normal; min-width: 240px; max-width: 420px; line-height: 1.5; padding-top: 6px; padding-bottom: 6px; }
.sw-keys { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 18px; color: var(--muted); font-size: 12px; }
.sw-keys b { color: var(--text); }
kbd { font: 11px/1 var(--mono); padding: 2px 5px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; background: var(--panel-2, var(--hover)); color: var(--text); }
.sw-split { height: 5px; flex: none; cursor: row-resize; border-top: 1px solid var(--line); margin-bottom: -4px; position: relative; z-index: 2; }
.sw-split:hover, .sw-split:active { background: color-mix(in srgb, var(--accent) 35%, transparent); }
.sw-panel { display: flex; flex-direction: column; flex: none; min-height: 0; background: var(--panel); }
.sw-panel.closed { height: auto !important; }
.sw-panel-head { display: flex; align-items: center; gap: 2px; height: 32px; flex: none; padding: 0 8px; }
.sw-ptab { height: 30px; border: 0; border-radius: 0; background: transparent; color: var(--muted); font-size: 12px; letter-spacing: .02em; border-bottom: 2px solid transparent; padding: 0 10px; }
.sw-ptab:hover { color: var(--text); background: transparent; }
.sw-ptab.on { color: var(--text); border-bottom-color: var(--accent); }
.sw-count { display: inline-block; min-width: 16px; padding: 0 4px; border-radius: 8px; background: var(--line-soft); font-size: 11px; line-height: 16px; text-align: center; }
.sw-count.bad { background: color-mix(in srgb, var(--bad) 16%, transparent); color: var(--bad); }
.sw-panel-body { flex: 1; overflow: auto; padding: 4px 12px 12px; min-height: 0; }
.sw-empty { padding: 18px 4px; color: var(--muted); }
.sw-probs { display: grid; }
.sw-prob { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; gap: 8px; align-items: start; height: auto; padding: 5px 6px; border: 0; border-radius: 4px; background: transparent; text-align: left; white-space: normal; }
.sw-prob:hover { background: var(--hover); }
.sw-sev { font-weight: 700; text-align: center; }
.sw-prob.error .sw-sev { color: var(--bad); }
.sw-prob.warning .sw-sev { color: var(--warn); }
.sw-pline { font-size: 12px; white-space: nowrap; }
.sw-pre { margin: 4px 0 0; font: 12px/1.5 var(--mono); white-space: pre-wrap; color: var(--muted); }
.sw-checks { display: grid; gap: 12px; padding-top: 6px; }
.sw-checks p { margin: 0; }
.sw-vers .actions { display: flex; gap: 4px; flex-wrap: wrap; }
.sw-ref-wrap { padding-top: 6px; }
.sw-ref-wrap > input { width: min(320px, 100%); margin-bottom: 8px; }
.sw-ref-list { columns: 2 380px; column-gap: 24px; }
.sw-ref-group { break-inside: avoid; margin-bottom: 12px; }
.sw-ref-group h3 { margin: 0 0 4px; font-size: 12px; color: var(--muted); }
.sw-ref-group p { margin: 0; font-size: 12px; }
.sw-ref { display: grid; grid-template-columns: minmax(150px, max-content) minmax(0, 1fr); gap: 10px; width: 100%; height: auto; padding: 3px 6px; border: 0; background: transparent; text-align: left; white-space: normal; font-size: 12px; }
.sw-ref:hover { background: var(--hover); }
.sw-ref code { font-family: var(--mono); color: var(--sw-lua); }
.sw-ref span { color: var(--muted); }
.sw-status { display: flex; align-items: center; gap: 14px; height: 24px; flex: none; padding: 0 10px; background: var(--sw-status); color: var(--sw-status-text); font-size: 12px; white-space: nowrap; overflow: hidden; }
.sw-status .muted { color: inherit; opacity: .85; }
.sw-status .ellip { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.sw-status .bad, .sw-status .warn { color: inherit; font-weight: 600; }
.sw-status span[class*="money"], .sw-status .gain, .sw-status .loss, .sw-status .pos, .sw-status .neg { color: inherit !important; }
.sw-st-probs { height: 22px; padding: 0 6px; border: 0; color: inherit; background: transparent; font-size: 12px; }
.sw-st-probs:hover { background: rgba(255, 255, 255, .14); }
.sw-st-dirty { font-weight: 600; }
.sw-menu { position: fixed; z-index: 60; min-width: 190px; padding: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.sw-menu button { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; height: 28px; border: 0; background: transparent; text-align: left; }
.sw-menu button:hover:not(:disabled), .sw-menu button:focus-visible { background: var(--pick); outline: none; }
.sw-menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.sw-menu kbd { font-size: 10px; }
.sw-dialog p { margin: 0; line-height: 1.6; }
.sw-dialog textarea { width: 100%; font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--text); resize: vertical; }
.sw-dialog-btns { display: flex; justify-content: flex-end; gap: 8px; }
@media (max-width: 760px) {
  .sw { grid-template-columns: minmax(0, 1fr); }
  .sw-side { position: absolute; z-index: 5; top: 0; bottom: 0; left: 0; width: min(280px, 85%); box-shadow: var(--shadow); transform: translateX(-102%); transition: transform .15s; }
  .sw.side-open .sw-side { transform: none; }
  .sw-side-toggle { display: inline-grid; }
  .sw-bar input { width: 100%; order: 5; }
  .sw-status .ellip { display: none; }
}
@media (prefers-reduced-motion: reduce) { .sw-side { transition: none; } }

/* ---- 說明文件 (Markdown) ------------------------------------------------- */
.sw-doc { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 28px; padding: 0 24px 40px 0; max-width: 1180px; }
.sw-doc-toc { position: sticky; top: 0; align-self: start; max-height: calc(100vh - 160px); overflow-y: auto; padding: 18px 0 18px 14px; border-right: 1px solid var(--line-soft); }
.sw-doc-links { display: grid; gap: 1px; }
.sw-doc-links a { display: block; padding: 4px 10px; border-radius: 5px; color: var(--muted); text-decoration: none; font-size: 13px; line-height: 1.4; }
.sw-doc-links a.l3 { padding-left: 22px; font-size: 12px; }
.sw-doc-links a:hover { color: var(--text); background: var(--hover); }
.sw-doc-links a.on { color: var(--accent); background: var(--pick); }
.sw-doc-main { min-width: 0; }
.sw-doc-top { position: sticky; top: 0; z-index: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 0 10px; background: var(--panel); border-bottom: 1px solid var(--line-soft); }
.sw-doc-top input { width: min(320px, 100%); }
.sw-doc-mtoc { display: none; width: 100%; }
.sw-doc-mtoc summary { cursor: pointer; color: var(--link); padding: 2px 0; }
.sw-doc-mtoc .sw-doc-links { max-height: 50vh; overflow-y: auto; padding: 6px 0; }
.md { max-width: 860px; line-height: 1.75; font-size: 14px; padding-top: 6px; }
.md h1 { font-size: 24px; margin: 18px 0 10px; }
.md h2 { font-size: 19px; margin: 34px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--line-soft); scroll-margin-top: 64px; }
.md h3 { font-size: 15px; margin: 24px 0 8px; scroll-margin-top: 64px; }
.md h4 { font-size: 14px; margin: 18px 0 6px; }
.md p { margin: 8px 0; }
.md ul, .md ol { margin: 6px 0; padding-left: 22px; }
.md li { margin: 3px 0; }
.md li > ul, .md li > ol { margin: 2px 0; }
.md code { font: 12.5px/1.5 var(--mono); padding: 1px 5px; border-radius: 4px; background: var(--line-soft); color: var(--sw-lua); white-space: nowrap; }
.md a { color: var(--link); }
.md a[data-doc-jump] { text-decoration: none; border-bottom: 1px dotted currentColor; }
.md blockquote { margin: 12px 0; padding: 8px 14px; border-left: 3px solid var(--warn); background: color-mix(in srgb, var(--warn) 8%, transparent); border-radius: 0 6px 6px 0; }
.md .table-wrap { margin: 10px 0 14px; }
.md-table th, .md-table td { height: auto; padding: 7px 10px; white-space: normal; vertical-align: top; line-height: 1.55; }
.md-table td:first-child { white-space: nowrap; }
.md-table code { white-space: normal; }
.md-code { position: relative; margin: 10px 0 14px; }
.md-code pre { margin: 0; padding: 12px 14px; overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--sw-side); font: 12.5px/1.6 var(--mono); }
.md-code pre code { padding: 0; background: none; color: var(--text); white-space: pre; font: inherit; }
.md-copy { position: absolute; top: 6px; right: 6px; height: 24px; padding: 0 8px; font-size: 12px; opacity: 0; transition: opacity .1s; background: var(--panel); }
.md-code:hover .md-copy, .md-copy:focus-visible { opacity: 1; }
.md mark { background: color-mix(in srgb, var(--warn) 35%, transparent); color: inherit; border-radius: 2px; }
.md mark.on { background: var(--warn); color: #000; }
.sw-ref-top { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 8px; }
.sw-ref-top input { width: min(320px, 100%); }
.sw-ref-top a { display: inline-flex; align-items: center; gap: 4px; color: var(--link); text-decoration: none; font-size: 12px; }
@media (max-width: 860px) {
  .sw-doc { grid-template-columns: minmax(0, 1fr); padding: 0 14px 32px; gap: 0; }
  .sw-doc-toc { display: none; }
  .sw-doc-mtoc { display: block; }
  .md { font-size: 14px; }
  .md h2 { font-size: 17px; }
  .md-copy { opacity: 1; }
  .md-code pre { padding-top: 34px; }
  .md .table-wrap { border: 0; background: none; overflow: visible; }
  .md-table thead { display: none; }
  .md-table, .md-table tbody, .md-table tr, .md-table td { display: block; width: 100%; }
  .md-table tr { padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; background: var(--panel); }
  .md-table tbody tr:hover td { background: none; }
  .md-table td { padding: 2px 0; border: 0; }
  .md-table td:first-child { font-weight: 600; white-space: normal; }
  .md-table td:not(:first-child)::before { content: attr(data-label) "："; color: var(--muted); font-size: 12px; }
}

/* ---- Tables that turn into cards on phones -------------------------------- */
@media (max-width: 760px) {
  .rwrap { border: 0; background: none; overflow: visible; }
  .rtable thead { display: none; }
  .rtable, .rtable tbody, .rtable tr { display: block; width: 100%; }
  .rtable tr { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; padding: 8px 12px; background: var(--panel); }
  .rtable tbody tr:hover td { background: none; }
  .rtable td { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; height: auto; min-height: 0; padding: 3px 0; border: 0; white-space: normal; text-align: right; }
  .rtable td::before { content: attr(data-label); color: var(--muted); font-size: 12px; text-align: left; flex: none; }
  .rtable td.rt-head { display: block; text-align: left; padding-bottom: 4px; }
  .rtable td.rt-head::before, .rtable td[data-label=""]::before { content: none; }
  .rtable td.rt-skip { display: none; }
  .rtable .actions { justify-content: flex-end; flex-wrap: wrap; }
}

/* ---- Section headers on phones -------------------------------------------- */
@media (max-width: 720px) {
  .section-head { flex-wrap: wrap; row-gap: 4px; }
  .section-head h1 { white-space: nowrap; }
  .section-head .sub { flex: 1 1 100%; order: 3; }
  .head-actions { flex-wrap: wrap; }
  .head-actions .button, .head-actions button { white-space: nowrap; }
}

/* ---- 回測 ------------------------------------------------------------------ */
.bt-new { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 22px; }
.bt-step { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); padding: 14px 16px 16px; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.bt-step h2 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 14px; font-weight: 600; }
.bt-num { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: var(--accent-text); font-size: 12px; font-weight: 600; flex: none; }
.bt-step .note { margin: 0; }
.bt-dates { display: flex; flex-wrap: wrap; gap: 8px; }
.bt-dates label { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.bt-src summary, .bt-details summary { cursor: pointer; color: var(--link); font-size: 12px; }
.bt-src[open] { display: grid; gap: 6px; }
.bt-fetch { display: flex; flex-wrap: wrap; gap: 6px; }
.bt-real { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; padding: 6px 10px; border-radius: 6px; background: var(--panel-2); }
#bt-series { display: grid; gap: 8px; }
.bt-series { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; display: grid; gap: 6px; }
.bt-series-main { display: flex; align-items: center; gap: 8px; min-width: 0; }
.bt-series-main .bt-lib { flex: 1 1 auto; min-width: 0; max-width: 100%; }
.bt-series-main .icon { width: 26px; height: 26px; padding: 0; flex: none; }
.bt-libnote { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bt-adv { display: grid; gap: 8px; padding-top: 4px; }
.bt-adv[hidden] { display: none; }
.bt-adv label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.bt-adv input { width: 100%; font-family: var(--mono); font-size: 12px; }
.bt-adv .chips { align-items: center; }
.bt-adv .chip { font-family: var(--mono); }
.bt-adv .chips a { color: var(--link); margin-left: 4px; }
#bt-add { justify-self: start; align-self: flex-start; }
.bt-opt { display: grid; gap: 4px; }
.bt-note { width: 100%; }
.bt-go { display: grid; gap: 6px; margin-top: auto; }
.bt-go .primary { height: 38px; font-size: 14px; }
.bt-history { margin-top: 4px; }
.bt-jobs { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px; }
.bt-job { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); padding: 12px 14px; display: grid; gap: 8px; align-content: start; min-width: 0; }
.bt-job.clickable { cursor: pointer; }
.bt-job.clickable:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.bt-job header { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.bt-job p { margin: 0; }
.bt-jrows { display: grid; gap: 3px; }
.bt-jrow { display: grid; grid-template-columns: minmax(0, 1fr) auto auto 44px; align-items: center; gap: 10px; }
.bt-jrow .legend-item { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bt-jrow .badge { justify-self: end; }
.bt-job footer { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 2px; }
.bt-conclusion { border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: var(--radius); background: var(--panel); padding: 12px 16px; margin-bottom: 12px; }
.bt-conclusion p { margin: 2px 0; }
.bt-conclusion p:first-child { font-size: 15px; }
.bt-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; margin-bottom: 18px; }
.bt-card { border: 1px solid var(--line); border-top: 3px solid var(--c); border-radius: var(--radius); background: var(--panel); padding: 12px 14px; display: grid; gap: 4px; min-width: 0; }
.bt-card.ref { border-top-style: dashed; background: var(--panel-2); }
.bt-card.best { box-shadow: 0 0 0 1px color-mix(in srgb, var(--ok) 45%, transparent); }
.bt-card-head { display: flex; align-items: center; gap: 6px; min-width: 0; }
.bt-card-head i { width: 10px; height: 10px; border-radius: 3px; background: var(--c); flex: none; }
.bt-card.ref .bt-card-head i { height: 0; border-top: 2px dashed var(--c); background: none; }
.bt-card-head b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bt-card-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bt-big .money.big { font-size: 26px; }
.bt-vs { font-size: 13px; }
.bt-mini { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: 12px; color: var(--muted); padding-top: 4px; border-top: 1px solid var(--line-soft); margin-top: 2px; }
.bt-sec { margin: 0 0 20px; }
.bt-sec > h2 { font-size: 14px; margin: 0 0 8px; }
.bt-tabs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 8px; }
.bt-tabs .muted { margin-left: 4px; }
.bt-details summary { font-size: 14px; color: var(--text); font-weight: 600; padding: 4px 0 8px; }
.bt-metrics td:first-child { white-space: normal; min-width: 160px; }
.bt-metrics td, .bt-metrics th { height: auto; padding-top: 7px; padding-bottom: 7px; }
.bt-hands-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 8px; }
.bt-hands-bar label { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.bt-hands td { height: auto; padding-top: 6px; padding-bottom: 6px; }
.bt-who { color: var(--muted); font-size: 12px; margin-right: 4px; }
.bt-fan { display: block; max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bt-more-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; }
@media (max-width: 1100px) {
  .bt-new { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .bt-new .bt-step:last-child { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  .bt-new { grid-template-columns: minmax(0, 1fr); }
  .bt-jobs { grid-template-columns: minmax(0, 1fr); }
  .bt-jrow { grid-template-columns: minmax(0, 1fr) auto 44px; }
  .bt-jrow .num.muted { display: none; }
  .bt-cards { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .bt-card { padding: 10px 12px; }
  .bt-big .money.big { font-size: 20px; }
  .bt-mini { gap: 0 8px; }
  .bt-conclusion p:first-child { font-size: 14px; }
  .bt-hands tr { position: relative; }
  .bt-hands .rt-head { font-weight: 500; padding-right: 64px; }
  .bt-hands td.bt-rp { position: absolute; top: 7px; right: 10px; padding: 0; }
  .bt-cell { min-width: 0; }
  .bt-fan { max-width: 220px; margin-left: auto; }
}

/* ---- 打牌參數 tables as cards on phones ------------------------------------- */
@media (max-width: 760px) {
  .pf-card:has(> .pf-scroll) { background: none; border: 0; box-shadow: none; overflow: visible; }
  .pf-scroll { overflow: visible; }
  .pf-table, .pf-table.pf-clubs { min-width: 0; }
  .pf-table thead { display: none; }
  .pf-table, .pf-table tbody { display: block; }
  .pf-table tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px 14px; position: relative; padding: 12px 14px; margin-bottom: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
  .pf-table tr.pf-default { background: var(--head-bg); }
  .pf-table td, .pf-table th:first-child, .pf-table td:first-child { display: block; min-width: 0; padding: 0; border: 0; white-space: normal; text-align: left; }
  .pf-table tbody tr:hover td, .pf-row:hover td, .pf-default td { background: none; }
  .pf-table td::before { content: attr(data-label); display: block; margin-bottom: 3px; color: var(--muted); font-size: 11.5px; }
  .pf-table td.pf-head-cell { grid-column: 1 / -1; padding-right: 116px; padding-bottom: 4px; border-bottom: 1px solid var(--line-soft); }
  .pf-table td.pf-head-cell::before, .pf-table td.acts::before { content: none; }
  .pf-table td.pf-skip { display: none; }
  .pf-table td.acts { position: absolute; top: 12px; right: 10px; display: flex; gap: 2px; }
  .pf-table .num { text-align: left; }
  .pf-bar { width: 64px; }
  .pf-clubs .pf-head-cell { padding-right: 0; }
  .pf-price { display: flex; gap: 6px; }
  .pf-price input[type="number"] { flex: 1 1 auto; width: 100%; min-width: 0; }
  .pf-price span { flex: none; white-space: nowrap; }
  .pf-table tr.pf-row.asking { border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); margin-bottom: 0; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
  .pf-row.asking td { background: none; }
  .pf-table tr.pf-confirm { display: block; padding: 0; margin-top: -1px; border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); border-top: 0; border-top-left-radius: 0; border-top-right-radius: 0; background: color-mix(in srgb, var(--bad) 7%, var(--panel)); }
  .pf-confirm td { display: block; background: none; }
  .pf-confirm td::before { content: none; }
  .pf-confirm div { padding: 10px 14px 12px; }
  .pf-table tr.pf-empty { display: block; }
  .pf-empty td { display: block; }
  .pf-empty td::before { content: none; }
}

/* ---- 回放台 ---------------------------------------------------------------- */
.st-form { display: flex; gap: 8px; align-items: center; }
.st-form input { width: 230px; font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.st-landing { max-width: 640px; }
.st-landing .st-form input { flex: 1; height: 40px; font-size: 18px; }
.st-landing .st-form button { height: 40px; padding: 0 22px; font-size: 15px; }
.st-landing .note { margin-top: 10px; line-height: 1.6; }
.st-h2 { font-size: 12px; color: var(--muted); font-weight: 600; margin: 24px 0 8px; }
.st-recent { display: grid; gap: 6px; }
.st-recent-item { display: flex; align-items: baseline; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--text); text-decoration: none; }
.st-recent-item:hover { background: var(--hover); }
.st-recent-item b { font-family: var(--mono); font-weight: 600; }
.st-bar .st-form input { width: 190px; }
.st-room { grid-template-columns: minmax(0, 1fr) 360px; }
#st-board-wrap .game-canvas { margin: 0 auto; width: min(100%, calc((100vh - 250px) * 16 / 9)); }
#st-seek { width: 100%; margin: 10px 0 6px; accent-color: var(--accent); }
.st-under { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.st-under .persp { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; color: var(--muted); font-size: 12px; }
.st-under .persp button { height: 24px; padding: 0 8px; }
.st-under .persp button.on { border-color: var(--accent); color: var(--accent); }
.st-hands { margin-top: 10px; align-items: center; }
.st-hands a.chip { display: inline-flex; align-items: center; border: 1px solid var(--line); text-decoration: none; }
.st-dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; }
.st-dl dt { color: var(--muted); }
.st-dl dd { margin: 0; }
.st-seats { width: 100%; border-collapse: collapse; }
.st-seats th { font-size: 12px; font-weight: 500; color: var(--muted); text-align: left; padding: 0 0 6px; }
.st-seats td { padding: 7px 0; border-top: 1px solid var(--line-soft); vertical-align: middle; }
.st-seats .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; padding-left: 8px; }
.st-seats tr.r-win td:first-child b { color: var(--score); }
.st-wind { display: inline-block; width: 20px; color: var(--muted); }
.st-result { line-height: 2; }
.st-result .st-tai { margin-left: 4px; }
.st-fan { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.st-tile { display: inline-block; padding: 0 5px; border-radius: 4px; line-height: 22px; font-size: 13px; font-weight: 600; background: var(--tile); border: 1px solid var(--tile-edge); box-shadow: 0 2px 0 var(--tile-side); }
.st-tile.man { color: var(--man); }
.st-tile.sou { color: var(--sou); }
.st-tile.pin { color: var(--pin); }
.st-tile.honor { color: #1f2328; }
.st-tile.flower { color: var(--flower); }
.st-tiles { display: flex; flex-wrap: wrap; gap: 6px 4px; margin-top: 8px; }
.st-wall summary { cursor: pointer; font-size: 12px; color: var(--muted); font-weight: 600; }
.st-steps { max-height: 340px; overflow: auto; position: relative; border: 1px solid var(--line); border-radius: var(--radius); }
.st-step { display: grid; grid-template-columns: 34px minmax(0, 7em) 1fr; gap: 6px; align-items: center; padding: 4px 8px; font-size: 13px; cursor: pointer; border-bottom: 1px solid var(--line-soft); }
.st-step:last-child { border-bottom: 0; }
.st-step:hover { background: var(--hover); }
.st-step.future { color: var(--muted); }
.st-step.current { background: var(--pick); box-shadow: inset 3px 0 0 var(--accent); }
.st-n { color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.st-who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-step.k-chi .st-what, .st-step.k-peng .st-what, .st-step.k-gang .st-what, .st-step.k-ting .st-what { color: var(--link); font-weight: 600; }
.st-step.k-hu .st-what, .st-step.k-zimo .st-what { color: var(--bad); font-weight: 700; }
.st-step.k-settle .st-what { font-weight: 600; }
.st-step.future .st-what { color: inherit; font-weight: inherit; }
@media (max-width: 980px) {
  .st-room { grid-template-columns: minmax(0, 1fr); }
  .st-bar .st-form { flex-basis: 100%; }
  .st-bar .st-form input { flex: 1; width: auto; }
  #st-board-wrap .game-canvas { width: 100%; }
}
