/* ==========================================================================
   Fitness · Claudinho — design system
   One stylesheet for the whole app (phone + desktop). Tokens first; every
   component reads tokens only, so the light theme is a token swap.
   ========================================================================== */

:root {
  color-scheme: dark;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", system-ui, Roboto, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;

  --bg: #0a0b0e;
  --bg-2: #0e1014;
  --surface: #15171d;
  --surface-2: #1c1f27;
  --surface-3: #262a35;
  --line: rgba(255, 255, 255, 0.07);
  --line-2: rgba(255, 255, 255, 0.13);
  --scrim: rgba(3, 4, 8, 0.62);
  --track: rgba(255, 255, 255, 0.08);

  --text: #f2f3f6;
  --text-2: #b8bcc8;
  --text-3: #868c9a;
  --text-4: #5b606d;

  /* Brand accent (Claudinho family: Fitness = violet). */
  --accent: #a78bfa;
  --accent-2: #8b5cf6;
  --accent-ink: #140f24;
  --accent-soft: rgba(167, 139, 250, 0.14);
  --accent-line: rgba(167, 139, 250, 0.35);

  /* Domain identity (validated as a set: CVD ΔE ≥ 9.4, ≥3:1 on surface). */
  --treino: #9085e9;
  --cardio: #d95926;
  --dieta: #199e70;
  --corpo: #3987e5;
  --treino-soft: rgba(144, 133, 233, 0.14);
  --cardio-soft: rgba(217, 89, 38, 0.15);
  --dieta-soft: rgba(25, 158, 112, 0.16);
  --corpo-soft: rgba(57, 135, 229, 0.15);

  /* Chart series (fixed order, never cycled). */
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;

  /* Status (text-safe steps). */
  --good: #45d07a;
  --good-soft: rgba(69, 208, 122, 0.13);
  --warn: #f4b33d;
  --warn-soft: rgba(244, 179, 61, 0.13);
  --bad: #f36f6f;
  --bad-soft: rgba(243, 111, 111, 0.13);

  --r-xl: 22px;
  --r-lg: 18px;
  --r: 14px;
  --r-sm: 10px;
  --r-xs: 7px;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-2: 0 12px 32px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.3);
  --glass: rgba(14, 16, 20, 0.78);

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 60px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f4f1;
  --bg-2: #ecece8;
  --surface: #ffffff;
  --surface-2: #f3f3f0;
  --surface-3: #e7e7e2;
  --line: rgba(15, 17, 21, 0.08);
  --line-2: rgba(15, 17, 21, 0.14);
  --scrim: rgba(20, 20, 26, 0.38);
  --track: rgba(15, 17, 21, 0.08);
  --text: #111318;
  --text-2: #464b57;
  --text-3: #767b86;
  --text-4: #a4a8b0;
  --accent: #7c3aed;
  --accent-2: #6d28d9;
  --accent-ink: #ffffff;
  --accent-soft: rgba(124, 58, 237, 0.1);
  --accent-line: rgba(124, 58, 237, 0.3);
  --treino: #6d5fd8;
  --cardio: #eb6834;
  --dieta: #1baf7a;
  --corpo: #2a78d6;
  --treino-soft: rgba(109, 95, 216, 0.1);
  --cardio-soft: rgba(235, 104, 52, 0.11);
  --dieta-soft: rgba(27, 175, 122, 0.12);
  --corpo-soft: rgba(42, 120, 214, 0.1);
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #4a3aa7; --s8: #e34948;
  --good: #16803f;
  --good-soft: rgba(22, 128, 63, 0.1);
  --warn: #a86400;
  --warn-soft: rgba(237, 161, 0, 0.14);
  --bad: #c9302c;
  --bad-soft: rgba(201, 48, 44, 0.09);
  --shadow-1: 0 1px 2px rgba(15, 17, 21, 0.06);
  --shadow-2: 0 16px 40px rgba(15, 17, 21, 0.16), 0 2px 6px rgba(15, 17, 21, 0.08);
  --glass: rgba(250, 250, 248, 0.82);
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
  min-height: 100dvh;
}
html.has-sheet, html.has-sheet body { overflow: hidden; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; touch-action: manipulation; }
img, svg { display: block; }
.ico { flex-shrink: 0; }
h1, h2, h3, h4, p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--accent-soft); }
.num, .tnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }
.dim { color: var(--text-2); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.good { color: var(--good); }
.bad { color: var(--bad); }
.warn { color: var(--warn); }
[hidden] { display: none !important; }

/* ==========================================================================
   Shell: sidebar (desktop) · view · tab bar (phone)
   ========================================================================== */
#app { min-height: 100dvh; }

.view {
  min-height: 100dvh;
  padding-top: var(--safe-t);
  padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 28px);
}
html.focus .view { padding-bottom: calc(var(--safe-b) + 24px); }
.view-enter { animation: view-in 0.2s var(--ease); }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.page { max-width: 1120px; margin: 0 auto; padding: 14px 16px 0; }
.page-narrow { max-width: 720px; }

/* Tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding: 6px 6px var(--safe-b);
  background: var(--glass);
  -webkit-backdrop-filter: saturate(170%) blur(20px);
  backdrop-filter: saturate(170%) blur(20px);
  border-top: 1px solid var(--line);
}
html.focus .tabbar { transform: translateY(110%); pointer-events: none; }
.tabbar { transition: transform 0.25s var(--ease); }
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.01em;
  color: var(--text-3);
  border-radius: 12px;
  transition: color 0.15s;
}
.tab .tab-ico { display: grid; place-items: center; width: 44px; height: 28px; border-radius: 999px; transition: background 0.2s var(--ease); }
.tab.is-active { color: var(--text); }
.tab.is-active .tab-ico { background: var(--accent-soft); color: var(--accent); }
.tab:active .tab-ico { transform: scale(0.94); }

/* Sidebar (desktop only) */
.sidebar { display: none; }

@media (min-width: 960px) {
  #app { display: grid; grid-template-columns: 248px minmax(0, 1fr); }
  .tabbar { display: none; }
  .view { padding-bottom: 48px; }
  .page { padding: 28px 36px 0; }
  .sidebar {
    display: flex; flex-direction: column; gap: 4px;
    position: sticky; top: 0; height: 100dvh;
    padding: 20px 14px;
    background: var(--bg-2);
    border-right: 1px solid var(--line);
    overflow-y: auto;
  }
  .brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 18px; }
  .brand-mark { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-2); color: var(--accent); }
  .brand-name { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
  .brand-sub { font-size: 12px; color: var(--text-3); }
  .nav-group { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-4); padding: 18px 12px 6px; }
  .nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 9px 12px; border-radius: 11px;
    color: var(--text-2); font-weight: 550; font-size: 14px;
    transition: background 0.15s, color 0.15s;
  }
  .nav-item:hover { background: var(--surface); color: var(--text); }
  .nav-item.is-active { background: var(--surface-2); color: var(--text); }
  .nav-item.is-active .ico { color: var(--accent); }
  .sidebar-foot { margin-top: auto; padding: 12px; font-size: 12px; color: var(--text-4); }
}

/* ==========================================================================
   Page scaffolding
   ========================================================================== */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 10px 0 18px; }
.page-head .titles { min-width: 0; }
.page-title { font-family: var(--font-display); font-size: 30px; line-height: 1.1; font-weight: 750; letter-spacing: -0.025em; }
.page-sub { color: var(--text-3); font-size: 14px; margin-top: 4px; }
.page-actions { display: flex; gap: 8px; flex-shrink: 0; }
@media (min-width: 960px) { .page-title { font-size: 32px; } }

/* Sub-page header with back button */
.subhead { display: flex; align-items: center; gap: 6px; padding: 6px 0 14px; margin-left: -8px; }
.subhead .titles { flex: 1; min-width: 0; }
.subhead h1 { font-size: 20px; font-weight: 700; letter-spacing: -0.015em; }
.subhead p { font-size: 13px; color: var(--text-3); }

.section { margin-top: 26px; }
.section:first-child { margin-top: 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 0 2px 10px; }
.section-title { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.section-link { font-size: 14px; font-weight: 600; color: var(--accent); display: inline-flex; align-items: center; gap: 2px; }
.eyebrow { font-size: 11.5px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-3); }

.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.grid-2, .grid-3, .grid-4 { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 720px) {
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
/* minmax(0, 1fr): without it the implicit track grows to fit horizontally
   scrolling children (chip rows, rails) and the page overflows on phones. */
.cols { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); }
.cols > .col { min-width: 0; }
@media (min-width: 1080px) {
  .cols { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: start; }
  .cols > .col { display: flex; flex-direction: column; gap: 20px; }
  .cols > .col > .section { margin-top: 0; }
}

/* ==========================================================================
   Cards & lists
   ========================================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px;
  position: relative;
}
.card-flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-title { font-size: 15px; font-weight: 650; }
.card-sub { font-size: 13px; color: var(--text-3); }
.card-link { display: block; transition: background 0.15s, transform 0.15s var(--ease); }
.card-link:active { transform: scale(0.99); background: var(--surface-2); }
@media (hover: hover) { .card-link:hover { background: var(--surface-2); } }

.hero {
  border-radius: var(--r-xl);
  padding: 18px;
  background:
    radial-gradient(120% 140% at 100% 0%, var(--c-soft, var(--accent-soft)) 0%, transparent 55%),
    var(--surface);
  border: 1px solid var(--line);
  position: relative;
  overflow: hidden;
}
.hero-treino, .c-treino { --c: var(--treino); --c-soft: var(--treino-soft); }
.hero-dieta, .c-dieta { --c: var(--dieta); --c-soft: var(--dieta-soft); }
.hero-cardio, .c-cardio { --c: var(--cardio); --c-soft: var(--cardio-soft); }
.hero-corpo, .c-corpo { --c: var(--corpo); --c-soft: var(--corpo-soft); }
.hero-title { font-family: var(--font-display); font-size: 22px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; margin-top: 4px; }
.hero-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 6px; color: var(--text-2); font-size: 13.5px; }
.hero-meta span { display: inline-flex; align-items: center; gap: 5px; }
.hero-meta .hero-why { color: var(--warn); font-weight: 650; }
.hero-note { margin-top: 8px; font-size: 12.5px; color: var(--text-3); }
.hero-actions { display: flex; gap: 8px; margin-top: 16px; }
/* Treino → "Último treino por grupo" */
.mg-row { display: flex; align-items: center; gap: 10px; }
.mg-name { width: 92px; flex-shrink: 0; font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.mg-days { width: 44px; flex-shrink: 0; text-align: right; font-size: 12.5px; font-weight: 650; }
.dom-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--accent)); display: inline-block; flex-shrink: 0; }

.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.list-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  min-height: 56px;
  width: 100%;
  text-align: left;
  position: relative;
}
.list-row + .list-row::before { content: ""; position: absolute; top: 0; left: 14px; right: 0; height: 1px; background: var(--line); }
button.list-row, a.list-row { transition: background 0.12s; }
button.list-row:active, a.list-row:active { background: var(--surface-2); }
@media (hover: hover) { button.list-row:hover, a.list-row:hover { background: var(--surface-2); } }
.list-row.is-selected, .list-row[aria-current="true"] { background: var(--surface-2); }
.lr-lead {
  width: 36px; height: 36px; border-radius: 11px; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--text-2);
}
.lr-lead.tone-treino { background: var(--treino-soft); color: var(--treino); }
.lr-lead.tone-dieta { background: var(--dieta-soft); color: var(--dieta); }
.lr-lead.tone-cardio { background: var(--cardio-soft); color: var(--cardio); }
.lr-lead.tone-corpo { background: var(--corpo-soft); color: var(--corpo); }
.lr-lead.tone-accent { background: var(--accent-soft); color: var(--accent); }
.lr-lead.tone-bad { background: var(--bad-soft); color: var(--bad); }
.lr-main { flex: 1; min-width: 0; }
.lr-title { font-weight: 600; font-size: 15px; line-height: 1.3; }
.lr-sub { font-size: 13px; color: var(--text-3); margin-top: 1px; }
.lr-trail { display: flex; align-items: center; gap: 8px; color: var(--text-3); font-size: 13.5px; flex-shrink: 0; }
.lr-chev { color: var(--text-4); }

/* ==========================================================================
   Buttons, chips, segmented control, badges
   ========================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px;
  border-radius: 14px;
  font-weight: 650; font-size: 15px; letter-spacing: -0.005em;
  white-space: nowrap;
  transition: transform 0.12s var(--ease), background 0.15s, opacity 0.15s, box-shadow 0.15s;
  position: relative;
  user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; pointer-events: none; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
@media (hover: hover) { .btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, white); } }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
@media (hover: hover) { .btn-secondary:hover { background: var(--surface-3); } }
.btn-ghost { color: var(--text-2); }
@media (hover: hover) { .btn-ghost:hover { background: var(--surface-2); color: var(--text); } }
.btn-danger { background: var(--bad); color: #fff; }
.btn-success { background: var(--dieta); color: #fff; }
.btn-tinted { background: var(--c-soft, var(--accent-soft)); color: var(--c, var(--accent)); }
.btn-sm { min-height: 36px; padding: 0 13px; font-size: 14px; border-radius: 11px; gap: 6px; }
.btn-lg { min-height: 54px; font-size: 16px; border-radius: 16px; }
.btn-block { width: 100%; }
.btn.is-busy { color: transparent !important; }
.btn.is-busy::after {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid currentColor; border-color: var(--text-3) transparent var(--text-3) transparent;
  animation: spin 0.7s linear infinite;
}
.btn-primary.is-busy::after { border-color: var(--accent-ink) transparent var(--accent-ink) transparent; }
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn {
  width: 40px; height: 40px; border-radius: 12px;
  display: inline-grid; place-items: center;
  color: var(--text-2);
  transition: background 0.12s, color 0.12s, transform 0.12s;
  flex-shrink: 0;
}
.icon-btn:active { transform: scale(0.94); background: var(--surface-2); }
@media (hover: hover) { .icon-btn:hover { background: var(--surface-2); color: var(--text); } }
.icon-btn.is-filled { background: var(--surface-2); border: 1px solid var(--line); }
.icon-btn:disabled { opacity: 0.35; pointer-events: none; }

.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px 16px; margin: 0 -16px; scroll-padding: 16px; }
.chips::-webkit-scrollbar { display: none; }
.chips.wrap-chips { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 0 14px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text-2);
  font-size: 14px; font-weight: 600;
  white-space: nowrap; flex-shrink: 0;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.12s;
}
.chip:active { transform: scale(0.96); }
.chip.is-on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.chip .chip-meta { color: var(--text-3); font-weight: 500; font-size: 12.5px; }
.chip.is-on .chip-meta { color: inherit; opacity: 0.8; }

.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border-radius: 12px; border: 1px solid var(--line); }
.seg button { min-height: 32px; padding: 0 12px; border-radius: 9px; font-size: 13.5px; font-weight: 600; color: var(--text-3); transition: background 0.15s, color 0.15s; flex: 1; white-space: nowrap; }
.seg button.is-on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
:root[data-theme="light"] .seg button.is-on { background: var(--surface); }
.seg-block { display: flex; width: 100%; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 8px;
  border-radius: 999px;
  font-size: 11.5px; font-weight: 650; letter-spacing: 0.01em;
  background: var(--surface-2); color: var(--text-2);
  white-space: nowrap;
}
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-good { background: var(--good-soft); color: var(--good); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.badge-treino { background: var(--treino-soft); color: var(--treino); }
.badge-dieta { background: var(--dieta-soft); color: var(--dieta); }
.badge-cardio { background: var(--cardio-soft); color: var(--cardio); }
.badge-corpo { background: var(--corpo-soft); color: var(--corpo); }
.mg { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-3); font-weight: 550; }
.mg::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--mg, var(--text-4)); }

.delta { font-weight: 650; font-variant-numeric: tabular-nums; }
.delta.is-good { color: var(--good); }
.delta.is-bad { color: var(--bad); }
.delta.is-flat { color: var(--text-3); }

/* ==========================================================================
   Stats, meters, rings
   ========================================================================== */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; min-width: 0; }
.stat-label { font-size: 12.5px; color: var(--text-3); font-weight: 550; }
.stat-value { font-family: var(--font-display); font-size: 24px; font-weight: 700; letter-spacing: -0.02em; margin-top: 2px; line-height: 1.15; }
.stat-value small { font-size: 14px; font-weight: 600; color: var(--text-3); margin-left: 2px; letter-spacing: 0; }
.stat-foot { font-size: 12.5px; color: var(--text-3); margin-top: 4px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.stat-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; }

.meter { height: 8px; border-radius: 999px; background: var(--track); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: inherit; background: var(--c, var(--accent)); transition: width 0.5s var(--ease); }
.meter.is-over > span { background: var(--warn); }

.ring { flex-shrink: 0; }
.ring circle:last-child { transition: stroke-dasharray 0.6s var(--ease); }
.ring-wrap { position: relative; display: inline-grid; place-items: center; }
.ring-wrap .ring-center { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; line-height: 1.1; }

.progress-line { height: 3px; background: var(--track); border-radius: 999px; overflow: hidden; }
.progress-line > span { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width 0.4s var(--ease); }

/* ==========================================================================
   Forms
   ========================================================================== */
.field { display: flex; flex-direction: column; gap: 6px; }
.field + .field { margin-top: 14px; }
.label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.label .opt { color: var(--text-4); font-weight: 500; }
.input, .select, .textarea {
  width: 100%;
  min-height: 46px;
  padding: 11px 14px;
  font-size: 16px;               /* ≥16px: no iOS zoom on focus */
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
  appearance: none;
}
.textarea { min-height: 84px; resize: vertical; line-height: 1.4; }
.select {
  padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23868c9a' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--surface); }
.input::placeholder, .textarea::placeholder { color: var(--text-4); }
.input-sm { min-height: 38px; padding: 7px 10px; border-radius: 10px; font-size: 15px; }
.search {
  position: relative;
}
.search .ico { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.search .input { padding-left: 40px; }
.hint { font-size: 12.5px; color: var(--text-3); }
.form-grid { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-grid .field + .field { margin-top: 0; }

.switch { position: relative; width: 50px; height: 30px; flex-shrink: 0; }
.switch input { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--surface-3); transition: background 0.2s; pointer-events: none; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform 0.2s var(--ease); }
.switch input:checked + span { background: var(--accent-2); }
.switch input:checked + span::after { transform: translateX(20px); }

/* Stepper (big number with −/+) */
.stepper { display: grid; grid-template-columns: 52px minmax(0, 1fr) 52px; align-items: center; gap: 8px; }
.stepper-btn {
  height: 52px; border-radius: 16px;
  display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
  transition: transform 0.1s, background 0.12s;
}
.stepper-btn:active { transform: scale(0.93); background: var(--surface-3); }
.stepper-value {
  height: 60px; width: 100%;
  text-align: center;
  font-family: var(--font-display);
  font-size: 34px; font-weight: 700; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  background: transparent; border: 0; border-radius: 14px;
  color: var(--text);
}
.stepper-value:focus { outline: none; background: var(--surface-2); }
.stepper-unit { text-align: center; font-size: 12.5px; color: var(--text-3); margin-top: -4px; }
.quick { display: flex; gap: 6px; justify-content: center; margin-top: 10px; flex-wrap: wrap; }
.quick button { min-height: 32px; padding: 0 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: 13px; font-weight: 650; color: var(--text-2); font-variant-numeric: tabular-nums; }
.quick button:active { transform: scale(0.95); }

/* ==========================================================================
   Sheets, action lists, toasts
   ========================================================================== */
.sheet-layer { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center; }
.sheet-scrim { position: absolute; inset: 0; background: var(--scrim); opacity: 0; transition: opacity 0.22s; }
.sheet {
  position: relative;
  width: 100%; max-width: 560px;
  max-height: calc(100dvh - var(--safe-t) - 24px);
  display: flex; flex-direction: column;
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  box-shadow: var(--shadow-2);
  transform: translateY(100%);
  transition: transform 0.3s var(--ease);
  padding-bottom: var(--safe-b);
  border: 1px solid var(--line);
  border-bottom: 0;
}
.sheet-tall { height: calc(100dvh - var(--safe-t) - 24px); }
.sheet-layer.in .sheet-scrim { opacity: 1; }
.sheet-layer.in .sheet { transform: none; }
.sheet-grab { display: flex; justify-content: center; padding: 8px 0 2px; touch-action: none; }
.sheet-grab span { width: 38px; height: 5px; border-radius: 999px; background: var(--line-2); }
.sheet-head { display: flex; align-items: flex-start; gap: 10px; padding: 6px 12px 10px 20px; touch-action: none; }
.sheet-titles { flex: 1; min-width: 0; padding-top: 6px; }
.sheet-titles h2 { font-size: 18px; font-weight: 700; letter-spacing: -0.015em; line-height: 1.25; }
.sheet-titles p { font-size: 13.5px; color: var(--text-3); margin-top: 2px; }
.sheet-body { padding: 4px 20px 20px; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; flex: 1; }
.sheet-foot { display: flex; gap: 10px; padding: 12px 20px 16px; border-top: 1px solid var(--line); }
.sheet-foot .btn { flex: 1; }
.sheet-text { color: var(--text-2); font-size: 15px; }
@media (min-width: 720px) {
  .sheet-layer { align-items: center; padding: 24px; }
  .sheet { border-radius: 24px; border-bottom: 1px solid var(--line); transform: translateY(16px) scale(0.98); opacity: 0; transition: transform 0.22s var(--ease), opacity 0.18s; padding-bottom: 0; max-height: min(86dvh, 820px); }
  .sheet-tall { height: min(86dvh, 820px); }
  .sheet-layer.in .sheet { opacity: 1; }
  .sheet-grab { display: none; }
  .sheet-head { padding-top: 14px; }
}

.action-list { display: flex; flex-direction: column; gap: 8px; }
.action-row {
  display: flex; align-items: center; gap: 14px;
  width: 100%; min-height: 58px; padding: 10px 14px;
  border-radius: 16px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  text-align: left;
  transition: background 0.12s, transform 0.12s var(--ease);
}
.action-row:active { transform: scale(0.985); background: var(--surface-3); }
@media (hover: hover) { .action-row:hover { background: var(--surface-3); } }
.action-ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); flex-shrink: 0; }
.action-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.action-label { font-weight: 650; font-size: 15px; }
.action-sub { font-size: 13px; color: var(--text-3); margin-top: 1px; }
.action-row.tone-primary { background: var(--accent-soft); border-color: var(--accent-line); }
.action-row.tone-primary .action-ico { background: var(--accent); color: var(--accent-ink); }
.action-row.tone-good .action-ico { background: var(--dieta); color: #fff; }
.action-row.tone-good { background: var(--dieta-soft); border-color: color-mix(in srgb, var(--dieta) 35%, transparent); }
.action-row.tone-danger .action-label { color: var(--bad); }
.action-row.tone-danger .action-ico { background: var(--bad-soft); color: var(--bad); }
.action-sep { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-4); margin: 10px 4px 0; }

#toasts {
  position: fixed; left: 0; right: 0; z-index: 200;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 14px);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none; padding: 0 16px;
}
html.focus #toasts { bottom: calc(var(--safe-b) + 96px); }
@media (min-width: 960px) { #toasts { bottom: 28px; left: 248px; } }
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 10px;
  max-width: 440px;
  padding: 11px 12px 11px 16px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface-3) 92%, transparent);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow-2);
  color: var(--text);
  font-size: 14.5px; font-weight: 550;
  transform: translateY(12px) scale(0.98); opacity: 0;
  transition: transform 0.22s var(--ease), opacity 0.2s;
}
.toast.in { transform: none; opacity: 1; }
.toast-msg { flex: 1; }
.toast-success .ico { color: var(--good); }
.toast-error .ico { color: var(--bad); }
.toast-act { color: var(--accent); font-weight: 700; padding: 6px 8px; border-radius: 8px; }

/* ==========================================================================
   Feedback: skeletons, empty states, banners
   ========================================================================== */
.skel {
  border-radius: var(--r-lg);
  background: linear-gradient(100deg, var(--surface) 30%, var(--surface-2) 50%, var(--surface) 70%);
  background-size: 300% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border: 1px solid var(--line);
}
.skel + .skel { margin-top: 12px; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

.empty { text-align: center; padding: 28px 18px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.empty-ico { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-3); margin-bottom: 6px; }
.empty-title { font-weight: 650; }
.empty-text { color: var(--text-3); font-size: 14px; max-width: 34ch; }
.empty .btn { margin-top: 10px; }
.empty.is-error .empty-ico { color: var(--bad); background: var(--bad-soft); }

.banner {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: var(--r);
  background: var(--surface); border: 1px solid var(--line);
  font-size: 14px;
}
.banner .ico { flex-shrink: 0; }
.banner-bad { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.banner-bad .ico { color: var(--bad); }
.banner-warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.banner-warn .ico { color: var(--warn); }
.banner-accent { background: var(--accent-soft); border-color: var(--accent-line); }
.banner-accent .ico { color: var(--accent); }
.banner .grow b { font-weight: 650; }

/* ==========================================================================
   Home: week strip
   ========================================================================== */
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.day {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 0 10px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  transition: transform 0.12s var(--ease), background 0.15s;
}
.day:active { transform: scale(0.96); }
.day.is-today { border-color: var(--accent-line); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.day-dow { font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; }
.day-num { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; }
.day-marks { display: flex; gap: 3px; height: 6px; }
.day-marks i { width: 6px; height: 6px; border-radius: 50%; background: var(--track); }
.day-marks i.m-treino { background: var(--treino); }
.day-marks i.m-cardio { background: var(--cardio); }
.day-marks i.m-dieta { background: var(--dieta); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-3); margin-top: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* Achievements rail */
.rail { display: flex; gap: 10px; overflow-x: auto; scrollbar-width: none; padding: 2px 16px 4px; margin: 0 -16px; scroll-snap-type: x proximity; }
.rail::-webkit-scrollbar { display: none; }
.rail > * { scroll-snap-align: start; flex-shrink: 0; }
.ach { width: 210px; padding: 12px 14px; display: flex; gap: 12px; align-items: flex-start; }
.ach-ico { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; background: var(--warn-soft); color: var(--warn); flex-shrink: 0; }
.ach-title { font-weight: 650; font-size: 14px; line-height: 1.3; }
.ach-sub { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }

/* ==========================================================================
   Workout logger
   ========================================================================== */
.logger-bar {
  position: sticky; top: 0; z-index: 30;
  padding: calc(var(--safe-t) + 6px) 8px 8px;
  margin-top: calc(-1 * var(--safe-t));
  background: var(--glass);
  -webkit-backdrop-filter: saturate(170%) blur(20px); backdrop-filter: saturate(170%) blur(20px);
  border-bottom: 1px solid var(--line);
}
.logger-bar-inner { display: flex; align-items: center; gap: 4px; max-width: 1120px; margin: 0 auto; }
.logger-title { flex: 1; min-width: 0; text-align: center; }
.logger-title b { display: block; font-size: 15.5px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logger-title span { font-size: 12.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.logger-bar .progress-line { max-width: 1120px; margin: 8px auto 0; }
.sync-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--warn); }

.ex-list { display: flex; flex-direction: column; gap: 12px; max-width: 760px; margin: 0 auto; }
.ex {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  overflow: hidden;
  transition: border-color 0.2s, opacity 0.2s;
  scroll-margin-top: 90px;
}
.ex.is-current { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.ex-head { display: flex; align-items: flex-start; gap: 12px; padding: 14px 10px 4px 14px; }
.ex-idx {
  width: 30px; height: 30px; border-radius: 10px; flex-shrink: 0;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 750; font-variant-numeric: tabular-nums;
  background: var(--surface-2); color: var(--text-2);
}
.ex.is-done .ex-idx { background: var(--good-soft); color: var(--good); }
.ex-name { font-weight: 700; font-size: 16px; line-height: 1.25; letter-spacing: -0.01em; }
.ex-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 3px; font-size: 12.5px; color: var(--text-3); }
.ex-meta b { color: var(--text-2); font-weight: 600; }
.ex-last { margin: 8px 14px 2px; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); font-size: 12.5px; color: var(--text-3); display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.ex-last b { color: var(--text-2); font-weight: 600; font-variant-numeric: tabular-nums; }
.ex-summary { padding: 0 14px 12px 56px; font-size: 13px; color: var(--text-3); font-variant-numeric: tabular-nums; }

.sets { padding: 6px 8px 8px; }
.sets-head, .set {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) minmax(0, 1.05fr) minmax(0, 0.95fr) 48px;
  align-items: center; gap: 6px;
}
.sets-head { padding: 6px 6px 4px; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-4); }
.sets-head > :nth-child(n+3) { text-align: center; }
.set { padding: 3px 6px; border-radius: 12px; min-height: 50px; transition: background 0.25s; }
.set-n { font-size: 13px; font-weight: 750; color: var(--text-3); text-align: center; font-variant-numeric: tabular-nums; }
.set-prev { font-size: 12.5px; color: var(--text-4); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.set-cell {
  height: 42px; border-radius: 11px;
  display: flex; align-items: center; justify-content: center; gap: 3px;
  background: var(--surface-2);
  font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--text);
  transition: background 0.15s, color 0.15s;
  width: 100%;
}
.set-cell small { font-size: 11px; font-weight: 600; color: var(--text-3); }
.set.is-pending .set-cell { color: var(--text-3); background: transparent; border: 1.5px dashed var(--line-2); }
.set-check {
  width: 44px; height: 42px; border-radius: 12px; justify-self: end;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--text-3);
  border: 1.5px solid var(--line-2);
  transition: background 0.15s, color 0.15s, transform 0.12s var(--ease), border-color 0.15s;
}
.set-check:active { transform: scale(0.9); }
.set.is-done .set-check { background: var(--good); border-color: var(--good); color: #06240f; }
:root[data-theme="light"] .set.is-done .set-check { color: #fff; }
.set.is-done { background: color-mix(in srgb, var(--good) 7%, transparent); }
.set.is-syncing .set-check { opacity: 0.6; }
.set.is-error .set-check { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.set.just-done { animation: set-pop 0.45s var(--ease); }
@keyframes set-pop { 0% { background: color-mix(in srgb, var(--good) 28%, transparent); } 100% { background: color-mix(in srgb, var(--good) 7%, transparent); } }
.set-tags { grid-column: 2 / -1; display: flex; gap: 6px; margin: -2px 0 2px; }
.pr-flag { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 750; color: var(--warn); }
.ex-foot { display: flex; gap: 8px; padding: 2px 14px 14px; }
.ex-foot .btn { flex: 1; }
/* Next-session suggestion under "Última vez" */
.ex-hint { margin: 6px 14px 2px; padding: 6px 6px 6px 10px; border-radius: 10px; background: var(--treino-soft); color: var(--text-2); font-size: 12.5px; display: flex; gap: 8px; align-items: center; }
.ex-hint .ico { color: var(--treino); flex-shrink: 0; }
.ex-hint b { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }
.ex-hint .btn { min-height: 30px; padding: 0 10px; flex-shrink: 0; }
/* Per-exercise difficulty ("Como foi?") */
.ex-rate { display: flex; align-items: center; gap: 10px; padding: 0 14px 10px; font-size: 12.5px; color: var(--text-3); }
.ex-rate .seg { flex: 1; }
.ex-rate .seg button { min-height: 34px; }
.ex-rate .seg button[data-k="facil"].is-on { color: var(--good); }
.ex-rate .seg button[data-k="dificil"].is-on { color: var(--bad); }
/* Unilateral toggle in the exercise header — a property of the exercise */
.uni-toggle { display: inline-flex; align-items: center; gap: 4px; min-height: 28px; padding: 0 8px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--text-4); font-size: 11.5px; font-weight: 650; }
.uni-toggle.is-on { background: var(--treino-soft); border-color: transparent; color: var(--treino); }

.logger-foot { max-width: 760px; margin: 18px auto 0; }

/* Rest timer pill */
.rest {
  position: fixed; z-index: 45; left: 50%;
  bottom: calc(var(--safe-b) + 16px);
  transform: translate(-50%, 140%);
  display: flex; align-items: center; gap: 8px;
  padding: 8px 8px 8px 10px;
  border-radius: 22px;
  background: color-mix(in srgb, var(--surface-3) 94%, transparent);
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow-2);
  transition: transform 0.3s var(--ease);
  width: min(420px, calc(100% - 24px));
}
@media (min-width: 960px) { .rest { left: calc(50% + 124px); } }
.rest.in { transform: translate(-50%, 0); }
.rest-time { font-family: var(--font-display); font-size: 24px; font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; min-width: 64px; }
.rest-label { font-size: 11.5px; color: var(--text-3); font-weight: 600; line-height: 1.1; }
.rest.is-over { border-color: var(--good); }
.rest.is-over .rest-time { color: var(--good); }
.rest .btn-sm { min-height: 38px; padding: 0 12px; }

/* Done screen */
.done { max-width: 520px; margin: 0 auto; padding: 28px 4px; text-align: center; }
.done-badge { width: 84px; height: 84px; border-radius: 28px; display: grid; place-items: center; margin: 12px auto 16px; background: var(--good-soft); color: var(--good); animation: pop-in 0.5s var(--ease); }
@keyframes pop-in { 0% { transform: scale(0.5); opacity: 0; } 70% { transform: scale(1.08); } 100% { transform: none; opacity: 1; } }
.done h1 { font-family: var(--font-display); font-size: 28px; font-weight: 750; letter-spacing: -0.02em; }

/* ==========================================================================
   Diet
   ========================================================================== */
.dates { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 2px 16px 4px; margin: 0 -16px; scroll-snap-type: x proximity; }
.dates::-webkit-scrollbar { display: none; }
.date {
  flex: 0 0 auto; width: 50px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px 0 8px; border-radius: 15px;
  background: var(--surface); border: 1px solid var(--line);
  scroll-snap-align: center;
  transition: background 0.15s, transform 0.12s var(--ease);
  position: relative;
}
.date:active { transform: scale(0.95); }
.date .day-dow { font-size: 10.5px; }
.date .day-num { font-size: 16px; }
.date.is-on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.date.is-on .day-dow { color: inherit; opacity: 0.75; }
.date-fill { width: 22px; height: 4px; border-radius: 999px; background: var(--track); overflow: hidden; }
.date-fill span { display: block; height: 100%; background: var(--dieta); border-radius: inherit; }
.date.is-on .date-fill { background: rgba(0,0,0,.15); }
.date.is-on .date-fill span { background: var(--accent-ink); }
.date.is-missing::after { content: ""; position: absolute; top: 6px; right: 7px; width: 6px; height: 6px; border-radius: 50%; background: var(--bad); }

.macro-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.macro-label { font-size: 12.5px; color: var(--text-3); font-weight: 600; margin-bottom: 6px; }
.macro-val { font-size: 12.5px; color: var(--text-3); margin-top: 6px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.macro-val b { color: var(--text); font-weight: 650; }

.meals { display: flex; flex-direction: column; gap: 10px; }
.meal {
  display: flex; align-items: stretch; gap: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  overflow: hidden;
  transition: border-color 0.2s, background 0.2s;
}
.meal-main { flex: 1; min-width: 0; padding: 13px 4px 13px 14px; text-align: left; display: flex; gap: 12px; }
.meal-time { width: 42px; flex-shrink: 0; font-size: 13px; font-weight: 700; color: var(--text-3); font-variant-numeric: tabular-nums; padding-top: 1px; }
.meal-body { flex: 1; min-width: 0; }
.meal-name { font-weight: 650; font-size: 15.5px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.meal-items { font-size: 13px; color: var(--text-3); margin-top: 3px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.meal-foot { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 12.5px; color: var(--text-3); flex-wrap: wrap; font-variant-numeric: tabular-nums; }
.meal-check {
  width: 64px; flex-shrink: 0;
  display: grid; place-items: center;
  border-left: 1px solid var(--line);
  color: var(--text-4);
  transition: background 0.15s, color 0.15s;
}
.meal-check .ck {
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  border: 2px solid var(--line-2);
  transition: all 0.2s var(--ease);
}
.meal-check:active .ck { transform: scale(0.88); }
.meal.is-planned .meal-check .ck, .meal.is-substituted .meal-check .ck { background: var(--dieta); border-color: var(--dieta); color: #fff; }
.meal.is-modified .meal-check .ck { background: var(--warn); border-color: var(--warn); color: #231400; }
.meal.is-skipped .meal-check .ck { background: var(--surface-3); border-color: var(--surface-3); color: var(--text-3); }
.meal.is-skipped .meal-name, .meal.is-skipped .meal-items { opacity: 0.6; }
.meal.is-next { border-color: color-mix(in srgb, var(--dieta) 45%, transparent); }
.meal.just-done .ck { animation: pop-in 0.4s var(--ease); }
.meal-extra { border-style: dashed; }

.mood-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.mood {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 6px; border-radius: 14px;
  background: var(--surface-2); border: 1.5px solid transparent;
  font-size: 13px; font-weight: 600; color: var(--text-2);
}
.mood.is-on.m-good { border-color: var(--good); color: var(--good); background: var(--good-soft); }
.mood.is-on.m-neutral { border-color: var(--warn); color: var(--warn); background: var(--warn-soft); }
.mood.is-on.m-bad { border-color: var(--bad); color: var(--bad); background: var(--bad-soft); }

.picker-results { margin-top: 8px; border-radius: 14px; border: 1px solid var(--line); overflow: hidden; background: var(--surface-2); }
.picker-results:empty { display: none; }
.picker-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px 14px; text-align: left; }
.picker-row + .picker-row { border-top: 1px solid var(--line); }
.picker-row:active { background: var(--surface-3); }
.staged { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.staged-item { display: grid; grid-template-columns: minmax(0, 1fr) 76px auto 36px; gap: 8px; align-items: center; padding: 8px 8px 8px 12px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.staged-item .input { min-height: 38px; padding: 6px 8px; text-align: right; font-size: 16px; border-radius: 10px; background: var(--surface); }
.item-chip.is-dropped { opacity: 0.45; text-decoration: line-through; }

/* ==========================================================================
   Body / tables / calendar
   ========================================================================== */
.kpis { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 900px) { .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.kpi .stat-value { font-size: 26px; }
.spark { margin-top: 6px; }

.chart { position: relative; }
.chart-plot { position: relative; width: 100%; touch-action: pan-y; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 10px; font-size: 12.5px; color: var(--text-2); }
.lg-item { display: inline-flex; align-items: center; gap: 6px; }
.lg-key { width: 14px; height: 3px; border-radius: 2px; background: var(--c); display: inline-block; flex-shrink: 0; }
.lg-key.is-dashed { background: repeating-linear-gradient(90deg, var(--c) 0 4px, transparent 4px 7px); }
.chart-empty { padding: 36px 0; text-align: center; color: var(--text-3); font-size: 14px; }
.chart-tip {
  position: absolute; top: 0; z-index: 3;
  min-width: 128px; padding: 8px 10px;
  border-radius: 12px;
  background: var(--surface-3);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow-2);
  font-size: 12.5px;
  pointer-events: none; opacity: 0; transform: translateY(-4px);
  transition: opacity 0.12s, transform 0.12s;
}
.chart-tip.on { opacity: 1; transform: none; }
.tip-date { font-weight: 700; margin-bottom: 4px; }
.tip-row { display: flex; align-items: center; gap: 6px; color: var(--text-2); white-space: nowrap; }
.tip-row .tip-name { flex: 1; }
.tip-row b { color: var(--text); font-variant-numeric: tabular-nums; }
.ch-grid { stroke: var(--line); stroke-width: 1; }
.ch-tick { fill: var(--text-3); font-size: 11px; font-variant-numeric: tabular-nums; font-family: var(--font); }
.ch-line { fill: none; stroke: var(--c); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ch-line.is-dashed { stroke-dasharray: 5 4; }
.ch-area { fill: var(--c); opacity: 0.1; stroke: none; }
.ch-dot { fill: var(--c); stroke: var(--surface); stroke-width: 2; }
.ch-dot.is-hl { stroke-width: 2.5; }
.ch-bar { fill: var(--c); }
.ch-ref { stroke: var(--text-4); stroke-width: 1; stroke-dasharray: 3 4; }
.ch-ref-lbl { fill: var(--text-3); font-size: 11px; font-family: var(--font); }
.ch-end { fill: var(--text); font-size: 12px; font-weight: 700; font-family: var(--font); font-variant-numeric: tabular-nums; }
.ch-cross { stroke: var(--text-4); stroke-width: 1; }

.table-wrap { overflow-x: auto; border-radius: var(--r-lg); border: 1px solid var(--line); background: var(--surface); -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; font-variant-numeric: tabular-nums; }
table.data th, table.data td { padding: 10px 12px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
table.data th { font-size: 11.5px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; background: var(--surface); position: sticky; top: 0; z-index: 1; }
table.data th:first-child, table.data td:first-child { text-align: left; position: sticky; left: 0; background: var(--surface); z-index: 1; }
table.data th:first-child { z-index: 2; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr.group td { background: var(--surface-2); font-size: 11.5px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.06em; }
table.data tr.group td:first-child { background: var(--surface-2); }
table.data td.lbl { color: var(--text-2); font-weight: 550; }

.cal { user-select: none; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-month { font-weight: 700; font-size: 16px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-dow { text-align: center; font-size: 11px; font-weight: 700; color: var(--text-4); padding: 4px 0; }
.cal-cell {
  aspect-ratio: 1 / 1; border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums;
  background: var(--surface-2);
  position: relative;
}
.cal-cell.is-out { background: transparent; color: var(--text-4); }
.cal-cell.is-today { box-shadow: inset 0 0 0 1.5px var(--accent); }
.cal-cell .day-marks { height: 5px; }
.cal-cell .day-marks i { width: 5px; height: 5px; }
.cal-cell.mood-good::after, .cal-cell.mood-neutral::after, .cal-cell.mood-bad::after { content: ""; position: absolute; top: 5px; right: 5px; width: 6px; height: 6px; border-radius: 50%; }
.cal-cell.mood-good::after { background: var(--good); }
.cal-cell.mood-neutral::after { background: var(--warn); }
.cal-cell.mood-bad::after { background: var(--bad); }

/* Upload zone */
.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 26px 16px; text-align: center;
  border-radius: var(--r-lg);
  border: 1.5px dashed var(--line-2);
  background: var(--surface);
  transition: border-color 0.15s, background 0.15s;
  cursor: pointer;
  width: 100%;
}
.drop:active, .drop.is-over { border-color: var(--accent-line); background: var(--accent-soft); }
.drop .drop-ico { width: 48px; height: 48px; border-radius: 15px; display: grid; place-items: center; background: var(--c-soft, var(--accent-soft)); color: var(--c, var(--accent)); }
.drop-title { font-weight: 650; }
.drop-sub { font-size: 13px; color: var(--text-3); }

/* Details / disclosure */
details.fold { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
details.fold > summary { list-style: none; cursor: pointer; padding: 14px 16px; display: flex; align-items: center; gap: 10px; font-weight: 650; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary .ico:last-child { margin-left: auto; color: var(--text-3); transition: transform 0.2s; }
details.fold[open] > summary .ico:last-child { transform: rotate(180deg); }
details.fold > .fold-body { padding: 0 16px 16px; }
.card details.fold { border-color: var(--line); background: var(--surface-2); }

/* Setup steps (Apple Health import) */
.steps { margin: 0 0 10px; padding-left: 20px; display: flex; flex-direction: column; gap: 10px; font-size: 14px; color: var(--text-2); line-height: 1.5; }
.steps b { color: var(--text); font-weight: 650; }
code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; background: var(--surface-3); padding: 1px 5px; border-radius: 6px; overflow-wrap: anywhere; }
.copy-row { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.copy-row code { flex: 1; min-width: 0; padding: 6px 8px; }

/* Admin tables (plan editors) */
.edit-row { display: grid; gap: 8px; align-items: center; }
.cell-input { width: 100%; min-height: 38px; padding: 6px 8px; border-radius: 9px; border: 1px solid transparent; background: transparent; font-size: 16px; font-variant-numeric: tabular-nums; transition: border-color 0.15s, background 0.15s; }
@media (hover: none) { .cell-input { background: var(--surface-2); } }   /* no hover hint on touch */
.cell-input:hover { background: var(--surface-2); }
.cell-input:focus { outline: none; background: var(--surface-2); border-color: var(--accent-line); }
.flash-ok { animation: flash-ok 0.9s; }
.flash-err { animation: flash-err 1.2s; }
@keyframes flash-ok { 0% { box-shadow: 0 0 0 2px var(--good); } 100% { box-shadow: 0 0 0 2px transparent; } }
@keyframes flash-err { 0%, 60% { box-shadow: 0 0 0 2px var(--bad); } 100% { box-shadow: 0 0 0 2px transparent; } }

/* Login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px calc(24px + var(--safe-b)); }
.login-card { width: 100%; max-width: 380px; }
.login-mark { width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; margin: 0 auto 16px; background: var(--surface); border: 1px solid var(--line); color: var(--accent); box-shadow: var(--shadow-2); }
.login h1 { text-align: center; font-family: var(--font-display); font-size: 26px; font-weight: 750; letter-spacing: -0.02em; }
.login .page-sub { text-align: center; margin-bottom: 26px; }
.check-row { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text-2); margin: 14px 0 18px; }
.check-row input { width: 18px; height: 18px; accent-color: var(--accent-2); }

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