/* Tokens */
:root {
  color-scheme: light dark;
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-2: #eef1f0;
  --text: #17201d;
  --muted: #5b6863;
  --border: #d5dcd9;
  --accent: #1f6f5c;
  --accent-text: #ffffff;
  --danger: #b3261e;
  --danger-text: #ffffff;
  --warn: #8a5a00;
  --ok: #1f6f5c;
  --focus: #2b7de9;
  --radius: 10px;
  --gap: 1rem;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1412;
    --surface: #171e1b;
    --surface-2: #1f2824;
    --text: #e4ebe8;
    --muted: #94a39d;
    --border: #2c3833;
    --accent: #5fc3a6;
    --accent-text: #08201a;
    --danger: #f2827a;
    --danger-text: #2a0705;
    --warn: #e8b85a;
    --ok: #5fc3a6;
  }
}

/* Base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 var(--font);
}
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.25rem; }
h2 { font-size: 1.1rem; margin-bottom: .75rem; }
h3 { font-size: 1rem; margin: 1.25rem 0 .5rem; }
p { margin: 0; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.material-symbols-outlined { font-size: 1.25em; line-height: 1; vertical-align: middle; }

/* Layout */
.masthead {
  display: flex; align-items: center; gap: .6rem;
  padding: .9rem 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.masthead > .material-symbols-outlined { color: var(--accent); font-size: 1.75rem; }
.masthead .badge { margin-left: auto; }
.layout {
  display: grid; gap: var(--gap);
  padding: var(--gap) 16px 3rem;
  max-width: 1100px; margin: 0 auto;
}
@media (min-width: 900px) {
  /* Left column stacks account, run, notes; sequence fills the right column.
     The trailing 1fr row absorbs any extra height from the tall sequence card
     so the left-column cards stay packed together. */
  .layout { grid-template-columns: 1fr 1fr; grid-template-rows: auto auto 1fr; align-items: start; }
  .layout > .card { grid-column: 1; }
  .layout > .card-side { grid-column: 2; grid-row: 1 / span 3; }
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  min-width: 0;
}
.stack { display: grid; gap: .75rem; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }

/* Fields */
.field { display: grid; gap: .3rem; min-width: 0; }
.field-row { display: grid; gap: .75rem; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; }
.card > form + .field { margin-top: 1rem; }
label { font-weight: 600; font-size: .9rem; }
input[type="password"], input[type="number"], select, textarea {
  width: 100%;
  font: inherit;
  color: inherit;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .55rem .65rem;
  min-height: 44px;
}
textarea { resize: vertical; font-family: var(--mono); font-size: .875rem; }
.suffix { position: relative; }
.suffix input { padding-right: 1.8rem; }
.suffix span { position: absolute; right: .65rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.check { display: flex; align-items: center; gap: .5rem; font-weight: 400; }
.check input { width: 1.15rem; height: 1.15rem; accent-color: var(--accent); }
.hint { color: var(--muted); font-size: .85rem; font-weight: 400; }
.error { color: var(--danger); font-size: .9rem; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: .35rem;
  min-height: 44px; padding: .5rem .9rem;
  font: inherit; font-weight: 600;
  color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px;
  cursor: pointer;
}
.btn:hover:not(:disabled) { filter: brightness(1.05); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn[data-variant="primary"] { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.btn[data-variant="danger"] { background: var(--danger); color: var(--danger-text); border-color: transparent; }
.btn[data-size="small"] { min-height: 36px; padding: .3rem .7rem; font-size: .875rem; }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px;
  color: var(--text); background: transparent;
  border: 1px solid var(--border); border-radius: 8px; cursor: pointer;
}
.icon-btn:disabled { opacity: .3; cursor: not-allowed; }

/* Badge */
.badge {
  font-size: .8rem; font-weight: 600;
  padding: .2rem .6rem; border-radius: 999px;
  background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--border);
}
.badge[data-state="ok"] { color: var(--ok); border-color: currentColor; }
.badge[data-state="demo"] { color: var(--warn); border-color: currentColor; }

/* Zones */
.zone-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.zone-list li {
  display: flex; align-items: center; gap: .5rem;
  padding: .35rem .5rem;
  background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px;
}
.zone-list li[data-on="false"] { opacity: .6; }
.zone-list .check { flex: 1; min-width: 0; }
.zone-list li { min-width: 0; }
.zone-list .check > span:last-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zone-list .zone-num { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 2.2ch; }
.zone-list li[data-current="true"] { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }

/* Run */
.status { font-weight: 600; min-height: 1.45em; }
.status[data-level="error"] { color: var(--danger); }
.countdown {
  font: 700 3.25rem/1.1 var(--mono);
  font-variant-numeric: tabular-nums;
  margin: .5rem 0;
  color: var(--accent);
}
.countdown[data-phase="pause"] { color: var(--muted); }
progress { width: 100%; height: 10px; accent-color: var(--accent); }
.log-box { margin-top: 1rem; }
.log-box summary { cursor: pointer; font-weight: 600; min-height: 32px; }
.log {
  list-style: none; margin: .5rem 0 0; padding: .5rem;
  max-height: 280px; overflow: auto;
  background: var(--surface-2); border-radius: 8px;
  font: .8rem/1.5 var(--mono);
}
.log time { color: var(--muted); margin-right: .5rem; }
.log li[data-level="warn"] { color: var(--warn); }
.log li[data-level="error"] { color: var(--danger); }
