/* yourFAHub - warm editorial finance
   Colour, type and layout tokens. Light is the base; dark redefines tokens only. */

:root {
  --ground: #f2ede3;
  --ground-2: #e9e2d4;
  --surface: #fcfaf5;
  --surface-2: #f1ebdf;
  --line: #ddd5c4;
  --line-strong: #c7bda7;
  --ink: #211e19;
  --ink-2: #5e584b;
  --ink-3: #837c6c;
  --forest: #1e4034;
  --forest-2: #2b5646;
  --forest-ink: #eef3ec;
  --forest-ink-2: #b8ccbf;
  --cobalt: #2a4fd7;
  --cobalt-soft: #e3e7fb;
  --clay: #b5551f;
  --clay-soft: #f6e6da;
  --good: #2e6b4e;
  --bad: #a33b26;
  --warn-bg: #fbf0d8;
  --warn-line: #d9bc7a;
  --warn-ink: #6d5113;
  --focus: #2a4fd7;
  --alloc-closing: #7b7261;
  --alloc-closing-ink: #fffdf8;
  --shadow: 0 1px 2px rgba(33, 30, 25, 0.06), 0 8px 24px -16px rgba(33, 30, 25, 0.35);
  --serif: "Fraunces", "Iowan Old Style", Georgia, serif;
  --sans: "Public Sans", "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --radius: 10px;
  --maxw: 1240px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #16140f;
    --ground-2: #1c1914;
    --surface: #201d18;
    --surface-2: #2a2620;
    --line: #3b362d;
    --line-strong: #524b3e;
    --ink: #f3eee4;
    --ink-2: #b6ad9a;
    --ink-3: #97907f;
    --forest: #21453a;
    --forest-2: #2d5a4a;
    --forest-ink: #eaf2ec;
    --forest-ink-2: #a9c4b3;
    --cobalt: #5c7cf0;
    --cobalt-soft: #25315c;
    --clay: #c97a33;
    --clay-soft: #3a2a1a;
    --good: #6cbf90;
    --bad: #e08573;
    --warn-bg: #352c16;
    --warn-line: #6d5a2b;
    --warn-ink: #e4cf9c;
    --focus: #8aa4ff;
    --alloc-closing: #8d8574;
    --alloc-closing-ink: #17140f;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 30px -18px rgba(0, 0, 0, 0.9);
  }
}

:root[data-theme="dark"] {
  --ground: #16140f;
  --ground-2: #1c1914;
  --surface: #201d18;
  --surface-2: #2a2620;
  --line: #3b362d;
  --line-strong: #524b3e;
  --ink: #f3eee4;
  --ink-2: #b6ad9a;
  --ink-3: #97907f;
  --forest: #21453a;
  --forest-2: #2d5a4a;
  --forest-ink: #eaf2ec;
  --forest-ink-2: #a9c4b3;
  --cobalt: #5c7cf0;
  --cobalt-soft: #25315c;
  --clay: #c97a33;
  --clay-soft: #3a2a1a;
  --good: #6cbf90;
  --bad: #e08573;
  --warn-bg: #352c16;
  --warn-line: #6d5a2b;
  --warn-ink: #e4cf9c;
  --focus: #8aa4ff;
  --alloc-closing: #8d8574;
  --alloc-closing-ink: #17140f;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 30px -18px rgba(0, 0, 0, 0.9);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* hidden must win over the layout display values below */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  font-family: var(--serif);
  font-weight: 600;
  text-wrap: balance;
  margin: 0;
}

a {
  color: var(--cobalt);
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--surface);
  color: var(--ink);
  padding: 10px 16px;
  z-index: 50;
}

.skip-link:focus {
  left: 8px;
  top: 8px;
}

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

/* ---------------------------------------------------------------- masthead */

.masthead {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--forest);
  color: var(--forest-ink);
  border-bottom: 1px solid rgba(0, 0, 0, 0.25);
}

.masthead-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 16px 20px;
  flex-wrap: wrap;
}

.wordmark {
  font-family: var(--serif);
  font-size: 1.22rem;
  letter-spacing: -0.01em;
  color: var(--forest-ink);
  display: flex;
  align-items: baseline;
}

.wordmark b {
  font-weight: 700;
}

.wordmark .fa {
  color: #f0c98a;
  font-weight: 700;
}

.masthead-tag {
  color: var(--forest-ink-2);
  font-size: 0.8rem;
  border-left: 1px solid rgba(255, 255, 255, 0.22);
  padding-left: 16px;
}

.masthead-nav {
  margin-left: auto;
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.masthead-nav a {
  color: var(--forest-ink-2);
  text-decoration: none;
  font-size: 0.82rem;
  padding: 6px 10px;
  border-radius: 999px;
}

.masthead-nav a:hover {
  color: var(--forest-ink);
  background: rgba(255, 255, 255, 0.09);
}

/* ------------------------------------------------------------------ intro */

.intro {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 40px 20px 26px;
  text-align: left;
}

.intro h1 {
  font-size: clamp(1.5rem, 1.1rem + 1.1vw, 2rem);
  line-height: 1.15;
  margin: 0;
  max-width: 24ch;
  letter-spacing: -0.015em;
}

.intro p {
  margin: 0;
  max-width: 62ch;
}

.intro-sub {
  margin-top: 10px !important;
  color: var(--ink-2);
  font-size: 1.02rem;
  line-height: 1.5;
}

.intro-hint {
  margin-top: 18px !important;
  color: var(--ink-3);
  font-size: 0.86rem;
  line-height: 1.5;
}

/* ----------------------------------------------------------------- layout */

.layout {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 20px 64px;
  display: grid;
  grid-template-columns: minmax(320px, 400px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
  border-top: 1px solid var(--line);
  padding-top: 26px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.inputs {
  position: sticky;
  top: 62px;
  max-height: calc(100vh - 74px);
  overflow-y: auto;
  padding: 18px;
}

.inputs::-webkit-scrollbar {
  width: 10px;
}

.inputs::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 10px;
}

.eyebrow {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  color: var(--ink-3);
  margin: 0 0 10px;
}

.field-group + .field-group {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 13px;
}

.field:last-child {
  margin-bottom: 0;
}

.field label,
.field .label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
}

.field-note {
  font-size: 0.74rem;
  color: var(--ink-3);
  margin: 0;
  line-height: 1.4;
}

.field-error {
  font-size: 0.76rem;
  color: var(--bad);
  margin: 0;
  font-weight: 500;
}

input[type="text"],
input[type="search"],
select {
  font: inherit;
  font-size: 0.92rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 9px 11px;
  width: 100%;
  font-variant-numeric: tabular-nums;
}

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%),
    linear-gradient(135deg, var(--ink-2) 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(50% + 1px), calc(100% - 13px) calc(50% + 1px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
  border-color: var(--focus);
}

input[aria-invalid="true"] {
  border-color: var(--bad);
  background: color-mix(in srgb, var(--bad) 6%, var(--surface));
}

.with-unit {
  position: relative;
  display: flex;
  align-items: center;
}

.with-unit .unit {
  position: absolute;
  left: 11px;
  font-size: 0.86rem;
  color: var(--ink-3);
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}

.with-unit.suffix .unit {
  left: auto;
  right: 11px;
}

.with-unit input {
  padding-left: 34px;
}

.with-unit.suffix input {
  padding-left: 11px;
  padding-right: 30px;
}

.pair {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 8px;
}

/* segmented control */

.seg {
  display: flex;
  gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 4px;
}

.seg.stack {
  flex-direction: column;
}

.seg label {
  flex: 1;
  position: relative;
}

.seg input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.seg span {
  display: block;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 7px 8px;
  border-radius: 6px;
  color: var(--ink-2);
  cursor: pointer;
}

.seg input:checked + span {
  background: var(--forest);
  color: var(--forest-ink);
}

.seg input:focus-visible + span {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* combobox */

.combo {
  position: relative;
}

.combo ul {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 264px;
  overflow-y: auto;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.combo-option {
  padding: 7px 9px;
  border-radius: 6px;
  font-size: 0.88rem;
  cursor: pointer;
}

.combo-option.is-active,
.combo-option:hover {
  background: var(--cobalt-soft);
}

.combo-option[aria-selected="true"] {
  font-weight: 600;
}

.combo-empty {
  padding: 8px 9px;
  font-size: 0.84rem;
  color: var(--ink-3);
}

/* assumptions disclosure */

details.assump {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

details.assump > summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.86rem;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

details.assump > summary::-webkit-details-marker {
  display: none;
}

details.assump > summary::before {
  content: "+";
  font-family: var(--mono);
  color: var(--ink-3);
  font-size: 0.95rem;
}

details.assump[open] > summary::before {
  content: "\2212";
}

.assump-summary {
  margin-top: 10px;
  font-size: 0.76rem;
  color: var(--ink-2);
  line-height: 1.6;
}

.assump-summary .k {
  color: var(--ink-3);
}

.assump-summary b {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--ink);
}

.assump-body {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.assump-item .row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.chip {
  font-size: 0.64rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-3);
  border: 1px solid var(--line);
  white-space: nowrap;
}

.chip.edited {
  background: var(--cobalt-soft);
  color: var(--cobalt);
  border-color: color-mix(in srgb, var(--cobalt) 35%, transparent);
}

.linkbtn {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 0.74rem;
  color: var(--cobalt);
  text-decoration: underline;
  cursor: pointer;
}

/* ---------------------------------------------------------------- results */

.results {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}

.banner {
  border: 1px solid var(--line-strong);
  border-left-width: 4px;
  border-radius: var(--radius);
  padding: 13px 16px;
  background: var(--surface);
  font-size: 0.88rem;
  color: var(--ink-2);
}

.banner b {
  color: var(--ink);
  display: block;
  font-size: 0.94rem;
  margin-bottom: 3px;
  font-weight: 600;
}

.banner.info {
  border-left-color: var(--cobalt);
}

.banner.warn {
  background: var(--warn-bg);
  border-color: var(--warn-line);
  border-left-color: var(--warn-line);
  color: var(--warn-ink);
}

.banner.warn b {
  color: var(--warn-ink);
}

.banner.error {
  border-left-color: var(--bad);
}

.banner ul {
  margin: 6px 0 0;
  padding-left: 18px;
}

.group {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.group > header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.group h2 {
  font-size: 1.12rem;
}

.group .sub {
  font-size: 0.76rem;
  color: var(--ink-3);
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px 18px;
}

.stat .k {
  font-size: 0.76rem;
  color: var(--ink-2);
  display: block;
  margin-bottom: 2px;
}

.stat .v {
  font-family: var(--serif);
  font-size: 1.32rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  display: block;
}

.stat .v.sm {
  font-size: 1.08rem;
}

.stat .v.neg {
  color: var(--bad);
}

.stat .v.pos {
  color: var(--good);
}

.stat .n {
  font-size: 0.72rem;
  color: var(--ink-3);
  display: block;
  margin-top: 3px;
  line-height: 1.4;
}

.stat .v.hero {
  font-size: 1.85rem;
  line-height: 1.15;
}

.divider {
  height: 1px;
  background: var(--line);
  margin: 16px 0;
}

.linelist {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 0.86rem;
}

.linelist > div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: baseline;
}

.linelist .amt {
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
  font-size: 0.82rem;
}

.linelist .tot {
  border-top: 1px solid var(--line);
  padding-top: 7px;
  font-weight: 600;
}

.note {
  font-size: 0.76rem;
  color: var(--ink-3);
  line-height: 1.55;
  margin: 12px 0 0;
}

/* allocation bar */

.alloc {
  margin-top: 4px;
}

.alloc-bar {
  display: flex;
  height: 30px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.alloc-seg {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
}

.alloc-seg.down {
  background: var(--forest);
}

.alloc-seg.stocks {
  background: var(--cobalt);
}

.alloc-outside {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--ink-2);
}

.alloc-outside .box {
  width: 30px;
  height: 12px;
  border-radius: 3px;
  border: 1px dashed var(--line-strong);
  background: repeating-linear-gradient(45deg, var(--surface-2), var(--surface-2) 4px, var(--surface) 4px, var(--surface) 8px);
}

/* chart */

.chart-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: var(--ink-2);
}

.legend span.item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
  flex: none;
}

.swatch.series-0 {
  background: var(--clay);
  border-radius: 999px;
}

.swatch.series-1 {
  background: var(--cobalt);
}

.chart-wrap {
  position: relative;
}

.chart-svg {
  display: block;
  overflow: visible;
}

.chart-grid {
  stroke: var(--line);
  stroke-width: 1;
}

.chart-axis {
  stroke: var(--line-strong);
  stroke-width: 1;
}

.chart-tick {
  fill: var(--ink-3);
  font-size: 11px;
  font-family: var(--mono);
}

.chart-axis-label {
  fill: var(--ink-3);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.chart-line {
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.chart-line.series-0,
.chart-end.series-0 {
  stroke: var(--clay);
}

.chart-line.series-1,
.chart-end.series-1 {
  stroke: var(--cobalt);
}

.chart-end.series-0 {
  fill: var(--clay);
}

.chart-end.series-1 {
  fill: var(--cobalt);
}

.chart-end-label {
  font-size: 11px;
  font-family: var(--mono);
  font-weight: 500;
}

.chart-end-label.series-0 {
  fill: var(--clay);
}

.chart-end-label.series-1 {
  fill: var(--cobalt);
}

.chart-crosshair {
  stroke: var(--line-strong);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}

.chart-dot {
  stroke: var(--surface);
  stroke-width: 2;
}

.chart-dot.series-0 {
  fill: var(--clay);
}

.chart-dot.series-1 {
  fill: var(--cobalt);
}

.chart-tip {
  position: absolute;
  top: 4px;
  width: 200px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 0.78rem;
  box-shadow: var(--shadow);
  pointer-events: none;
}

.chart-tip-year {
  font-weight: 700;
  margin-bottom: 5px;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-3);
}

.chart-tip-row {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 3px;
  color: var(--ink-2);
}

.chart-tip-row b {
  margin-left: auto;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

/* tables */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  max-height: 460px;
  overflow-y: auto;
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.8rem;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

th,
td {
  padding: 7px 10px;
  text-align: right;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}

th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  font-family: var(--sans);
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--ink-2);
  text-align: right;
  z-index: 1;
}

th:first-child,
td:first-child {
  text-align: left;
}

tbody tr:nth-child(even) td {
  background: color-mix(in srgb, var(--surface-2) 45%, transparent);
}

tfoot td {
  font-weight: 700;
  border-top: 2px solid var(--line-strong);
  background: var(--surface);
  position: sticky;
  bottom: 0;
}

/* buttons */

.btn {
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  padding: 9px 15px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.btn:hover {
  background: var(--surface-2);
}

.btn-primary {
  background: var(--forest);
  border-color: var(--forest);
  color: var(--forest-ink);
}

.btn-primary:hover {
  background: var(--forest-2);
}

.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

.actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.export-note {
  font-size: 0.76rem;
  color: var(--ink-3);
}

/* detail disclosures */

details.detail {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

details.detail > summary {
  cursor: pointer;
  padding: 15px 18px;
  font-family: var(--serif);
  font-size: 1.02rem;
  font-weight: 600;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

details.detail > summary::-webkit-details-marker {
  display: none;
}

details.detail > summary::after {
  content: "Show";
  font-family: var(--sans);
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--cobalt);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

details.detail[open] > summary::after {
  content: "Hide";
}

details.detail .detail-body {
  padding: 0 18px 18px;
}

.method dt {
  font-weight: 600;
  font-size: 0.86rem;
  margin-top: 12px;
}

.method dd {
  margin: 3px 0 0;
  font-size: 0.82rem;
  color: var(--ink-2);
  line-height: 1.55;
}

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

footer.site {
  border-top: 1px solid var(--line);
  background: var(--ground-2);
}

footer.site .inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 24px 20px 40px;
  font-size: 0.78rem;
  color: var(--ink-2);
  line-height: 1.6;
}

footer.site strong {
  color: var(--ink);
}

@media (max-width: 960px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .inputs {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .intro {
    padding-top: 30px;
  }

  .masthead-tag {
    border-left: none;
    padding-left: 0;
    flex-basis: 100%;
  }
}

@media (max-width: 560px) {
  .masthead-inner {
    padding: 9px 16px;
    gap: 8px 14px;
  }

  .masthead-nav {
    margin-left: 0;
    flex-basis: 100%;
  }

  .masthead-nav a {
    padding: 5px 9px;
  }

  .intro,
  .layout,
  footer.site .inner {
    padding-left: 16px;
    padding-right: 16px;
  }

  .group,
  .inputs {
    padding: 15px;
  }

  .stat-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .stat .v.hero {
    font-size: 1.55rem;
  }

  .pair {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* ------------------------------------------------------------ skin switch */

.skin-switch {
  font: inherit;
  font-size: 0.76rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 9px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.06);
  color: var(--forest-ink);
  cursor: pointer;
}

.skin-switch:hover {
  background: rgba(255, 255, 255, 0.14);
}

.skin-switch .dot {
  width: 22px;
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.25);
  position: relative;
  flex: none;
}

.skin-switch .dot::after {
  content: "";
  position: absolute;
  top: 1px;
  left: 1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--forest-ink);
  transition: transform 0.15s ease;
}

.skin-switch[aria-pressed="true"] .dot::after {
  transform: translateX(10px);
}

@media (prefers-reduced-motion: reduce) {
  .skin-switch .dot::after {
    transition: none;
  }
}

/* -------------------------------------------------- budget + allocation */

.alloc-seg.closing {
  background: var(--alloc-closing);
  color: var(--alloc-closing-ink);
}

.alloc-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 10px;
  font-size: 0.78rem;
  color: var(--ink-2);
}

.alloc-legend span.item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.alloc-legend .swatch.down {
  background: var(--forest);
}

.alloc-legend .swatch.closing {
  background: var(--alloc-closing);
}

.alloc-legend .swatch.stocks {
  background: var(--cobalt);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink-2);
}

.status-pill.ok {
  border-color: color-mix(in srgb, var(--good) 45%, transparent);
  color: var(--good);
}

.status-pill.short {
  background: var(--warn-bg);
  border-color: var(--warn-line);
  color: var(--warn-ink);
}

.gapbars {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-top: 4px;
}

.gapbar .top {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--ink-2);
  margin-bottom: 4px;
}

.gapbar .track {
  height: 14px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  overflow: hidden;
}

.gapbar .fill {
  height: 100%;
  background: var(--forest);
}

.gapbar.required .fill {
  background: var(--bad);
}

.gapbar .amt {
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
  color: var(--ink);
}

/* ------------------------------------------------------- estimate rows */

.field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.readout {
  font-size: 0.76rem;
  color: var(--ink-2);
  line-height: 1.5;
  margin: 2px 0 0;
}

.readout b {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.readout .basis {
  display: inline-block;
  margin-top: 2px;
}


/* ------------------------------------------- introduction / results notes */

.field-head.tight {
  justify-content: flex-start;
  position: relative;
}

/* The inputs panel scrolls, so an escaping bubble would be clipped: anchor it
   to the label row instead and let it use the panel's full content width. */
.field-head.tight .tip {
  position: static;
}

.field-head.tight .tip-bubble {
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  width: auto;
  max-width: none;
}

.results-note {
  margin: 0 0 14px;
  font-size: 0.76rem;
  line-height: 1.5;
  color: var(--ink-3);
  border-left: 2px solid var(--line-strong);
  padding-left: 10px;
}

/* ------------------------------------------------------------- tooltips */

.tip {
  position: relative;
  display: inline-flex;
  line-height: 0;
}

.tip-btn {
  width: 18px;
  height: 18px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--ink-2);
  font: inherit;
  font-size: 0.68rem;
  font-weight: 700;
  font-style: italic;
  line-height: 16px;
  text-align: center;
  cursor: help;
}

.tip-btn:hover,
.tip-btn[aria-expanded="true"] {
  border-color: var(--forest);
  background: var(--forest);
  color: var(--forest-ink);
}

.tip-btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.tip-bubble {
  position: absolute;
  z-index: 40;
  top: calc(100% + 8px);
  left: -8px;
  width: max-content;
  max-width: 260px;
  padding: 9px 11px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--ink-2);
  font-size: 0.76rem;
  font-style: normal;
  font-weight: 400;
  line-height: 1.5;
  text-align: left;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s ease;
}

.tip:hover .tip-bubble,
.tip.is-open .tip-bubble,
.tip:focus-within .tip-bubble {
  opacity: 1;
  visibility: visible;
}

@media (max-width: 480px) {
  .tip-bubble {
    left: auto;
    right: -4px;
    max-width: min(260px, 74vw);
  }
}

/* ------------------------------------------------- contribution sidebar */

/* Narrow and medium widths: the card follows the results column. */
.layout > .support-card {
  grid-column: 1 / -1;
  justify-self: stretch;
}

@media (min-width: 961px) {
  .layout > .support-card {
    grid-column: 2;
  }
}

/* Wide: a genuine right-margin column that never eats the calculator. */
@media (min-width: 1280px) {
  .layout {
    grid-template-columns: minmax(300px, 380px) minmax(0, 1fr) 212px;
  }

  .layout > .support-card {
    grid-column: 3;
    grid-row: 1;
    position: sticky;
    top: 62px;
    align-self: start;
    padding: 14px;
  }

  .layout > .support-card .support-grid {
    gap: 6px;
  }
}

/* Wider still: give the page back the width the sidebar took. */
@media (min-width: 1360px) {
  :root {
    --maxw: 1480px;
  }
}
