/* Zapp Partner: "Ledger" — warm paper / ink, one money-green accent. */

:root {
  --bg: #f4f2ea;
  --surface: #fffefa;
  --surface-2: #eeebe1;
  --text: #121612;
  --muted: #566058;
  --line: #dcd8ca;
  --accent: #0e6b3c;
  --accent-press: #0a5630;
  --accent-text: #0b5a32;
  --on-accent: #ffffff;
  --accent-soft: #dcefe2;
  --in: #0e6b3c;
  --in-soft: #dcefe2;
  --out: #8f5200;
  --out-soft: #f8e8c9;
  --cash: #a53f2a;
  --cash-soft: #f6dfd7;
  --bad: #b3261e;
  --bad-soft: #fbe3df;
  --scrim: rgba(10, 14, 10, 0.5);
  --shadow: 0 1px 2px rgba(18, 22, 18, 0.06), 0 10px 30px -12px rgba(18, 22, 18, 0.25);
  --r-sm: 10px;
  --r: 14px;
  --r-lg: 20px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --spring: cubic-bezier(0.34, 1.4, 0.64, 1);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0c100d;
  --surface: #141a16;
  --surface-2: #1b231e;
  --text: #edf2ee;
  --muted: #99a79e;
  --line: #27312b;
  --accent: #3ddc84;
  --accent-press: #66e6a0;
  --accent-text: #5fe39a;
  --on-accent: #05140b;
  --accent-soft: #14301f;
  --in: #4be08e;
  --in-soft: #14301f;
  --out: #f0b84e;
  --out-soft: #33290f;
  --cash: #f59a7d;
  --cash-soft: #3a1f17;
  --bad: #ff8a7e;
  --bad-soft: #3b1a16;
  --scrim: rgba(0, 0, 0, 0.62);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 14px 34px -14px rgba(0, 0, 0, 0.7);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #0c100d;
    --surface: #141a16;
    --surface-2: #1b231e;
    --text: #edf2ee;
    --muted: #99a79e;
    --line: #27312b;
    --accent: #3ddc84;
    --accent-press: #66e6a0;
    --accent-text: #5fe39a;
    --on-accent: #05140b;
    --accent-soft: #14301f;
    --in: #4be08e;
    --in-soft: #14301f;
    --out: #f0b84e;
    --out-soft: #33290f;
    --cash: #f59a7d;
    --cash-soft: #3a1f17;
    --bad: #ff8a7e;
    --bad-soft: #3b1a16;
    --scrim: rgba(0, 0, 0, 0.62);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 14px 34px -14px rgba(0, 0, 0, 0.7);
    color-scheme: dark;
  }
}

/* ===== Base ===== */
* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { scrollbar-color: var(--line) transparent; }

body {
  margin: 0;
  min-height: 100dvh;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

body.modal-open { overflow: hidden; }
::selection { background: var(--accent); color: var(--on-accent); }
h1, h2, h3, p, dl, dd { margin: 0; }
h1, h2 { text-wrap: balance; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
input { caret-color: var(--accent); }
a { text-underline-offset: 3px; }

.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;
}

.skip {
  position: absolute; left: 12px; top: -48px; z-index: 90;
  background: var(--surface); color: var(--text); padding: 10px 12px; border-radius: var(--r-sm);
}
.skip:focus { top: 12px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app {
  position: relative;
  width: min(520px, 100%);
  margin: 0 auto;
  min-height: 100dvh;
  background: var(--bg);
}

@media (min-width: 560px) {
  .app { border-inline: 1px solid var(--line); }
}

/* ===== Pages ===== */
.page { display: none; }
.page.active {
  display: block;
  min-height: 100dvh;
  padding-bottom: 28px;
  animation: pageIn 0.22s var(--ease) both;
}
body.has-nav .page.active { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }

@keyframes pageIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ===== Sign in ===== */
#loginPage.active {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100dvh;
  padding: calc(32px + env(safe-area-inset-top)) 24px calc(28px + env(safe-area-inset-bottom));
}

.brand-mark {
  width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center;
  background: var(--accent); color: var(--on-accent);
}
.brand-mark .icon { width: 26px; height: 26px; stroke-width: 2; }

.login-brand { margin: 22px 0 26px; }
.login-brand h1 { font-size: 2.25rem; line-height: 1.05; letter-spacing: -0.035em; font-weight: 750; }
.login-brand p { margin-top: 10px; color: var(--muted); max-width: 30ch; }

.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 22px 20px 20px; }
.login-card h2 { font-size: 1.125rem; letter-spacing: -0.02em; margin-bottom: 4px; }


.hint { color: var(--muted); font-size: 0.875rem; margin-bottom: 16px; }

/* ===== Forms ===== */
.input-group { margin-bottom: 14px; }
.input-group label { display: block; font-size: 0.8125rem; font-weight: 650; margin-bottom: 6px; }

.input-group input {
  width: 100%; min-height: 50px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: var(--r); background: var(--bg); font-size: 1rem;
  transition: border-color 0.18s, box-shadow 0.18s;
}
.input-group input::placeholder { color: var(--muted); opacity: 0.75; }
.input-group input:focus-visible {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 28%, transparent);
}
.input-group input[aria-invalid="true"] { border-color: var(--bad); }

.field { position: relative; }
.field input { padding-right: 54px; }
.field-btn {
  position: absolute; top: 50%; right: 4px; width: 44px; height: 44px; display: grid; place-items: center;
  transform: translateY(-50%); border: 0; border-radius: var(--r-sm); background: transparent; color: var(--muted);
}

.error-msg { background: var(--bad-soft); color: var(--bad); border-radius: var(--r); padding: 10px 12px; font-size: 0.875rem; margin-bottom: 12px; }
.error-msg:not([hidden]) { animation: shake 0.32s var(--ease); }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  55% { transform: translateX(4px); }
  80% { transform: translateX(-2px); }
}

.pin-dots { display: flex; gap: 8px; margin: -4px 2px 14px; }
.pin-dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--line); transition: background 0.15s, transform 0.25s var(--spring); }
.pin-dots i.on { background: var(--accent); transform: scale(1.2); }

/* ===== Buttons ===== */
.btn {
  width: 100%; min-height: 50px; border: 0; border-radius: var(--r);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 0 16px; font-size: 1rem; font-weight: 700; text-decoration: none;
  transition: transform 0.15s var(--ease), background 0.18s, border-color 0.18s, opacity 0.18s;
}
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:disabled { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }
.btn-secondary { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn-ghost { background: transparent; color: var(--text); }
.btn-danger { background: var(--bad); color: var(--on-accent); }
.btn-danger-ghost { background: var(--bad-soft); color: var(--bad); }
.btn .icon { width: 20px; height: 20px; }

.btn-spin { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.icon { width: 22px; height: 22px; display: block; }

.icon-btn {
  width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: var(--r);
  background: transparent; color: var(--text); transition: background 0.18s, transform 0.15s var(--ease);
}
.icon-btn:active { transform: scale(0.92); }
.icon-btn:disabled { opacity: 0.5; cursor: progress; }
.icon-btn.spinning .icon { animation: spin 0.8s linear infinite; }

.text-btn { border: 0; background: transparent; color: var(--accent-text); font-weight: 700; font-size: 0.875rem; min-height: 44px; padding: 0 2px; }

/* ===== Header ===== */
.header { position: sticky; top: 0; z-index: 20; background: var(--bg); padding: calc(8px + env(safe-area-inset-top)) 10px 8px 20px; }
.header-row { min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.header h1 { font-size: 1.5rem; line-height: 1.15; letter-spacing: -0.03em; font-weight: 750; }
.header h1:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
.header-sub { margin-top: 2px; color: var(--muted); font-size: 0.875rem; }
.header-actions { display: flex; }
.header-row .grow { flex: 1; }

.sticky-stack { position: sticky; top: 0; z-index: 20; background: var(--bg); border-bottom: 1px solid var(--line); }
.sticky-stack .header { position: static; }
.sticky-stack .filter-bar { padding: 2px 16px 12px; }

/* ===== Dashboard ===== */
.ledger { padding: 10px 20px 0; }
.ledger-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.balance-label { font-size: 0.875rem; font-weight: 650; color: var(--muted); }
.ledger .icon-btn { width: 40px; height: 40px; margin-right: -8px; color: var(--muted); }

.balance-amount { display: flex; align-items: baseline; gap: 8px; margin-top: 2px; font-size: 3rem; line-height: 1.05; font-weight: 750; letter-spacing: -0.045em; }
.balance-unit { font-size: 1rem; font-weight: 700; letter-spacing: 0; color: var(--muted); }
.balance-mask { letter-spacing: 0.1em; }
.ledger-meta { margin-top: 6px; color: var(--muted); font-size: 0.8125rem; }

.actions { display: grid; grid-template-columns: 1.5fr 1fr 1fr; gap: 8px; margin-top: 18px; }
.actions .btn { min-height: 48px; font-size: 0.9375rem; padding: 0 12px; }

.inline-note { margin: 8px 0 0; color: var(--bad); font-size: 0.8125rem; }

.panel, .tx-list, .sk { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }

.block { margin: 14px 16px 0; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.block-head h2 { font-size: 1rem; letter-spacing: -0.015em; }
.block-fig { font-weight: 750; color: var(--in); }

.mix { display: flex; height: 12px; gap: 3px; margin-bottom: 14px; }
.mix i { display: block; flex: 0 0 0; min-width: 0; border-radius: 4px; transition: flex-grow 0.6s var(--ease); flex-grow: 0; }
.mix .m-pay { background: var(--in); }
.mix .m-top { background: var(--out); }
.mix .m-cash { background: var(--cash); }
.mix.empty i { background: var(--surface-2); }
.mix.empty i:not(:first-child) { display: none; }

.legend { display: grid; gap: 2px; }
.legend-row { display: flex; align-items: center; gap: 10px; min-height: 36px; font-size: 0.9375rem; }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto; }
.legend-dot.pay { background: var(--in); }
.legend-dot.top { background: var(--out); }
.legend-dot.cash { background: var(--cash); }
.legend-name { flex: 1; }
.legend-val { font-weight: 750; }

/* ===== Lists ===== */
.section { margin-top: 24px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 20px 6px; }
.section-head h2 { font-size: 1.0625rem; letter-spacing: -0.02em; }
#recentTransactions { margin: 0 16px; }

.filter-bar { display: flex; gap: 8px; overflow-x: auto; padding: 0 16px 12px; scrollbar-width: none; }
.filter-bar::-webkit-scrollbar { display: none; }

.filter-chip {
  flex: 0 0 auto; min-height: 42px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line);
  background: transparent; color: var(--muted); font-size: 0.875rem; font-weight: 700;
  transition: background 0.18s, color 0.18s, border-color 0.18s, transform 0.15s var(--ease);
}
.filter-chip:active { transform: scale(0.96); }
.filter-chip[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--bg); }

#transactionList { padding: 14px 16px 0; }

.tx-list { overflow: hidden; }
.day { padding: 14px 16px 4px; color: var(--muted); font-size: 0.8125rem; font-weight: 700; }

.tx {
  width: 100%; display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  padding: 12px 16px; border: 0; border-top: 1px solid var(--line); background: var(--surface); text-align: left;
  animation: fadeUp 0.28s var(--ease) both; animation-delay: calc(var(--i, 0) * 18ms);
  transition: background 0.15s;
}
.day + .tx { border-top: 0; }
.tx:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

.tx-mark { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; }
.tx-mark .icon { width: 19px; height: 19px; }
.type-payment { background: var(--in-soft); color: var(--in); }
.type-topup { background: var(--out-soft); color: var(--out); }
.type-cashout { background: var(--cash-soft); color: var(--cash); }
.type-other { background: var(--surface-2); color: var(--muted); }

.tx-title, .tx-meta { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-title { font-weight: 650; }
.tx-meta { margin-top: 2px; color: var(--muted); font-size: 0.8125rem; }
.tx-amt { font-weight: 750; white-space: nowrap; }
.tx-amt.in, .sheet-fig.in { color: var(--in); }
.tx-amt.out, .sheet-fig.out { color: var(--out); }

.sk { padding: 8px 0; }
.sk-row {
  height: 48px; margin: 10px 16px; border-radius: var(--r-sm);
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--line) 50%, var(--surface-2) 75%);
  background-size: 220% 100%; animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { from { background-position: 120% 0; } to { background-position: -120% 0; } }

.empty { text-align: center; padding: 30px 12px 18px; }
.empty-art { width: 52px; height: 52px; margin: 0 auto 12px; display: grid; place-items: center; border-radius: 16px; background: var(--surface-2); color: var(--muted); }
.empty p { color: var(--muted); font-size: 0.9375rem; }
.empty .empty-title { color: var(--text); font-size: 1rem; font-weight: 700; margin-bottom: 4px; }
.empty .btn { width: auto; min-width: 148px; margin-top: 14px; }

.pagination { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 16px; }
.pagination button {
  min-height: 44px; padding: 0 16px; border: 1px solid var(--line); border-radius: var(--r);
  background: transparent; font-weight: 700; transition: transform 0.15s var(--ease), background 0.18s;
}
.pagination button:active:not(:disabled) { transform: scale(0.96); }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination-info { color: var(--muted); font-size: 0.875rem; }

/* ===== Profile ===== */
.pad { padding: 8px 16px 16px; }
.panel { padding: 0 16px 16px; margin-bottom: 14px; }
.panel.tight { padding-bottom: 4px; }
.panel-title { padding: 16px 0 2px; font-size: 1rem; letter-spacing: -0.015em; }
.identity { display: flex; align-items: center; gap: 14px; padding: 18px 0 16px; border-bottom: 1px solid var(--line); }
.avatar { width: 56px; height: 56px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 18px; background: var(--accent); color: var(--on-accent); font-weight: 750; letter-spacing: -0.02em; }
.identity-name { font-size: 1.125rem; font-weight: 750; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.identity-id { margin-top: 2px; color: var(--muted); font-size: 0.8125rem; }
.panel .error-msg { margin: 12px 0; }
.pad > .btn { margin-top: 4px; }

.facts { margin: 0; }
.fact { display: flex; justify-content: space-between; gap: 16px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.fact:last-child { border-bottom: 0; }
.fact dt { color: var(--muted); font-size: 0.875rem; }
.fact dd { margin: 0; max-width: 62%; text-align: right; font-size: 0.875rem; font-weight: 650; overflow-wrap: anywhere; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.8125rem; font-weight: 500; }

.copy-btn { display: inline-flex; align-items: center; min-height: 32px; margin-left: 8px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--r-sm); background: transparent; color: var(--text); font-size: 0.75rem; font-weight: 700; vertical-align: middle; }

.setting { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.setting:last-child { border-bottom: 0; }
.setting-text strong { display: block; font-size: 0.9375rem; font-weight: 650; }
.setting-text span { display: block; color: var(--muted); font-size: 0.8125rem; margin-top: 1px; }

.switch { position: relative; flex: 0 0 auto; width: 52px; height: 32px; padding: 0; border: 0; border-radius: 999px; background: var(--line); transition: background 0.2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: var(--text); transition: transform 0.3s var(--spring), background 0.2s; }
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(20px); background: var(--on-accent); }

.seg { display: inline-grid; grid-auto-flow: column; gap: 2px; padding: 3px; border-radius: var(--r); background: var(--surface-2); }
.seg button { min-height: 36px; padding: 0 12px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--muted); font-size: 0.8125rem; font-weight: 700; transition: background 0.18s, color 0.18s; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); }

.pill { display: inline-flex; align-items: center; min-height: 28px; padding: 0 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 750; }
.pill.ok { background: var(--in-soft); color: var(--in); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.neutral { background: var(--surface-2); color: var(--muted); }
.sheet-hero .pill { margin-top: 10px; }

/* ===== Top-up ===== */
.recent-row, .mode-bar { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.mode-bar { margin: 4px 0 14px; }
.recent-row { margin: -2px 0 14px; }
.recent-row::-webkit-scrollbar, .mode-bar::-webkit-scrollbar { display: none; }

#topupOffer:not([hidden]) { animation: fadeUp 0.3s var(--ease) both; }
.operator-line { display: inline-flex; align-items: center; gap: 8px; margin: 16px 0 12px; padding: 8px 12px; border-radius: var(--r); background: var(--in-soft); color: var(--in); font-size: 0.9375rem; font-weight: 700; }
.operator-line .icon { width: 18px; height: 18px; }

.choice-list { overflow: hidden; margin-bottom: 14px; }
.choice { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border: 0; border-top: 1px solid var(--line); background: var(--surface); text-align: left; transition: background 0.15s; }
.choice:first-child { border-top: 0; }
.choice[aria-pressed="true"] { background: var(--accent-soft); }
.choice:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.choice-name { display: block; font-weight: 650; overflow-wrap: anywhere; }
.choice-amt { flex: 0 0 auto; font-weight: 750; }

.success { text-align: center; padding: 28px 0 8px; }
.success-mark { width: 76px; height: 76px; margin: 0 auto 14px; display: block; }
.success-ring { fill: var(--in-soft); stroke: var(--in); stroke-width: 3; stroke-dasharray: 252; stroke-dashoffset: 252; animation: draw 0.6s var(--ease) 0.05s forwards; }
.success-check { fill: none; stroke: var(--in); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 52; stroke-dashoffset: 52; animation: draw 0.4s var(--ease) 0.45s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.result-title { font-size: 1.375rem; font-weight: 750; letter-spacing: -0.03em; margin-bottom: 14px; }

/* ===== QR ===== */
.qr-card { display: flex; flex-direction: column; align-items: center; padding: 22px 16px 16px; }
.qr-name { margin: 0; text-align: center; font-size: 1.0625rem; font-weight: 750; letter-spacing: 0.02em; }
.qr-frame { margin: 16px 0 12px; padding: 14px; border-radius: var(--r-lg); background: #fff; animation: fadeUp 0.35s var(--ease) both; }
.qr-frame img { display: block; width: min(260px, 70vw); height: auto; }
.qr-card .btn { margin-top: 8px; }

/* ===== Bottom nav ===== */
.bottom-nav {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); width: min(520px, 100%); z-index: 30;
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.nav-ind { position: absolute; top: -1px; left: 0; width: calc(100% / 3); height: 3px; display: flex; justify-content: center; transition: transform 0.3s var(--ease); pointer-events: none; }
.nav-ind::after { content: ""; width: 36px; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent); }
.bottom-nav[data-active="1"] .nav-ind { transform: translateX(100%); }
.bottom-nav[data-active="2"] .nav-ind { transform: translateX(200%); }

.nav-item { min-height: 62px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 0; background: transparent; color: var(--muted); font-size: 0.75rem; font-weight: 700; transition: color 0.18s; }
.nav-item .icon { width: 22px; height: 22px; transition: transform 0.25s var(--spring); }
.nav-item.is-on { color: var(--text); }
.nav-item.is-on .icon { color: var(--accent-text); transform: translateY(-1px); }
.nav-item:active .icon { transform: scale(0.88); }
.nav-item:focus-visible { outline-offset: -3px; }

/* ===== Sheets and dialogs ===== */
.modal { position: fixed; inset: 0; z-index: 40; display: none; align-items: flex-end; justify-content: center; background: var(--scrim); }
.modal.active { display: flex; animation: fade 0.18s ease-out; }
.modal.active.closing { animation: fadeOut 0.16s ease-in forwards; }
.modal.center { align-items: center; padding: 20px; }

.modal-content {
  width: min(520px, 100%); max-height: min(90dvh, 780px); overflow: auto; background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-bottom: 0; border-radius: 24px 24px 0 0; padding-bottom: env(safe-area-inset-bottom);
  box-shadow: var(--shadow); animation: sheetIn 0.3s var(--ease);
  scrollbar-width: thin; scrollbar-color: var(--line) transparent; overscroll-behavior: contain;
}
.modal.closing .modal-content { animation: sheetOut 0.16s ease-in forwards; }
.modal.center .modal-content { width: min(360px, 100%); max-height: none; border: 1px solid var(--line); border-radius: var(--r-lg); padding: 22px 20px 14px; animation: popIn 0.26s var(--ease); }
.modal.center.closing .modal-content { animation: fadeOut 0.14s ease-in forwards; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; } }
@keyframes sheetIn { from { transform: translateY(32px); } to { transform: none; } }
@keyframes sheetOut { to { transform: translateY(32px); opacity: 0; } }
@keyframes popIn { from { transform: scale(0.94); opacity: 0; } to { transform: none; opacity: 1; } }

.sheet-top { position: sticky; top: 0; z-index: 1; background: var(--surface); touch-action: none; cursor: grab; }
.handle { width: 40px; height: 4px; margin: 10px auto 0; border-radius: 99px; background: var(--line); }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 8px 4px 22px; }
.modal-title { font-size: 1.0625rem; letter-spacing: -0.02em; }
.modal-body { padding: 8px 22px 28px; }

.sheet-fig { font-size: 2.25rem; font-weight: 750; letter-spacing: -0.045em; }
.sheet-fig span { margin-left: 6px; color: var(--muted); font-size: 0.9375rem; font-weight: 650; letter-spacing: 0; }
.sheet-who { margin-top: 4px; color: var(--muted); font-size: 0.9375rem; }
.sheet-hero { margin-bottom: 8px; }
.sheet-note { margin-top: 12px; color: var(--muted); font-size: 0.8125rem; }
.dialog-copy { margin-top: 8px; color: var(--muted); font-size: 0.9375rem; }
.dialog-actions { display: flex; flex-direction: column; gap: 4px; margin-top: 16px; }
.modal.center .facts { margin-top: 8px; }

/* ===== Toasts ===== */
.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(86px + env(safe-area-inset-bottom)); z-index: 70; display: grid; gap: 8px; width: min(420px, calc(100% - 32px)); justify-items: center; pointer-events: none; }
body:not(.has-nav) .toasts { bottom: calc(28px + env(safe-area-inset-bottom)); }
.toast { display: inline-flex; align-items: center; gap: 10px; max-width: 100%; padding: 12px 16px; border-radius: var(--r); background: var(--text); color: var(--bg); font-size: 0.875rem; font-weight: 650; box-shadow: var(--shadow); animation: toastIn 0.28s var(--ease) both; }
.toast .icon { width: 18px; height: 18px; flex: 0 0 auto; }
.toast.ok .icon { color: var(--in); }
:root[data-theme="dark"] .toast.ok .icon { color: #0e6b3c; }
.toast.bad .icon { color: var(--bad); }
.toast.out { animation: toastOut 0.2s ease-in forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(6px); } }

.noscript { padding: 24px; }

@media (hover: hover) {
  .btn-primary:hover:not(:disabled) { background: var(--accent-press); }
  .btn-secondary:hover:not(:disabled), .btn-ghost:hover { background: var(--surface-2); }
  .btn-danger:hover { filter: brightness(1.08); }
  .btn-danger-ghost:hover { filter: brightness(0.97); }
  .choice:hover:not([aria-pressed="true"]), .tx:hover, .icon-btn:hover:not(:disabled), .field-btn:hover, .pagination button:hover:not(:disabled), .copy-btn:hover { background: var(--surface-2); }
  .filter-chip:hover:not([aria-pressed="true"]) { background: var(--surface-2); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
