:root {
  color-scheme: light dark;
  --bg: #f3f5f8;
  --card: #ffffff;
  --text: #17202b;
  --muted: #5d6877;
  --line: #dde2e9;
  --accent: #2f6fde;
  --accent-text: #ffffff;
  --ok: #1d8a4f;
  --warn: #b7791f;
  --bad: #c7392b;
  --idle: #8a94a3;
  --soft: #eef2f7;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418;
    --card: #1a1f25;
    --text: #e7ebf0;
    --muted: #98a3b1;
    --line: #2c333c;
    --accent: #6b9cff;
    --accent-text: #0d1420;
    --ok: #4cc27f;
    --warn: #e8b04a;
    --bad: #ff6f61;
    --idle: #7d8794;
    --soft: #222932;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.wrap { max-width: 520px; margin: 0 auto; padding: 12px; }

.top { display: flex; align-items: center; gap: 10px; margin: 2px 2px 12px; }
.logo { border-radius: 8px; flex: none; }
.brand { min-width: 0; flex: 1; }
.title { font-weight: 650; font-size: 15px; }
.subtitle { color: var(--muted); font-size: 12px; }

.badge {
  flex: none; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  background: var(--soft); color: var(--muted);
}
.badge[data-tone="ok"] { color: var(--ok); }
.badge[data-tone="warn"] { color: var(--warn); }
.badge[data-tone="bad"] { color: var(--bad); }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 10px; box-shadow: var(--shadow);
}
.card h2 { font-size: 14px; margin: 0 0 6px; }
.card p { margin: 0 0 10px; }
.note { border-color: var(--accent); }
.muted { color: var(--muted); }

.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
input[type="password"], input[type="text"] {
  flex: 1 1 180px; min-width: 0; font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
}
input:focus-visible, button:focus-visible, .paste:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
button {
  font: inherit; font-weight: 600; color: var(--text); background: var(--soft);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; cursor: pointer;
}
button:hover { filter: brightness(.97); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.link {
  background: none; border: none; padding: 4px 2px; color: var(--muted); font-weight: 500;
  text-decoration: underline; text-underline-offset: 2px;
}
button:disabled { opacity: .55; cursor: default; }

.message { min-height: 1em; font-size: 13px; margin: 8px 0 0 !important; }
.message[data-tone="ok"] { color: var(--ok); }
.message[data-tone="bad"] { color: var(--bad); }
.message[data-tone="warn"] { color: var(--warn); }

.status { display: flex; gap: 10px; align-items: flex-start; }
.dot {
  flex: none; width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; background: var(--idle);
}
.status[data-tone="ok"] .dot { background: var(--ok); }
.status[data-tone="warn"] .dot { background: var(--warn); }
.status[data-tone="bad"] .dot { background: var(--bad); }
.status[data-tone="busy"] .dot { background: var(--accent); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .status[data-tone="busy"] .dot { animation: none; } }
.status-title { font-weight: 650; font-size: 15px; }
.status-text { color: var(--muted); }

.shot { margin: 12px 0 0; }
.shot img {
  display: block; width: 100%; max-height: 240px; object-fit: contain;
  background: var(--soft); border: 1px solid var(--line); border-radius: 8px;
}
.shot figcaption { font-size: 12px; margin-top: 4px; }

.paste {
  margin-top: 12px; padding: 12px; text-align: center; font-size: 13px; color: var(--muted);
  border: 1.5px dashed var(--line); border-radius: 8px; cursor: text;
}
.paste.over { border-color: var(--accent); color: var(--text); }
kbd {
  font: 12px ui-monospace, Consolas, monospace; padding: 1px 5px; border-radius: 4px;
  border: 1px solid var(--line); background: var(--soft);
}

.help summary { cursor: pointer; font-weight: 600; }
.help ol { margin: 10px 0 0; padding-left: 20px; color: var(--muted); }
.help li { margin-bottom: 6px; }

.foot { display: flex; gap: 14px; justify-content: center; padding: 2px 0 8px; }

/* ---------- W04: status, form, candidates, deck, settings ---------- */
.small { font-size: 12px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.card-head h2 { margin: 0; }
.badge.small { font-size: 11px; padding: 2px 8px; }
.status-body { flex: 1; min-width: 0; }
.status-progress {
  margin-top: 6px; font-size: 12px; color: var(--muted); background: var(--soft);
  border-radius: 6px; padding: 4px 8px; overflow-wrap: anywhere;
}
button.ghost { background: none; border-color: var(--line); padding: 6px 12px; flex: none; }
button.wide { flex: 1; }

.form { display: grid; gap: 12px; }
.field { display: grid; gap: 5px; min-width: 0; }
.field > span:not(.select) { font-size: 12px; font-weight: 600; color: var(--muted); }
.pair { display: flex; gap: 8px; flex-wrap: wrap; }
.pair > * { flex: 1 1 140px; min-width: 0; }
.pair > .select { flex: 0 1 130px; }
input[type="number"], select {
  font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; min-width: 0;
}
input[type="text"] { flex: 1 1 140px; }
select:focus-visible, input[type="number"]:focus-visible, input[type="text"]:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
.segmented { display: flex; gap: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.segmented label { flex: 1; position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented span {
  display: block; text-align: center; padding: 7px 4px; font-size: 13px; color: var(--muted);
  border-left: 1px solid var(--line);
}
.segmented label:first-child span { border-left: none; }
.segmented input:checked + span { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }

.candidates { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; }
.candidates .divider { font-size: 12px; font-weight: 600; color: var(--muted); padding: 6px 2px 0; }
.candidate {
  width: 100%; text-align: left; display: grid; gap: 3px; background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-weight: 400;
}
.candidate:hover { border-color: var(--accent); filter: none; }
.cand-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.cand-name { font-weight: 650; overflow-wrap: anywhere; }
.cand-meta { font-size: 12px; color: var(--muted); }
.cand-warn { font-size: 12px; color: var(--warn); }
.tag {
  font: 12px ui-monospace, Consolas, monospace; color: var(--muted); background: var(--soft);
  border-radius: 4px; padding: 1px 5px; flex: none;
}

.deck-img {
  display: block; width: 100%; border-radius: 8px; background: var(--soft); margin-bottom: 12px;
}
.deck-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.deck-name { font-weight: 700; font-size: 16px; overflow-wrap: anywhere; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 10px 0; font-size: 13px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.cards-list { margin: 0 0 10px; padding-left: 18px; font-size: 13px; }
.notes { list-style: none; margin: 0 0 8px; padding: 0; font-size: 13px; color: var(--warn); }
.notes:empty { display: none; }

details.card > summary { cursor: pointer; font-weight: 600; }
.settings { display: grid; gap: 10px; margin-top: 10px; }
.switch { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; font-size: 13px; }
.switch input { margin-top: 2px; accent-color: var(--accent); }
.foot { flex-wrap: wrap; }

/* Selects: own arrow with room on the right (the native one sat on the edge). */
.select { position: relative; display: block; min-width: 0; }
.select select {
  width: 100%; appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer;
}
.select::after {
  content: ""; position: absolute; right: 14px; top: 50%; width: 7px; height: 7px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: translateY(-70%) rotate(45deg); pointer-events: none;
}

.status-actions { margin-top: 10px; }
.status-actions button { font-size: 13px; padding: 6px 12px; }
.deck-label {
  font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 8px;
  text-transform: uppercase; letter-spacing: .04em;
}
#deckCard.previous .deck-img { opacity: .8; }

/* Header tools: fast search toggle next to the watch badge (owner 15.11). */
.top-tools { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.pill {
  font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px;
  background: var(--soft); color: var(--muted); border: 1px solid var(--line);
}
.pill[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.shot-settings { display: grid; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.status-actions .primary { font-size: 13px; padding: 6px 14px; }

.shot-actions { margin-top: 8px; }
.shot-actions button { font-size: 13px; padding: 6px 12px; }
