/* Ernest Del Real mortgage app — editorial black & white, one column, thumb-reach actions at the bottom. */
:root {
  --bg: #ffffff;
  --bg-dim: #faf9f7;
  --ink: #0a0a0a;
  --ink-soft: #2a2a2a;
  --muted: #767676;
  --muted-light: #b8b8b8;
  --rule: #e4e2dd;
  --rule-strong: #1a1a1a;
  --accent: #6b5a3e;
  --on-ink: #ffffff;
  --bar-bg: rgba(255, 255, 255, 0.92);
  --scrim: rgba(10, 10, 10, 0.32);
  --seg-pi: #0a0a0a;
  --seg-tax: #5f5c57;
  --seg-ins: #a39f97;
  --seg-mi: #6b5a3e;
  --seg-hoa: #d9d4ca;

  --serif: "Cormorant Garamond", "Times New Roman", Georgia, serif;
  --sans: "Inter Tight", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0c0b; --bg-dim: #151513; --ink: #f3f1ec; --ink-soft: #d6d3cc; --muted: #8e8a83;
    --muted-light: #55524d; --rule: #2a2926; --rule-strong: #d9d6cf; --accent: #b8a07a; --on-ink: #0c0c0b;
    --bar-bg: rgba(12, 12, 11, 0.9); --scrim: rgba(0, 0, 0, 0.55);
    --seg-pi: #f3f1ec; --seg-tax: #b3afa7; --seg-ins: #7c7871; --seg-mi: #b8a07a; --seg-hoa: #3d3b37;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c0c0b; --bg-dim: #151513; --ink: #f3f1ec; --ink-soft: #d6d3cc; --muted: #8e8a83;
  --muted-light: #55524d; --rule: #2a2926; --rule-strong: #d9d6cf; --accent: #b8a07a; --on-ink: #0c0c0b;
  --bar-bg: rgba(12, 12, 11, 0.9); --scrim: rgba(0, 0, 0, 0.55);
  --seg-pi: #f3f1ec; --seg-tax: #b3afa7; --seg-ins: #7c7871; --seg-mi: #b8a07a; --seg-hoa: #3d3b37;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { background: var(--bg); }
body {
  margin: 0; color: var(--ink); font-family: var(--sans); font-weight: 300; font-size: 15px; line-height: 1.55;
  letter-spacing: 0.005em; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
body::before {
  content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 35; background: var(--bar-bg);
}
button, input, select { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
p { margin: 0; }

.col {
  width: 100%; max-width: 560px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
main.col { padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }

.eyebrow { font-size: 10px; font-weight: 400; letter-spacing: 0.3em; text-transform: uppercase; color: var(--muted); }

/* ---------- App bar ---------- */
.appbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 30;
  background: var(--bar-bg); -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--rule);
}
.appbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 54px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-text { font-size: 9.5px; font-weight: 400; letter-spacing: 0.36em; text-transform: uppercase; line-height: 1.25; }
.brand-text span { display: block; }
.appbar-figure {
  font-family: var(--serif); font-size: 22px; line-height: 1; font-variant-numeric: lining-nums tabular-nums;
  opacity: 0; transform: translateY(4px); transition: opacity .2s ease, transform .2s ease; white-space: nowrap;
}
.appbar-figure small { font-size: 12px; color: var(--muted); margin-left: 2px; }
.appbar-figure.show { opacity: 1; transform: none; }

/* ---------- Install banner ---------- */
.install {
  margin-top: 14px; border: 1px solid var(--ink); display: flex; justify-content: space-between; align-items: center;
  gap: 12px; padding: 10px 8px 10px 14px;
}
.install-title { font-size: 13px; font-weight: 500; }
.install-sub { font-size: 12px; color: var(--muted); }
.install-actions { display: flex; align-items: center; gap: 2px; }

/* ---------- Screen header ---------- */
.screen-head { padding: 26px 0 18px; }
h1 { font-family: var(--serif); font-weight: 300; font-size: 38px; line-height: 1.04; letter-spacing: -0.01em; margin: 8px 0 0; text-wrap: balance; }
h1 em { font-style: italic; }

/* ---------- Hero figure ---------- */
.hero { border-top: 1px solid var(--rule-strong); border-bottom: 1px solid var(--rule); padding: 18px 0 20px; }
.big {
  font-family: var(--serif); font-weight: 300; font-size: 64px; line-height: 1; letter-spacing: -0.02em;
  margin-top: 10px; font-variant-numeric: lining-nums tabular-nums;
}
.big small { font-size: 0.3em; color: var(--muted); margin-left: 4px; letter-spacing: 0; font-weight: 400; }
.hero-sub { font-size: 13px; color: var(--ink-soft); margin-top: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.chip { font-size: 9.5px; letter-spacing: 0.18em; text-transform: uppercase; padding: 5px 9px; border: 1px solid var(--rule); color: var(--ink-soft); white-space: nowrap; }
.chip.strong { border-color: var(--ink); color: var(--ink); }
.bar { display: flex; gap: 2px; height: 10px; margin-top: 18px; background: var(--rule); }
.bar i { display: block; height: 100%; }

.legend { list-style: none; margin: 10px 0 0; padding: 0; }
.legend li {
  display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 10px; align-items: baseline;
  padding: 7px 0; border-bottom: 1px solid var(--rule); font-size: 13.5px;
}
.legend li:last-child { border-bottom: 0; }
.legend .sw { width: 10px; height: 10px; align-self: center; }
.legend .v { font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 400; }
.legend li.off, .legend li.off .v { color: var(--muted-light); }
.legend-card { margin-top: 18px; border-top: 1px solid var(--rule); }
.legend-card li:last-child { border-bottom: 1px solid var(--rule); }
.legend li.total { font-weight: 500; }

/* ---------- Inputs ---------- */
.group { display: grid; grid-template-columns: minmax(0, 1fr); gap: 22px; padding: 22px 0; }
.field { display: grid; gap: 6px; min-width: 0; align-content: start; }
.field > label, .label { font-size: 10px; font-weight: 400; letter-spacing: 0.22em; text-transform: uppercase; color: var(--muted); }
.control {
  display: flex; align-items: baseline; gap: 6px; border-bottom: 1px solid var(--rule-strong); padding: 0 0 5px;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.control:focus-within { border-bottom-color: var(--accent); box-shadow: 0 1px 0 0 var(--accent); }
.affix { font-family: var(--serif); font-size: 20px; color: var(--muted); line-height: 1; white-space: nowrap; }
.control input, .control select {
  flex: 1; min-width: 0; width: 100%; border: 0; background: transparent; outline: none; padding: 0; border-radius: 0;
  font-family: var(--serif); font-size: 26px; font-weight: 400; line-height: 1.25; color: var(--ink);
  font-variant-numeric: lining-nums tabular-nums; -webkit-appearance: none; appearance: none;
}
.control select { font-size: 19px; cursor: pointer; }
.hint { font-size: 12px; line-height: 1.45; color: var(--muted); }
.hint button { border: 0; background: none; padding: 0; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; font-size: 12px; cursor: pointer; }
.tuck { margin-top: -12px; }
.pair { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; }
.pair.even { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.seg { display: grid; border: 1px solid var(--ink); }
.seg-2 { grid-template-columns: repeat(2, 1fr); }
.seg-3 { grid-template-columns: repeat(3, 1fr); }
.seg-5 { grid-template-columns: repeat(5, 1fr); }
.seg button {
  border: 0; border-left: 1px solid var(--ink); background: transparent; color: var(--ink); cursor: pointer;
  padding: 12px 2px; font-size: 10.5px; font-weight: 400; letter-spacing: 0.12em; text-transform: uppercase; white-space: nowrap;
}
.seg button:first-child { border-left: 0; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); }

.more { border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.more summary {
  list-style: none; display: flex; align-items: center; gap: 12px; padding: 15px 0; cursor: pointer;
  font-size: 13px; font-weight: 400;
}
.more summary::-webkit-details-marker { display: none; }
.more summary::after { content: "+"; font-family: var(--serif); font-size: 24px; line-height: 1; color: var(--muted); width: 14px; text-align: center; }
.more[open] summary::after { content: "\2212"; }
.more-sum { margin-left: auto; font-size: 12px; color: var(--muted); text-align: right; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.more .group { padding-top: 6px; }

/* ---------- Figures and notes ---------- */
.figs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-top: 1px solid var(--rule); border-left: 1px solid var(--rule); margin-top: 22px; }
.fig { padding: 12px 12px 14px; border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); min-width: 0; }
.fig .eyebrow { font-size: 9px; letter-spacing: 0.2em; }
.fig .n { font-family: var(--serif); font-size: 24px; font-weight: 400; line-height: 1.15; margin-top: 5px; font-variant-numeric: lining-nums tabular-nums; overflow-wrap: anywhere; }
.fig .s { font-size: 11px; color: var(--muted); margin-top: 1px; }
.notes { display: grid; gap: 10px; margin-top: 18px; }
.notes:empty { display: none; }
.note { font-size: 13px; line-height: 1.5; color: var(--ink-soft); padding-left: 12px; border-left: 1px solid var(--accent); }
.note b { font-weight: 500; color: var(--ink); }
.note.saving { border-left-color: var(--ink); }

/* ---------- Buttons ---------- */
.actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 24px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 12px;
  border: 1px solid var(--ink); background: transparent; color: var(--ink); cursor: pointer; text-decoration: none; text-align: center;
  font-size: 10.5px; font-weight: 400; letter-spacing: 0.18em; text-transform: uppercase; line-height: 1.3;
}
.btn.solid { background: var(--ink); color: var(--on-ink); }
.btn:active, .cbtn:active, .seg button:active, .tiers button:active { opacity: 0.7; }
.btn-sm {
  border: 1px solid var(--ink); background: transparent; color: var(--ink); min-height: 34px; padding: 0 14px; cursor: pointer;
  font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase;
}
.btn-sm.solid { background: var(--ink); color: var(--on-ink); }
.icon-btn { border: 0; background: none; color: var(--muted); padding: 10px; cursor: pointer; line-height: 0; }
.fine { font-size: 11px; color: var(--muted); line-height: 1.55; margin-top: 18px; }

/* ---------- Afford tiers ---------- */
.tiers { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--rule-strong); margin-top: 18px; }
.tiers button {
  border: 0; border-left: 1px solid var(--rule-strong); background: transparent; color: var(--ink); cursor: pointer;
  padding: 10px 4px 11px; display: grid; gap: 1px; justify-items: center; min-width: 0;
}
.tiers button:first-child { border-left: 0; }
.tiers button[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); }
.t-l { font-size: 9px; letter-spacing: 0.16em; text-transform: uppercase; }
.t-p { font-family: var(--serif); font-size: 22px; line-height: 1.15; font-variant-numeric: lining-nums tabular-nums; }
.t-d { font-size: 10.5px; opacity: 0.7; }

/* ---------- Saved ---------- */
.saved-list { border-top: 1px solid var(--rule-strong); }
.saved-list:empty { display: none; }
.saved { padding: 16px 0; border-bottom: 1px solid var(--rule); display: grid; gap: 8px; }
.saved-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.saved-name { font-family: var(--serif); font-size: 22px; line-height: 1.15; min-width: 0; overflow-wrap: anywhere; }
.saved-pay { font-family: var(--serif); font-size: 24px; white-space: nowrap; font-variant-numeric: lining-nums tabular-nums; }
.saved-pay small { font-size: 12px; color: var(--muted); }
.saved-meta { font-size: 12.5px; color: var(--ink-soft); }
.saved-tag { font-size: 9px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--accent); }
.saved-acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.saved-acts .btn { min-height: 36px; padding: 0 12px; font-size: 9.5px; }
.saved-acts .btn.quiet { border-color: var(--rule); color: var(--muted); }
.empty { border-top: 1px solid var(--rule-strong); padding: 26px 0 8px; }
.empty-title { font-family: var(--serif); font-size: 26px; }
.empty p { color: var(--ink-soft); font-size: 14px; margin: 8px 0 18px; max-width: 42ch; }
.empty b { font-weight: 500; }

/* ---------- Ernest ---------- */
.profile { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 18px; align-items: end; padding: 26px 0 20px; }
.profile img { width: 112px; height: 112px; object-fit: cover; filter: grayscale(1) contrast(1.02); }
.profile h1 { font-size: 34px; }
.role { font-size: 12px; color: var(--muted); margin-top: 6px; }
.lede { font-size: 15px; color: var(--ink-soft); padding-top: 16px; border-top: 1px solid var(--rule-strong); }
.contact-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 20px; }
.cbtn {
  display: grid; justify-items: center; gap: 8px; padding: 16px 6px; border: 1px solid var(--ink); color: var(--ink);
  text-decoration: none; font-size: 10.5px; letter-spacing: 0.2em; text-transform: uppercase;
}
.cbtn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linejoin: round; stroke-linecap: round; }
.rows { margin-top: 22px; border-top: 1px solid var(--rule); }
.row { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 12px; align-items: baseline; padding: 12px 0; border-bottom: 1px solid var(--rule); }
.row .k { font-size: 9.5px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--muted); }
.row .v { font-family: var(--serif); font-style: italic; font-size: 19px; overflow-wrap: anywhere; min-width: 0; }
.row a { color: inherit; text-decoration: none; }
.copy { border: 1px solid var(--rule); background: transparent; color: var(--ink-soft); padding: 6px 10px; cursor: pointer; font-size: 9.5px; letter-spacing: 0.2em; text-transform: uppercase; }
.install-help { margin-top: 26px; padding: 16px; background: var(--bg-dim); border: 1px solid var(--rule); }
.install-help ol { margin: 10px 0 0; padding-left: 18px; font-size: 14px; color: var(--ink-soft); }
.install-help li + li { margin-top: 6px; }
.install-help .btn { margin-top: 12px; width: 100%; }
.disclaimer { margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--rule); font-size: 11px; color: var(--muted); line-height: 1.6; }
.disclaimer p { margin-bottom: 10px; }
.eho { display: flex; align-items: center; gap: 10px; font-size: 9.5px; letter-spacing: 0.22em; text-transform: uppercase; margin-top: 6px; }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: var(--bar-bg); -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  border-top: 1px solid var(--rule); padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tabbar-inner { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tabbar button {
  position: relative; border: 0; background: none; color: var(--muted); cursor: pointer; padding: 9px 0 8px;
  display: grid; justify-items: center; gap: 3px; font-size: 9.5px; letter-spacing: 0.14em; text-transform: uppercase;
}
.tabbar svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linejoin: round; stroke-linecap: round; }
.tabbar button[aria-selected="true"] { color: var(--ink); }
.tabbar button[aria-selected="true"]::before { content: ""; position: absolute; top: -1px; left: 28%; right: 28%; height: 1px; background: var(--ink); }
.badge {
  position: absolute; top: 5px; left: calc(50% + 7px); min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: var(--accent); color: var(--bg); font-size: 9.5px; font-style: normal; letter-spacing: 0; display: grid; place-items: center;
}

/* ---------- Sheet + toast ---------- */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 50; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; max-width: 560px; margin: 0 auto; max-height: 88vh; overflow: auto;
  background: var(--bg); border-top: 1px solid var(--rule-strong);
  padding: 10px max(16px, env(safe-area-inset-right, 0px)) calc(18px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}
.sheet-grip { width: 36px; height: 3px; background: var(--rule); margin: 0 auto 14px; }
.sheet-title { font-family: var(--serif); font-size: 26px; line-height: 1.1; margin: 6px 0 12px; }
.sheet-preview {
  white-space: pre-wrap; font-family: var(--sans); font-size: 13px; line-height: 1.55; margin: 0; color: var(--ink-soft);
  background: var(--bg-dim); border: 1px solid var(--rule); padding: 12px; max-height: 32vh; overflow: auto;
}
.sheet-preview:empty { display: none; }
.sheet-steps { margin: 0; padding-left: 18px; font-size: 14px; color: var(--ink-soft); }
.sheet-steps li + li { margin-top: 8px; }
.sheet-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.sheet-actions:empty { display: none; }
.sheet-cancel { width: 100%; margin-top: 10px; border-color: var(--rule); }
.toast {
  position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom, 0px)); z-index: 70;
  transform: translate(-50%, 12px); opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease;
  background: var(--ink); color: var(--on-ink); padding: 10px 14px; font-size: 13px; display: flex; align-items: center; gap: 14px;
  max-width: calc(100% - 32px); white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast button { border: 0; background: none; color: inherit; cursor: pointer; padding: 4px; font-size: 10.5px; letter-spacing: 0.2em; text-transform: uppercase; text-decoration: underline; text-underline-offset: 3px; }

button:focus-visible, a:focus-visible, summary:focus-visible, select:focus-visible { outline: 1px solid var(--accent); outline-offset: 3px; }
.control input:focus-visible, .control select:focus-visible { outline: none; }

@media (max-width: 370px) {
  .big { font-size: 54px; }
  .control input { font-size: 23px; }
  .seg button { letter-spacing: 0.06em; font-size: 10px; }
  .t-p { font-size: 19px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
