* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* Screen-reader-only utility — hides content visually but keeps it for assistive tech. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

:root {
  --bg: #ffffff;
  --bg-soft: #f6f6f6;
  --line: #e8e8e8;
  --text: #1a1a1a;
  --text-dim: #6b6b6b;
  --text-faint: #a8a8a8;
  --overdue: #d92d20;
  --overdue-bg: #fef3f2;
  --upcoming: #b54708;
  --upcoming-bg: #fffaeb;
  --paid: #067647;
  --paid-bg: #ecfdf3;
  --accent: #007AFF;
  --accent-text: #ffffff;
  --serif: 'Outfit', system-ui, 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', 'Yu Gothic', Meiryo, sans-serif;
  --sans: 'Outfit', system-ui, 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', 'Yu Gothic', Meiryo, sans-serif;
  --safe-top: env(safe-area-inset-top);
  --safe-bot: env(safe-area-inset-bottom);
  --nav-h: 64px;
  --z-blood: #c1272d;
  --z-rot: #6b8e3d;
  --z-bone: #d4cfa0;
  --z-warning: #d4912a;
  --z-typewriter: 'Special Elite', 'Courier New', monospace;
  --z-display: 'Creepster', 'Special Elite', cursive;
  --z-mono: 'JetBrains Mono', 'Courier New', monospace;
}
[data-theme="dark"] {
  --bg: #0e0e10;
  --bg-soft: #1a1a1d;
  --line: #2a2a2e;
  --text: #f0f0f2;
  --text-dim: #9a9aa0;
  --text-faint: #5e5e64;
  --overdue: #f87171;
  --overdue-bg: #2a1313;
  --upcoming: #fbbf24;
  --upcoming-bg: #2a1f0a;
  --paid: #4ade80;
  --paid-bg: #0e2418;
  --accent: #0A84FF;
  --accent-text: #ffffff;
}
html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  text-transform: uppercase;
  letter-spacing: 0.02em;}
input, select, textarea, button {
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
input::placeholder { text-transform: uppercase; letter-spacing: 0.02em; }
body {
  min-height: 100vh;
  min-height: 100dvh;
  padding-top: var(--safe-top);
  padding-bottom: calc(var(--safe-bot) + var(--nav-h) + 80px);
}
.app { max-width: 540px; margin: 0 auto; }

/* Screens */
.screen { display: none; }
.screen.active { display: block; animation: fadeIn 0.18s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

header {
  padding: 28px 24px 4px;
  display: flex; align-items: flex-start; justify-content: space-between;
}
.brand-wrap { display: flex; flex-direction: column; gap: 2px; }
.brand {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 26px;
  letter-spacing: -0.02em;
  line-height: 1.05;
}
.brand span { font-weight: 400; }
.brand-name {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 22px;
  letter-spacing: -0.01em;
  color: var(--text-dim);
  line-height: 1.05;
}
.brand-name:empty { display: none; }
.date-chip { font-size: 11px; color: var(--text-dim); padding-top: 8px; }

/* Summary card */
.summary {
  margin: 16px 20px 4px;
  padding: 22px 22px 20px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 4px;
}
.sum-label { font-size: 11px; color: var(--text-dim); margin-bottom: 8px; }
.sum-amount {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 42px;
  letter-spacing: -0.03em;
  line-height: 1;
}
.sum-amount .cents { color: var(--text-dim); font-weight: 400; }
.sum-meta {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-dim);
}
.sum-meta span { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sum-meta span + span { padding-left: 14px; border-left: 1px solid var(--line); }
.sum-meta b {
  color: var(--text);
  font-weight: 700;
  font-size: 16px;
  font-family: var(--serif);
  letter-spacing: -0.01em;
}
.sum-meta .m-overdue b { color: var(--overdue); }
.sum-meta .m-upcoming b { color: var(--upcoming); }
.sum-meta .m-paid b { color: var(--paid); }
.sum-meta i {
  font-style: normal;
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: 0.06em;
}

/* Tabs (filter) */
.tabs {
  display: flex;
  gap: 18px;
  padding: 18px 24px 0;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid var(--line);
}
.tabs::-webkit-scrollbar { display: none; }

/* Hide scrollbars everywhere — touch scrolling still works */
* {
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/Edge */
}
*::-webkit-scrollbar { display: none; } /* Chrome/Safari/Opera */

/* ============ MODE TOGGLE ============ */
/* Body class controls which mode's content is visible */
body.mode-zombie .mode-bills-only { display: none !important; }
body.mode-bills .mode-zombie-only { display: none !important; }
body:not(.mode-zombie):not(.mode-bills) .mode-zombie-only { display: none !important; }

html, body {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.tab {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  padding: 10px 0 14px;
  background: transparent;
  color: var(--text-faint);
  border: none;
  border-bottom: 1.5px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.tab.active { color: var(--text); border-bottom-color: var(--text); }
.tab[data-filter="overdue"].active { color: var(--overdue); border-bottom-color: var(--overdue); }
.tab[data-filter="upcoming"].active { color: var(--upcoming); border-bottom-color: var(--upcoming); }
.tab[data-filter="paid"].active { color: var(--paid); border-bottom-color: var(--paid); }
.tab .count { font-size: 11px; margin-left: 5px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.tab.active .count { color: var(--text-dim); }

.section-head {
  padding: 22px 24px 10px;
  display: flex; align-items: baseline; justify-content: space-between;
}
.section-head h2 { font-family: var(--serif); font-weight: 400; font-size: 13px; color: var(--text-dim); }
.section-head .count { font-size: 11px; color: var(--text-faint); font-variant-numeric: tabular-nums; }

/* Bills */
.bills { padding: 0; }
.bill {
  padding: 16px 24px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  transition: background 0.12s ease;
}
.bill:active { background: var(--bg-soft); }
.bill.paid .name { text-decoration: line-through; text-decoration-color: var(--text-faint); color: var(--text-dim); }
.bill.paid .bill-amount { color: var(--text-faint); }
.bill .name {
  font-weight: 500;
  font-size: 15px;
  letter-spacing: -0.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bill .meta { margin-top: 4px; font-size: 12px; color: var(--text-dim); }
.bill .meta .due-overdue { color: var(--overdue); font-weight: 700; background: var(--overdue-bg); padding: 2px 7px; border-radius: 3px; }
.bill .meta .due-soon { color: var(--upcoming); font-weight: 700; background: var(--upcoming-bg); padding: 2px 7px; border-radius: 3px; }
.bill .meta .due-paid { color: var(--paid); font-weight: 700; background: var(--paid-bg); padding: 2px 7px; border-radius: 3px; }
.bill .meta .sep { margin: 0 6px; color: var(--text-faint); }
.bill-amount {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 17px;
  letter-spacing: -0.02em;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.bill-amount .small { color: var(--text-dim); }

.empty {
  margin: 60px 24px;
  text-align: center;
}
.empty .glyph { font-family: var(--serif); font-size: 42px; font-weight: 400; color: var(--text-faint); margin-bottom: 14px; letter-spacing: -0.02em; }
.empty p { color: var(--text-dim); font-size: 13px; max-width: 280px; margin: 0 auto; }
.empty p strong { color: var(--text); font-weight: 600; }

/* Floating action button */
.fab {
  position: fixed;
  bottom: calc(var(--nav-h) + 16px + var(--safe-bot));
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--text);
  color: var(--bg);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(0,0,0,0.18), 0 2px 6px rgba(0,0,0,0.1);
  z-index: 50;
  transition: transform 0.15s ease;
  padding: 0;
}
.fab:active { transform: scale(0.92); }
.fab svg { width: 22px; height: 22px; }
.fab.hidden { display: none; }

/* Bottom nav */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--bg);
  border-top: 1px solid var(--line);
  padding: 6px 0 calc(6px + var(--safe-bot));
  display: flex;
  justify-content: space-around;
  z-index: 40;
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-faint);
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  transition: color 0.15s ease;
  position: relative;
}
.nav-item svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-item.active { color: var(--text); }
.nav-item:active { transform: scale(0.95); }
.nav-badge {
  position: absolute;
  top: 4px;
  /* Positioned to the right of the icon — assumes 22px icon, ~50% of button width */
  left: calc(50% + 8px);
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--overdue);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  line-height: 16px;
  letter-spacing: 0;
  text-align: center;
  pointer-events: none;
  box-shadow: 0 0 0 2px var(--bg);
  transform-origin: center;
}
.nav-badge[hidden] { display: none; }
/* Pop animation: scale up briefly, then scale out and fade. The browser
   will hide the element via the `hidden` attribute after animation completes. */
.nav-badge.popping {
  animation: badgePop 320ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
@keyframes badgePop {
  0%   { transform: scale(1);    opacity: 1; }
  35%  { transform: scale(1.4);  opacity: 1; }
  100% { transform: scale(0);    opacity: 0; }
}
/* Appear animation: small scale-in pulse when the badge first shows up */
.nav-badge.appearing {
  animation: badgeAppear 360ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes badgeAppear {
  0%   { transform: scale(0);   opacity: 0; }
  60%  { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(1);   opacity: 1; }
}

/* Portrait images (pre-rendered WebP loaded from /assets/portraits) */
.z-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  /* Fade in as the WebP decodes, avoids a hard pop */
  animation: photoFadeIn 240ms ease-out;
}
.z-photo.s-turned   { filter: grayscale(0.45) contrast(0.95) brightness(0.92); }
.z-photo.s-infected { filter: saturate(0.85) brightness(0.96); }
@keyframes photoFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Sheet */
.sheet-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.sheet-overlay.open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--bg);
  border-radius: 4px 4px 0 0;
  padding: 16px 24px calc(28px + var(--safe-bot));
  z-index: 101;
  transform: translateY(100%);
  transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
  max-width: 540px;
  margin: 0 auto;
  max-height: 92vh;
  overflow-y: auto;
  border-top: 1px solid var(--line);
}
.sheet.open { transform: translateY(0); }

/* Must-pick blocking modals (e.g. first-run leader chooser) sit above toasts.
   Without this, a "Saved" or "All bills deleted" toast would render on top of
   a forced-choice modal and obscure the buttons. */
.sheet[data-must-pick="true"] { z-index: 250; }
.sheet-overlay.must-pick-overlay { z-index: 249; }
.handle { width: 36px; height: 4px; background: var(--line); border-radius: 999px; margin: 0 auto 18px; }
.sheet h3 {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}
.sheet h3 span { font-weight: 400; }
.sheet .sub { font-size: 12px; color: var(--text-dim); margin-bottom: 22px; }

/* Form */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 11px; color: var(--text-dim); margin-bottom: 7px; }
.field input, .field select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 13px 14px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 500;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.15s ease;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--text); }
/* Date input — signal it's tappable and give the picker indicator a larger,
   theme-matched hit area. Pairs with the showPicker() click handler so the
   whole field opens the calendar. */
.field input[type="date"] {
  cursor: pointer;
}
.field input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.6;
  padding: 4px;
  margin-left: 4px;
}
.field input[type="date"]::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}
/* In dark mode, the default near-black icon is invisible on the dark field.
   Invert it to a light glyph. Light mode keeps the default dark icon. */
[data-theme="dark"] .field input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.8);
}
.field select {
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3e%3cpath d='M1 1L6 6L11 1' stroke='%236b6b6b' stroke-width='1.5' stroke-linecap='round'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
}
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.amount-input { position: relative; }
.amount-input::before {
  content: var(--currency-symbol, '$');
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--serif);
  color: var(--text-dim);
  font-size: 16px;
  pointer-events: none;
  z-index: 1;
}
.amount-input input { padding-left: 28px; font-family: var(--serif); font-size: 20px; font-weight: 500; letter-spacing: -0.02em; }

.btn-row { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; margin-top: 18px; }
.btn { height: 50px; border-radius: 4px; border: none; font-family: var(--sans); font-size: 14px; font-weight: 500; cursor: pointer; letter-spacing: -0.005em; transition: transform 0.12s ease; }
.btn:active { transform: scale(0.97); }
.btn-secondary { background: var(--bg); color: var(--text-dim); border: 1px solid var(--line); }
.btn-primary { background: var(--text); color: var(--bg); }
.btn-danger {
  background: var(--bg);
  color: var(--text-dim);
  border: 1px solid var(--line);
  width: 100%;
  margin-top: 10px;
  height: 46px;
  border-radius: 4px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--sans);
  font-size: 13px;
}
.btn-danger:active { transform: scale(0.98); }

/* Detail */
.detail-card { border-bottom: 1px solid var(--line); padding-bottom: 22px; margin-bottom: 6px; }
.detail-amount { font-family: var(--serif); font-size: 42px; font-weight: 400; letter-spacing: -0.03em; line-height: 1; }
.detail-amount .cents { color: var(--text-dim); }
.detail-name { margin-top: 6px; font-size: 15px; font-weight: 500; color: var(--text-dim); }
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px 14px;
  padding-top: 22px;
  margin-top: 18px;
  border-top: 1px solid var(--line);
}
.detail-grid div .k { font-size: 11px; color: var(--text-faint); margin-bottom: 4px; }
.detail-grid div .v { font-family: var(--serif); font-size: 15px; font-weight: 500; }
.detail-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.action-btn {
  padding: 14px;
  border-radius: 4px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
}
.action-btn.primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.action-btn.primary.mercy {
  background: var(--overdue);
  border-color: var(--overdue);
  color: #fff;
}
.action-btn.primary.mercy:active {
  background: var(--overdue);
  opacity: 0.85;
}
/* Mercy-kill (outline) variant — the explicit accept-loss option, sits next
   to the "Treat infection" primary so the player has both choices visible. */
.action-btn.mercy-outline {
  border-color: var(--overdue);
  color: var(--overdue);
}
.action-btn.mercy-outline:active {
  background: var(--overdue);
  color: #fff;
  opacity: 0.85;
}
.action-btn:active { transform: scale(0.98); }

/* Survival result modal — factor rows that show what helped or hurt the roll. */
.surv-factor {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--bg-soft, rgba(127,127,127,0.08));
  border-radius: 4px;
  font-size: 13px;
}
.surv-factor .label { color: var(--text-dim); }
.surv-factor .pct {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.surv-factor .pct.pos { color: var(--ok, #6ab04c); }
.surv-factor .pct.neg { color: var(--overdue); }

.history { margin-top: 22px; padding-top: 22px; border-top: 1px solid var(--line); }
.history h4 { font-size: 11px; color: var(--text-dim); margin-bottom: 10px; font-weight: 500; }
.history-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.history-item:last-child { border-bottom: none; }
.history-item .date { color: var(--text-dim); font-size: 12px; }
.history-item .amt { font-family: var(--serif); font-weight: 500; font-variant-numeric: tabular-nums; }

.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 90px + var(--safe-bot));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--bg);
  padding: 11px 18px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  max-width: calc(100vw - 32px);
  width: max-content;
  text-align: center;
  line-height: 1.4;
  word-wrap: break-word;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== Calendar screen ===== */
.cal-header {
  padding: 22px 24px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.cal-title {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -0.02em;
}
.cal-nav { display: flex; gap: 8px; }
.cal-nav button {
  width: 36px; height: 36px;
  border-radius: 4px;
  background: var(--bg);
  border: 1px solid var(--line);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text);
}
.cal-nav button:active { background: var(--bg-soft); }
.cal-nav svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  padding: 0 16px;
  margin-bottom: 6px;
}
.cal-weekdays div {
  text-align: center;
  font-size: 10px;
  color: var(--text-faint);
  letter-spacing: 0.12em;
  padding: 6px 0;
  font-weight: 600;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  padding: 0 16px 16px;
  gap: 2px;
}
.cal-day {
  aspect-ratio: 1;
  border-radius: 4px;
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: transparent;
  position: relative;
  color: var(--text);
  transition: background 0.12s ease;
}
.cal-day.empty { cursor: default; color: transparent; pointer-events: none; }
.cal-day.muted { color: var(--text-faint); }

.cal-day:hover, .cal-day:active, .cal-day:focus {
  background: var(--bg-soft);
  outline: none;
}

/* Today: light grey background fill */
.cal-day.today {
  background: var(--bg-soft);
}
.cal-day.today span {
  font-weight: 700;
}

/* Selected: darker grey fill */
.cal-day.selected {
  background: var(--line);
}
.cal-day span { position: relative; z-index: 1; }

/* Status dots beneath number */
.cal-day .marker {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 3px;
  z-index: 2;
}
.cal-day .marker .d {
  width: 4px; height: 4px;
  border-radius: 50%;
}
.cal-day .marker .d.overdue { background: var(--overdue); }
.cal-day .marker .d.upcoming { background: var(--upcoming); }
.cal-day .marker .d.paid { background: var(--paid); }

.cal-day-list {
  margin: 22px 24px;
  padding: 18px 18px 14px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 4px;
}
.cal-day-list h4 {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
  margin-bottom: 10px;
}
.cal-day-list .empty-line {
  font-size: 12px;
  color: var(--text-dim);
  padding: 8px 0;
}
.cal-day-list-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  font-size: 13px;
  cursor: pointer;
}
.cal-day-list-item:first-of-type { border-top: none; }
.cal-day-list-item .name { font-weight: 500; }
.cal-day-list-item .amt { font-family: var(--serif); font-weight: 500; font-variant-numeric: tabular-nums; }

/* Legend */
.cal-legend {
  display: flex;
  justify-content: center;
  gap: 16px;
  padding: 14px 24px 4px;
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.06em;
}
.cal-legend span { display: flex; align-items: center; gap: 5px; }
.cal-legend .d {
  width: 6px; height: 6px;
  border-radius: 50%;
}

/* ===== Insights screen ===== */
.ins-header { padding: 22px 24px 14px; }
.ins-header h2 {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -0.02em;
}
.ins-header p { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

.stat-grid {
  margin: 0 20px 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.stat-card {
  padding: 16px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 4px;
}
.stat-card .k { font-size: 11px; color: var(--text-dim); letter-spacing: 0.06em; margin-bottom: 6px; }
.stat-card .v {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.stat-card .v .small { font-size: 13px; color: var(--text-faint); font-weight: 400; }
.stat-card .sub { font-size: 11px; color: var(--text-faint); letter-spacing: 0.04em; margin-top: 4px; }

.cat-block {
  margin: 14px 20px;
  padding: 18px 18px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 4px;
}
.cat-block h3 {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
  margin-bottom: 14px;
}
.cat-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0;
  font-size: 12px;
}
.cat-row .name { flex: 1; font-weight: 500; }
.cat-row .bar-wrap { flex: 2; height: 6px; background: var(--bg); border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.cat-row .bar { height: 100%; background: var(--text); }
.cat-row .amt { font-family: var(--serif); font-weight: 500; font-variant-numeric: tabular-nums; min-width: 70px; text-align: right; font-size: 12px; }

.history-block {
  margin: 14px 20px 0;
  padding: 18px 18px 4px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 4px;
}
.history-block h3 {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
  margin-bottom: 10px;
}
.month-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  font-size: 12px;
}
.month-row:first-of-type { border-top: none; }
.month-row .label { flex: 1; color: var(--text-dim); font-size: 11px; letter-spacing: 0.04em; }
.month-row .bar-wrap { flex: 2; height: 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.month-row .bar { height: 100%; background: var(--paid); }
.month-row .amt { font-family: var(--serif); font-weight: 500; font-variant-numeric: tabular-nums; min-width: 80px; text-align: right; }

/* ===== Profile screen ===== */
.profile-header {
  padding: 28px 24px 14px;
  text-align: center;
}
.avatar {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: var(--text);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 26px;
  margin: 0 auto 12px;
  letter-spacing: -0.02em;
}
.profile-header h2 {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.02em;
}
.profile-header p { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

.profile-summary {
  margin: 16px 20px;
  padding: 18px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 4px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  text-align: center;
}
.profile-summary .ps-box .k { font-size: 11px; color: var(--text-faint); letter-spacing: 0.06em; }
.profile-summary .ps-box .v { font-family: var(--serif); font-weight: 700; font-size: 20px; letter-spacing: -0.02em; margin-top: 4px; }
.profile-summary .ps-box + .ps-box { border-left: 1px solid var(--line); padding-left: 10px; }

.menu-section { margin: 14px 20px 0; }
.menu-section h4 {
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: 0.1em;
  margin: 14px 4px 8px;
}
.menu {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
}
.menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  cursor: pointer;
  background: transparent;
  border-left: none; border-right: none; border-bottom: none;
  width: 100%;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  text-align: left;
}
.menu-item:first-child { border-top: none; }
.menu-item:active { background: var(--bg); }
.menu-item .label { display: flex; align-items: center; gap: 12px; }
.menu-item .label svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.menu-item .right { color: var(--text-faint); font-size: 11px; display: flex; align-items: center; gap: 6px; }
.menu-item .right svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }
.menu-item.danger { color: var(--overdue); }

/* Toggle switch */
.toggle {
  position: relative;
  width: 44px;
  height: 26px;
  flex-shrink: 0;
}
.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.toggle .track {
  position: absolute;
  inset: 0;
  background: var(--line);
  border-radius: 999px;
  transition: background 0.2s ease;
  cursor: pointer;
}
.toggle .track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: var(--bg);
  border-radius: 50%;
  transition: transform 0.2s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.toggle input:checked + .track {
  background: var(--text);
}
.toggle input:checked + .track::after {
  transform: translateX(18px);
}
.menu-item.has-toggle { cursor: pointer; }

/* Inline name editor */
.menu-item .name-input {
  background: transparent;
  border: none;
  border-bottom: 1.5px solid var(--text);
  border-radius: 0;
  padding: 4px 0;
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-align: right;
  width: 160px;
  outline: none;
  text-transform: uppercase;
}
.menu-item .name-input::placeholder { color: var(--text-faint); font-weight: 400; }

.profile-foot { text-align: center; padding: 24px 24px 14px; font-size: 11px; color: var(--text-faint); letter-spacing: 0.08em; }

/* Currency picker sheet */
.cur-list {
  margin: 4px -24px 0;
  max-height: 60vh;
  overflow-y: auto;
}
.cur-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-top: 1px solid var(--line);
  cursor: pointer;
  background: transparent;
  border-left: none; border-right: none; border-bottom: none;
  width: 100%;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  text-align: left;
}
.cur-item:first-child { border-top: none; }
.cur-item:active { background: var(--bg-soft); }
.cur-item.selected { background: var(--bg-soft); }
.cur-item .cur-left { display: flex; align-items: center; gap: 14px; }
.cur-item .cur-symbol {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 18px;
  width: 28px;
  text-align: center;
  color: var(--text);
}
.cur-item .cur-name { display: flex; flex-direction: column; gap: 2px; }
.cur-item .cur-code { font-weight: 700; letter-spacing: 0.04em; }
.cur-item .cur-label { font-size: 11px; color: var(--text-faint); letter-spacing: 0.04em; font-weight: 400; }
.cur-item .cur-check {
  width: 18px; height: 18px;
  stroke: var(--text); fill: none;
  stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round;
  opacity: 0;
}
.cur-item.selected .cur-check { opacity: 1; }

/* Export options */
.export-opt {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  margin-bottom: 8px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  cursor: pointer;
  width: 100%;
  text-align: left;
  font-family: var(--sans);
  color: var(--text);
}
.export-opt:active { background: var(--bg-soft); }
.export-opt .ico {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-soft);
  border-radius: 4px;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.export-opt .info { flex: 1; }
.export-opt .info .t { font-size: 13px; font-weight: 600; letter-spacing: 0.02em; }
.export-opt .info .d { font-size: 11px; color: var(--text-dim); margin-top: 2px; font-weight: 400; letter-spacing: 0.02em; }
.export-opt .arrow {
  width: 14px; height: 14px;
  stroke: var(--text-faint); fill: none; stroke-width: 2; stroke-linecap: round;
}

/* Confirm sheet */
.confirm-icon {
  width: 56px; height: 56px;
  margin: 4px auto 16px;
  border-radius: 50%;
  background: var(--overdue-bg);
  display: flex; align-items: center; justify-content: center;
}
.confirm-icon svg {
  width: 26px; height: 26px;
  stroke: var(--overdue);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.confirm-title {
  text-align: center;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}
.confirm-message {
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
  max-width: 320px;
  margin: 0 auto 20px;
  line-height: 1.5;
}
.confirm-stats {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 14px 16px;
  margin-bottom: 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.confirm-stats .k { font-size: 11px; color: var(--text-dim); }
.confirm-stats .v {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
}
.btn-confirm-danger {
  background: var(--overdue);
  color: #fff;
  border: none;
  height: 50px;
  border-radius: 4px;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.15s ease;
  width: 100%;
}
.btn-confirm-danger:active { transform: scale(0.97); }
.btn-confirm-danger:disabled { opacity: 0.4; cursor: not-allowed; }

.import-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-dim);
}
.import-row .v {
  font-family: var(--serif);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.import-error {
  background: var(--overdue-bg);
  border: 1px solid var(--overdue);
  color: var(--overdue);
  padding: 14px;
  border-radius: 4px;
  font-size: 12px;
  margin-bottom: 14px;
  font-weight: 500;
}
/* ============================================================
   ZOMBIE MODE HOME — clean, matches bill-tracker aesthetic
   ============================================================ */

/* Header */
.z-header {
  padding: 28px 24px 4px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}
.z-header-title {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 26px;
  letter-spacing: -0.02em;
  line-height: 1.05;
}
.z-header-title span { font-weight: 400; color: var(--text-dim); }
.z-header-day {
  font-size: 11px;
  color: var(--text-dim);
  padding-top: 8px;
}

/* Status banner — subtle, not horror */
.z-status {
  margin: 14px 20px 4px;
  padding: 12px 16px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-left: 3px solid var(--paid);
  border-radius: 4px;
  font-size: 13px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 10px;
}
.z-status.warn { border-left-color: var(--upcoming); }
.z-status.crit { border-left-color: var(--overdue); }
.z-status .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--paid);
  flex-shrink: 0;
}
.z-status.warn .dot { background: var(--upcoming); }
.z-status.crit { background: var(--overdue-bg); }
.z-status.crit .dot { background: var(--overdue); }
.z-status b {
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.01em;
}

/* ============ LEVEL CARD ============ */
.z-level-card {
  margin: 12px 20px 0;
  padding: 14px 16px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 4px;
}
.z-level-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.z-level-id {
  display: flex;
  align-items: center;
  gap: 12px;
}
.z-level-num {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 28px;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--text);
  min-width: 32px;
  text-align: center;
}
.z-level-label { line-height: 1.3; }
.z-level-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.z-level-prestige {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 1px;
}
.z-level-prestige span { color: var(--text-dim); font-weight: 600; }
.z-level-xp {
  font-size: 11px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}
.z-xp-bar {
  height: 4px;
  background: var(--line);
  border-radius: 99px;
  overflow: hidden;
}
.z-xp-fill {
  height: 100%;
  background: var(--paid);
  border-radius: 99px;
  transition: width 0.4s ease;
}

/* ============ STREAKS ============ */
.z-streaks {
  margin: 8px 20px 0;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}
.z-streak {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 14px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
}
.z-streak-num {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 26px;
  letter-spacing: -0.02em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.z-streak-label {
  font-size: 10px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  line-height: 1.3;
  word-break: break-word;
}

/* Summary card (camp scene) */
.z-summary {
  margin: 16px 20px 4px;
  padding: 18px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 4px;
}
.z-leader-portrait {
  width: 100%;
  aspect-ratio: 1;
  display: block;
  border-radius: 4px;
  background: var(--bg);
  border: 1px solid var(--line);
  overflow: hidden;
  container-type: size;
}
.z-summary .meta {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text-dim);
}
.z-summary .meta .leader {
  font-weight: 600;
  color: var(--text);
}
.z-summary .meta .state {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.z-summary .meta .state.ok { color: var(--paid); }
.z-summary .meta .state.warn { color: var(--upcoming); }
.z-summary .meta .state.crit { color: var(--overdue); }

/* Stats grid */
.z-stats {
  margin: 8px 20px 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.z-stat {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 14px;
}
.z-stat .k {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.z-stat .v {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--text);
}
.z-stat .v.warn { color: var(--upcoming); }
.z-stat .v.crit { color: var(--overdue); }
.z-stat .v.ok { color: var(--paid); }
.z-stat .sub {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 4px;
}

/* Section header */
.z-section-head {
  padding: 22px 24px 10px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.z-section-head h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 14px;
  color: var(--text-dim);
}
.z-section-head .count {
  font-size: 12px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

/* Split section header — two title+count pairs on one row */
.z-section-head-split {
  justify-content: space-between;
  gap: 16px;
}
.z-sect-pair {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.z-sect-pair.right { justify-content: flex-end; }
.z-sect-pair h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 14px;
  color: var(--text-dim);
}
.z-sect-pair .count {
  font-size: 12px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.z-sect-tap {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  margin: 0;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  color: inherit;
  transition: opacity 0.12s ease;
}
/* Tappable section heads need a clearer affordance. The chevron after the
   header text says "this opens something"; brightening the heading+count from
   the default dim tones reinforces it. The disabled state below dims back. */
.z-sect-tap .z-sect-pair h2,
.z-sect-tap h2 {
  color: var(--text);
}
.z-sect-tap .count {
  color: var(--text-dim);
}
.z-sect-tap::after {
  content: '›';
  display: inline-block;
  margin-left: 4px;
  color: var(--text-dim);
  font-size: 16px;
  line-height: 1;
  transform: translateY(-1px);
}
.z-sect-tap:hover h2 { color: var(--text); }
.z-sect-tap:hover::after { color: var(--text); }
.z-sect-tap:active { opacity: 0.6; }
.z-sect-tap[disabled] { cursor: default; opacity: 0.5; }
.z-sect-tap[disabled]::after { display: none; }

/* ============ LEADER ============ */
.leader-choice-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.leader-choice {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 16px 12px;
  text-align: center;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
  transition: all 0.15s ease;
}
.leader-choice:hover {
  border-color: var(--text-dim);
}
.leader-choice.selected {
  border-color: var(--accent, var(--text));
  background: var(--bg);
  box-shadow: inset 0 0 0 1px var(--accent, var(--text));
}
.leader-choice-name {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.leader-choice-sub {
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Portrait picker — horizontal row of leader thumbnails. The user picks
   one and it becomes their leader's face. Scrolls horizontally on narrow
   screens so 5+ thumbs always fit. */
.leader-portrait-picker-wrap {
  margin-top: 18px;
}
.leader-portrait-picker-label {
  font-size: 10px;
  letter-spacing: 0.18em;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 10px;
}
.leader-portrait-picker {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  /* hide native scrollbar but keep scroll functional */
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
}
.leader-portrait-picker::-webkit-scrollbar { display: none; }
.leader-portrait-thumb {
  flex: 0 0 auto;
  width: 72px;
  height: 72px;
  border-radius: 6px;
  overflow: hidden;
  position: relative;
  background: var(--bg-soft);
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: border-color 0.15s ease, transform 0.1s ease;
}
.leader-portrait-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.leader-portrait-thumb:hover { border-color: var(--text-dim); }
.leader-portrait-thumb.selected {
  border-color: var(--text);
}
.leader-portrait-thumb.selected::after {
  content: '✓';
  position: absolute;
  top: 4px;
  right: 4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text);
  color: var(--bg);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.leader-portrait-thumb:active { transform: scale(0.97); }

/* First-run leader sheet — picker fades in once sex has been chosen.
   Reuses the same picker thumb styles as the re-pick sheet, but adds
   a smooth reveal so the new section doesn't jar into view. */
.leader-first-picker-wrap {
  animation: leaderFirstFadeIn 280ms ease-out;
}
.leader-first-actions {
  margin-top: 18px;
  animation: leaderFirstFadeIn 280ms ease-out;
}
@keyframes leaderFirstFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============ AI PHOTOS ============ */
.ai-status {
  padding: 12px 14px;
  border-radius: 4px;
  font-size: 12px;
  line-height: 1.4;
  margin: 12px 0 4px;
  border-left: 3px solid var(--text-faint);
  background: var(--bg-soft);
  color: var(--text-dim);
}
.ai-status.ok {
  border-left-color: var(--paid);
  color: var(--text);
  background: var(--paid-bg);
}
.ai-status.warn {
  border-left-color: var(--upcoming);
  color: var(--text);
  background: var(--upcoming-bg);
}

/* ============ MANAGE CATEGORIES ============ */
.cat-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
  max-height: 50vh;
  overflow-y: auto;
}
.cat-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 4px;
  transition: opacity 0.12s ease;
}
.cat-actions {
  display: flex;
  gap: 2px;
}
.cat-row.disabled { opacity: 0.45; }
.cat-row .reorder {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.cat-row .reorder button {
  width: 24px;
  height: 18px;
  padding: 0;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 3px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  transition: all 0.12s ease;
}
.cat-row .reorder button:hover { color: var(--text); border-color: var(--text-faint); }
.cat-row .reorder button:disabled { opacity: 0.3; cursor: default; }
.cat-row .reorder svg { width: 10px; height: 10px; }
.cat-info { min-width: 0; }
.cat-info .name {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cat-action-btn {
  background: none;
  border: none;
  padding: 6px;
  cursor: pointer;
  color: var(--text-dim);
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s ease;
}
.cat-action-btn:hover { color: var(--text); background: var(--bg); }
.cat-action-btn svg { width: 16px; height: 16px; }
.cat-action-btn.danger:hover { color: var(--overdue); }
.cat-add-btn {
  width: 100%;
  padding: 12px;
  background: transparent;
  border: 1px dashed var(--line);
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 12px;
  letter-spacing: inherit;
  text-transform: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.12s ease;
}
.cat-add-btn:hover {
  border-color: var(--text-faint);
  color: var(--text);
  background: var(--bg-soft);
}

/* ============ FALLEN MEMORIAL ============ */
.fallen-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}
.fallen-card {
  padding: 14px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-left: 3px solid var(--overdue);
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.fallen-head {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 12px;
  align-items: center;
}
.fallen-portrait {
  width: 72px;
  height: 72px;
  border-radius: 4px;
  background: var(--bg);
  border: 1px solid var(--line);
  overflow: hidden;
  flex-shrink: 0;
  opacity: 0.7;
  container-type: size;
}
.fallen-id { min-width: 0; }
.fallen-name {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: line-through;
  text-decoration-color: var(--overdue);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.1;
}
.fallen-role {
  font-size: 11px;
  color: var(--text-dim);
  font-style: italic;
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fallen-cause {
  font-size: 11px;
  color: var(--overdue);
  font-weight: 600;
  margin-top: 4px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.fallen-bill {
  padding-top: 10px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}
.fallen-bill-label {
  font-size: 9px;
  letter-spacing: 0.16em;
  color: var(--text-faint);
  text-transform: uppercase;
  font-weight: 700;
  flex-shrink: 0;
}
.fallen-bill-name {
  font-size: 13px;
  color: var(--text);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.fallen-death {
  font-style: italic;
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.55;
  padding: 10px 0 0;
  border-top: 1px dashed var(--line);
  margin: 0;
}
.fallen-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.fallen-stat {
  text-align: center;
  padding: 6px;
}
.fallen-stat-num {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.02em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  display: block;
}
.fallen-stat-label {
  font-size: 9px;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  margin-top: 4px;
  text-transform: uppercase;
  font-weight: 600;
  display: block;
}
.fallen-empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-dim);
  font-size: 13px;
  font-style: italic;
  border: 1px dashed var(--line);
  border-radius: 4px;
}

/* Hall of Fame — past camp era cards */
.legacy-card {
  padding: 14px 16px 16px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-left: 3px solid var(--text-dim);
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.legacy-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.legacy-era {
  font-weight: 700;
  color: var(--text-dim);
}
.legacy-end {
  font-style: italic;
}
.legacy-leader {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.01em;
  color: var(--text);
}
.legacy-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding-top: 4px;
}
.legacy-stat {
  text-align: center;
  background: var(--bg);
  padding: 8px 4px;
  border-radius: 4px;
  border: 1px solid var(--line);
}
.legacy-stat .num {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 17px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.legacy-stat .label {
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-top: 4px;
}
/* Longest-lived survivor — the era's main character.
   Small portrait + name + role + tenure. Designed to read like a memorial
   plaque, not a stat row. */
.legacy-longest {
  padding: 12px 14px;
  background: var(--bg);
  border-radius: 4px;
  border: 1px solid var(--line);
}
.legacy-longest-head {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 10px;
}
.legacy-longest-body {
  display: flex;
  align-items: center;
  gap: 12px;
}
.legacy-longest-thumb {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.legacy-longest-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.legacy-longest-initials {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 16px;
  color: var(--text-dim);
  letter-spacing: -0.01em;
  /* The initials are always in the DOM but only visible when .is-initials
     is applied (portrait failed to load or wasn't archived). */
  display: none;
}
.legacy-longest-thumb.is-initials .legacy-longest-initials {
  display: block;
}
.legacy-longest-info {
  flex: 1;
  min-width: 0;
}
.legacy-longest-name {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: var(--text);
  margin-bottom: 2px;
  /* Allow fate badge to wrap naturally if name is long */
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.legacy-longest-sub {
  font-size: 12px;
  color: var(--text-faint);
  font-style: italic;
}
.legacy-longest-fate {
  display: inline-block;
  font-family: var(--sans);
  font-style: normal;
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--bg-soft);
  color: var(--text-faint);
  border: 1px solid var(--line);
}
.legacy-longest-fate.fate-turned {
  color: var(--overdue, #c14a4a);
  border-color: var(--overdue, #c14a4a);
  background: transparent;
}
.legacy-longest-fate.fate-infected {
  color: var(--text-dim);
  border-color: var(--text-dim);
  background: transparent;
}

/* Achievements list — one row per achievement, locked rows muted */
.ach-row {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 4px;
}
.ach-row.locked {
  opacity: 0.45;
}
.ach-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  background: var(--bg);
  border-radius: 4px;
  border: 1px solid var(--line);
  color: var(--text);
}
.ach-row.locked .ach-icon { color: var(--text-faint); }
.ach-body { min-width: 0; }
.ach-name {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  letter-spacing: -0.01em;
}
.ach-desc {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}
.ach-date {
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  text-align: right;
  white-space: nowrap;
}

/* Roster */
.z-roster {
  padding: 0;
}
.z-survivor {
  padding: 16px 24px;
  display: grid;
  grid-template-columns: 108px 1fr auto;
  gap: 16px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.12s ease;
}
.z-survivor:active { background: var(--bg-soft); }

.z-survivor.s-turned { opacity: 0.55; }
.z-survivor.s-turned .z-name { text-decoration: line-through; text-decoration-color: var(--text-faint); color: var(--text-dim); }

.z-portrait {
  width: 108px;
  height: 108px;
  border-radius: 4px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  overflow: hidden;
  flex-shrink: 0;
  container-type: size;
}

.z-info { min-width: 0; }
.z-name {
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.005em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.z-title-chip {
  display: inline-block;
  margin-left: 6px;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 2px 5px;
  background: var(--bg-soft);
  color: var(--text-dim);
  border: 1px solid var(--line);
  border-radius: 2px;
  vertical-align: 2px;
}
.z-title-chip.z-chip-wanderer {
  background: transparent;
  color: var(--upcoming);
  border-color: var(--upcoming);
}
.z-role {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.z-trial {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 2px;
}
.z-survivor.s-shaken .z-trial,
.z-survivor.s-wounded .z-trial { color: var(--upcoming); font-weight: 600; }
.z-survivor.s-infected .z-trial { color: var(--overdue); font-weight: 700; }

.z-state-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: 3px;
  text-transform: uppercase;
  white-space: nowrap;
}
.z-state-badge.s-safe { color: var(--paid); background: var(--paid-bg); }
.z-state-badge.s-shaken,
.z-state-badge.s-wounded { color: var(--upcoming); background: var(--upcoming-bg); }
.z-state-badge.s-infected { color: var(--overdue); background: var(--overdue-bg); }
.z-state-badge.s-turned { color: var(--text-faint); background: var(--bg-soft); border: 1px solid var(--line); }

.z-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}
.z-amount {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.01em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.z-amount .cents { color: var(--text-dim); font-weight: 400; }
.z-survivor.s-turned .z-amount { color: var(--text-faint); }

/* Empty */
.z-empty {
  margin: 50px 24px;
  text-align: center;
  padding: 32px 24px;
  border: 1px dashed var(--line);
  border-radius: 4px;
}
.z-empty .glyph {
  font-family: var(--serif);
  font-size: 40px;
  font-weight: 400;
  color: var(--text-faint);
  display: block;
  margin-bottom: 12px;
  letter-spacing: -0.02em;
}
.z-empty p {
  color: var(--text-dim);
  font-size: 13px;
  max-width: 280px;
  margin: 0 auto;
}
.z-empty p strong { color: var(--text); font-weight: 600; }

/* Story log */
.z-story {
  padding: 0 24px;
}
.z-log-entry {
  display: grid;
  grid-template-columns: 50px 1fr;
  gap: 12px;
  align-items: baseline;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.z-log-entry:last-child { border-bottom: none; }
.z-log-day {
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  font-weight: 600;
}
.z-log-text {
  color: var(--text);
  line-height: 1.5;
}
.z-log-entry.k-shaken .z-log-text,
.z-log-entry.k-wounded .z-log-text { color: var(--upcoming); }
.z-log-entry.k-infected .z-log-text { color: var(--overdue); font-weight: 600; }

/* Terminal — the wounded → infected crossover, the moment a survivor is
   past saving. Highlighted block, same red as turned, but with a "WARNING"
   pseudo-label so it reads as a distinct turning-point event rather than a
   final death. */
.z-log-entry.k-terminal {
  background: var(--overdue-bg);
  margin: 6px -10px;
  padding: 12px 14px;
  border-radius: 4px;
  border-bottom: none;
  border-left: 3px solid var(--overdue);
  /* Two-row grid so the ::before label spans full width above the day+text */
  grid-template-columns: 50px 1fr;
  grid-template-rows: auto auto;
  row-gap: 6px;
}
.z-log-entry.k-terminal::before {
  content: "⚠ TERMINAL";
  grid-column: 1 / -1;
  font-size: 9px;
  letter-spacing: 0.18em;
  font-weight: 800;
  color: var(--overdue);
}
.z-log-entry.k-terminal .z-log-text {
  color: var(--overdue);
  font-weight: 600;
}
.z-log-entry.k-terminal .z-log-day { color: var(--overdue); font-weight: 700; }
.z-log-entry.k-turned {
  background: var(--overdue-bg);
  margin: 6px -10px;
  padding: 12px 14px;
  border-radius: 4px;
  border-bottom: none;
  border-left: 3px solid var(--overdue);
}
.z-log-entry.k-turned .z-log-text {
  color: var(--overdue);
  font-weight: 600;
  font-style: italic;
}
.z-log-entry.k-turned .z-log-day { color: var(--overdue); font-weight: 700; }

/* Returned — survivor pulled through an infection. Mirror the turned style
   visually (highlighted block) but in a positive green color to mark it as
   a rare good event. */
.z-log-entry.k-returned {
  background: rgba(106, 176, 76, 0.08);
  margin: 6px -10px;
  padding: 12px 14px;
  border-radius: 4px;
  border-bottom: none;
  border-left: 3px solid var(--ok, #6ab04c);
}
.z-log-entry.k-returned .z-log-text {
  color: var(--ok, #6ab04c);
  font-weight: 600;
  font-style: italic;
}
.z-log-entry.k-returned .z-log-day { color: var(--ok, #6ab04c); font-weight: 700; }

/* Wanderer — a one-off NPC passing through. Subtle italic + a quiet
   left-border to mark it as world-building rather than camp news. */
.z-log-entry.k-wanderer {
  margin: 6px -10px;
  padding: 12px 14px;
  border-radius: 4px;
  border-bottom: none;
  border-left: 3px solid var(--text-faint);
  background: rgba(127, 127, 127, 0.04);
  /* Two-row grid so the ::before label can span full width */
  grid-template-columns: 50px 1fr;
  grid-template-rows: auto auto;
  row-gap: 6px;
}
.z-log-entry.k-wanderer::before {
  content: "↝ A WANDERER";
  grid-column: 1 / -1;
  font-size: 9px;
  letter-spacing: 0.18em;
  font-weight: 800;
  color: var(--text-faint);
}
.z-log-entry.k-wanderer .z-log-text {
  color: var(--text-dim);
  font-style: italic;
  line-height: 1.6;
}
.z-log-entry.k-wanderer .z-log-day { color: var(--text-faint); }

/* Reaction — quiet ripple-event after a loss. Plain row but italic + dim,
   no special block treatment (so the loss event still stands out). */
.z-log-entry.k-reaction .z-log-text {
  color: var(--text-dim);
  font-style: italic;
}
.z-log-entry.k-reaction .z-log-day { color: var(--text-faint); }

/* Season — ambient month-of-year observation. Like wanderer (italic, dim,
   muted left border) but with a different label and slightly cooler tone
   so the two don't blur together. */
.z-log-entry.k-season {
  margin: 6px -10px;
  padding: 12px 14px;
  border-radius: 4px;
  border-bottom: none;
  border-left: 3px solid var(--text-faint);
  background: rgba(127, 127, 127, 0.04);
  grid-template-columns: 50px 1fr;
  grid-template-rows: auto auto;
  row-gap: 6px;
}
.z-log-entry.k-season::before {
  content: "○ THE WORLD TURNS";
  grid-column: 1 / -1;
  font-size: 9px;
  letter-spacing: 0.18em;
  font-weight: 800;
  color: var(--text-faint);
}
.z-log-entry.k-season .z-log-text {
  color: var(--text-dim);
  font-style: italic;
  line-height: 1.6;
}
.z-log-entry.k-season .z-log-day { color: var(--text-faint); }
.z-log-entry.k-milestone {
  background: linear-gradient(135deg, #fef6dc 0%, #f4e4a8 100%);
  margin: 14px -10px;
  padding: 18px 16px 16px;
  border-radius: 4px;
  border-bottom: none;
  border-left: 4px solid #b8860b;
  box-shadow: 0 1px 0 rgba(184, 134, 11, 0.15);
  /* Match founding's two-row grid so the ::before label spans full width */
  grid-template-columns: 50px 1fr;
  grid-template-rows: auto auto;
  row-gap: 8px;
}
.z-log-entry.k-milestone::before {
  content: "★ MILESTONE";
  grid-column: 1 / -1;
  font-size: 9px;
  letter-spacing: 0.18em;
  font-weight: 800;
  color: #8a6508;
}
[data-theme="dark"] .z-log-entry.k-milestone {
  background: linear-gradient(135deg, #2a2210 0%, #3a2f15 100%);
  border-left-color: #d4af37;
  box-shadow: 0 1px 0 rgba(212, 175, 55, 0.2);
}
[data-theme="dark"] .z-log-entry.k-milestone::before {
  color: #d4af37;
}
.z-log-entry.k-milestone .z-log-text {
  color: #5a4408;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: -0.005em;
}
[data-theme="dark"] .z-log-entry.k-milestone .z-log-text {
  color: #f4e4a8;
}
.z-log-entry.k-milestone .z-log-day {
  color: #8a6508;
  font-weight: 800;
  letter-spacing: 0.12em;
}
[data-theme="dark"] .z-log-entry.k-milestone .z-log-day {
  color: #d4af37;
}
.z-log-entry.k-interaction .z-log-text {
  font-style: italic;
  color: var(--text-dim);
}
.z-log-entry.k-arrival {
  background: var(--paid-bg);
  margin: 6px -10px;
  padding: 12px 14px;
  border-radius: 4px;
  border-bottom: none;
  border-left: 3px solid var(--paid);
}
.z-log-entry.k-arrival .z-log-text {
  color: var(--text);
  font-weight: 500;
}
.z-log-entry.k-arrival .z-log-day { color: var(--paid); font-weight: 700; }

.z-log-entry.k-wander {
  margin: 6px -10px;
  padding: 12px 14px;
  border-radius: 4px;
  border-bottom: none;
  border-left: 3px solid var(--upcoming);
}
.z-log-entry.k-wander .z-log-text {
  color: var(--text);
  font-weight: 500;
  font-style: italic;
}
.z-log-entry.k-wander .z-log-day { color: var(--upcoming); font-weight: 700; }

.z-log-entry.k-mercyKill {
  background: var(--overdue-bg);
  margin: 6px -10px;
  padding: 12px 14px;
  border-radius: 4px;
  border-bottom: none;
  border-left: 3px solid var(--overdue);
}
.z-log-entry.k-mercyKill .z-log-text {
  color: var(--overdue);
  font-weight: 600;
  font-style: italic;
}
.z-log-entry.k-mercyKill .z-log-day { color: var(--overdue); font-weight: 700; }
/* Voice — quoted dialogue, slightly indented and italic */
.z-log-entry.k-voice .z-log-text {
  font-style: italic;
  color: var(--text);
}
/* Goodbye — last words. Solemn red-tinged italic, sits just before the kill event */
.z-log-entry.k-goodbye {
  margin: 6px -10px;
  padding: 12px 14px;
  border-bottom: none;
  border-left: 3px solid var(--text-dim);
}
.z-log-entry.k-goodbye .z-log-text {
  font-style: italic;
  color: var(--text-dim);
  font-weight: 500;
}
.z-log-entry.k-goodbye .z-log-day { color: var(--text-faint); font-weight: 600; }
/* Diary — leader's reflections, distinct subdued treatment */
.z-log-entry.k-diary {
  background: var(--bg-soft);
  margin: 6px -10px;
  padding: 12px 14px;
  border-radius: 4px;
  border-bottom: none;
  border-left: 3px solid var(--text-dim);
}
.z-log-entry.k-diary .z-log-text {
  color: var(--text);
  font-style: italic;
  font-weight: 400;
}
.z-log-entry.k-diary .z-log-day { color: var(--text); font-weight: 700; }

/* Founding entry — the moment the leader was chosen and the camp began.
   Treated as gold/treasured: the most important entry in the entire log. */
.z-log-entry.k-founding {
  background: linear-gradient(135deg, #fef6dc 0%, #f4e4a8 100%);
  margin: 14px -10px;
  padding: 18px 16px 16px;
  border-radius: 4px;
  border-bottom: none;
  border-left: 4px solid #b8860b;
  box-shadow: 0 1px 0 rgba(184, 134, 11, 0.15);
  position: relative;
  /* Override base grid: header band on top spanning full width, then DAY/text row below */
  grid-template-columns: 50px 1fr;
  grid-template-rows: auto auto;
  row-gap: 8px;
}
.z-log-entry.k-founding::before {
  content: "★ THE CAMP BEGINS";
  grid-column: 1 / -1;
  font-size: 9px;
  letter-spacing: 0.18em;
  font-weight: 800;
  color: #8a6508;
}
[data-theme="dark"] .z-log-entry.k-founding {
  background: linear-gradient(135deg, #2a2210 0%, #3a2f15 100%);
  border-left-color: #d4af37;
  box-shadow: 0 1px 0 rgba(212, 175, 55, 0.2);
}
[data-theme="dark"] .z-log-entry.k-founding::before {
  color: #d4af37;
}
[data-theme="dark"] .z-log-entry.k-founding::before {
  color: #d4af37;
}
.z-log-entry.k-founding .z-log-text {
  color: #5a4408;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: -0.005em;
}
[data-theme="dark"] .z-log-entry.k-founding .z-log-text {
  color: #f4e4a8;
}
.z-log-entry.k-founding .z-log-day {
  color: #8a6508;
  font-weight: 800;
  letter-spacing: 0.12em;
}
[data-theme="dark"] .z-log-entry.k-founding .z-log-day {
  color: #d4af37;
}
/* Bond — subtle small-events between two survivors */
.z-log-entry.k-bond .z-log-text {
  color: var(--text-dim);
  font-style: italic;
}
.z-log-empty {
  padding: 20px 0;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  font-style: italic;
}

/* ============ SURVIVOR DETAIL — redesigned ============ */

/* Hero block: portrait + identity side-by-side */
.z-hero {
  display: grid;
  grid-template-columns: 136px 1fr;
  gap: 16px;
  align-items: center;
  padding: 4px 0 22px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--line);
}
.z-hero-portrait {
  width: 136px;
  height: 136px;
  border-radius: 4px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  overflow: hidden;
  flex-shrink: 0;
  container-type: size;
}
.z-hero-id {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.z-hero-name {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 24px;
  letter-spacing: -0.02em;
  line-height: 1.05;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.z-hero-role {
  font-size: 12px;
  color: var(--text-dim);
  font-style: italic;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.z-hero-titles {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.z-hero-titles[hidden] { display: none; }
.z-hero-titles .title-pill {
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 2px;
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--line);
}
.z-hero-titles .title-pill.tenure {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}
.z-hero-titles .title-pill.wanderer {
  background: transparent;
  color: var(--upcoming);
  border-color: var(--upcoming);
}
.z-hero-bill {
  font-size: 12px;
  color: var(--text);
  margin-top: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
}
.z-hero-bill .lbl {
  font-size: 9px;
  letter-spacing: 0.16em;
  color: var(--text-faint);
  text-transform: uppercase;
  font-weight: 700;
  margin-right: 6px;
}
.z-hero-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.z-hero-amount {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.01em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.z-hero-due {
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 3px;
  text-transform: uppercase;
  font-weight: 600;
}
.z-hero-due.warn { color: var(--upcoming); border-color: var(--upcoming); background: var(--upcoming-bg); }
.z-hero-due.crit { color: var(--overdue); border-color: var(--overdue); background: var(--overdue-bg); }
.z-hero-due.ok { color: var(--paid); border-color: var(--paid); background: var(--paid-bg); }

.z-hero-level {
  font-size: 11px;
  color: var(--paid);
  background: var(--paid-bg);
  border: 1px solid var(--paid);
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 3px;
  text-transform: uppercase;
  font-weight: 700;
}

.z-svxp-row {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 14px;
  align-items: center;
}
.z-svxp-num {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 30px;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--paid);
  text-align: center;
}
.z-svxp-bar-wrap { min-width: 0; }
.z-svxp-meta {
  font-size: 11px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  margin-bottom: 6px;
  letter-spacing: 0.04em;
}
.z-svxp-bar {
  height: 6px;
  background: var(--line);
  border-radius: 99px;
  overflow: hidden;
}
.z-svxp-fill {
  height: 100%;
  background: var(--paid);
  border-radius: 99px;
  transition: width 0.4s ease;
}

/* Section pattern */
.z-section {
  margin-bottom: 22px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}
.z-section:last-of-type { border-bottom: none; }
.z-section-label {
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--text-faint);
  margin-bottom: 12px;
  text-transform: uppercase;
  font-weight: 700;
}
.z-section-prose {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  font-style: italic;
}

/* Bond row — relationship with another survivor */
.z-bond-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.z-bond-row {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 14px;
  align-items: center;
}
.z-bond-row.z-bond-broken .z-bond-portrait { opacity: 0.55; }
.z-bond-row.z-bond-broken .z-bond-name-line {
  text-decoration: line-through;
  text-decoration-color: var(--text-faint);
  color: var(--text-dim);
}
.z-bond-row.z-bond-broken .z-bond-label-line { color: var(--text-faint); }
.z-bond-portrait {
  width: 64px;
  height: 64px;
  border-radius: 4px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  overflow: hidden;
  flex-shrink: 0;
  container-type: size;
}
.z-bond-content { min-width: 0; }
.z-bond-content .z-bond-label-line {
  font-size: 9px;
  letter-spacing: 0.16em;
  color: var(--text-faint);
  text-transform: uppercase;
  font-weight: 700;
}
.z-bond-content .z-bond-name-line {
  font-size: 15px;
  color: var(--text);
  font-weight: 600;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.z-bond-meta {
  font-size: 12px;
  color: var(--text-faint);
  font-style: italic;
  margin-top: 3px;
}

/* Bill reference — small line that connects this bond's partner back to
   the underlying bill they're tied to. Helps the player remember which
   real-world obligation the survivor represents. */
.z-bond-bill {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Status grid (4 stat cells) */
.z-status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 18px;
}
.z-status-cell .k {
  font-size: 11px;
  color: var(--text-faint);
  margin-bottom: 4px;
}
.z-status-cell .v {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.01em;
  color: var(--text);
}
.z-status-cell .v.warn { color: var(--upcoming); }
.z-status-cell .v.crit { color: var(--overdue); }

/* Actions row.
   Holds 2 or 3 buttons depending on survivor state:
   - Normal: [Settle bill (2fr)] [Edit profile (1fr)]
   - Infected: [Settle bill] [Mercy kill] [Edit profile]
   Flexbox with flex-grow lets the row reflow cleanly whether the middle
   button is hidden (display:none) or shown, without needing JS to swap
   grid templates. The primary button keeps a larger share via flex-grow:2. */
.z-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 22px;
}
.z-actions .action-btn {
  flex: 1 1 0;
  min-width: 0;
  padding: 14px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 600;
}
.z-actions .action-btn.primary { flex-grow: 2; }

@keyframes splashDot {
  0%, 60%, 100% { opacity: 0.3; transform: scale(0.85); }
  30%           { opacity: 1.0; transform: scale(1.0); }
}
/* Light theme splash — overrides the dark default if user is on light theme */
html[data-theme="light"] #splash {
  background: #fafafa;
}
html[data-theme="light"] #splash > div > div:first-child {
  color: #0e0e10;
}
html[data-theme="light"] #splash > div > div:nth-child(2) {
  color: #8a8a92;
}
#splash.hide {
  opacity: 0;
  pointer-events: none;
}
