:root {
  --bg: #0f172a; --panel: #1e293b; --panel2: #273449; --text: #e2e8f0; --muted: #94a3b8; --accent: #38bdf8;
  --accent-ink: #04202e; --ok: #4ade80; --warn: #fbbf24; --bad: #f87171; --line: #334155; --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
body { padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
a { color: var(--accent); text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.center { text-align: center; }
.small { font-size: 0.85rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.8rem; word-break: break-all; }

.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--bg); z-index: 5; }
.brand { font-weight: 700; font-size: 1.2rem; color: var(--text); letter-spacing: 0.02em; }
.topnav { margin-left: auto; display: flex; gap: 14px; }
.badge { background: var(--warn); color: #231a00; border-radius: 999px; padding: 2px 10px; font-size: 0.8rem; font-weight: 600; }
.badge.bad { background: var(--bad); color: #2a0000; }
.banner { margin: 12px 16px 0; padding: 10px 14px; border-radius: 10px; background: var(--panel2); font-size: 0.9rem; }
.banner button { margin-left: 8px; }

main { max-width: 640px; margin: 0 auto; padding: 16px 16px 48px; }
h1 { font-size: 1.4rem; margin: 4px 0 16px; }
h2 { font-size: 1.05rem; margin: 22px 0 10px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.card { background: var(--panel); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.card h3 { margin: 0 0 8px; font-size: 1rem; color: var(--muted); font-weight: 600; }
.big { font-size: 2.2rem; font-weight: 700; line-height: 1.1; }
.row { display: flex; align-items: center; gap: 10px; }
.row.spread { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0 18px; }
button, .btn { appearance: none; border: 0; border-radius: 12px; padding: 12px 16px; font: inherit; font-weight: 600;
  background: var(--panel2); color: var(--text); cursor: pointer; min-height: 46px; display: inline-flex;
  align-items: center; justify-content: center; }
button.primary, .btn.primary { background: var(--accent); color: var(--accent-ink); }
button.danger { background: #7f1d1d; color: #fee2e2; }
button.link { background: none; color: var(--accent); padding: 6px 0; min-height: 0; }
button:disabled { opacity: 0.5; cursor: default; }
button.block, .btn.block { width: 100%; }

label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 4px; }
input, select, textarea { width: 100%; font: inherit; font-size: 16px; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; min-height: 46px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.field { margin-bottom: 14px; }
.field .hint { font-size: 0.8rem; color: var(--muted); margin-top: 4px; }
.error { color: var(--bad); font-size: 0.9rem; }
.check { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 1rem; margin-bottom: 12px; }
.check input { width: 22px; height: 22px; min-height: 0; }
.days { display: flex; gap: 6px; flex-wrap: wrap; }
.days label { margin: 0; display: flex; align-items: center; gap: 4px; background: var(--panel2); padding: 8px 10px;
  border-radius: 10px; color: var(--text); }
.days input { width: 18px; height: 18px; min-height: 0; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.list li a { color: var(--text); flex: 1; }
.pill { font-size: 0.75rem; padding: 2px 8px; border-radius: 999px; background: var(--panel2); color: var(--muted); }
.pill.ok { background: #14532d; color: #bbf7d0; }
.pill.bad { background: #7f1d1d; color: #fecaca; }
.pill.warn { background: #713f12; color: #fde68a; }

table.kv { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.kv td { padding: 7px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.kv td:first-child { color: var(--muted); width: 45%; }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 600; z-index: 20;
  max-width: 90vw; text-align: center; }
.steps { padding-left: 20px; }
.steps li { margin-bottom: 10px; }
.spark { width: 100%; height: 56px; display: block; margin-top: 8px; }
.spark polyline { fill: none; stroke: var(--accent); stroke-width: 2; }
.spark circle { fill: var(--muted); }
