/* Reply Army Mini App — the alchemist's notebook.
   Parchment, ink, one antique-gold accent, hairline rules, almost square corners. */

:root,
[data-theme="light"] {
  --bg: #EDE3C7;
  --bg2: #F4ECD6;
  --ink: #2A2418;
  --ink2: #5C5238;
  --ink3: #8A7E60;
  --gold: #C8922E;
  --gold-ink: #9A6C19;          /* gold dark enough for small text on parchment */
  --plate: #E4D8B6;
  --line: rgba(42, 36, 24, 0.18);
  --line-strong: rgba(42, 36, 24, 0.28);
  --gold-a12: rgba(200, 146, 46, 0.12);
  --gold-a20: rgba(200, 146, 46, 0.20);
  --gold-a38: rgba(200, 146, 46, 0.38);
  --gold-a55: rgba(200, 146, 46, 0.55);
  --success: #5BB985;
  --success-ink: #2F7A50;
  --danger: #A8473A;
  --danger-ink: #93392D;
  --danger-a12: rgba(168, 71, 58, 0.12);
  --on-ink: #EDE3C7;            /* text on an ink-filled surface */
  --gold-on-ink: #E0A93A;       /* gold that stays readable on an ink-filled surface */
  --on-gold: #1C1407;
  --bar-bg: rgba(237, 227, 199, 0.90);
  --shadow: 0 10px 30px rgba(42, 36, 24, 0.14);
  --grain-opacity: 0.38;
  --grain-blend: multiply;
}

[data-theme="dark"] {
  --bg: #16120C;
  --bg2: #211B12;
  --ink: #ECE0C2;
  --ink2: #B6A981;
  --ink3: #7E745A;
  --gold: #E0A93A;
  --gold-ink: #E0A93A;
  --plate: #1E1810;
  --line: rgba(236, 224, 194, 0.14);
  --line-strong: rgba(236, 224, 194, 0.24);
  --gold-a12: rgba(224, 169, 58, 0.10);
  --gold-a20: rgba(224, 169, 58, 0.18);
  --gold-a38: rgba(224, 169, 58, 0.34);
  --gold-a55: rgba(224, 169, 58, 0.50);
  --success: #5BB985;
  --success-ink: #6CCB96;
  --danger: #C8604F;
  --danger-ink: #DB7A68;
  --danger-a12: rgba(200, 96, 79, 0.14);
  --on-ink: #16120C;
  --gold-on-ink: #8A5F12;       /* in dark mode the ink surface is light, so use a deep gold */
  --on-gold: #1C1407;
  --bar-bg: rgba(22, 18, 12, 0.90);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --grain-opacity: 0.10;
  --grain-blend: screen;
}

:root {
  --serif: 'EB Garamond', Georgia, 'Times New Roman', serif;
  --caps: 'Cinzel', 'Trajan Pro', Georgia, serif;
  --safe-top: max(env(safe-area-inset-top, 0px), var(--tg-content-safe-area-inset-top, 0px));
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --tabbar-h: 62px;
  --col: 560px;
  --gutter: 18px;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 17.5px;
  line-height: 1.5;
  font-feature-settings: "onum" 0;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
  transition: background-color .45s ease, color .45s ease;
}

/* paper grain (data: image is allowed by img-src) */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  mix-blend-mode: var(--grain-blend);
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='0.55'/></svg>");
}

::selection { background: var(--gold-a38); }

a { color: inherit; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
[hidden] { display: none !important; }

.noscript { padding: 40px 24px; text-align: center; }

/* ───────── motion ───────── */
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes pulse { 0%, 100% { opacity: .45; } 50% { opacity: 1; } }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

.fade-up { animation: fadeUp .6s ease both; }
.fade-up.d1 { animation-delay: .05s; }
.fade-up.d2 { animation-delay: .10s; }
.fade-up.d3 { animation-delay: .15s; }
.fade-up.d4 { animation-delay: .20s; }
.fade-up.d5 { animation-delay: .25s; }

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

/* ───────── boot ───────── */
.app { position: relative; z-index: 1; min-height: 100vh; min-height: 100dvh; }
.boot {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
}
.boot-mark { color: var(--gold); font-size: 22px; animation: pulse 1.6s infinite ease-in-out; }
.boot-label { font-family: var(--caps); font-size: 11px; letter-spacing: .3em; text-transform: uppercase; color: var(--ink2); }

/* ───────── shell ───────── */
.shell {
  max-width: var(--col);
  margin: 0 auto;
  padding:
    calc(var(--safe-top) + 6px)
    calc(var(--gutter) + var(--safe-right))
    calc(var(--tabbar-h) + var(--safe-bottom) + 28px)
    calc(var(--gutter) + var(--safe-left));
}
.shell.no-tabs { padding-bottom: calc(var(--safe-bottom) + 28px); }
.shell.has-footer { padding-bottom: calc(var(--safe-bottom) + 168px); }

.topbar {
  display: flex; align-items: center; gap: 10px;
  min-height: 52px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 22px;
}
.brand { display: inline-flex; align-items: baseline; gap: 6px; text-decoration: none; }
.brand-mark { color: var(--gold); font-size: 14px; transform: translateY(-1px); }
.brand-name { font-family: var(--caps); font-weight: 600; font-size: 14px; letter-spacing: .22em; }
.brand-sub { font-family: var(--caps); font-weight: 500; font-size: 10px; letter-spacing: .18em; color: var(--gold-ink); transform: translateY(-3px); }
.topbar-spacer { flex: 1; }
.topbar-title { font-family: var(--caps); font-size: 11px; letter-spacing: .22em; text-transform: uppercase; color: var(--ink2); }

.icon-btn {
  width: 44px; height: 44px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid transparent; border-radius: 2px;
  background: transparent; color: var(--ink2);
  transition: color .2s, border-color .2s;
}
.icon-btn:hover, .icon-btn:active { color: var(--gold); border-color: var(--gold-a38); }
.icon-btn[disabled] { opacity: .5; }
.icon-btn.is-busy .icon { animation: spin 1s linear infinite; }

.back-btn {
  display: inline-flex; align-items: center; gap: 4px;
  min-height: 40px; padding: 0 12px 0 8px; margin-right: 10px;
  border: 1px solid var(--line-strong); border-radius: 2px;
  background: transparent; color: var(--ink);
  font-family: var(--caps); font-size: 11px; font-weight: 600; letter-spacing: .18em; text-transform: uppercase;
}
.back-btn:active { color: var(--gold-ink); border-color: var(--gold); }

/* Wide "Back" button under the content of every sub-screen. */
.back-bar { margin: 6px 0 0; padding-top: 18px; border-top: 1px solid var(--line); }
.back-bar[hidden] { display: none; }

.icon { width: 22px; height: 22px; flex: none; display: block; }
.icon-sm { width: 16px; height: 16px; }
.icon-xs { width: 13px; height: 13px; }

/* ───────── type ───────── */
.eyebrow {
  font-family: var(--caps);
  font-size: 11px;
  letter-spacing: .26em;
  text-transform: uppercase;
  color: var(--gold-ink);
  margin: 0 0 10px;
}
.title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(30px, 8.6vw, 40px);
  line-height: 1.04;
  letter-spacing: -0.6px;
  margin: 0 0 10px;
  text-wrap: balance;
}
.title em { font-style: italic; color: var(--gold-ink); }
.h2 { font-weight: 500; font-size: 25px; line-height: 1.15; letter-spacing: -0.3px; margin: 0 0 8px; }
.h3 { font-weight: 500; font-size: 20px; line-height: 1.2; letter-spacing: -0.2px; margin: 0; }
.lead { font-size: 18px; line-height: 1.55; color: var(--ink2); margin: 0 0 18px; text-wrap: pretty; }
.muted { color: var(--ink2); }
.faint { color: var(--ink3); }
.small { font-size: 15px; }
.tiny { font-size: 13.5px; }
.italic { font-style: italic; }
.caps {
  font-family: var(--caps); font-size: 10.5px; letter-spacing: .2em; text-transform: uppercase;
}
.num { font-variant-numeric: lining-nums tabular-nums; font-feature-settings: "lnum" 1, "tnum" 1; }
.text-gold { color: var(--gold-ink); }
.text-danger { color: var(--danger-ink); }
.text-ok { color: var(--success-ink); }
.center { text-align: center; }
.break { overflow-wrap: anywhere; word-break: break-word; }
p { margin: 0 0 12px; }

.section { margin: 0 0 30px; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-head .eyebrow { margin: 0 0 4px; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }

/* ───────── ornament rule ───────── */
.rule {
  display: flex; align-items: center; gap: 16px;
  margin: 30px 0;
  color: var(--gold);
}
.rule::before, .rule::after { content: ""; height: 1px; flex: 1; background: var(--line-strong); }
.rule-mark { font-size: 13px; letter-spacing: 9px; padding-left: 9px; }
.hairline { height: 1px; background: var(--line); border: 0; margin: 16px 0; }

/* ───────── plates ───────── */
.plate {
  position: relative;
  background: var(--plate);
  border: 1px solid var(--gold-a38);
  border-radius: 2px;
  padding: 18px;
}
.plate + .plate { margin-top: 12px; }
.plate-tight { padding: 14px 16px; }
.plate-ink {
  background: var(--ink); color: var(--on-ink);
  border-color: var(--ink);
}
.plate-ink .eyebrow { color: var(--gold-on-ink); }
.plate-ink .muted { color: var(--on-ink); opacity: .72; }
/* Buttons take their text colour from --ink, which is this plate's background:
   flip them so they stay readable on the inverted surface (both themes). */
.plate-ink .btn-gold,
.plate-ink .btn-secondary { color: var(--on-ink); border-color: var(--gold-on-ink); }
.plate-ink .btn-primary { background: var(--gold); border-color: var(--gold); color: var(--on-gold); }
.plate-ink .btn-gold:hover:not([disabled]), .plate-ink .btn-gold:active:not([disabled]),
.plate-ink .btn-secondary:hover:not([disabled]), .plate-ink .btn-secondary:active:not([disabled]) {
  background: var(--gold); border-color: var(--gold); color: var(--on-gold);
}
.plate-danger { border-color: var(--danger); background: var(--danger-a12); }
.plate-quiet { background: transparent; border: 1px solid var(--line); }

/* balance */
.balance-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.balance {
  display: flex; align-items: baseline; gap: 8px;
  font-weight: 500; letter-spacing: -1.5px; line-height: 1;
  margin: 6px 0 14px;
}
.balance-value { font-size: 64px; }
.balance-max { font-size: 24px; color: var(--ink2); letter-spacing: -0.3px; }
.balance-unit { font-family: var(--caps); font-size: 10.5px; letter-spacing: .22em; text-transform: uppercase; color: var(--ink2); margin-left: 4px; }
.meter { position: relative; height: 2px; background: var(--line); overflow: hidden; }
.meter-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: var(--p, 0%);
  background: var(--gold);
  transition: width .8s cubic-bezier(.2,.7,.2,1);
}
.meter-legend { display: flex; justify-content: space-between; margin-top: 8px; font-size: 14.5px; color: var(--ink2); }

/* chip */
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 11px;
  background: var(--plate);
  border: 1px solid var(--gold-a38);
  border-radius: 2px;
  font-family: var(--caps); font-size: 10.5px; letter-spacing: .2em; text-transform: uppercase;
  color: var(--gold-ink);
  white-space: nowrap;
}
.chip-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); flex: none; animation: pulse 2s infinite ease-in-out; }
.chip.ok { color: var(--success-ink); border-color: rgba(91, 185, 133, .45); }
.chip.ok .chip-dot { background: var(--success); }
.chip.danger { color: var(--danger-ink); border-color: var(--danger); }
.chip.danger .chip-dot { background: var(--danger); }
.chip.quiet { color: var(--ink2); border-color: var(--line); background: transparent; }
.chip.quiet .chip-dot { background: var(--ink3); animation: none; }
.tag {
  display: inline-flex; align-items: center;
  padding: 3px 7px;
  border: 1px solid var(--gold-a38); border-radius: 1px;
  font-family: var(--caps); font-size: 9.5px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--gold-ink); white-space: nowrap;
}
.tag.ok { color: var(--success-ink); border-color: rgba(91, 185, 133, .45); }
.tag.danger { color: var(--danger-ink); border-color: var(--danger); }
.tag.quiet { color: var(--ink2); border-color: var(--line); }

/* ───────── buttons ───────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 48px; padding: 0 22px;
  border-radius: 2px; border: 1px solid transparent;
  font-family: var(--caps); font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
  line-height: 1.2; text-align: center; text-decoration: none;
  transition: background-color .22s ease, color .22s ease, border-color .22s ease, opacity .2s;
  user-select: none; -webkit-user-select: none;
}
.btn-primary { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.btn-primary:hover:not([disabled]), .btn-primary:active:not([disabled]) { background: var(--gold); border-color: var(--gold); color: var(--on-gold); }
.btn-secondary { background: transparent; color: var(--ink2); border-color: var(--line-strong); }
.btn-secondary:hover:not([disabled]), .btn-secondary:active:not([disabled]) { color: var(--gold-ink); border-color: var(--gold); }
.btn-gold { background: transparent; color: var(--ink); border-color: var(--gold-a55); }
.btn-gold:hover:not([disabled]), .btn-gold:active:not([disabled]) { background: var(--gold); color: var(--on-gold); border-color: var(--gold); }
.btn-danger { background: transparent; color: var(--danger-ink); border-color: var(--danger); }
.btn-danger:active:not([disabled]) { background: var(--danger); color: #fff; }
.btn-block { display: flex; width: 100%; }
.btn-sm { min-height: 44px; padding: 0 14px; font-size: 10.5px; }
.btn[disabled] { opacity: .42; cursor: not-allowed; }
.btn.is-busy { opacity: .7; cursor: progress; }
.btn.is-busy::after {
  content: ""; width: 10px; height: 10px; border-radius: 50%;
  border: 1.5px solid currentColor; border-right-color: transparent;
  animation: spin .8s linear infinite;
}
.btn-row { display: flex; gap: 10px; }
.btn-row > .btn { flex: 1; }
.btn-col { display: flex; flex-direction: column; gap: 10px; }

.text-link {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 2px;
  background: none; border: 0;
  color: var(--ink2); font-style: italic; font-size: 16px;
  text-decoration: underline; text-decoration-color: var(--gold-a55); text-underline-offset: 4px;
}
.text-link:active { color: var(--gold-ink); }
.text-link.danger { color: var(--danger-ink); text-decoration-color: var(--danger); }

.x-link {
  display: inline; padding: 0; border: 0; background: none;
  color: var(--ink); text-align: left;
  text-decoration: underline; text-decoration-color: var(--gold-a55); text-underline-offset: 3px;
  overflow-wrap: anywhere;
}
.x-link:active { color: var(--gold-ink); }

/* quick actions */
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.quick-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 9px;
  min-height: 92px; padding: 14px 8px;
  background: var(--plate); color: var(--ink);
  border: 1px solid var(--gold-a38); border-radius: 2px;
  font-family: var(--caps); font-size: 10.5px; letter-spacing: .2em; text-transform: uppercase;
  transition: border-color .2s, color .2s, background-color .2s;
}
.quick-btn .icon { color: var(--gold); width: 26px; height: 26px; }
.quick-btn:active { border-color: var(--gold); color: var(--gold-ink); }
.quick-btn[disabled] { opacity: .5; }

/* ───────── lists ───────── */
.list { border: 1px solid var(--line-strong); border-radius: 2px; background: var(--plate); }
.list-item {
  display: flex; align-items: center; gap: 14px;
  width: 100%; min-height: 58px; padding: 13px 16px;
  border: 0; border-bottom: 1px solid var(--line);
  background: transparent; color: inherit; text-align: left;
  font-size: 17px; line-height: 1.3;
}
.list-item:last-child { border-bottom: 0; }
button.list-item:active, a.list-item:active { background: var(--gold-a12); }
.list-item .icon { color: var(--gold); }
.list-main { flex: 1; min-width: 0; }
.list-title { display: block; overflow-wrap: anywhere; }
.list-sub { display: block; font-size: 14.5px; color: var(--ink2); margin-top: 2px; overflow-wrap: anywhere; }
.list-aside { flex: none; text-align: right; color: var(--ink2); font-size: 15px; }
.chev { color: var(--ink3); flex: none; }
.rank {
  flex: none; width: 30px;
  font-style: italic; font-size: 20px; color: var(--gold-ink); text-align: center;
}
.list-item.is-disabled { opacity: .55; }

/* ───────── forms ───────── */
.field { display: block; margin: 0 0 18px; }
.field-label {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  font-family: var(--caps); font-size: 10.5px; letter-spacing: .22em; text-transform: uppercase;
  color: var(--ink2); margin-bottom: 8px;
}
.field-row { display: flex; gap: 8px; align-items: stretch; }
.input, .textarea {
  width: 100%; min-height: 50px;
  padding: 11px 14px;
  background: var(--bg2);
  border: 1px solid var(--line-strong); border-radius: 2px;
  color: var(--ink);
  font-family: var(--serif); font-size: 18px; line-height: 1.35;
  transition: border-color .2s, background-color .2s;
  -webkit-appearance: none; appearance: none;
}
[data-theme="dark"] .input, [data-theme="dark"] .textarea { background: var(--plate); }
.input::placeholder, .textarea::placeholder { color: var(--ink3); font-style: italic; }
.input:focus, .textarea:focus { outline: none; border-color: var(--gold); }
.input.is-invalid, .textarea.is-invalid { border-color: var(--danger); }
.input.is-valid { border-color: var(--success); }
.textarea { min-height: 96px; resize: vertical; }
.hint { font-size: 15px; color: var(--ink2); margin-top: 7px; line-height: 1.4; }
.hint.error { color: var(--danger-ink); }
.hint.ok { color: var(--success-ink); }
.counter { font-family: var(--serif); font-size: 14px; letter-spacing: 0; text-transform: none; }
.counter.over { color: var(--danger-ink); }
.quick-amounts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 10px; }
.quick-amounts .btn { font-family: var(--serif); font-size: 18px; letter-spacing: 0; font-weight: 500; }
.inline-actions { display: flex; flex-wrap: wrap; gap: 4px 14px; }

/* amount picker */
.amounts { display: grid; grid-template-columns: repeat(auto-fill, minmax(66px, 1fr)); gap: 8px; }
.amount {
  min-height: 54px; padding: 0;
  background: transparent; color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: 2px;
  font-size: 23px; font-weight: 500;
  font-variant-numeric: lining-nums tabular-nums; font-feature-settings: "lnum" 1;
  transition: background-color .18s, color .18s, border-color .18s;
}
.amount:active:not([disabled]) { border-color: var(--gold); }
.amount[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.amount[disabled] { opacity: .35; border-style: dashed; cursor: not-allowed; }

/* segmented */
.segmented {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  border: 1px solid var(--line-strong); border-radius: 2px;
  margin-bottom: 22px;
}
.segment {
  min-height: 46px; border: 0; border-right: 1px solid var(--line);
  background: transparent; color: var(--ink2);
  font-family: var(--caps); font-size: 10.5px; letter-spacing: .2em; text-transform: uppercase;
}
.segment:last-child { border-right: 0; }
.segment[aria-selected="true"] { background: var(--ink); color: var(--on-ink); }

/* ───────── home bits ───────── */
.greeting { margin-bottom: 20px; }
.greeting .title { margin-bottom: 6px; }
.status-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.banner {
  display: flex; align-items: center; gap: 14px;
  width: 100%; padding: 16px 16px 16px 18px; margin: 0 0 14px;
  background: var(--ink); color: var(--on-ink);
  border: 1px solid var(--gold); border-radius: 2px;
  text-align: left;
}
.banner:active { background: var(--gold); color: var(--on-gold); }
.banner .eyebrow { color: var(--gold); margin-bottom: 4px; }
.banner:active .eyebrow { color: var(--on-gold); }
.banner-time { font-size: 30px; font-weight: 500; letter-spacing: -0.5px; line-height: 1; }
.banner-sub { font-size: 15px; opacity: .78; }

.progress-line { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.progress-line .meter { flex: 1; }

.lock-actions { margin: 10px 0 16px; }
.lock-note { display: flex; gap: 12px; align-items: flex-start; }
.lock-note .icon { color: var(--gold); margin-top: 3px; }

/* ───────── mission ───────── */
.countdown {
  font-size: 58px; font-weight: 500; line-height: 1; letter-spacing: -1.5px;
  margin: 2px 0 6px;
}
.countdown.warn { color: var(--danger-ink); }
.mission-meta { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }

.task {
  display: grid; grid-template-columns: 44px 1fr; gap: 4px 12px;
  padding: 16px 16px 16px 12px;
  background: var(--plate);
  border: 1px solid var(--gold-a38); border-radius: 2px;
  transition: border-color .3s, background-color .3s;
}
.task + .task { margin-top: 10px; }
.task.is-opened { border-color: rgba(91, 185, 133, .55); }
.task-body { min-width: 0; }
.mission-lead { margin-top: 14px; }
.task-num {
  display: flex; align-items: flex-start; justify-content: center; padding-top: 2px;
  font-style: italic; font-size: 26px; line-height: 1; color: var(--gold-ink);
}
.task.is-opened .task-num { color: var(--success-ink); }
.task-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.task-author { font-weight: 500; font-size: 18px; overflow-wrap: anywhere; }
.fav { color: var(--gold); display: inline-flex; }
.task-url { font-size: 13.5px; color: var(--ink3); overflow-wrap: anywhere; }
.task-note {
  font-style: italic; color: var(--ink2); font-size: 16px;
  border-left: 2px solid var(--gold-a55); padding: 2px 0 2px 10px; margin: 6px 0 2px;
  overflow-wrap: anywhere;
}
.task-actions { display: flex; align-items: center; gap: 12px; margin-top: 8px; flex-wrap: wrap; }
.opened-mark { display: inline-flex; align-items: center; gap: 6px; color: var(--success-ink); font-family: var(--caps); font-size: 10px; letter-spacing: .18em; text-transform: uppercase; }

.sticky-footer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  padding: 12px calc(var(--gutter) + var(--safe-right)) calc(var(--safe-bottom) + 12px) calc(var(--gutter) + var(--safe-left));
  background: var(--bar-bg);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.sticky-inner { max-width: calc(var(--col) - 2 * var(--gutter)); margin: 0 auto; }
.footer-note { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 14.5px; color: var(--ink2); margin-bottom: 8px; min-height: 30px; }

/* result */
.result { text-align: center; padding: 18px 4px 6px; }
.result-mark {
  width: 76px; height: 76px; margin: 0 auto 18px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--gold); border-radius: 50%;
  color: var(--gold);
  box-shadow: 0 0 0 5px var(--gold-a12);
}
.result-mark .icon { width: 32px; height: 32px; }
.result-mark.ok { border-color: var(--success); color: var(--success-ink); box-shadow: 0 0 0 5px rgba(91,185,133,.12); }
.result-mark.danger { border-color: var(--danger); color: var(--danger-ink); box-shadow: 0 0 0 5px var(--danger-a12); }
.result .lead { margin-left: auto; margin-right: auto; max-width: 34ch; }
.big-figure { font-size: 54px; font-weight: 500; letter-spacing: -1px; line-height: 1; margin: 6px 0 10px; }

/* ───────── stats ───────── */
.figures { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.figure { background: var(--plate); border: 1px solid var(--gold-a38); border-radius: 2px; padding: 14px 14px 12px; }
.figure.wide { grid-column: 1 / -1; }
.figure .eyebrow { font-size: 10px; letter-spacing: .2em; margin-bottom: 6px; }
.figure-value { font-size: 36px; font-weight: 500; line-height: 1.05; letter-spacing: -0.8px; }
.figure-sub { font-size: 14.5px; color: var(--ink2); margin-top: 2px; }
.figure-trio { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.figure-trio .figure-value { font-size: 30px; }
.figure-mini { padding: 14px 0 2px; }
.figure-mini .caps { font-size: 9.5px; letter-spacing: .16em; }

/* ───────── kv rows ───────── */
.kv { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: 0; }
.kv-k { font-family: var(--caps); font-size: 10.5px; letter-spacing: .2em; text-transform: uppercase; color: var(--ink2); flex: none; }
.kv-v { text-align: right; min-width: 0; overflow-wrap: anywhere; }

/* ───────── states ───────── */
.empty { text-align: center; padding: 26px 18px; border: 1px dashed var(--line-strong); border-radius: 2px; }
.empty-mark { color: var(--gold); font-size: 15px; letter-spacing: 8px; padding-left: 8px; display: block; margin-bottom: 8px; }
.empty-title { font-style: italic; font-size: 19px; margin: 0 0 4px; }
.empty-text { color: var(--ink2); font-size: 15.5px; margin: 0 auto; max-width: 32ch; }
.empty .btn { margin-top: 14px; }

.skeleton {
  border-radius: 2px;
  background: linear-gradient(90deg, var(--plate) 30%, var(--gold-a20) 50%, var(--plate) 70%);
  background-size: 300% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border: 1px solid var(--line);
}
.sk-line { height: 14px; margin: 10px 0; }
.sk-line.w40 { width: 40%; }
.sk-line.w60 { width: 60%; }
.sk-line.w80 { width: 80%; }
.sk-title { height: 34px; width: 70%; margin: 6px 0 16px; }
.sk-block { height: 150px; margin: 12px 0; }
.sk-row { height: 58px; margin: 0; border-radius: 0; border-top: 0; }
.sk-row:first-child { border-top: 1px solid var(--line); }

.inline-error { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--danger); background: var(--danger-a12); border-radius: 2px; color: var(--danger-ink); font-size: 15.5px; margin: 0 0 14px; }
.inline-error .icon { margin-top: 2px; }
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--gold-a38); background: var(--gold-a12); border-radius: 2px; font-size: 15.5px; color: var(--ink); margin: 0 0 16px; }
.notice .icon { color: var(--gold); margin-top: 1px; }

.load-more { display: flex; justify-content: center; margin-top: 14px; }

/* ───────── gate screens ───────── */
.gate {
  position: relative; z-index: 1;
  min-height: 100vh; min-height: 100dvh;
  max-width: 480px; margin: 0 auto;
  padding: calc(var(--safe-top) + 40px) calc(var(--gutter) + 6px) calc(var(--safe-bottom) + 34px);
  display: flex; flex-direction: column; justify-content: center;
  text-align: center;
}
.gate .title { font-size: clamp(32px, 9vw, 44px); }
.gate .lead { margin-left: auto; margin-right: auto; max-width: 30ch; }
.gate-emblem { width: 112px; height: 112px; margin: 0 auto 26px; color: var(--gold); }
.gate-emblem.danger { color: var(--danger); }
.gate-actions { margin-top: 18px; display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.gate-foot { margin-top: 28px; font-family: var(--caps); font-size: 10px; letter-spacing: .26em; text-transform: uppercase; color: var(--ink3); }
.gate .countdown { margin: 8px 0 4px; }
.gate-form { text-align: left; margin-top: 10px; }

/* ───────── tab bar ───────── */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--bar-bg);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding: 0 var(--safe-right) var(--safe-bottom) var(--safe-left);
}
.tabbar-inner { max-width: var(--col); margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); }
.tab {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  min-height: var(--tabbar-h); padding: 6px 2px 4px;
  border: 0; background: transparent; color: var(--ink3);
  font-family: var(--caps); font-size: 9.5px; letter-spacing: .2em; text-transform: uppercase;
  transition: color .2s;
}
.tab::before {
  content: ""; position: absolute; top: -1px; left: 30%; right: 30%; height: 2px;
  background: var(--gold); transform: scaleX(0); transition: transform .3s ease;
}
.tab[aria-current="page"] { color: var(--gold-ink); }
.tab[aria-current="page"]::before { transform: scaleX(1); }
.tab .icon { width: 23px; height: 23px; }

/* ───────── overlays ───────── */
.toast {
  position: fixed; left: 50%; z-index: 80;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 14px);
  transform: translateX(-50%);
  width: calc(100% - 2 * var(--gutter)); max-width: calc(var(--col) - 2 * var(--gutter));
  padding: 13px 16px;
  background: var(--ink); color: var(--on-ink);
  border-left: 3px solid var(--gold); border-radius: 2px;
  box-shadow: var(--shadow);
  font-size: 16px; line-height: 1.35;
  animation: rise .3s ease both;
}
.toast.error { border-left-color: var(--danger); }
.toast.ok { border-left-color: var(--success); }
.toast.leaving { opacity: 0; transition: opacity .3s; }
.no-tabs-mode .toast { bottom: calc(var(--safe-bottom) + 18px); }
.footer-mode .toast { bottom: calc(var(--safe-bottom) + 170px); }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(10, 8, 5, .62);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0 0 var(--safe-bottom);
  animation: fadeIn .2s ease both;
}
.modal {
  width: 100%; max-width: 480px;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--gold-a55); border-bottom: 0; border-radius: 2px 2px 0 0;
  padding: 22px 20px 18px;
  box-shadow: var(--shadow);
  animation: fadeUp .3s ease both;
}
.modal .eyebrow { margin-bottom: 8px; }

/* ───────── mission: copy / export links ───────── */
.mission-tools {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-top: 16px;
}
.export-sheet { max-height: calc(100vh - 24px - var(--safe-top)); overflow-y: auto; }
.export-title { font-family: var(--serif); font-weight: 500; font-size: 28px; line-height: 1.1; letter-spacing: -.3px; margin: 0 0 16px; }
.export-scope { margin-bottom: 18px; }
.export-scope .segment { flex: 1; padding: 0 10px; }
.export-scope .segment[disabled] { opacity: .4; cursor: not-allowed; }
.export-label {
  font-family: var(--caps); font-size: 10.5px; letter-spacing: .24em; text-transform: uppercase;
  color: var(--gold-ink); margin-bottom: 10px;
}
.fmt-chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.fmt-chip {
  min-height: 46px; padding: 0 8px;
  background: var(--plate); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: 2px;
  font-family: var(--serif); font-size: 17px; line-height: 1;
  transition: background .18s ease, color .18s ease, border-color .18s ease, transform .12s ease;
}
.fmt-chip:active { transform: scale(.97); }
.fmt-chip.is-on { background: var(--ink); color: var(--on-ink); border-color: var(--gold); box-shadow: inset 0 -2px 0 var(--gold); }
.export-hint { margin: 10px 0 8px; font-style: italic; }
.export-preview {
  display: block; width: 100%; min-height: 0; height: 172px; resize: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; line-height: 1.55;
  white-space: pre; overflow: auto; overflow-wrap: normal;
  border-color: var(--gold-a55);
}
.export-meta { margin: 8px 0 16px; text-align: right; }
.btn.is-done,
.btn.is-done:hover:not([disabled]),
.btn.is-done:active:not([disabled]) { background: var(--success); border-color: var(--success); color: #0E1A12; }
.modal-text { font-size: 18px; line-height: 1.45; margin: 0 0 18px; white-space: pre-line; overflow-wrap: anywhere; }
@media (min-width: 600px) {
  .modal-backdrop { align-items: center; padding: 20px; }
  .modal { border-bottom: 1px solid var(--gold-a55); border-radius: 2px; }
}

.ribbon {
  position: fixed; top: calc(var(--safe-top) + 2px); left: 50%; z-index: 100;
  transform: translateX(-50%);
  padding: 2px 10px;
  background: var(--gold); color: var(--on-gold);
  border-radius: 0 0 2px 2px;
  font-family: var(--caps); font-size: 9px; font-weight: 700; letter-spacing: .3em; text-align: center;
  pointer-events: none;
}

.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ───────── wider screens ───────── */
@media (min-width: 700px) {
  :root { --gutter: 28px; }
  body { font-size: 18px; }
  .shell { padding-top: calc(var(--safe-top) + 18px); }
  .figures { grid-template-columns: repeat(3, 1fr); }
  .figure.wide { grid-column: span 3; }
}
@media (max-width: 359px) {
  :root { --gutter: 14px; }
  .balance-value { font-size: 54px; }
  .quick-btn { min-height: 84px; font-size: 9.5px; letter-spacing: .14em; }
  .tab { letter-spacing: .12em; }
}

.list-tools { margin: 0 0 14px; }
.export-scope .segment { font-size: 10px; letter-spacing: .14em; }
