/* =============================================================================
   EMI Workbench — stylesheet
   Ledger paper and ink: hairline rules, tabular figures, one ink-blue accent.
   Tokens are declared once on :root, then redefined for dark under BOTH the
   OS media query and the explicit [data-theme] stamp, so the toggle wins in
   either direction and the un-stamped "system" state renders correctly.
   ========================================================================== */

:root {
  color-scheme: light;

  --ground:        #f1f2ef;   /* page plane — ledger paper, faint green-grey */
  --surface:       #fbfbfa;   /* cards, chart surface (validator surface)     */
  --surface-2:     #ffffff;   /* raised: sheets, keypad                       */
  --ink:           #111619;
  --ink-2:         #4a5257;
  --ink-3:         #7d858a;
  --rule:          #dfe2dc;
  --rule-strong:   #c2c7c0;

  --accent:        #17457f;
  --accent-ink:    #ffffff;
  --accent-soft:   #e6edf6;
  --accent-line:   #c8d8ea;

  --good:          #006300;
  --warn:          #b06f00;
  --danger:        #c0392f;

  /* Data series — validated: adjacent CVD ΔE 9.1, normal-vision ΔE 19.6 */
  --s1: #2a78d6;   /* principal   */
  --s2: #eb6834;   /* interest    */
  --s3: #1baf7a;   /* prepaid / GST */
  --s4: #eda100;   /* fees / one-time */
  --s5: #e87ba4;   /* ownership   */

  --shadow-sheet: 0 -8px 32px rgba(17, 22, 25, .18);
  --radius:   10px;
  --radius-s: 7px;

  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Roboto Mono", "SF Mono", "DejaVu Sans Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ground:      #0c0d0d;
    --surface:     #1a1a19;
    --surface-2:   #232320;
    --ink:         #ffffff;
    --ink-2:       #c3c2b7;
    --ink-3:       #898781;
    --rule:        #2c2c2a;
    --rule-strong: #383835;
    --accent:      #7fb0ec;
    --accent-ink:  #0c0d0d;
    --accent-soft: #17222e;
    --accent-line: #2b3d52;
    --good:        #0ca30c;
    --warn:        #fab219;
    --danger:      #e66767;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181;
    --shadow-sheet: 0 -8px 32px rgba(0, 0, 0, .55);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ground:      #0c0d0d;
  --surface:     #1a1a19;
  --surface-2:   #232320;
  --ink:         #ffffff;
  --ink-2:       #c3c2b7;
  --ink-3:       #898781;
  --rule:        #2c2c2a;
  --rule-strong: #383835;
  --accent:      #7fb0ec;
  --accent-ink:  #0c0d0d;
  --accent-soft: #17222e;
  --accent-line: #2b3d52;
  --good:        #0ca30c;
  --warn:        #fab219;
  --danger:      #e66767;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181;
  --shadow-sheet: 0 -8px 32px rgba(0, 0, 0, .55);
}

/* ── base ──────────────────────────────────────────────────────────────── */

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 400 15px/1.45 var(--sans);
  padding-block: 0 calc(40px + env(safe-area-inset-bottom));
  overflow-x: hidden;
}
/* Tools with a bottom nav and a sticky answer strip need the extra runway. */
body.has-nav { padding-bottom: calc(140px + env(safe-area-inset-bottom)); }

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

.wrap { max-width: 560px; margin: 0 auto; padding-inline: 16px; }

.num { font-variant-numeric: tabular-nums; }

.sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ── app bar ───────────────────────────────────────────────────────────── */

.appbar {
  position: sticky; top: 0; z-index: 40;
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
  padding-block: 10px;
  padding-top: calc(10px + env(safe-area-inset-top));
}
.appbar .wrap { display: flex; align-items: center; gap: 10px; }

.brand {
  display: flex; align-items: baseline; gap: 7px;
  margin-right: auto; min-width: 0;
}
.brand b { font-size: 16px; font-weight: 600; letter-spacing: -.01em; }
.brand span {
  font-size: 10px; letter-spacing: .09em; text-transform: uppercase;
  color: var(--ink-3); white-space: nowrap;
}

.chip-btn {
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 13px; font-weight: 500;
  color: var(--ink-2);
  background: var(--surface);
  white-space: nowrap;
}
.chip-btn:active { background: var(--accent-soft); }

/* ── screens & nav ─────────────────────────────────────────────────────── */

.screen[hidden] { display: none !important; }
.screen { padding-top: 14px; }

.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
  background: var(--surface);
  border-top: 1px solid var(--rule);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav .wrap {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px;
  padding-block: 6px 4px;
}
.navbtn {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 5px 2px 4px;
  border-radius: var(--radius-s);
  font-size: 11px; font-weight: 500; letter-spacing: .01em;
  color: var(--ink-3);
}
.navbtn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.navbtn[aria-current="true"] { color: var(--accent); }
.navbtn[aria-current="true"] svg { stroke-width: 2.1; }

/* the live answer, always visible above the nav while you type */
.emistrip {
  position: fixed; left: 0; right: 0; z-index: 44;
  bottom: calc(57px + env(safe-area-inset-bottom));
  background: var(--accent);
  color: var(--accent-ink);
  border-top: 1px solid var(--accent);
}
.emistrip .wrap {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding-block: 9px;
}
.emistrip .lbl {
  font-size: 10px; letter-spacing: .09em; text-transform: uppercase;
  opacity: .82;
}
.emistrip .val { font-size: 20px; font-weight: 600; letter-spacing: -.02em; }
.emistrip .sub { font-size: 12px; opacity: .85; text-align: right; }

/* ── cards ─────────────────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.card h2, .card h3 {
  margin: 0 0 2px;
  font-size: 11px; font-weight: 600; letter-spacing: .085em;
  text-transform: uppercase; color: var(--ink-3);
}
.card .hint {
  margin: 0 0 12px;
  font-size: 12.5px; color: var(--ink-3); line-height: 1.4;
}
.card.flush { padding: 0; overflow: hidden; }

/* ── segmented control ─────────────────────────────────────────────────── */

.seg {
  display: flex; gap: 2px;
  background: var(--ground);
  border: 1px solid var(--rule);
  border-radius: var(--radius-s);
  padding: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}
.seg::-webkit-scrollbar { display: none; }
.seg button {
  flex: 1 0 auto;
  padding: 7px 11px;
  border-radius: 5px;
  font-size: 13px; font-weight: 500;
  color: var(--ink-2);
  white-space: nowrap;
}
.seg button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(17, 22, 25, .1);
}
.seg.sm button { padding: 5px 9px; font-size: 12px; }

/* ── input rows ────────────────────────────────────────────────────────── */

.field { padding-block: 11px; border-bottom: 1px solid var(--rule); }
.field:last-child { border-bottom: 0; padding-bottom: 2px; }
.field.solved { display: none; }

.field-top {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 7px;
}
.field-top label {
  font-size: 13.5px; color: var(--ink-2); margin-right: auto;
  display: flex; align-items: center; gap: 6px;
}
.field-note {
  font-size: 11px; color: var(--ink-3);
  border: 1px solid var(--rule); border-radius: 4px; padding: 1px 5px;
}

.valbtn {
  display: flex; align-items: baseline; gap: 3px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-s);
  background: var(--surface-2);
  padding: 6px 10px;
  font-family: var(--mono);
  font-size: 15px; font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  min-width: 108px;
  justify-content: flex-end;
}
.valbtn small { font-size: 11px; color: var(--ink-3); font-family: var(--sans); }
.valbtn:active { border-color: var(--accent); }

.unit-toggle {
  display: flex; border: 1px solid var(--rule); border-radius: 5px; overflow: hidden;
}
.unit-toggle button {
  padding: 4px 7px; font-size: 11px; font-weight: 600; color: var(--ink-3);
  font-family: var(--mono);
}
.unit-toggle button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 26px; margin: 0; background: transparent;
  display: block;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 3px; border-radius: 2px;
  background: linear-gradient(to right, var(--accent) var(--pct, 0%), var(--rule) var(--pct, 0%));
}
input[type="range"]::-moz-range-track {
  height: 3px; border-radius: 2px; background: var(--rule);
}
input[type="range"]::-moz-range-progress { height: 3px; border-radius: 2px; background: var(--accent); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 22px; height: 22px; margin-top: -9.5px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 2px solid var(--accent);
  box-shadow: 0 1px 3px rgba(17, 22, 25, .25);
}
input[type="range"]::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--surface-2); border: 2px solid var(--accent);
}

.range-ends {
  display: flex; justify-content: space-between;
  font-size: 10.5px; color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  margin-top: -2px;
}

.quickchips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.quickchips button {
  border: 1px solid var(--rule); border-radius: 999px;
  padding: 4px 10px; font-size: 12px; color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.quickchips button:active { background: var(--accent-soft); border-color: var(--accent-line); }

.tenure-row { display: flex; gap: 8px; align-items: center; }
.tenure-row .valbtn { min-width: 0; flex: 1; }

/* ── results ───────────────────────────────────────────────────────────── */

.hero { padding: 16px 14px 14px; }
.hero .lbl {
  font-size: 11px; letter-spacing: .085em; text-transform: uppercase;
  color: var(--ink-3);
}
.hero .fig {
  font-size: 40px; font-weight: 300; letter-spacing: -.03em; line-height: 1.06;
  margin-top: 3px;
}
.hero .fig.small { font-size: 30px; }
.hero .caption { margin-top: 5px; font-size: 12.5px; color: var(--ink-2); }

.stats {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid var(--rule);
}
.stats div {
  padding: 10px 14px;
  border-bottom: 1px solid var(--rule);
}
.stats div:nth-child(odd) { border-right: 1px solid var(--rule); }
.stats div:nth-last-child(-n+2):nth-child(odd) { border-bottom: 0; }
.stats div:last-child { border-bottom: 0; }
.stats dt {
  font-size: 10.5px; letter-spacing: .07em; text-transform: uppercase;
  color: var(--ink-3); margin: 0 0 2px;
}
.stats dd {
  margin: 0; font-size: 15.5px; font-weight: 500;
  font-variant-numeric: tabular-nums; letter-spacing: -.01em;
}
.stats dd small {
  display: block; margin-top: 1px;
  font-size: 11.5px; font-weight: 400; color: var(--ink-3);
  letter-spacing: 0; line-height: 1.3;
}

.flag {
  display: flex; gap: 8px; align-items: flex-start;
  padding: 10px 12px; border-radius: var(--radius-s);
  font-size: 12.5px; line-height: 1.4;
  border: 1px solid var(--rule);
  background: var(--ground);
  margin-bottom: 12px;
}
.flag.good { border-color: color-mix(in srgb, var(--good) 35%, var(--rule)); }
.flag.warn { border-color: color-mix(in srgb, var(--warn) 45%, var(--rule)); }
.flag b { font-weight: 600; }
.flag .dot { flex: none; width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; }
.flag.good .dot { background: var(--good); }
.flag.warn .dot { background: var(--warn); }

/* ── charts ────────────────────────────────────────────────────────────── */

.chartbox { position: relative; }
.chartbox svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-scroll { overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; }

.legend {
  display: flex; flex-wrap: wrap; gap: 6px 14px;
  margin-top: 10px; font-size: 12px; color: var(--ink-2);
}
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i {
  width: 10px; height: 10px; border-radius: 2px; flex: none;
}
.legend b { font-weight: 500; font-variant-numeric: tabular-nums; color: var(--ink); }

.breakdown { display: grid; gap: 1px; margin-top: 12px; }
.breakdown > div {
  display: grid; grid-template-columns: 12px 1fr auto auto;
  align-items: center; gap: 9px;
  padding: 7px 0; border-bottom: 1px solid var(--rule);
  font-size: 13px;
}
.breakdown > div:last-child { border-bottom: 0; }
.breakdown i { width: 10px; height: 10px; border-radius: 2px; }
.breakdown .amt { font-variant-numeric: tabular-nums; font-weight: 500; }
.breakdown .pc { font-variant-numeric: tabular-nums; color: var(--ink-3); font-size: 12px; min-width: 42px; text-align: right; }

.tip {
  position: absolute; z-index: 5; pointer-events: none;
  background: var(--surface-2);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-s);
  box-shadow: 0 4px 14px rgba(17, 22, 25, .16);
  padding: 8px 10px; font-size: 12px; min-width: 132px;
  transform: translate(-50%, -100%);
}
.tip[hidden] { display: none; }
.tip b { display: block; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 4px; }
.tip div { display: flex; justify-content: space-between; gap: 12px; font-variant-numeric: tabular-nums; }
.tip i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 5px; }

/* ── schedule table ────────────────────────────────────────────────────── */

.sched { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.sched th, .sched td {
  padding: 7px 8px; text-align: right;
  font-variant-numeric: tabular-nums; font-family: var(--mono);
  white-space: nowrap;
}
.sched th {
  font-family: var(--sans); font-size: 10px; font-weight: 600;
  letter-spacing: .07em; text-transform: uppercase; color: var(--ink-3);
  border-bottom: 1px solid var(--rule-strong);
  position: sticky; top: 0; background: var(--surface); z-index: 1;
}
.sched th:first-child, .sched td:first-child { text-align: left; }
.sched tr.yr { border-top: 1px solid var(--rule); cursor: pointer; }
.sched tr.yr:first-child { border-top: 0; }
.sched tr.yr td { font-weight: 600; font-family: var(--sans); }
.sched tr.yr td:first-child { display: flex; align-items: center; gap: 6px; }
.sched tr.yr .caret {
  display: inline-block; width: 0; height: 0;
  border-left: 4px solid var(--ink-3);
  border-top: 4px solid transparent; border-bottom: 4px solid transparent;
  transition: transform .12s ease;
}
.sched tr.yr[aria-expanded="true"] .caret { transform: rotate(90deg); }
.sched tr.mo td { color: var(--ink-2); background: var(--ground); font-size: 12px; }
.sched tr.mo td:first-child { padding-left: 20px; }
.sched .pos { color: var(--s3); }
.sched-wrap { overflow-x: auto; max-height: 62vh; overflow-y: auto; }
.sched-foot {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 9px 12px; border-top: 1px solid var(--rule-strong);
  font-size: 12px; color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

/* ── prepayment rows ───────────────────────────────────────────────────── */

.prepay { display: grid; gap: 8px; }
.prepay-row {
  display: grid; grid-template-columns: 1fr auto; gap: 8px;
  align-items: center;
  border: 1px solid var(--rule); border-radius: var(--radius-s);
  padding: 9px 10px;
  background: var(--ground);
}
.prepay-row .meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12.5px; }
.prepay-row select, .prepay-row input[type="number"] {
  border: 1px solid var(--rule-strong); border-radius: 5px;
  background: var(--surface-2); padding: 4px 6px; font-size: 12.5px;
  font-variant-numeric: tabular-nums; max-width: 100%;
}
.prepay-row .amt { font-family: var(--mono); font-weight: 500; }
.iconbtn {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; color: var(--ink-3);
  border: 1px solid var(--rule);
  text-decoration: none; flex: none;
}
.iconbtn:active { background: var(--accent-soft); }

.addbtn {
  width: 100%; border: 1px dashed var(--rule-strong); border-radius: var(--radius-s);
  padding: 10px; font-size: 13px; font-weight: 500; color: var(--accent);
}

/* ── actions ───────────────────────────────────────────────────────────── */

.actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 12px; }
.btn {
  border: 1px solid var(--rule-strong); border-radius: var(--radius-s);
  background: var(--surface); padding: 11px 12px;
  font-size: 13.5px; font-weight: 500; color: var(--ink);
  display: flex; align-items: center; justify-content: center; gap: 7px;
}
.btn:active { background: var(--accent-soft); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.wide { grid-column: 1 / -1; }
.btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; }

/* ── sheets (keypad, settings) ─────────────────────────────────────────── */

.scrim {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(17, 22, 25, .42);
  display: flex; align-items: flex-end; justify-content: center;
}
.scrim[hidden] { display: none; }

.sheet {
  width: 100%; max-width: 560px;
  background: var(--surface-2);
  border-radius: 16px 16px 0 0;
  border-top: 1px solid var(--rule);
  box-shadow: var(--shadow-sheet);
  padding: 10px 16px calc(16px + env(safe-area-inset-bottom));
  max-height: 88vh; overflow-y: auto;
  animation: rise .16s ease-out;
}
@keyframes rise { from { transform: translateY(14px); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } }

.grabber {
  width: 36px; height: 4px; border-radius: 2px;
  background: var(--rule-strong); margin: 2px auto 12px;
}

.keyhead { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.keyhead .lbl { font-size: 12px; color: var(--ink-3); }
.keyhead .cur {
  font-family: var(--mono); font-size: 26px; font-weight: 500;
  font-variant-numeric: tabular-nums; letter-spacing: -.02em;
  border-bottom: 2px solid var(--accent); padding-bottom: 2px; min-width: 60px; text-align: right;
}
.keyhead .words { font-size: 12px; color: var(--ink-3); text-align: right; }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.keypad button {
  padding: 15px 0; border-radius: var(--radius-s);
  border: 1px solid var(--rule);
  background: var(--surface);
  font-size: 20px; font-weight: 500; font-variant-numeric: tabular-nums;
}
.keypad button:active { background: var(--accent-soft); }
.keypad button.wide { grid-column: span 2; }
.keypad button.act { font-size: 15px; color: var(--accent); font-weight: 600; }
.keypad button.done { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-size: 16px; }

.setrow {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--rule);
}
.setrow:last-of-type { border-bottom: 0; }
.setrow .t { font-size: 14px; }
.setrow .d { font-size: 12px; color: var(--ink-3); margin-top: 2px; }

/* ── saved scenarios ───────────────────────────────────────────────────── */

.saved-item {
  display: grid; grid-template-columns: 22px 1fr auto; gap: 10px; align-items: center;
  padding: 11px 12px; border-bottom: 1px solid var(--rule);
}
.saved-item:last-child { border-bottom: 0; }
.saved-item .nm { font-size: 14px; font-weight: 500; }
.saved-item .mt { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; font-variant-numeric: tabular-nums; }
.saved-item input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }

.cmp { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.cmp th, .cmp td { padding: 8px; border-bottom: 1px solid var(--rule); text-align: right; font-variant-numeric: tabular-nums; }
.cmp th:first-child, .cmp td:first-child { text-align: left; font-variant-numeric: normal; color: var(--ink-3); font-size: 11.5px; }
.cmp thead th { font-size: 12px; font-weight: 600; border-bottom: 1px solid var(--rule-strong); }
.cmp .best { color: var(--good); font-weight: 600; }

.empty { padding: 26px 14px; text-align: center; color: var(--ink-3); font-size: 13.5px; line-height: 1.5; }

/* ── toast ─────────────────────────────────────────────────────────────── */

.toast {
  position: fixed; z-index: 70; left: 50%; transform: translateX(-50%);
  bottom: calc(120px + env(safe-area-inset-bottom));
  background: var(--ink); color: var(--ground);
  padding: 9px 15px; border-radius: 999px; font-size: 13px;
  box-shadow: 0 4px 16px rgba(17, 22, 25, .3);
}
.toast[hidden] { display: none; }

/* ── landing: the tile grid ────────────────────────────────────────────── */

.lede {
  margin: 16px 0 18px;
  font-size: 15.5px; line-height: 1.5; color: var(--ink-2);
  max-width: 46ch;
}
.lede b { color: var(--ink); font-weight: 600; }

.section-label {
  display: flex; align-items: center; gap: 10px;
  margin: 22px 0 10px;
  font-size: 11px; font-weight: 600; letter-spacing: .085em;
  text-transform: uppercase; color: var(--ink-3);
}
.section-label::after {
  content: ""; flex: 1; height: 1px; background: var(--rule);
}

.tiles { display: grid; gap: 10px; }
@media (min-width: 520px) { .tiles { grid-template-columns: 1fr 1fr; } }

.tile {
  display: grid; grid-template-columns: 38px 1fr; gap: 12px;
  align-items: start;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  color: inherit; text-decoration: none;
}
.tile:active { border-color: var(--accent-line); background: var(--accent-soft); }
.tile .glyph {
  width: 38px; height: 38px; border-radius: 9px;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}
.tile .glyph svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.tile h3 { margin: 1px 0 3px; font-size: 15px; font-weight: 600; letter-spacing: -.005em; }
.tile p { margin: 0; font-size: 12.5px; line-height: 1.4; color: var(--ink-3); }
.tile .tags {
  display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px;
}
.tile .tags span {
  font-size: 10.5px; color: var(--ink-3);
  border: 1px solid var(--rule); border-radius: 4px; padding: 1px 5px;
}
.tile.soon { opacity: .72; }
.tile.soon .glyph { background: var(--ground); color: var(--ink-3); }
.tile .soon-flag {
  font-size: 10px; letter-spacing: .07em; text-transform: uppercase;
  color: var(--ink-3); border: 1px dashed var(--rule-strong);
  border-radius: 4px; padding: 1px 5px;
}

.site-foot {
  margin: 26px 0 8px; padding-top: 14px;
  border-top: 1px solid var(--rule);
  font-size: 12px; color: var(--ink-3); line-height: 1.55;
}
.site-foot a { color: var(--accent); }

/* ── converter ─────────────────────────────────────────────────────────── */

.conv-head {
  display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center;
  padding-bottom: 12px; border-bottom: 1px solid var(--rule);
}
.conv-value {
  width: 100%; border: 0; background: none; padding: 0;
  font-family: var(--mono); font-size: 30px; font-weight: 500;
  font-variant-numeric: tabular-nums; letter-spacing: -.02em;
  color: var(--ink);
}
.conv-value:focus { outline: none; }
.conv-from {
  border: 1px solid var(--rule-strong); border-radius: var(--radius-s);
  background: var(--surface-2); padding: 7px 10px;
  font-size: 13px; font-weight: 500; max-width: 46vw;
}

.unit-list { display: grid; }
.unit-row {
  display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: baseline;
  padding: 11px 2px; border-bottom: 1px solid var(--rule);
  text-align: left; width: 100%;
}
.unit-row:last-child { border-bottom: 0; }
.unit-row:active { background: var(--accent-soft); }
.unit-row .u-name { font-size: 13.5px; }
.unit-row .u-sym { color: var(--ink-3); font-size: 12px; margin-left: 5px; }
.unit-row .u-val {
  font-family: var(--mono); font-size: 15px; font-weight: 500;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.unit-row.is-source { background: var(--accent-soft); border-radius: var(--radius-s); }
.unit-row.is-source .u-val { color: var(--accent); }
.badge {
  display: inline-block; margin-left: 6px;
  font-size: 10px; letter-spacing: .05em; text-transform: uppercase;
  color: var(--ink-3); border: 1px solid var(--rule); border-radius: 4px;
  padding: 0 4px; vertical-align: 1px;
}
.badge.warn { border-color: color-mix(in srgb, var(--warn) 50%, var(--rule)); color: var(--warn); }

/* ── date & time ───────────────────────────────────────────────────────── */

.dt-grid { display: grid; gap: 10px; }
.dt-field {
  display: grid; gap: 6px;
  padding: 11px 0; border-bottom: 1px solid var(--rule);
}
.dt-field:last-child { border-bottom: 0; }
.dt-field > label {
  font-size: 11px; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-3);
}
.dt-field .row { display: flex; gap: 8px; flex-wrap: wrap; }
input[type="date"], input[type="time"], input[type="number"].plain, select.plain {
  border: 1px solid var(--rule-strong); border-radius: var(--radius-s);
  background: var(--surface-2); padding: 9px 10px;
  font-family: var(--mono); font-size: 14px;
  font-variant-numeric: tabular-nums; color: var(--ink);
  flex: 1 1 auto; min-width: 0; max-width: 100%;
}
select.plain { font-family: var(--sans); }
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator { filter: invert(var(--cal-invert, 0)); }
:root[data-theme="dark"] { --cal-invert: 1; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --cal-invert: 1; } }

.units-out {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
  border-top: 1px solid var(--rule);
}
.units-out div {
  padding: 10px 4px; border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
}
.units-out div:last-child { border-right: 0; }
.units-out dt {
  margin: 0 0 2px; font-size: 10px; letter-spacing: .06em;
  text-transform: uppercase; color: var(--ink-3);
}
.units-out dd {
  margin: 0; font-size: 15px; font-weight: 500; font-variant-numeric: tabular-nums;
}

/* ── print: the schedule as a document ─────────────────────────────────── */

@media print {
  @page { margin: 14mm; }
  body { background: #fff; color: #000; padding: 0; font-size: 10pt; }
  .appbar, .bottomnav, .emistrip, .actions, .scrim, .toast,
  .seg, .quickchips, input[type="range"], .range-ends, .addbtn, .iconbtn { display: none !important; }
  .wrap { max-width: none; padding: 0; }
  .card { border: 0; border-top: 1px solid #999; border-radius: 0; padding: 8pt 0; margin: 0; page-break-inside: avoid; }
  .sched-wrap { max-height: none; overflow: visible; }
  .sched tr.mo { display: table-row !important; }
  .sched tr.mo td { background: none; }
  .sched th { position: static; }
  .hero .fig { font-size: 24pt; }
  .chartbox { page-break-inside: avoid; }
  .print-only { display: block !important; }
}
.print-only { display: none; }
