:root {
  color-scheme: light dark;
  --ground: #eef2f1; --card: #ffffff; --input: #f5f8f7; --ink: #12211f; --muted: #566864; --line: #dbe4e2;
  --brand: #17685f; --on-brand: #ffffff; --tint: #e1efec; --danger: #b3261e; --on-danger: #ffffff;
  --hero: #0f4842; --hero-ink: #ffffff; --hero-muted: #b9d8d2; --hero-line: #2c655e;
  --healthy: #11603c; --healthy-bg: #d9f2e3; --safe: #6d4800; --safe-bg: #fdeec6; --unhealthy: #98201a; --unhealthy-bg: #fde1df;
  --zone-unhealthy: #e5786f; --zone-safe: #f0c35b; --zone-healthy: #5cc48b;
  --shadow: 0 1px 2px rgb(16 40 36 / .05), 0 4px 16px rgb(16 40 36 / .05);
  --tabs: 64px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ground: #0c1413; --card: #162220; --input: #0f1a18; --ink: #e5efed; --muted: #9fb3af; --line: #2a3b38;
    --brand: #74cbbd; --on-brand: #06231f; --tint: #1b3531; --danger: #f2a39d; --on-danger: #3b0906;
    --hero: #123f39; --hero-ink: #f1faf8; --hero-muted: #a9cec7; --hero-line: #2f645c;
    --healthy: #8fddb3; --healthy-bg: #153a28; --safe: #f1cd7e; --safe-bg: #3c3013; --unhealthy: #f5aaa5; --unhealthy-bg: #46201e;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--ground); color: var(--ink); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) calc(var(--tabs) + 64px + env(safe-area-inset-bottom)) env(safe-area-inset-left); }
main { max-width: 600px; margin: 0 auto; padding: 12px 16px 16px; display: grid; gap: 14px; outline: none; }
main > * { min-width: 0; }
h1 { font-size: 21px; line-height: 1.3; letter-spacing: -.01em; margin: 0; }
h2 { font-size: 16px; line-height: 1.4; margin: 0; }
p { margin: 0; }
.muted, .hint { color: var(--muted); }
.hint { font-size: 14px; font-weight: 400; }
.center { text-align: center; }
.error { color: var(--unhealthy); }
.warning { padding: 10px 12px; border-radius: 10px; background: var(--safe-bg); color: var(--safe); font-size: 15px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; }
.card { background: var(--card); border-radius: 18px; padding: 18px; display: grid; gap: 16px; box-shadow: var(--shadow); }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Tab atas dan toggle PPN */
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 14px; background: var(--line); position: sticky; top: calc(env(safe-area-inset-top) + 8px); z-index: 2; }
.modes button { min-height: 44px; padding: 0 8px; border-radius: 10px; color: var(--muted); }
.modes [aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgb(0 0 0 / .14); }
.field-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.switch { display: flex; gap: 2px; padding: 3px; border-radius: 12px; background: var(--ground); }
.switch button { min-height: 44px; padding: 0 12px; border-radius: 9px; font-size: 14px; color: var(--muted); }
.switch [aria-pressed="true"] { background: var(--brand); color: var(--on-brand); }

/* Kartu hasil */
.hero { background: var(--hero); color: var(--hero-ink); border-radius: 22px; padding: 20px; display: grid; gap: 8px; }
.hero-label { font-size: 15px; color: var(--hero-muted); }
.hero-value { font-size: clamp(30px, 10vw, 42px); line-height: 1.15; font-weight: 700; letter-spacing: -.025em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.hero-note { color: var(--hero-muted); }
.hero-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; font-size: 18px; font-variant-numeric: tabular-nums; }
.gauge { position: relative; height: 10px; margin: 10px 8px 6px; border-radius: 5px;
  background: linear-gradient(to right, var(--zone-unhealthy) var(--safe-at), var(--zone-safe) var(--safe-at) var(--healthy-at), var(--zone-healthy) var(--healthy-at)); }
.gauge-mark { position: absolute; top: -5px; left: var(--mark-at); width: 20px; height: 20px; margin-left: -10px; border-radius: 50%; background: #fff; border: 5px solid var(--hero); box-shadow: 0 0 0 2px #fff; }
.chips { display: flex; gap: 8px; overflow-x: auto; margin: 8px -20px -4px; padding: 4px 20px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button { flex: none; min-height: 44px; padding: 0 14px; border-radius: 22px; border-color: var(--hero-line); color: var(--hero-ink); font-size: 15px; }
.chips [aria-pressed="true"] { background: #fff; border-color: #fff; color: #0f4842; }
.hero :focus-visible { outline-color: #fff; }

/* Isian */
.field { display: grid; gap: 6px; min-width: 0; align-content: end; }
.label { font-size: 15px; font-weight: 600; }
.pair, .trio { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); }
.trio { gap: 10px; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); }
.trio .label { font-size: 14px; letter-spacing: -.01em; }
/* 16px atau lebih mencegah iPhone memperbesar layar saat mengetik. */
input { width: 100%; min-width: 0; min-height: 50px; padding: 0 14px; font: inherit; font-size: 17px; color: var(--ink); background: var(--input); border: 1px solid var(--line); border-radius: 12px; }
input:focus { outline: 2px solid var(--brand); outline-offset: -1px; background: var(--card); }
input::placeholder { color: var(--muted); opacity: .7; }
.affix { position: relative; display: block; }
.affix input { padding-left: 44px; font-variant-numeric: tabular-nums; font-weight: 600; }
.affix.percent input { padding: 0 30px 0 14px; }
.unit { position: absolute; left: 14px; top: 0; line-height: 50px; color: var(--muted); pointer-events: none; z-index: 1; }
.percent .unit { left: auto; right: 12px; }

button { font: inherit; min-height: 50px; padding: 0 18px; border-radius: 12px; border: 1px solid transparent; font-weight: 600; cursor: pointer; touch-action: manipulation; color: var(--ink); background: none; -webkit-tap-highlight-color: transparent; }
button:disabled { opacity: .45; cursor: default; }
button:active:not(:disabled) { filter: brightness(.94); }
button.primary { background: var(--brand); color: var(--on-brand); }
button.secondary { background: var(--tint); color: var(--brand); display: flex; align-items: center; justify-content: center; gap: 8px; }
button.quiet { display: flex; align-items: center; gap: 6px; padding: 0 8px; color: var(--brand); }
button.danger { background: var(--danger); color: var(--on-danger); }
button.text { padding: 0 10px; color: var(--brand); }
button.danger-text { color: var(--unhealthy); }
button.icon-button { width: 48px; padding: 0; display: grid; place-items: center; color: var(--muted); align-self: end; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
main:focus-visible { outline: none; }

/* Skenario */
.scenarios { display: grid; gap: 16px; }
.scenario { display: grid; gap: 10px; }
.scenario + .scenario { border-top: 1px solid var(--line); padding-top: 16px; }
.scenario-inputs { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; }
.scenario-result { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-variant-numeric: tabular-nums; }
.badge { display: inline-block; justify-self: start; padding: 3px 10px; border-radius: 12px; font-size: 14px; line-height: 1.4; font-weight: 600; white-space: nowrap; }
.badge.healthy { color: var(--healthy); background: var(--healthy-bg); }
.badge.safe { color: var(--safe); background: var(--safe-bg); }
.badge.unhealthy { color: var(--unhealthy); background: var(--unhealthy-bg); }
.range { display: grid; grid-template-columns: 112px 1fr; align-items: center; gap: 12px; }
.range > div { display: grid; font-variant-numeric: tabular-nums; }

/* Rincian */
details.card { padding: 0; gap: 0; }
summary { padding: 16px 18px; min-height: 54px; font-weight: 600; cursor: pointer; border-radius: 18px; }
.detail-body { display: grid; gap: 14px; padding: 0 18px 18px; }
dl { margin: 0; }
dl > div { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; padding: 9px 0; }
dl > div + div { border-top: 1px solid var(--line); }
dt { color: var(--muted); }
dd { margin: 0 0 0 auto; font-variant-numeric: tabular-nums; }
.total dt, .total dd { color: var(--ink); font-weight: 700; }

/* Tersimpan */
.actions, .stack, .list { display: grid; gap: 12px; }
.search { background: var(--card); }
.empty { justify-items: start; }
.record { padding: 0; gap: 0; overflow: hidden; }
.record-open { display: grid; gap: 6px; padding: 16px 18px 8px; text-align: left; font-weight: 400; overflow-wrap: anywhere; }
.record-open > strong { font-size: 17px; }
.record-open .muted { font-size: 14px; }
.record-open:focus-visible { outline-offset: -3px; }
.record-result { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-variant-numeric: tabular-nums; }
.record-actions { display: flex; justify-content: flex-end; padding: 0 8px 6px; }

/* Navigasi bawah */
.tabs, .summary { position: fixed; left: 0; right: 0; background: var(--card); border-top: 1px solid var(--line); z-index: 3; }
.tabs { bottom: 0; display: grid; grid-template-columns: repeat(3, 1fr); padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
.tabs button { min-height: var(--tabs); border-radius: 0; padding: 0 4px; color: var(--muted); font-size: 14px; display: grid; justify-items: center; align-content: center; gap: 2px; }
.tabs [aria-current] { color: var(--brand); }
.tabs [aria-current] svg { fill: var(--tint); }
.tabs :focus-visible { outline-offset: -3px; }
.summary { bottom: calc(var(--tabs) + env(safe-area-inset-bottom)); display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 2px 14px; min-height: 48px; padding: 8px 16px; font-variant-numeric: tabular-nums; }
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(var(--tabs) + 64px + env(safe-area-inset-bottom)); margin: 0 auto; max-width: 480px; padding: 14px 18px; border-radius: 14px; background: var(--ink); color: var(--ground); z-index: 4; }
.banner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; max-width: 568px; margin: 12px auto 0; width: calc(100% - 32px); padding: 12px 18px; border-radius: 16px; background: var(--tint); }
.banner p { flex: 1 1 160px; }
dialog { width: min(400px, calc(100% - 32px)); border: 0; border-radius: 22px; padding: 22px; background: var(--card); color: var(--ink); }
dialog::backdrop { background: rgb(0 0 0 / .5); }
dialog[open] { display: grid; gap: 12px; }
dialog p { overflow-wrap: anywhere; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 8px; }

/* Halaman pasang */
.installing { padding-bottom: env(safe-area-inset-bottom); }
.install-head { display: grid; justify-items: center; gap: 12px; padding: 32px 0 12px; text-align: center; }
ol { margin: 0; padding-left: 24px; display: grid; gap: 8px; }
@media (max-width: 345px) { .card { padding: 16px; } .switch, .switch button { flex: 1; } }
