/* CalorieQuest's look: a dark indigo "game board" with gold, mint and ember.
   One theme on every device (the design is dark by nature). Colours and sizes
   are tokens on :root. No inline styles anywhere: the Content-Security-Policy
   forbids them. Fonts are served from /static/fonts (fonts/LICENSE.txt). */
@font-face {
  font-family: "Fredoka"; src: url("/static/fonts/fredoka.woff2") format("woff2");
  font-weight: 300 700; font-display: swap;
}
@font-face {
  font-family: "Nunito"; src: url("/static/fonts/nunito.woff2") format("woff2");
  font-weight: 400 900; font-display: swap;
}
:root {
  color-scheme: dark;
  --bg: #15142a;
  --surface: #221f42;       /* cards */
  --surface-2: #1b1935;     /* tab bar, inputs, inset panels */
  --raised: #2e2a58;        /* chips, pressed states */
  --text: #f4f1ff;
  --text-2: #d9d4f2;
  --muted: #b4aed6;
  --faint: #5e5888;
  --grid: #34306a;          /* card borders, dividers, chart grid */
  --axis: #4a4580;
  --border: #34306a;
  --accent: #ffc247;        /* gold: primary actions, XP, the active tab */
  --accent-ink: #15142a;
  --accent-soft: #3a3358;
  --mint: #46e0a0;          /* calories left, done */
  --ember: #ff8a3d;         /* exercise, streak */
  --ember-ink: #ffb054;
  --series-1: #4c94ec;      /* protein, weight line, calorie bars */
  --series-2: #e56b36;      /* carbs */
  --series-3: #22a877;      /* fat */
  --good: #46e0a0;
  --good-ink: #46e0a0;
  --warn-ink: #ffc247;
  --warn-soft: #3a3020;
  --critical: #ff6b6b;
  --critical-ink: #ff9090;
  --reward: #ffc247;
  --radius: 20px;
  --shadow: none;
  --display: "Fredoka", "Nunito", system-ui, sans-serif;
  font-family: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0; background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.45; font-weight: 600;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}
h1, h2, .display { font-family: var(--display); font-weight: 600; }
h1 { font-size: 1.5rem; margin: 0; line-height: 1.2; }
h2 { font-size: 1.1rem; margin: 0; }
h3 { font-size: 0.75rem; margin: 18px 0 6px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 800; }
p { margin: 8px 0; }
a { color: var(--accent); }
strong, b { font-weight: 800; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.hidden { visibility: hidden; }

/* ---- layout ------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--bg);
}
.brand { font-family: var(--display); font-weight: 700; font-size: 1.15rem; color: var(--accent); text-decoration: none; }
.chips { display: flex; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 4px 12px; border-radius: 999px;
  background: var(--raised); color: var(--muted); font-weight: 800; font-size: 0.9rem; text-decoration: none;
}
.chip svg { width: 18px; height: 18px; }
.chip.lit { color: var(--ember-ink); }
.chip.lit .flame { fill: var(--ember); stroke: var(--ember-ink); }
.flame { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; }
.chip.level { color: var(--accent); }
main { max-width: 720px; margin: 0 auto; padding: 4px 16px 16px; }
main > div > * + * { margin-top: 12px; }
main > div > h1 { margin-bottom: 4px; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; justify-content: center; align-items: center;
  background: var(--surface-2); border-top: 2px solid #2a2750;
  padding: 6px 8px env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1; max-width: 120px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 4px; min-height: 56px; color: var(--muted); text-decoration: none; font-size: 0.72rem; font-weight: 800;
}
.tabbar a.on { color: var(--accent); }
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a.fab {
  flex: none; width: 60px; height: 60px; min-height: 0; margin: -30px 8px 0; padding: 0; justify-content: center;
  border-radius: 20px; background: var(--accent); color: var(--accent-ink); border: 4px solid var(--bg);
}
.tabbar a.fab svg { width: 28px; height: 28px; stroke-width: 3; }

.card {
  background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.card > * + * { margin-top: 12px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.empty { color: var(--text-2); margin: 4px 0; }

/* ---- controls ----------------------------------------------------------- */
button, input, select { font: inherit; color: inherit; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 8px 18px;
  border-radius: 14px; border: 2px solid var(--axis); background: var(--raised); color: var(--text);
  font-weight: 800; text-decoration: none; cursor: pointer;
}
.btn.primary:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.danger { color: var(--critical-ink); }
.btn.danger:not(.ghost) { border-color: var(--critical); }
.btn.small { min-height: 36px; padding: 4px 12px; font-size: 0.9rem; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: default; }
.link { background: none; border: 0; padding: 4px 0; color: var(--accent); text-decoration: underline; cursor: pointer; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; flex: none;
  border-radius: 50%; border: 0; background: transparent; color: var(--text-2); font-size: 1.4rem;
  text-decoration: none; cursor: pointer;
}
.icon-btn:hover, .btn.ghost:hover { background: var(--accent-soft); }
.icon-btn svg, .btn svg, .pill svg {
  width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.2;
  stroke-linecap: round; stroke-linejoin: round;
}
/* A small rounded secondary action, e.g. "Save as recipe" under a meal. */
.pill {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 4px 14px 4px 10px;
  border-radius: 999px; border: 2px solid var(--grid); background: var(--surface-2); color: var(--muted);
  font: inherit; font-size: 0.85rem; font-weight: 800; cursor: pointer; text-decoration: none;
}
.pill svg { width: 16px; height: 16px; }
.pill:hover { color: var(--accent); border-color: var(--accent); }
.meal > .pill { margin-left: auto; display: flex; width: max-content; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

input[type="text"], input[type="password"], input[type="number"], input[type="search"],
input[type="date"], input[type="time"], select {
  width: 100%; min-height: 44px; padding: 8px 12px; border-radius: 12px;
  border: 2px solid var(--grid); background: var(--surface-2); color: var(--text); font-weight: 700;
}
input:focus, select:focus { border-color: var(--accent); outline: none; }
input::placeholder { color: var(--faint); }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field .label { font-size: 0.85rem; font-weight: 800; color: var(--muted); }
.field .hint { font-size: 0.8rem; color: var(--muted); }
form > * + * { margin-top: 16px; }
.grid2, .grid3 { row-gap: 16px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 600; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }

.status { font-weight: 600; font-size: 0.9rem; }
.status.critical { color: var(--critical-ink); }
.status.good { color: var(--good-ink); }
.status.warn { color: var(--warn-ink); background: var(--warn-soft); padding: 8px 12px; border-radius: 10px; font-weight: 500; }
.badge { flex: none; font-size: 0.7rem; font-weight: 600; color: var(--text-2); border: 1px solid var(--border); border-radius: 999px; padding: 2px 8px; }

/* ---- diary -------------------------------------------------------------- */
.day-nav { display: flex; align-items: center; gap: 2px; }
.day-nav .icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.day-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.day-title h1 { font-size: 1.35rem; }
.day-title .small { line-height: 1.2; }

/* The hero card at the top of the diary: who you are, then today's budget. */
.hero-strip { display: flex; align-items: center; gap: 14px; text-decoration: none; color: inherit; }
.hero-mini {
  width: 72px; height: 72px; flex: none; border-radius: 18px; background: var(--raised);
  border: 3px solid var(--accent); overflow: hidden; display: flex; align-items: flex-end; justify-content: center;
}
.hero-mini svg { width: 64px; height: auto; display: block; margin-bottom: -6px; }
.hero-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.hero-name { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.hero-name strong { font-family: var(--display); font-weight: 600; font-size: 1.1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hero-name span { flex: none; font-weight: 800; font-size: 0.82rem; color: var(--accent); }
.xp-bar { height: 10px; border-radius: 999px; background: var(--bg); overflow: hidden; }
.xp-bar i { display: block; height: 100%; min-width: 6px; border-radius: 999px; background: var(--accent); transition: width 0.5s ease; }

.budget { display: flex; flex-direction: column; gap: 8px; }
.budget-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.eyebrow { font-size: 0.72rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.big-num { font-family: var(--display); font-weight: 700; font-size: 2.6rem; line-height: 1; color: var(--mint); font-variant-numeric: tabular-nums; }
.budget.over .big-num { color: var(--critical); }
.budget-side { text-align: right; font-size: 0.85rem; font-weight: 700; color: var(--muted); line-height: 1.5; }
.earned-kcal { color: var(--ember-ink); }
.budget-bar { display: flex; gap: 2px; height: 16px; padding: 2px; border-radius: 999px; background: var(--bg); }
.budget-bar i { display: block; border-radius: 999px; min-width: 0; transition: flex-grow 0.4s ease; flex-basis: 0; }
.budget-bar .eaten { background: var(--mint); }
.budget.over .budget-bar .eaten { background: var(--critical); }
.budget-bar .earned { background: var(--ember); }
.budget-bar .rest { background: transparent; }

.macro-bar { display: flex; gap: 2px; height: 8px; }
.macro-bar i { border-radius: 4px; min-width: 4px; flex-basis: 0; }
.macro-list { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.85rem; }
.macro-list div { display: flex; align-items: center; gap: 5px; }
.dot { width: 10px; height: 10px; border-radius: 50%; }
.m-protein { background: var(--series-1); }
.m-carbs { background: var(--series-2); }
.m-fat { background: var(--series-3); }

/* Daily quests */
.quests > * + * { margin-top: 10px; }
.quests header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.quests header span { font-size: 0.85rem; font-weight: 800; color: var(--accent); }
.quest { display: flex; align-items: center; gap: 10px; min-height: 28px; font-weight: 700; }
.quest .box {
  width: 24px; height: 24px; flex: none; border-radius: 8px; border: 2px solid var(--faint);
  display: flex; align-items: center; justify-content: center;
}
.quest .box svg { width: 16px; height: 16px; fill: none; stroke: var(--accent-ink); stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; }
.quest.done .box { background: var(--mint); border-color: var(--mint); }
.quest .q-title { flex: 1; min-width: 0; }
.quest.done .q-title { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 2px; }
.quest .q-progress { font-size: 0.82rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.quest .q-progress.warn { color: var(--critical-ink); }
.quests.all-done { border-color: var(--accent); }

.meal header { display: flex; align-items: center; gap: 10px; }
.meal header h2 { flex: 1; }
.meal-kcal { font-weight: 800; font-variant-numeric: tabular-nums; }
.meal.compact { padding-top: 10px; padding-bottom: 10px; }
.meal.compact .entries { display: none; }
.meal-empty { display: flex; align-items: center; gap: 4px; }
.meal-empty .add-meal {
  flex: 1; min-height: 52px; border-radius: var(--radius); border: 2px dashed var(--faint); background: transparent;
  color: var(--accent); font-weight: 800; font-size: 0.95rem; display: flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none;
}
.meal-empty .add-meal svg, .btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; }
.meal-empty .copy { flex: none; padding: 0 12px; min-height: 52px; font-size: 0.85rem; color: var(--muted); }
.add-btn { color: var(--accent); background: var(--raised); border-radius: 12px; width: 40px; height: 40px; }
.add-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; }
.hero-card-day > * + * { margin-top: 16px; }
.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;
}
.entries { list-style: none; margin: 8px -8px 0; padding: 0; }
.entries li { display: flex; align-items: center; border-top: 2px solid var(--surface-2); }
.entries li > button:first-child {
  flex: 1; min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 52px; padding: 8px; background: none; border: 0; text-align: left; cursor: pointer; border-radius: 8px;
}
.entries li > button:first-child:hover { background: var(--accent-soft); }
.entries.plain li { padding: 8px; gap: 12px; justify-content: space-between; }
.e-main { display: flex; flex-direction: column; min-width: 0; }
.e-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.e-kcal { font-weight: 700; font-variant-numeric: tabular-nums; }
.row-actions { display: flex; flex: none; }
.weigh h2 { flex: 1; min-width: 0; }
.weigh input[type="number"] { width: 96px; }
.weigh input[type="date"] { width: auto; flex: 1; min-width: 140px; }
.banner { border-color: var(--accent); background: var(--accent-soft); }

/* ---- add food ----------------------------------------------------------- */
.searchbar input { flex: 1; width: auto; }
.tabs, .seg { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 14px; }
.tabs button, .seg button {
  flex: 1; min-height: 38px; border: 0; background: transparent; border-radius: 10px; font-weight: 800;
  color: var(--muted); cursor: pointer; white-space: nowrap; padding: 4px 10px;
}
.tabs button.on, .seg button.on { background: var(--raised); color: var(--accent); }
.seg button { min-height: 32px; font-size: 0.85rem; }
.results > * + * { margin-top: 12px; }
.results .entries { margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.results .entries li:first-child { border-top: 0; }
.results .entries li > button:first-child { padding: 8px 14px; border-radius: 0; }
.amount input { flex: 1; width: auto; min-width: 80px; }
.amount select { flex: 2; width: auto; }
.portion-bar { gap: 8px; }
.facts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; }
.facts div { display: flex; flex-direction: column; background: var(--surface-2); border-radius: 12px; padding: 8px 4px; }
.facts strong { font-size: 1.1rem; }
.scanner { width: 100%; max-height: 50vh; border-radius: 10px; background: #000; object-fit: cover; }

/* ---- sheets, toasts ----------------------------------------------------- */
dialog.sheet {
  width: min(520px, 100%); max-width: 100%; max-height: 92dvh; margin: auto auto 0; padding: 0; border: 0;
  border-radius: 24px 24px 0 0; background: var(--surface); color: var(--text); overflow: auto;
  border-top: 2px solid var(--axis);
}
dialog.sheet::backdrop { background: rgba(8, 7, 20, 0.7); }
dialog.sheet > header { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 8px 0 18px; }
dialog.sheet > header h2 { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.sheet-body { padding: 8px 18px calc(18px + env(safe-area-inset-bottom)); }
.sheet-body > * + * { margin-top: 12px; }
@media (min-width: 620px) { dialog.sheet { margin: auto; border-radius: 18px; } }

.toasts { position: fixed; left: 0; right: 0; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 2147483647; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast { background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 14px; font-weight: 700; max-width: 480px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45); }
.toast.error { background: var(--critical); color: #15142a; }
.toast.reward { background: var(--reward); color: var(--accent-ink); font-weight: 800; }
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 2147483646; }
.confetti i { position: absolute; top: -12px; width: 8px; height: 14px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { top: 105%; rotate: 540deg; } }

/* ---- progress & rewards ------------------------------------------------- */
.hero { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.hero strong { font-family: var(--display); font-weight: 700; font-size: 2rem; line-height: 1.1; }
.card h3 { border-top: 2px solid var(--surface-2); padding-top: 16px; }
.card > h3:first-child { border-top: 0; padding-top: 0; }
.meter { height: 12px; background: var(--bg); border-radius: 6px; overflow: hidden; }
.meter i { display: block; height: 100%; min-width: 4px; background: var(--accent); border-radius: 6px; }
.meter.thin { height: 6px; margin: 4px 0 2px; }
.meal .meter.thin i { background: var(--ember); }
.meal-kcal.burn { color: var(--ember-ink); }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tile { display: flex; flex-direction: column; background: var(--surface-2); border-radius: 14px; padding: 10px 12px; min-width: 0; }
.tile strong { font-family: var(--display); font-weight: 600; font-size: 1.4rem; color: var(--accent); }

.chart-wrap { position: relative; }
.chart { display: block; width: 100%; height: auto; touch-action: pan-y; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.chart .line { stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }
.chart .bar { fill: var(--series-1); }
.chart .bar.over { fill: var(--critical); }
.chart .bar.dim { opacity: 0.45; }
.chart .target-line { stroke: var(--text-2); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart .cursor { stroke: var(--axis); stroke-width: 1; }
.tip {
  position: absolute; top: 0; transform: translateX(-50%); pointer-events: none; white-space: nowrap;
  display: flex; flex-direction: column; background: var(--text); color: var(--bg); border-radius: 8px;
  padding: 6px 10px; font-size: 0.8rem; line-height: 1.35;
}
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.8rem; color: var(--text-2); margin-top: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.key { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.key.bar { background: var(--series-1); }
.key.bar.over { background: var(--critical); }
.key.target { height: 0; width: 16px; border-radius: 0; border-top: 2px dashed var(--text-2); }
details summary { cursor: pointer; color: var(--accent); font-weight: 600; min-height: 36px; display: flex; align-items: center; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
td, th { padding: 6px 4px; border-top: 1px solid var(--grid); text-align: left; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.freezes { font-weight: 800; color: var(--series-1); }
.streak-head { align-items: center; }
.streak-head svg { width: 30px; height: 30px; align-self: center; }
.streak-head strong { font-family: var(--display); font-size: 2.2rem; font-weight: 700; }
.streak-head .flame { stroke: var(--muted); }
.streak-head.lit .flame { fill: var(--ember); stroke: var(--ember-ink); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-grid.head { font-size: 0.75rem; color: var(--muted); text-align: center; margin-bottom: 4px; }
.cal {
  aspect-ratio: 1; max-height: 44px; display: flex; align-items: center; justify-content: center; border-radius: 10px;
  font-size: 0.85rem; font-weight: 600; text-decoration: none; color: var(--muted); border: 1px solid var(--grid);
}
.cal.logged { background: var(--raised); border-color: var(--accent); color: var(--accent); }
.cal.frozen { background: var(--surface-2); border-color: var(--series-1); color: var(--series-1); }
.cal.future { border-style: dashed; opacity: 0.5; }
.cal.today { outline: 3px solid var(--ember); outline-offset: 2px; }
.key.cal { aspect-ratio: auto; border-radius: 3px; }
.key.cal.missed { background: transparent; }

.achs { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; }
.ach { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border-radius: 16px; background: var(--surface-2); border: 2px solid transparent; }
.ach > div { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.ach-icon {
  width: 48px; height: 48px; flex: none; border-radius: 50%; background: var(--bg); border: 2px solid var(--grid);
  display: flex; align-items: center; justify-content: center; font-size: 1.5rem; line-height: 1; filter: grayscale(1); opacity: 0.55;
}
.ach.done { border-color: var(--accent); }
.ach.done .ach-icon { border-color: var(--accent); background: var(--raised); }
.ach.done .ach-icon { filter: none; opacity: 1; }
.earned { color: var(--good-ink); font-weight: 600; }

/* ---- hero, monsters, boss fights ------------------------------------------ */
.hero-row { display: flex; gap: 16px; align-items: center; }
.hero-frame { width: 112px; flex: none; background: var(--raised); border-radius: 14px; padding: 6px; }
.hero-frame svg, .fighter svg, .trophy svg { display: block; width: 100%; height: auto; }
.hero-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
/* The hero is drawn in flat colours with one dark outline, cartoon style. */
.ol { stroke: #2b2118; stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.ol-thin { stroke: #2b2118; stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.hero-ol { stroke: #2b2118; stroke-linecap: round; }
.hero-skin { fill: #f6cfa3; }
.hero-skin-line { stroke: #f6cfa3; stroke-linecap: round; }
.hero-nose { fill: #eeb27f; }
.hero-body { fill: var(--series-1); }
.hero-sleeve { stroke: var(--series-1); stroke-linecap: round; }
.hero-hem { stroke: #2b2118; stroke-width: 1.6; opacity: 0.45; stroke-linecap: round; }
.hero-rope { stroke: #8a5a2b; stroke-width: 3; stroke-linecap: round; }
.hero-trouser { stroke: #4b5a74; stroke-linecap: round; }
.hero-boot, .hero-belt { fill: #7a4a22; }
.hero-boot-cuff { fill: #a8703a; }
.hero-gold { fill: #f2b21b; }
.hero-steel-fill { fill: #cfd8e0; }
.hero-rivets { stroke: #2b2118; stroke-width: 3; stroke-linecap: round; opacity: 0.6; }
.hero-fuller { stroke: #ffffff; stroke-width: 1.6; stroke-linecap: round; opacity: 0.7; }
.hero-wood-fill { fill: #b9843f; }
.hero-wood-line { stroke: #8a5a2b; stroke-linecap: round; }
.hero-ivory { fill: #f4ecd8; }
.hero-hair { fill: #6b3f1d; }
.hero-band, .hero-cape { fill: #d94040; }
.hero-shield { fill: #2f9e6e; }
.hero-shield-mark { stroke: #ffffff; stroke-width: 3.5; stroke-linecap: round; }
.hero-white { fill: #ffffff; }
.hero-dark { fill: #2b2118; }
.hero-brow { stroke: #2b2118; stroke-width: 2.6; stroke-linecap: round; }
.hero-brow.thin { stroke-width: 1.6; }
.monster > :not([opacity]):not([stroke]) { stroke: #2b2118; stroke-width: 2.2; stroke-linejoin: round; paint-order: stroke; }
.hero-aura { fill: #eda100; opacity: 0.22; animation: aura 2.4s ease-in-out infinite alternate; }
@keyframes aura { to { opacity: 0.4; } }
.meter.hp i { background: var(--critical); transition: width 0.3s ease; }
.trophies { display: flex; gap: 8px; flex-wrap: wrap; }
.trophy { width: 56px; height: 56px; padding: 6px; border-radius: 12px; border: 2px solid var(--border); background: var(--raised); cursor: pointer; }

.fight-name, .fight-result { display: flex; flex-direction: column; align-items: center; text-align: center; }
.fight-result { min-height: 3.2em; }
.fight-result strong { font-size: 1.25rem; }
.arena { position: relative; display: flex; justify-content: space-between; align-items: flex-end; height: 170px; padding: 0 4px; overflow: hidden; }
.fighter { width: 116px; transition: transform 0.25s ease; }
.hero-side.lunge { transform: translateX(72px) rotate(8deg); }
.monster-side.hit { animation: shake 0.3s; }
.monster-side.beaten { transition: transform 0.8s ease-in, opacity 0.8s; transform: translateY(46px) rotate(70deg) scale(0.6); opacity: 0; }
.slash { position: absolute; right: 86px; top: 44px; font-size: 3rem; opacity: 0; transform: scale(0.4); transition: opacity 0.1s, transform 0.1s; }
.slash.show { opacity: 1; transform: scale(1.2); }
@keyframes shake { 25% { transform: translateX(10px) rotate(4deg); } 50% { transform: translateX(-6px); } 75% { transform: translateX(8px) rotate(-3deg); } }
@media (prefers-reduced-motion: reduce) { .hero-aura { animation: none; } .fighter, .monster-side.beaten { transition: none; } }

.stack > * + * { margin-top: 10px; }
.badge.recipe { color: var(--accent); border-color: var(--accent); }
.recipes-head { color: var(--accent); }
.items { list-style: none; margin: 0; padding: 0; }
.items li { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 8px 0; border-top: 1px solid var(--grid); }
.items li:first-child { border-top: 0; }
.recipe-total { display: flex; justify-content: space-between; border-top: 2px solid var(--axis); padding-top: 8px; }
.meal > .link { display: block; }
.tabs { overflow-x: auto; }
.tabs button { padding: 4px 6px; font-size: 0.9rem; }
.qr { display: block; width: min(240px, 80%); height: auto; margin: 0 auto; border-radius: 8px; }
.secret { font-family: ui-monospace, Consolas, monospace; font-size: 1.05rem; text-align: center; word-spacing: 0.3em; user-select: all; overflow-wrap: anywhere; }
.codes { list-style: none; margin: 0; padding: 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; background: var(--bg); border-radius: 10px; font-family: ui-monospace, Consolas, monospace; font-size: 1.05rem; text-align: center; user-select: all; }

/* ---- the hero exercising ---------------------------------------------------
   hero.js tags the parts (.hero-all, .leg-a/.leg-b, .arm-front/.arm-back);
   each .ex-<name> below sets the pose and the motion. Angles: the hero faces
   right; a negative leg angle swings the foot forward, a negative front-arm
   angle (positive back-arm angle) raises that arm. */
.ex-figure { width: 150px; margin: 0 auto; background: var(--raised); border-radius: 14px; padding: 6px; }
.ex-figure svg { display: block; width: 100%; height: auto; overflow: hidden; }
.exercising .hero-gear { display: none; }
.ex-ground { stroke: var(--axis); stroke-width: 2; stroke-linecap: round; }
.ex-mat { fill: var(--series-3); opacity: 0.6; }
.ex-prop { stroke: var(--text-2); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.ex-water { fill: var(--series-1); opacity: 0.35; }
.ex-ball { fill: var(--series-2); }
.exercising .hero-all { transform-origin: 60px 108px; animation: ex-body var(--t, 0.5s) ease-in-out infinite alternate; }
.exercising .hero-leg, .exercising .hero-arm { animation: ex-swing var(--t, 0.5s) ease-in-out infinite alternate; }
@keyframes ex-body { from { transform: var(--from, none); } to { transform: var(--to, none); } }
@keyframes ex-swing { from { transform: rotate(var(--a, 0deg)); } to { transform: rotate(var(--b, 0deg)); } }
@keyframes ex-spin { to { transform: rotate(360deg); } }
@keyframes ex-squash { from { transform: scaleY(1); } to { transform: scaleY(0.58); } }

/* on foot */
.ex-walk, .ex-walk-fast, .ex-hike, .ex-elliptical, .ex-stairs { --to: translateY(-2px); }
.ex-walk .leg-a, .ex-hike .leg-a, .ex-elliptical .leg-a, .ex-stairs .leg-a { --a: -24deg; --b: 24deg; }
.ex-walk .leg-b, .ex-hike .leg-b, .ex-elliptical .leg-b, .ex-stairs .leg-b { --a: 24deg; --b: -24deg; }
.ex-walk .arm-front, .ex-hike .arm-front { --a: 30deg; --b: -15deg; }
.ex-walk .arm-back, .ex-hike .arm-back { --a: -30deg; --b: 15deg; }
.ex-walk-fast { --t: 0.32s; }
.ex-walk-fast .leg-a { --a: -32deg; --b: 32deg; }
.ex-walk-fast .leg-b { --a: 32deg; --b: -32deg; }
.ex-walk-fast .arm-front { --a: 40deg; --b: -45deg; }
.ex-walk-fast .arm-back { --a: -40deg; --b: 45deg; }
.ex-hike { --t: 0.65s; --from: rotate(5deg); --to: rotate(5deg) translateY(-2px); }
.ex-elliptical { --t: 0.42s; }
.ex-elliptical .arm-front { --a: 20deg; --b: -70deg; }
.ex-elliptical .arm-back { --a: 40deg; --b: -20deg; }
.ex-stairs { --t: 0.45s; --from: translate(-6px, 4px); --to: translate(4px, -8px); }
.ex-stairs .leg-a { --a: -55deg; --b: 10deg; }
.ex-stairs .leg-b { --a: 10deg; --b: -55deg; }
.ex-run, .ex-sports { --t: 0.26s; --from: rotate(10deg); --to: rotate(10deg) translateY(-6px); }
.ex-run .leg-a, .ex-sports .leg-a { --a: -48deg; --b: 40deg; }
.ex-run .leg-b, .ex-sports .leg-b { --a: 40deg; --b: -48deg; }
.ex-run .arm-front, .ex-sports .arm-front { --a: 35deg; --b: -75deg; }
.ex-run .arm-back, .ex-sports .arm-back { --a: -45deg; --b: 55deg; }
.ex-sports .ex-ball { animation: ex-body 0.26s ease-in infinite alternate; --from: translateY(-46px); --to: translateY(4px); }

/* machines and water */
.ex-cycle { --t: 0.4s; --from: translate(-2px, -20px) rotate(16deg); --to: translate(-2px, -21px) rotate(16deg); }
.ex-cycle .leg-a { --a: -62deg; --b: -8deg; }
.ex-cycle .leg-b { --a: -8deg; --b: -62deg; }
.ex-cycle .arm-front { --a: -10deg; --b: -10deg; }
.ex-cycle .arm-back { --a: -100deg; --b: -100deg; }
.ex-wheel { fill: none; stroke-dasharray: 8 5; transform-box: fill-box; transform-origin: center; animation: ex-spin 0.8s linear infinite; }
.ex-swim { --t: 0.9s; --from: translate(-20px, -34px) rotate(84deg) scale(0.8); --to: translate(-20px, -30px) rotate(88deg) scale(0.8); }
.ex-swim .hero-arm { animation: ex-spin 1.1s linear infinite; }
.ex-swim .arm-back { animation-delay: -0.55s; }
.ex-swim .hero-leg { --t: 0.18s; }
.ex-swim .leg-a { --a: -16deg; --b: 16deg; }
.ex-swim .leg-b { --a: 16deg; --b: -16deg; }
.ex-row { --t: 0.8s; --from: translate(-14px, 22px) rotate(20deg); --to: translate(2px, 22px) rotate(-14deg); }
.ex-row .leg-a, .ex-row .leg-b { --a: -62deg; --b: -84deg; }
.ex-row .arm-front { --a: -30deg; --b: 25deg; }
.ex-row .arm-back { --a: -110deg; --b: -70deg; }

/* jumping about */
.ex-jumprope { --t: 0.24s; --to: translateY(-12px); }
.ex-jumprope .arm-front { --a: 15deg; --b: 5deg; }
.ex-jumprope .arm-back { --a: -15deg; --b: -5deg; }
.ex-rope { transform-box: fill-box; transform-origin: center; animation: ex-body 0.24s ease-in-out infinite alternate; --from: scaleY(1); --to: scaleY(0.12); }
.ex-jacks { --t: 0.34s; --to: translateY(-8px); }
.ex-jacks .leg-a { --b: 20deg; }
.ex-jacks .leg-b { --b: -20deg; }
.ex-jacks .arm-front { --a: 15deg; --b: -125deg; }
.ex-jacks .arm-back { --a: -15deg; --b: 125deg; }
.ex-dance { --t: 0.42s; --from: translateX(-5px) rotate(-8deg); --to: translateX(5px) rotate(8deg); }
.ex-dance .leg-a { --a: -14deg; --b: 8deg; }
.ex-dance .leg-b { --a: 8deg; --b: -14deg; }
.ex-dance .arm-front { --a: -95deg; --b: -140deg; }
.ex-dance .arm-back { --a: 140deg; --b: 95deg; }
.ex-burpee .hero-all { animation: ex-burpee 2.2s ease-in-out infinite; }
.ex-burpee .hero-leg { animation: none; }
.ex-burpee .hero-arm { animation: none; }
@keyframes ex-burpee {
  0%, 100% { transform: none; }
  18% { transform: translateY(13px); }
  40%, 55% { transform: translate(-20px, 16px) rotate(80deg) scale(0.8); }
  72% { transform: translateY(13px); }
  86% { transform: translateY(-16px); }
}

/* strength */
.ex-squat { --t: 0.75s; --to: translateY(13px); }
.ex-squat .hero-leg { animation-name: ex-squash; }
.ex-squat .arm-front { --a: -50deg; --b: -50deg; }
.ex-squat .arm-back { --a: -85deg; --b: -85deg; }
.ex-lunge { --t: 0.8s; --to: translateY(9px); }
.ex-lunge .leg-a { --b: 38deg; }
.ex-lunge .leg-b { --b: -38deg; }
.ex-weights { --t: 0.8s; }
.ex-weights .arm-front { --a: 20deg; --b: -80deg; }
.ex-weights .arm-back { --a: -20deg; --b: 80deg; }
.ex-pullup { --t: 0.9s; --from: translateY(6px); --to: translateY(-12px); }
.ex-pullup .arm-front { --a: -125deg; --b: -105deg; }
.ex-pullup .arm-back { --a: 125deg; --b: 105deg; }
.ex-pullup .ex-ground { display: none; }
.ex-pushup { --t: 0.7s; --from: translate(-20px, 10px) rotate(74deg) scale(0.8); --to: translate(-20px, 19px) rotate(83deg) scale(0.8); }
.ex-plank { --t: 0.12s; --from: translate(-20px, 14px) rotate(79deg) scale(0.8); --to: translate(-20px, 14.6px) rotate(79deg) scale(0.8); }
.ex-pushup .arm-front, .ex-plank .arm-front { --a: -37deg; --b: -37deg; }
.ex-pushup .arm-back, .ex-plank .arm-back { --a: -108deg; --b: -108deg; }
.ex-situp { --t: 0.9s; --from: translate(22px, 16px) rotate(-84deg) scale(0.8); --to: translate(22px, 16px) rotate(-24deg) scale(0.8); }
.ex-situp .leg-a, .ex-situp .leg-b { --a: 40deg; --b: -40deg; }
.ex-situp .arm-front { --a: -150deg; --b: -150deg; }
.ex-situp .arm-back { --a: 150deg; --b: 150deg; }

/* slow */
.ex-yoga { --t: 2.2s; --from: scale(1); --to: scale(1.03); }
.ex-yoga .leg-b { --a: -52deg; --b: -52deg; }
.ex-yoga .arm-front { --a: -118deg; --b: -124deg; }
.ex-yoga .arm-back { --a: 118deg; --b: 124deg; }
.ex-stretch { --t: 1.6s; --from: rotate(-15deg); --to: rotate(15deg); }
.ex-stretch .arm-front { --a: -125deg; --b: -125deg; }
.ex-stretch .arm-back { --a: -10deg; --b: -10deg; }
.ex-estimate { text-align: center; }
.info { background: var(--surface-2); border: 2px solid var(--grid); border-radius: 14px; padding: 10px 12px; }
.guide { margin: 0; padding-left: 22px; }
.guide li { margin: 8px 0; }
.secret.left { text-align: left; flex: 1; min-width: 0; font-size: 0.85rem; background: var(--bg); padding: 8px; border-radius: 8px; word-spacing: 0; }
@media (prefers-reduced-motion: reduce) {
  .exercising .hero-all, .exercising .hero-leg, .exercising .hero-arm, .ex-wheel, .ex-rope, .ex-ball { animation: none !important; }
}

/* ---- sign-in ------------------------------------------------------------ */
body.login { padding: 0; }
body.login main { max-width: 400px; min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; align-items: stretch; text-align: center; gap: 12px; }
body.login img { align-self: center; border-radius: 18px; }
body.login form { text-align: left; }
body.login .link { display: block; margin-left: auto; margin-right: auto; }

@media (max-width: 420px) {
  .summary { justify-content: center; }
  .facts strong { font-size: 1rem; }
  .tile strong { font-size: 1.1rem; }
}
@media (prefers-reduced-motion: reduce) { .ring-fill { transition: none; } }

/* ---- Hall of Heroes (hall.js) ------------------------------------------ */
.hall-link { display: flex; align-items: center; gap: 14px; text-decoration: none; color: inherit; }
.hall-link:hover { border-color: var(--accent); }
.hall-link .e-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.hall-link strong { font-family: var(--display); font-weight: 600; font-size: 1.15rem; }
.hall-link svg { width: 20px; height: 20px; color: var(--muted); flex: none; }
.hall-link-icon { width: 48px; height: 48px; flex: none; display: grid; place-items: center; font-size: 1.6rem;
  border-radius: 50%; background: var(--raised); border: 2px solid var(--accent); }
.hall-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.hall-list > li { margin: 0; }
.hall-trophy.final { border-color: var(--accent); }
.victory-frame { border-radius: 16px; padding: 10px 8px 0; overflow: hidden;
  background: linear-gradient(180deg, var(--raised), var(--surface-2)); }
.victory { display: block; width: 100%; height: auto; }
.v-glow { fill: var(--accent); opacity: 0.13; }
.v-ground { fill: #000; opacity: 0.28; }
.v-star { fill: var(--accent); }
.triumph .arm-front { transform: rotate(-32deg); }
.victory .monster > :not([opacity]):not([stroke]) { stroke: #2b2118; stroke-width: 2.2; stroke-linejoin: round; paint-order: stroke; }
.hall-plaque { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; margin-top: 14px; }
.hall-plaque strong { font-family: var(--display); font-weight: 600; font-size: 1.35rem; }
.hall-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 8px; margin: 14px 0; }
.hall-facts > div { background: var(--surface-2); border-radius: 12px; padding: 8px 10px; text-align: center; min-width: 0; }
.hall-facts dt { color: var(--muted); font-size: 0.78rem; }
.hall-facts dd { margin: 2px 0 0; font-weight: 800; }
.hall-trophy > .pill { display: flex; margin: 0 auto; }
.hall-empty { text-align: center; }
.hall-empty .hero-frame { margin: 0 auto 10px; }
.hall-ahead { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 12px 8px; }
.hall-ahead li { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; min-width: 0; }
.ahead-frame { width: 64px; padding: 6px; border-radius: 12px; background: var(--raised); }
.ahead-frame svg { display: block; width: 100%; height: auto; }
.ahead-frame.unknown svg { filter: brightness(0); opacity: 0.5; }
.hall-records { grid-template-columns: repeat(2, 1fr); }
.hall-records .tile strong { font-size: 1.25rem; }

/* ---- meal ideas (ideas.js) ---------------------------------------------- */
.idea-styles { display: flex; flex-wrap: wrap; gap: 8px; }
.idea-styles .pill { padding: 4px 14px; }
.pill.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.idea-list > * + * { margin-top: 12px; }
.idea h3 { margin: 0; padding: 0; border: 0; font-size: 1.1rem; text-transform: none; letter-spacing: 0; color: var(--text); }
.idea-total { display: block; }
.idea-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.badge.new { color: var(--accent); border-color: var(--accent); }
.idea p { margin-top: 4px; }
.idea .items li > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.nowrap { white-space: nowrap; }
