/* ==========================================================================
   Mia — design system (module C). Mobile-first, Nara-like: dark navy, rounded
   cards with coloured header bands, overlapping round blue "+", serif display
   type, big serif numbers with superscript units, bottom sheets.
   Themes: <html data-theme="dark|light|auto"> (dark is the default).
   No external resources (fonts are system stacks).
   ========================================================================== */

/* ---------- Tokens: dark (default) ---------- */
:root {
  color-scheme: dark;
  --bg: #1c2130;
  --bg-2: #232838;
  --surface: #2a3043;
  --surface-2: #323a50;
  --line: #3d4560;
  --text: #f4f1ea;
  --text-2: #b3b9c9;
  --text-3: #7f879b;

  --feed: #f6c84c;
  --feed-ink: #1f2330;
  --feed-soft: rgba(246, 200, 76, 0.16);
  --feed-text: #f6c84c;
  --growth: #afdc8e;
  --growth-ink: #1f2330;
  --growth-soft: rgba(175, 220, 142, 0.16);
  --growth-text: #afdc8e;
  --allergen: #cfc6f3;
  --allergen-ink: #1f2330;
  --allergen-soft: rgba(207, 198, 243, 0.16);
  --allergen-text: #cfc6f3;
  --guide: #f2d9c4;
  --guide-ink: #1f2330;
  --guide-soft: rgba(242, 217, 196, 0.14);
  --guide-text: #f2d9c4;
  --neutral-band: #efe9dc;
  --neutral-ink: #1f2330;
  --neutral-soft: rgba(179, 185, 201, 0.14);
  --neutral-text: #b3b9c9;

  --accent: #4d74ab;
  --accent-2: #6f95cc;
  --on-accent: #ffffff;
  --accent-soft: rgba(111, 149, 204, 0.18);
  --accent-text: #8fb0e0;
  --link: #8fb0e0;

  --danger: #e07a6c;
  --danger-soft: rgba(224, 122, 108, 0.16);
  --danger-text: #f0998d;
  --ok: #8fd19e;
  --ok-soft: rgba(143, 209, 158, 0.16);
  --ok-text: #8fd19e;
  --warn: #f0c36b;
  --warn-soft: rgba(240, 195, 107, 0.16);
  --warn-text: #f0c36b;

  --input-bg: #232838;
  --sheet-bg: #2a3043;
  --backdrop: rgba(10, 12, 20, 0.55);
  --tabbar-bg: rgba(26, 30, 44, 0.94);
  --toast-bg: #3b4460;
  --toast-text: #f4f1ea;
  --toast-action: #b5cdf0;
  --tab-on: #7fa3d8;
  --focus: #8fb2e6;
  --track-off: #4a5370;

  --chart-grid: #3d4560;
  --chart-axis: #7f879b;
  --chart-point: #6f95cc;

  --font-display: ui-serif, "New York", "Iowan Old Style", "Palatino", Georgia, serif;
  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;

  --r-card: 20px;
  --r-sheet: 24px;
  --r-ctl: 12px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --tabbar-h: 64px;
}

/* ---------- Tokens: light ---------- */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f2ea;
  --bg-2: #ece8de;
  --surface: #ffffff;
  --surface-2: #f4f1ea;
  --line: #e2ddd0;
  --text: #1f2330;
  --text-2: #4d5466;
  --text-3: #80879a;
  --feed: #f2bd2f;
  --feed-soft: rgba(242, 189, 47, 0.2);
  --feed-text: #7d5a00;
  --growth: #8fcb67;
  --growth-soft: rgba(143, 203, 103, 0.22);
  --growth-text: #3b6e1c;
  --allergen: #b9adea;
  --allergen-soft: rgba(185, 173, 234, 0.28);
  --allergen-text: #4f3fa3;
  --guide: #f2d9c4;
  --guide-soft: rgba(226, 180, 140, 0.24);
  --guide-text: #7f4f2a;
  --neutral-band: #e9e4d8;
  --neutral-soft: rgba(77, 84, 102, 0.1);
  --neutral-text: #4d5466;
  --accent-soft: rgba(77, 116, 171, 0.14);
  --accent-text: #3d5f91;
  --link: #3d5f91;
  --danger: #cf5a4a;
  --danger-soft: rgba(207, 90, 74, 0.12);
  --danger-text: #a8402f;
  --ok: #3f9a57;
  --ok-soft: rgba(63, 154, 87, 0.12);
  --ok-text: #2c7442;
  --warn: #c98a12;
  --warn-soft: rgba(242, 189, 47, 0.2);
  --warn-text: #7d5a00;
  --input-bg: #ffffff;
  --sheet-bg: #f5f2ea;
  --backdrop: rgba(31, 35, 48, 0.4);
  --tabbar-bg: rgba(250, 248, 243, 0.94);
  --toast-bg: #1f2330;
  --toast-text: #f4f1ea;
  --toast-action: #a9c4ec;
  --tab-on: #4d74ab;
  --focus: #4d74ab;
  --track-off: #d6d0c2;
  --chart-grid: #e2ddd0;
  --chart-axis: #80879a;
  --chart-point: #4d74ab;
  --shadow: 0 6px 20px rgba(31, 35, 48, 0.08);
  --shadow-sm: 0 1px 4px rgba(31, 35, 48, 0.08);
}

@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] {
    color-scheme: light;
    --bg: #f5f2ea;
    --bg-2: #ece8de;
    --surface: #ffffff;
    --surface-2: #f4f1ea;
    --line: #e2ddd0;
    --text: #1f2330;
    --text-2: #4d5466;
    --text-3: #80879a;
    --feed: #f2bd2f;
    --feed-soft: rgba(242, 189, 47, 0.2);
    --feed-text: #7d5a00;
    --growth: #8fcb67;
    --growth-soft: rgba(143, 203, 103, 0.22);
    --growth-text: #3b6e1c;
    --allergen: #b9adea;
    --allergen-soft: rgba(185, 173, 234, 0.28);
    --allergen-text: #4f3fa3;
    --guide: #f2d9c4;
    --guide-soft: rgba(226, 180, 140, 0.24);
    --guide-text: #7f4f2a;
    --neutral-band: #e9e4d8;
    --neutral-soft: rgba(77, 84, 102, 0.1);
    --neutral-text: #4d5466;
    --accent-soft: rgba(77, 116, 171, 0.14);
    --accent-text: #3d5f91;
    --link: #3d5f91;
    --danger: #cf5a4a;
    --danger-soft: rgba(207, 90, 74, 0.12);
    --danger-text: #a8402f;
    --ok: #3f9a57;
    --ok-soft: rgba(63, 154, 87, 0.12);
    --ok-text: #2c7442;
    --warn: #c98a12;
    --warn-soft: rgba(242, 189, 47, 0.2);
    --warn-text: #7d5a00;
    --input-bg: #ffffff;
    --sheet-bg: #f5f2ea;
    --backdrop: rgba(31, 35, 48, 0.4);
    --tabbar-bg: rgba(250, 248, 243, 0.94);
    --toast-bg: #1f2330;
    --toast-text: #f4f1ea;
    --toast-action: #a9c4ec;
    --tab-on: #4d74ab;
    --focus: #4d74ab;
    --track-off: #d6d0c2;
    --chart-grid: #e2ddd0;
    --chart-axis: #80879a;
    --chart-point: #4d74ab;
    --shadow: 0 6px 20px rgba(31, 35, 48, 0.08);
    --shadow-sm: 0 1px 4px rgba(31, 35, 48, 0.08);
  }
}

/* ---------- Tones: set --tone / --tone-ink / --tone-soft / --tone-text ---------- */
.tone-feed { --tone: var(--feed); --tone-ink: var(--feed-ink); --tone-soft: var(--feed-soft); --tone-text: var(--feed-text); }
.tone-growth { --tone: var(--growth); --tone-ink: var(--growth-ink); --tone-soft: var(--growth-soft); --tone-text: var(--growth-text); }
.tone-allergen { --tone: var(--allergen); --tone-ink: var(--allergen-ink); --tone-soft: var(--allergen-soft); --tone-text: var(--allergen-text); }
.tone-guide { --tone: var(--guide); --tone-ink: var(--guide-ink); --tone-soft: var(--guide-soft); --tone-text: var(--guide-text); }
.tone-neutral { --tone: var(--neutral-band); --tone-ink: var(--neutral-ink); --tone-soft: var(--neutral-soft); --tone-text: var(--neutral-text); }
.tone-accent,
.tone-info { --tone: var(--accent); --tone-ink: var(--on-accent); --tone-soft: var(--accent-soft); --tone-text: var(--accent-text); }
.tone-ok { --tone: var(--ok); --tone-ink: #1f2330; --tone-soft: var(--ok-soft); --tone-text: var(--ok-text); }
.tone-warn { --tone: var(--warn); --tone-ink: #1f2330; --tone-soft: var(--warn-soft); --tone-text: var(--warn-text); }
.tone-danger { --tone: var(--danger); --tone-ink: #ffffff; --tone-soft: var(--danger-soft); --tone-text: var(--danger-text); }

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

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  overflow-x: clip;
  overscroll-behavior-y: none;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 400;
}

p {
  margin: 0;
}

img,
svg {
  display: block;
  max-width: 100%;
}

svg.icon {
  flex: none;
}

a {
  color: var(--link);
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

button:disabled {
  cursor: default;
}

strong,
b {
  font-weight: 600;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

:focus:not(:focus-visible) {
  outline: none;
}

::selection {
  background: var(--accent-soft);
}

/* ---------- Layout ---------- */
.app {
  min-height: 100vh;
  min-height: 100dvh;
  /* Never let one too-wide element widen the layout viewport (mobile browsers then
     zoom out the whole page). 'clip' — unlike 'hidden' — keeps position: sticky working. */
  overflow-x: clip;
}

.app-main {
  min-height: 100vh;
  min-height: 100dvh;
}

/* Solid band behind the iOS status bar (black-translucent). */
.statusbar-shim {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--safe-top);
  background: var(--bg);
  z-index: 40;
  pointer-events: none;
}

.screen {
  --bleed: 16px;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: max(20px, calc(var(--safe-top) + 8px)) calc(16px + var(--safe-right)) calc(var(--safe-bottom) + 32px) calc(16px + var(--safe-left));
}

.has-tabbar .screen {
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 24px);
}

.screen-header {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  margin: 0 0 18px;
}

.page-heading {
  flex: 1 1 auto;
  min-width: 0;
}

.screen-title {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.screen-header.large .screen-title {
  font-size: 34px;
}

.screen-sub {
  margin-top: 4px;
  color: var(--text-2);
  font-size: 15px;
}

.page-back {
  margin-left: -10px;
}

.page-header-right {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section {
  margin: 0 0 24px;
}

.section-title {
  margin: 0 4px 8px;
  color: var(--text-3);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.section-foot {
  margin: 8px 4px 0;
  color: var(--text-3);
  font-size: 13px;
  line-height: 1.45;
}

/* ---------- Utilities ---------- */
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-sm { display: flex; flex-direction: column; gap: 6px; }
.stack-lg { display: flex; flex-direction: column; gap: 20px; }
.hstack { display: flex; align-items: center; gap: 8px; min-width: 0; }
.hstack.wrap { flex-wrap: wrap; }
.hstack.center { justify-content: center; }
.hstack.between { justify-content: space-between; }
.hstack.top { align-items: flex-start; }
.spacer { flex: 1 1 auto; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: 14px; }
.tiny { font-size: 12px; line-height: 1.4; }
.serif { font-family: var(--font-display); }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; min-width: 0; }
.num { font-variant-numeric: tabular-nums; }
.strong { font-weight: 600; }
.link { color: var(--link); font-weight: 500; background: none; border: 0; padding: 0; }
.divider { height: 1px; margin: 12px 0; border: 0; background: var(--line); }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }

.visually-hidden,
.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.offscreen {
  position: fixed;
  top: 0;
  left: -9999px;
  opacity: 0;
}

/* ---------- Cards ---------- */
.card {
  position: relative;
  margin: 0 0 20px;
  background: var(--surface);
  border-radius: var(--r-card);
  box-shadow: var(--shadow);
}

.card-band {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 66px;
  padding: 14px 20px;
  border-radius: var(--r-card) var(--r-card) 0 0;
  background: var(--tone, var(--neutral-band));
  color: var(--tone-ink, var(--neutral-ink));
}

.card-band.has-fab {
  padding-right: 92px;
}

.card-title {
  flex: 1 1 auto;
  min-width: 0;
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.card-band-right {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.fab-add {
  position: absolute;
  right: 18px;
  bottom: -28px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.28);
  transition: transform 0.12s ease, background-color 0.15s ease;
}

.fab-add:active {
  transform: scale(0.94);
  background: var(--accent-2);
}

.card-body {
  padding: 4px 0;
}

.card-body.under-fab {
  padding-top: 14px;
}

.card.no-band .card-body {
  border-radius: var(--r-card);
}

.card-pad,
.card-body.card-pad {
  padding: 16px 20px;
}

.card-body.under-fab.card-pad {
  padding-top: 24px;
}

.card-body > * + .row,
.card-body > .row + *,
.card-body > * + .card-sep {
  border-top: 1px solid var(--line);
}

.card-foot {
  border-top: 1px solid var(--line);
}

.card-foot > * + * {
  border-top: 1px solid var(--line);
}

.card-link {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 56px;
  padding: 14px 20px;
  border: 0;
  background: none;
  color: var(--text);
  font-size: 17px;
  text-align: left;
  border-radius: 0 0 var(--r-card) var(--r-card);
}

.card-link:active {
  background: var(--surface-2);
}

.card-link-label {
  flex: 1 1 auto;
  min-width: 0;
}

.card-link-chev {
  color: var(--text-3);
}

/* Nara "Laatste fles … 140 ml" block */
.hero-stat {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px 16px;
}

.hero-stat-icon {
  flex: none;
}

.hero-stat-main {
  flex: 1 1 auto;
  min-width: 0;
}

.hero-stat-title {
  font-family: var(--font-display);
  font-size: 24px;
  line-height: 1.15;
}

.hero-stat-sub {
  margin-top: 2px;
  color: var(--text-2);
  font-size: 16px;
}

/* Today header: avatar + serif name + date */
.child-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 4px 0 22px;
}

.child-header-main {
  flex: 1 1 auto;
  min-width: 0;
}

.child-name {
  font-family: var(--font-display);
  font-size: 34px;
  line-height: 1.05;
  letter-spacing: -0.01em;
}

.child-date {
  margin-top: 4px;
  color: var(--text-2);
  font-size: 16px;
}

.child-age {
  margin-top: 2px;
  color: var(--text-3);
  font-size: 14px;
}

.child-header-actions {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.banner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 18px;
  padding: 14px 18px;
  border-radius: 18px;
  background: var(--tone, var(--guide));
  color: var(--tone-ink, var(--guide-ink));
  font-family: var(--font-display);
  font-size: 20px;
  line-height: 1.25;
}

/* Weetje van de dag: compact, max 3 lines of text so the Voeding card stays in view */
.fact {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: -6px 0 16px;
  padding: 10px 6px 10px 14px;
  border-radius: 16px;
  background: var(--guide-soft);
  border: 1px solid var(--line);
}

.fact-icon {
  flex: none;
  margin-top: 2px;
  color: var(--guide-text);
}

.fact-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.fact-kind {
  color: var(--text-3);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.fact-text {
  color: var(--text);
  font-size: 15px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
}

.fact-main.open .fact-text {
  -webkit-line-clamp: unset;
  line-clamp: unset;
  overflow: visible;
}

.fact-source {
  margin-top: 4px;
  color: var(--text-3);
  font-size: 12px;
}

.fact-close,
.fact-link {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: -10px 0 -10px -6px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--text-2);
  cursor: pointer;
}

.fact-close:active,
.fact-link:active {
  background: var(--surface-2);
}

/* ---------- Big numbers & KPIs ---------- */
.big-num {
  font-family: var(--font-display);
  font-size: 56px;
  font-weight: 400;
  line-height: 1;
  letter-spacing: -0.02em;
  white-space: nowrap;
  font-variant-numeric: lining-nums;
}

.big-num sup {
  position: relative;
  top: 0.18em;
  margin-left: 0.06em;
  font-size: 0.32em;
  letter-spacing: 0;
  vertical-align: top;
  line-height: 1;
}

.big-num.sm { font-size: 40px; }
.big-num.lg { font-size: 72px; }

.kpi {
  min-width: 0;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.kpi-value {
  font-family: var(--font-display);
  font-size: 30px;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-value sup {
  position: relative;
  top: 0.2em;
  margin-left: 0.08em;
  font-size: 0.45em;
  vertical-align: top;
}

.kpi-label {
  margin-top: 4px;
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.3;
}

.kpi-sub {
  margin-top: 2px;
  color: var(--text-3);
  font-size: 12px;
}

/* ---------- Rows & lists ---------- */
.list {
  overflow: hidden;
  background: var(--surface);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-sm);
}

.list > * + * {
  border-top: 1px solid var(--line);
}

.row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 64px;
  margin: 0;
  padding: 12px 20px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  text-decoration: none;
}

.row + .row {
  border-top: 1px solid var(--line);
}

.row.is-clickable {
  cursor: pointer;
}

.row.is-clickable:active {
  background: var(--surface-2);
}

.row.is-disabled {
  opacity: 0.55;
}

.row-icon {
  position: relative;
  display: grid;
  flex: none;
  place-items: center;
  width: 44px;
  height: 44px;
  color: var(--text);
}

/* Nara-like colour blob behind the line icon */
.row-icon[class*="tone-"]::before {
  content: "";
  position: absolute;
  left: 3px;
  bottom: 3px;
  width: 30px;
  height: 27px;
  border-radius: 58% 42% 55% 45% / 52% 60% 40% 48%;
  background: var(--tone);
  opacity: 0.95;
}

.row-icon > * {
  position: relative;
}

.row-main {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.row-title {
  font-size: 17px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.row-title.serif {
  font-family: var(--font-display);
  font-size: 22px;
  line-height: 1.2;
}

.row-sub {
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.row-extra {
  display: block;
  margin-top: 6px;
}

.row-value {
  display: flex;
  flex: none;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  max-width: 45%;
  font-size: 17px;
  text-align: right;
  white-space: nowrap;
}

.row-value-sub {
  color: var(--text-2);
  font-size: 13px;
}

.row-chev {
  flex: none;
  color: var(--text-3);
}

/* ---------- Bars ---------- */
.bar {
  width: 100%;
  height: 10px;
  overflow: hidden;
  border-radius: 5px;
}

.bar-fill {
  height: 100%;
  border-radius: 5px;
  background: var(--tone, var(--feed));
}

/* Nara style: bar length proportional, label right after it */
.bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.bar.inline {
  flex: 0 0 auto;
  min-width: 6px;
}

.bar.inline .bar-fill {
  width: 100% !important;
}

.bar-label {
  flex: none;
  font-size: 17px;
  white-space: nowrap;
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--tone-soft, var(--neutral-soft));
  color: var(--tone-text, var(--text-2));
  font-family: var(--font-ui);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  vertical-align: middle;
}

.badge.solid {
  background: var(--tone, var(--neutral-band));
  color: var(--tone-ink, var(--neutral-ink));
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  max-width: 100%;
  padding: 12px 20px;
  border: 1px solid transparent;
  border-radius: 14px;
  font-family: var(--font-ui);
  font-size: 17px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  transition: background-color 0.15s ease, transform 0.1s ease, opacity 0.15s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled,
.btn.is-disabled {
  opacity: 0.5;
  transform: none;
  pointer-events: none;
}

.btn.is-busy {
  pointer-events: none;
}

.btn-label {
  min-width: 0;
}

.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:active { background: var(--accent-2); }
.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--line); }
.btn-danger { background: var(--danger-soft); color: var(--danger-text); }
.btn-danger-solid { background: var(--danger); color: #ffffff; }
.btn-ghost { padding-left: 12px; padding-right: 12px; background: transparent; color: var(--link); }
.btn-ghost:active { background: var(--accent-soft); }
.btn-full { display: flex; width: 100%; }

.btn-sm {
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 12px;
  font-size: 15px;
}

/* Round icon button (back chevron, header actions) */
.btn-icon {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
}

.btn-icon:active {
  background: var(--surface-2);
}

/* Nara's outlined header buttons (⋯) */
.btn-outline-icon {
  display: inline-grid;
  flex: none;
  place-items: center;
  min-width: 52px;
  height: 44px;
  padding: 0 12px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: transparent;
  color: var(--text);
}

.btn-outline-icon:active {
  background: var(--surface-2);
}

/* ---------- Forms ---------- */
.field {
  padding: 12px 0;
}

.sheet-body > .field,
.sheet-body > .field-row {
  margin: 0 calc(-1 * var(--bleed));
  padding: 14px var(--bleed);
  border-bottom: 1px solid var(--line);
}

.field-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.field-label {
  display: block;
  font-family: var(--font-display);
  font-size: 19px;
  line-height: 1.25;
  color: var(--text);
}

.field-right {
  flex: none;
  color: var(--text-2);
  font-size: 14px;
}

.field.inline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
}

.field.inline > .field-label {
  flex: 1 1 auto;
  margin: 0;
}

.field.inline > .field-control {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
}

.field.inline > .field-hint,
.field.inline > .field-warn,
.field.inline > .field-error {
  flex: 1 0 100%;
  margin-top: 0;
}

.field-hint {
  margin-top: 6px;
  color: var(--text-3);
  font-size: 13px;
  line-height: 1.4;
}

.field-warn {
  margin-top: 6px;
  color: var(--warn-text);
  font-size: 14px;
  line-height: 1.4;
}

.field-error {
  margin-top: 6px;
  color: var(--danger-text);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
}

.field.has-error .input,
.field.has-error .input-unit {
  border-color: var(--danger);
}

.input {
  display: block;
  width: 100%;
  min-height: 48px;
  margin: 0;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
  background: var(--input-bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 17px; /* ≥ 16px: no iOS zoom on focus */
  line-height: 1.3;
  -webkit-appearance: none;
  appearance: none;
}

.input::placeholder {
  color: var(--text-3);
  opacity: 1;
}

.input:focus {
  outline: none;
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input:disabled,
.input[readonly] {
  opacity: 0.7;
}

.textarea {
  min-height: 88px;
  line-height: 1.45;
  resize: vertical;
}

.input-date {
  min-height: 48px;
  line-height: 24px;
  text-align: left;
}

.input-date::-webkit-date-and-time-value {
  margin: 0;
  text-align: left;
}

.input-date::-webkit-calendar-picker-indicator {
  opacity: 0.7;
}

.input-wrap {
  position: relative;
}

.input-wrap.has-reveal .input {
  padding-right: 52px;
}

.input-reveal {
  position: absolute;
  top: 50%;
  right: 2px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--text-2);
  transform: translateY(-50%);
}

.input-unit {
  display: flex;
  align-items: center;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
  background: var(--input-bg);
}

.input-unit:focus-within {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input-unit .input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.input-unit-suffix {
  flex: none;
  padding: 0 14px 0 2px;
  color: var(--text-2);
  font-size: 17px;
}

.input-unit.is-disabled {
  opacity: 0.6;
}

/* Big centred amount (Nara bottle sheet) */
.input-unit.size-lg {
  justify-content: center;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.input-unit.size-lg .input {
  flex: 0 1 auto;
  width: 3.4ch;
  min-height: 76px;
  padding: 4px 2px;
  border-bottom: 2px solid var(--line);
  border-radius: 0;
  font-family: var(--font-display);
  font-size: 60px;
  line-height: 1;
  text-align: right;
}

.input-unit.size-lg .input:focus {
  border-bottom-color: var(--accent-2);
}

.input-unit.size-lg .input-unit-suffix {
  align-self: flex-start;
  padding: 14px 0 0 6px;
  font-family: var(--font-display);
  font-size: 22px;
}

.input-unit.size-sm {
  width: 96px;
}

.input-unit.size-sm .input {
  min-height: 40px;
  padding: 8px 4px 8px 10px;
  font-size: 16px;
}

.input-unit.size-sm .input-unit-suffix {
  padding-right: 10px;
  font-size: 15px;
}

.datetime {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.field.inline .datetime {
  align-items: flex-end;
}

.datetime-chips {
  justify-content: flex-start;
}

.copy-box {
  margin-bottom: 14px;
  font-size: 15px;
  word-break: break-all;
}

/* Toggle (iOS switch) */
.toggle {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  cursor: pointer;
}

/* A Toggle placed directly in a list/card/sheet behaves like a full-bleed row. */
.list > .toggle,
.card-body > .toggle,
.sheet-body > .toggle {
  min-height: 60px;
  padding: 10px 20px;
}

.toggle.is-disabled {
  opacity: 0.55;
  cursor: default;
}

.toggle-text {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
}

.toggle-label {
  font-size: 17px;
  line-height: 1.3;
}

.toggle-sub {
  margin-top: 2px;
  color: var(--text-3);
  font-size: 13px;
  line-height: 1.4;
}

.toggle-input {
  position: absolute;
  top: 50%;
  right: 0;
  width: 51px;
  height: 31px;
  margin: -15.5px 0 0;
  opacity: 0;
  cursor: inherit;
}

.toggle-track {
  position: relative;
  flex: none;
  width: 51px;
  height: 31px;
  border-radius: 16px;
  background: var(--track-off);
  transition: background-color 0.2s ease;
}

.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s ease;
}

.toggle-input:checked + .toggle-track {
  background: var(--accent);
}

.toggle-input:checked + .toggle-track .toggle-thumb {
  transform: translateX(20px);
}

.toggle-input:focus-visible + .toggle-track {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* Chips */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.chips.nowrap {
  flex-wrap: nowrap;
  overflow-x: auto;
  margin-left: calc(-1 * var(--bleed, 0px));
  margin-right: calc(-1 * var(--bleed, 0px));
  padding: 4px var(--bleed, 0px);
  scroll-padding: 0 var(--bleed, 0px);
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.chips.nowrap::-webkit-scrollbar {
  display: none;
}

.field.inline .chips.nowrap {
  margin: 0;
  padding: 4px 0;
}

.chip {
  position: relative;
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.chip.on {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
}

.chip:disabled {
  opacity: 0.45;
}

.chip-sm {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 14px;
}

/* keep a 44px tall hit area for compact chips */
.chip-sm::after {
  content: "";
  position: absolute;
  top: -4px;
  bottom: -4px;
  left: 0;
  right: 0;
}

.chip-badge {
  padding: 1px 6px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.16);
  font-size: 12px;
}

/* Big icon tiles (e.g. meal choice) */
.chips-lg {
  justify-content: space-around;
  gap: 4px;
}

.chip-lg {
  flex: 1 1 0;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  max-width: 96px;
  padding: 6px 2px;
  border: 0;
  border-radius: 16px;
  background: transparent;
  white-space: normal;
  text-align: center;
}

.chip-lg .chip-icon {
  box-sizing: content-box;
  padding: 14px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text);
}

.chip-lg.on {
  background: transparent;
  color: var(--text);
}

.chip-lg.on .chip-icon {
  background: var(--accent);
  color: var(--on-accent);
}

.chip-lg .chip-label {
  max-width: 100%;
  font-size: 13px;
  line-height: 1.2;
  -webkit-hyphens: auto;
  hyphens: auto; /* <html lang="nl">: "Tussen-doortje" instead of overflowing */
  overflow-wrap: break-word;
}

@media (max-width: 359px) {
  .chip-lg .chip-icon {
    padding: 11px;
  }

  .chip-lg .chip-label {
    font-size: 12px;
    letter-spacing: -0.01em;
  }
}

/* Segmented control */
.seg {
  display: inline-flex;
  gap: 2px;
  max-width: 100%;
  padding: 3px;
  border-radius: 12px;
  background: rgba(127, 135, 155, 0.18);
}

.seg-full {
  display: flex;
  width: 100%;
}

.seg-btn {
  position: relative;
  display: inline-flex;
  flex: 1 1 0;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  min-height: 38px;
  padding: 6px 8px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-2);
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.15;
  text-align: center;
  -webkit-hyphens: auto;
  hyphens: auto; /* long Dutch words ("Kunstvoeding") hyphenate instead of breaking anywhere */
  overflow-wrap: break-word;
  transition: background-color 0.15s ease, color 0.15s ease;
}

@media (max-width: 359px) {
  .seg-btn {
    padding: 6px 4px;
    font-size: 13px;
  }
}

.seg-btn.on {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: var(--shadow-sm);
}

.seg.is-disabled {
  opacity: 0.55;
}

.seg-sm .seg-btn {
  min-height: 32px;
  padding: 4px 10px;
  font-size: 14px;
}

.seg-sm .seg-btn::after {
  content: "";
  position: absolute;
  top: -6px;
  bottom: -6px;
  left: 0;
  right: 0;
}

/* ---------- Notices, empty states, spinner ---------- */
.notice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--tone-soft, var(--accent-soft));
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
}

.notice-icon {
  flex: none;
  margin-top: 1px;
  color: var(--tone-text, var(--accent-text));
}

.notice-body {
  flex: 1 1 auto;
  min-width: 0;
}

.notice-title {
  margin-bottom: 2px;
  font-weight: 600;
}

.notice-sm {
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 14px;
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 40px 24px;
  color: var(--text-2);
  text-align: center;
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-2);
}

.empty.tone-danger .empty-icon {
  background: var(--danger-soft);
  color: var(--danger-text);
}

.empty-title {
  color: var(--text);
  font-family: var(--font-display);
  font-size: 24px;
  line-height: 1.2;
}

.empty-text {
  max-width: 34ch;
  font-size: 15px;
  line-height: 1.45;
}

.empty-action {
  margin-top: 8px;
}

.spinner {
  display: inline-block;
  flex: none;
  width: 28px;
  height: 28px;
  border: 3px solid var(--line);
  border-top-color: var(--accent-2);
  border-radius: 50%;
  animation: mia-spin 0.8s linear infinite;
}

.spinner-sm {
  width: 18px;
  height: 18px;
  border-width: 2px;
  border-color: currentColor;
  border-top-color: transparent;
  opacity: 0.85;
}

.spinner.is-hidden {
  visibility: hidden;
}

.spinner-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 56px 0;
}

/* ---------- Avatar ---------- */
.avatar {
  display: inline-grid;
  flex: none;
  place-items: center;
  overflow: hidden;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: var(--surface-2);
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-initial {
  border-color: transparent;
  background: var(--tone);
  color: var(--tone-ink);
  font-family: var(--font-display);
  line-height: 1;
}

/* ---------- Sheets & dialogs ---------- */
.sheet-layer {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: var(--backdrop);
  animation: mia-fade-in 0.22s ease-out;
}

.sheet-layer:not(.top) .sheet-backdrop {
  background: rgba(0, 0, 0, 0.12);
}

.sheet {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 600px;
  max-height: calc(100vh - var(--safe-top) - 10px);
  max-height: calc(var(--vvh, 100dvh) - var(--safe-top) - 10px);
  margin: 0 auto var(--kb, 0px);
  overflow: hidden;
  border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  background: var(--sheet-bg);
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.3);
  animation: mia-sheet-up 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.sheet:focus,
.dialog:focus {
  outline: none;
}

.sheet-layer.closing {
  pointer-events: none;
}

.sheet-layer.closing .sheet {
  animation: mia-sheet-down 0.22s ease-in forwards;
}

.sheet-layer.closing .sheet-backdrop,
.sheet-layer.closing .dialog {
  animation: mia-fade-out 0.2s ease-in forwards;
}

.sheet > * {
  flex: 1 1 auto;
  min-height: 0;
}

.sheet-inner {
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin: 0;
}

.sheet-head {
  display: grid;
  flex: none;
  grid-template-columns: minmax(48px, 1fr) minmax(0, auto) minmax(48px, 1fr);
  align-items: center;
  min-height: 66px;
  padding: 0 8px;
  background: var(--tone, var(--surface-2));
  color: var(--tone-ink, var(--text));
}

.sheet-head.tone-neutral {
  background: var(--surface-2);
  color: var(--text);
}

.sheet-close {
  display: grid;
  justify-self: start;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: inherit;
}

.sheet-title {
  padding: 12px 4px;
  font-family: var(--font-display);
  font-size: clamp(24px, 7.5vw, 32px);
  font-weight: 400;
  line-height: 1.1;
  text-align: center;
  overflow-wrap: anywhere;
}

.sheet-save {
  justify-self: end;
  min-width: 48px;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  background: none;
  color: inherit;
  font-family: var(--font-ui);
  font-size: 17px;
  font-weight: 600;
}

.sheet-save:disabled {
  opacity: 0.45;
}

.sheet-head-right {
  display: flex;
  justify-self: end;
  align-items: center;
}

.sheet-body {
  --bleed: 20px;
  flex: 1 1 auto;
  min-height: 0;
  padding: 0 20px 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.sheet-body:last-child {
  padding-bottom: calc(20px + var(--safe-bottom));
}

.sheet-body > .row,
.sheet-body > .list-bleed {
  margin: 0 calc(-1 * var(--bleed));
  width: calc(100% + 2 * var(--bleed));
}

.sheet-body > .row {
  padding-left: var(--bleed);
  padding-right: var(--bleed);
  border-bottom: 1px solid var(--line);
}

.sheet-body > .row + .row {
  border-top: 0;
}

.sheet-body > .section-title {
  margin: 20px 0 8px;
}

.sheet-body > .notice,
.sheet-body > .stack,
.sheet-body > .chips {
  margin-top: 14px;
}

.sheet-foot {
  flex: none;
  padding: 12px 20px calc(12px + var(--safe-bottom));
  border-top: 1px solid var(--line);
  background: var(--sheet-bg);
}

.dialog-layer {
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
}

.dialog {
  position: relative;
  width: 100%;
  max-width: 340px;
  margin-bottom: var(--kb, 0px);
  padding: 22px 20px 18px;
  border-radius: 20px;
  background: var(--sheet-bg);
  box-shadow: var(--shadow);
  animation: mia-pop-in 0.2s ease-out;
}

.dialog-title {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 24px;
  line-height: 1.2;
  text-align: center;
}

.dialog-text {
  margin: 0 0 18px;
  color: var(--text-2);
  font-size: 16px;
  line-height: 1.45;
  text-align: center;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.dialog-actions.single {
  grid-template-columns: 1fr;
}

.dialog-actions .btn {
  min-width: 0;
  padding-left: 8px;
  padding-right: 8px;
}

/* ---------- Toasts ---------- */
.toast-host {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--safe-bottom) + 16px);
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  pointer-events: none;
}

.has-tabbar .toast-host {
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 12px);
}

.sheet-open .toast-host {
  bottom: calc(var(--kb, 0px) + var(--safe-bottom) + 16px);
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 480px;
  min-height: 52px;
  padding: 8px 8px 8px 16px;
  border-radius: 16px;
  background: var(--toast-bg);
  color: var(--toast-text);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  font-size: 15px;
  line-height: 1.35;
  pointer-events: auto;
  animation: mia-toast-in 0.25s ease-out;
}

.toast-icon {
  flex: none;
  color: #a9c4ec;
}

.toast.kind-ok .toast-icon { color: #8fd19e; }
.toast.kind-error .toast-icon { color: #f0998d; }

.toast-msg {
  flex: 1 1 auto;
  min-width: 0;
  padding: 4px 0;
}

.toast-action {
  flex: none;
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.12);
  color: var(--toast-action);
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 600;
}

.toast-close {
  flex: none;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: inherit;
  font-size: 22px;
  line-height: 1;
  opacity: 0.6;
}

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  padding: 0 var(--safe-right) var(--safe-bottom) var(--safe-left);
  border-top: 1px solid var(--line);
  background: var(--tabbar-bg);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
}

.tabbar-inner {
  display: flex;
  max-width: 560px;
  height: var(--tabbar-h);
  margin: 0 auto;
}

.tab {
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 0;
  padding: 4px 1px;
  color: var(--text-3);
  /* "Geschiedenis" must fit in a fifth of a 320 px screen */
  font-size: clamp(10px, 2.8vw, 12px);
  font-weight: 500;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.tab.on {
  color: var(--tab-on);
}

.tab:active .tab-icon {
  transform: scale(0.92);
}

.tab-icon {
  transition: transform 0.1s ease;
}

.tab-label {
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

@media (max-width: 359px) {
  .tab {
    padding: 4px 0;
    font-size: 9.5px;
    letter-spacing: -0.03em;
  }
}

/* ---------- Sync badge ---------- */
.sync-badge {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  max-width: 100%;
  padding: 4px 12px;
  border: 0;
  border-radius: 999px;
  background: var(--warn-soft);
  color: var(--warn-text);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.sync-badge::after {
  content: "";
  position: absolute;
  top: -6px;
  bottom: -6px;
  left: 0;
  right: 0;
}

.sync-badge.is-offline {
  background: var(--neutral-soft);
  color: var(--text-2);
}

/* always=true and nothing pending: calm "Gesynchroniseerd" */
.sync-badge:not(.is-offline):not(.is-pending) {
  background: var(--ok-soft);
  color: var(--ok-text);
}

.sync-badge.is-syncing .sync-badge-icon {
  animation: mia-spin 1.2s linear infinite;
}

.sync-badge-count {
  padding: 0 6px;
  border-radius: 8px;
  background: rgba(127, 135, 155, 0.25);
}

/* ---------- Photos ---------- */
.photo-field {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.photo-add {
  border-radius: 999px;
}

.photo-thumb {
  position: relative;
  width: 96px;
  height: 96px;
}

.photo-thumb-btn {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 14px;
  background: var(--surface-2);
}

.photo-thumb-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-remove {
  position: absolute;
  top: -8px;
  right: -8px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 2px solid var(--sheet-bg);
  border-radius: 50%;
  background: var(--text);
  color: var(--bg);
}

.photo-remove::after {
  content: "";
  position: absolute;
  inset: -6px;
}

.photo-viewer {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 50vh;
  padding: 12px 0 calc(12px + var(--safe-bottom));
  background: #000000;
}

.photo-viewer img {
  max-width: 100%;
  max-height: calc(var(--vvh, 100dvh) - var(--safe-top) - 60px);
  object-fit: contain;
}

.photo-viewer-close {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #ffffff;
}

/* ---------- Day headings (History) ---------- */
.day-heading {
  position: sticky;
  top: var(--safe-top);
  z-index: 5;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 8px calc(-1 * var(--bleed, 16px)) 8px;
  padding: 10px calc(var(--bleed, 16px) + 4px) 8px;
  background: var(--bg);
  font-family: var(--font-display);
  font-size: 22px;
  line-height: 1.2;
}

.day-heading-sum {
  flex: none;
  max-width: 60%;
  color: var(--text-2);
  font-family: var(--font-ui);
  font-size: 13px;
  text-align: right;
}

/* ---------- Charts (E, F) ---------- */
.chart {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  touch-action: pan-y;
  -webkit-user-select: none;
  user-select: none;
}

.chart text {
  fill: var(--text-2);
  font-family: var(--font-ui);
  font-size: 11px;
}

.chart .grid line,
.chart .grid path {
  stroke: var(--chart-grid);
  stroke-width: 1;
}

.chart .axis {
  stroke: var(--chart-axis);
}

.chart-tooltip {
  margin-top: 12px;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  font-size: 15px;
  line-height: 1.55;
}

.chart-tooltip strong {
  font-weight: 600;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 8px;
  color: var(--text-2);
  font-size: 13px;
}

.chart-legend .swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border-radius: 3px;
  vertical-align: -1px;
}

/* ---------- Accordion (Guide) & tables ---------- */
.acc {
  margin: 0 0 14px;
  overflow: hidden;
  border-radius: var(--r-card);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.acc > summary {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 60px;
  padding: 14px 20px;
  font-family: var(--font-display);
  font-size: 22px;
  line-height: 1.2;
  list-style: none;
  cursor: pointer;
}

.acc > summary::-webkit-details-marker {
  display: none;
}

.acc > summary::after {
  content: "";
  flex: none;
  width: 9px;
  height: 9px;
  margin-left: auto;
  border-right: 2px solid var(--text-3);
  border-bottom: 2px solid var(--text-3);
  transform: rotate(45deg) translateY(-3px);
  transition: transform 0.2s ease;
}

.acc[open] > summary::after {
  transform: rotate(-135deg) translateY(-3px);
}

.acc[class*="tone-"] > summary {
  background: var(--tone);
  color: var(--tone-ink);
}

.acc[class*="tone-"] > summary::after {
  border-color: currentColor;
}

.acc-body {
  padding: 16px 20px 18px;
  color: var(--text-2);
  line-height: 1.5;
}

.acc-body > * + * {
  margin-top: 10px;
}

.acc-body ul,
.acc-body ol {
  margin: 0;
  padding-left: 20px;
}

.table-wrap {
  overflow-x: auto;
  margin: 0 calc(-1 * var(--bleed, 0px));
  padding: 0 var(--bleed, 0px);
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th,
.table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.table th {
  color: var(--text-2);
  font-weight: 600;
}

.table tr.on td {
  background: var(--guide-soft);
}

.source-links {
  color: var(--text-3);
  font-size: 12px;
}

/* ---------- Auth screens & boot ---------- */
.auth {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(40px, calc(var(--safe-top) + 28px)) 16px calc(var(--safe-bottom) + 32px);
}

.auth-inner {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  max-width: 420px;
}

.auth-brand {
  margin: 16px 0 6px;
  text-align: center;
}

.auth-title {
  font-family: var(--font-display);
  font-size: 64px;
  font-weight: 400;
  line-height: 1;
  letter-spacing: -0.02em;
}

.auth-sub {
  margin-top: 8px;
  color: var(--text-2);
  font-size: 17px;
}

.auth-card {
  margin: 0;
}

.auth-card .field {
  padding: 4px 0;
}

.auth-lead {
  font-size: 17px;
  line-height: 1.45;
}

.auth-error {
  margin: 0;
}

.auth-hint {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 0 8px;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.45;
}

.auth-hint svg {
  margin-top: 1px;
}

/* Static loading placeholder in index.php (<div class="boot">) and main.js' Splash. */
.boot,
.boot-splash {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 100vh;
  min-height: 100dvh;
  padding: var(--safe-top) 16px var(--safe-bottom);
  text-align: center;
  animation: mia-fade-in 0.4s ease-out;
}

.boot-title {
  color: var(--text);
  font-family: var(--font-display);
  font-size: 56px;
  font-weight: 400;
  line-height: 1;
  letter-spacing: -0.02em;
}

.boot-sub {
  color: var(--text-3);
  font-size: 15px;
}

.boot .spinner {
  margin-top: 14px;
}

.boot-noscript,
.boot-error {
  max-width: 420px;
  margin: 0 auto;
  padding: 40px 20px;
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  text-align: center;
}

/* ---------- Scroll lock (sheet open) ---------- */
html.sheet-open,
html.sheet-open body {
  overscroll-behavior: none;
}

/* ---------- Animations ---------- */
@keyframes mia-spin {
  to { transform: rotate(360deg); }
}

@keyframes mia-fade-in {
  from { opacity: 0; }
}

@keyframes mia-fade-out {
  to { opacity: 0; }
}

@keyframes mia-sheet-up {
  from { transform: translateY(100%); }
}

@keyframes mia-sheet-down {
  to { transform: translateY(100%); }
}

@keyframes mia-pop-in {
  from { opacity: 0; transform: scale(0.94); }
}

@keyframes mia-toast-in {
  from { opacity: 0; transform: translateY(12px); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }

  .spinner,
  .sync-badge.is-syncing .sync-badge-icon {
    animation-duration: 1.6s !important;
    animation-iteration-count: infinite !important;
  }
}

/* ---------- Wider screens ---------- */
@media (min-width: 640px) {
  .sheet {
    margin-bottom: max(var(--kb, 0px), 24px);
    border-radius: var(--r-sheet);
  }

  .sheet-body:last-child {
    padding-bottom: 20px;
  }
}

@media (hover: hover) {
  .row.is-clickable:hover,
  .card-link:hover {
    background: var(--surface-2);
  }

  .btn-secondary:hover {
    border-color: var(--text-3);
  }
}
