:root {
  color-scheme: dark;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  color: #f1f2f4;
  background: #101217;
  --panel: #171a21;
  --border: #30343f;
  --muted: #a6abba;
  --accent: #ffba78;
  --error: #ff9f9f;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: radial-gradient(ellipse at 15% 5%, #1d1a1c 0, transparent 31rem);
  min-height: 100vh;
  line-height: 1.5;
}

.shell { width: min(100% - 3rem, 66rem); margin-inline: auto; }
.masthead { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-block: 1.25rem; border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: .65rem; font-weight: 690; white-space: nowrap; }
.mark { display: grid; place-items: center; width: 2.15rem; height: 2.15rem; border-radius: 9px; background: #35291f; border: 1px solid #684932; color: var(--accent); font-size: 1.25rem; }
.day { color: var(--muted); font-size: .875rem; font-variant-numeric: tabular-nums; text-align: right; }

h1, h2, p, dl, dd, fieldset { margin: 0; }
h1 { font-size: clamp(2rem, 5vw, 3.3rem); letter-spacing: -.055em; font-weight: 690; line-height: 1.08; margin: 2.4rem 0 1.5rem; }
h2 { font-size: 1.075rem; line-height: 1.3; letter-spacing: -.015em; font-weight: 660; }

.dashboard { display: grid; grid-template-columns: 1.28fr 1fr; gap: 1rem; }
.card { min-width: 0; padding: clamp(1.15rem, 3vw, 1.65rem); border: 1px solid var(--border); border-radius: 18px; background: var(--panel); }
.card-heading { display: flex; justify-content: space-between; align-items: center; gap: .6rem; }
.buy { border-color: #584030; background: linear-gradient(135deg, #211a17, #1b181a 56%, #181a21); }
.tier-badge { padding: .2rem .6rem; border: 1px solid #745035; border-radius: 6px; color: var(--accent); font-size: .875rem; font-weight: 650; white-space: nowrap; }

#buy-amount {
  display: block;
  margin-top: .65rem;
  color: #ffe3c9;
  font-size: clamp(2.7rem, 8vw, 5.65rem);
  font-weight: 700;
  letter-spacing: -.075em;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

#buy-amount, .score, .breakdown dd, td, input, .estimate { font-variant-numeric: tabular-nums; }
.muted, .estimate, .breakdown dt { color: var(--muted); }
.estimate, .buy-note { margin-top: .55rem; }
.estimate { color: #e9cdb4; }
.buy-note:empty { display: none; }

.breakdown { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; padding-top: 1rem; margin-top: 1.2rem; border-top: 1px solid #48403e; }
.breakdown dt, .hint, .error { font-size: .875rem; }
.breakdown dd { margin-top: .2rem; font-size: 1.2rem; font-weight: 660; overflow-wrap: anywhere; }

.budget-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin-top: 1rem; }
.field { min-width: 0; }
.field label { display: block; margin-bottom: .35rem; color: #dbdde6; font-size: .875rem; }
.input-shell { display: flex; align-items: center; gap: .55rem; min-height: 2.75rem; padding: .55rem .7rem; background: #11141b; border: 1px solid #667085; border-radius: 8px; }
.input-shell span { color: var(--muted); }
.input-shell:focus-within { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.input-shell:has([aria-invalid="true"]) { border-color: var(--error); }
input { width: 100%; min-width: 0; padding: 0; background: transparent; border: 0; outline: 0; color: inherit; font: inherit; }
input::placeholder { color: #939bab; opacity: 1; }
.hint, .error { margin-top: .6rem; }
.error { color: var(--error); }

details { margin-top: .9rem; padding-top: .75rem; border-top: 1px solid var(--border); }
details .field { margin-top: .75rem; }
summary { width: fit-content; cursor: pointer; color: #e2e4ea; font-size: .875rem; list-style: none; }
summary::-webkit-details-marker { display: none; }
summary::before { display: inline-block; width: 1rem; content: "+"; color: var(--accent); }
details[open] summary::before { content: "−"; }

.source-picker { display: inline-flex; max-width: 100%; gap: .2rem; padding: .2rem; margin-block: .95rem .8rem; border: 1px solid var(--border); border-radius: 9px; background: #10131a; }
.source-picker input, .visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; clip-path: inset(50%); overflow: hidden; white-space: nowrap; }
.source-picker label { padding: .4rem .7rem; border-radius: 6px; color: var(--muted); font-size: .875rem; cursor: pointer; }
.source-picker input:checked + label { background: #35303a; color: #fff0e4; }
.source-picker input:focus-visible + label, a:focus-visible, button:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.score-line { display: flex; align-items: center; justify-content: space-between; gap: .8rem; }
.score { font-size: 2.35rem; font-weight: 680; line-height: 1.08; letter-spacing: -.05em; }
.omega-input { max-width: 13rem; }

button { min-height: 2.5rem; padding: .4rem .8rem; border: 1px solid #667085; border-radius: 7px; background: #20242e; color: inherit; font: inherit; font-size: .875rem; cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
button:disabled { color: var(--muted); cursor: default; }

.scale { margin-top: 1rem; }
.scale-track { position: relative; height: .32rem; margin-inline: .18rem; border-radius: 1rem; background: linear-gradient(90deg, #f2a15d, #94755d 48%, #626d86); }
.scale-track span { position: absolute; left: var(--score); top: 50%; translate: -50% -50%; width: .72rem; height: .72rem; border-radius: 50%; background: #fff0e1; box-shadow: 0 0 0 2px #171a21; }
.scale-labels { display: flex; justify-content: space-between; margin-top: .35rem; font-size: .875rem; color: var(--muted); }

table { width: 100%; border-collapse: collapse; margin-top: .65rem; text-align: left; }
th, td { border-bottom: 1px solid var(--border); padding: .48rem .5rem; font-size: .875rem; }
th { color: var(--muted); font-weight: 560; }
th:last-child, td:last-child { text-align: right; overflow-wrap: anywhere; }
tr[aria-current="true"] td { background: #352a26; color: #ffdbb9; font-weight: 660; }
tr[aria-current="true"] td:first-child { box-shadow: inset 2px 0 var(--accent); }

footer { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: .65rem 1rem; padding-block: 1.2rem 2rem; color: var(--muted); font-size: .875rem; }
nav { display: flex; flex-wrap: wrap; gap: .45rem 1rem; }
a { text-decoration-color: #9d7557; text-underline-offset: .18em; color: #efc6a3; }
a:hover { color: #ffe6d0; }

@media (max-width: 45rem) {
  .shell { width: calc(100% - 2rem); }
  .dashboard { grid-template-columns: 1fr; }
  h1 { margin-top: 1.7rem; }
}

@media (max-width: 23rem) {
  .budget-inputs { grid-template-columns: 1fr; }
  th, td { padding-inline: .3rem; }
}
