:root {
  color-scheme: dark;
  --bg: #000;
  --panel: #111216;
  --panel-2: #17191f;
  --stroke: rgba(255, 255, 255, .18);
  --text: #f7f8fb;
  --muted: #a7abb6;
  --blue: #1688ff;
  --cyan: #20e2f4;
  --green: #25d67d;
  --error: #ff6961;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: radial-gradient(circle at 50% -15%, #10284a 0, #05070b 32%, #000 70%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button { color: inherit; }

.app-shell {
  width: min(100%, 500px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: calc(12px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom));
}

.app-header {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.app-icon { border-radius: 10px; box-shadow: 0 0 18px rgba(22, 136, 255, .2); }
h1 { margin: 0; font-size: clamp(1.8rem, 7.4vw, 2.2rem); line-height: 1; letter-spacing: -.04em; }

.calculator { display: grid; gap: 10px; }
.input-panel, .result-panel {
  border: 1px solid var(--stroke);
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(255,255,255,.075), rgba(255,255,255,.035));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.035), 0 12px 32px rgba(0,0,0,.22);
}
.input-panel { padding: 10px; display: grid; gap: 7px; }

.field { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 5px 8px; }
.field label { min-width: 0; font-size: .88rem; line-height: 1.15; }
.tax { color: var(--muted); font-size: .78rem; }
.control { display: grid; grid-template-columns: 92px 48px; align-items: center; gap: 8px; }
.control input {
  width: 92px;
  min-height: 36px;
  padding: 6px 8px;
  border: 1px solid #fff;
  border-radius: 7px;
  outline: 0;
  background: #090a0d;
  color: #fff;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  appearance: textfield;
}
.control input::-webkit-inner-spin-button { appearance: none; }
.control input:focus { border-color: var(--cyan); box-shadow: 0 0 0 2px rgba(32,226,244,.18); }
.control span { color: #d9dbe1; font-size: .82rem; white-space: nowrap; }
.error { grid-column: 1 / -1; margin: -2px 0 0; min-height: 0; color: var(--error); font-size: .72rem; text-align: right; }
.error:empty { display: none; }
.field:has(.error:not(:empty)) input { border-color: var(--error); }

.mode-switch { display: grid; grid-template-columns: 1fr 1fr; padding: 3px; gap: 3px; border-radius: 9px; background: #090a0d; }
.mode-switch button { min-height: 34px; padding: 5px 6px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: .78rem; cursor: pointer; }
.mode-switch button[aria-selected="true"] { background: #353842; color: #fff; box-shadow: 0 1px 3px #000; }

.result-panel { padding: 10px; min-height: 205px; }
.empty-result { min-height: 183px; display: grid; place-content: center; justify-items: center; gap: 2px; color: var(--muted); }
.empty-result .bolt { color: var(--blue); font-size: 2rem; line-height: 1; }
.empty-result strong { color: #fff; font-size: 1.35rem; }
.empty-result small { font-size: .75rem; }
.result-headline { margin: 0 0 8px; text-align: center; font-size: 1.18rem; font-weight: 500; }
.result-headline strong { font-size: 1.3rem; }
.battery { display: flex; width: 100%; height: 17px; overflow: hidden; border-radius: 6px; background: rgba(255,255,255,.12); }
.battery span { display: block; height: 100%; transition: width .18s ease; }
#batteryStart { background: var(--blue); }
#batteryGain { background: var(--green); }
.batteryEmpty { flex: 1; }
.legend { display: flex; justify-content: space-between; margin-top: 5px; color: var(--muted); font-size: .7rem; }
.legend span { display: inline-flex; align-items: center; gap: 4px; }
.legend i { width: 8px; height: 8px; border-radius: 2px; }
.legend b { color: #fff; }
.start-dot { background: var(--blue); }
.gain-dot { background: var(--green); }
.adjusted { margin: 5px 0 0; color: #ffae42; text-align: center; font-size: .75rem; }
.metrics { display: grid; margin: 8px 0 0; gap: 3px; }
.metrics div { display: grid; grid-template-columns: 1fr auto; align-items: baseline; }
.metrics dt { color: var(--muted); font-size: .8rem; }
.metrics dd { margin: 0; font-size: .88rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.disclaimer { margin: 9px 3px 0; color: #777c87; font-size: .68rem; line-height: 1.35; }
.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; }
[hidden] { display: none !important; }

@media (min-width: 760px) {
  .app-shell { width: min(100%, 920px); padding: 32px 24px; }
  .calculator { grid-template-columns: minmax(360px, .9fr) minmax(390px, 1.1fr); align-items: start; }
  .result-panel { min-height: 100%; }
  .empty-result { min-height: 330px; }
  .result-headline { margin-top: 16px; font-size: 1.45rem; }
  .result-headline strong { font-size: 1.65rem; }
  .battery { height: 22px; margin-top: 18px; }
  .metrics { margin-top: 22px; gap: 10px; }
  .metrics dt, .metrics dd { font-size: 1rem; }
}

@media (max-height: 760px) and (max-width: 759px) {
  .app-shell { padding-top: calc(7px + env(safe-area-inset-top)); }
  .app-header { margin-bottom: 7px; }
  .app-icon { width: 34px; height: 34px; }
  h1 { font-size: 1.72rem; }
  .calculator { gap: 7px; }
  .input-panel { padding: 8px 10px; gap: 5px; }
  .result-panel { min-height: 184px; padding: 8px 10px; }
  .empty-result { min-height: 166px; }
  .disclaimer { margin-top: 6px; }
}
