:root {
  color-scheme: light;
  --paper: #F4F6F2;
  --panel: #FFFFFF;
  --ink: #1E2A2D;
  --muted: #566467;
  --line: #D6DDD6;
  --field: #A9B6B0;
  --accent: #1C5D63;
  --below: #B23A2E; --below-bg: #FBE7E3;
  --some: #8F5600;  --some-bg: #FDEFD8;
  --most: #4F6E17;  --most-bg: #EDF3DD;
  --strong: #23703E; --strong-bg: #E1F1E6;
}
[data-tone="below"] { --tone: var(--below); --tone-bg: var(--below-bg); }
[data-tone="some"] { --tone: var(--some); --tone-bg: var(--some-bg); }
[data-tone="most"] { --tone: var(--most); --tone-bg: var(--most-bg); }
[data-tone="strong"] { --tone: var(--strong); --tone-bg: var(--strong-bg); }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.6 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); text-underline-offset: 2px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: clamp(2rem, 7vw, 2.75rem); font-weight: 760; margin: 0 0 8px; }
h2 { font-size: 1.5rem; font-weight: 700; margin: 40px 0 12px; }
h3 { font-size: 1.15rem; font-weight: 680; margin: 28px 0 8px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.top { border-bottom: 1px solid var(--line); background: var(--panel); }
.brand { display: inline-flex; align-items: center; gap: 10px; min-height: 52px; font-weight: 680; color: var(--ink); text-decoration: none; }
.brand img { border-radius: 6px; }

.intro { padding: 28px 0 20px; max-width: 62ch; }
.lede { font-size: 1.125rem; color: var(--muted); margin: 0; }
.note { background: var(--some-bg); padding: 10px 14px; border-radius: 8px; }

/* Calculator: one column on phones, inputs | results from 900px. */
.calc { display: grid; gap: 16px; }
.pill {
  position: sticky; top: 0; z-index: 2; margin: 0 -16px 12px;
  padding: 10px 16px; background: var(--paper); border-bottom: 1px solid var(--line);
  font-weight: 600; display: flex; align-items: center; gap: 10px;
}
.pill b { font-size: 1.35rem; font-variant-numeric: tabular-nums; }
@media (min-width: 900px) {
  .calc { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
  .pill { display: none; }
}

fieldset { margin: 0 0 16px; padding: 8px 16px 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); min-width: 0; }
fieldset:last-child { margin-bottom: 0; }
legend { padding: 0 6px; margin-left: -6px; font-weight: 700; font-size: 1.05rem; }
.field { display: grid; gap: 6px; margin-top: 14px; min-width: 0; }
legend + .field, legend + .row > .field:first-child, legend + .row > .field:nth-child(2) { margin-top: 2px; }
.field > label { font-weight: 560; }
.row { display: grid; gap: 0 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; }
.pair { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.affix {
  display: flex; align-items: center; min-height: 48px;
  border: 1px solid var(--field); border-radius: 8px; background: var(--panel);
}
.affix:focus-within { outline: 3px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.affix span { padding: 0 12px; color: var(--muted); }
.affix span:first-child { padding-right: 0; }
.affix input:first-child { padding-left: 12px; }
input, select { font: inherit; font-size: 1.0625rem; color: var(--ink); }
.affix input {
  flex: 1; min-width: 0; width: 100%; height: 46px; padding: 0 8px;
  border: 0; background: transparent; font-variant-numeric: tabular-nums;
}
.affix input:focus { outline: none; }
select {
  min-height: 48px; padding: 0 36px 0 12px; border: 1px solid var(--field); border-radius: 8px;
  -webkit-appearance: none; appearance: none; background-color: var(--panel);
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 19px) 50%, calc(100% - 14px) 50%; background-size: 5px 5px; background-repeat: no-repeat;
}
.hint { margin: 6px 0 0; font-size: 0.9rem; color: var(--muted); }
.check { display: flex; align-items: center; gap: 10px; min-height: 48px; margin-top: 10px; font-weight: 560; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 0; accent-color: var(--accent); }

/* Results */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px 16px 20px; }
.card + .card { margin-top: 16px; }
.card h2 { font-size: 1.1rem; margin: 0 0 6px; }
.result { border-top: 6px solid var(--tone, var(--line)); }
.ratio { margin: 0; display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px; }
.big { font-size: clamp(3.5rem, 16vw, 4.75rem); font-weight: 760; line-height: 1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.result[data-tone=""] .big { color: var(--field); }
.badge {
  display: inline-block; padding: 4px 12px; border-radius: 999px;
  color: var(--tone, var(--muted)); background: var(--tone-bg, var(--paper));
  font-weight: 680; font-size: 0.95rem;
}

.gauge { position: relative; margin: 22px 0 34px; }
.track { display: grid; grid-template-columns: 20fr 16fr 4fr 20fr; gap: 2px; height: 12px; border-radius: 6px; overflow: hidden; }
.track span:nth-child(1) { background: var(--below); }
.track span:nth-child(2) { background: #D99A2B; }
.track span:nth-child(3) { background: #8DAA45; }
.track span:nth-child(4) { background: var(--strong); }
.marker {
  position: absolute; top: -7px; width: 6px; height: 26px; margin-left: -3px;
  background: var(--ink); border-radius: 3px; box-shadow: 0 0 0 2px var(--panel);
  transition: left 0.2s ease-out;
}
.tick { position: absolute; top: 18px; font-size: 0.8rem; color: var(--muted); transform: translateX(-50%); font-variant-numeric: tabular-nums; }
.tick.end { transform: translateX(-100%); padding-right: 2px; }
.tick.start { transform: none; padding-left: 2px; }
@media (prefers-reduced-motion: reduce) { .marker { transition: none; } }

.tiers { list-style: none; margin: 0 0 18px; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; font-size: 0.875rem; }
.tiers li { padding: 6px 10px; border-radius: 8px; color: var(--muted); border: 1px solid transparent; }
.tiers li span { display: block; color: var(--ink); }
.tiers li::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; background: var(--tone); }
.tiers li[aria-current] { background: var(--tone-bg); border-color: var(--tone); color: var(--ink); font-weight: 650; }

.breakdown { display: grid; grid-template-columns: 1fr auto; margin: 0; font-variant-numeric: tabular-nums; }
.breakdown dt, .breakdown dd { margin: 0; padding: 7px 0; border-bottom: 1px solid var(--line); }
.breakdown dd { text-align: right; }
.breakdown .total { font-weight: 700; }
.small { font-size: 0.875rem; color: var(--muted); margin: 10px 0 0; }
.share { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-top: 16px; }
.btn {
  min-height: 48px; padding: 0 18px; border: 0; border-radius: 8px; cursor: pointer;
  background: var(--accent); color: #fff; font: inherit; font-weight: 650;
}
.btn:hover { background: #154A4F; }
#share-status { color: var(--muted); font-size: 0.9rem; }

.maxloan { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.maxloan th, .maxloan td { padding: 8px 0; border-bottom: 1px solid var(--line); text-align: left; }
.maxloan td { text-align: right; font-weight: 650; }
.maxloan thead th { font-size: 0.875rem; color: var(--muted); font-weight: 560; }
.maxloan thead th:last-child { text-align: right; }
.needed { margin: 14px 0 0; }
.needed strong { font-variant-numeric: tabular-nums; }

/* Reserved for ads later, so adding them shifts nothing. Empty until then. */
.ad-slot { min-height: 250px; margin: 16px 0; }

/* Article */
.guide, .faq, .disclaimer, .prose { max-width: 68ch; }
.guide { margin-top: 24px; }
.guide ul { padding-left: 1.2em; }
.guide li { margin-bottom: 10px; }
.formula {
  margin: 18px 0; padding: 14px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  font-size: 1.15rem; font-weight: 650; font-variant-numeric: tabular-nums;
}
.table-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
.guide table { border-collapse: collapse; min-width: 520px; width: 100%; font-size: 0.95rem; }
.guide th, .guide td { padding: 10px 12px 10px 0; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.guide thead th { border-bottom: 2px solid var(--ink); }
.guide tbody th { font-weight: 650; }
.faq h2 { margin-top: 8px; }
.disclaimer { margin: 32px 0 48px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); font-size: 0.95rem; }
.disclaimer p { margin: 0; }

.prose { padding-top: 28px; padding-bottom: 48px; }
.prose h1 { font-size: clamp(1.9rem, 6vw, 2.4rem); }
.prose ul { padding-left: 1.2em; }

.foot { border-top: 1px solid var(--line); background: var(--panel); color: var(--muted); font-size: 0.95rem; padding: 18px 0 28px; }
.foot nav { display: flex; flex-wrap: wrap; gap: 4px 20px; }
.foot nav a { display: inline-flex; align-items: center; min-height: 44px; }
.foot p { margin: 8px 0 0; }
