/* VADPath: control-room theme */
:root {
  --font-body: 'General Sans', 'Inter', system-ui, sans-serif;
  --font-display: 'Clash Display', 'General Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'SFMono-Regular', Menlo, monospace;

  --bg: #090e1a;
  --bg-2: #0d1424;
  --surface: #111a2d;
  --surface-2: #182339;
  --surface-3: #1f2c47;
  --ink: #eef3fb;
  --muted: #8b9ab4;
  --line: #22304a;
  --line-2: #2e3f5e;
  --accent: #33d6c4;
  --accent-ink: #052220;
  --accent-soft: rgba(51, 214, 196, 0.14);

  --emergency: #ff4d5e;
  --emergency-soft: rgba(255, 77, 94, 0.16);
  --urgent: #ff8a3d;
  --urgent-soft: rgba(255, 138, 61, 0.16);
  --call: #ffc857;
  --call-soft: rgba(255, 200, 87, 0.16);
  --home: #3ddc84;
  --home-soft: rgba(61, 220, 132, 0.16);
  --blue: #7eaaff;
  --blue-soft: rgba(126, 170, 255, 0.16);

  --display-bg: #05090f;
  --display-ink: #c8ffe8;
  --display-dim: #5f7d70;

  --radius: 14px;
  --radius-lg: 22px;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 12px 40px rgba(0, 0, 0, 0.45);

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.25rem;
  --text-xl: 1.6rem;
  --text-2xl: 2.2rem;
  --text-3xl: 3rem;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-8: 3rem;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; color-scheme: dark; }
html, body { overflow-x: hidden; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--ink);
  background: radial-gradient(1200px 600px at 80% -10%, rgba(51, 214, 196, 0.10), transparent 60%),
              radial-gradient(900px 500px at -10% 110%, rgba(126, 170, 255, 0.08), transparent 60%),
              var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--accent); }
button { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0 0 var(--space-3); line-height: 1.12; letter-spacing: -0.015em; font-family: var(--font-display); }
h1 { font-size: var(--text-2xl); font-weight: 600; }
h2 { font-size: var(--text-xl); font-weight: 600; }
h3 { font-size: var(--text-lg); font-weight: 600; }
p { margin: 0 0 var(--space-3); }
.muted { color: var(--muted); }
.small { font-size: var(--text-sm); }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.skip { position: absolute; left: -999px; top: 0; background: var(--surface); padding: var(--space-2); }
.skip:focus { left: var(--space-2); z-index: 100; }

/* Motion */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 77, 94, 0); } 50% { box-shadow: 0 0 0 6px rgba(255, 77, 94, 0.35); } }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
@keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.enter { animation: rise 0.36s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.enter-2 { animation-delay: 0.06s; }
.enter-3 { animation-delay: 0.12s; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Top bar */
.topbar {
  display: flex; align-items: center; gap: var(--space-4);
  padding: var(--space-3) var(--space-5);
  background: rgba(9, 14, 26, 0.82); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: var(--space-2); color: var(--ink); text-decoration: none; margin-right: auto; }
.brand .logo { color: var(--accent); }
.brand-name { font-family: var(--font-display); font-weight: 600; font-size: var(--text-lg); letter-spacing: -0.01em; }
.nav { display: flex; gap: 2px; }
.nav a {
  color: var(--muted); text-decoration: none; font-weight: 500; font-size: var(--text-sm);
  padding: var(--space-2) var(--space-3); border-radius: 999px;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.sos {
  display: inline-flex; align-items: center; gap: 6px; padding: 0.5rem 0.9rem; border-radius: 999px;
  border: 1px solid var(--emergency); background: var(--emergency-soft); color: #ffb3ba; font-weight: 700; font-size: var(--text-sm); cursor: pointer;
}
.sos:hover { background: var(--emergency); color: #fff; }
@media (max-width: 640px) {
  .topbar { padding: var(--space-2) var(--space-3); gap: var(--space-2); }
  .nav a { padding: var(--space-2) 8px; font-size: var(--text-xs); }
  .sos span { display: none; }
  .sos { padding: 0.5rem 0.6rem; }
}
@media (max-width: 400px) { .brand-name { display: none; } }

.main { flex: 1; width: 100%; max-width: 1040px; margin: 0 auto; padding: var(--space-6) var(--space-5) var(--space-8); }
@media (max-width: 640px) { .main { padding: var(--space-4) var(--space-4) var(--space-8); } }
.footer { border-top: 1px solid var(--line); padding: var(--space-4) var(--space-5); color: var(--muted); font-size: var(--text-xs); text-align: center; }
.footer p { max-width: 760px; margin: 0 auto; }

/* Cards and layout */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: var(--space-5); box-shadow: var(--shadow);
}
.card + .card { margin-top: var(--space-4); }
.grid { display: grid; gap: var(--space-4); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 760px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.row { display: flex; gap: var(--space-3); flex-wrap: wrap; align-items: center; }
.between { justify-content: space-between; }
.stack > * + * { margin-top: var(--space-3); }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: var(--space-5) 0; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  padding: 0.7rem 1.1rem; border-radius: 12px; border: 1px solid var(--line-2);
  background: var(--surface-2); color: var(--ink); font-weight: 600; font-size: var(--text-sm);
  cursor: pointer; text-decoration: none; transition: background 0.15s, transform 0.08s, border-color 0.15s;
}
.btn:hover { background: var(--surface-3); border-color: var(--muted); }
.btn:active { transform: translateY(1px) scale(0.99); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); background: var(--accent); border-color: var(--accent); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); border-color: transparent; }
.btn-lg { padding: 1rem 1.3rem; font-size: var(--text-base); border-radius: 14px; }
.btn-emergency { background: var(--emergency); border-color: var(--emergency); color: #fff; }
.btn-emergency:hover { background: var(--emergency); filter: brightness(1.08); border-color: var(--emergency); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

/* Home */
.hero { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: var(--space-6); align-items: center; padding: var(--space-5) 0 var(--space-6); }
@media (max-width: 860px) { .hero { grid-template-columns: 1fr; } }
.hero h1 { font-size: clamp(2.1rem, 4.6vw, 3.4rem); font-weight: 600; line-height: 1.02; margin-bottom: var(--space-4); }
.hero h1 em { font-style: normal; color: var(--accent); }
.hero p { max-width: 46ch; color: var(--muted); font-size: var(--text-lg); }
.legend { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-4); }
.legend span { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--text-xs); font-weight: 600; color: var(--ink); background: var(--surface-2); border: 1px solid var(--line); padding: 4px 10px; border-radius: 999px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.emergency { background: var(--emergency); box-shadow: 0 0 10px var(--emergency); }
.dot.urgent { background: var(--urgent); box-shadow: 0 0 10px var(--urgent); }
.dot.call { background: var(--call); box-shadow: 0 0 10px var(--call); }
.dot.home { background: var(--home); box-shadow: 0 0 10px var(--home); }

/* Controller mock */
.ctrl { background: linear-gradient(160deg, #1a2440, #0c1222); border: 1px solid var(--line-2); border-radius: 28px; padding: var(--space-4); box-shadow: var(--shadow); position: relative; }
.ctrl .screen { background: var(--display-bg); border-radius: 16px; padding: var(--space-4); font-family: var(--font-mono); color: var(--display-ink); border: 1px solid #1b2a33; min-height: 150px; }
.ctrl .screen .alarm-line { display: flex; align-items: center; gap: var(--space-2); font-weight: 700; font-size: var(--text-base); letter-spacing: 0.02em; min-height: 1.6em; }
.ctrl .screen .lamp { width: 12px; height: 12px; border-radius: 50%; }
.ctrl .screen .vals { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-2); margin-top: var(--space-3); }
.ctrl .screen .vals div { font-size: var(--text-xs); color: var(--display-dim); text-transform: uppercase; letter-spacing: 0.08em; }
.ctrl .screen .vals strong { display: block; font-size: 1.35rem; color: var(--display-ink); font-weight: 600; letter-spacing: 0; }
.ctrl .buttons { display: flex; justify-content: space-between; align-items: center; margin-top: var(--space-4); gap: var(--space-3); }
.ctrl .buttons .lamps { display: flex; gap: 10px; }
.ctrl .buttons .lamps i { width: 14px; height: 14px; border-radius: 50%; background: #222c44; border: 1px solid #33406a; }
.ctrl .buttons .lamps i.on.emergency { background: var(--emergency); box-shadow: 0 0 14px var(--emergency); animation: blink 0.9s infinite; }
.ctrl .buttons .lamps i.on.call { background: var(--call); box-shadow: 0 0 14px var(--call); animation: blink 1.6s infinite; }
.ctrl .buttons .lamps i.on.home { background: var(--home); box-shadow: 0 0 14px var(--home); }
.ctrl .buttons .keys { display: flex; gap: var(--space-2); }
.ctrl .buttons .keys button { width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line-2); background: var(--surface-2); color: var(--muted); cursor: pointer; font-size: 14px; font-weight: 700; }
.ctrl .buttons .keys button:hover { color: var(--ink); background: var(--surface-3); }
.ctrl .caption { font-size: var(--text-xs); color: var(--muted); margin: var(--space-3) 0 0; text-align: center; }

.modes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); }
@media (max-width: 760px) { .modes { grid-template-columns: 1fr; } }
.mode {
  display: block; text-decoration: none; color: var(--ink); position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: var(--space-5); box-shadow: var(--shadow); transition: border-color 0.2s, transform 0.2s;
}
.mode::after { content: '→'; position: absolute; right: var(--space-5); top: var(--space-5); font-size: 1.4rem; color: var(--muted); transition: transform 0.2s, color 0.2s; }
.mode:hover { border-color: var(--accent); transform: translateY(-3px); }
.mode:hover::after { transform: translateX(4px); color: var(--accent); }
.mode .eyebrow { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.1em; color: var(--accent); font-weight: 700; }
.mode.clin .eyebrow { color: var(--blue); }
.mode.clin:hover { border-color: var(--blue); }
.mode h2 { margin: var(--space-2) 0; font-size: var(--text-xl); }
.mode p { color: var(--muted); margin-bottom: var(--space-3); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tags span { font-size: var(--text-xs); padding: 4px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }

/* Call strip and sheet */
.calls { display: grid; gap: var(--space-2); }
.callbtn {
  display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-radius: 14px;
  border: 1px solid var(--line-2); background: var(--surface-2); color: var(--ink); text-decoration: none; transition: background 0.15s, transform 0.08s;
}
.callbtn:hover { background: var(--surface-3); }
.callbtn:active { transform: scale(0.99); }
.callbtn .ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; background: var(--surface-3); color: var(--ink); }
.callbtn .who { font-weight: 700; }
.callbtn .num { font-family: var(--font-mono); color: var(--muted); font-size: var(--text-sm); }
.callbtn.emergency { background: var(--emergency); border-color: var(--emergency); color: #fff; }
.callbtn.emergency .ico { background: rgba(255, 255, 255, 0.2); color: #fff; }
.callbtn.emergency .num { color: rgba(255, 255, 255, 0.85); }
.callbtn.primary { border-color: var(--accent); }
.callbtn.primary .ico { background: var(--accent-soft); color: var(--accent); }
.callbtn.add { border-style: dashed; color: var(--muted); }
.callbtn.add .num { font-family: var(--font-body); }
.sheet[hidden] { display: none; }
.sheet { position: fixed; inset: 0; z-index: 50; display: grid; place-items: end center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(4, 7, 14, 0.7); backdrop-filter: blur(4px); }
.sheet-panel { position: relative; width: min(560px, 100%); background: var(--surface); border: 1px solid var(--line-2); border-radius: 24px 24px 0 0; padding: var(--space-5); animation: rise 0.28s ease both; }
@media (min-width: 640px) { .sheet { place-items: center; } .sheet-panel { border-radius: 24px; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--space-3); }
.sheet-head h2 { margin: 0; }

/* Patient flow */
.flow-head { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-4); }
.progress { flex: 1; height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--blue)); border-radius: 3px; transition: width 0.4s cubic-bezier(0.2, 0.8, 0.2, 1); }
.stepnum { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--muted); white-space: nowrap; }
.step-title { font-family: var(--font-display); font-size: clamp(1.5rem, 3.2vw, 2.1rem); font-weight: 600; line-height: 1.1; margin-bottom: var(--space-2); letter-spacing: -0.015em; }
.step-help { color: var(--muted); margin-bottom: var(--space-4); max-width: 60ch; }
.options { display: grid; gap: var(--space-2); }
.opt {
  display: grid; grid-template-columns: 44px 1fr 20px; align-items: center; gap: var(--space-3); width: 100%; text-align: left;
  padding: var(--space-3) var(--space-4); border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface-2); cursor: pointer; transition: border-color 0.15s, background 0.15s, transform 0.12s; color: var(--ink);
}
.opt:hover { border-color: var(--accent); background: var(--surface-3); transform: translateX(3px); }
.opt:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.opt .glyph { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); }
.opt .glyph.emergency { background: var(--emergency-soft); color: var(--emergency); }
.opt .glyph.call { background: var(--call-soft); color: var(--call); }
.opt .glyph.home { background: var(--home-soft); color: var(--home); }
.opt .glyph.accent { background: var(--accent-soft); color: var(--accent); }
.opt .glyph.blue { background: var(--blue-soft); color: var(--blue); }
.opt .label { font-weight: 600; font-size: var(--text-base); }
.opt .sub { color: var(--muted); font-size: var(--text-sm); margin-top: 1px; }
.opt .chev { color: var(--muted); }
.check {
  display: flex; gap: var(--space-3); align-items: center;
  padding: var(--space-3) var(--space-4); border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface-2); cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.check:hover { border-color: var(--accent); }
.check input { width: 22px; height: 22px; flex: none; accent-color: var(--accent); }
.check.selected { border-color: var(--accent); background: var(--accent-soft); }
.check.none { border-style: dashed; }
.steps { counter-reset: s; list-style: none; padding: 0; margin: 0 0 var(--space-4); }
.steps li { counter-increment: s; display: flex; gap: var(--space-3); padding: var(--space-3) 0; border-bottom: 1px solid var(--line); align-items: flex-start; }
.steps li::before {
  content: counter(s); flex: none; width: 28px; height: 28px; border-radius: 50%;
  background: var(--surface-3); color: var(--ink); font-weight: 700; font-size: var(--text-sm);
  display: inline-flex; align-items: center; justify-content: center;
}
.steps li:last-child { border-bottom: 0; }
.steps li[hidden] { display: none; }
.steps.compact li { padding: var(--space-2) 0; }
.more { color: var(--accent); background: none; border: 0; padding: var(--space-2) 0; font-weight: 600; cursor: pointer; font-size: var(--text-sm); }
.confirm { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-4); }
.confirm p { font-weight: 600; margin-bottom: var(--space-3); font-size: var(--text-lg); font-family: var(--font-display); }
.confirm .row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); max-width: 420px; }

/* Fields */
.field { display: flex; flex-direction: column; gap: var(--space-1); }
.field label { font-weight: 600; font-size: var(--text-sm); }
.field .hint { color: var(--muted); font-size: var(--text-xs); }
.field input, .field select, .field textarea {
  font: inherit; padding: 0.65rem 0.8rem; border: 1px solid var(--line-2); border-radius: 10px;
  background: var(--bg-2); color: var(--ink); width: 100%;
}
.field input:focus, .field select:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.seg { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.seg button {
  padding: 0.55rem 0.95rem; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface-2);
  color: var(--ink); cursor: pointer; font-size: var(--text-sm); font-weight: 500; transition: background 0.15s;
}
.seg button:hover { background: var(--surface-3); }
.seg button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }

/* Controller display */
.display {
  background: var(--display-bg); color: var(--display-ink); border-radius: 16px;
  padding: var(--space-4); font-family: var(--font-mono); display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-3);
  border: 1px solid #1b2a33; box-shadow: inset 0 0 40px rgba(51, 214, 196, 0.04);
}
.display .cell { display: flex; flex-direction: column; gap: 3px; }
.display .k { font-size: var(--text-xs); color: var(--display-dim); text-transform: uppercase; letter-spacing: 0.1em; }
.display .v { font-size: 1.6rem; font-weight: 600; line-height: 1.1; }
.display .u { font-size: var(--text-xs); color: var(--display-dim); }
.display input {
  font-family: var(--font-mono); font-size: 1.5rem; font-weight: 600; background: #030608; color: var(--display-ink);
  border: 1px solid #1f3038; border-radius: 8px; padding: 0.35rem 0.55rem; width: 100%;
}
.display input:focus { outline: 2px solid var(--accent); }
.display .base { font-size: var(--text-xs); color: var(--display-dim); }
@media (max-width: 640px) { .display { grid-template-columns: repeat(2, 1fr); } }

/* Outcomes */
.outcome { border-radius: var(--radius-lg); overflow: hidden; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); }
.outcome-head { padding: var(--space-5); color: #fff; position: relative; }
.outcome-head .tier { display: inline-flex; align-items: center; gap: 8px; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.12em; font-weight: 700; background: rgba(0, 0, 0, 0.22); padding: 6px 12px; border-radius: 999px; }
.outcome-head .tier::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: #fff; }
.outcome-head h2 { color: #fff; font-size: clamp(1.5rem, 3.4vw, 2.2rem); margin: var(--space-3) 0 0; line-height: 1.08; }
.outcome-head .why { color: rgba(255, 255, 255, 0.86); margin: var(--space-3) 0 0; max-width: 60ch; }
.outcome-body { padding: var(--space-5); }
.outcome.emergency .outcome-head { background: linear-gradient(135deg, #e0313f, #ff4d5e); }
.outcome.emergency .outcome-head .tier::before { animation: blink 0.9s infinite; }
.outcome.urgent .outcome-head { background: linear-gradient(135deg, #e0641c, #ff8a3d); }
.outcome.call .outcome-head { background: linear-gradient(135deg, #b98a17, #ffc857); color: #1a1200; }
.outcome.call .outcome-head h2, .outcome.call .outcome-head .why { color: #1a1200; }
.outcome.call .outcome-head .tier { background: rgba(0, 0, 0, 0.12); }
.outcome.call .outcome-head .tier::before { background: #1a1200; }
.outcome.home .outcome-head { background: linear-gradient(135deg, #1f9a55, #3ddc84); color: #03200f; }
.outcome.home .outcome-head h2, .outcome.home .outcome-head .why { color: #03200f; }
.outcome.home .outcome-head .tier { background: rgba(0, 0, 0, 0.12); }
.outcome.home .outcome-head .tier::before { background: #03200f; }
.callrow { display: grid; gap: var(--space-2); grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin-bottom: var(--space-5); }
.callrow .callbtn.emergency { animation: pulse 1.6s infinite; }
.bring { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: var(--space-3); font-size: var(--text-sm); color: var(--muted); }
.bring span { background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; color: var(--ink); font-size: var(--text-xs); }
details.more-box { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); margin-top: var(--space-4); }
details.more-box summary { cursor: pointer; padding: var(--space-3) var(--space-4); font-weight: 600; list-style: none; display: flex; justify-content: space-between; align-items: center; }
details.more-box summary::after { content: '+'; color: var(--muted); font-size: 1.2rem; }
details.more-box[open] summary::after { content: '−'; }
details.more-box .inner { padding: 0 var(--space-4) var(--space-4); }
.summary { font-family: var(--font-mono); font-size: var(--text-xs); white-space: pre-wrap; background: var(--bg-2); padding: var(--space-3); border-radius: 10px; margin: 0; color: var(--muted); border: 1px solid var(--line); }

/* Chips */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: var(--text-xs); font-weight: 700; }
.chip.emergency, .chip.hazard, .chip.red { background: var(--emergency-soft); color: var(--emergency); }
.chip.urgent, .chip.amber { background: var(--urgent-soft); color: var(--urgent); }
.chip.call, .chip.advisory { background: var(--call-soft); color: var(--call); }
.chip.home { background: var(--home-soft); color: var(--home); }
.chip.event, .chip.blue { background: var(--blue-soft); color: var(--blue); }

/* Tabs */
.tabs { display: flex; gap: 4px; margin-bottom: var(--space-5); overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: thin; background: var(--surface); border: 1px solid var(--line); padding: 4px; border-radius: 999px; width: max-content; max-width: 100%; }
.tabs button {
  background: none; border: 0; padding: var(--space-2) var(--space-4); border-radius: 999px;
  color: var(--muted); font-weight: 600; font-size: var(--text-sm); cursor: pointer; white-space: nowrap; transition: background 0.15s;
}
.tabs button:hover { color: var(--ink); }
.tabs button.on { color: var(--accent-ink); background: var(--accent); }
@media (max-width: 640px) { .tabs { border-radius: 16px; flex-wrap: wrap; overflow: visible; width: 100%; } .tabs button { padding: var(--space-2) var(--space-3); font-size: var(--text-xs); } }

/* Tables */
table.tbl { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.tbl th, .tbl td { text-align: left; padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th { color: var(--muted); font-weight: 600; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.06em; }
.tbl-wrap { overflow-x: auto; }

/* Alarm cards */
.alarm { border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-4); background: var(--surface-2); }
.alarm h3 { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; font-size: var(--text-base); font-family: var(--font-body); font-weight: 700; }
.alarm .display-text { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--display-ink); background: var(--display-bg); padding: 6px 10px; border-radius: 8px; margin-bottom: var(--space-3); display: inline-block; }
.alarm dl { margin: 0; display: grid; grid-template-columns: 80px 1fr; gap: var(--space-1) var(--space-3); font-size: var(--text-sm); }
.alarm dt { color: var(--muted); font-weight: 600; }
.alarm dd { margin: 0; }

/* Differential */
.dx { border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-4); background: var(--surface-2); }
.dx.top { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-soft), 0 10px 30px rgba(51, 214, 196, 0.08); }
.dx-head { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); width: 100%; background: none; border: 0; padding: 0; text-align: left; cursor: pointer; color: inherit; }
.dx-head .chev { color: var(--muted); font-size: 1.1rem; width: 1.2em; text-align: center; }
.dx.closed:hover { border-color: var(--line-2); }
.dx-body[hidden] { display: none; }
.dx-head h3 { font-family: var(--font-body); font-size: var(--text-base); font-weight: 700; }
.bar { height: 8px; background: var(--bg-2); border-radius: 4px; overflow: hidden; margin: var(--space-2) 0 var(--space-3); }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--blue)); transform-origin: left; animation: grow 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.dx ul { margin: var(--space-2) 0 0; padding-left: 1.1rem; font-size: var(--text-sm); }
.pattern { font-family: var(--font-mono); font-size: var(--text-sm); background: var(--display-bg); color: var(--display-ink); border-radius: 10px; padding: var(--space-3) var(--space-4); border: 1px solid #1b2a33; }
.toggles { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: var(--space-2); }
.toggle { display: flex; gap: var(--space-2); align-items: center; padding: var(--space-2) var(--space-3); border: 1px solid var(--line); border-radius: 10px; font-size: var(--text-sm); cursor: pointer; background: var(--surface-2); transition: border-color 0.15s; }
.toggle:hover { border-color: var(--line-2); }
.toggle input { accent-color: var(--accent); width: 18px; height: 18px; flex: none; }
.toggle.on { border-color: var(--accent); background: var(--accent-soft); }
.banner { border-radius: var(--radius); padding: var(--space-3) var(--space-4); font-weight: 600; font-size: var(--text-sm); }
.banner.emergency { background: var(--emergency-soft); color: #ffb3ba; border: 1px solid var(--emergency); }
.banner.home { background: var(--home-soft); color: var(--home); }

/* Algorithm map */
.tree { font-size: var(--text-sm); }
.node { border-left: 2px solid var(--line-2); margin-left: var(--space-3); padding-left: var(--space-4); padding-top: var(--space-2); position: relative; }
.node::before { content: ''; position: absolute; left: -2px; top: 1.15rem; width: var(--space-3); border-top: 2px solid var(--line-2); }
.node-title { font-weight: 600; }
.node-type { font-size: var(--text-xs); color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin-right: var(--space-2); }
.edge { color: var(--muted); font-size: var(--text-xs); margin-top: var(--space-2); }
.edge strong { color: var(--ink); }
.node .ref { color: var(--accent); font-size: var(--text-xs); }
.root { border-left: 0; margin-left: 0; padding-left: 0; }
.root::before { display: none; }

/* Cases */
.case { border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-4); background: var(--surface); }
.case .choices { display: grid; gap: var(--space-2); grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); margin-top: var(--space-3); }
.case .choices button { text-align: left; justify-content: flex-start; }
.case .choices button.right { border-color: var(--home); background: var(--home-soft); color: var(--home); }
.case .choices button.wrong { border-color: var(--emergency); background: var(--emergency-soft); color: var(--emergency); }
.feedback { margin-top: var(--space-3); padding: var(--space-3) var(--space-4); border-radius: 10px; background: var(--surface-2); font-size: var(--text-sm); border-left: 3px solid var(--accent); }
.score { font-family: var(--font-mono); font-size: var(--text-sm); color: var(--accent); background: var(--accent-soft); padding: 4px 12px; border-radius: 999px; }

/* Toast */
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px); opacity: 0; background: var(--ink); color: var(--bg); padding: var(--space-2) var(--space-4); border-radius: 999px; font-size: var(--text-sm); font-weight: 600; transition: opacity 0.2s, transform 0.2s; pointer-events: none; z-index: 60; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media print {
  body { background: #fff; color: #000; }
  .topbar, .footer, .btn, .tabs, .sos, .sheet { display: none !important; }
  .main { max-width: none; padding: 0; }
  .card, .outcome { box-shadow: none; break-inside: avoid; background: #fff; color: #000; border-color: #999; }
}

/* About */
.about-hero { padding: var(--space-4) 0 var(--space-6); max-width: 720px; }
.about-hero h1 { font-size: clamp(2rem, 4.2vw, 3rem); margin-bottom: var(--space-3); }
.about-hero .lead { color: var(--muted); font-size: var(--text-lg); margin: 0; }
.about .card h2 { font-size: var(--text-lg); margin-bottom: var(--space-3); }
.aims { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--space-4); }
.aims > div { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-4); }
.aims h3 { font-size: var(--text-base); font-family: var(--font-body); font-weight: 700; margin: var(--space-2) 0; }
.aims p { color: var(--muted); font-size: var(--text-sm); margin: 0; }
.aim-n { font-family: var(--font-mono); color: var(--accent); font-size: var(--text-xs); letter-spacing: .1em; }
.card.thanks { border-color: var(--accent); background: linear-gradient(135deg, rgba(51, 214, 196, 0.10), var(--surface)); }
.card.thanks strong { color: var(--accent); }
@media (max-width: 640px) { .nav a { padding: var(--space-2) 6px; } }
.team { list-style: none; padding: 0; margin: 0 0 var(--space-4); display: grid; gap: var(--space-3); }
.team li { display: grid; gap: 2px; padding-left: var(--space-3); border-left: 2px solid var(--accent); }
.team li strong { font-weight: 700; }
.team li span { color: var(--muted); font-size: var(--text-sm); }

/* Account chip */
.acct { display: inline-flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); color: var(--ink); border-radius: 999px; padding: 4px 12px 4px 4px; cursor: pointer; font: inherit; font-size: var(--text-sm); font-weight: 600; margin-left: var(--space-2); }
.acct:hover { border-color: var(--accent); }
.acct[hidden] { display: none; }
.avatar { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #06231f; font-weight: 700; font-size: 12px; letter-spacing: .02em; flex: none; }
.avatar.guest { background: var(--surface-2); color: var(--muted); }
.avatar.big { width: 56px; height: 56px; font-size: 20px; }
@media (max-width: 640px) { .acct { padding: 3px; margin-left: 4px; } .acct .acct-name { display: none; } }

/* Sign in */
.signin { display: grid; grid-template-columns: minmax(0, 480px) minmax(0, 1fr); gap: var(--space-6); align-items: start; padding-top: var(--space-4); }
.signin-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--space-6); }
.signin-brand { display: flex; align-items: center; gap: 10px; color: var(--accent); font-family: var(--font-display); font-weight: 600; font-size: var(--text-lg); margin-bottom: var(--space-4); }
.signin-card h1 { font-size: var(--text-2xl); margin-bottom: var(--space-2); }
.signin-form { display: grid; gap: var(--space-3); margin-top: var(--space-4); }
.signin .known .label { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.known { display: grid; gap: 6px; margin-top: var(--space-4); }
.known-btn { display: flex; align-items: center; gap: 12px; text-align: left; width: 100%; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; color: var(--ink); cursor: pointer; font: inherit; }
.known-btn:hover { border-color: var(--accent); }
.known-btn .who { font-weight: 600; } .known-btn .num { color: var(--muted); font-size: var(--text-sm); }
.known-btn .chev { margin-left: auto; color: var(--muted); font-size: 20px; }
.signin .err { color: var(--emergency); font-size: var(--text-sm); }
.link-btn { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font: inherit; font-size: var(--text-sm); margin-top: var(--space-3); padding: 0; }
.link-btn:hover { color: var(--ink); }
.tiny { font-size: 12px; line-height: 1.5; margin: var(--space-3) 0 0; }
.signin-side { display: grid; gap: var(--space-4); padding-top: var(--space-4); }
.side-item { display: flex; gap: 12px; align-items: flex-start; }
.side-item .dot { margin-top: 6px; flex: none; }
.side-item strong { display: block; margin-bottom: 2px; }
.side-item p { color: var(--muted); font-size: var(--text-sm); margin: 0; }
@media (max-width: 860px) { .signin { grid-template-columns: 1fr; } .signin-side { padding-top: 0; } }

/* Account page */
.acct-head { display: flex; align-items: center; gap: var(--space-4); flex-wrap: wrap; }
.acct-meta { flex: 1; min-width: 200px; } .acct-meta h1 { font-size: var(--text-xl); margin-bottom: 2px; }
.btn-sm { padding: 6px 12px; font-size: var(--text-sm); }
.btn.danger { color: var(--emergency); }
.hello { color: var(--accent); font-size: var(--text-sm); font-weight: 600; margin-bottom: var(--space-2); letter-spacing: .02em; }
.recent-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-3); }
.recent-head h2, .recent-head h3 { margin: 0; }
.recent { margin-top: var(--space-4); }
.enc-list { display: grid; gap: 6px; }
.enc { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.enc summary { display: flex; align-items: center; gap: 12px; padding: 10px 12px; cursor: pointer; list-style: none; }
.enc summary::-webkit-details-marker { display: none; }
.enc-tier { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: 3px 8px; border-radius: 999px; flex: none; background: var(--surface); }
.enc.emergency .enc-tier { color: var(--emergency); background: rgba(255,77,94,.14); }
.enc.urgent .enc-tier { color: var(--urgent); background: rgba(255,138,61,.14); }
.enc.call .enc-tier { color: var(--call); background: rgba(255,200,87,.14); }
.enc.home .enc-tier { color: var(--home); background: rgba(61,220,132,.14); }
.enc-title { font-weight: 600; flex: 1; min-width: 0; }
.enc-when { color: var(--muted); font-size: var(--text-xs); white-space: nowrap; }
.enc-body { padding: 0 12px 12px; border-top: 1px solid var(--line); }
.enc-answers { list-style: none; padding: 0; margin: 10px 0 8px; display: grid; gap: 6px; }
.enc-answers li { display: flex; justify-content: space-between; gap: 12px; font-size: var(--text-sm); }
.enc-answers li span { color: var(--muted); } .enc-answers li strong { text-align: right; font-weight: 600; }
.empty { color: var(--muted); font-size: var(--text-sm); padding: var(--space-3); border: 1px dashed var(--line); border-radius: var(--radius); }
.saved-note { display: flex; align-items: center; gap: 8px; font-size: var(--text-sm); margin-top: var(--space-4); color: var(--ink); }
.saved-note a { color: var(--accent); }
@media (max-width: 640px) { .enc summary { flex-wrap: wrap; } .enc-when { width: 100%; } .acct-actions { width: 100%; } }
@media (max-width: 640px) {
  .nav a[data-nav="algorithm"], .nav a[data-nav="about"] { display: none; }
  .sos, .acct { flex: none; }
  .brand { flex: none; }
}
@media (max-width: 400px) { .topbar { gap: 6px; } .nav a { padding: var(--space-2) 5px; } .acct { margin-left: 0; } }

/* About logo */
.about-hero { max-width: none; }
.about-hero-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(260px, 420px); gap: var(--space-6); align-items: center; }
.about-hero-grid .lead { max-width: 640px; }
.logo-plate { display: block; background: #fff; border-radius: var(--radius-lg); padding: 22px 26px; box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.06); }
.logo-plate img { display: block; width: 100%; height: auto; }
@media (max-width: 760px) { .about-hero-grid { grid-template-columns: 1fr; } .logo-plate { max-width: 360px; } }
