:root {
  --bg: #f4eee5;
  --surface: #fffaf3;
  --surface-2: #f9f3ea;
  --ink: #2e2924;
  --ink-soft: #564d44;
  --muted: #8a7f73;
  --line: #e5dacb;
  --line-strong: #d6c8b5;
  --accent: #b8775a;
  --accent-ink: #fffaf3;
  --accent-soft: #f1e1d6;
  --sage: #5f8565;
  --sage-bg: #e6eee2;
  --amber: #a8762a;
  --amber-bg: #f6e9cf;
  --rose: #b0574a;
  --rose-bg: #f5e0db;
  --focus: #7c6aa6;
  --focus-bg: #ece7f4;
  --shadow: 0 1px 2px rgba(60, 45, 30, .05), 0 6px 20px -8px rgba(60, 45, 30, .14);
  --radius: 16px;
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1916;
    --surface: #25211d;
    --surface-2: #2b2621;
    --ink: #eee5d8;
    --ink-soft: #cfc4b5;
    --muted: #9a8f82;
    --line: #38312a;
    --line-strong: #4a4137;
    --accent: #d39272;
    --accent-ink: #1c1916;
    --accent-soft: #3a2b23;
    --sage: #93b896;
    --sage-bg: #26322a;
    --amber: #e0b064;
    --amber-bg: #3a2f1c;
    --rose: #e28f80;
    --rose-bg: #3b2422;
    --focus: #b4a5dc;
    --focus-bg: #2d2839;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -10px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app {
  max-width: 1120px;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 16px calc(32px + env(safe-area-inset-bottom));
}

/* Header */
.top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.brand h1 { font: 500 26px/1.15 var(--serif); letter-spacing: -.01em; margin: 0; }
.tagline { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.top-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid transparent;
  background: transparent; color: var(--ink-soft); display: grid; place-items: center;
}
.icon-btn:hover { background: var(--surface); border-color: var(--line); }

.sync { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); padding: 0 6px; }
.sync .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--sage); }
.sync[data-state="saving"] .dot { background: var(--amber); animation: pulse 1s infinite ease-in-out; }
.sync[data-state="offline"] .dot, .sync[data-state="error"] .dot { background: var(--rose); }
@keyframes pulse { 50% { opacity: .35; } }

/* Calibration */
.calibration {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 14px;
}
.cal-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.cal-title { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
.cal-count { font: 500 15px var(--serif); }
.cal-count b { font-weight: 600; }
.cal-bar { display: flex; gap: 3px; margin: 10px 0 8px; }
.cal-seg { flex: 1; height: 6px; border-radius: 3px; background: var(--line); }
.cal-seg.calib { background: color-mix(in srgb, var(--focus) 22%, var(--line)); }
.cal-seg.filled { background: var(--accent); }
.cal-seg.calib.filled { background: var(--focus); }
.cal-note { font-size: 13px; color: var(--ink-soft); margin: 0; }
.cal-note .phase { font-weight: 600; }

/* Banners */
.banner {
  display: flex; gap: 12px; align-items: center; border-radius: var(--radius);
  padding: 12px 16px; margin-bottom: 14px; font-size: 14px;
}
.focus-banner { background: var(--focus-bg); color: var(--ink); border: 1px solid color-mix(in srgb, var(--focus) 30%, transparent); }
.banner-mark { width: 10px; height: 10px; border-radius: 50%; background: var(--focus); flex: none; box-shadow: 0 0 0 5px color-mix(in srgb, var(--focus) 20%, transparent); }

/* Add row */
.add-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.add-blocked { margin: 0; font-size: 13.5px; color: var(--ink-soft); max-width: 560px; flex: 1 1 260px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line-strong);
  background: var(--surface); font-weight: 500; font-size: 14.5px; transition: background .15s, opacity .15s, transform .05s;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 88%, black); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-soft); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.quiet-danger { color: var(--rose); border-color: color-mix(in srgb, var(--rose) 35%, var(--line)); }
.btn:disabled { opacity: .45; }

/* Pipeline */
.pipeline { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 900px) {
  .pipeline { grid-template-columns: 1fr 1fr 1fr; align-items: start; }
}
.stage {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: calc(var(--radius) + 4px);
  padding: 14px; transition: opacity .25s, filter .25s;
}
.stage.locked { opacity: .5; filter: saturate(.5); }
.stage.focus { background: var(--focus-bg); border-color: color-mix(in srgb, var(--focus) 35%, var(--line)); }
.stage-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin: 2px 4px 12px; }
.stage-name { font: 500 17px var(--serif); margin: 0; }
.stage-num { color: var(--muted); font-family: var(--sans); font-size: 12px; font-weight: 500; letter-spacing: .05em; text-transform: uppercase; display: block; margin-bottom: 2px; }
.stage-cap { font-size: 12.5px; color: var(--muted); white-space: nowrap; display: inline-flex; align-items: center; gap: 5px; }
.stage-cap .lock { width: 13px; height: 13px; }
.slots { display: grid; gap: 12px; }

.slot-empty {
  border: 1.5px dashed var(--line-strong); border-radius: var(--radius); padding: 22px 16px;
  text-align: center; color: var(--muted); font-size: 13.5px; min-height: 96px;
  display: grid; place-content: center; gap: 2px;
}
.slot-empty .slot-label { font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; }

/* Card */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow); display: grid; gap: 10px;
}
.slot-label { font-size: 11px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
.card-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.card-name { font: 500 20px/1.2 var(--serif); margin: 2px 0 0; word-break: break-word; }
.platform { display: inline-block; margin-top: 4px; font-size: 12px; color: var(--ink-soft); background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 1px 9px; }
.card-edit { width: 34px; height: 34px; margin: -4px -4px 0 0; border-radius: 10px; border: none; background: transparent; color: var(--muted); display: grid; place-items: center; flex: none; }
.card-edit:hover { background: var(--surface-2); color: var(--ink); }
.notes { margin: 0; font-size: 14px; color: var(--ink-soft); white-space: pre-wrap; word-break: break-word; }
.notes.empty { color: var(--muted); font-style: italic; }

.ttl { border-radius: 12px; padding: 8px 11px; font-size: 13px; display: grid; gap: 1px; }
.ttl b { font-weight: 600; }
.ttl.ok { background: var(--sage-bg); color: var(--sage); }
.ttl.warn { background: var(--amber-bg); color: var(--amber); }
.ttl.alert { background: var(--rose-bg); color: var(--rose); }
.ttl.snoozed { background: var(--focus-bg); color: var(--focus); }
.ttl.paused { background: var(--surface-2); color: var(--muted); }
.ttl .ttl-msg { color: var(--ink-soft); }
.ttl-adjust { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.ttl-btn {
  min-height: 30px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 500;
  border: 1px solid color-mix(in srgb, currentColor 30%, transparent); background: color-mix(in srgb, var(--surface) 60%, transparent); color: inherit;
}
.ttl-btn:hover:not(:disabled) { background: var(--surface); }
.ttl-btn:disabled { opacity: .4; }
.field-hint { font-size: 12.5px; color: var(--muted); }
.optional { font-style: normal; font-weight: 400; color: var(--muted); }

/* Turn counter */
.turns { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; row-gap: 6px; }
.turn-btn, .turn-undo { white-space: nowrap; }
.turn-dots { flex-wrap: wrap; }
.turns-label { font-size: 12px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
.turn-dots { display: inline-flex; gap: 4px; }
.turn-dot { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--line-strong); }
.turn-dot.on { background: var(--sage); border-color: var(--sage); }
.turn-dot.rapport.on { background: var(--amber); border-color: var(--amber); }
.turns-n { font-size: 12.5px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.turns-spacer { flex: 1; }
.turn-undo { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--muted); font-size: 16px; }
.turn-btn { min-height: 34px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--sage); background: var(--sage-bg); color: var(--sage); font-weight: 600; font-size: 13px; }
.turn-btn:hover:not(:disabled) { background: color-mix(in srgb, var(--sage) 18%, var(--sage-bg)); }
.turn-undo:disabled, .turn-btn:disabled { opacity: .45; }

/* Chips in dialogs */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 38px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: transparent; font-size: 14px; color: var(--ink-soft); }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--ink); font-weight: 500; }
#snoozeQuick + input { margin-top: 4px; }
.since { font-size: 12.5px; color: var(--muted); }

.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  min-height: 32px; padding: 0 11px; border-radius: 999px; border: 1px solid var(--line-strong);
  background: transparent; font-size: 12.5px; color: var(--ink-soft); display: inline-flex; align-items: center; gap: 6px;
}
.pill .mark { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--line-strong); display: grid; place-items: center; font-size: 10px; line-height: 1; }
.pill[data-v="pass"] { background: var(--sage-bg); border-color: color-mix(in srgb, var(--sage) 40%, transparent); color: var(--sage); }
.pill[data-v="pass"] .mark { background: var(--sage); border-color: var(--sage); color: var(--surface); }
.pill[data-v="fail"] { background: var(--rose-bg); border-color: color-mix(in srgb, var(--rose) 40%, transparent); color: var(--rose); }
.pill[data-v="fail"] .mark { background: var(--rose); border-color: var(--rose); color: var(--surface); }
.pill:disabled { opacity: .6; }

.card-actions { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 2px; }
.card-actions .btn { min-height: 40px; padding: 0 13px; font-size: 13.5px; }
.card-actions .btn { flex: 1 1 auto; }
.blocked-reason { font-size: 12.5px; color: var(--muted); margin: -2px 0 0; }

/* Archive */
.archive { margin-top: 26px; }
.archive details { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.archive summary { list-style: none; padding: 14px 16px; cursor: pointer; font: 500 15px var(--serif); display: flex; align-items: center; gap: 8px; }
.archive summary::-webkit-details-marker { display: none; }
.archive summary::before { content: ""; width: 7px; height: 7px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(-45deg); transition: transform .2s; margin-right: 4px; }
.archive details[open] summary::before { transform: rotate(45deg); }
.count { font: 500 12px var(--sans); color: var(--muted); background: var(--surface-2); border-radius: 999px; padding: 1px 8px; }
.archive-list { list-style: none; margin: 0; padding: 0 16px 10px; }
.archive-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; }
.archive-list .meta { color: var(--muted); font-size: 12.5px; }
.archive-list .empty { color: var(--muted); font-style: italic; border: none; }
.archive-list .del { border: none; background: transparent; color: var(--muted); font-size: 12.5px; padding: 6px 8px; border-radius: 8px; }
.archive-list .del:hover { color: var(--rose); background: var(--rose-bg); }

.foot { text-align: center; color: var(--muted); font-size: 12px; margin-top: 28px; }

/* Dialogs */
dialog.sheet {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 20px; padding: 0; width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
  box-shadow: 0 24px 60px -20px rgba(40, 28, 18, .45);
}
dialog.sheet::backdrop { background: rgba(40, 30, 22, .35); backdrop-filter: blur(2px); }
@media (max-width: 600px) {
  dialog.sheet { margin: auto auto 0; width: 100vw; max-width: 100vw; border-radius: 20px 20px 0 0; padding-bottom: env(safe-area-inset-bottom); }
}
dialog.sheet form, .sheet-inner { padding: 20px; display: grid; gap: 14px; }
dialog.sheet h2 { font: 500 21px var(--serif); margin: 0; }
.sheet-sub, .hint { margin: -6px 0 0; color: var(--ink-soft); font-size: 14px; }
.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; color: var(--ink-soft); font-weight: 500; }
.field input, .field textarea {
  width: 100%; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--bg);
  padding: 11px 12px; font-size: 16px; resize: vertical;
}
.field input:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.sheet-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-top: 4px; }

.templates { display: grid; gap: 10px; }
.template { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; background: var(--bg); display: grid; gap: 8px; }
.template-label { font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
.template p { margin: 0; font-size: 14px; color: var(--ink); white-space: pre-wrap; }
.template .btn { justify-self: start; min-height: 36px; font-size: 13px; padding: 0 12px; }
.template .btn.copied { background: var(--sage-bg); color: var(--sage); border-color: transparent; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px;
  box-shadow: var(--shadow); max-width: calc(100vw - 32px); z-index: 10;
}
.toast a { color: inherit; font-weight: 600; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Over-limit (after lowering a limit in settings) */
.stage-cap.over { color: var(--rose); font-weight: 600; }
.over-note { margin: -4px 4px 12px; font-size: 12.5px; color: var(--rose); }
.card.over { border-style: dashed; border-color: color-mix(in srgb, var(--rose) 45%, var(--line)); }
.card.over .slot-label { color: var(--rose); }
.cal-bar.dense { gap: 1px; }
.btn.small { min-height: 38px; padding: 0 14px; font-size: 13.5px; }

/* Settings sheet */
dialog.settings-sheet { width: min(760px, calc(100vw - 24px)); height: min(860px, calc(100dvh - 24px)); overflow: hidden; }
@media (max-width: 600px) {
  dialog.settings-sheet { width: 100vw; max-width: 100vw; height: calc(100dvh - 12px); max-height: calc(100dvh - 12px); }
}
.settings-wrap { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr); height: 100%; }
.settings-head, .settings-body { min-width: 0; }
.settings-head { padding: 18px 20px 0; border-bottom: 1px solid var(--line); }
.settings-head h2 { margin-bottom: 10px !important; }
.settings-nav { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 10px; scrollbar-width: none; margin: 0 -4px; }
.settings-nav::-webkit-scrollbar { display: none; }
.settings-nav button { flex: none; border: none; background: transparent; color: var(--ink-soft); font-size: 13px; padding: 7px 10px; border-radius: 999px; }
.settings-nav button:hover { background: var(--surface-2); color: var(--ink); }
.settings-body { overflow-y: auto; padding: 4px 20px 24px; overscroll-behavior: contain; scroll-padding-top: 8px; }
.settings-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface); }

.set-section { padding: 20px 0 6px; border-bottom: 1px solid var(--line); display: grid; gap: 14px; scroll-margin-top: 4px; }
.set-section:last-child { border-bottom: none; }
.set-section h3 { font: 500 18px var(--serif); margin: 0; }
.set-intro, .set-hint { margin: -6px 0 0; font-size: 13.5px; color: var(--ink-soft); }
.set-hint { margin: 0; color: var(--muted); }
.set-intro code, .set-hint code { background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 0 5px; font-size: 12.5px; }

.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.set-label { display: grid; gap: 1px; min-width: 0; }
.set-label > span { font-size: 14.5px; font-weight: 500; }
.set-label > small { font-size: 12.5px; color: var(--muted); }
.set-block { display: grid; gap: 8px; }

.set-stage { background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; display: grid; gap: 10px; }
.set-stage-head { font-size: 11.5px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
.set-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 560px) { .set-grid { grid-template-columns: 2fr 1fr; } }
.set-stage .field input { padding: 9px 11px; font-size: 15px; background: var(--surface); }

.stepper { display: inline-flex; align-items: center; gap: 0; flex: none; }
.stepper button { width: 38px; height: 38px; border: 1px solid var(--line-strong); background: var(--surface); font-size: 17px; color: var(--ink-soft); }
.stepper button:first-child { border-radius: 10px 0 0 10px; }
.stepper button:nth-of-type(2) { border-radius: 0 10px 10px 0; }
.stepper input { width: 54px; height: 38px; text-align: center; border: 1px solid var(--line-strong); border-left: none; border-right: none; background: var(--bg); font-size: 15px; font-variant-numeric: tabular-nums; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper input:focus { outline: none; box-shadow: inset 0 0 0 2px var(--accent-soft); }
.stepper-suffix { margin-left: 8px; font-size: 13px; color: var(--muted); min-width: 44px; }

.switch-row { cursor: pointer; }
.switch { appearance: none; -webkit-appearance: none; flex: none; width: 46px; height: 28px; border-radius: 999px; background: var(--line-strong); position: relative; cursor: pointer; transition: background .15s; margin: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .15s; }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(18px); }

.check-row { display: flex; flex-wrap: wrap; gap: 8px; }
.check-inline { display: inline-flex; align-items: center; gap: 8px; min-height: 38px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 999px; font-size: 14px; cursor: pointer; }
.check-inline input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; border: 1px solid var(--line-strong); background: var(--bg); border-radius: 12px; padding: 6px; }
.tag { display: inline-flex; align-items: center; gap: 2px; padding: 0 2px 0 10px; min-height: 32px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 13.5px; }
.tag button { width: 26px; height: 26px; border: none; background: transparent; color: var(--muted); border-radius: 50%; font-size: 16px; line-height: 1; }
.tag button:hover { background: var(--rose-bg); color: var(--rose); }
.tag-input { flex: 1 1 140px; min-width: 120px; border: none; background: transparent; padding: 6px 6px; font-size: 15px; }
.tag-input:focus { outline: none; }
.plain-input { width: 100%; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--bg); padding: 10px 12px; font-size: 15px; }
.plain-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.list-editor { display: grid; gap: 8px; }
.list-row { display: flex; gap: 8px; }
.list-row input, .tpl-edit input { flex: 1; min-width: 0; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--bg); padding: 9px 11px; font-size: 15px; }
.icon-del { flex: none; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--muted); font-size: 18px; line-height: 1; }
.icon-del:hover { color: var(--rose); background: var(--rose-bg); border-color: transparent; }
.set-section > .btn.small, .tpl-group > .btn.small { justify-self: start; }

.tpl-group { display: grid; gap: 10px; padding-bottom: 6px; }
.tpl-edit { border: 1px solid var(--line); border-radius: 14px; background: var(--bg); padding: 10px; display: grid; gap: 8px; }
.tpl-edit-head { display: flex; gap: 8px; }
.tpl-edit-head input { font-weight: 500; background: var(--surface); }
.tpl-edit textarea { width: 100%; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); padding: 10px 11px; font-size: 14.5px; line-height: 1.5; resize: vertical; }
.list-row input:focus, .tpl-edit input:focus, .tpl-edit textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.data-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.file-btn { cursor: pointer; }

/* Login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 36px 28px 24px; text-align: center; box-shadow: var(--shadow); display: grid; gap: 6px; justify-items: center; }
.login-mark { width: 40px; height: 40px; border-radius: 50%; background: var(--accent); box-shadow: inset 0 0 0 13px var(--accent), inset 0 0 0 20px var(--bg); margin-bottom: 8px; }
.login-card h1 { font: 500 24px/1.2 var(--serif); margin: 0; }
.login-button { margin: 22px 0 4px; min-height: 44px; display: flex; justify-content: center; }
/* Google's button lives in an iframe whose page is light-scheme. If our dark
   color-scheme is inherited, the browser paints an opaque white box behind it.
   Matching the scheme keeps the iframe transparent. */
.login-button, .login-button iframe { color-scheme: light; }
.login-msg { min-height: 20px; margin: 4px 0 0; font-size: 13.5px; color: var(--ink-soft); }
.login-foot { margin: 14px 0 0; font-size: 12px; color: var(--muted); }

/* Waiting for reply */
.waiting { margin-top: 22px; background: var(--surface-2); border: 1px solid var(--line); border-radius: calc(var(--radius) + 4px); padding: 14px; }
.waiting-head { display: flex; align-items: baseline; justify-content: space-between; gap: 6px 12px; flex-wrap: wrap; margin: 2px 4px 12px; }
.waiting-head h2 { font: 500 17px var(--serif); margin: 0; display: flex; align-items: center; gap: 8px; }
.waiting-head p { margin: 0; font-size: 13px; color: var(--muted); }
.waiting-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
@media (min-width: 900px) { .waiting-list { grid-template-columns: 1fr 1fr; } }
.wait-item { display: flex; justify-content: space-between; align-items: center; gap: 10px 14px; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.wait-item.ghosted { background: var(--rose-bg); border-color: color-mix(in srgb, var(--rose) 30%, var(--line)); }
.wait-main { display: grid; gap: 1px; min-width: 0; }
.wait-name { font: 500 17px var(--serif); word-break: break-word; }
.wait-name .meta { font: 400 12.5px var(--sans); color: var(--muted); }
.wait-status { font-size: 13px; font-weight: 600; color: var(--amber); }
.wait-item.ghosted .wait-status { color: var(--rose); }
.wait-from { font-size: 12.5px; color: var(--muted); }
.wait-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.waiting-list .empty { color: var(--muted); font-size: 13.5px; padding: 6px 4px; }
.ttl-btn.muted { opacity: .55; }
