  :root {
    color-scheme: light dark;
    --bg: #fbfbfc;
    --surface: #ffffff;
    --surface-2: #f4f4f7;
    --text: #1b1b20;
    --muted: #6a6a76;
    --border: #dcdce3;
    --border-strong: #bcbcc7;
    --accent: #4f46e5;
    --accent-text: #ffffff;
    --danger: #c62d2d;
    --danger-bg: #fbeaea;
    --ok: #1c7c43;
    --ok-bg: #e7f5ec;
    --warn: #8a5a00;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 8px 24px rgba(0, 0, 0, 0.06);
  }
  @media (prefers-color-scheme: dark) {
    :root {
      --bg: #0f0f13;
      --surface: #17171c;
      --surface-2: #1e1e25;
      --text: #e9e9ef;
      --muted: #9a9aa7;
      --border: #2c2c35;
      --border-strong: #3c3c48;
      --accent: #8b83ff;
      --accent-text: #12121a;
      --danger: #ff7a7a;
      --danger-bg: #3a1f1f;
      --ok: #5fd98d;
      --ok-bg: #17321f;
      --warn: #e6b45c;
      --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
    }
  }

  * { box-sizing: border-box; }
  body {
    font: 15px/1.55 -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", sans-serif;
    color: var(--text);
    background: var(--bg);
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 1rem 5rem;
    -webkit-text-size-adjust: 100%;
  }

  h1 { font-size: 1.35rem; margin: 0; }
  h2 { font-size: 1.05rem; margin: 0 0 0.25rem; }
  h3 { font-size: 1rem; margin: 0 0 0.5rem; }
  p { margin: 0.4rem 0; }
  code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.85em;
    background: var(--surface-2);
    padding: 0.1em 0.35em;
    border-radius: 4px;
  }
  .muted { color: var(--muted); font-size: 0.85rem; }
  .error { color: var(--danger); }

  /* ---- explainer ---- */
  details.explainer > summary {
    cursor: pointer;
    font-weight: 600;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.45rem;
  }
  details.explainer > summary::-webkit-details-marker { display: none; }
  details.explainer > summary::before {
    content: "▸";
    display: inline-block;
    color: var(--muted);
    transition: transform 0.15s ease;
  }
  details.explainer[open] > summary::before { transform: rotate(90deg); }
  details.explainer .explainer-body { margin-top: 0.75rem; font-size: 0.88rem; }
  details.explainer .explainer-body p { margin: 0.5rem 0; }
  details.explainer .explainer-body ol { margin: 0.5rem 0; padding-left: 1.2rem; }
  details.explainer .explainer-body li { margin: 0.35rem 0; }

  section { margin-top: 2.25rem; }
  .section-desc { color: var(--muted); font-size: 0.85rem; margin: 0.15rem 0 1rem; }

  /* ---- controls ---- */
  input, textarea, select, button {
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
  }
  input, select {
    padding: 0.5rem 0.6rem;
    min-height: 2.5rem;
    width: 100%;
  }
  select { appearance: auto; }
  textarea {
    padding: 0.55rem 0.65rem;
    width: 100%;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.82rem;
    line-height: 1.5;
    tab-size: 2;
  }
  input:focus, textarea:focus, select:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
    border-color: var(--accent);
  }
  input::placeholder, textarea::placeholder { color: var(--muted); }

  button {
    padding: 0.5rem 0.9rem;
    min-height: 2.5rem;
    cursor: pointer;
    background: var(--surface);
    border-color: var(--border-strong);
    white-space: nowrap;
  }
  button:hover { background: var(--surface-2); }
  button:active { transform: translateY(1px); }
  .btn-primary {
    background: var(--accent);
    color: var(--accent-text);
    border-color: transparent;
    font-weight: 600;
  }
  .btn-primary:hover { background: var(--accent); filter: brightness(1.07); }
  .btn-danger { color: var(--danger); border-color: var(--border-strong); }
  .btn-danger:hover { background: var(--danger-bg); }
  .btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--muted);
    padding: 0.35rem 0.5rem;
    min-height: 2rem;
  }
  .btn-ghost:hover { background: var(--surface-2); color: var(--text); }
  button:disabled { opacity: 0.4; cursor: not-allowed; }
  button:disabled:hover { background: var(--surface); transform: none; }

  /* ---- generic form layout ---- */
  .form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
    gap: 0.75rem 0.85rem;
    align-items: start;
  }
  .field { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }
  .field > label {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
  }
  .field .hint { font-size: 0.75rem; color: var(--muted); }
  .form-actions {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  /* ---- cards ---- */
  .card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    padding: 1rem 1.1rem;
    margin: 0.85rem 0;
    box-shadow: var(--shadow);
  }
  .card-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 0.75rem;
  }
  .card-head .id { color: var(--muted); font-size: 0.8rem; word-break: break-all; }
  .card-head-actions { display: flex; gap: 0.4rem; flex-shrink: 0; }

  .edit-row { margin-top: 0.85rem; padding-top: 0.85rem; border-top: 1px dashed var(--border); }

  /* ---- playlist ---- */
  .playlist { margin-top: 1rem; }
  .pl-empty { color: var(--muted); font-size: 0.85rem; margin: 0.5rem 0 0.75rem; }
  .slot {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    padding: 0.75rem 0.85rem 0.85rem;
    margin: 0.6rem 0;
  }
  .slot-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.6rem;
  }
  .slot-title { font-weight: 600; font-size: 0.82rem; color: var(--muted); letter-spacing: 0.03em; }
  .slot-actions { display: flex; gap: 0.15rem; align-items: center; }
  .slot-fields { align-items: start; margin-bottom: 0.7rem; }
  .dur-wrap { display: flex; align-items: baseline; gap: 0.5rem; }
  .dur-wrap input { max-width: 8rem; }
  .dur-hint { white-space: nowrap; }

  .json-field { gap: 0.35rem; }
  .json-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.35rem 0.6rem;
  }
  .json-tools { display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; }
  .json-status { font-size: 0.75rem; font-family: ui-monospace, monospace; }
  .json-status.is-ok { color: var(--ok); }
  .json-status.is-bad { color: var(--danger); }
  textarea.pl-config { resize: none; min-height: 4.5rem; overflow-y: hidden; }
  textarea.is-invalid { border-color: var(--danger); outline-color: var(--danger); }
  .json-note { margin: 0; }

  .pl-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.85rem;
  }
  .pl-bar .spacer { flex: 1 1 auto; }
  .pl-save-status { font-size: 0.8rem; }
  .pl-save-status.is-warn { color: var(--warn); }
  .pl-save-status.is-ok { color: var(--ok); }

  /* ---- flow diagram (playlist -> content -> MQTT -> device) ---- */
  .flow {
    display: flex;
    align-items: stretch;
    gap: 0.35rem;
    margin: 0.85rem 0 0.6rem;
    overflow-x: auto;
    padding-bottom: 0.15rem;
  }
  .flow-step {
    flex: 1 1 0;
    min-width: 6.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.15rem;
    padding: 0.55rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
  }
  .flow-step {
    transition: border-color 0.25s ease, background 0.25s ease, box-shadow 0.25s ease;
  }
  .flow-step.is-live {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 12%, var(--surface-2));
    color: var(--accent);
    animation: flow-pulse-accent 2.2s ease-in-out infinite;
  }
  .flow-step.is-push {
    border-color: var(--warn);
    background: color-mix(in srgb, var(--warn) 14%, var(--surface-2));
    color: var(--warn);
    animation: flow-pulse-warn 2.2s ease-in-out infinite;
  }
  .flow-step.is-empty { opacity: 0.55; }
  .flow-icon { line-height: 1; color: var(--muted); }
  .flow-step.is-live .flow-icon, .flow-step.is-push .flow-icon { color: inherit; }
  .flow-icon svg { display: block; width: 1.3rem; height: 1.3rem; }
  .flow-label { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; color: var(--muted); }
  .flow-sub { font-size: 0.78rem; word-break: break-word; color: var(--text); }
  .flow-arrow {
    align-self: center;
    flex: 0 0 auto;
    color: var(--border-strong);
    display: flex;
    align-items: center;
  }
  .flow-arrow svg { display: block; width: 1.5rem; height: 0.8rem; }
  .flow-arrow.is-active { color: var(--accent); }
  .flow-arrow.is-active .flow-arrow-dash { animation: flow-dash 0.6s linear infinite; }

  @keyframes flow-dash { to { stroke-dashoffset: -8; } }
  @keyframes flow-pulse-accent {
    0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent); }
    50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 0%, transparent); }
  }
  @keyframes flow-pulse-warn {
    0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--warn) 45%, transparent); }
    50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--warn) 0%, transparent); }
  }
  @media (prefers-reduced-motion: reduce) {
    .flow-step.is-live, .flow-step.is-push, .flow-arrow.is-active .flow-arrow-dash { animation: none; }
  }

  .rotation-bar-wrap { margin: 0.4rem 0 1rem; }
  .rotation-bar {
    position: relative;
    display: flex;
    height: 1.4rem;
    border-radius: 999px;
    overflow: hidden;
    background: var(--surface-2);
    border: 1px solid var(--border);
  }
  .rotation-seg {
    height: 100%;
    background: var(--border-strong);
    border-right: 1px solid var(--surface);
    position: relative;
  }
  .rotation-seg:last-child { border-right: none; }
  .rotation-seg.type-vocab { background: color-mix(in srgb, var(--accent) 55%, var(--surface-2)); }
  .rotation-seg.type-blank { background: var(--surface-2); }
  .rotation-seg.type-message { background: color-mix(in srgb, var(--warn) 55%, var(--surface-2)); }
  .rotation-seg.is-current { outline: 2px solid var(--accent); outline-offset: -2px; }
  .rotation-marker {
    position: absolute;
    top: -2px;
    bottom: -2px;
    width: 2px;
    background: var(--text);
    transition: left 1s linear;
  }
  .rotation-caption { display: flex; justify-content: space-between; gap: 0.5rem; margin-top: 0.3rem; }

  .updated-at { font-size: 0.75rem; color: var(--muted); }

  /* ---- activity feed ---- */
  .activity-list { display: flex; flex-direction: column; gap: 0; }
  .activity-row {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    padding: 0.55rem 0;
    border-bottom: 1px solid var(--border);
  }
  .activity-row:last-child { border-bottom: none; }
  .activity-dot {
    flex: 0 0 auto;
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 999px;
    background: var(--muted);
    margin-top: 0.35rem;
  }
  .activity-dot.is-ok { background: var(--ok); }
  .activity-dot.is-danger { background: var(--danger); }
  .activity-dot.is-accent { background: var(--accent); }
  .activity-dot.is-warn { background: var(--warn); }
  .activity-main { flex: 1 1 auto; min-width: 0; }
  .activity-detail { color: var(--muted); }
  .activity-time { flex: 0 0 auto; color: var(--muted); font-size: 0.8rem; white-space: nowrap; }

  /* ---- api keys ---- */
  .key-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    margin: 0.5rem 0;
  }

  /* ---- login ---- */
  #login {
    max-width: 24rem;
    margin: 3rem auto 0;
    text-align: center;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    padding: 2rem 1.5rem;
    box-shadow: var(--shadow);
  }
  #login button { width: 100%; margin-top: 1rem; }

  #app[hidden], #login[hidden] { display: none; }

  /* ---- toasts ---- */
  #toasts {
    position: fixed;
    left: 50%;
    bottom: 1.25rem;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: min(92vw, 32rem);
    z-index: 50;
  }
  .toast {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--border);
    border-left: 3px solid var(--muted);
    border-radius: var(--radius-sm);
    background: var(--surface);
    box-shadow: var(--shadow);
    font-size: 0.88rem;
    transition: opacity 0.2s ease;
  }
  .toast .toast-msg { flex: 1 1 auto; }
  .toast .toast-x {
    border: none;
    background: transparent;
    color: var(--muted);
    padding: 0 0.25rem;
    min-height: auto;
    font-size: 1.1rem;
    line-height: 1;
  }
  .toast.toast-error { border-left-color: var(--danger); }
  .toast.toast-ok { border-left-color: var(--ok); }

  /* ---- modal ---- */
  .modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: grid;
    place-items: center;
    padding: 1rem;
    z-index: 60;
  }
  .modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    width: min(92vw, 28rem);
    box-shadow: var(--shadow);
  }
  .modal input { margin-top: 0.75rem; font-family: ui-monospace, monospace; font-size: 0.8rem; }
  .modal-actions { display: flex; gap: 0.5rem; margin-top: 1rem; }
  .modal-actions button { flex: 1 1 auto; }

  @media (max-width: 480px) {
    body { padding: 1rem 0.75rem 5rem; }
    .card { padding: 0.85rem; }
    .dur-wrap input { max-width: 100%; }
  }


/* =====================================================================
   v2 layout: header + tabs, views, and the helper widgets
   ===================================================================== */

.appbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem;
  padding: 0.75rem 0; margin-bottom: 1.25rem;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: baseline; gap: 0.75rem; flex-wrap: wrap; margin-right: auto; }
.worker-badge { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.8rem; }
.worker-badge .activity-dot { margin-top: 0; }
.nav { display: flex; gap: 0.2rem; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  padding: 0.4rem 0.8rem; border-radius: 999px; color: var(--muted);
  text-decoration: none; font-weight: 600; font-size: 0.9rem; white-space: nowrap;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.is-on { background: var(--accent); color: var(--accent-text); }
.logout button { min-height: 2rem; }
@media (max-width: 700px) {
  .brand { margin-right: 0; }
  .nav { order: 3; width: 100%; }
  .logout { margin-left: auto; }
}

#view { min-height: 40vh; }
.page-head { margin-bottom: 1rem; }
.page-head h2 { font-size: 1.4rem; margin: 0; }
.page-head-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 0.4rem; }
.section-head h3 { margin: 0; }
section { margin-top: 1.75rem; }
h4 { font-size: 0.9rem; margin: 1rem 0 0.2rem; }
a { color: var(--accent); }
.field-wide { grid-column: 1 / -1; }
.warn-note { color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent); padding: 0.5rem 0.7rem; border-radius: var(--radius-sm); font-size: 0.85rem; }
.warn-text { color: var(--warn) !important; }

/* ---- checklist ---- */
.steps { list-style: none; margin: 0.75rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.step { display: flex; align-items: center; gap: 0.8rem; padding: 0.6rem 0.7rem; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.step.is-next { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
.step.is-done { opacity: 0.65; }
.step-main { flex: 1 1 auto; min-width: 0; }
.step-mark {
  flex: 0 0 auto; width: 1.7rem; height: 1.7rem; border-radius: 999px; display: grid; place-items: center;
  font-weight: 700; font-size: 0.85rem; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border-strong);
}
.step.is-next .step-mark { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.step.is-done .step-mark, .all-set .step-mark { background: var(--ok); color: #fff; border-color: transparent; }
.all-set { display: flex; align-items: center; gap: 0.8rem; }

/* ---- device cards ---- */
.device-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr)); gap: 0.85rem; margin-top: 0.5rem; }
.device-grid .card { margin: 0; }
.device-card { display: flex; flex-direction: column; gap: 0.6rem; border-left: 4px solid var(--border-strong); }
.device-card.status-online { border-left-color: var(--ok); }
.device-card.status-idle { border-left-color: var(--warn); }
.device-card.status-offline { border-left-color: var(--danger); }
.dc-head { display: flex; align-items: flex-start; gap: 0.7rem; }
.dc-icon { flex: 0 0 auto; width: 2.4rem; height: 2.4rem; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); color: var(--accent); }
.dc-icon svg { width: 1.35rem; height: 1.35rem; }
.dc-title { flex: 1 1 auto; min-width: 0; }
.dc-title h3 { margin: 0; overflow-wrap: anywhere; }
.status-pill { margin-top: 0.4rem; display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.75rem; font-weight: 600; padding: 0.2rem 0.55rem; border-radius: 999px; background: var(--surface-2); white-space: nowrap; }
.status-pill .dot { width: 0.5rem; height: 0.5rem; border-radius: 999px; background: var(--muted); }
.status-pill.status-online { color: var(--ok); background: var(--ok-bg); }
.status-pill.status-online .dot { background: var(--ok); }
.status-pill.status-idle { color: var(--warn); }
.status-pill.status-idle .dot { background: var(--warn); }
.status-pill.status-offline { color: var(--danger); background: var(--danger-bg); }
.status-pill.status-offline .dot { background: var(--danger); }
.stat-chips, .chip-row { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.stat-chip { font-size: 0.78rem; padding: 0.15rem 0.55rem; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); white-space: nowrap; }
.dc-lines { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.85rem; }
.dc-line { display: flex; align-items: center; gap: 0.5rem; }
.dc-line svg { flex: 0 0 auto; width: 1rem; height: 1rem; color: var(--muted); }
.dc-line.warn { color: var(--warn); }
.dc-hint { margin: 0; font-size: 0.82rem; color: var(--muted); }
.dc-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: auto; padding-top: 0.4rem; border-top: 1px dashed var(--border); }
.empty-state { text-align: center; padding: 2rem 1rem; grid-column: 1 / -1; }
.mini-list { display: flex; flex-direction: column; gap: 0.4rem; }
.mini-row { display: flex; align-items: center; gap: 0.7rem; padding: 0.6rem 0.8rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.mini-icon svg { width: 1.2rem; height: 1.2rem; color: var(--muted); display: block; }

/* ---- chips, segmented control ---- */
.chip { min-height: 2rem; padding: 0.2rem 0.75rem; border-radius: 999px; font-size: 0.85rem; background: var(--surface); }
.chip.is-on { background: var(--accent); color: var(--accent-text); border-color: transparent; font-weight: 600; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 0; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.seg-btn { border: none; border-radius: 0; background: transparent; min-height: 2.2rem; padding: 0.35rem 0.85rem; font-size: 0.88rem; }
.seg-btn + .seg-btn { border-left: 1px solid var(--border); }
.seg-btn.is-on { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.seg-btn.is-on:hover { background: var(--accent); }

/* ---- station picker ---- */
.stop-picker { position: relative; }
.stop-picker input.is-unset { border-color: var(--warn); }
.stop-menu { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); box-shadow: var(--shadow); max-height: 15rem; overflow-y: auto; }
.stop-opt { display: flex; width: 100%; justify-content: space-between; gap: 1rem; border: none; border-radius: 0; text-align: left; background: transparent; }
.stop-opt:hover { background: var(--surface-2); }
.stop-empty { padding: 0.6rem 0.8rem; }

/* ---- departure rows + test results ---- */
.spec-list { display: flex; flex-direction: column; gap: 0.7rem; margin-bottom: 0.5rem; }
.spec-card { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); padding: 0.8rem; display: flex; flex-direction: column; gap: 0.7rem; }
.spec-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 0.7rem; }
.spec-grid-3 { grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); }
.spec-actions { display: flex; gap: 0.4rem; justify-content: space-between; }
.btn-remove { color: var(--danger); }
.test-result { border-radius: var(--radius-sm); padding: 0.6rem 0.8rem; font-size: 0.88rem; background: var(--surface); border: 1px solid var(--border); }
.test-result.is-ok { border-color: var(--ok); background: var(--ok-bg); }
.test-result.is-bad { border-color: var(--danger); background: var(--danger-bg); }
.test-result.is-warn { border-color: var(--warn); }
.test-items { margin: 0.4rem 0 0; padding-left: 1.1rem; }
.test-counts { margin-top: 0.2rem; }

/* ---- "only when" ---- */
.when { display: flex; flex-direction: column; gap: 0.6rem; }
.when-body { display: flex; flex-direction: column; gap: 0.8rem; padding: 0.8rem; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); }
.when-summary { margin: 0; }
.time-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.time-row input[type="time"] { width: auto; }
label.check { display: inline-flex; align-items: center; gap: 0.4rem; text-transform: none; letter-spacing: 0; font-size: 0.9rem; font-weight: 500; color: var(--text); }
label.check input, label.radio input { width: auto; min-height: 0; }
label.radio { display: flex; align-items: flex-start; gap: 0.5rem; text-transform: none; letter-spacing: 0; font-size: 0.92rem; font-weight: 500; color: var(--text); }

/* ---- playlist slots ---- */
.slot-headline { display: flex; flex-direction: column; min-width: 0; }
.slot-summary { font-size: 0.8rem; }
.slot { display: flex; flex-direction: column; gap: 0.85rem; }
.slot-head { margin-bottom: 0; }
.dur-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.9rem; }
.dur-custom { display: inline-flex; align-items: center; gap: 0.4rem; }
.dur-custom input { width: 6rem; }
.json-preview { margin: 0.5rem 0 0; padding: 0.6rem 0.7rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 0.78rem; overflow-x: auto; }
details.advanced > summary { cursor: pointer; color: var(--muted); font-size: 0.85rem; padding: 0.2rem 0; }
details.advanced[open] > summary { margin-bottom: 0.5rem; }
.rotation-seg.type-departures { background: color-mix(in srgb, var(--ok) 55%, var(--surface-2)); }
.range-row { display: flex; align-items: center; gap: 0.7rem; }
.range-row input { min-height: 0; padding: 0; }
.chip-row.linked { margin-top: 0.35rem; }

/* ---- wizard, token dialog, copy rows ---- */
.modal-wide { width: min(94vw, 40rem); max-height: 92vh; overflow-y: auto; }
.preset-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 0.7rem; margin-top: 0.8rem; }
.preset-tile { display: flex; flex-direction: column; align-items: flex-start; gap: 0.3rem; text-align: left; padding: 0.9rem; white-space: normal; min-height: 7rem; }
.preset-tile:hover { border-color: var(--accent); }
.preset-icon { color: var(--accent); }
.preset-icon svg { width: 1.6rem; height: 1.6rem; display: block; }
.form-stack { display: flex; flex-direction: column; gap: 0.9rem; margin: 0.9rem 0; }
.copy-row { display: flex; gap: 0.4rem; margin: 0.35rem 0; }
.copy-row input { font-family: ui-monospace, Menlo, monospace; font-size: 0.8rem; margin: 0; }
.modal .copy-row input { margin-top: 0; }
.setup-steps { padding-left: 1.2rem; margin: 0.4rem 0 0.9rem; }
.setup-steps li { margin: 0.5rem 0; }
.test-box { display: flex; flex-direction: column; gap: 0.5rem; align-items: flex-start; margin: 0.8rem 0; }
.test-box .test-result { align-self: stretch; }
.token-dialog h4 { margin-top: 1rem; }
.modal h3 { margin-top: 0; }
@media (max-width: 480px) {
  .seg { width: 100%; }
  .seg-btn { flex: 1 1 auto; }
}

/* a rule like `.x { display: flex }` would otherwise defeat the hidden attribute */
[hidden] { display: none !important; }
.hint { font-size: 0.78rem; color: var(--muted); margin: 0.2rem 0; }
.field > label .muted { font-size: inherit; font-weight: 500; text-transform: none; letter-spacing: 0; }

/* collapsible playlist slots */
.slot-head { cursor: pointer; }
.slot-toggle { display: flex; align-items: center; gap: 0.6rem; border: none; background: transparent; padding: 0; min-height: 0; text-align: left; flex: 1 1 auto; min-width: 0; white-space: normal; }
.slot-toggle:hover { background: transparent; }
.slot-toggle .chev { color: var(--muted); transition: transform 0.15s ease; flex: 0 0 auto; }
.slot.is-open .slot-toggle .chev { transform: rotate(90deg); }
.slot-content { display: flex; flex-direction: column; gap: 0.85rem; padding-top: 0.2rem; }
.slot:not(.is-open) { gap: 0; }
.slot-title { color: var(--text); font-size: 0.9rem; }
