/* Kardiograph — warm minimalism: soft neutrals, charcoal text, rounded cards, pill controls. */
:root {
  --bg: #f7f5f2;
  --surface: #ffffff;
  --surface-2: #faf8f5;
  --text: #2b2a28;
  --text-2: #6b6762;
  --text-3: #9c9791;
  --border: rgba(43, 42, 40, 0.08);
  --border-strong: rgba(43, 42, 40, 0.16);
  --accent: #e0574f;        /* warm coral — tracing highlights & primary actions */
  --accent-soft: rgba(224, 87, 79, 0.12);
  --accent-2: #2f6fed;      /* calipers / measurements */
  --ok: #2e9e6a;
  --ok-soft: rgba(46, 158, 106, 0.12);
  --warn: #d98b1a;
  --warn-soft: rgba(217, 139, 26, 0.14);
  --bad: #d64545;
  --bad-soft: rgba(214, 69, 69, 0.12);
  --shadow: 0 1px 2px rgba(30, 25, 20, 0.04), 0 8px 24px rgba(30, 25, 20, 0.06);
  --shadow-sm: 0 1px 2px rgba(30, 25, 20, 0.05);
  --radius: 18px;
  --radius-sm: 12px;
  --pill: 999px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-heading: "Manrope", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --chrome: #fbfaf8;        /* app bar, control bar, dock, rail */
  --pasteboard: #e9e6e1;    /* area behind the ECG page */
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171615;
    --surface: #211f1d;
    --surface-2: #272523;
    --text: #efece8;
    --text-2: #b4aea7;
    --text-3: #7d776f;
    --border: rgba(255, 255, 255, 0.07);
    --border-strong: rgba(255, 255, 255, 0.14);
    --accent-soft: rgba(224, 87, 79, 0.18);
    --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 10px 30px rgba(0,0,0,0.35);
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --chrome: #1e1c1b; --pasteboard: #121110;
  }
}
:root[data-theme="dark"] {
  --bg: #171615; --surface: #211f1d; --surface-2: #272523; --text: #efece8; --text-2: #b4aea7; --text-3: #7d776f;
  --border: rgba(255,255,255,0.07); --border-strong: rgba(255,255,255,0.14); --accent-soft: rgba(224,87,79,0.18);
  --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 10px 30px rgba(0,0,0,0.35); --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --chrome: #1e1c1b; --pasteboard: #121110;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }

/* ---------- Shell ----------
   Illustrator/Photoshop-style workspace. The ECG page is the canvas and gets
   all the space it can; settings live in a control bar above it, docked
   collapsible panels and an icon rail on the right, and a status bar below.
   Only the dock scrolls; the canvas stays put. */
.app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }

.appbar {
  flex: 0 0 auto; display: flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 6px 0 12px;
  background: var(--chrome); border-bottom: 1px solid var(--border);
}
.brand { font-family: var(--font-heading); font-size: 13px; font-weight: 800; margin: 0; letter-spacing: -0.01em; }
.spacer { flex: 1; }

.workspace {
  --sidebar-w: 340px;
  flex: 1 1 auto; min-height: 0;
  display: flex;
  background: var(--pasteboard);
}
.workspace.resizing { cursor: col-resize; user-select: none; }
.workspace.resizing * { cursor: col-resize !important; }

/* Canvas: control bar on top, the page centered on a pasteboard. */
.canvas { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; position: relative; }
.controlbar {
  flex: 0 0 auto; display: flex; align-items: center; gap: 6px 16px; flex-wrap: wrap;
  padding: 6px 12px; background: var(--chrome); border-bottom: 1px solid var(--border);
}
.cb-group { display: flex; align-items: center; gap: 6px; }
.cb-label { font-size: 11.5px; color: var(--text-3); font-weight: 600; }
.controlbar .segmented { padding: 2px; }
.controlbar .segmented .pill { padding: 3px 9px; font-size: 12px; }
.controlbar > .cb-group > .pill { padding: 4px 10px; font-size: 12px; display: inline-flex; align-items: center; gap: 3px; }
.paper-scroll { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 20px; }
.paper-scroll.fit { overflow: hidden; display: flex; align-items: center; justify-content: center; }
.ecg-view { flex: 0 0 auto; border-radius: 3px; overflow: hidden; box-shadow: 0 1px 2px rgba(0,0,0,0.12), 0 8px 28px rgba(0,0,0,0.14); margin: 0 auto; }

/* ---------- Divider ---------- */
.splitter { flex: 0 0 7px; position: relative; cursor: col-resize; touch-action: none; outline: none; background: var(--chrome); border-left: 1px solid var(--border); }
.splitter::after {
  content: ""; position: absolute; top: 50%; left: 50%; width: 3px; height: 28px; margin: -14px 0 0 -1.5px;
  border-radius: 2px; background: var(--border-strong); transition: background 120ms ease;
}
.splitter:hover, .splitter:focus-visible, .workspace.resizing .splitter { background: var(--accent-soft); }
.splitter:hover::after, .splitter:focus-visible::after, .workspace.resizing .splitter::after { background: var(--accent); }

/* ---------- Dock & panels ---------- */
.dock {
  flex: 0 0 var(--sidebar-w); width: var(--sidebar-w); min-width: 0;
  overflow-y: auto; overscroll-behavior: contain;
  background: var(--chrome);
}
.workspace.dock-hidden .dock, .workspace.dock-hidden .splitter { display: none; }
.panel { border-bottom: 1px solid var(--border); }
.panel-head {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; gap: 8px; padding: 0 10px 0 4px; height: 38px;
  background: var(--chrome); border-bottom: 1px solid transparent;
}
.panel.open .panel-head { border-bottom-color: var(--border); }
.panel-toggle {
  flex: 1; display: flex; align-items: center; gap: 4px; height: 100%; min-width: 0;
  border: none; background: none; cursor: pointer; padding: 0 6px; text-align: left; border-radius: 6px;
}
.panel-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.panel-title { font-family: var(--font-heading); font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-2); }
.chev { display: inline-grid; place-items: center; color: var(--text-3); transition: transform 140ms ease; transform: rotate(-90deg); }
.panel.open .chev { transform: none; }
.panel-body { display: none; }
.panel.open .panel-body { display: block; }
.panel-pad { padding: 6px 16px 14px; }
.panel-note { font-size: 12px; color: var(--text-3); margin: 4px 0 10px; }
.pill.small { padding: 3px 10px; font-size: 12px; }

/* Icon rail (far right), like the collapsed panel strip in Adobe apps. */
.rail {
  flex: 0 0 44px; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 0;
  background: var(--chrome); border-left: 1px solid var(--border);
}
.rail-sep { width: 22px; height: 1px; background: var(--border-strong); margin: 4px 0; }
.rail-btn {
  width: 34px; height: 34px; display: grid; place-items: center; border-radius: 8px;
  border: none; background: none; color: var(--text-2); cursor: pointer; position: relative;
  transition: background 120ms ease, color 120ms ease;
}
.rail-btn:hover { background: var(--surface-2); color: var(--text); }
.rail-btn.active { background: var(--accent-soft); color: var(--accent); }
.rail-btn[aria-pressed="true"]:first-child { color: var(--text); }
.rail-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- Status bar ---------- */
.statusbar {
  flex: 0 0 auto; display: flex; align-items: center; gap: 16px; height: 28px; padding: 0 12px;
  font-size: 12px; color: var(--text-2); background: var(--chrome); border-top: 1px solid var(--border);
  white-space: nowrap; overflow: hidden;
}
.sb-item { display: inline-flex; gap: 5px; font-variant-numeric: tabular-nums; }
.sb-k { color: var(--text-3); font-weight: 600; }
.sb-info { color: var(--text-3); overflow: hidden; text-overflow: ellipsis; }
[hidden] { display: none !important; }
.segmented.wrap { flex-wrap: wrap; gap: 2px; }
.ctl.stack { grid-template-columns: 1fr; }
.ctl.stack .segmented { justify-self: start; }
.sb-rhythm { color: var(--text-2); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meas-sub .interp { font-weight: 600; color: var(--text); margin: 4px 0 6px; }
.sb-info.caliper { color: var(--accent-2); font-family: var(--mono); }
.sb-zoom { color: var(--text-3); font-variant-numeric: tabular-nums; min-width: 72px; text-align: right; }

/* Narrow screens: stack the canvas above the panels and let the page scroll. */
@media (max-width: 900px) {
  .app { height: auto; min-height: 100%; overflow: visible; }
  .workspace { flex-direction: column; }
  .splitter, .rail { display: none; }
  .paper-scroll { flex: none; max-height: 75vh; }
  .dock, .workspace.dock-hidden .dock { display: block; flex: none; width: auto; overflow: visible; }
  .sb-item:nth-child(n+4), .sb-info { display: none; }
}

/* ---------- Cards (legacy) ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }

/* ---------- Pills & buttons ---------- */
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  white-space: nowrap;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: var(--pill);
  padding: 6px 12px;
  font-size: 12.5px; font-weight: 500;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, transform 80ms ease, box-shadow 120ms ease;
}
.pill:hover { background: var(--surface-2); border-color: var(--text-3); }
.pill:active { transform: scale(0.98); }
.pill.active { background: var(--text); color: var(--surface); border-color: var(--text); }
.pill:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--pill); padding: 3px; }
.segmented .pill { border: none; background: transparent; padding: 5px 11px; }
.segmented .pill.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.btn {
  white-space: nowrap;
  border: 1px solid var(--border-strong); background: var(--surface); border-radius: var(--pill);
  padding: 7px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background 120ms ease, transform 80ms ease;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(0.98); }
.btn.ghost { border-color: transparent; background: transparent; display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.pill.icon-only { display: inline-grid; place-items: center; padding: 4px 7px; }
.appbar .segmented { padding: 1px; }
.appbar .btn.ghost { padding: 3px 8px; font-size: 12px; }
.appbar .pill.icon-only { padding: 2px 6px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.05); }

/* ---------- Sliders ---------- */
.ctl { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center; padding: 7px 0; }
.ctl .lbl { font-size: 13px; color: var(--text); font-weight: 500; }
.ctl .val {
  font-family: var(--mono); font-size: 12.5px; color: var(--text-2);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--pill);
  padding: 2px 9px; min-width: 76px; text-align: right;
}
.ctl .val input { width: 54px; border: none; background: transparent; text-align: right; font-family: var(--mono); font-size: 12.5px; padding: 0; outline: none; color: var(--text); }
.ctl input[type=range] { grid-column: 1 / -1; width: 100%; margin: 4px 0 0; }
input[type=range] { -webkit-appearance: none; appearance: none; height: 22px; background: transparent; cursor: pointer; }
input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(to right, var(--accent) var(--fill, 0%), var(--border-strong) var(--fill, 0%)); }
input[type=range]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--border-strong); }
input[type=range]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--accent); }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; margin-top: -7px;
  background: var(--surface); border: 1.5px solid var(--border-strong); box-shadow: 0 1px 4px rgba(0,0,0,0.18);
  transition: transform 120ms ease, box-shadow 120ms ease;
}
input[type=range]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--surface); border: 1.5px solid var(--border-strong); box-shadow: 0 1px 4px rgba(0,0,0,0.18); }
input[type=range]:hover::-webkit-slider-thumb, input[type=range]:focus-visible::-webkit-slider-thumb { transform: scale(1.1); box-shadow: 0 0 0 6px var(--accent-soft), 0 1px 4px rgba(0,0,0,0.2); }
input[type=range]:focus-visible { outline: none; }
.ctl-group { border-top: 1px solid var(--border); padding: 2px 0 6px; }
.ctl-group:first-child { border-top: none; }
.ctl-group > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 6px; padding: 8px 0 4px; user-select: none; }
.ctl-group > summary::-webkit-details-marker { display: none; }
.ctl-group > summary::before { content: ""; width: 6px; height: 6px; border-right: 1.5px solid var(--text-3); border-bottom: 1.5px solid var(--text-3); transform: rotate(-45deg); transition: transform 140ms ease; margin: 0 2px 0 1px; }
.ctl-group[open] > summary::before { transform: rotate(45deg); }
.ctl-group > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.ctl-group h3 { font-family: var(--font-heading); font-size: 11.5px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; margin: 0; }

/* ---------- Measurements ---------- */
.meas { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
.meas .m { display: flex; flex-direction: column; gap: 1px; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.meas .m .k { font-size: 11px; color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.meas .m .v { font-family: var(--font-heading); font-size: 17px; font-weight: 800; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.meas .m .v small { font-size: 11px; font-weight: 500; color: var(--text-3); margin-left: 3px; }
.meas .m.wide { grid-column: 1 / -1; }
.badge { display: inline-block; font-size: 10.5px; font-weight: 700; border-radius: var(--pill); padding: 1px 7px; margin-left: 6px; vertical-align: middle; letter-spacing: 0.02em; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.meas-sub { font-size: 12px; color: var(--text-2); margin-top: 10px; line-height: 1.6; }
.meas-sub b { color: var(--text); font-weight: 600; }
.axis-row { display: flex; align-items: center; gap: 14px; }
.axis-dial { flex: 0 0 auto; }
.caliper-box { font-family: var(--mono); font-size: 12px; color: var(--accent-2); background: rgba(47,111,237,0.08); border-radius: var(--radius-sm); padding: 8px 10px; margin-top: 10px; display: none; }
.caliper-box.show { display: block; }

.preset-desc { font-size: 12px; color: var(--text-3); margin-top: 8px; min-height: 16px; }
.kbd { font-family: var(--mono); font-size: 11px; background: var(--surface-2); border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 6px; padding: 0 5px; }

@media print {
  body { background: #fff; }
  .pal-backdrop, .appbar, .controlbar, .splitter, .dock, .rail, .statusbar { display: none !important; }
  .app { height: auto; overflow: visible; display: block; }
  .workspace { display: block; background: #fff; }
  .paper-scroll { overflow: visible; padding: 0; background: #fff; display: block; }
  .ecg-view { box-shadow: none; border-radius: 0; }
}

/* ---------- ⌘K command palette ---------- */
.pal-trigger {
  display: inline-flex; align-items: center; gap: 8px; height: 24px; padding: 0 6px 0 9px; width: min(320px, 40vw);
  border: 1px solid var(--border-strong); border-radius: 7px; background: var(--surface); color: var(--text-3);
  font-size: 12px; cursor: pointer; transition: border-color 120ms ease, color 120ms ease;
}
.pal-trigger span { flex: 1; text-align: left; }
.pal-trigger:hover { border-color: var(--text-3); color: var(--text-2); }
.pal-trigger:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.pal-trigger .kbd { font-size: 10.5px; }

.pal-backdrop {
  position: fixed; inset: 0; z-index: 100; display: flex; justify-content: center; align-items: flex-start;
  padding: 12vh 16px 16px; background: rgba(20, 16, 12, 0);
  transition: background 140ms ease;
}
.pal-backdrop[hidden] { display: none; }
.pal-backdrop.show { background: rgba(20, 16, 12, 0.14); } /* no blur: the tracing must stay readable while editing */
.palette {
  width: min(620px, 100%); max-height: min(560px, 76vh); display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.28), 0 2px 8px rgba(0,0,0,0.12);
  transform: translateY(-6px) scale(0.985); opacity: 0; transition: transform 140ms ease, opacity 140ms ease;
}
.pal-backdrop.show .palette { transform: none; opacity: 1; }
.pal-search { display: flex; align-items: center; gap: 10px; padding: 0 14px; height: 52px; border-bottom: 1px solid var(--border); flex: 0 0 auto; }
.pal-glyph { font-size: 20px; color: var(--text-3); line-height: 1; transform: translateY(-1px); }
.pal-input { flex: 1; border: none; outline: none; background: transparent; font-size: 16px; color: var(--text); min-width: 0; }
.pal-input::placeholder { color: var(--text-3); }
.pal-flash {
  flex: 0 0 auto; font-size: 12.5px; font-weight: 600; color: var(--ok); background: var(--ok-soft);
  padding: 0 16px; height: 0; line-height: 30px; overflow: hidden; transition: height 140ms ease;
}
.pal-flash.show { height: 30px; }
.pal-list { flex: 1 1 auto; overflow-y: auto; padding: 6px; overscroll-behavior: contain; }
.palette.editing .pal-list { display: none; }
.pal-section { font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-3); padding: 10px 10px 4px; }
.pal-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 13.5px;
}
.pal-item.sel { background: var(--accent-soft); }
.pal-item .pal-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pal-item .pal-title b { font-weight: 700; }
.pal-item.active .pal-title::after { content: "●"; color: var(--accent); font-size: 8px; margin-left: 8px; vertical-align: 2px; }
.pal-sec { font-size: 11.5px; color: var(--text-3); white-space: nowrap; }
.pal-hint {
  font-family: var(--mono); font-size: 12px; color: var(--text-2); white-space: nowrap;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 1px 7px;
}
.pal-hint:empty { display: none; }
.pal-empty { padding: 24px; text-align: center; color: var(--text-3); }
.pal-editor { display: none; padding: 18px 20px 20px; }
.palette.editing .pal-editor { display: block; }
.palette.editing .pal-search { opacity: 0.55; }
.pal-ed-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.pal-ed-sec { font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-3); }
.pal-ed-title { font-family: var(--font-heading); font-size: 18px; font-weight: 800; letter-spacing: -0.01em; }
.pal-ed-row { display: flex; align-items: center; gap: 16px; }
.pal-ed-val { display: flex; align-items: baseline; gap: 6px; flex: 0 0 auto; padding: 6px 12px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface-2); }
.pal-ed-val:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.pal-num { width: 88px; border: none; outline: none; background: transparent; font-family: var(--mono); font-size: 22px; font-weight: 600; text-align: right; color: var(--text); }
.pal-ed-unit { font-family: var(--mono); font-size: 13px; color: var(--text-3); }
.pal-range { flex: 1; }
.pal-ed-range { display: flex; justify-content: space-between; margin: 4px 0 0 140px; font-family: var(--mono); font-size: 11px; color: var(--text-3); }
.palette.result .pal-search, .palette.busy .pal-search { opacity: 1; }
.pal-status { display: flex; align-items: center; gap: 12px; color: var(--text-2); font-size: 14px; }
.pal-spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--accent); animation: pal-spin 0.8s linear infinite; flex: 0 0 auto; }
@keyframes pal-spin { to { transform: rotate(360deg); } }
.pal-result { border-left: 3px solid var(--ok); padding: 2px 0 2px 14px; }
.pal-result.error { border-left-color: var(--bad); }
.pal-res-title { font-family: var(--font-heading); font-size: 16px; font-weight: 800; margin-bottom: 6px; }
.pal-res-line { font-size: 13px; color: var(--text-2); line-height: 1.45; margin-top: 4px; }
.pal-res-line.error-text { color: var(--bad); }
.pal-res-line.error-text:empty { display: none; }
.pal-secret { width: 100%; box-sizing: border-box; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface-2); color: var(--text); font-family: var(--mono); font-size: 14px; outline: none; }
.pal-secret:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.pal-note { margin-top: 10px; font-size: 12px; line-height: 1.5; color: var(--text-3); }
.pal-foot { flex: 0 0 auto; display: flex; gap: 16px; padding: 8px 14px; border-top: 1px solid var(--border); font-size: 11.5px; color: var(--text-3); background: var(--surface-2); }
.pal-foot .kbd { margin-right: 2px; }
@media (max-width: 900px) { .pal-trigger { width: auto; } .pal-trigger span { display: none; } }
@media (prefers-reduced-motion: reduce) { .palette, .pal-backdrop, .pal-flash { transition: none; } .pal-spin { animation-duration: 2.4s; } }
a.btn { text-decoration: none; }

/* /match: drop an ECG photo on the tracing */
.drop-hint {
  position: absolute; inset: 12px; z-index: 5; display: none; place-items: center;
  border: 2px dashed var(--accent); border-radius: 12px; background: var(--accent-soft);
  pointer-events: none; font-weight: 600; color: var(--text);
}
.drop-hint span { background: var(--surface); padding: 8px 14px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.12); }
.canvas.dropping .drop-hint { display: grid; }

/* Medzcool account (src/auth/account.ts) */
.account { display: inline-flex; align-items: center; gap: 6px; margin-left: 6px; }
.account:empty { display: none; }
.account__name { font-size: 12px; opacity: .75; max-width: 12em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Sign-in screen over the app (src/auth/account.ts) */
.auth-gate { position: fixed; inset: 0; z-index: 10000; display: grid; place-items: center; padding: 16px; background: var(--auth-gate-bg, #f6f5f1); color: var(--auth-gate-fg, #1d1d1b); font-family: Inter, system-ui, -apple-system, sans-serif; }
.auth-gate__card { width: min(400px, 100%); text-align: center; }
.auth-gate__title { margin: 0 0 12px; font-size: 28px; font-weight: 700; letter-spacing: -0.01em; }
.auth-gate__title::before { content: ""; display: block; width: 44px; height: 44px; margin: 0 auto 16px; border-radius: 12px; background: #e0574f url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 12h4l2-5 4 10 2-5h8'/%3E%3C/svg%3E") center / 24px no-repeat; }
.auth-gate__text { margin: 0 0 24px; font-size: 15px; line-height: 1.5; opacity: .75; }
.auth-gate__actions { display: flex; flex-direction: column; gap: 10px; }
.auth-gate__btn { display: block; padding: 11px 16px; border-radius: 10px; border: 1px solid rgba(0,0,0,.14); background: transparent; color: inherit; font: inherit; font-size: 15px; font-weight: 600; text-decoration: none; cursor: pointer; }
.auth-gate__btn--primary { background: #e0574f; border-color: #e0574f; color: #fff; }
.auth-gate__btn:focus-visible { outline: 2px solid #2f6fed; outline-offset: 2px; }
@media (prefers-color-scheme: dark) { .auth-gate { --auth-gate-bg: #161614; --auth-gate-fg: #ecebe6; } .auth-gate__btn { border-color: rgba(255,255,255,.18); } }
:root[data-theme="dark"] .auth-gate { --auth-gate-bg: #161614; --auth-gate-fg: #ecebe6; }
:root[data-theme="light"] .auth-gate { --auth-gate-bg: #f6f5f1; --auth-gate-fg: #1d1d1b; }
