/* Meridian Capital — Portfolio Construction prototype (snyx showcase; reconstructed from client work, synthetic data).
   Desktop first (metrics and colours read off the 2023-03-03 screens), with
   responsive tiers at the end: ≤1199 drawer nav, ≤959 stacked builder and
   charts, ≤767 mobile with touch-first sliders. */

:root {
  --font: "Nunito Sans", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --navy: #10122f;            /* topbar, headings */
  --indigo: #1e2266;          /* primary buttons, slider, net cash */
  --indigo-hover: #2a2f7e;
  --violet: #3d3a9a;          /* links, outline button */
  --violet-soft: #eef0f8;     /* table header */
  --text: #1f2030;
  --muted: #6b6c7b;
  --faint: #9a9ba8;
  --line: #dfe0e8;
  --line-soft: #ecedf2;
  --grid: #e6e7ee;
  --bg: #ffffff;
  --side: #f7f7f9;
  --side-active: #f0f0f4;
  --track: #d6d8e4;
  --tip: #1c1c24;
  --radius: 4px;
  --topbar-h: 88px;
  --sidebar-w: 240px;
  --content-w: 1100px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body { font: 15px/1.5 var(--font); color: var(--text); background: var(--bg); min-height: 100vh; }
body.no-scroll { overflow: hidden; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:disabled { cursor: default; }
input, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
svg.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }
h1, h2, h3 { line-height: 1.25; color: var(--navy); }
:focus-visible { outline: 2px solid var(--violet); outline-offset: 2px; }
b { font-weight: 700; }

/* ================================================================ shell */
.topbar { position: sticky; top: 0; z-index: 20; height: var(--topbar-h); background: var(--navy); color: #fff; display: flex; align-items: center; justify-content: space-between; padding: 0 32px 0 30px; }
.logo { display: inline-flex; align-items: center; gap: 6px; color: #fff; font-size: 21px; font-weight: 500; letter-spacing: .22em; }
.logo .logo-mark { width: 22px; height: 26px; stroke: none; fill: #fff; }
.logo.dark { color: var(--navy); }
.logo.dark .logo-mark { fill: var(--navy); }
.iconbtn { width: 40px; height: 40px; display: inline-grid; place-items: center; border-radius: var(--radius); color: #fff; }
.iconbtn:hover { background: rgba(255, 255, 255, .1); }
.iconbtn .ic { width: 22px; height: 22px; }

.frame { display: flex; min-height: calc(100vh - var(--topbar-h)); }
.sidebar { width: var(--sidebar-w); flex: none; background: var(--side); border-right: 1px solid var(--line-soft); display: flex; flex-direction: column; justify-content: space-between; position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); }
.nav { list-style: none; }
.nav-item { display: flex; align-items: center; gap: 12px; width: 100%; height: 64px; padding: 0 18px 0 20px; font-size: 16px; color: var(--text); border-left: 4px solid transparent; text-align: left; }
.nav-item .ic { width: 18px; height: 18px; color: var(--navy); }
.nav-item span { flex: 1; }
.nav-item .chev { width: 16px; height: 16px; color: var(--muted); transition: transform .15s; }
.nav-item:hover { background: var(--side-active); }
.nav-group.is-active > .nav-item { border-left-color: var(--indigo); background: var(--side-active); }
.nav-sub { list-style: none; background: var(--side-active); border-top: 1px solid var(--line-soft); }
.nav-group:not(.is-active) .nav-sub { background: transparent; }
.nav-sub-item { display: flex; align-items: center; height: 57px; padding-left: 44px; font-size: 16px; border-bottom: 1px solid var(--line-soft); }
.nav-sub-item:hover { background: #eaeaf0; }
.nav-sub-item.is-here { font-weight: 700; color: var(--navy); }
.help { padding: 28px 18px 28px 18px; display: grid; grid-template-columns: 40px 1fr; column-gap: 14px; row-gap: 16px; align-items: start; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: linear-gradient(160deg, #e4dbc8, #c8b592); color: #5f5340; display: grid; place-items: center; overflow: hidden; }
.avatar .ic { width: 24px; height: 24px; }
.help-text { font-size: 13px; line-height: 1.45; color: var(--muted); }
.help-text strong { display: block; font-size: 14px; color: var(--text); margin-bottom: 2px; }
.help .btn { grid-column: 2; justify-self: start; }

.main { flex: 1; min-width: 0; padding: 0 48px 72px 48px; }
.page-head { display: flex; align-items: center; justify-content: space-between; max-width: var(--content-w); height: 88px; margin-top: 0; }
.page-head h1 { font-size: 30px; font-weight: 400; }
.content { max-width: var(--content-w); display: grid; gap: 28px; margin-top: 24px; }
.results { display: grid; gap: 28px; }   /* the results wrapper spaces its cards like .content does */

/* ============================================================= buttons */
.btn { display: inline-flex; align-items: center; gap: 10px; height: 40px; padding: 0 16px; border-radius: var(--radius); font-size: 15px; font-weight: 600; white-space: nowrap; transition: background .12s, color .12s; }
.btn .ic { width: 20px; height: 20px; }
.btn.primary { background: var(--indigo); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--indigo-hover); }
.btn.primary:disabled { background: #ebebf0; color: #9d9eab; }
.btn.outline { border: 1px solid var(--violet); color: var(--violet); background: #fff; }
.btn.outline:hover { background: var(--violet-soft); }
.btn.sm { height: 40px; padding: 0 14px; font-size: 15px; }
.link { color: var(--violet); font-size: 13.5px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.link:hover { color: var(--indigo); }
.textbtn { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); padding: 4px 8px; border-radius: var(--radius); }
.textbtn .ic { width: 16px; height: 16px; }
.textbtn:hover { color: var(--violet); background: var(--violet-soft); }

/* ================================================================ cards */
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.card-head { position: relative; overflow: hidden; display: flex; align-items: center; justify-content: space-between; width: 100%; height: 56px; padding: 0 20px; font-size: 17px; color: var(--text); text-align: left; border-radius: var(--radius); }
.card-head:hover { background: #fafafc; }
.card-head .ic { width: 22px; height: 22px; color: var(--navy); stroke-width: 2; }
.builder:not(.is-collapsed) .card-head { border-bottom: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; }

.builder-body { display: grid; grid-template-columns: 256px 1fr 216px; gap: 36px; padding: 20px 20px 24px; }
.builder-body h3 { font-size: 18px; font-weight: 600; margin-bottom: 14px; }
.help-copy { font-size: 15px; line-height: 1.6; color: var(--text); margin-bottom: 14px; }
.fields { display: flex; gap: 22px; margin-bottom: 28px; }
.field { display: grid; gap: 8px; font-size: 15px; }
.field input, .field select { height: 42px; border: 1px solid #c9cad5; border-radius: var(--radius); padding: 0 14px; background: #fff; width: 100%; }
.field input:focus, .field select:focus { outline: none; border-color: var(--violet); box-shadow: 0 0 0 3px rgba(61, 58, 154, .12); }
/* Step one: the empty amount field breathes a soft halo until something is typed.
   Deliberately not gated on prefers-reduced-motion: it is the cue for what to do first. */
.field input.is-pulse { animation: halo 1.8s ease-out infinite; }
.field input.is-pulse:focus { animation-name: halo-focus; }
@keyframes halo { 0% { box-shadow: 0 0 0 0 rgba(61, 58, 154, .35); } 70%, 100% { box-shadow: 0 0 0 9px rgba(61, 58, 154, 0); } }
@keyframes halo-focus { 0% { box-shadow: 0 0 0 3px rgba(61, 58, 154, .12), 0 0 0 0 rgba(61, 58, 154, .35); } 70%, 100% { box-shadow: 0 0 0 3px rgba(61, 58, 154, .12), 0 0 0 9px rgba(61, 58, 154, 0); } }
.field.currency { width: 96px; }
.field:not(.currency) { flex: 1; }
.select-wrap { position: relative; display: block; }
.select-wrap select { appearance: none; -webkit-appearance: none; padding-right: 34px; }
.select-wrap .ic { position: absolute; right: 10px; top: 50%; width: 18px; height: 18px; margin-top: -9px; pointer-events: none; color: var(--navy); stroke-width: 2; }

/* sliders */
.sliders { display: grid; gap: 6px; }
.slider { display: grid; grid-template-columns: 84px 28px 1fr; align-items: center; height: 36px; }
.slider label { font-size: 15px; }
.slider .val { font-size: 16px; font-weight: 700; color: var(--navy); }
.track-wrap { position: relative; height: 36px; }
.track { position: absolute; left: 10px; right: 10px; top: 50%; height: 3px; margin-top: -1.5px; background: var(--track); border-radius: 2px; }
.track .fill { position: absolute; left: 0; top: 0; height: 100%; background: var(--indigo); border-radius: 2px; }
.track i { position: absolute; top: -3px; width: 1px; height: 9px; margin-left: -.5px; background: #c3c5d3; }
.track-wrap input[type="range"] { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; background: transparent; appearance: none; -webkit-appearance: none; cursor: pointer; }
.track-wrap input[type="range"]::-webkit-slider-runnable-track { height: 100%; background: transparent; }
.track-wrap input[type="range"]::-moz-range-track { background: transparent; }
.track-wrap input[type="range"]::-webkit-slider-thumb { appearance: none; -webkit-appearance: none; width: 22px; height: 22px; margin-top: 7px; border-radius: 50%; background: var(--indigo); border: 0; box-shadow: 0 1px 3px rgba(16, 18, 47, .3); }
.track-wrap input[type="range"]::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: var(--indigo); border: 0; box-shadow: 0 1px 3px rgba(16, 18, 47, .3); }
.track-wrap input[type="range"]:focus-visible { outline: none; }
.track-wrap input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px rgba(61, 58, 154, .25); }

.col.mix { display: grid; justify-items: center; align-content: space-between; gap: 20px; }
.donut-wrap { position: relative; width: 196px; height: 196px; }
.donut { display: block; width: 100%; height: 100%; }
.donut .seg { cursor: pointer; transition: opacity .12s; }
.donut .seg:hover, .donut .seg:focus-visible { opacity: .85; outline: none; }
.col.mix .btn { width: 100%; justify-content: center; }
/* Construct: while the steps are incomplete the disabled button explains itself on hover.
   The tooltip hangs off a wrapper because a disabled button receives no pointer events. */
.construct-wrap { position: relative; width: 100%; }
.construct-wrap > #construct:disabled { pointer-events: none; }
.construct-wrap::after { content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 10px); transform: translateX(-50%); background: var(--tip); color: #fff; font-size: 12px; font-weight: 400; line-height: 1.4; padding: 8px 12px; border-radius: 6px; white-space: nowrap; z-index: 5; opacity: 0; pointer-events: none; transition: opacity .1s; }
.construct-wrap::before { content: ""; position: absolute; left: 50%; bottom: calc(100% + 4px); margin-left: -6px; border: 6px solid transparent; border-top-color: var(--tip); border-bottom: 0; opacity: 0; pointer-events: none; transition: opacity .1s; }
.builder:not(.is-loading) .construct-wrap:has(> #construct:disabled):hover::after,
.builder:not(.is-loading) .construct-wrap:has(> #construct:disabled):hover::before { opacity: 1; }

/* ============================================================== summary */
.summary { padding: 22px 20px 12px; }
.summary h2 { font-size: 20px; font-weight: 700; margin-bottom: 16px; }
.summary .when { font-weight: 400; }
.stale { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #8a5a00; background: #fff6e0; border: 1px solid #f2dba3; padding: 8px 12px; border-radius: var(--radius); margin-bottom: 14px; }
.stale .ic { width: 16px; height: 16px; }
.summary-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.summary-table thead th { background: var(--violet-soft); color: var(--indigo); font-size: 12px; font-weight: 700; text-align: left; padding: 10px 8px; }
.summary-table th.num, .summary-table td.num { text-align: center; }
.summary-table thead th:first-child { width: 200px; }
.summary-table thead th:nth-child(2) { width: 140px; }
.summary-table thead th:nth-child(3) { width: 110px; }
.summary-table tbody tr { border-bottom: 1px solid var(--line-soft); }
.summary-table tbody tr:nth-child(even) { background: #f8f8fa; }
.summary-table tbody th { text-align: left; font-weight: 400; padding: 18px 8px; vertical-align: top; }
.summary-table tbody td { padding: 18px 8px; vertical-align: top; }
.summary-table td.desc { line-height: 1.45; padding-right: 24px; }
.term { position: relative; color: var(--violet); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; cursor: help; border-radius: 2px; }
.term::after { content: attr(data-tip); position: absolute; left: calc(100% + 14px); top: 50%; transform: translateY(-50%); width: 180px; background: var(--tip); color: #fff; font-size: 12px; font-weight: 400; line-height: 1.4; padding: 10px 12px; border-radius: 6px; z-index: 5; opacity: 0; pointer-events: none; transition: opacity .1s; }
.term::before { content: ""; position: absolute; left: calc(100% + 8px); top: 50%; margin-top: -6px; border: 6px solid transparent; border-right-color: var(--tip); border-left: 0; opacity: 0; pointer-events: none; transition: opacity .1s; }
.term:hover::after, .term:hover::before, .term:focus-visible::after, .term:focus-visible::before { opacity: 1; }

/* =============================================================== charts */
.chart-card { padding: 22px 20px 16px; }
.charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 36px; padding: 22px 20px 16px; }
.chart-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.chart-head h3 { font-size: 18px; font-weight: 600; }
.plot { position: relative; }
.chart-svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-svg .grid { stroke: var(--grid); stroke-width: 1; }
.chart-svg .grid.zero { stroke: #c9cad6; }
.chart-svg .tick { font: 700 11.5px var(--font); fill: var(--text); }
.chart-svg .seg { cursor: pointer; transition: opacity .1s; outline: none; }
.chart-svg .seg.is-hover, .chart-svg .seg:focus-visible { opacity: .82; }
.chart-svg .crosshair { stroke: var(--faint); stroke-width: 1; pointer-events: none; }
.chart-svg .hit { cursor: crosshair; }
.chart-svg .hit, .chart-svg .seg, .donut .seg { touch-action: pan-y; }
.legend { list-style: none; display: flex; gap: 24px; margin-top: 16px; padding-left: 4px; }
.legend-item { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; color: var(--text); padding: 4px 6px; border-radius: var(--radius); }
.legend-item:hover { background: #f4f4f8; }
.legend-item.is-off { color: var(--faint); }
.legend-item.is-off .key { opacity: .3; }
.key { display: inline-block; flex: none; background: var(--c); }
.key.dot { width: 11px; height: 11px; border-radius: 50%; }
.key.line { width: 14px; height: 2px; border-radius: 1px; }
.table-wrap { max-height: 420px; overflow: auto; border: 1px solid var(--line-soft); border-radius: var(--radius); }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { position: sticky; top: 0; background: var(--violet-soft); color: var(--indigo); font-size: 12px; text-align: left; padding: 8px 12px; }
table.data td { padding: 7px 12px; border-bottom: 1px solid var(--line-soft); font-variant-numeric: tabular-nums; }
table.data .num { text-align: right; }
table.data tbody tr:hover { background: #f8f8fa; }

/* tooltips */
.tip { position: absolute; z-index: 10; min-width: 120px; background: var(--tip); color: #fff; border-radius: 6px; padding: 8px 10px 6px; font-size: 12px; pointer-events: none; box-shadow: 0 6px 20px rgba(16, 18, 47, .22); }
.tip.is-pill { min-width: 0; padding: 6px 10px; font-weight: 700; white-space: nowrap; }
.tip.is-pill::before { content: ""; position: absolute; left: -6px; top: 50%; margin-top: -6px; border: 6px solid transparent; border-right-color: var(--tip); border-left: 0; }
.tip-title { color: #c9cad6; font-size: 11px; margin-bottom: 6px; white-space: nowrap; }
.tip-row { display: flex; align-items: center; gap: 8px; padding: 2px 0; white-space: nowrap; }
.tip-row .key.dot { width: 10px; height: 10px; border-radius: 2px; }
.tip-label { color: #d6d7e0; }
.tip-value { margin-left: auto; font-weight: 700; padding-left: 14px; }
.tip-row.is-strong .tip-label { color: #fff; }

/* toasts */
.toast-wrap { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 50; }
.toast { display: flex; align-items: center; gap: 10px; background: var(--navy); color: #fff; font-size: 14px; padding: 12px 16px; border-radius: 6px; box-shadow: 0 8px 24px rgba(16, 18, 47, .25); animation: rise .18s ease-out; }
.toast.warn { background: #3a2a06; }
.toast .ic { width: 18px; height: 18px; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* =============================================================== motion */
/* Loading state after Construct is clicked: spinner in the button, an
   indeterminate bar under the card header, the form dimmed. */
.spinner { width: 18px; height: 18px; border: 2.5px solid rgba(255, 255, 255, .35); border-top-color: #fff; border-radius: 50%; flex: none; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.builder.is-loading .card-head::after { content: ""; position: absolute; left: -30%; bottom: 0; height: 3px; width: 30%; background: var(--violet); border-radius: 2px; animation: indeterminate 1.1s ease-in-out infinite; }
@keyframes indeterminate { to { left: 100%; } }
.builder.is-loading .col.amount, .builder.is-loading .col.strategy { opacity: .5; pointer-events: none; transition: opacity .25s; }
.builder.is-loading #construct:disabled { background: var(--indigo); color: #fff; }

/* Entrance of the results. The container carries .is-entering; each card waits
   invisible until app.js marks it .is-in as it scrolls into view, then the card
   rises and its chart rolls out left to right: bars grow in turn, lines draw,
   dots pop along the line, the reference line and legend arrive last. --d
   staggers cards that come into view together (set inline by app.js); --t0 is
   where the chart marks start inside the card's own timeline. Deliberately not
   gated on prefers-reduced-motion: the rollout is the point of the demo. */
.is-entering > .card { opacity: 0; }
.is-entering > .card.is-in { animation: card-in .6s cubic-bezier(.2, .7, .2, 1) both; animation-delay: var(--d, 0ms); }
@keyframes card-in { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }   /* explicit `to`: the waiting card's base opacity is 0 */
@keyframes fade-in { from { opacity: 0; } }
.is-entering .is-in .summary-table tbody tr { animation: fade-in .5s ease-out both; animation-delay: calc(var(--d, 0ms) + 260ms + var(--i) * 110ms); }
.is-entering .is-in { --t0: 380ms; }
.is-entering .is-in .chart-col:nth-child(2) { --t0: 680ms; }   /* the right-hand chart follows the left */
.is-entering .is-in .chart-svg .grid, .is-entering .is-in .chart-svg .tick { animation: fade-in .45s ease-out both; animation-delay: calc(var(--d, 0ms) + var(--t0) - 140ms); }
.is-entering .is-in .chart-svg g.bar, .is-entering .is-in .chart-svg rect.bar { transform-box: fill-box; transform-origin: bottom center; animation: grow .55s cubic-bezier(.2, .7, .2, 1) both; animation-delay: calc(var(--d, 0ms) + var(--t0) + var(--i) * 45ms); }
.is-entering .is-in .chart-svg rect.bar.down { transform-origin: top center; }
@keyframes grow { from { transform: scaleY(0); } }
.is-entering .is-in .chart-svg .line { stroke-dasharray: 1 1; stroke-dashoffset: 1; animation: draw 1.3s cubic-bezier(.4, 0, .2, 1) forwards; animation-delay: calc(var(--d, 0ms) + var(--t0) + 260ms); }
@keyframes draw { to { stroke-dashoffset: 0; } }
.is-entering .is-in .chart-svg .dot { transform-box: fill-box; transform-origin: center; animation: pop .3s cubic-bezier(.2, .7, .2, 1.2) both; animation-delay: calc(var(--d, 0ms) + var(--t0) + 260ms + var(--i) * 60ms); }
@keyframes pop { from { transform: scale(0); } }
.is-entering .is-in .chart-svg .ref { stroke-dasharray: 1 1; stroke-dashoffset: 1; animation: draw .7s ease-out forwards; animation-delay: calc(var(--d, 0ms) + var(--t0) + 1500ms); }
.is-entering .is-in .legend, .is-entering .is-in .chart-head .textbtn { animation: fade-in .45s ease-out both; animation-delay: calc(var(--d, 0ms) + var(--t0) + 1100ms); }

/* =========================================================== responsive */
.menubtn, .drawer-head, .steps, .bubble, .yr, .backdrop { display: none; }

/* ---- ≤1199: the sidebar becomes a drawer behind a menu button */
@media (max-width: 1199px) {
  .menubtn { display: inline-grid; }
  .topbar { padding: 0 16px 0 10px; }
  .topbar .logo { margin-right: auto; margin-left: 6px; }
  .sidebar { position: fixed; top: 0; left: 0; bottom: 0; height: 100vh; height: 100dvh; width: 300px; max-width: 86vw; z-index: 40; transform: translateX(-100%); transition: transform .2s ease; overflow-y: auto; border-right: 0; }
  .sidebar.is-open { transform: none; box-shadow: 12px 0 40px rgba(16, 18, 47, .25); }
  .backdrop { display: block; position: fixed; inset: 0; background: rgba(16, 18, 47, .45); z-index: 35; }
  .drawer-head { display: flex; align-items: center; justify-content: space-between; height: 64px; padding: 0 8px 0 18px; border-bottom: 1px solid var(--line-soft); }
  .drawer-head .logo { font-size: 18px; }
  .drawer-head .iconbtn { color: var(--navy); }
  .drawer-head .iconbtn:hover { background: var(--side-active); }
  .main { padding: 0 32px 64px; }
  .page-head, .content { max-width: none; }
}

/* ---- ≤959: builder goes two-column, charts stack */
@media (max-width: 959px) {
  .builder-body { grid-template-columns: 1fr 200px; gap: 24px 32px; }
  .col.amount, .col.strategy { grid-column: 1; }
  .col.mix { grid-column: 2; grid-row: 1 / span 2; align-content: start; gap: 24px; padding-top: 8px; }
  .charts-row { grid-template-columns: 1fr; gap: 32px; }

  /* summary rows become stacked cards */
  .summary { padding: 16px 16px 4px; }
  .summary h2 { font-size: 18px; }
  .summary .when { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; }
  .summary-table, .summary-table tbody { display: block; }
  .summary-table thead { display: none; }
  .summary-table tbody tr { display: grid; grid-template-columns: 1fr auto; padding: 14px 0; row-gap: 4px; background: none !important; }
  .summary-table tbody th { grid-column: 1 / -1; padding: 0; font-weight: 700; color: var(--navy); }
  .summary-table tbody td { padding: 0; }
  .summary-table td.amount { text-align: left; font-size: 17px; font-weight: 700; }
  .summary-table td.year { text-align: right; color: var(--muted); align-self: end; }
  .yr { display: inline; }
  .summary-table td.desc { grid-column: 1 / -1; font-size: 14px; line-height: 1.5; color: var(--muted); padding-right: 0; }
  .term::after { left: 0; top: calc(100% + 10px); transform: none; width: min(260px, 80vw); }
  .term::before { left: 12px; top: calc(100% + 4px); margin: 0; border: 6px solid transparent; border-bottom-color: var(--tip); border-top: 0; }
}

/* ---- ≤767: mobile */
@media (max-width: 767px) {
  :root { --topbar-h: 64px; }
  .topbar { padding: 0 6px; }
  .logo { font-size: 16px; gap: 4px; letter-spacing: .14em; } /* two-word wordmark fits 320px */
  .logo .logo-mark { width: 18px; height: 21px; }
  .main { padding: 0 16px 48px; }
  .page-head { height: 64px; }
  .page-head h1 { font-size: 24px; }
  .btn.advanced { width: 40px; padding: 0; justify-content: center; }
  .btn.advanced span { display: none; }
  .content, .results { gap: 16px; }
  .content { margin-top: 8px; }
  .card-head { height: 52px; padding: 0 16px; font-size: 16px; }
  .builder-body { grid-template-columns: 1fr; gap: 24px; padding: 16px 16px 20px; }
  .builder-body h3 { font-size: 17px; margin-bottom: 10px; }
  .help-copy { font-size: 14px; }
  .fields { margin-bottom: 20px; }
  .field input, .field select { height: 44px; font-size: 16px; } /* 16px stops iOS zooming the field */
  .col.mix { grid-column: 1; grid-row: auto; justify-items: stretch; padding-top: 0; gap: 20px; }
  .donut-wrap { width: 160px; height: 160px; justify-self: center; }
  .col.mix .btn { height: 48px; font-size: 16px; }

  /* touch-first sliders: label + value on one line, a 44px-tall track,
     28px thumb, a value bubble while dragging, tappable 0–5 step marks */
  .sliders { gap: 8px; }
  .slider { grid-template-columns: 1fr auto; grid-template-areas: "label val" "track track" "steps steps"; height: auto; row-gap: 0; }
  .slider label { grid-area: label; font-weight: 600; }
  .slider .val { grid-area: val; font-size: 17px; }
  .track-wrap { grid-area: track; height: 44px; }
  .track { left: 14px; right: 14px; height: 4px; margin-top: -2px; }
  .track i { top: -4px; height: 12px; }
  .track-wrap input[type="range"]::-webkit-slider-thumb { width: 28px; height: 28px; margin-top: 8px; }
  .track-wrap input[type="range"]::-moz-range-thumb { width: 28px; height: 28px; }
  .bubble { display: block; position: absolute; bottom: 24px; transform: translateX(-50%); min-width: 32px; padding: 3px 8px; border-radius: 6px; background: var(--tip); color: #fff; font-size: 13px; font-weight: 700; text-align: center; opacity: 0; transition: opacity .12s; pointer-events: none; }
  .bubble::after { content: ""; position: absolute; left: 50%; bottom: -5px; margin-left: -5px; border: 5px solid transparent; border-top-color: var(--tip); border-bottom: 0; }
  .slider.is-dragging .bubble { opacity: 1; }
  .steps { display: block; grid-area: steps; position: relative; height: 24px; margin: -4px 14px 0; }
  .step { position: absolute; top: 0; transform: translateX(-50%); width: 32px; height: 24px; font-size: 12px; font-weight: 700; color: var(--faint); border-radius: 4px; }
  .step.is-on { color: var(--indigo); }

  /* charts */
  .chart-card, .charts-row { padding: 16px 12px 12px; }
  .charts-row { gap: 28px; }
  .chart-head { margin-bottom: 12px; }
  .chart-head h3 { font-size: 16px; }
  .legend { flex-wrap: wrap; gap: 4px 14px; margin-top: 10px; }
  .tip { font-size: 12px; }
  .toast-wrap { width: calc(100% - 32px); max-width: 420px; }
  .toast { width: 100%; }
}
