:root {
  --bg: #0f1115;
  --card: #181b22;
  --line: #262a33;
  --text: #e6e8ee;
  --muted: #8a90a0;
  --accent: #6c9cff;
  --good: #6fcf97;
  --bad: #e8594f;
  --warn: #f2c94c;
  --radius: 16px;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

.wrap { max-width: 560px; margin: 32px auto 64px; padding: 0 16px; display: grid; gap: 16px; }
#app, .screen { display: grid; gap: 16px; }

.card { background: var(--card); border-radius: var(--radius); padding: 20px; }

h1 { margin: 0; font-size: 1.4rem; letter-spacing: 0.02em; }
h2 { margin: 0; font-size: 0.9rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); margin: 0; }
.small { font-size: 0.85rem; }
.err { color: var(--bad); margin: 0; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; }
.spread { justify-content: space-between; }

/* Banner (time travel) */
.banner {
  background: var(--warn); color: #1a1a1a; text-align: center;
  padding: 6px 12px; font-size: 0.85rem; font-weight: 600;
}

.banner.error { background: var(--bad); color: #fff; }
.banner button { margin-left: 10px; background: rgba(0, 0, 0, 0.15); color: #1a1a1a; font-weight: 600; }
.tt-status { margin: 12px 0 0; }
#rename-form { display: flex; }
.backup-row { margin-top: 12px; flex-wrap: wrap; }
.backup-list { margin: 10px 0 0; padding-left: 18px; display: grid; gap: 2px; }
.ok { color: var(--good); }
.tt-row { flex-wrap: wrap; margin-top: 10px; }
.test-panel { border: 1px dashed var(--warn); }
.test-panel h2 { color: var(--warn); }
.test-panel .tt-status { margin-top: 6px; }
.test-panel input[type="date"] { padding: 4px 8px; }
button:disabled { opacity: 0.4; cursor: default; filter: none; }

/* Nav */
.nav { display: flex; gap: 6px; align-items: center; }
.nav .ico { display: none; }
.nav a {
  color: var(--muted); text-decoration: none; padding: 6px 14px; border-radius: 999px;
  font-weight: 600; font-size: 0.9rem;
}
.nav a:hover { color: var(--text); }
.nav a.active { background: var(--card); color: var(--text); }

/* Companion card */
.companion { display: flex; align-items: center; gap: 20px; }
.avatar { width: 256px; height: 256px; flex-shrink: 0; image-rendering: pixelated; }
.level { font-weight: 700; color: var(--accent); }
.xpbar { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; margin: 12px 0 6px; }
.xpfill { height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width 0.4s ease; }
.companion.pulse { animation: pulse 1.4s ease; }
.companion.shake { animation: shake 0.5s ease; }
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 var(--accent); }
  30%  { box-shadow: 0 0 40px 6px var(--accent); }
  100% { box-shadow: 0 0 0 0 transparent; }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

a.plain { color: inherit; text-decoration: none; }
a.plain:hover { text-decoration: underline; text-decoration-color: var(--accent); }

/* Random event card */
.event { border-left: 4px solid var(--warn); display: grid; gap: 6px; }
.event[data-kind="good"] { border-left-color: var(--good); }
.event h3 { margin: 0; font-size: 1.1rem; }
.event p { margin: 0; }
.event-img { width: 100%; border-radius: 10px; }
.event #event-close { padding: 0 8px; font-size: 1rem; line-height: 1.4; }
.tag.fx-good { color: var(--good); }
.tag.fx-bad { color: var(--warn); }
.event.event-new { animation: eventIn 0.5s ease-out; }
@keyframes eventIn { 0% { transform: translateY(-8px) scale(0.97); opacity: 0; } 100% { transform: none; opacity: 1; } }

/* Mood */
.mood-line { margin: 4px 0 0; }
.mood-chip { font-weight: 600; }
.mood-chip[data-band="happy"] { color: var(--good); }
.mood-chip[data-band="neutral"] { color: var(--text); }
.mood-chip[data-band="worried"] { color: var(--warn); }
.mood-chip[data-band="sad"] { color: var(--bad); }
.profile-mood { margin-top: 16px; display: grid; gap: 6px; }
.moodbar {
  height: 10px; border-radius: 999px; position: relative; overflow: hidden;
  background: linear-gradient(90deg, rgba(232, 89, 79, 0.25), rgba(242, 201, 76, 0.25), rgba(111, 207, 151, 0.25));
}
.moodfill {
  height: 100%; width: 50%; border-right: 3px solid var(--text);
  background: transparent; transition: width 0.8s ease;
}
.tiny { font-size: 0.75rem; }

/* Profile */
.profile { display: flex; gap: 20px; align-items: flex-start; }
.portrait { margin: 0; width: 200px; flex-shrink: 0; display: grid; gap: 6px; }
.portrait img {
  width: 200px; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 12px;
  background: var(--bg); border: 2px solid var(--accent);
}
.portrait img.pixel { object-fit: contain; image-rendering: pixelated; padding: 12px; }
.portrait figcaption { overflow-wrap: anywhere; }
.personality { margin: 14px 0 0; font-size: 1.05rem; }
.traits { list-style: none; margin: 12px 0 8px; padding: 0; display: grid; gap: 10px; }
.trait { display: grid; grid-template-columns: 80px 1fr 64px; align-items: center; gap: 10px; }
.trait .xpbar { margin: 0; }
.trait .xpfill { transition: width 0.8s ease; }
.trait-value { text-align: right; color: var(--muted); font-size: 0.85rem; }
.achievements { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.ach { background: var(--bg); border-radius: 12px; padding: 10px; display: grid; gap: 2px;
  opacity: 0.45; filter: grayscale(1); }
.ach.got { opacity: 1; filter: none; border: 1px solid var(--accent); }
.ach-icon { font-size: 1.1rem; font-weight: 800; color: var(--accent); }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60;
  display: flex; gap: 10px; align-items: center; padding: 12px 18px; border-radius: 14px;
  background: var(--card); border: 1px solid var(--accent); box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
  font-weight: 600; animation: toastIn 0.4s ease-out, toastOut 0.4s ease-in 3.6s forwards;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 20px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes toastOut { to { opacity: 0; transform: translate(-50%, 20px); } }
/* Roster */
.roster { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.roster-card { display: grid; gap: 6px; justify-items: center; text-align: center; align-content: start;
  border-top: 4px solid var(--c); }
.roster-card.active { outline: 2px solid var(--c); }
.roster-card.locked { border-top-color: var(--line); }
.roster-avatar { width: 128px; height: 128px; image-rendering: pixelated; }
.silhouette { filter: brightness(0); opacity: 0.6; }
.roster-title { gap: 8px; justify-content: center; }
.roster-blurb, .roster-hint { margin: 4px 0; }
.roster-hint { color: var(--muted); }
.roster-swap { margin-top: 6px; border: 1px solid var(--c); }
.badge { background: var(--c); color: #111; font-size: 0.7rem; font-weight: 800; padding: 2px 8px;
  border-radius: 999px; text-transform: uppercase; letter-spacing: 0.05em; }
.mini { width: 100%; display: grid; gap: 3px; text-align: left; }
.mini-bar { height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; }
.mini-fill { height: 100%; background: var(--c, var(--accent)); border-radius: 999px; }
.roster-card.locked .mini-fill { background: var(--muted); }

/* Unlock reveal */
.reveal { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center;
  background: rgba(0, 0, 0, 0.75); padding: 16px; }
.reveal-card { background: var(--card); border: 2px solid var(--c); border-radius: var(--radius);
  padding: 28px; max-width: 380px; width: 100%; display: grid; gap: 8px; justify-items: center;
  text-align: center; box-shadow: 0 0 60px -10px var(--c); animation: revealIn 0.5s ease-out; }
.reveal-kicker { margin: 0; color: var(--c); font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.1em; font-size: 0.8rem; }
.reveal-avatar { width: 192px; height: 192px; image-rendering: pixelated;
  filter: brightness(0); transition: filter 1.4s ease; }
.reveal-avatar.revealed { filter: none; }
.reveal-card h1 { margin: 4px 0 0; }
.reveal-blurb { margin: 4px 0 8px; }
.reveal-buttons { gap: 8px; justify-content: center; }
.reveal-buttons .primary { background: var(--c); color: #111; } /* the new character's colour */
@keyframes revealIn { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: none; } }

/* Speech bubble */
.speech {
  position: relative; margin: -4px 0 0 36px; padding: 12px 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  font-size: 0.95rem;
}
.speech::before {
  content: ""; position: absolute; top: -7px; left: 30px; width: 12px; height: 12px;
  background: var(--card); border-left: 1px solid var(--line); border-top: 1px solid var(--line);
  transform: rotate(45deg);
}
.away {
  margin: 0; padding: 10px 14px; border-radius: 12px; font-size: 0.85rem;
  background: rgba(232, 89, 79, 0.12); color: #f0a39d;
}
/* Pocket: the weekly backup nudge is a calm reminder, not a warning */
.nudge {
  margin: 0; padding: 10px 14px; border-radius: 12px; font-size: 0.85rem;
  background: rgba(108, 156, 255, 0.1); color: var(--text);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}

/* ---------------------------------------------------------------- Animation */
/* Avatar: wrap breathes, sprite hops/wiggles, blink frame sits on top */
.avatar-wrap { position: relative; flex-shrink: 0; cursor: pointer; animation: breathe 3.6s ease-in-out infinite; }
.sprite { position: relative; transform-origin: 50% 100%; }
.sprite .avatar { display: block; }
.sprite .blink { position: absolute; left: 0; top: 0; }
@keyframes breathe { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
.sprite.hop { animation: hop 0.45s ease-out; }
@keyframes hop {
  0%   { transform: translateY(0) scale(1, 1); }
  20%  { transform: translateY(0) scale(1.06, 0.92); }
  50%  { transform: translateY(-14px) scale(0.96, 1.05); }
  80%  { transform: translateY(0) scale(1.04, 0.96); }
  100% { transform: none; }
}
.sprite.wiggle { animation: wiggle 0.5s ease; }
@keyframes wiggle {
  0%, 100% { transform: rotate(0); } 25% { transform: rotate(-4deg); }
  50% { transform: rotate(4deg); } 75% { transform: rotate(-2deg); }
}
.sprite.dim { animation: dim 1.8s ease; }
@keyframes dim { 0% { filter: none; } 30% { filter: grayscale(0.8) brightness(0.7); } 100% { filter: none; } }

/* Level badge, XP bar, speech bubble */
.level.bump { display: inline-block; animation: bump 0.6s ease; }
@keyframes bump { 0%, 100% { transform: scale(1); } 40% { transform: scale(1.6); } }
.xpfill.shimmer {
  background-image: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.6) 50%, transparent 100%);
  background-size: 50% 100%; background-repeat: no-repeat; animation: shimmer 0.8s ease;
}
@keyframes shimmer { from { background-position: -100% 0; } to { background-position: 250% 0; } }
.speech.bubble { animation: bubble 0.3s ease-out; transform-origin: 36px 0; }
@keyframes bubble { 0% { transform: scale(0.92); opacity: 0.5; } 100% { transform: scale(1); opacity: 1; } }

/* Tick / untick */
.habit.pop .box { animation: pop 0.35s ease-out; }
@keyframes pop { 0% { transform: scale(0.6); } 60% { transform: scale(1.3); } 100% { transform: scale(1); } }
.habit.unpop .box { animation: unpop 0.3s ease; }
@keyframes unpop { 0% { transform: scale(0.8); } 100% { transform: scale(1); } }

/* Floating "+10 XP" and confetti (added to <body> by app.js) */
.float {
  position: fixed; z-index: 50; pointer-events: none; font-weight: 800; font-size: 0.95rem;
  animation: floatUp 1s ease-out forwards;
}
.float.gain { color: var(--accent); text-shadow: 0 0 8px var(--accent); }
.float.loss { color: var(--muted); animation-name: floatDown; }
@keyframes floatUp {
  0%   { opacity: 0; transform: translateY(4px) scale(0.8); }
  20%  { opacity: 1; transform: translateY(-6px) scale(1.15); }
  100% { opacity: 0; transform: translateY(-44px); }
}
@keyframes floatDown { 0% { opacity: 1; } 100% { opacity: 0; transform: translateY(16px); } }
.confetti {
  position: fixed; width: 8px; height: 8px; z-index: 50; pointer-events: none;
  animation: confetti var(--t, 1.2s) cubic-bezier(0.2, 0.6, 0.4, 1) forwards;
}
@keyframes confetti {
  0%   { transform: translate(0, 0) rotate(0); opacity: 1; }
  45%  { transform: translate(var(--dx), var(--dy)) rotate(calc(var(--rot) * 0.5)); opacity: 1; }
  100% { transform: translate(calc(var(--dx) * 1.3), calc(var(--dy) + 280px)) rotate(var(--rot)); opacity: 0; }
}

/* Settings screen toggles (app.js) */
body.no-anim *, body.no-anim *::before, body.no-anim *::after { animation: none !important; transition: none !important; }
body.no-breathe .avatar-wrap { animation: none; }
.setting label { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; cursor: pointer; }
.setting input { grid-row: span 2; width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--accent); }
.setting.sub { padding-left: 24px; }
.setting:has(input:disabled) { opacity: 0.45; }

/* Windows "reduce motion" setting: no animations */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Lists */
.habits { list-style: none; margin: 12px 0 0; padding: 0; }
.habit { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.habit .name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.habit.archived .name { color: var(--muted); text-decoration: line-through; }
.empty { color: var(--muted); padding: 10px 0; border-top: 1px solid var(--line); }

.tag {
  font-size: 0.75rem; padding: 2px 8px; border-radius: 999px; white-space: nowrap;
  background: var(--line); color: var(--muted);
}
.tag.strict { color: var(--bad); }
.tag.relaxed { color: var(--good); }
.tag.risk { background: rgba(232, 89, 79, 0.18); color: var(--bad); font-weight: 600; }
.tag.streak { color: var(--warn); }
.tag.week-done { color: var(--accent); }
.tag.freeze { color: #8fd3ff; }
.habit.rested .name { color: var(--muted); }
.habit.rested .name::after { content: " · resting"; font-size: 0.8rem; }
#rest-btn.on { background: var(--accent); color: var(--bg); font-weight: 600; }
.float.freeze-float { color: #8fd3ff; text-shadow: 0 0 8px #8fd3ff; }

/* Today check-in */
.check { cursor: pointer; user-select: none; }
.check:hover .name { color: #fff; }
.box {
  width: 22px; height: 22px; border-radius: 7px; flex-shrink: 0;
  border: 2px solid var(--line); display: grid; place-items: center;
  transition: background 0.15s, border-color 0.15s;
}
.check.done .box { background: var(--accent); border-color: var(--accent); }
.check.done .box::after { content: "✓"; color: var(--bg); font-weight: 700; font-size: 0.85rem; }
.check.done .name { color: var(--muted); }

/* Stats */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.tile { background: var(--bg); border-radius: 12px; padding: 12px; }
.tile b { display: block; font-size: 1.4rem; }
.tile span { color: var(--muted); font-size: 0.8rem; }
.table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 0.9rem; }
.table th { text-align: left; color: var(--muted); font-weight: 500; font-size: 0.8rem; padding: 6px 0; }
.table td { padding: 8px 0; border-top: 1px solid var(--line); }
.table td:not(:first-child), .table th:not(:first-child) { text-align: right; }
.up { color: var(--good); }
.down { color: var(--bad); }

/* Consistency: journeys, main vs extra habits, let-go offer (ADHD-first) */
.habit { flex-wrap: wrap; }
.habit .name small.tiny { display: block; color: var(--muted); font-size: 0.8rem; margin-top: 2px; }
.journey { flex-basis: 100%; display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: center;
  padding-left: 32px; font-size: 0.75rem; color: var(--muted); }
#habit-list .journey, #extra-list .journey { padding-left: 0; order: 9; }
.journey-bar { height: 4px; background: var(--line); border-radius: 999px; overflow: hidden; }
.journey-fill { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width 0.6s ease; }
.journey.paused .journey-fill { background: var(--muted); }
.journey.paused .journey-text { color: var(--warn); }
.tag.built { color: var(--warn); font-weight: 600; }
.showup { margin: 10px 0 0; color: var(--muted); }
.showup.yes { color: var(--good); }
.extras-title { margin: 16px 0 0; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; }
.habit.extra .name { color: var(--muted); }
.habit.extra .journey-fill { background: var(--muted); }
.letgo { display: grid; gap: 8px; padding: 10px 12px; margin: 4px 0 8px; border-radius: 12px;
  background: rgba(242, 201, 76, 0.08); border: 1px solid rgba(242, 201, 76, 0.25); font-size: 0.85rem; }
.letgo .row { gap: 8px; }

/* Goals and aspirations */
.north-star { display: block; margin: -6px 0 0 36px; font-size: 0.85rem; color: var(--muted);
  text-decoration: none; }
.north-star:hover { color: var(--text); }
.north-star b { color: var(--warn); font-weight: 600; }
.goal-form { grid-template-columns: 1fr; }
.goal .name small { display: block; color: var(--muted); font-size: 0.8rem; margin-top: 2px; }

/* Daily puzzle (phone-first: big chips and keys, wraps instead of scrolling sideways) */
.puzzle h3 { margin: 6px 0 0; font-size: 1.05rem; }
.puzzle .row.spread { cursor: pointer; }
.puzzle.folded > :not(.row) { display: none !important; }
.puzzle.finished .puzzle-items { display: none; }
.puzzle-items { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip { min-width: 44px; height: 44px; padding: 0 10px; display: inline-grid; place-items: center;
  border-radius: 10px; background: var(--bg); border: 1px solid var(--line); font-weight: 700;
  font-size: 1.1rem; font-variant-numeric: tabular-nums; }
button.chip:hover { border-color: var(--accent); }
button.chip.used { opacity: 0.3; }
.chip.goal { background: var(--accent); color: var(--bg); border-color: transparent; }
.chip.ask { color: var(--accent); border-style: dashed; }
.puzzle-form { margin-top: 12px; gap: 10px; }
.puzzle-keys { display: flex; flex-wrap: wrap; gap: 8px; }
.puzzle-keys:empty { display: none; }
.puzzle-answer { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.puzzle-answer input { font-size: 1.1rem; padding: 10px 12px; min-width: 0; }
.puzzle-answer input.wrong { animation: shake 0.4s ease; border-color: var(--bad); }
.puzzle-feedback { margin: 10px 0 0; color: var(--warn); }
.puzzle-result { margin: 12px 0 0; padding: 10px 14px; border-radius: 12px; background: var(--bg); }
.puzzle-result.solved { color: var(--good); }

/* First-launch intro (works at phone width: one column, full-width buttons) */
.intro { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center;
  background: var(--bg); padding: 16px; overflow-y: auto; }
.intro-card { background: var(--card); border: 2px solid var(--c); border-radius: var(--radius);
  padding: 28px 22px; max-width: 420px; width: 100%; display: grid; gap: 8px; justify-items: center;
  text-align: center; box-shadow: 0 0 60px -14px var(--c); animation: revealIn 0.5s ease-out; }
.intro-card h1 { margin: 4px 0 0; color: var(--c); }
.intro-step { display: grid; gap: 12px; width: 100%; margin-top: 8px; animation: revealIn 0.35s ease-out; }
.intro-speech { margin: 6px 0 0; text-align: left; min-height: 3.2em; }
.intro-speech::before { left: calc(50% - 6px); }
.intro-speech p { margin: 0; }
.intro-how { margin: 0; padding-left: 1.3em; text-align: left; display: grid; gap: 8px; font-size: 0.95rem; }
.intro-step button.primary { background: var(--c); color: #111; padding: 12px; }
.intro-step input { padding: 12px; }
button.link { background: none; color: var(--muted); text-decoration: underline; padding: 4px; }

/* Forms */
form { display: grid; gap: 12px; margin-top: 14px; }
.field { display: grid; gap: 6px; font-size: 0.85rem; color: var(--muted); }
input, select, button {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px;
}
input:focus, select:focus { outline: 1px solid var(--accent); }
button { cursor: pointer; background: var(--line); border-color: transparent; }
button:hover { filter: brightness(1.2); }
button.primary { background: var(--accent); color: var(--bg); font-weight: 600; }
/* links and labels that look like buttons (Export / Import) */
.button { display: inline-block; font: inherit; color: var(--text); background: var(--line);
  border-radius: 10px; padding: 8px 12px; text-decoration: none; cursor: pointer; }
.button:hover { filter: brightness(1.2); }
.button.primary { background: var(--accent); color: var(--bg); font-weight: 600; }
button.small { padding: 4px 10px; font-size: 0.85rem; }
label.toggle { font-size: 0.85rem; color: var(--muted); display: flex; gap: 6px; align-items: center; }

.phone-url { margin: 8px 0; font-size: 1.3rem; font-weight: 700; color: var(--accent);
  user-select: all; word-break: break-all; }
code { font-size: 0.85em; background: var(--bg); padding: 1px 5px; border-radius: 6px; }

/* Phone opened from the home screen: keep clear of the notch and the home bar */
body { padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }

/* Nothing in the main column may push the page wider than the screen. */
#app > *, .screen > * { min-width: 0; }

@media (max-width: 480px) {
  .wrap { margin-top: 12px; padding: 0 10px; }
  .tiles { grid-template-columns: 1fr 1fr; }
  .profile { flex-direction: column; align-items: center; }
  /* phone: the nav becomes a tab bar at the bottom, in thumb reach */
  .nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; justify-content: space-around; gap: 0;
    background: var(--card); border-top: 1px solid var(--line);
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); }
  .nav a { flex: 1; display: grid; justify-items: center; gap: 1px; padding: 6px 0; border-radius: 10px;
    font-size: 0.68rem; font-weight: 600; }
  .nav a .ico { display: block; font-size: 1.2rem; line-height: 1; }
  .nav .grow, #quit { display: none; }
  .wrap { margin-bottom: calc(84px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 70; max-width: calc(100vw - 24px); }
  /* half-size avatar on phones (JS sets the desktop size inline) */
  .companion { gap: 14px; }
  .sprite .avatar { width: 128px !important; height: 128px !important; }
  /* Habits screen: the name gets its own line, buttons underneath */
  #habit-list .name, #extra-list .name, #built-list .name, #archived-list .name, #goal-list .name { flex-basis: 100%; }
}
