:root {
  --bg: #f4f6fb;
  --bg-grad: radial-gradient(1200px 600px at 10% -10%, #d6e8ff 0%, transparent 60%),
             radial-gradient(900px 500px at 110% 0%, #d3f0f8 0%, transparent 55%);
  --card: #ffffff;
  --text: #161b2e;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-2: #0284c7;
  --spartan: #d92638;
  --border: #e4e7ef;
  --error: #dc2626;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 8px 24px rgba(16, 24, 40, 0.06);
  --kcal: #f97316;
  --protein: #16a34a;
  --carbs: #ca8a04;
  --water: #06b6d4;
  --fat: #db2777;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0d14;
    --bg-grad: radial-gradient(1200px 600px at 10% -10%, #10264d 0%, transparent 60%),
               radial-gradient(900px 500px at 110% 0%, #0a3547 0%, transparent 55%);
    --card: #151824;
    --text: #e7e9f3;
    --muted: #98a2b3;
    --accent: #3b82f6;
    --accent-2: #0284c7;
  --spartan: #d92638;
    --border: #262b3b;
    --error: #f87171;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}

/* Explicit dark theme, for when the toggle forces it over a light system setting. */
:root[data-theme="dark"] {
  --bg: #0b0d14;
  --bg-grad: radial-gradient(1200px 600px at 10% -10%, #10264d 0%, transparent 60%),
             radial-gradient(900px 500px at 110% 0%, #0a3547 0%, transparent 55%);
  --card: #151824;
  --text: #e7e9f3;
  --muted: #98a2b3;
  --accent: #3b82f6;
  --accent-2: #0284c7;
  --spartan: #d92638;
  --border: #262b3b;
  --error: #f87171;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
/* Native controls (date picker, scrollbars, select) follow the chosen theme. */
:root { color-scheme: light dark; }
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

[hidden] { display: none !important; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; height: 100%; }

body {
  margin: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  background: var(--bg-grad) fixed, var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ---------- App shell ----------
   Phones: the shell fills the screen. It is a column: top bar, scrolling content,
   input bar. Only the chat scrolls, so the input bar never jumps. */
.shell {
  width: 100%;
  max-width: 920px;
  height: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}

/* Desktop and large tablets: a centered, rounded app window. */
@media (min-width: 900px) and (min-height: 560px) {
  body { padding: 24px; }
  .shell {
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 24px;
    background: color-mix(in srgb, var(--card) 72%, transparent);
    -webkit-backdrop-filter: blur(3px); /* light blur: the particles stay visible through the window */
    backdrop-filter: blur(3px);
    box-shadow: var(--shadow);
  }
}
@media (min-width: 1400px) {
  .shell { max-width: 1040px; }
}
/* While loading, the desktop window shrinks to a compact, centered panel. */
@media (min-width: 900px) and (min-height: 560px) {
  body[data-view="loading"] { display: grid; place-items: center; }
  body[data-view="loading"] .shell { height: auto; max-width: 460px; }
  body[data-view="loading"] .center { padding: 48px 0; }
}

/* ---------- Top bar ---------- */
.topbar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-text { min-width: 0; }
.logo img { width: 100%; height: 100%; display: block; filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.35)); }
.logo {
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
}
h1 { font-size: 1.25rem; margin: 0; letter-spacing: -0.01em; }
.topbar p { margin: 2px 0 0; color: var(--muted); font-size: 0.85rem; }

.center { flex: 1; display: grid; place-items: center; }
.muted { color: var(--muted); font-size: 0.85rem; }
.error { color: var(--error); }

/* ---------- Login ---------- */
.login-view {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
}
.card {
  /* 10% see-through, so the particle network shows faintly behind the content */
  background: color-mix(in srgb, var(--card) 90%, transparent);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.login-card {
  width: 100%;
  max-width: 380px;
  margin: auto; /* centers on both axes, and stays reachable when the keyboard shrinks the screen */
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-card h2 { margin: 0 0 4px; font-size: 1.2rem; }
.login-card .error { margin: 0; }
.login-card .error:empty { display: none; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 0.875rem; color: var(--muted); }
.field input { width: 100%; }

/* ---------- Chat ---------- */
.app-view { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
}
.log:empty { justify-content: center; align-items: center; }
.log:empty::before {
  content: "Describe what you ate and I'll estimate the calories and macros.";
  max-width: 360px;
  padding: 96px 24px 28px;
  background: url(/avatars/bowl.svg) no-repeat center 22px / 52px 52px;
  text-align: center;
  line-height: 1.5;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: 16px;
}

.msg {
  align-self: flex-start;
  width: 100%;
  max-width: 620px;
  padding: 14px 16px;
  background: color-mix(in srgb, var(--card) 90%, transparent);
  border: 1px solid var(--border);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow);
  overflow-wrap: anywhere;
  animation: rise 0.25s ease-out;
}
.msg.muted { width: auto; }
.msg strong { display: block; font-size: 1.02rem; margin-bottom: 4px; }
.msg.user {
  align-self: flex-end;
  width: auto;
  max-width: min(85%, 520px);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--on-accent, #fff);
  border: none;
  border-radius: 16px;
  border-bottom-right-radius: 4px;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.25);
}
.msg.error { color: var(--error); border-color: color-mix(in srgb, var(--error) 40%, transparent); }
.items { color: var(--muted); font-size: 0.875rem; margin-bottom: 12px; line-height: 1.5; }

.macros {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 10px 0;
}
.tile {
  min-width: 0;
  border-radius: 12px;
  padding: 10px 6px;
  text-align: center;
  background: color-mix(in srgb, var(--c) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--c) 30%, transparent);
}
.tile .value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--c);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.tile .label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-top: 2px;
}

.actions { display: flex; align-items: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }

/* ---------- Buttons and inputs ---------- */
button {
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  min-height: 44px;
  padding: 9px 18px;
  border-radius: 999px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  transition: transform 0.12s ease, box-shadow 0.2s ease, opacity 0.2s, border-color 0.2s;
}
button.primary {
  border: none;
  color: var(--on-accent, #fff);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}
button.primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 8px 18px rgba(37, 99, 235, 0.35); }
button.ghost { background: transparent; color: var(--muted); padding: 8px 14px; min-height: 40px; flex: none; }
button.ghost:hover:not(:disabled) { color: var(--text); border-color: var(--accent); }
button:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }
button:disabled { opacity: 0.5; cursor: default; }

input {
  font: inherit;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
input[type="date"] { padding: 6px 12px; font-size: 0.85rem; border-radius: 999px; min-height: 40px; }

/* ---------- Input bar ---------- */
.composer {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 20px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--card) 60%, transparent);
}
.date-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chip { width: auto; min-height: 40px; padding: 6px 14px; font-size: 0.82rem; }
.chip:hover:not(:disabled) { border-color: var(--accent); }
.chip.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--on-accent, #fff);
  border-color: transparent;
}
.input-row { display: flex; gap: 10px; align-items: center; }
.input-row input { flex: 1; min-width: 0; }
.input-row button { flex: none; }

/* ---------- Tabs ---------- */
.tabs {
  flex: none;
  display: flex;
  gap: 4px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 1 0 auto;
  min-height: 40px;
  padding: 6px 16px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 0.92rem;
  box-shadow: none;
}
.tab:hover { color: var(--text); }
#account-btn[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.tab[aria-selected="true"] {
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.meals-panel { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.panel {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px;
}
.panel-inner { max-width: 680px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.stack { display: flex; flex-direction: column; gap: 16px; }

/* ---------- Sections, forms and lists ---------- */
.section { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.section h2 { margin: 0; font-size: 1.05rem; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid .span-all { grid-column: 1 / -1; }
.form-grid p { margin: 0; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.form-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.inline-form { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.inline-form .field { width: 170px; }
.inline-form .field.grow { flex: 1; min-width: 150px; width: auto; }

.entries { display: flex; flex-direction: column; }
.entry {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.entry:last-child { border-bottom: none; }
.entries > .muted { margin-bottom: 4px; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.pill {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
}
button.small { min-height: 34px; padding: 4px 12px; font-size: 0.8rem; flex: none; }

/* ---------- Today summary ---------- */
.big-number { font-size: 2rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.big-number .unit { font-size: 0.95rem; font-weight: 500; color: var(--muted); }
.stat-line { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 0.9rem; }
.bar-row { display: flex; flex-direction: column; gap: 6px; }
.bar-head { display: flex; justify-content: space-between; gap: 12px; font-size: 0.9rem; }
.bar-value { color: var(--muted); font-variant-numeric: tabular-nums; }
.bar {
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: color-mix(in srgb, var(--c) 16%, transparent);
}
.bar > span { display: block; height: 100%; width: var(--pct, 0%); background: var(--c); border-radius: 999px; transition: width 0.4s ease; }

/* ---------- Top bar actions, selects, user management ---------- */
.topbar-actions { display: flex; align-items: center; gap: 8px; flex: none; }
button.icon-only { width: 40px; min-width: 40px; padding: 0; display: grid; place-items: center; font-size: 1.05rem; }

select {
  font: inherit;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  width: 100%;
}
select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
select:disabled, input:disabled { opacity: 0.55; cursor: not-allowed; }

.section h3 { margin: 8px 0 0; font-size: 0.95rem; }
.profile { margin: 0; }
.entry { flex-wrap: wrap; }
.entry .grow { flex: 1; min-width: 0; }
.row-actions { display: flex; gap: 8px; flex: none; }
.editor { width: 100%; margin-top: 8px; padding-top: 14px; border-top: 1px dashed var(--border); }
.field.check { flex-direction: row; align-items: center; gap: 10px; align-self: end; min-height: 44px; font-size: 0.9rem; }
.field.check input { width: 18px; min-height: 18px; height: 18px; box-shadow: none; accent-color: var(--accent); }
.pill-accent { background: color-mix(in srgb, var(--accent) 22%, transparent); border-color: var(--accent); }
.pill-warn { background: color-mix(in srgb, var(--error) 14%, transparent); border-color: color-mix(in srgb, var(--error) 45%, transparent); }
button.danger:hover:not(:disabled) { color: var(--error); border-color: var(--error); }

/* ---------- Meal photo ---------- */
.icon-btn {
  flex: none;
  width: 44px;
  min-width: 44px;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: 1.15rem;
}
.photo-preview { display: flex; align-items: center; gap: 12px; }
.photo-preview img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--border);
}
.photo-preview .muted { flex: 1; min-width: 0; }
.msg.user .thumb {
  display: block;
  width: 100%;
  max-width: 260px;
  max-height: 220px;
  object-fit: cover;
  border-radius: 12px;
  margin-bottom: 8px;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Tablets and phones ---------- */
@media (max-width: 640px) {
  .topbar { padding: 12px 16px; }
  .log { padding: 16px; gap: 12px; }
  .composer { padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); }
  .msg { max-width: 100%; }
  .msg.user { max-width: 90%; }
}
@media (max-width: 520px) {
  .topbar p { display: none; }
  .logo { width: 38px; height: 38px; font-size: 20px; }
  .macros { grid-template-columns: repeat(2, 1fr); }
  .tile .value { font-size: 1.05rem; }
  .login-card { padding: 20px; }
  /* Keep Today / Yesterday / date picker on one row to leave more room for the chat. */
  .date-bar { gap: 6px; flex-wrap: nowrap; }
  .date-bar > .muted { display: none; }
  .chip { padding: 6px 12px; flex: none; }
  input[type="date"] { flex: 1 1 0; min-width: 0; padding: 6px 10px; }
}

/* Short screens, such as a phone held sideways. */
@media (max-height: 480px) {
  .topbar { padding: 6px 16px; }
  .topbar p { display: none; }
  .logo { width: 32px; height: 32px; font-size: 17px; }
  .log { padding: 12px 16px; }
  .composer { gap: 6px; padding-top: 8px; }
  .login-view { padding: 12px 16px; }
}
/* Phone held sideways: date controls and the message box share one row. */
@media (max-height: 480px) and (min-width: 600px) {
  .composer { flex-direction: row; align-items: center; gap: 12px; }
  #meal-date, .photo-preview { flex: none; }
  .date-bar { flex: none; }
  .date-bar > .muted { display: none; }
  .input-row { flex: 1; min-width: 0; }
  .panel { padding: 12px 16px; }
}

/* New sections on small screens. */
@media (max-width: 640px) {
  .panel { padding: 16px; }
  .section { padding: 16px; }
}
@media (max-width: 520px) {
  .tab { padding: 6px 10px; font-size: 0.88rem; }
  .grid-3 { gap: 8px; }
  .grid-3 .field { font-size: 0.8rem; }
  .grid-3 input { padding-left: 10px; padding-right: 10px; }
  .inline-form .field { width: 100%; }
  .inline-form button { width: 100%; }
  .big-number { font-size: 1.75rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* AI usage */
.usage-grid { display: grid; grid-template-columns: auto repeat(4, 1fr); gap: 8px 16px; align-items: baseline; margin: 0 0 8px; }
.usage-grid .head { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }
.usage-grid .num { font-variant-numeric: tabular-nums; font-weight: 600; }
.usage-note { margin: 0; }
@media (max-width: 480px) { .usage-grid { gap: 8px 8px; font-size: 0.85rem; } .usage-grid .head { font-size: 0.7rem; letter-spacing: 0; } }

/* ---------- Landing (the signed-out screen) ---------- */
#particles { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; display: none; pointer-events: none; }
body[data-view="login"] #particles, body[data-view="app"] #particles { display: block; }
.shell { position: relative; z-index: 1; }

/* Signed out, the app window disappears and the page itself is the stage. */
body[data-view="login"] .shell {
  max-width: 1120px;
  height: 100%;
  border: none;
  border-radius: 0;
  background: none;
  box-shadow: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  overflow: visible;
}
body[data-view="login"] .topbar { border-bottom: none; justify-content: flex-end; }
body[data-view="login"] .brand { display: none; }

.landing {
  margin: auto;
  width: 100%;
  max-width: 1000px;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 380px);
  gap: 56px;
  align-items: center;
  padding: 8px 0 24px;
}
.hero { display: flex; flex-direction: column; align-items: flex-start; gap: 14px; }
.hero-mark { width: 104px; height: 104px; filter: drop-shadow(0 10px 28px rgba(217, 38, 56, 0.35)) drop-shadow(0 4px 14px rgba(37, 99, 235, 0.35)); }
.eyebrow { margin: 0; display: flex; align-items: center; gap: 10px; text-transform: uppercase; letter-spacing: 0.18em; font-size: 0.75rem; font-weight: 600; color: var(--accent); }
.eyebrow::before { content: ""; width: 28px; height: 2px; background: var(--spartan); box-shadow: 0 0 10px var(--spartan); }
.hero-title { margin: 0; font-size: clamp(3rem, 8vw, 4.8rem); line-height: 1; letter-spacing: -0.04em; font-weight: 800; }
.hero-title span {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-lead { margin: 0; max-width: 36ch; font-size: 1.1rem; line-height: 1.5; color: var(--muted); }

.landing .login-card {
  margin: 0;
  max-width: none;
  background: color-mix(in srgb, var(--card) 78%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

@media (max-width: 899px) {
  .landing { grid-template-columns: minmax(0, 420px); justify-content: center; gap: 28px; text-align: center; }
  /* On a phone the sign-in form comes right after the headline; the rest of the pitch sits below it. */
  .hero { display: contents; }
  .hero > * { justify-self: center; }
  .landing .login-card { order: 4; width: 100%; }
  .hero-mark { width: 76px; height: 76px; }
  .eyebrow { justify-content: center; }
  .landing { gap: 18px; }
}
@media (max-height: 700px) and (min-width: 900px) {
  .hero-mark { width: 64px; height: 64px; }
}
@media (prefers-reduced-motion: no-preference) {
  .hero > *, .landing .login-card { animation: rise 0.7s ease-out both; }
  .hero > :nth-child(2) { animation-delay: 0.05s; }
  .hero > :nth-child(3) { animation-delay: 0.1s; }
  .hero > :nth-child(4) { animation-delay: 0.15s; }
  .landing .login-card { animation-delay: 0.25s; }
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ---------- Today: layout toggle and pie charts ---------- */
.today-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 12px; }
.view-toggle { display: inline-flex; margin-left: auto; gap: 2px; padding: 3px; border: 1px solid var(--border); border-radius: 999px; background: color-mix(in srgb, var(--card) 90%, transparent); }
.view-toggle button { min-height: 34px; padding: 4px 16px; border: none; border-radius: 999px; background: transparent; color: var(--muted); box-shadow: none; font-size: 0.85rem; }
.view-toggle button[aria-pressed="true"] { color: var(--text); background: color-mix(in srgb, var(--accent) 18%, transparent); box-shadow: inset 0 -2px 0 var(--accent); }
.pies { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.pie { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; min-width: 0; }
.pie .muted { font-size: 0.78rem; overflow-wrap: anywhere; }
.pie-label { font-weight: 600; font-size: 0.92rem; margin-top: 4px; }
.pie-chart { position: relative; width: 100%; max-width: 120px; aspect-ratio: 1; }
.pie-chart svg { width: 100%; height: 100%; display: block; }
.pie-track { fill: none; stroke: color-mix(in srgb, var(--muted) 22%, transparent); stroke-width: 5; }
.pie-arc { fill: none; stroke: var(--c); stroke-width: 5; stroke-linecap: round; transition: stroke-dasharray 0.5s ease; }
.pie-arc.over { stroke: var(--error); }
.pie-center { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 700; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
@media (max-width: 560px) { .pies { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 20px; } }

/* =====================================================================
   Material layer (Apple-style glass)
   Principles: translucent layers over a soft colour field, a hairline of light on every edge,
   large soft shadows, generous radii, system typography, segmented controls.
   Blue and Spartan red stay the brand; everything below only changes surfaces and type.
   Note: an element with backdrop-filter becomes the backdrop for its children, so the app window
   blurs the particles once and the cards inside are plain translucent fills.
   ===================================================================== */
:root {
  --bg: #eef2f9;
  --bg-grad: radial-gradient(900px 600px at 8% -8%, rgba(59, 130, 246, 0.30), transparent 60%),
             radial-gradient(800px 560px at 108% 4%, rgba(34, 211, 238, 0.26), transparent 58%),
             radial-gradient(700px 520px at 70% 112%, rgba(217, 38, 56, 0.10), transparent 60%);
  --win: rgba(255, 255, 255, 0.58);
  --win-edge: rgba(255, 255, 255, 0.85);
  --fill: rgba(255, 255, 255, 0.62);
  --fill-edge: rgba(255, 255, 255, 0.9);
  --field: rgba(255, 255, 255, 0.72);
  --seg: rgba(60, 70, 100, 0.10);
  --seg-on: rgba(255, 255, 255, 0.95);
  --stroke: rgba(16, 24, 40, 0.08);
  --lift: 0 1px 1px rgba(16, 24, 40, 0.04), 0 10px 28px -10px rgba(16, 24, 40, 0.16);
  --window-shadow: 0 2px 4px rgba(16, 24, 40, 0.04), 0 30px 70px -20px rgba(30, 58, 138, 0.28);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #07090f;
    --bg-grad: radial-gradient(900px 600px at 8% -8%, rgba(37, 99, 235, 0.40), transparent 60%),
               radial-gradient(800px 560px at 108% 4%, rgba(6, 182, 212, 0.22), transparent 58%),
               radial-gradient(700px 520px at 15% 112%, rgba(217, 38, 56, 0.18), transparent 60%);
    --win: rgba(18, 22, 34, 0.58);
    --win-edge: rgba(255, 255, 255, 0.09);
    --fill: rgba(255, 255, 255, 0.055);
    --fill-edge: rgba(255, 255, 255, 0.10);
    --field: rgba(255, 255, 255, 0.06);
    --seg: rgba(118, 118, 128, 0.24);
    --seg-on: rgba(255, 255, 255, 0.16);
    --stroke: rgba(255, 255, 255, 0.08);
    --lift: 0 10px 30px -12px rgba(0, 0, 0, 0.55);
    --window-shadow: 0 2px 4px rgba(0, 0, 0, 0.3), 0 30px 80px -20px rgba(0, 0, 0, 0.7);
  }
}
:root[data-theme="dark"] {
  --bg: #07090f;
  --bg-grad: radial-gradient(900px 600px at 8% -8%, rgba(37, 99, 235, 0.40), transparent 60%),
             radial-gradient(800px 560px at 108% 4%, rgba(6, 182, 212, 0.22), transparent 58%),
             radial-gradient(700px 520px at 15% 112%, rgba(217, 38, 56, 0.18), transparent 60%);
  --win: rgba(18, 22, 34, 0.58);
  --win-edge: rgba(255, 255, 255, 0.09);
  --fill: rgba(255, 255, 255, 0.055);
  --fill-edge: rgba(255, 255, 255, 0.10);
  --field: rgba(255, 255, 255, 0.06);
  --seg: rgba(118, 118, 128, 0.24);
  --seg-on: rgba(255, 255, 255, 0.16);
  --stroke: rgba(255, 255, 255, 0.08);
  --lift: 0 10px 30px -12px rgba(0, 0, 0, 0.55);
  --window-shadow: 0 2px 4px rgba(0, 0, 0, 0.3), 0 30px 80px -20px rgba(0, 0, 0, 0.7);
}

/* Typography: the system font, which is SF Pro on Apple devices. */
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  letter-spacing: -0.006em;
}
h1, h2, h3, .hero-title, .big-number { letter-spacing: -0.02em; }
.section h2 { font-size: 1.12rem; font-weight: 650; }

/* The app window. */
@media (min-width: 900px) and (min-height: 560px) {
  .shell {
    border: 1px solid var(--win-edge);
    border-radius: 30px;
    background: var(--win);
    -webkit-backdrop-filter: blur(14px) saturate(170%);
    backdrop-filter: blur(14px) saturate(170%);
    box-shadow: inset 0 1px 0 var(--win-edge), var(--window-shadow);
  }
}
.topbar { border-bottom-color: var(--stroke); }
.tabs { border-bottom: none; padding: 4px 16px 10px; }

/* Segmented controls: the tabs and the Detailed / Compact switch. */
.tabs {
  gap: 2px;
  margin: 2px 16px 8px;
  padding: 3px;
  border-radius: 14px;
  background: var(--seg);
}
.tab { border-radius: 11px; min-height: 36px; font-weight: 600; transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease; }
.tab[aria-selected="true"] {
  background: var(--seg-on);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.14), 0 3px 8px rgba(0, 0, 0, 0.08);
}
.view-toggle { padding: 3px; border: none; background: var(--seg); }
.view-toggle button { border-radius: 999px; transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease; }
.view-toggle button[aria-pressed="true"] {
  background: var(--seg-on);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.14), 0 3px 8px rgba(0, 0, 0, 0.08);
}

/* Cards: translucent fill with a hairline of light on top. */
.card, .msg {
  background: var(--fill);
  border: 1px solid var(--fill-edge);
  border-radius: 22px;
  box-shadow: inset 0 1px 0 var(--fill-edge), var(--lift);
}
.msg { border-bottom-left-radius: 8px; }
.msg.user { border: none; border-bottom-right-radius: 8px; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 8px 20px -8px rgba(37, 99, 235, 0.5); }
.section { padding: 20px; gap: 14px; }
.entry { border-bottom-color: var(--stroke); }

/* Phones have no window behind the cards, so each card blurs the background itself. */
@media not all and (min-width: 900px) and (min-height: 560px) {
  .card, .msg:not(.user) {
    -webkit-backdrop-filter: blur(18px) saturate(170%);
    backdrop-filter: blur(18px) saturate(170%);
  }
}

/* Controls. */
button { background: var(--fill); border-color: var(--stroke); box-shadow: inset 0 1px 0 var(--fill-edge); }
button.ghost { background: transparent; border-color: var(--stroke); box-shadow: none; }
button.primary {
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 88%, #fff) 0%, var(--accent) 45%, var(--accent-2) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 8px 18px -6px rgba(37, 99, 235, 0.55);
}
.chip.active {
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 88%, #fff) 0%, var(--accent) 45%, var(--accent-2) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 6px 14px -6px rgba(37, 99, 235, 0.55);
}
input, select { background: var(--field); border-color: var(--stroke); border-radius: 14px; }
input[type="date"] { border-radius: 999px; }
.composer { background: var(--fill); border-top-color: var(--stroke); }

/* Today: bigger numbers, softer bars and rings. */
.big-number { font-size: 2.5rem; font-weight: 700; letter-spacing: -0.035em; }
.big-number .unit { font-size: 1rem; letter-spacing: 0; }
.bar { height: 9px; background: color-mix(in srgb, var(--c) 18%, transparent); }
.bar > span { background: linear-gradient(90deg, color-mix(in srgb, var(--c) 78%, #fff), var(--c)); }
.pies { gap: 18px; }
.pie-chart { max-width: 128px; }
.pie-track { stroke: color-mix(in srgb, var(--muted) 20%, transparent); stroke-width: 4.2; }
.pie-arc { stroke-width: 4.2; filter: drop-shadow(0 0 2.5px color-mix(in srgb, var(--c) 55%, transparent)); }
.pie-center { font-size: 1.2rem; font-weight: 700; letter-spacing: -0.03em; }
.pie-label { font-weight: 650; }

/* Landing: the sign-in card is the glass hero, the pitch floats on the colour field. */
.hero-mark { border-radius: 0; box-shadow: none; }
.hero-title { font-size: clamp(2.6rem, 11vw, 4.4rem); font-weight: 800; letter-spacing: -0.05em; }
.hero-lead { font-size: 1.15rem; line-height: 1.5; max-width: 34ch; }
.landing .login-card {
  padding: 30px 28px;
  gap: 16px;
  background: var(--win);
  border: 1px solid var(--win-edge);
  border-radius: 32px;
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  backdrop-filter: blur(28px) saturate(180%);
  box-shadow: inset 0 1px 0 var(--win-edge), var(--window-shadow);
}
.landing .login-card h2 { font-size: 1.35rem; font-weight: 700; }
.landing .login-card input { min-height: 48px; border-radius: 14px; }
.landing .login-card button.primary { min-height: 50px; font-size: 1rem; }

.tile { border-radius: 16px; }

/* ---------- Shared bits: card headers, key/value rows, stat tiles ---------- */
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-head h2 { margin: 0; }
.stack-sm { display: flex; flex-direction: column; gap: 14px; }
.kv { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--stroke); }
.kv strong { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.stat-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: 12px 14px; border-radius: 16px; background: var(--field); border: 1px solid var(--stroke); }
.stat .label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.stat .value { font-size: 1.3rem; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; color: var(--c, var(--text)); }
.stat .sub-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; min-height: 1.1em; }
.stat .sub { font-size: 0.78rem; color: var(--muted); }
.weight-line { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 14px; }
.delta { font-size: 0.8rem; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.delta.good { color: var(--protein); }
.delta.warn { color: var(--kcal); }

/* Weight trend chart */
.trend svg { display: block; overflow: visible; }
.trend-line { fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.trend-area { fill: url(#trend-fill); }
.trend-stop-top { stop-color: var(--accent); stop-opacity: 0.28; }
.trend-stop-bottom { stop-color: var(--accent); stop-opacity: 0; }
.trend-dot { fill: var(--accent); }
.trend-last { fill: var(--bg); stroke: var(--accent); stroke-width: 2.5; }
.trend-axis { display: flex; justify-content: space-between; gap: 12px; margin-top: 6px; font-size: 0.78rem; }

/* Phones: the Detailed / Compact switch fills the row like an iOS segmented control. */
@media (max-width: 560px) {
  .today-toolbar .view-toggle { width: 100%; margin-left: 0; }
  .today-toolbar .view-toggle button { flex: 1; }
}
#goals-status:empty { display: none; }
#goals-status { margin: 0; }

/* ---------- Neon borders: each tile is outlined in the colour of its metric (Body and Goals) ---------- */
.stat {
  background: var(--field);
  border: 1.5px solid color-mix(in srgb, var(--c, var(--stroke)) 85%, transparent);
  box-shadow: 0 0 14px -4px color-mix(in srgb, var(--c, transparent) 65%, transparent);
}
.stat .value { color: var(--text); text-shadow: none; }

/* Phones: the date row on Today spans the full width, like the switch under it. */
@media (max-width: 560px) {
  .today-toolbar #today-date { flex: 1 1 100%; }
  .today-toolbar .date-bar { width: 100%; }
  .today-toolbar .chip { flex: 1 1 0; }
  .today-toolbar input[type="date"] { flex: 1.5 1 0; }
}

/* ---------- Logo: night and day versions, following the active theme ---------- */
img.logo-light { display: none; }
:root[data-theme="light"] img.logo-dark { display: none; }
:root[data-theme="light"] img.logo-light { display: block; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) img.logo-dark { display: none; }
  :root:not([data-theme="dark"]) img.logo-light { display: block; }
}
.hero-logo { line-height: 0; }

/* ---------- Confirmation dialog ---------- */
dialog.confirm-dialog {
  width: min(92vw, 380px);
  padding: 22px;
  border: 1px solid var(--fill-edge);
  border-radius: 22px;
  background: var(--fill);
  color: var(--text);
  box-shadow: inset 0 1px 0 var(--fill-edge), 0 30px 70px -20px rgba(0, 0, 0, 0.55);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  backdrop-filter: blur(28px) saturate(180%);
}
dialog.confirm-dialog::backdrop { background: rgba(8, 12, 22, 0.45); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
dialog.confirm-dialog[open] { animation: confirm-in 0.16s ease-out; }
dialog.confirm-dialog h2 { margin: 0 0 6px; font-size: 1.1rem; }
dialog.confirm-dialog p { margin: 0 0 4px; line-height: 1.45; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.confirm-actions button { min-width: 92px; }
button.primary.danger-solid {
  background: linear-gradient(180deg, color-mix(in srgb, var(--error) 85%, #fff) 0%, var(--error) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 8px 18px -6px color-mix(in srgb, var(--error) 60%, transparent);
}
@keyframes confirm-in { from { opacity: 0; transform: scale(0.96) translateY(6px); } }
@media (prefers-reduced-motion: reduce) { dialog.confirm-dialog[open] { animation: none; } }

/* ---------- Onboarding wizard and plan ---------- */
dialog.wizard {
  width: min(94vw, 540px);
  max-height: min(92vh, 760px);
  padding: 22px;
  overflow: auto;
  border: 1px solid var(--fill-edge);
  border-radius: 24px;
  background: var(--fill);
  color: var(--text);
  box-shadow: inset 0 1px 0 var(--fill-edge), 0 30px 70px -20px rgba(0, 0, 0, 0.55);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  backdrop-filter: blur(28px) saturate(180%);
}
dialog.wizard::backdrop { background: rgba(8, 12, 22, 0.5); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
dialog.wizard[open] { animation: confirm-in 0.16s ease-out; }
dialog.wizard h2 { margin: 0 0 4px; font-size: 1.25rem; }
dialog.wizard h3 { margin: 0; font-size: 0.95rem; }
.wizard-progress { display: flex; gap: 6px; margin: 8px 0 18px; }
.wizard-progress .dot { height: 4px; flex: 1; border-radius: 4px; background: var(--stroke); transition: background 0.2s; }
.wizard-progress .dot.on { background: var(--accent); }
.wizard-step { display: block; }
.wizard-step[hidden] { display: none; }
.wizard-status { min-height: 1.3em; margin: 12px 0 0; }
.wizard-nav { display: flex; align-items: center; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.wizard-nav .grow { flex: 1; }
.field-label { font-size: 0.875rem; color: var(--muted); }
.field small { font-size: 0.78rem; }

.choices { display: grid; gap: 8px; }
.choice {
  display: flex; align-items: center; gap: 12px; cursor: pointer;
  padding: 12px 14px; border-radius: 16px;
  background: var(--field); border: 1px solid var(--stroke);
  transition: border-color 0.15s, background 0.15s;
}
.choice:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--stroke)); }
.choice input { flex: none; width: 18px; height: 18px; min-height: 0; margin: 0; padding: 0; box-shadow: none; accent-color: var(--accent); }
.choice-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.choice:has(input:checked) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--field));
}
.choice:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.wizard textarea { width: 100%; resize: vertical; min-height: 84px; font: inherit; }

.plan-kcal { display: flex; align-items: baseline; gap: 4px; }
.plan-kcal-number { font-size: 2.6rem; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.plan-notes { margin: 0; padding-left: 1.2em; display: grid; gap: 4px; }
.plan-disclaimer { font-size: 0.8rem; margin: 0; }
.callout {
  margin: 0; padding: 12px 14px; border-radius: 14px; line-height: 1.45;
  background: color-mix(in srgb, var(--spartan, #d92638) 12%, var(--field));
  border: 1px solid color-mix(in srgb, var(--spartan, #d92638) 45%, transparent);
}
@media (max-width: 560px) {
  dialog.wizard { padding: 18px; border-radius: 20px; }
  .wizard-nav { gap: 8px; }
  .wizard-nav button { flex: 1 1 auto; }
  .wizard-nav .grow { display: none; }
}
@media (prefers-reduced-motion: reduce) { dialog.wizard[open] { animation: none; } }
.stack-sm[hidden], .field[hidden], .wizard-step[hidden] { display: none; } /* these set display, which would otherwise beat [hidden] */
.choices.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 380px) { .choices.two { grid-template-columns: 1fr; } }

/* The notes box matches the other fields (the browser's plain white box did not). */
textarea { background: var(--field); border: 1px solid var(--stroke); border-radius: 14px; padding: 10px 14px; color: var(--text); line-height: 1.45; transition: border-color 0.2s, box-shadow 0.2s; }
textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
textarea::placeholder { color: var(--muted); opacity: 0.8; }

/* The wizard keeps its title and buttons in view; only the questions scroll. */
dialog.wizard { overflow: hidden; }
dialog.wizard[open] { display: flex; flex-direction: column; }
dialog.wizard .wizard-form { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 2px 4px 2px 2px; margin: 0 -4px 0 -2px; }
dialog.wizard .wizard-nav { flex: none; }
dialog.wizard .wizard-status { flex: none; }

/* ---------- Language selector ---------- */
.lang-select {
  min-height: 40px;
  width: auto;
  padding: 6px 28px 6px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  cursor: pointer;
  background-color: var(--fill);
  border: 1px solid var(--stroke);
  color: var(--text);
}
@media (max-width: 560px) { .lang-select { padding: 6px 24px 6px 10px; font-size: 0.8rem; } }

/* Phones: with the language selector the top bar is full, so the brand keeps only its mark. */
@media (max-width: 480px) {
  .brand-text { display: none; }
  .topbar-actions { gap: 6px; }
}

/* ---------- Welcome and gentler transitions ---------- */
dialog.wizard[open] { animation: wizard-in 0.5s cubic-bezier(0.2, 0.8, 0.2, 1); }
dialog.wizard[open]::backdrop { animation: backdrop-in 0.5s ease; }
@keyframes wizard-in { from { opacity: 0; transform: translateY(28px) scale(0.95); } }
@keyframes backdrop-in { from { opacity: 0; } }
.wizard-step:not([hidden]) { animation: step-in 0.32s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.wizard-step[data-dir="back"]:not([hidden]) { animation-name: step-in-back; }
@keyframes step-in { from { opacity: 0; transform: translateX(26px); } }
@keyframes step-in-back { from { opacity: 0; transform: translateX(-26px); } }
.wizard-progress .dot { transition: background 0.35s ease; }
dialog.wizard h2[hidden] { display: none; }

.welcome { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 14px; padding-top: 4px; }
.welcome-logo { line-height: 0; }
.welcome-logo img { width: 72px; height: 72px; border-radius: 18px; }
.welcome-title { margin: 0; font-size: 1.5rem; letter-spacing: -0.02em; }
.welcome-lead, .welcome-next { margin: 0; color: var(--muted); line-height: 1.5; }
.welcome-next { font-size: 0.92rem; }
.welcome-list { list-style: none; margin: 4px 0; padding: 0; display: grid; gap: 10px; width: 100%; text-align: left; }
.welcome-list li { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 16px; background: var(--field); border: 1px solid var(--stroke); line-height: 1.45; }
.welcome-list li:nth-child(1) { animation: step-in 0.5s 0.15s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.welcome-list li:nth-child(2) { animation: step-in 0.5s 0.27s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.welcome-list li:nth-child(3) { animation: step-in 0.5s 0.39s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.welcome-list .emoji { font-size: 1.3rem; line-height: 1.25; }
@media (prefers-reduced-motion: reduce) {
  dialog.wizard[open], dialog.wizard[open]::backdrop, .wizard-step:not([hidden]), .welcome-list li { animation: none; }
}

@media (max-width: 560px) {
  .welcome { gap: 10px; padding-top: 0; }
  .welcome-logo img { width: 52px; height: 52px; border-radius: 14px; }
  .welcome-title { font-size: 1.25rem; }
  .welcome-lead { font-size: 0.92rem; }
  .welcome-list { gap: 8px; margin: 2px 0; }
  .welcome-list li { padding: 9px 12px; gap: 10px; font-size: 0.9rem; line-height: 1.38; }
  .welcome-list .emoji { font-size: 1.15rem; }
  .welcome-next { font-size: 0.85rem; line-height: 1.4; }
}

/* Long labels such as "Carbohidratos" must stay inside their box on phones. */
.stat .label, .tile .label { min-width: 0; overflow-wrap: break-word; hyphens: manual; }
@media (max-width: 480px) {
  .stat-grid.three .stat { padding: 10px 8px; }
  .stat-grid.three .label { font-size: 0.66rem; letter-spacing: 0.02em; }
  .stat-grid.three .value { font-size: 1.15rem; }
}

/* ---------- Meal conversation ---------- */
.msg .question { margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: var(--field); border: 1px solid var(--stroke); font-size: 0.94rem; line-height: 1.45; }
.msg.superseded { opacity: 0.55; }
.msg.superseded .actions button { display: none; }
.new-meal { align-self: flex-start; }
.new-meal[hidden] { display: none; }
.meal-extras { display: flex; flex-wrap: wrap; gap: 8px; }
.manual-meal { display: flex; flex-direction: column; gap: 10px; }
.manual-meal p { margin: 0; }
.manual-meal .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.manual-meal .actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

.tab[hidden] { display: none; }

/* ---------- Areas (Nutrition / Gym) ---------- */
.areas { display: flex; gap: 2px; margin: 8px 16px 0; padding: 3px; border-radius: 999px; background: var(--seg); }
.areas button { flex: 1; min-height: 38px; border: none; border-radius: 999px; background: transparent; color: var(--muted); box-shadow: none; font-weight: 700; font-size: 0.92rem; transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease; }
.areas button[aria-pressed="true"] { background: var(--seg-on); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.14), 0 3px 8px rgba(0, 0, 0, 0.08); }

/* ---------- Gym timer ---------- */
.timer-card { align-items: center; text-align: center; gap: 14px; }
.timer-modes { margin: 0 auto; }
.timer-face { --c: var(--accent); position: relative; width: min(72vw, 260px); aspect-ratio: 1; margin: 4px auto; }
.timer-ring, .timer-ring svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.timer-display { position: absolute; inset: 0; display: grid; place-items: center; font-size: clamp(2.4rem, 13vw, 3.6rem); font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.timer-face.running { --c: var(--protein); }
.timer-face.done { --c: var(--error); animation: timer-flash 0.6s ease 3; }
@keyframes timer-flash { 50% { opacity: 0.35; } }
.timer-status { min-height: 1.4em; margin: 0; font-weight: 600; }
.timer-presets { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.timer-custom { display: flex; align-items: flex-end; justify-content: center; gap: 10px; flex-wrap: wrap; }
.timer-custom .field { width: 96px; text-align: left; }
.timer-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.timer-actions .primary { min-width: 140px; min-height: 52px; font-size: 1.05rem; }
.timer-actions button[hidden] { display: none; }
.timer-laps { list-style: none; margin: 0; padding: 0; width: 100%; display: grid; gap: 6px; text-align: left; }
.timer-laps[hidden] { display: none; }
.timer-laps li { display: grid; grid-template-columns: 1fr auto auto; gap: 14px; padding: 8px 12px; border-radius: 12px; background: var(--field); border: 1px solid var(--stroke); font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) { .timer-face.done { animation: none; } }
.timer-ring .pie-track, .timer-ring .pie-arc { stroke-width: 2.2; }
.timer-ring .pie-arc { transition: none; }

.tabs[hidden] { display: none; }

/* ---------- Gym: routine, coach, equipment ---------- */
.stack-lg { display: flex; flex-direction: column; gap: 16px; }
.notice { margin: 0; padding: 10px 14px; border-radius: 12px; background: color-mix(in srgb, var(--protein) 16%, transparent); border: 1px solid color-mix(in srgb, var(--protein) 40%, transparent); font-weight: 600; }
.day-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip.today { box-shadow: inset 0 -3px 0 var(--accent); }
.ex-card { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border-radius: 16px; background: var(--field); border: 1px solid var(--stroke); }
.ex-head { display: flex; flex-direction: column; gap: 2px; }
.ex-head strong { font-size: 1.05rem; }
.ex-notes { margin: 0; }
.ex-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.sets { display: flex; gap: 6px; flex-wrap: wrap; }
.set { width: 44px; min-height: 44px; padding: 0; border-radius: 50%; border: 1px solid var(--stroke); background: transparent; color: var(--text); font-weight: 700; }
.set.done { background: var(--protein); border-color: var(--protein); color: #fff; }
.weight { display: flex; align-items: center; gap: 8px; }
.weight input { width: 88px; min-height: 40px; }
.weight-status { min-width: 4em; }
.day-summary { margin: 0; }
.rest-bar { position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 50; display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 16px; background: var(--card); border: 1px solid var(--accent); box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35); }
.rest-bar[hidden] { display: none; }
.rest-bar .rest-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rest-bar .rest-time { font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.rest-bar.done { border-color: var(--error); animation: timer-flash 0.6s ease 3; }
.check-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.check-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; border: 1px solid var(--stroke); font-size: 0.85rem; cursor: pointer; }
.check-chip:has(input:checked) { background: color-mix(in srgb, var(--accent) 18%, transparent); border-color: var(--accent); }
.check-chip input { width: auto; min-height: 0; margin: 0; }
.quick-add { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.quick-add select { flex: 1; min-width: 140px; }
.thread { display: flex; flex-direction: column; gap: 10px; }
.routine-draft { max-width: 100%; }
.preview-day h4 { margin: 8px 0 4px; }
.preview-day ul { margin: 0; padding-left: 1.1rem; display: grid; gap: 4px; }
@media (prefers-reduced-motion: reduce) { .rest-bar.done { animation: none; } }
#routine-root { padding-bottom: 96px; } /* room for the rest timer bar */

/* ---------- Bottom navigation and the More sheet ---------- */
.screen-title { display: none; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; font-size: 1.1rem; }
@media (max-width: 480px) { .screen-title { display: block; } }
.bottom-nav { flex: none; display: flex; justify-content: center; gap: 4px; padding: 6px 10px calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid var(--stroke); background: var(--fill); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.bottom-nav button { flex: 1; max-width: 140px; min-height: 52px; padding: 4px 2px; border: none; border-radius: 14px; background: transparent; box-shadow: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); font-size: 0.7rem; font-weight: 600; }
.bottom-nav button .ico { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.bottom-nav button[aria-current="page"] { color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
body[data-view="app"] .composer { padding-bottom: 10px; } /* the bottom bar already clears the phone's edge */
.rest-bar { bottom: calc(84px + env(safe-area-inset-bottom)); } /* above the bottom bar */

/* The bottom bar and the More sheet are frosted glass: translucent fill, a hairline of light on the edge, and a soft blur
   of whatever is behind them, like the cards and the confirmation dialog. */
.bottom-nav { align-self: center; width: min(520px, calc(100% - 20px)); margin: 0 10px calc(8px + env(safe-area-inset-bottom)); padding: 5px; gap: 2px; border: 1px solid var(--win-edge); border-radius: 26px; background: var(--win); -webkit-backdrop-filter: blur(28px) saturate(190%); backdrop-filter: blur(28px) saturate(190%); box-shadow: inset 0 1px 0 var(--win-edge), var(--lift); }
.bottom-nav button { max-width: none; border-radius: 21px; font-weight: 500; transition: background 0.2s ease, color 0.2s ease; }
.bottom-nav button[aria-current="page"] { background: var(--seg-on); color: var(--accent); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.10); }
.rest-bar { bottom: calc(92px + env(safe-area-inset-bottom)); }

dialog.more-sheet { position: fixed; inset: auto 8px calc(8px + env(safe-area-inset-bottom)) 8px; margin: 0 auto; width: min(520px, calc(100% - 16px)); max-width: none; max-height: calc(100% - 24px); overflow: auto; padding: 8px 8px 10px; border: 1px solid var(--win-edge); border-radius: 28px; color: var(--text);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0) 38%), var(--win);
  -webkit-backdrop-filter: blur(34px) saturate(190%); backdrop-filter: blur(34px) saturate(190%);
  box-shadow: inset 0 1px 0 var(--win-edge), 0 2px 6px rgba(0, 0, 0, 0.06), 0 28px 70px -18px rgba(10, 20, 50, 0.42);
  display: grid; gap: 1px; animation: sheet-up 0.26s cubic-bezier(0.2, 0.85, 0.25, 1); }
dialog.more-sheet::backdrop { background: rgba(8, 12, 22, 0.20); } /* only a soft dim: the glass is the sheet itself */
@keyframes sheet-up { from { transform: translateY(18px) scale(0.98); opacity: 0; } }
/* On wide screens it opens as a popover above the More button (its position is set from the button when it opens). */
@media (min-width: 760px) {
  dialog.more-sheet { inset: auto auto var(--sheet-bottom, 92px) var(--sheet-left, 12px); margin: 0; width: 232px; padding: 6px; border-radius: 18px; transform-origin: 100% 100%; }
  .more-grab { display: none; }
  /* Denser rows for a mouse: smaller targets, type and icons than the thumb-sized ones on a phone */
  .more-row { min-height: 36px; padding: 6px 10px; gap: 10px; border-radius: 11px; font-size: 0.88rem; }
  .more-row .ico { width: 17px; height: 17px; }
  .more-group { padding: 9px 10px 3px; font-size: 0.64rem; }
  .more-group:empty { margin: 5px 10px; }
  .bottom-nav { width: 420px; }
  .bottom-nav button { min-height: 46px; }
}
.more-grab { width: 36px; height: 4px; border-radius: 2px; background: var(--stroke); margin: 4px auto 6px; }
.more-group { padding: 12px 14px 4px; font-size: 0.68rem; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); }
.more-group:empty { height: 1px; padding: 0; margin: 6px 14px; background: var(--stroke); }
.more-row { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 48px; padding: 8px 14px; border: none; border-radius: 16px; background: transparent; box-shadow: none; color: var(--text); font-size: 0.98rem; font-weight: 500; text-align: left; transition: background 0.15s ease; }
.more-row:hover { background: var(--seg); }
.more-row .ico { width: 20px; height: 20px; fill: none; stroke: var(--muted); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.more-row.on { background: color-mix(in srgb, var(--accent) 13%, transparent); color: var(--accent); font-weight: 600; }
.more-row.on .ico { stroke: var(--accent); }
.more-row.danger { color: var(--error); }
.more-row.danger .ico { stroke: var(--error); }
@media (prefers-reduced-motion: reduce) { dialog.more-sheet { animation: none; } .bottom-nav button { transition: none; } }

/* Selects: our own chevron, a little in from the edge (the browser's sits right against it). A mid grey reads on both themes. */
select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' fill='none' stroke='%238893a5' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1.5 1.75l4.5 4.5 4.5-4.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  background-size: 11px 7px;
}
.lang-select { padding-right: 36px; background-position: right 15px center; }
@media (max-width: 560px) { .lang-select { padding-right: 30px; background-position: right 12px center; } }

/* ---------- A gym's look ----------
   The gym picks one accent color; brand.js works out the tones for each theme (so it always reads) and sets them as
   --b-light*, --b-dark*. In the Gym screens (html[data-brand="gym"]) and inside a preview (.brand-scope) the accent
   tokens take those values, so everything that already uses --accent follows. */
:root[data-brand="gym"], .brand-scope { --accent: var(--b-light); --accent-2: var(--b-light-2); --on-accent: var(--b-light-on); }
@media (prefers-color-scheme: dark) {
  :root[data-brand="gym"]:not([data-theme="light"]), :root:not([data-theme="light"]) .brand-scope { --accent: var(--b-dark); --accent-2: var(--b-dark-2); --on-accent: var(--b-dark-on); }
}
:root[data-theme="dark"][data-brand="gym"], :root[data-theme="dark"] .brand-scope { --accent: var(--b-dark); --accent-2: var(--b-dark-2); --on-accent: var(--b-dark-on); }

.gym-brand { display: flex; align-items: center; gap: 10px; padding: 2px 4px; min-width: 0; }
.gym-brand img { width: 30px; height: 30px; border-radius: 8px; object-fit: contain; flex: none; background: var(--fill); }
.gym-brand span { font-weight: 600; font-size: 0.92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.swatches { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.swatch { width: 30px; height: 30px; min-height: 30px; padding: 0; border-radius: 50%; border: 2px solid transparent; box-shadow: 0 0 0 1px var(--stroke); }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--text); }
.swatch-custom { width: 34px; height: 34px; min-height: 34px; padding: 0; border: none; border-radius: 50%; background: none; cursor: pointer; }
.logo-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.logo-box { width: 64px; height: 64px; display: grid; place-items: center; border-radius: 14px; border: 1px dashed var(--stroke); background: var(--fill); overflow: hidden; }
.logo-box img { width: 56px; height: 56px; object-fit: contain; }
.brand-preview { display: flex; flex-direction: column; gap: 10px; padding: 12px 14px; border-radius: 16px; border: 1px solid var(--stroke); background: var(--card); }
.preview-head { display: flex; align-items: center; gap: 10px; }
.preview-logo { border-radius: 7px; object-fit: contain; }
.preview-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.preview-button { padding: 8px 16px; border-radius: 999px; font-weight: 600; font-size: 0.9rem; color: var(--on-accent, #fff); background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.preview-chip { padding: 6px 12px; border-radius: 999px; font-size: 0.85rem; border: 1px solid var(--stroke); color: var(--muted); }
.preview-chip.on { color: var(--accent); border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); font-weight: 600; }
.brand-preview.is-default { --b-light: #2563eb; --b-light-2: #0284c7; --b-light-on: #ffffff; --b-dark: #3b82f6; --b-dark-2: #0284c7; --b-dark-on: #ffffff; }
.gym-brand { margin: 4px 16px 0; padding: 0; }
.swatch-custom { -webkit-appearance: none; appearance: none; }
.swatch-custom::-webkit-color-swatch-wrapper { padding: 0; }
.swatch-custom::-webkit-color-swatch { border: none; border-radius: 50%; box-shadow: 0 0 0 1px var(--stroke); }
.swatch-custom::-moz-color-swatch { border: none; border-radius: 50%; }

/* The mode badge: shown only to people who have both modes, next to the screen name. */
.mode-badge { flex: none; padding: 3px 10px; border-radius: 999px; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent); background: color-mix(in srgb, var(--accent) 12%, transparent); }

/* The two sections of the setup: which one this screen belongs to, and which is required. */
#profile-view h3, #profile-form h3 { margin: 10px 0 0; font-size: 0.95rem; }
#profile-view h3:first-child, #profile-form h3:first-child { margin-top: 0; }

/* ---------- Gym management screens (My gym, Admin > Gyms): proportions ---------- */
/* The sections already space their children with a gap, so paragraphs and headings carry no margin of their own. */
#mygym-root .section > p, #gyms-root .section > p, #users-section h2, #users-section h3, #mygym-root .section h2, #gyms-root .section h2, #mygym-root .section h3, #gyms-root .section h3 { margin: 0; }
.seg-bar { display: flex; margin-left: 0; width: 100%; }
.seg-bar button { flex: 1; min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px 12px; flex-wrap: wrap; }
.panel-head .row-actions { flex-wrap: wrap; }
.count { display: inline-block; min-width: 1.6em; padding: 1px 8px; margin-left: 4px; border-radius: 999px; background: var(--seg); color: var(--muted); font-size: 0.78rem; font-weight: 600; text-align: center; vertical-align: 0.12em; }
.stack-tight { display: flex; flex-direction: column; gap: 10px; }
.soft-panel { padding: 14px; border: 1px solid var(--stroke); border-radius: 16px; background: color-mix(in srgb, var(--field) 55%, transparent); }
.soft-panel h3 { font-size: 0.9rem; }
.equip-form { grid-template-columns: minmax(0, 1fr) 110px; }
.entry { padding: 12px 0; align-items: center; }
.entry-title { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.entry .grow > .muted { margin-top: 2px; line-height: 1.4; }
.entry[hidden] { display: none; }
.check-chip { padding: 4px 10px; font-size: 0.8rem; }
.stat-pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
@media (max-width: 480px) {
  .panel-head .row-actions { width: 100%; }
  .panel-head .row-actions button { flex: 1; }
}
/* An empty status line or an empty photo block must not leave a gap between the card's children. */
.section p:empty, .section .stack-tight:has(> p:empty:only-child) { display: none; }
/* The Admin tabs line up with the content column below them. */
.tabs { max-width: 680px; margin: 12px auto 8px; width: calc(100% - 32px); box-sizing: border-box; }
/* Rows with three actions (users, gyms) put them under the text on a phone, so the text keeps its width. */
@media (max-width: 480px) {
  #users-section .entry, #gyms-root .entry { flex-direction: column; align-items: stretch; gap: 10px; }
  #users-section .entry .row-actions, #gyms-root .entry .row-actions { flex-wrap: wrap; }
}

/* ---------- Profile ---------- */
.brand-text p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 52ch; }
.identity { display: flex; align-items: center; gap: 14px; }
.identity-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.identity-text strong { font-size: 1.15rem; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.avatar { flex: none; width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; font-size: 1.35rem; font-weight: 700; color: var(--on-accent, #fff); background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--accent) 70%, transparent); }
#profile-view { gap: 12px; }
#profile-view .soft-panel h3 { margin: 0; }
#profile-view .kv { padding: 10px 0; }
#profile-view .kv:last-of-type { border-bottom: none; padding-bottom: 0; }
#profile-view .kv strong { font-size: 0.98rem; font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.kv .unset { color: var(--muted); font-size: 0.9rem; }
#profile-view .soft-panel > p { margin: 0; }
#profile-form h3 { margin: 6px 0 0; }

/* The phone: the country (with its code) next to the number. */
.phone-row { display: flex; gap: 8px; }
.phone-row select { flex: 0 1 46%; min-width: 0; }
.phone-row input { flex: 1; min-width: 0; }

/* ---------- Joining a gym, and the count of people waiting ---------- */
.gym-line { display: flex; align-items: center; gap: 12px; min-width: 0; }
.gym-mark { flex: none; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; overflow: hidden; font-weight: 700; background: var(--seg); color: var(--muted); }
.gym-mark img { width: 100%; height: 100%; object-fit: cover; display: block; }
.bottom-nav button { position: relative; }
.bottom-nav button[data-badge]:not([data-badge=""])::after { content: attr(data-badge); position: absolute; top: 2px; right: calc(50% - 26px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; display: grid; place-items: center; font-size: 0.68rem; font-weight: 700; line-height: 1; color: var(--on-accent, #fff); background: var(--error); box-sizing: border-box; }

/* ---------- Header badge, setup intro and the mode card ---------- */
.brand-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
@media (max-width: 480px) {
  /* The brand text is hidden on a phone, but the badge stays: it sits after the screen title. */
  .brand-text, .brand-title { display: contents; }
  .brand-text h1, .brand-text p { display: none; }
  .mode-badge { order: 2; }
}
dialog.wizard .intro { display: flex; flex-direction: column; gap: 14px; }
dialog.wizard .intro p, dialog.wizard .intro h3 { margin: 0; }
.intro-lead { font-size: 1rem; line-height: 1.5; }
.intro-list { margin: 0; padding-left: 1.2rem; display: grid; gap: 6px; font-size: 0.95rem; }
.intro-list li::marker { color: var(--accent); }
#personal-card p { margin: 0; }
#personal-card .field.check { align-self: stretch; min-height: 0; padding: 12px 14px; cursor: pointer; color: var(--text); }
.wizard-sections { margin-bottom: 14px; }

/* ---------- AI allowance bar, routine editor and previous routines ---------- */
.quota { display: flex; flex-direction: column; gap: 6px; font-size: 0.82rem; color: var(--muted); }
.quota[hidden] { display: none; }
.quota .bar { height: 6px; }
.quota-high .bar > span { background: var(--error); }
.composer .quota { padding: 0 4px; }
.routine-editor .re-ex { padding-top: 12px; border-top: 1px solid var(--stroke); }
.routine-editor .re-ex:first-of-type { border-top: none; padding-top: 0; }
.routine-editor .soft-panel { gap: 12px; }
.routine-editor .soft-panel > h3 { margin: 0; font-size: 1rem; }
.picked-file { display: flex; gap: 14px; align-items: flex-start; padding: 12px; border: 1px solid var(--stroke); border-radius: 14px; background: var(--surface-2, rgba(255, 255, 255, 0.04)); }
.picked-file[hidden] { display: none; }
.picked-file .grow { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.picked-file strong { overflow-wrap: anywhere; }
.picked-file p { margin: 0; }
.picked-thumb { width: 84px; height: 84px; object-fit: cover; border-radius: 10px; flex: none; }
.picked-pdf { width: 64px; height: 84px; flex: none; display: grid; place-items: center; border-radius: 10px; border: 1px solid var(--stroke); font-weight: 700; letter-spacing: 0.06em; color: var(--muted); }
@media (max-width: 480px) { .picked-file { flex-direction: column; } }
#routine-root .section > p, #routine-root .section > h2 { margin: 0; }

/* Gym > Tools */
.panel-inner-stack { display: flex; flex-direction: column; gap: 16px; }
.timer-card > h2 { margin: 0; align-self: flex-start; }
.tool-row { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.tool-row .field { flex: 1 1 140px; min-width: 0; }
.tool-result { display: flex; flex-direction: column; gap: 4px; padding: 14px; border-radius: 14px; border: 1px solid var(--stroke); }
.tool-big { font-size: 1.6rem; font-weight: 700; line-height: 1.2; }
.unit-toggle { margin-left: 0; }
.unit-toggle button { min-height: 32px; padding: 2px 12px; }
.weight { flex-wrap: wrap; }

/* Landing: what the app offers, one mascot per feature. */
.features { width: 100%; max-width: 1000px; margin: 0 auto; padding: 8px 0 40px; display: flex; flex-direction: column; gap: 18px; }
.features > h2 { margin: 0; font-size: 1.3rem; }
.feature-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.feature-grid li { display: flex; gap: 14px; align-items: flex-start; padding: 14px; border-radius: 16px; background: var(--fill); border: 1px solid var(--fill-edge); box-shadow: inset 0 1px 0 var(--fill-edge); min-width: 0; }
.feature-grid img { width: 52px; height: 52px; flex: none; }
.feature-grid h3 { margin: 0 0 2px; font-size: 1rem; }
.feature-grid p { margin: 0; font-size: 0.88rem; color: var(--muted); line-height: 1.45; }
@media (max-width: 899px) { .features > h2 { text-align: center; } }

/* Avatars: the picker (setup and Profile) and the mascot in the top bar. */
.brand .logo img { box-sizing: border-box; padding: 3px; border-radius: 12px; background: #161d2b; }
.avatar-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.avatar-option { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 6px 10px; border-radius: 16px; background: var(--field); border: 1px solid var(--stroke); cursor: pointer; text-align: center; transition: border-color 0.15s, background 0.15s, transform 0.15s; min-width: 0; }
.avatar-option:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--stroke)); transform: translateY(-1px); }
.avatar-option input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.avatar-option img { width: 56px; height: 56px; border-radius: 14px; background: #161d2b; padding: 4px; box-sizing: border-box; }
.avatar-option strong { font-size: 0.85rem; }
.avatar-option small { font-size: 0.7rem; }
.avatar-option:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--field)); box-shadow: 0 0 0 1px var(--accent); }
.avatar-option:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (max-width: 460px) {
  .avatar-grid { gap: 8px; }
  .avatar-option { padding: 10px 2px 8px; }
  .avatar-option img { width: 46px; height: 46px; }
  .avatar-option strong { font-size: 0.74rem; }
  .avatar-option small { display: none; }
}
@media (prefers-reduced-motion: reduce) { .avatar-option { transition: none; } .avatar-option:hover { transform: none; } }

/* Setup wizard: numbered sections, grouped fields and a footer that stays put. */
.wizard-sections { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 8px; }
.wizard-sections .sec { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 14px; border: 1px solid var(--stroke); background: color-mix(in srgb, var(--field) 55%, transparent); min-width: 0; }
.wizard-sections .sec > span { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.wizard-sections .sec strong { font-size: 0.82rem; color: var(--muted); font-weight: 600; }
.wizard-sections .sec small { font-size: 0.72rem; color: var(--muted); }
.wizard-sections .sec b { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 0.75rem; border: 1px solid var(--stroke); color: var(--muted); }
.wizard-sections .sec.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.wizard-sections .sec.on strong { color: var(--text); }
.wizard-sections .sec.on b { background: var(--accent); border-color: var(--accent); color: var(--on-accent, #fff); }
.wizard-sections .sec.done b { background: color-mix(in srgb, var(--accent) 22%, transparent); border-color: transparent; color: var(--accent); }
dialog.wizard .soft-panel h3 { font-size: 0.9rem; }
dialog.wizard .soft-panel .form-grid { gap: 12px; }
dialog.wizard .wizard-nav { padding-top: 14px; border-top: 1px solid var(--stroke); }
@media (max-width: 460px) { .wizard-sections small { display: none; } }
.avatar.has-image { background: #161d2b; box-shadow: none; padding: 0; overflow: hidden; border-radius: 16px; }
.avatar.has-image img { width: 100%; height: 100%; display: block; padding: 4px; box-sizing: border-box; }

/* "AI" in the name is painted in the accent colors, in the top bar like in the landing title. */
.brand-text h1 .ai-mark { background: linear-gradient(135deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* Today: the workout of the day. */
#today-workout[hidden] { display: none; }
#today-workout { gap: 14px; }
#today-workout p { margin: 0; }
.workout-top { display: flex; align-items: center; gap: 14px; min-width: 0; }
.workout-mascot { flex: none; width: 56px; height: 56px; border-radius: 16px; background: #161d2b; display: grid; place-items: center; box-shadow: 0 8px 20px -10px color-mix(in srgb, var(--accent) 70%, transparent); }
.workout-mascot img { width: 44px; height: 44px; display: block; }
.workout-heading { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.workout-label { margin: 0; font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); font-weight: 700; }
.workout-title { margin: 0; font-size: 1.2rem; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.workout-ring { flex: none; width: 64px; max-width: 64px; }
.workout-ring .pie-center { font-size: 0.85rem; }
.workout-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pill-ok { background: color-mix(in srgb, var(--accent-2) 18%, transparent); color: var(--accent-2); border-color: transparent; }
.workout-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.workout-list li { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 12px; border: 1px solid var(--stroke); background: color-mix(in srgb, var(--field) 55%, transparent); font-size: 0.92rem; min-width: 0; }
.workout-list li b { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 0.75rem; background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.workout-list .workout-ex { flex: 1; min-width: 0; overflow-wrap: anywhere; font-weight: 600; }
.workout-list li > .muted { flex: none; font-variant-numeric: tabular-nums; }
#today-workout.done { border-color: color-mix(in srgb, var(--accent-2) 55%, var(--stroke)); }
#today-workout { border-color: color-mix(in srgb, var(--accent-2) 55%, var(--stroke)); }
.workout-day { display: flex; flex-direction: column; gap: 14px; }
.workout-day + .workout-day { padding-top: 14px; border-top: 1px solid var(--stroke); }
#today-workout .workout-label { color: var(--accent-2); }
