:root {
  color-scheme: light;
  --bg: #f3f5f4;
  --paper: #fff;
  --ink: #15221c;
  --muted: #50625a;
  --line: #dce4df;
  --control: #b5c3bb;
  --rail: #edf1ee;
  --result-bg: #eff6f0;
  --tone: #176344;
  --tone-ink: #fff;
  --positive: #126141;
  --secondary: #b36e18;
  --ring: #137255;
  --error: #a12436;
  --warning: #804312;
  --radius: 14px;
  --panel-pad: 30px;
  --shadow: 0 16px 40px #1831220a;
  font-family: Inter, system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; padding: clamp(14px, 7vh, 68px) 16px; }
:where(h1, h2, h3, p, dl, dd, fieldset) { margin: 0; }
:where(button, input, textarea) { font: inherit; }
:where(button, summary) { cursor: pointer; }
:where(button, input, summary, textarea):focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 3px;
}
.shell {
  width: min(100%, 680px);
  margin-inline: auto;
  padding: var(--panel-pad);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 6px);
  box-shadow: var(--shadow);
}
.intro {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 20px;
}
h1 { font-size: clamp(1.32rem, 3.8vw, 1.8rem); line-height: 1.1; letter-spacing: -.043em; text-wrap: balance; }
.intro p { margin-top: 6px; font-size: .83rem; color: var(--muted); }
h2 { font-size: .96rem; line-height: 1.3; font-weight: 720; letter-spacing: -.012em; }
h3 { font-size: .86rem; font-weight: 670; line-height: 1.3; }
.modes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 3px;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--rail);
}
.modes button {
  min-height: 44px;
  padding: 6px 5px;
  border: 1px solid transparent;
  border-radius: calc(var(--radius) - 3px);
  background: transparent;
  color: var(--muted);
  font-weight: 650;
  font-size: .87rem;
  transition: color .16s, background-color .16s, border-color .16s;
}
.modes button:hover { color: var(--ink); }
.modes button[aria-pressed="true"] {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--line);
  box-shadow: 0 1px 2px #10101012;
}
.workspace { display: grid; gap: 17px; margin-top: 20px; }
.inputs h2, .extra h2, .diagnostics h2 { margin-bottom: 12px; }
.input-grid, .extra-grid { display: grid; gap: 12px; }
fieldset { min-width: 0; padding: 0; border: 0; }
legend, .field { font-size: .83rem; line-height: 1.28; font-weight: 620; }
legend { padding: 0; margin-bottom: 5px; }
.field > span:first-child:not(.sr-only) { display: block; margin-bottom: 5px; }
.field { display: block; min-width: 0; }
.pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.control {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 4px;
  padding: 0 11px;
  border: 1px solid var(--control);
  border-radius: var(--radius);
  background: var(--field-bg, var(--paper));
  transition: border-color .16s, box-shadow .16s;
}
.control:focus-within { border-color: var(--ring); box-shadow: 0 0 0 1px var(--ring); }
.control:has([aria-invalid=true]) { border-color: var(--error); }
.control input {
  min-width: 0;
  width: 100%;
  padding: 6px 0;
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.control input:focus-visible { outline: none; }
.control > span { color: var(--muted); font-size: .8rem; white-space: nowrap; }
.error { display: block; margin-top: 4px; color: var(--error); }
.result { min-width: 0; }
.result-main {
  padding: 15px 18px;
  border-radius: var(--radius);
  background: var(--result-bg);
  border: 1px solid var(--line);
}
.result-main p { margin-top: 7px; color: var(--muted); font-size: .83rem; }
.result-main small { display: block; margin-top: 3px; color: var(--muted); font-size: .76rem; line-height: 1.35; }
#estimated {
  display: block;
  font-size: clamp(2.32rem, 6.5vw, 3.35rem);
  color: var(--positive);
  font-weight: 735;
  line-height: 1.06;
  letter-spacing: -.052em;
  margin-block: 2px 3px;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.actions { display: flex; align-items: stretch; gap: 8px; }
.button {
  display: inline-flex;
  min-height: 44px;
  gap: 7px;
  align-items: center;
  justify-content: center;
  padding: 6px 13px;
  border: 1px solid var(--control);
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  font-size: .82rem;
  font-weight: 660;
  transition: background-color .16s, border-color .16s, color .16s;
}
.button:hover { border-color: var(--ring); background: var(--rail); }
.button svg { flex: none; width: 16px; height: 16px; }
.button:not(.account) svg { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.button.copy { background: var(--tone); color: var(--tone-ink); border-color: var(--tone); }
.button.copy:hover { filter: brightness(1.12); }
.button:disabled { opacity: .55; cursor: default; }
.account { min-width: 44px; }
.extra, .diagnostics { padding-top: 16px; border-top: 1px solid var(--line); }
.between { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.range-field > span.between { display: flex; margin-bottom: 0; }
.range-field input { width: 100%; margin: 0; height: 44px; accent-color: var(--ring); cursor: pointer; }
.value, .between :is(dd, strong) { text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.advanced-results { padding: 9px 2px 0; }
.metrics > div { min-height: 33px; padding-block: 6px; font-size: .83rem; }
.metrics > div + div { border-top: 1px solid var(--line); }
.metrics dt { color: var(--muted); }
.metrics dd { font-weight: 660; }
#difference { color: var(--positive); }
.comparison { margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--line); }
.bar-row { margin-top: 7px; color: var(--muted); font-size: .78rem; }
.bar-row strong { color: var(--ink); }
.track { background: var(--rail); height: 7px; margin-top: 4px; border-radius: 6px; overflow: hidden; }
.bar { width: 100%; height: 100%; border-radius: inherit; transform: scaleX(var(--scale, 0)); transform-origin: left; transition: transform .3s ease-out; }
.public-bar { background: var(--secondary); }
.estimated-bar { background: var(--positive); }
.diagnostic-body { padding: 1px 12px 3px; border: 1px solid var(--line); border-radius: var(--radius); }
.diagnostic-item { padding: 10px 0; font-size: .83rem; }
.diagnostic-item + .diagnostic-item { border-top: 1px solid var(--line); }
.diagnostic-item p, .diagnostic-body details p { color: var(--muted); margin-top: 5px; font-size: .81rem; line-height: 1.45; }
.status { color: var(--positive); font-size: .75rem; text-align: right; }
.status.warn { color: var(--warning); }
.diagnostic-body details { border-top: 1px solid var(--line); }
.diagnostic-body details p { margin: 0 0 8px; }
summary { padding: 12px 0; min-height: 44px; font-size: .83rem; font-weight: 660; }
dialog { width: min(420px, calc(100% - 28px)); padding: 18px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--paper); color: var(--ink); }
dialog::backdrop { background: #17221e72; }
dialog p { margin: 10px 0; color: var(--muted); }
textarea { width: 100%; margin: 10px 0; padding: 8px; border: 1px solid var(--control); background: var(--paper); color: var(--ink); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
[data-mode="advanced"] :is(.extra, .advanced-results, .diagnostics) { animation: reveal .22s ease-out both; }
@keyframes reveal { from { opacity: .6; transform: translateY(3px); } to { opacity: 1; transform: translateY(0); } }
@media (max-width: 520px) {
  :root { --panel-pad: 14px; }
  body { padding: 9px; }
  .intro { margin-bottom: 11px; }
  .account { padding-inline: 10px; }
  .account span { display: none; }
  .workspace { margin-top: 12px; gap: 12px; }
  .inputs h2, .extra h2, .diagnostics h2 { margin-bottom: 8px; }
  .input-grid, .extra-grid { gap: 8px; }
  .result-main { padding: 10px 12px; }
  .result-main p { margin-top: 5px; }
}
@media (max-height: 730px) and (min-width: 521px) {
  :root { --panel-pad: 21px; }
  body { padding-block: 12px; }
  .intro { margin-bottom: 14px; }
  .workspace { margin-top: 14px; gap: 12px; }
  .result-main { padding-block: 11px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
#difference.negative { color: var(--error); }
@media (max-width: 360px) {
  :root { --panel-pad: 11px; }
  body { padding: 6px; }
  .workspace { gap: 10px; }
}


.actions { flex-wrap: wrap; }
.actions .save { background: var(--tone); color: var(--tone-ink); border-color: var(--tone); }
.actions .save:hover { filter: brightness(1.12); }
.actions .copy { background: transparent; color: var(--ink); border-color: var(--control); }
.action-feedback:not(:empty) { margin-top: 7px; font-size: .79rem; color: var(--muted); }
.account-mark { fill: none; stroke: currentColor; stroke-width: 1.75; }
.account-dialog { width: min(600px, calc(100% - 24px)); max-height: min(85vh, 680px); overflow: auto; }
.account-dialog h3 { margin-top: 17px; }
.dialog-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; }
a.button { text-decoration: none; }
a.button[aria-disabled="true"] { opacity: .55; cursor: default; }
.google-start svg { width: 18px; height: 18px; }
.account-email { overflow-wrap: anywhere; }
.history-list { padding: 0; margin: 0; list-style: none; }
.history-row { display: flex; justify-content: space-between; gap: 8px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); }
.history-row strong { font-size: .87rem; }
.history-row small { display: block; margin-top: 3px; color: var(--muted); font-size: .75rem; line-height: 1.45; }
.history-row .button { flex: none; }
#history-more { margin-top: 9px; }
.privacy-link { color: var(--muted); font-size: .79rem; padding: 8px 0; }
dialog .auth-hint:empty, dialog #history-feedback:empty { display: none; }
.account-dialog .account-email { margin-top: 4px; }
@media (max-width: 430px) {
  .actions .button { padding-inline: 9px; }
}
@media (max-width: 390px) {
  .actions .button svg { display: none; }
  .actions { gap: 6px; }
}
@media (max-width: 430px) {
  .actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .actions .button { padding-inline: 3px; font-size: .77rem; }
}
