/* Calculator components — inputs, results, charts, compare mode */

.calc-layout { display: grid; gap: var(--s4); grid-template-columns: minmax(0, 1fr); }

.calc-panel {
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--s3);
  box-shadow: var(--shadow-card);
}

.calc-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: var(--s2); flex-wrap: wrap; margin-bottom: var(--s3);
}
.calc-head h2 { font-size: 1.25rem; margin: 0; }
.calc-head .btn-ghost { flex-shrink: 0; }

/* Field rows */
.field-grid { display: grid; gap: var(--s2); grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: .875rem; font-weight: 500; color: var(--text-strong); }
.field .hint { font-size: .75rem; color: var(--text-muted); }

.input-shell {
  display: flex; align-items: center;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--bg-surface); overflow: hidden;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.input-shell:focus-within {
  border-color: var(--c-primary-mid);
  box-shadow: 0 0 0 3px var(--c-primary-tint);
}
.input-shell .prefix, .input-shell .suffix {
  padding: 0 12px; font-size: .875rem; color: var(--text-muted);
  background: var(--bg-sunken); align-self: stretch; display: grid; place-items: center;
  flex-shrink: 0;
}
.input-shell input, .input-shell select {
  flex: 1; min-width: 0; height: 48px; padding: 0 12px;
  border: 0; background: transparent; color: var(--text-strong);
  font-family: var(--font-mono); font-size: 1rem;
}
.input-shell select { font-family: var(--font-body); cursor: pointer; }
.input-shell input:focus, .input-shell select:focus { outline: none; }
.input-shell.invalid { border-color: var(--c-error); }
.input-shell.invalid:focus-within { box-shadow: 0 0 0 3px var(--c-error-tint); }

.field-error { font-size: .8125rem; color: var(--c-error); min-height: 0; }
.field-error:empty { display: none; }

/* Segmented toggle */
.segmented { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; }
.segmented button {
  min-height: 40px; padding: 0 var(--s2); border: 0; cursor: pointer;
  background: var(--bg-surface); color: var(--text-body);
  font-family: inherit; font-size: .8125rem; font-weight: 500;
}
.segmented button + button { border-left: 1px solid var(--line-strong); }
.segmented button[aria-pressed="true"] { background: var(--c-primary-mid); color: #FFFFFF; }

/* Quick-pick chips */
.chips { display: flex; flex-wrap: wrap; gap: var(--s1); }
.chips button {
  min-height: 40px; padding: 0 var(--s2);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--bg-surface); color: var(--text-body);
  font-family: inherit; font-size: .875rem; cursor: pointer;
}
.chips button:hover { border-color: var(--c-primary-mid); color: var(--c-primary-mid); }
.chips button[aria-pressed="true"] { background: var(--c-primary-tint); border-color: var(--c-primary-mid); color: var(--text-on-tint); }

.calc-actions { display: flex; gap: var(--s2); flex-wrap: wrap; margin-top: var(--s3); }
.calc-actions .btn-primary { flex: 1 1 200px; }

/* Results */
.results[hidden] { display: none; }
.results {
  margin-top: var(--s3);
  animation: reveal .3s ease both;
}
@keyframes reveal {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.result-primary {
  background: var(--c-primary-tint);
  border-left: 4px solid var(--c-primary);
  padding: var(--s3);
  margin-bottom: var(--s2);
}
.result-primary .label { font-size: .875rem; color: var(--text-on-tint); margin: 0 0 4px; }
.result-primary .value {
  font-family: var(--font-mono); font-size: 2.25rem; font-weight: 600;
  color: var(--text-on-tint); line-height: 1.15; margin: 0;
  white-space: nowrap; overflow: hidden; text-overflow: clip;
}
.result-primary .sub { font-size: .875rem; color: var(--text-on-tint); margin: 6px 0 0; opacity: .85; }

.result-stats { display: grid; gap: var(--s1); grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stat { background: var(--bg-sunken); border-radius: var(--radius); padding: var(--s2); }
.stat .label { font-size: .8125rem; color: var(--text-muted); margin: 0 0 2px; }
.stat .value { font-family: var(--font-mono); font-size: 1.25rem; font-weight: 600; color: var(--text-strong); margin: 0; white-space: nowrap; overflow: hidden; }
.stat { min-width: 0; }

/* Chart */
.chart-box { margin-top: var(--s3); }
.chart-box canvas { width: 100%; height: auto; display: block; }
.chart-legend { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s1); font-size: .8125rem; color: var(--text-muted); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* Working / formula panel */
.working {
  margin-top: var(--s3); border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg-surface);
}
.working summary {
  cursor: pointer; padding: var(--s2) var(--s3); font-weight: 600; font-size: .9375rem;
  color: var(--text-strong); list-style: none;
  display: flex; justify-content: space-between; align-items: center; gap: var(--s2);
}
.working summary::-webkit-details-marker { display: none; }
.working summary::after { content: "+"; color: var(--c-primary-mid); font-size: 1.25rem; }
.working[open] summary::after { content: "\2212"; }
.working .body { padding: 0 var(--s3) var(--s3); }
.working code, .working .eq {
  display: block; font-family: var(--font-mono); font-size: .875rem;
  background: var(--bg-sunken); padding: var(--s2); border-radius: var(--radius-sm);
  margin-bottom: var(--s1); overflow-x: auto; color: var(--text-strong);
}

/* Data tables */
.table-scroll { overflow-x: auto; margin-top: var(--s3); border: 1px solid var(--line); border-radius: var(--radius); }
table.data { width: 100%; border-collapse: collapse; font-size: .875rem; }
table.data th, table.data td { padding: 10px var(--s2); text-align: right; white-space: nowrap; }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data thead th {
  background: var(--bg-sunken); color: var(--text-strong); font-weight: 600;
  position: sticky; top: 0; font-size: .8125rem;
}
table.data td { border-top: 1px solid var(--line); font-family: var(--font-mono); }
table.data td:first-child { font-family: var(--font-body); }
table.data tbody tr:hover { background: var(--bg-sunken); }
.table-tools { display: flex; gap: var(--s1); flex-wrap: wrap; margin-top: var(--s2); }

/* Compare mode */
.compare-grid { display: grid; gap: var(--s2); grid-template-columns: 1fr 1fr; }
.compare-col { border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s2); background: var(--bg-sunken); }
.compare-col h3 { font-size: .9375rem; margin-bottom: var(--s2); color: var(--text-muted); }
.compare-col .field-grid { grid-template-columns: 1fr; }
.compare-col-b { border-top: 3px solid var(--c-accent); }
.compare-col-a { border-top: 3px solid var(--c-primary-mid); }
.diff-good { color: var(--c-success); font-weight: 600; }
.diff-bad { color: var(--c-error); font-weight: 600; }

@media (max-width: 640px) {
  .compare-grid { grid-template-columns: 1fr; }
}

/* Sticky mobile result bar */
.sticky-result {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
  background: var(--c-primary); color: #FFFFFF;
  padding: 10px var(--s2);
  display: none; align-items: center; justify-content: space-between; gap: var(--s2);
  box-shadow: 0 -2px 12px rgba(31, 35, 64, .18);
}
.sticky-result .label { font-size: .75rem; opacity: .85; margin: 0; }
.sticky-result > div { min-width: 0; flex: 1; }
.sticky-result .value { font-family: var(--font-mono); font-size: 1.125rem; font-weight: 600; margin: 0; white-space: nowrap; overflow: hidden; }
.sticky-result button {
  background: rgba(255,255,255,.16); color: #FFFFFF; border: 0;
  border-radius: var(--radius-sm); min-height: 36px; padding: 0 12px;
  font-family: inherit; font-size: .8125rem; cursor: pointer; flex-shrink: 0;
}
@media (max-width: 767px) {
  .sticky-result.show { display: flex; }
  body.has-sticky { padding-bottom: 68px; }
}

/* Gauge / scale visual for health tools */
.gauge { margin-top: var(--s3); }
.gauge-track { display: flex; height: 14px; border-radius: 7px; overflow: hidden; }
.gauge-track i { display: block; height: 100%; }
.gauge-marker { position: relative; height: 22px; }
.gauge-marker span {
  position: absolute; transform: translateX(-50%);
  font-size: .75rem; color: var(--text-strong); font-weight: 600; white-space: nowrap;
  top: 2px;
}
.gauge-marker span::before {
  content: ""; position: absolute; top: -10px; left: 50%; transform: translateX(-50%);
  border-left: 5px solid transparent; border-right: 5px solid transparent;
  border-bottom: 6px solid var(--text-strong);
}
.gauge-labels { display: flex; justify-content: space-between; font-size: .6875rem; color: var(--text-muted); margin-top: 4px; }

.verdict { display: inline-block; padding: 6px 14px; border-radius: 999px; font-size: .875rem; font-weight: 600; }
.verdict-good { background: var(--c-success-tint); color: var(--c-success); }
.verdict-warn { background: var(--c-warn-tint); color: var(--c-warn); }
.verdict-bad { background: var(--c-error-tint); color: var(--c-error); }


/* Two-column calculator layout.
   Inputs sit in one card on the left, results in a card on the right that
   stays in view while scrolling. Wide tables (the EMI schedule) live in a
   .results-wide block that spans both columns underneath, so no column of
   figures is ever squeezed or cut off. */
.calc-wrap { max-width: 1140px; }
.calc-wrap > p, .calc-wrap > h1 { max-width: 72ch; }
.calc-inputs { container-type: inline-size; min-width: 0; }
.results-placeholder { display: none; }
.results-wide { margin-top: var(--s3); min-width: 0; }
.results-wide[hidden] { display: none; }
.results-wide > h3:first-child { margin-top: 0; }

@media (min-width: 900px) {
  .calc-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: var(--s3);
    align-items: start;
    background: transparent;
    border: 0;
    box-shadow: none;
    padding: 0;
  }
  .calc-inputs,
  .calc-panel > .results,
  .results-placeholder,
  .results-wide {
    background: var(--bg-surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: var(--s3);
    box-shadow: var(--shadow-card);
  }
  .calc-inputs { grid-column: 1; grid-row: 1; }
  .calc-panel > .results,
  .results-placeholder {
    grid-column: 2; grid-row: 1;
    margin-top: 0;
    position: sticky; top: 88px;
  }
  .results-wide { grid-column: 1 / -1; grid-row: 2; margin-top: var(--s3); }
  .calc-panel:has(> .results[hidden]) > .results-placeholder {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-align: center; min-height: 260px; gap: var(--s1);
    color: var(--text-muted); border-style: dashed; background: var(--bg-sunken); box-shadow: none;
  }
  .results-placeholder svg { width: 40px; height: 40px; color: var(--c-primary-light); }
  .results-placeholder p { margin: 0; max-width: 28ch; font-size: .9375rem; }
  .results-placeholder strong { color: var(--text-strong); font-weight: 600; }
  .calc-panel > .results > .result-primary:first-child { margin-top: 0; }
}

/* Inside a narrow input card, side-by-side groups stack instead of cramming. */
@container (max-width: 520px) {
  .compare-grid { grid-template-columns: 1fr; }
  .exp-row { grid-template-columns: 1fr 1fr; }
  .exp-row .btn { grid-column: 1 / -1; }
}
@container (max-width: 340px) {
  .exp-row { grid-template-columns: 1fr; }
}

/* Auto-generated range slider paired with each numeric field. */
.slider-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.slider-row input[type="range"] {
  flex: 1; height: 4px; -webkit-appearance: none; appearance: none;
  background: var(--line-strong); border-radius: 2px; cursor: pointer; min-width: 0;
}
.slider-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: var(--c-primary-mid); cursor: pointer; border: 0;
}
.slider-row input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--c-primary-mid); cursor: pointer; border: 0;
}
.slider-ends {
  display: flex; justify-content: space-between;
  font-size: .6875rem; color: var(--text-muted); margin-top: 4px;
}

/* Proportion bar under the headline result. */
.prop-bar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; margin: var(--s2) 0; }
.prop-bar i { display: block; height: 100%; }

.result-rows { margin-top: var(--s2); }
.result-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s2);
  padding: 11px 0; border-bottom: 1px solid var(--line); font-size: .9375rem;
}
.result-row:last-child { border-bottom: 0; }
.result-row .k { display: inline-flex; align-items: center; gap: 9px; color: var(--text-body); }
.result-row .k i { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.result-row .v { font-family: var(--font-mono); font-weight: 600; color: var(--text-strong); }

/* What-if sensitivity strip. */
.whatif { margin-top: var(--s3); border-top: 1px solid var(--line); padding-top: var(--s2); }
.whatif h3, .whatif h4 { font-size: .8125rem; color: var(--text-muted); font-weight: 600;
  letter-spacing: .05em; text-transform: uppercase; margin-bottom: var(--s1); }
.whatif-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.whatif-item { background: var(--bg-sunken); border-radius: var(--radius-sm); padding: 10px 12px; }
.whatif-item .lbl { font-size: .75rem; color: var(--text-muted); display: block; margin-bottom: 2px; }
.whatif-item { min-width: 0; }
.whatif-item .val { font-family: var(--font-mono); font-size: .9375rem; font-weight: 600; color: var(--text-strong); display: block; white-space: nowrap; overflow: hidden; }
.whatif-item .delta { font-size: .75rem; margin-left: 5px; }
.delta-up { color: var(--c-error); }
.delta-down { color: var(--c-success); }

/* Experience calculator rows. */
.exp-row {
  display: grid; gap: var(--s1); align-items: end;
  grid-template-columns: 1fr 1fr auto; margin-bottom: var(--s2);
}
.exp-row .btn { min-height: 48px; }
.exp-list { margin-top: var(--s3); }
.exp-item {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s2);
  padding: 12px var(--s2); background: var(--bg-sunken);
  border-radius: var(--radius-sm); margin-bottom: 8px; font-size: .9375rem;
}
.exp-item .n {
  display: grid; place-items: center; width: 26px; height: 26px; flex-shrink: 0;
  border-radius: 7px; background: var(--c-primary-tint); color: var(--text-on-tint);
  font-size: .75rem; font-weight: 600;
}
.exp-item .meta { flex: 1; min-width: 0; }
.exp-item .meta strong { display: block; color: var(--text-strong); font-weight: 500; }
.exp-item .meta span { font-size: .8125rem; color: var(--text-muted); }
.exp-item .dur { font-family: var(--font-mono); font-weight: 600; color: var(--text-strong); white-space: nowrap; }
.exp-item button {
  background: transparent; border: 0; cursor: pointer; color: var(--text-muted);
  font-size: 1.25rem; line-height: 1; padding: 4px 8px; border-radius: 6px;
}
.exp-item button:hover { color: var(--c-error); background: var(--c-error-tint); }
.exp-empty { color: var(--text-muted); font-size: .9375rem; padding: var(--s3); text-align: center; }

.checkline { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; }
.checkline input { width: 19px; height: 19px; accent-color: var(--c-primary-mid); cursor: pointer; }

/* Unit dropdown inside an input box. */
.input-shell select.unit-select,
.input-shell select.period-select {
  flex: 0 0 auto; width: auto; max-width: 60%; min-width: max-content;
  border-left: 1px solid var(--line); background: var(--bg-sunken);
  padding: 0 28px 0 12px; font-size: .875rem; font-weight: 500; color: var(--text-strong);
}
.input-shell input.ftin-part { flex: 1 1 0; border-left: 1px solid var(--line); }
.input-shell .ftin-part[hidden] { display: none; }
.input-shell .suffix.ftin-part { padding: 0 8px; }
.input-shell input::placeholder { color: var(--text-muted); opacity: .7; font-family: var(--font-body); }

/* Correct band widths for a 15 to 40 BMI scale. */
.gauge-labels.abs { position: relative; height: 16px; display: block; }
.gauge-labels.abs span { position: absolute; transform: translateX(-50%); }
.gauge-labels.abs span:first-child { transform: none; }
.gauge-labels.abs span:last-child { transform: translateX(-100%); }

@media (max-width: 480px) {
  .result-primary .value { font-size: 1.875rem; }
  .table-scroll table.data th, .table-scroll table.data td { padding: 9px 12px; }
}

/* When a result has to wrap, it breaks only at spaces, never inside a figure. */
.result-primary .value, .stat .value, .whatif-item .val { overflow-wrap: normal; word-break: keep-all; }

/* "Next steps" links under a result, pre-filled with the visitor's numbers. */
.next-steps { margin-top: var(--s3); border-top: 1px solid var(--line); padding-top: var(--s2); }
.next-steps h3, .next-steps h4 { font-size: .8125rem; color: var(--text-muted); font-weight: 600;
  letter-spacing: .05em; text-transform: uppercase; margin-bottom: var(--s1); }
.next-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.next-grid a {
  display: block; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--bg-surface); color: var(--text-strong); font-weight: 600; font-size: .9375rem;
}
.next-grid a:hover { border-color: var(--c-primary-mid); text-decoration: none; }
.next-grid a span { display: block; font-weight: 400; font-size: .8125rem; color: var(--text-muted); margin-top: 2px; }
#r-meaning p:last-child { margin-bottom: 0; }
.calc-inputs > .hint { font-size: .8125rem; color: var(--text-muted); line-height: 1.55; }

/* A data table too wide for its box is shown as stacked cards instead of
   scrolling sideways, so no amount is ever hidden. utils.js adds .stacked
   only when the table would not fit. */
table.data.stacked thead { display: none; }
table.data.stacked, table.data.stacked tbody, table.data.stacked tr, table.data.stacked td { display: block; width: 100%; }
table.data.stacked tr { border-top: 1px solid var(--line); padding: 10px 0; }
table.data.stacked tbody tr:first-child { border-top: 0; }
table.data.stacked td {
  border: 0; padding: 3px var(--s2); text-align: right; white-space: normal;
  display: flex; justify-content: space-between; align-items: baseline; gap: var(--s2);
}
table.data.stacked td::before {
  content: attr(data-label); font-family: var(--font-body); font-size: .8125rem;
  color: var(--text-muted); text-align: left; white-space: nowrap;
}
table.data.stacked td:first-child { font-weight: 600; color: var(--text-strong); justify-content: flex-start; }
table.data.stacked td:first-child::before { content: none; }
table.data.stacked td:first-child:empty { display: none; }
.table-scroll:has(table.stacked) { overflow-x: visible; }
table.data.stacked tbody tr:hover { background: transparent; }

/* Inside a narrow box the number keeps at least 5 characters of room. */
.input-shell input { min-width: 5ch; }

/* Percentage page: no separate results box, so the three mini calculators
   use the full width, side by side on desktop. */
@media (min-width: 900px) {
  body[data-calc="percentage"] .calc-panel { grid-template-columns: 1fr; }
  body[data-calc="percentage"] .calc-inputs {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); align-items: stretch;
  }
  body[data-calc="percentage"] .calc-inputs > .calc-head { grid-column: 1 / -1; margin-bottom: 0; }
  body[data-calc="percentage"] .calc-inputs > .compare-col { margin-bottom: 0 !important; }
  body[data-calc="percentage"] .compare-col .field-grid { grid-template-columns: 1fr; }
}
.compare-col > .hint { margin: -8px 0 var(--s2); font-size: .8125rem; color: var(--text-muted); }

/* Boxes that carry a "per year / per month" dropdown take a full row, so
   both the amount and the dropdown text always fit. */
.field-grid > .field:has(.period-select) { grid-column: 1 / -1; }

/* ---------- Results band: secondary result sections, full width ----------
   Sits after the calculator panel (not inside it) so the sticky result card
   can never slide over it. */
.calc-panel:has(> .results[hidden]) + .results-band { display: none; }
.results-band {
  margin-top: var(--s3); min-width: 0;
  background: var(--bg-surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: var(--s3); box-shadow: var(--shadow-card);
}
.results-band > .callout { margin: 0; }
.results-band > .next-steps,
.results-band > .whatif { margin-top: 0; border-top: 0; padding-top: 0; }
.results-band > * + * { margin-top: var(--s3); }
.results-band .whatif-grid { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
@media (min-width: 900px) {
  .results-band {
    display: grid; gap: var(--s3) var(--s4);
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  }
  .results-band > * + * { margin-top: 0; }
  .results-band > .table-tools,
  .results-band > .callout,
  .results-band > .working { grid-column: 1 / -1; }
  /* When the two cards are close in height they share one height, so there
     is no ragged gap. JS adds .even only then; when one card is much taller,
     the result card keeps following you down the page instead. */
  .calc-panel.even:has(> .results:not([hidden])) { align-items: stretch; }
  .calc-panel.even:has(> .results:not([hidden])) > .results { position: static; }
  .results-band > .table-tools { margin-top: calc(var(--s1) * -1); }
}

/* ---------- Article with sidebar ---------- */
.article-aside { display: none; }
@media (min-width: 1100px) {
  .article-layout {
    display: grid; grid-template-columns: minmax(0, 1fr) 300px;
    gap: var(--s6); align-items: start;
  }
  .article-layout > .prose { max-width: none; min-width: 0; }
  .article-aside {
    display: flex; flex-direction: column; gap: var(--s3);
    align-self: stretch; margin-top: var(--s6);
  }
  .aside-sticky { position: sticky; top: 88px; display: flex; flex-direction: column; gap: var(--s3); }
}
@media (min-width: 1100px) and (max-height: 720px) {
  .aside-sticky { position: static; }
}
.aside-card {
  background: var(--bg-surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: var(--s2) var(--s3); box-shadow: var(--shadow-card);
}
.aside-card h2 {
  font-size: .75rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-muted); margin: 0 0 var(--s1);
}
.aside-card ul { list-style: none; margin: 0; padding: 0; }
.aside-card li { margin: 0; }
.aside-card a {
  display: block; padding: 6px 10px; margin: 0 -10px; border-radius: var(--radius-sm);
  font-size: .9rem; color: var(--text-body); text-decoration: none; line-height: 1.4;
}
.aside-card a:hover { background: var(--bg-sunken); color: var(--text-strong); text-decoration: none; }
.article-toc a { border-left: 2px solid transparent; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin-left: -12px; padding-left: 10px; }
.article-toc a.active { border-left-color: var(--c-primary-mid); color: var(--text-on-tint); font-weight: 600; background: var(--c-primary-tint); }
.aside-tools a { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.aside-tools a::after { content: "\2192"; color: var(--c-primary-light); }
.article-aside .ad-sidebar { width: 300px; min-height: 250px; margin: 0; }
.prose h2[id] { scroll-margin-top: 88px; }

/* ---------- More calculators (internal links, visible on every screen) ---------- */
.more-calcs ul { list-style: none; margin: var(--s2) 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.more-calcs li { margin: 0; }
.more-calcs a {
  display: inline-block; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--bg-surface); color: var(--text-body); font-size: .9rem; line-height: 1.4; text-decoration: none;
}
.more-calcs a:hover { background: var(--bg-sunken); color: var(--text-strong); text-decoration: none; }
.more-calcs a.more-calcs-all { color: var(--text-on-tint); background: var(--c-primary-tint); border-color: transparent; font-weight: 600; }

/* ---------- Contact page ---------- */
.contact-wrap { max-width: 1140px; }
.contact-lead { max-width: 68ch; color: var(--text-body); font-size: 1.0625rem; margin-bottom: var(--s4); }
.contact-grid { display: grid; gap: var(--s3); grid-template-columns: minmax(0, 1fr); align-items: start; margin-bottom: var(--s6); }
@media (min-width: 900px) { .contact-grid { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); } }
.contact-card {
  background: var(--bg-surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: var(--s3); box-shadow: var(--shadow-card);
}
.contact-card > h2 { font-size: 1.25rem; margin: 0 0 var(--s2); }
.contact-card .optional { color: var(--text-muted); font-weight: 400; }
.textarea-shell { align-items: stretch; }
.textarea-shell textarea {
  flex: 1; border: 0; background: transparent; color: var(--text-strong);
  font: 1rem/1.55 var(--font-body); padding: 12px 14px; resize: vertical; min-height: 160px; outline: none;
}
.textarea-shell textarea::placeholder { color: var(--text-muted); opacity: .8; }
.contact-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); margin-top: var(--s3); }
.contact-actions .btn { min-width: 170px; }
.contact-actions .btn[disabled] { opacity: .7; cursor: progress; }
.form-status { margin: 0; font-size: .9375rem; }
.form-status.is-ok { color: var(--c-success); font-weight: 500; }
.form-status.is-error { color: var(--c-error); }
.contact-side { display: flex; flex-direction: column; gap: var(--s2); }
.side-item { display: flex; gap: var(--s2); align-items: flex-start; padding: var(--s2) var(--s3); }
.side-item h2 { font-size: 1rem; margin: 2px 0 4px; }
.side-item p, .side-item ol { margin: 0; font-size: .9375rem; color: var(--text-body); }
.side-item ol { padding-left: 1.2em; }
.side-item li { margin-bottom: 2px; }
.side-item .side-tip { margin-top: var(--s1); font-size: .8125rem; color: var(--text-muted); }
.side-ico {
  width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0;
  display: grid; place-items: center; background: var(--c-primary-tint); color: var(--c-primary-mid);
}
.side-ico svg { width: 20px; height: 20px; }

/* ---------- GPA / CGPA rows ---------- */
.gpa-tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); width: 100%; margin-bottom: var(--s2); }
.gpa-tabs button { min-width: 0; padding-inline: 6px; white-space: nowrap; }
@container (max-width: 480px) {
  .gpa-tabs { grid-template-columns: 1fr 1fr; }
  .gpa-tabs button:nth-child(3) { border-left: 0; }
  .gpa-tabs button:nth-child(n+3) { border-top: 1px solid var(--line-strong); }
}
.gpa-panel[hidden] { display: none; }
.gpa-panel > .hint { margin: 0 0 var(--s2); }
.gpa-head, .gpa-row {
  display: grid; gap: 8px; align-items: center;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, .9fr) minmax(0, 1.1fr) 36px;
}
.gpa-head-cgpa, .gpa-row-cgpa { grid-template-columns: minmax(0, .9fr) minmax(0, 1fr) minmax(0, 1fr) 36px; }
.gpa-head { font-size: .75rem; font-weight: 600; color: var(--text-muted); letter-spacing: .03em; margin-bottom: 6px; }
.gpa-rows { display: flex; flex-direction: column; gap: 8px; }
.gpa-row .input-shell input, .gpa-row .input-shell select { min-width: 0; width: 100%; }
.gpa-row .sem-label { font-size: .875rem; font-weight: 500; color: var(--text-strong); }
.gpa-del {
  width: 36px; height: 36px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: transparent; color: var(--text-muted); font-size: 1.25rem; line-height: 1; cursor: pointer;
}
.gpa-del:hover { color: var(--c-error); background: var(--c-error-tint); border-color: transparent; }
.gpa-add { margin-top: var(--s2); }
@container (max-width: 420px) {
  .gpa-head { display: none; }
  .gpa-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 36px; }
  .gpa-row > .input-shell:first-child { grid-column: 1 / -1; }
  .gpa-row-cgpa { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 36px; }
  .gpa-row-cgpa .sem-label { grid-column: 1 / -1; }
}
.field .optional { color: var(--text-muted); font-weight: 400; }
.gpa-row .g-name { font-family: var(--font-body); }
body[data-calc="zakat"] .result-stats { grid-template-columns: 1fr 1fr; }
