:root {
  color-scheme: light;
  --ink: #212d25;
  --muted: #52645a;
  --brand: #204b37;
  --brand-dark: #163b2b;
  --on-brand: #fffef4;
  --panel-dark: #163b2b;
  --panel-end: #2d5940;
  --on-panel: #fffef4;
  --soft: #edf3e7;
  --soft-strong: #dae8cf;
  --canvas: #f7f5ee;
  --paper: #fffef9;
  --desk: #e8eee5;
  --line: #e4e7dc;
  --outline: #758578;
  --accent: #983d21;
  --badge: #983d21;
  --warm: #f7e8d8;
  --inverse-muted: #dae9dd;
  --danger: #892f23;
  --error-bg: #f8e4df;
  --error-line: #c48578;
  --light-bg: #e5efd8;
  --light-ink: #163b2b;
  --disabled: #536459;
  --skeleton-base: #e3eadf;
  --skeleton-shine: #eef2e9;
  --focus: #137458;
  --shadow: 0 3px 14px #253c2610;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --radius-sm: 10px;
  --radius: 18px;
  --radius-lg: 24px;
  --text-xs: .8125rem;
  --text-sm: .875rem;
  --text: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.5rem;
  --fast: 150ms;
  --normal: 240ms;
  --shell: 520px;
  --sticky: calc(64px + env(safe-area-inset-top, 0px));
  --dock: calc(62px + env(safe-area-inset-bottom, 0px));
  --gutter: clamp(12px, 4vw, 20px);
  --sticky-content: calc(var(--sticky) + var(--network-height, 0px));
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  scroll-padding-top: calc(var(--sticky-content) + 8px);
  scroll-padding-bottom: calc(var(--dock) + 14px);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --ink: #f2f4ee;
    --muted: #bac9c1;
    --brand: #bde0cc;
    --brand-dark: #d9f0e1;
    --on-brand: #12251c;
    --panel-dark: #123328;
    --panel-end: #244a3a;
    --soft: #263b33;
    --soft-strong: #335043;
    --canvas: #19211e;
    --paper: #222d28;
    --desk: #111713;
    --line: #41534a;
    --outline: #889f94;
    --accent: #ffc0a2;
    --badge: #983d21;
    --warm: #432d24;
    --inverse-muted: #dbeae0;
    --danger: #ffb8a8;
    --error-bg: #412a26;
    --error-line: #a6695b;
    --light-bg: #dbecd7;
    --disabled: #465850;
    --skeleton-base: #293831;
    --skeleton-shine: #35473e;
    --focus: #a6e1c1;
    --shadow: 0 3px 14px #0004;
  }
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--desk); overflow-wrap: anywhere; }
button, input, select, textarea { font: inherit; color: inherit; }
button { border: 0; background: transparent; cursor: pointer; }
a { color: inherit; text-decoration: none; }
button, a, input, select, textarea, summary { -webkit-tap-highlight-color: #204b371f; }
button, a, summary { touch-action: manipulation; }
button, summary { min-height: 44px; min-width: 44px; }
button:disabled { cursor: not-allowed; }
button.primary:disabled { background: var(--disabled); color: white; }
button.step:disabled { color: var(--muted); }
button, a { transition: background-color var(--fast), color var(--fast), transform var(--fast); }
button:active:not(:disabled), a:active { transform: scale(.97); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
h1, h2, h3, p, ol, ul, dl, dd { margin: 0; }
h1 { font-size: var(--text-xl); line-height: 1.3; }
h2 { font-size: var(--text-lg); line-height: 1.4; }
h3 { font-size: var(--text); }
p { white-space: pre-line; overflow-wrap: anywhere; }
small { display: block; color: var(--muted); font-size: var(--text-xs); }
svg { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }

.app {
  width: min(100%, var(--shell));
  min-height: 100vh;
  min-height: 100dvh;
  margin-inline: auto;
  background: var(--canvas);
  box-shadow: 0 0 48px #204b3710;
}

header {
  position: sticky;
  z-index: 6;
  top: 0;
  display: flex;
  gap: var(--space-2);
  align-items: center;
  min-height: var(--sticky);
  padding: env(safe-area-inset-top, 0px) var(--gutter) 0;
  color: var(--brand);
  background: var(--canvas);
  border-bottom: 1px solid var(--line);
}

.brand { display: inline-flex; align-items: center; min-height: 44px; gap: var(--space-2); font-size: var(--text-lg); font-weight: 800; white-space: nowrap; }
.brand img { width: 36px; height: 36px; }
.back { display: grid; place-items: center; width: 44px; padding: 0; }
header strong { font-size: var(--text-lg); }
.search-link { display: flex; align-items: center; min-height: 44px; min-width: 0; gap: var(--space-2); margin-left: auto; padding: 0 var(--space-3); background: var(--paper); border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: var(--text-xs); }
.search-link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-link svg { width: 17px; height: 17px; }

main { padding: var(--space-3) var(--gutter) calc(var(--space-5) + env(safe-area-inset-bottom, 0px)); outline: none; }
main > * + * { margin-top: var(--space-3); }
main > .sr-only + * { margin-top: 0; }
.with-dock main { padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px)); }
.keyboard-open footer { visibility: hidden; }
footer:empty { display: none; }
footer { position: fixed; inset: auto 0 0; z-index: 8; width: min(100%, var(--shell)); margin-inline: auto; background: var(--paper); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0px); }
.bottom-nav { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); padding: 4px 6px; }
.nav-item { position: relative; display: grid; min-height: 53px; align-content: center; justify-items: center; gap: 2px; border-radius: var(--radius-sm); color: var(--muted); font-size: var(--text-xs); }
.nav-item[aria-current] { color: var(--brand); background: var(--soft); font-weight: 750; }
.nav-item sup, .shortcut-link sup { position: absolute; top: 2px; left: 54%; padding: 0 5px; border-radius: 12px; color: white; background: var(--badge); font-size: .7rem; }
.pulse { animation: pulse 420ms ease-out; }
@keyframes pulse { 40% { transform: scale(1.13); background: var(--soft-strong); } }

.primary, .soft, .light, .plain { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; gap: var(--space-1); padding: 8px 12px; border: 1px solid transparent; border-radius: var(--radius-sm); font-weight: 700; text-align: center; }
.primary { color: var(--on-brand); background: var(--brand); }
.primary:hover:not(:disabled) { background: var(--brand-dark); }
.soft { color: var(--brand); background: var(--soft); }
.soft:hover:not(:disabled) { background: var(--soft-strong); }
.light { color: var(--light-ink); background: var(--light-bg); }
.plain { color: var(--brand); padding-inline: var(--space-2); font-size: var(--text-sm); }
.plain:hover { background: var(--soft); }
.wide { width: 100%; margin-top: var(--space-2); }
.paired { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
.entry { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); min-height: 46px; width: 100%; padding: 8px 2px; border-bottom: 1px solid var(--line); color: var(--brand); font-weight: 650; text-align: left; overflow-wrap: anywhere; }
.entry:last-child { border-bottom: 0; }
.entry::after { flex: none; content: '›'; font-size: 1.3rem; }

.card { padding: var(--space-4); border: 1px solid var(--line); border-radius: 8px; background: var(--paper); box-shadow: var(--shadow); }
.card > h2 { margin-bottom: var(--space-2); }
.card > p + p, .card > p + .line, .card > h3 { margin-top: var(--space-3); }
.card section + section { margin-top: var(--space-3); }
.section-head, .toolbar, .line, .row, .copy-line { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.section-head { min-height: 44px; }
.line, .copy-line { min-height: 44px; padding-block: 6px; border-bottom: 1px solid var(--line); }
.line > b, .line > dd { text-align: right; overflow-wrap: anywhere; }
.line > span:first-child, .line > dt, .copy-line > span { color: var(--muted); }
.line > b, .line > dd, .copy-line > span { min-width: 0; }
.copy-line > span { overflow-wrap: anywhere; }
.copy-line > span b { color: var(--ink); }
.copy-line .field { min-width: 0; }
.copy { flex: none; font-size: var(--text-sm); }
.copy svg { width: 16px; height: 16px; }
.row { min-height: 64px; padding-block: var(--space-2); border-bottom: 1px solid var(--line); }
.row > .picture { width: 54px; height: 54px; flex: none; border-radius: var(--radius-sm); }
.row > span:last-child { flex: none; max-width: 42%; text-align: right; font-size: var(--text-sm); }
.grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.muted { color: var(--muted); font-size: var(--text-sm); }
.empty { display: grid; place-items: center; gap: var(--space-2); padding: var(--space-5) var(--space-4); text-align: center; }
.empty > svg { width: 32px; height: 32px; color: var(--brand); }
.empty > h2 { margin: 0; }

.tabs { display: flex; gap: var(--space-1); overflow-x: auto; padding: 3px; scrollbar-width: thin; }
.tabs button { flex: 1 0 auto; padding: 6px 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: var(--paper); font-size: var(--text-sm); }
.tabs button[aria-pressed="true"] { background: var(--brand); color: var(--on-brand); border-color: var(--brand); font-weight: 700; }
.picture { display: grid; position: relative; width: 100%; place-items: center; overflow: hidden; background: var(--soft); color: var(--brand); }
.picture img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity var(--normal); }
.picture[data-ready] img { opacity: 1; }
.picture[data-failed] img { opacity: 0; }
.picture[data-ready] > svg { visibility: hidden; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
.grid.list { grid-template-columns: 1fr; }
.amount { color: var(--accent); font-size: 1.35rem; line-height: 1.15; min-width: 0; font-weight: 800; }
.amount small { display: inline; color: inherit; font-size: .65em; }
.stepper { display: flex; align-items: center; width: fit-content; border-radius: var(--radius-sm); background: var(--soft); }
.step { width: 44px; padding: 0; color: var(--brand); font-size: 1.25rem; font-weight: 750; }
.stepper output { min-width: 24px; text-align: center; font-weight: 700; }

.field { width: 100%; min-height: 46px; padding: 8px 11px; border: 1px solid var(--outline); border-radius: var(--radius-sm); background: var(--paper); }
.field[aria-invalid="true"] { border-color: var(--danger); }
.field-error { color: var(--danger); font-weight: 500; }
.field-error:empty { display: none; }
.form-field { display: grid; gap: var(--space-1); margin-bottom: var(--space-3); font-weight: 650; }
.form-field .field { font-weight: 400; }
.form-error { padding: var(--space-3); margin-bottom: var(--space-3); border: 1px solid var(--error-line); border-radius: 8px; background: var(--error-bg); color: var(--danger); }
.form-error p { margin-top: var(--space-1); }
.error-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-2); }
textarea.field { resize: vertical; }
input[type="checkbox"] { width: 21px; height: 21px; accent-color: var(--brand); flex: none; }
.consent { margin-top: var(--space-3); }
.consent label { display: flex; align-items: center; gap: var(--space-2); min-height: 44px; }
.consent a { text-decoration: underline; }
summary { cursor: pointer; padding-block: 10px; color: var(--brand); }

dialog { width: min(calc(100% - 24px), 460px); max-height: 90dvh; padding: var(--space-4); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); background: var(--paper); box-shadow: 0 12px 48px #071e1a44; }
dialog::backdrop { background: #13291f9c; }
.dialog-body { display: grid; gap: var(--space-4); }
#toast { position: fixed; z-index: 10; inset: auto 0 calc(82px + env(safe-area-inset-bottom, 0px)); width: fit-content; max-width: min(90%, var(--shell)); margin-inline: auto; padding: 10px 16px; border-radius: 14px; background: var(--panel-dark); color: var(--on-panel); text-align: center; box-shadow: var(--shadow); pointer-events: none; }
#toast:empty { padding: 0; box-shadow: none; }
#pull-status { position: fixed; z-index: 7; inset: calc(var(--sticky-content) + 5px) 0 auto; width: fit-content; margin-inline: auto; padding: 6px 12px; border-radius: 20px; background: var(--brand); color: var(--on-brand); box-shadow: var(--shadow); font-size: var(--text-xs); pointer-events: none; }
#network-status { position: sticky; top: var(--sticky); z-index: 5; padding: 8px var(--gutter); background: var(--warm); color: var(--accent); border-bottom: 1px solid var(--line); font-size: var(--text-sm); }
.skip-link { position: fixed; z-index: 20; top: var(--space-2); left: var(--space-2); padding: 12px; background: var(--paper); color: var(--brand); transform: translateY(-200%); }
.skip-link:focus { transform: none; }
.sr-only, .clipboard-input { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.skeleton, .poster-preview[data-slow] { border-radius: var(--radius); background: linear-gradient(105deg, var(--skeleton-base) 25%, var(--skeleton-shine) 48%, var(--skeleton-base) 70%) 0 / 240% 100%; animation: skeleton 1.5s linear infinite; }
.skeleton.hero { height: 212px; }
.skeleton.shortcut { height: 96px; }
.skeleton.tile { height: 242px; }
@keyframes skeleton { to { background-position: -170% 0; } }

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