/* FitGen-AI — design tokens, layout and components.
   Dark slate + emerald is the default look; Settings › Data switches to light or to the system theme.
   Fonts: Plus Jakarta Sans / JetBrains Mono when installed, otherwise the system UI fonts (the app
   works offline, so nothing is fetched from a font CDN). */
:root {
  --bg: #070b12;
  --bg-grad: linear-gradient(180deg, #020617 0%, #0a0f1d 42%, #070b12 100%);
  --sidebar: rgba(10, 15, 29, .92);
  --side-foot: rgba(2, 6, 23, .6);
  --header: rgba(10, 15, 29, .82);
  --card: rgba(15, 23, 42, .9);
  --surface: #0f172a;
  --surface-2: rgba(2, 6, 23, .62);
  --surface-3: #1e293b;
  --input: #020617;
  --btn: #0f172a;
  --btn-hover: #1e293b;
  --hover: rgba(30, 41, 59, .45);
  --border: #1e293b;
  --border-2: rgba(51, 65, 85, .8);
  --border-3: #475569;
  --divider: rgba(30, 41, 59, .6);
  --text-strong: #ffffff;
  --text: #e2e8f0;
  --text-2: #94a3b8;
  --text-3: #64748b;
  --accent: #10b981;
  --accent-strong: #34d399;
  --accent-3: #6ee7b7;
  --accent-soft: rgba(16, 185, 129, .14);
  --accent-line: rgba(16, 185, 129, .28);
  --accent-ink: #020617;
  --accent-grad: linear-gradient(90deg, #10b981, #14b8a6);
  --accent-grad-hover: linear-gradient(90deg, #34d399, #2dd4bf);
  --teal: #2dd4bf;
  --cyan: #22d3ee;
  --protein: #818cf8;
  --carbs: #fbbf24;
  --fat: #fb7185;
  --fiber: #34d399;
  --gym: #38bdf8; --gym-soft: rgba(56, 189, 248, .13);
  --home: #a78bfa; --home-soft: rgba(167, 139, 250, .13);
  --rest: #94a3b8; --rest-soft: rgba(148, 163, 184, .1);
  --danger: #fb7185; --danger-soft: rgba(244, 63, 94, .13);
  --warn: #fbbf24; --warn-ink: #fcd34d; --warn-soft: rgba(245, 158, 11, .15);
  --ok: #34d399;
  --shadow: 0 20px 25px -5px rgba(0, 0, 0, .35), 0 8px 10px -6px rgba(0, 0, 0, .3);
  --shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, .55);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --glow: 0 10px 15px -3px rgba(16, 185, 129, .22), 0 4px 6px -4px rgba(16, 185, 129, .22);
  --inset: inset 0 2px 4px rgba(0, 0, 0, .3);
  --accent-tile: rgba(2, 44, 34, .18); --accent-tile-line: rgba(6, 78, 59, .45);
  --radius: 16px;
  --radius-sm: 12px;
  --font: "Plus Jakarta Sans", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Code", "Cascadia Mono", Consolas, ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg: #f1f5f9; --bg-grad: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    --sidebar: rgba(255, 255, 255, .95); --side-foot: #f8fafc; --header: rgba(248, 250, 252, .86);
    --card: #ffffff; --surface: #ffffff; --surface-2: #f8fafc; --surface-3: #e2e8f0; --input: #ffffff;
    --btn: #ffffff; --btn-hover: #f1f5f9; --hover: #f1f5f9;
    --border: #e2e8f0; --border-2: #cbd5e1; --border-3: #94a3b8; --divider: #e2e8f0;
    --text-strong: #0f172a; --text: #1e293b; --text-2: #475569; --text-3: #64748b;
    --accent-strong: #059669; --accent-3: #047857; --accent-soft: rgba(16, 185, 129, .12); --accent-line: rgba(5, 150, 105, .3); --accent-ink: #022c22;
    --teal: #0d9488; --cyan: #0891b2;
    --protein: #6366f1; --carbs: #d97706; --fat: #e11d48; --fiber: #059669;
    --gym: #0284c7; --gym-soft: #e0f2fe; --home: #7c3aed; --home-soft: #ede9fe; --rest: #64748b; --rest-soft: #f1f5f9;
    --danger: #e11d48; --danger-soft: #ffe4e6; --warn: #d97706; --warn-ink: #b45309; --warn-soft: #fef3c7; --ok: #059669;
    --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 8px 24px rgba(15, 23, 42, .06); --shadow-lg: 0 12px 32px rgba(15, 23, 42, .1);
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06); --glow: 0 8px 18px -8px rgba(16, 185, 129, .55); --inset: inset 0 1px 2px rgba(15, 23, 42, .06);
    --accent-tile: rgba(16, 185, 129, .06); --accent-tile-line: rgba(5, 150, 105, .28);
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #f1f5f9; --bg-grad: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  --sidebar: rgba(255, 255, 255, .95); --side-foot: #f8fafc; --header: rgba(248, 250, 252, .86);
  --card: #ffffff; --surface: #ffffff; --surface-2: #f8fafc; --surface-3: #e2e8f0; --input: #ffffff;
  --btn: #ffffff; --btn-hover: #f1f5f9; --hover: #f1f5f9;
  --border: #e2e8f0; --border-2: #cbd5e1; --border-3: #94a3b8; --divider: #e2e8f0;
  --text-strong: #0f172a; --text: #1e293b; --text-2: #475569; --text-3: #64748b;
  --accent-strong: #059669; --accent-3: #047857; --accent-soft: rgba(16, 185, 129, .12); --accent-line: rgba(5, 150, 105, .3); --accent-ink: #022c22;
  --teal: #0d9488; --cyan: #0891b2;
  --protein: #6366f1; --carbs: #d97706; --fat: #e11d48; --fiber: #059669;
  --gym: #0284c7; --gym-soft: #e0f2fe; --home: #7c3aed; --home-soft: #ede9fe; --rest: #64748b; --rest-soft: #f1f5f9;
  --danger: #e11d48; --danger-soft: #ffe4e6; --warn: #d97706; --warn-ink: #b45309; --warn-soft: #fef3c7; --ok: #059669;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 8px 24px rgba(15, 23, 42, .06); --shadow-lg: 0 12px 32px rgba(15, 23, 42, .1);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06); --glow: 0 8px 18px -8px rgba(16, 185, 129, .55); --inset: inset 0 1px 2px rgba(15, 23, 42, .06);
    --accent-tile: rgba(16, 185, 129, .06); --accent-tile-line: rgba(5, 150, 105, .28);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background-color: var(--bg); background-image: var(--bg-grad); background-attachment: fixed;
  color: var(--text); font-family: var(--font); font-size: 14.5px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -0.015em; color: var(--text-strong); }
h1 { font-size: 24px; font-weight: 900; letter-spacing: -0.025em; }
h2 { font-size: 17px; font-weight: 800; }
h3 { font-size: 15px; font-weight: 700; }
p { margin: 0; }
a { color: var(--accent-strong); }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: rgba(16, 185, 129, .3); }
.num, td.num, .tabular { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.hidden { display: none !important; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grow { flex: 1; min-width: 0; }
code, .mono-sm { font-family: var(--mono); font-size: 12.5px; }
code { background: var(--surface-3); border: 1px solid var(--border-2); padding: 1px 6px; border-radius: 6px; color: var(--text); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-3); }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: 288px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; justify-content: space-between; z-index: 30;
  background: var(--sidebar); border-right: 1px solid var(--border); user-select: none;
}
.side-top { display: flex; flex-direction: column; gap: 24px; padding: 20px; overflow-y: auto; min-height: 0; }
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 6px 0; min-width: 0; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, #34d399, #059669); color: #020617; box-shadow: var(--glow);
}
.brand-row { display: flex; align-items: center; gap: 6px; }
.brand-name { font-weight: 800; font-size: 18px; letter-spacing: -0.025em; line-height: 1.2; color: var(--text-strong); white-space: nowrap; }
.brand-name span { color: var(--accent-strong); }
.brand-sub { font-size: 12px; color: var(--text-2); font-weight: 500; white-space: nowrap; }
.local-badge {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; padding: 1px 6px; border-radius: 4px;
  background: var(--accent-soft); color: var(--accent-strong); border: 1px solid var(--accent-line);
}
.nav { display: flex; flex-direction: column; gap: 4px; font-size: 14px; font-weight: 500; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 12px; border: 1px solid transparent;
  color: var(--text-2); text-decoration: none; transition: background .15s, color .15s, border-color .15s;
}
.nav a svg { flex: none; color: var(--text-3); transition: color .15s, transform .15s; }
.nav a:hover { color: var(--text); background: var(--hover); }
.nav a:hover svg { color: var(--accent-strong); transform: scale(1.1); }
.nav a.active { background: var(--accent-soft); color: var(--accent-3); border-color: rgba(16, 185, 129, .2); box-shadow: var(--shadow-sm); }
.nav a.active .lbl { color: var(--text-strong); font-weight: 600; }
.nav a.active svg { color: var(--accent-strong); }
.nav .end { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; }
.nav a.active .end::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent-strong); box-shadow: 0 1px 3px rgba(52, 211, 153, .6); }
.ai-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); flex: none; margin-left: -4px; }
.ai-dot.ok { background: var(--ok); animation: pulse 2s cubic-bezier(.4, 0, .6, 1) infinite; }
.ai-dot.busy { background: var(--gym); animation: pulse 1s infinite; }
.ai-dot.err { background: var(--danger); }
.nav-badge { font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 4px; border: 1px solid transparent; white-space: nowrap; }
.nav-badge.ready { background: rgba(245, 158, 11, .2); color: var(--warn-ink); border-color: rgba(245, 158, 11, .3); }
.nav-badge.live { background: var(--accent-soft); color: var(--accent-strong); border-color: var(--accent-line); animation: pulse 2s infinite; }
.nav-badge.done { background: var(--accent-soft); color: var(--accent-strong); border-color: var(--accent-line); }
.count-badge { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: #f59e0b; color: #1f1300; font-size: 11px; font-weight: 800; }

.side-foot { display: flex; flex-direction: column; gap: 12px; padding: 16px; border-top: 1px solid var(--border); background: var(--side-foot); }
.gpu-card {
  display: block; padding: 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border);
  font-size: 12px; text-decoration: none; color: inherit; transition: border-color .15s;
}
.gpu-card:hover { border-color: var(--border-2); }
.gpu-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--divider); }
.gpu-name { display: flex; align-items: center; gap: 6px; font-weight: 600; color: var(--text); min-width: 0; overflow: hidden; }
.gpu-name svg { color: var(--accent-strong); flex: none; }
.gpu-name .gpu-kind { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gpu-chip {
  display: inline-flex; align-items: center; gap: 5px; flex: none; font-size: 10px; font-family: var(--mono); font-weight: 700;
  padding: 2px 6px; border-radius: 4px; background: var(--accent-soft); color: var(--accent-strong); white-space: nowrap;
}
.gpu-chip.busy { background: var(--gym-soft); color: var(--gym); }
.gpu-chip.err { background: var(--danger-soft); color: var(--danger); }
.gpu-vram { margin-top: 10px; }
.gpu-vram .row { justify-content: space-between; font-size: 11px; color: var(--text-2); gap: 6px; }
.gpu-vram .gpu-num { font-family: var(--mono); font-weight: 600; color: var(--text); white-space: nowrap; }
.gpu-bar { height: 8px; margin-top: 4px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.gpu-bar > i { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #2dd4bf, #34d399); transition: width .4s ease; }
.gpu-bar > i.hot { background: linear-gradient(90deg, #f59e0b, #fb7185); }
.gpu-models { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--divider); font-size: 10px; font-family: var(--mono); }
.gpu-models > div { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--text-2); }
.gpu-models .m { color: var(--text); font-weight: 500; background: var(--surface-3); padding: 1px 5px; border-radius: 4px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gpu-models .m.loaded::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 5px; border-radius: 50%; background: var(--ok); vertical-align: 1px; }
.gpu-models .m.none { color: var(--text-3); background: transparent; padding: 0; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 4px 0; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: linear-gradient(45deg, #059669, #2dd4bf); color: #020617; font-weight: 800; font-size: 12px; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, .3);
}
.user-chip .who { flex: 1; min-width: 0; line-height: 1.3; }
.user-chip .who strong { display: block; font-size: 12px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .who span { display: block; font-size: 10px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: 78px; padding: 16px 32px; background: var(--header); border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.head-text { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.title-row > span:empty { display: none; }
.topbar h1 { font-size: 24px; }
.page-sub { font-size: 12px; color: var(--text-2); }
.page-sub:empty { display: none; }
.page-sub strong { color: var(--text); font-weight: 600; }
.head-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; flex-wrap: wrap; }
.page-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-actions:empty { display: none; }
.date-badge {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 12px; white-space: nowrap;
  background: var(--surface); border: 1px solid var(--border); font-size: 12px; font-weight: 500; color: var(--text); box-shadow: var(--inset);
}
.date-badge svg { color: var(--text-2); }
.phase-badge {
  display: inline-flex; align-items: center; gap: 7px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--accent-soft); color: var(--accent-strong); border: 1px solid rgba(16, 185, 129, .22); white-space: nowrap;
}
.ping { position: relative; width: 6px; height: 6px; border-radius: 50%; background: var(--accent-strong); flex: none; }
.ping::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: inherit; animation: ping 1.4s cubic-bezier(0, 0, .2, 1) infinite; }
@keyframes ping { 75%, 100% { transform: scale(2.4); opacity: 0; } }
@keyframes pulse { 50% { opacity: .4; } }
.status-pill {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 10px; border-radius: 999px; white-space: nowrap;
  background: var(--surface); border: 1px solid var(--border); font-size: 12px; font-weight: 600; color: var(--text-2); text-decoration: none;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); flex: none; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px var(--accent-soft); }
.dot.warn { background: var(--warn); }
.dot.err { background: var(--danger); }
.dot.busy { background: var(--gym); animation: pulse 1.2s infinite; }
.view { padding: 32px; max-width: 1280px; width: 100%; margin: 0 auto; }
.mobile-bar, .tabbar { display: none; }

/* ---------- cards & grid ---------- */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; min-width: 0;
}
.card > header { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
/* The title never shrinks below its longest word: when it doesn't fit beside the meta text, the meta wraps below. */
.card > header h2 {
  flex: 1 1 auto; min-width: min-content; display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: var(--text);
}
.card > header h2.title { text-transform: none; letter-spacing: -0.015em; font-size: 17px; font-weight: 800; color: var(--text-strong); }
.card > header .meta { font-size: 12px; font-family: var(--mono); color: var(--text-2); }
.hd-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--accent-strong)); flex: none; }
.grid { display: grid; gap: 20px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.split { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); align-items: start; }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: 1 / -1; }
.section-title { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-2); margin: 28px 0 12px; }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px;
  border-radius: 12px; border: 1px solid var(--border-2); background: var(--btn); cursor: pointer; color: var(--text);
  font-weight: 700; font-size: 13px; white-space: nowrap; text-decoration: none; box-shadow: var(--shadow-sm);
  transition: background .15s, border-color .15s, color .15s, transform .15s, box-shadow .15s;
}
.btn svg { flex: none; }
.btn:hover { background: var(--btn-hover); border-color: var(--border-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn .ic-accent { color: var(--accent-strong); }
.btn.primary { background: var(--accent-grad); border-color: transparent; color: var(--accent-ink); box-shadow: var(--glow); }
.btn.primary:hover { background: var(--accent-grad-hover); transform: scale(1.02); }
.btn.primary:disabled:hover { transform: none; background: var(--accent-grad); }
.btn.soft { background: var(--accent-soft); border-color: rgba(16, 185, 129, .3); color: var(--accent-3); box-shadow: none; }
.btn.soft:hover { background: rgba(16, 185, 129, .25); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); box-shadow: none; }
.btn.ghost:hover { background: var(--hover); color: var(--text); }
.btn.danger { color: var(--danger); }
.btn.sm { height: 30px; padding: 0 11px; font-size: 12px; border-radius: 10px; }
.btn.xs { height: 24px; padding: 0 10px; font-size: 11px; border-radius: 6px; gap: 4px; }
.btn.icon { width: 36px; padding: 0; }
.btn.icon.sm { width: 30px; height: 30px; }
.btn .spin { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.text-link { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; color: var(--accent-strong); text-decoration: none; background: none; border: 0; padding: 0; cursor: pointer; }
.text-link:hover { color: var(--accent-3); }
.text-link.quiet { color: var(--text-2); font-weight: 500; }
.text-link.quiet:hover { color: var(--text); }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--text-3); }
.input, select.input, textarea.input {
  width: 100%; height: 40px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-2);
  background: var(--input); color: var(--text-strong); outline: none; transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--text-3); }
textarea.input { height: auto; min-height: 80px; padding: 10px 12px; resize: vertical; }
.input:focus { border-color: var(--accent-strong); box-shadow: 0 0 0 3px rgba(16, 185, 129, .16); }
.input.sm { height: 32px; padding: 0 9px; font-size: 13.5px; border-radius: 9px; }
.input.num { text-align: right; }
.input-group { display: flex; align-items: center; gap: 6px; }
.input-group .unit { color: var(--text-3); font-size: 13px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }

.seg { display: inline-flex; padding: 3px; gap: 3px; border-radius: 12px; background: var(--input); border: 1px solid var(--border); flex-wrap: wrap; }
.seg button {
  border: 0; background: transparent; padding: 6px 12px; border-radius: 9px; cursor: pointer; font-weight: 600;
  font-size: 13px; color: var(--text-2); min-width: 38px;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface-3); color: var(--text-strong); box-shadow: var(--shadow-sm); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--border-2); background: var(--surface); cursor: pointer; font-size: 13px; font-weight: 550; color: var(--text-2);
}
.chip:hover { border-color: var(--border-3); color: var(--text); }
.chip.on { border-color: rgba(16, 185, 129, .45); background: var(--accent-soft); color: var(--accent-3); }

.choice-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.choice {
  text-align: left; padding: 14px; border-radius: 12px; border: 1.5px solid var(--border-2); background: var(--surface-2);
  cursor: pointer; display: flex; flex-direction: column; gap: 4px; color: var(--text);
}
.choice:hover { border-color: var(--border-3); }
.choice.on { border-color: var(--accent); background: var(--accent-soft); }
.choice strong { font-size: 15px; color: var(--text-strong); }
.choice span { font-size: 13px; color: var(--text-2); }

.switch { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; }
.switch input { appearance: none; width: 38px; height: 22px; border-radius: 999px; background: var(--surface-3); position: relative; flex: none; cursor: pointer; transition: background .15s; margin: 1px 0 0; border: 1px solid var(--border-2); }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, .35); }
.switch input:checked { background: var(--accent); border-color: var(--accent); }
.switch input:checked::after { transform: translateX(16px); }

/* ---------- badges & tags ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 11.5px;
  font-weight: 700; background: var(--surface-3); color: var(--text); border: 1px solid var(--border-2); white-space: nowrap;
}
.badge.gym { background: var(--gym-soft); color: var(--gym); border-color: transparent; }
.badge.home { background: var(--home-soft); color: var(--home); border-color: transparent; }
.badge.rest { background: var(--rest-soft); color: var(--rest); border-color: transparent; }
.badge.ai { background: var(--accent-soft); color: var(--accent-strong); border-color: rgba(16, 185, 129, .25); }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.tag {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 6px; white-space: nowrap;
  background: var(--surface-3); color: var(--text); font-size: 12px; font-weight: 500; border: 1px solid var(--border-2);
}
.tag.primary { background: rgba(16, 185, 129, .15); color: var(--accent-3); border-color: rgba(16, 185, 129, .3); font-weight: 600; }
.kicker {
  font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; padding: 2px 8px; border-radius: 4px; white-space: nowrap;
  background: rgba(16, 185, 129, .2); color: var(--accent-3); border: 1px solid rgba(16, 185, 129, .3);
}
.kicker.rest { background: var(--rest-soft); color: var(--rest); border-color: var(--border-2); }

/* ---------- metrics ---------- */
.metric { display: flex; flex-direction: column; gap: 2px; }
.metric .v { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; color: var(--text-strong); }
.metric .k { font-size: 12px; color: var(--text-2); font-weight: 600; }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 14px; }
.bar { height: 8px; border-radius: 999px; background: var(--input); border: 1px solid var(--border); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width .4s ease; }
.macro-row { display: grid; grid-template-columns: 72px 1fr auto; gap: 10px; align-items: center; }
.macro-row .name { font-weight: 600; font-size: 13px; }
.macro-row .val { font-size: 12.5px; font-family: var(--mono); color: var(--text-2); text-align: right; min-width: 104px; }
.legend-dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; }

.ring-wrap { display: flex; align-items: center; gap: 22px; }
.ring-label { position: relative; }
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-center .v { font-size: 26px; font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; color: var(--text-strong); }
.ring-center .k { font-size: 12px; color: var(--text-2); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left; font-family: var(--mono); font-size: 11px; font-weight: 600; letter-spacing: .02em; text-transform: uppercase;
  color: var(--text-2); padding: 9px 10px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.data td { padding: 10px; border-bottom: 1px solid var(--divider); vertical-align: top; }
table.data tbody tr:hover { background: var(--hover); }
table.data tr:last-child td { border-bottom: 0; }
table.data td.num, table.data th.num { text-align: right; white-space: nowrap; }
table.data .ex-name { font-weight: 700; color: var(--text-strong); }
table.data .sub { font-size: 12px; color: var(--text-2); }

/* ---------- toasts & modal ---------- */
/* Messages are informational only: clicks pass through them to the page underneath. */
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; pointer-events: none; }
.toast {
  pointer-events: none; background: #0f172a; color: #e2e8f0; border: 1px solid #334155; padding: 11px 16px; border-radius: 12px;
  font-size: 13.5px; font-weight: 500; max-width: 380px; box-shadow: 0 20px 40px -12px rgba(0, 0, 0, .6); animation: rise .2s ease;
}
.toast.error { background: #4c0519; border-color: #9f1239; color: #ffe4e6; }
.toast.ok { background: #022c22; border-color: #047857; color: #d1fae5; }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }
.modal-back {
  position: fixed; inset: 0; background: rgba(2, 6, 23, .7); display: grid; place-items: center; z-index: 50; padding: 16px;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); animation: fade .15s;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: min(560px, 100%); max-height: min(720px, 92vh); display: flex; flex-direction: column; background: var(--surface);
  border-radius: var(--radius); border: 1px solid var(--border-2); box-shadow: var(--shadow-lg);
}
.modal > header { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.modal > header h2 { flex: 1; font-size: 16px; }
.modal .body { padding: 16px 18px; overflow-y: auto; }
.modal > footer { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--border); }

/* ---------- empty / notices ---------- */
.empty { text-align: center; padding: 28px 16px; color: var(--text-2); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty .ico { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); }
.empty h3 { color: var(--text-strong); }
.notice { display: flex; gap: 10px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); font-size: 13.5px; color: var(--text); }
.notice.warn { background: var(--warn-soft); border-color: rgba(245, 158, 11, .25); }
.notice.err { background: var(--danger-soft); border-color: rgba(244, 63, 94, .25); }
.notice.ok { background: var(--accent-soft); border-color: var(--accent-line); }
.notice svg { flex: none; margin-top: 2px; }

/* ---------- pipeline / progress ---------- */
.steps { display: flex; flex-direction: column; gap: 2px; }
.step { display: grid; grid-template-columns: 22px 1fr; gap: 10px; align-items: start; padding: 6px 0; font-size: 13.5px; color: var(--text-3); }
.step .ic { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--border-2); display: grid; place-items: center; margin-top: 1px; }
.step.active { color: var(--text); }
.step.active .ic { border-color: var(--accent-strong); border-top-color: transparent; animation: spin .8s linear infinite; }
.step.done { color: var(--text-2); }
.step.done .ic { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.step.fail .ic { background: var(--danger); border-color: var(--danger); color: #fff; }
.step .detail { font-size: 12px; color: var(--text-3); margin-top: 2px; font-family: var(--mono); }
.progress { height: 6px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #2dd4bf, #34d399); transition: width .3s; }
.progress.indeterminate > i { width: 35%; animation: slide 1.2s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(300%); } }
.stats-line { font-size: 12px; color: var(--text-3); font-family: var(--mono); }

/* ---------- Today dashboard ---------- */
.dash { display: flex; flex-direction: column; gap: 28px; }
.dash-row { display: grid; grid-template-columns: minmax(0, 4fr) minmax(0, 5fr) minmax(0, 3fr); gap: 24px; }
.dash-row > .card { display: flex; flex-direction: column; justify-content: space-between; }
.dash-row > .card > header { margin-bottom: 4px; }
.kcal-ring {
  --p: 0%; --ring: var(--accent); width: 176px; height: 176px; margin: 16px auto; padding: 12px; border-radius: 50%;
  background: conic-gradient(var(--ring) 0 var(--p), var(--surface-3) var(--p) 100%); box-shadow: var(--inset);
}
.kcal-ring.over { --ring: var(--warn); }
.kcal-inner {
  width: 100%; height: 100%; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); text-align: center;
}
.kcal-inner .v { font-size: 30px; font-weight: 900; letter-spacing: -0.025em; line-height: 1.1; color: var(--text-strong); font-variant-numeric: tabular-nums; }
.kcal-inner .l { font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--accent-strong); }
.kcal-inner hr { width: 48px; height: 1px; margin: 4px 0; border: 0; background: var(--border); }
.kcal-inner .r { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--text-2); white-space: nowrap; }
.kcal-ring.over .kcal-inner .l, .kcal-ring.over .kcal-inner .r { color: var(--warn); }
.stat-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding-top: 10px; border-top: 1px solid var(--border); text-align: center; }
.stat-pair > div { padding: 8px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--divider); min-width: 0; }
.stat-pair span { display: block; font-size: 11px; color: var(--text-2); }
.stat-pair strong { font-size: 14px; font-weight: 700; font-family: var(--mono); color: var(--text); white-space: nowrap; }
.stat-pair strong.ok { color: var(--accent-strong); }
.mlist { display: flex; flex-direction: column; gap: 16px; margin: 12px 0; }
.mrow { display: flex; flex-direction: column; gap: 6px; }
.mtop { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; }
.mname { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--text); white-space: nowrap; }
.mname i { width: 10px; height: 10px; border-radius: 2px; background: var(--c); }
.mval { font-family: var(--mono); color: var(--text); white-space: nowrap; }
.mval strong { color: var(--c); font-weight: 700; }
.mval small { font-size: 10px; color: var(--text-3); }
.mbar { height: 8px; border-radius: 999px; background: var(--input); border: 1px solid var(--border); overflow: hidden; }
.mbar > i { display: block; height: 100%; border-radius: inherit; background: var(--c); transition: width .5s ease; }
.insight { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12px; color: var(--text-2); }
.insight strong { font-size: 11px; font-weight: 700; white-space: nowrap; color: var(--accent-strong); }
.insight strong.warn { color: var(--warn); }
.card > header .meta.goal { font-family: var(--font); font-size: 11px; }
.w-now { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.w-now .v { font-size: 36px; font-weight: 900; letter-spacing: -0.025em; line-height: 1; color: var(--text-strong); font-variant-numeric: tabular-nums; }
.w-now .u { font-size: 14px; font-weight: 700; color: var(--text-2); }
.w-delta { margin-left: auto; padding: 2px 8px; border-radius: 8px; font-size: 12px; font-weight: 600; white-space: nowrap; color: var(--accent-strong); background: var(--accent-soft); border: 1px solid rgba(16, 185, 129, .2); }
.w-delta.off { color: var(--warn); background: var(--warn-soft); border-color: rgba(245, 158, 11, .25); }
.spark-area { position: relative; height: 56px; margin-top: 12px; }
.spark-area svg { display: block; width: 100%; height: 100%; overflow: visible; }
.spark-area .end { position: absolute; width: 8px; height: 8px; border-radius: 50%; background: var(--accent-strong); transform: translate(-50%, -50%); box-shadow: 0 0 0 3px rgba(16, 185, 129, .2); }
.spark-empty { height: 56px; margin-top: 12px; display: grid; place-items: center; font-size: 12px; color: var(--text-3); border: 1px dashed var(--border-2); border-radius: 12px; }
.quick-log { display: flex; gap: 8px; padding-top: 12px; margin-top: 12px; border-top: 1px solid var(--border); }
.unit-input { position: relative; flex: 1; min-width: 0; }
.unit-input .input { height: 32px; padding-right: 32px; font-size: 12px; font-family: var(--mono); }
.unit-input .u { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-size: 12px; color: var(--text-3); pointer-events: none; }

.train { display: flex; flex-direction: column; gap: 16px; }
.train-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.train-head .title-row { gap: 8px; }
.train-head h2 { font-size: 20px; font-weight: 900; letter-spacing: -0.025em; }
.train-head .sub { font-size: 12px; color: var(--text-2); margin-top: 3px; }
.train-head .sub strong { color: var(--text); font-weight: 600; }
.train-grid { display: grid; grid-template-columns: minmax(0, 8fr) minmax(0, 4fr); gap: 24px; align-items: stretch; }
.spot { padding: 24px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; justify-content: space-between; }
.spot-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.spot-kicker { display: flex; align-items: center; gap: 8px; font-size: 12px; font-family: var(--mono); font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--accent-strong); }
.pulse-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent-strong); animation: pulse 2s cubic-bezier(.4, 0, .6, 1) infinite; flex: none; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.spot-title { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.spot-title h3 { font-size: 24px; font-weight: 900; letter-spacing: -0.025em; }
.spot-title p { font-size: 12px; color: var(--text-2); margin-top: 4px; }
.spot-title p strong { color: var(--text); }
.spot-title .tags .tag { padding: 4px 10px; border-radius: 8px; }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 20px 0; }
.tile { display: flex; flex-direction: column; justify-content: space-between; gap: 8px; min-width: 0; padding: 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.tile .lbl { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 10px; font-family: var(--mono); font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--accent-strong); }
.tile .lbl svg { color: var(--text-2); }
.tile h4 { font-size: 15px; font-weight: 800; margin: 4px 0 2px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.tile p { font-size: 11px; line-height: 1.6; color: var(--text-2); }
.tile .foot { font-size: 10px; font-family: var(--mono); color: var(--accent-strong); opacity: .85; }
.tile.accent { background: var(--accent-tile); border-color: var(--accent-tile-line); }
.tile.accent h4 { color: var(--accent-3); }
.set-log { border-radius: 12px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--border); }
.set-log-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px; padding: 10px 16px;
  background: var(--card); border-bottom: 1px solid var(--border); font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--text);
}
.set-log-head .mono { font-size: 11px; font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--accent-strong); }
.set-log .table-wrap { margin: 0; }
table.sets-table { width: 100%; border-collapse: collapse; font-size: 12px; font-family: var(--mono); text-align: left; }
.sets-table th { padding: 10px 12px; font-size: 11px; font-weight: 600; color: var(--text-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.sets-table td { padding: 9px 12px; color: var(--text-2); border-bottom: 1px solid var(--divider); white-space: nowrap; }
.sets-table th:first-child, .sets-table td:first-child { padding-left: 16px; }
.sets-table th:last-child, .sets-table td:last-child { padding-right: 16px; text-align: right; }
.sets-table tr:last-child td { border-bottom: 0; }
.sets-table b { color: var(--text-strong); font-weight: 700; }
.sets-table tr.done { background: rgba(16, 185, 129, .05); }
.sets-table tr.done:hover { background: rgba(16, 185, 129, .1); }
.sets-table tr.done td:first-child { color: var(--text); font-weight: 700; }
.sets-table tr.next { background: rgba(16, 185, 129, .1); box-shadow: inset 2px 0 0 var(--accent-strong); }
.sets-table tr.next td:first-child { color: var(--accent-3); font-weight: 700; }
.sets-table tr.next td:first-child small { font-weight: 500; opacity: .8; }
.sets-table tr.pending td:first-child { color: var(--text); font-weight: 500; }
.set-cell { display: inline-flex; align-items: center; gap: 8px; }
.sdot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent-strong); flex: none; }
.cell-input {
  width: 72px; height: 26px; padding: 0 6px; border-radius: 6px; border: 1px solid rgba(16, 185, 129, .4); outline: none;
  background: var(--input); color: var(--text-strong); font: inherit; font-weight: 700; text-align: center;
}
.cell-input.reps { width: 58px; }
.cell-input:focus { border-color: var(--accent-strong); box-shadow: 0 0 0 2px rgba(16, 185, 129, .2); }
.done-chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 4px; font-size: 11px; color: var(--accent-strong); background: var(--accent-soft); border: 1px solid rgba(16, 185, 129, .2); }
.prev-inline { display: none; font-size: 10px; font-weight: 500; color: var(--text-3); margin-top: 2px; }
.spot-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 12px; }
.spot-foot .tip { display: flex; align-items: flex-start; gap: 8px; color: var(--text); min-width: 0; flex: 1 1 320px; }
.tip-ic { display: grid; place-items: center; padding: 4px; border-radius: 6px; background: rgba(16, 185, 129, .2); color: var(--accent-strong); flex: none; }
.spot-foot .links { display: flex; align-items: center; gap: 10px; }
.spot-foot .links .sep { color: var(--border-3); }
.spot-done { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.spot-done h3 { font-size: 24px; font-weight: 900; letter-spacing: -0.025em; }
.spot-done p { color: var(--text-2); font-size: 13px; }
.queue { display: flex; flex-direction: column; justify-content: space-between; }
.queue header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.queue header h2 { font-size: 14px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; }
.queue header .meta { font-size: 11px; font-family: var(--mono); color: var(--text-2); white-space: nowrap; }
div.q-item { cursor: default; }
div.q-item:hover { background: none; }
.q-list { display: flex; flex-direction: column; margin-top: 8px; }
.q-item {
  position: relative; display: flex; align-items: flex-start; gap: 12px; width: calc(100% + 16px); margin: 0 -8px; padding: 12px 8px;
  border-radius: 12px; border: 1px solid transparent; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.q-item + .q-item::before { content: ""; position: absolute; left: 8px; right: 8px; top: -1px; height: 1px; background: var(--divider); }
.q-item.on::before, .q-item.on + .q-item::before { display: none; }
.q-item:hover { background: var(--hover); }
.q-item.on { background: rgba(16, 185, 129, .05); border-color: rgba(16, 185, 129, .2); }
.q-num { width: 24px; height: 24px; margin-top: 1px; border-radius: 50%; display: grid; place-items: center; flex: none; font-size: 12px; font-weight: 700; background: var(--surface-3); color: var(--text); }
.q-item.on .q-num { background: var(--accent); color: var(--accent-ink); font-weight: 900; }
.q-item.done .q-num { background: var(--accent-soft); color: var(--accent-strong); }
.q-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.q-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.q-name { font-size: 12.5px; font-weight: 700; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-item.on .q-name { color: var(--text-strong); }
.q-tag { font-size: 10px; font-family: var(--mono); color: var(--text-3); white-space: nowrap; }
.q-item.on .q-tag, .q-item.done .q-tag { color: var(--accent-strong); font-weight: 700; }
.q-sub { font-size: 11px; color: var(--text-2); }
.q-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--border); }
.sec-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 12px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.sec-head h2 { font-size: 18px; font-weight: 700; }
.sec-head .sub { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.count-chip { padding: 1px 8px; border-radius: 4px; font-size: 12px; color: var(--text); background: var(--surface-3); border: 1px solid var(--border-2); white-space: nowrap; }
.meals-dash { padding: 24px; }
.meal-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.meal-tile { display: flex; flex-direction: column; justify-content: space-between; min-width: 0; padding: 16px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); transition: border-color .15s; }
.meal-tile:hover { border-color: var(--border-2); }
.meal-tile .top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; font-size: 12px; }
.meal-tile .when { font-size: 10px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--text); }
.meal-tile .kc { font-family: var(--mono); font-weight: 700; color: var(--accent-strong); white-space: nowrap; }
.meal-tile .mt-body { display: flex; gap: 12px; align-items: flex-start; }
.meal-tile h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; font-size: 14px; font-weight: 700; }
.meal-tile p { font-size: 12px; color: var(--text-2); }
.meal-tile .thumb-sm { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; flex: none; border: 1px solid var(--border); }
.meal-tile .mac { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 11px; font-family: var(--mono); font-weight: 700; }
.plan-cta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; }
.plan-cta h3 { font-size: 20px; font-weight: 900; }
.plan-cta p { color: var(--text-2); font-size: 13px; margin-top: 4px; max-width: 640px; }

/* ---------- meals ---------- */
.meals-layout { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 20px; align-items: start; }
.dropzone {
  border: 2px dashed var(--border-2); border-radius: 14px; padding: 26px 16px; text-align: center; cursor: pointer; background: var(--surface-2);
  display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--text-2); transition: border-color .15s, background .15s, box-shadow .3s;
}
.dropzone strong { color: var(--text-strong); }
.dropzone svg { color: var(--accent-strong); }
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dropzone:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px rgba(16, 185, 129, .2); }
.dropzone.attn { border-color: var(--accent); box-shadow: 0 0 0 6px rgba(16, 185, 129, .18); }
.preview { position: relative; border-radius: 14px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--border); }
.preview img { display: block; width: 100%; max-height: 340px; object-fit: contain; }
.item-name { font-weight: 700; color: var(--text-strong); }
.match-btn {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px; text-align: left; width: 100%; color: var(--text);
  padding: 6px 8px; border-radius: 8px; border: 1px solid var(--border-2); background: var(--surface-2); cursor: pointer; font-size: 13px;
}
.match-btn:hover { border-color: var(--accent); }
.match-btn.missing { border-color: var(--warn); background: var(--warn-soft); }
.match-btn .src { font-size: 11px; color: var(--text-3); }
.conf { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.compare { display: grid; grid-template-columns: auto repeat(4, minmax(0, 1fr)); gap: 6px 12px; font-size: 13.5px; align-items: center; }
.compare .h { font-size: 11px; font-weight: 600; font-family: var(--mono); color: var(--text-2); text-transform: uppercase; letter-spacing: .02em; text-align: right; }
.compare .l { font-weight: 600; color: var(--text-2); }
.compare .c { text-align: right; font-family: var(--mono); }
.compare .c.strong { font-weight: 700; color: var(--text-strong); }
.meal-card { display: grid; grid-template-columns: 64px 1fr auto; gap: 12px; align-items: start; padding: 12px 0; border-bottom: 1px solid var(--divider); }
.meal-card:last-child { border-bottom: 0; }
.meal-card strong { color: var(--text-strong); }
.thumb { width: 64px; height: 64px; border-radius: 12px; object-fit: cover; background: var(--surface-3); display: grid; place-items: center; color: var(--text-2); }
.meal-items { font-size: 13px; color: var(--text-2); margin-top: 4px; }
.macro-inline { display: flex; gap: 10px; font-size: 12px; font-family: var(--mono); color: var(--text-2); flex-wrap: wrap; }
.macro-inline b { font-weight: 700; }
.food-result { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 10px; border-radius: 10px; cursor: pointer; border: 1px solid transparent; }
.food-result:hover { background: var(--hover); border-color: var(--border); }

/* ---------- plan ---------- */
.week-strip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; }
.day-tile {
  border-radius: 12px; padding: 12px; border: 1px solid var(--border); background: var(--card); cursor: pointer; color: var(--text);
  display: flex; flex-direction: column; gap: 6px; min-height: 118px; text-align: left; box-shadow: var(--shadow);
}
.day-tile:hover { border-color: var(--border-3); }
.day-tile.today { outline: 2px solid var(--accent); outline-offset: 1px; }
.day-tile .wd { font-size: 11px; font-weight: 700; font-family: var(--mono); color: var(--text-2); text-transform: uppercase; letter-spacing: .05em; }
.day-tile .t { font-size: 13px; font-weight: 700; line-height: 1.25; color: var(--text-strong); }
.day-tile .d { font-size: 11.5px; color: var(--text-3); margin-top: auto; }
.day-tile.gym { border-top: 3px solid var(--gym); }
.day-tile.home { border-top: 3px solid var(--home); }
.day-tile.rest { border-top: 3px solid var(--rest); background: var(--surface-2); box-shadow: none; }
.day-card > header { flex-wrap: wrap; }
.day-card > header h2 { text-transform: none; letter-spacing: -0.015em; font-size: 16px; font-weight: 800; color: var(--text-strong); }
.day-num { font-size: 11px; font-weight: 700; font-family: var(--mono); color: var(--text-2); text-transform: uppercase; letter-spacing: .05em; }
.muscles { font-size: 12.5px; color: var(--text-2); }
.ex-cards { display: none; }
.tips { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; color: var(--text-2); }

/* ---------- workout ---------- */
.ex-log { border: 1px solid var(--border); border-radius: 14px; padding: 14px; background: var(--surface-2); }
.ex-log + .ex-log { margin-top: 12px; }
.ex-log strong { color: var(--text-strong); }
.ex-log.done { border-color: rgba(16, 185, 129, .45); background: rgba(16, 185, 129, .05); }
.sets { display: grid; grid-template-columns: 34px minmax(80px, 150px) minmax(70px, 130px) 44px; gap: 8px; align-items: center; margin-top: 10px; }
.sets .h { font-size: 11px; font-weight: 600; font-family: var(--mono); color: var(--text-2); text-transform: uppercase; }
.set-n { width: 28px; height: 28px; border-radius: 8px; background: var(--surface-3); display: grid; place-items: center; font-size: 12.5px; font-weight: 700; font-family: var(--mono); color: var(--text); }
.check {
  width: 40px; height: 36px; border-radius: 10px; border: 1.5px solid var(--border-2); background: var(--input);
  display: grid; place-items: center; cursor: pointer; color: transparent;
}
.check:hover { border-color: var(--accent); }
.check.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.hint-box { font-size: 13px; padding: 8px 10px; border-radius: 10px; background: var(--accent-soft); border: 1px solid rgba(16, 185, 129, .18); color: var(--text); margin-top: 10px; display: flex; gap: 8px; }
.hint-box svg { color: var(--accent-strong); flex: none; margin-top: 2px; }
.rest-timer {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 40; display: flex; align-items: center; gap: 14px;
  padding: 10px 12px 10px 18px; border-radius: 999px; background: #0f172a; color: #f1f5f9; border: 1px solid rgba(16, 185, 129, .4);
  box-shadow: 0 20px 40px -12px rgba(0, 0, 0, .6), 0 0 0 4px rgba(16, 185, 129, .1);
}
.rest-timer svg { color: #34d399; }
.rest-timer .t { font-size: 22px; font-weight: 800; font-family: var(--mono); font-variant-numeric: tabular-nums; min-width: 64px; color: #6ee7b7; }
.rest-timer .btn { background: transparent; color: #f1f5f9; border-color: rgba(255, 255, 255, .22); box-shadow: none; }
.rest-timer .btn:hover { background: rgba(255, 255, 255, .08); }

/* ---------- chat ---------- */
.chat { display: flex; flex-direction: column; height: calc(100vh - 190px); min-height: 420px; }
.chat .log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding: 4px 4px 16px; }
.msg { max-width: min(720px, 88%); padding: 11px 15px; border-radius: 16px; font-size: 14px; line-height: 1.6; }
.msg.user { align-self: flex-end; background: var(--accent-grad); color: var(--accent-ink); font-weight: 500; border-bottom-right-radius: 6px; white-space: pre-wrap; }
.msg.assistant { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--border); border-bottom-left-radius: 6px; color: var(--text); }
.msg.assistant p + p, .msg.assistant p + ul, .msg.assistant ul + p { margin-top: 8px; }
.msg.assistant ul, .msg.assistant ol { margin: 6px 0 0; padding-left: 20px; }
.msg.assistant strong { color: var(--text-strong); }
.msg .meta { font-size: 11px; font-family: var(--mono); color: var(--text-3); margin-top: 6px; }
.composer { display: flex; gap: 10px; align-items: flex-end; padding-top: 12px; border-top: 1px solid var(--border); }
.composer textarea { min-height: 46px; max-height: 160px; }
.typing::after { content: "▍"; animation: pulse 1s infinite; }

/* ---------- settings / gpu ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs button { border: 0; background: none; padding: 10px 14px; font-weight: 700; font-size: 13.5px; color: var(--text-2); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button:hover { color: var(--text); }
.tabs button.on { color: var(--accent-strong); border-bottom-color: var(--accent-strong); }
.vram-bar { display: flex; height: 22px; border-radius: 8px; overflow: hidden; background: var(--surface-3); }
.vram-bar > i { display: block; height: 100%; }
.vram-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--text-2); margin-top: 8px; }
.model-row { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--divider); }
.model-row > div:first-child { flex: 1 1 200px; min-width: 0; }
.model-row code { white-space: nowrap; }
.model-row:last-child { border-bottom: 0; }
.formula { font-family: var(--mono); font-size: 12px; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; overflow-x: auto; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
details > summary { color: var(--text-2); }

/* ---------- auth ---------- */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: min(440px, 100%); padding: 28px; box-shadow: var(--shadow-lg); }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 44px; }
.pw-toggle { position: absolute; right: 5px; top: 5px; }
.version { font-size: 11px; color: var(--text-3); padding: 2px 8px 0; font-family: var(--mono); }

/* ---------- onboarding (focused setup step, no app navigation) ---------- */
.setup-page { min-height: 100vh; display: flex; flex-direction: column; }
.setup-head {
  display: flex; align-items: center; gap: 12px; padding: 12px 20px; position: sticky; top: 0; z-index: 10;
  background: var(--header); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}
.setup-actions {
  display: flex; align-items: center; gap: 14px; position: sticky; bottom: 0; z-index: 10; margin-top: auto;
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
  background: var(--header); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-top: 1px solid var(--border);
}
.onboard { max-width: 860px; width: 100%; margin: 0 auto; padding: 28px 20px 32px; }
.onboard .hero { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }

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

/* ---------- responsive ---------- */
@media (max-width: 1360px) {
  .app { grid-template-columns: 256px minmax(0, 1fr); }
}
@media (max-width: 1180px) {
  .dash-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-row > .weight-card { grid-column: 1 / -1; }
  .train-grid { grid-template-columns: 1fr; }
  .meal-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.split { grid-template-columns: 1fr; }
  .meals-layout { grid-template-columns: 1fr; }
  .week-strip { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .topbar { padding: 14px 24px; }
  .view { padding: 24px; }
}
@media (max-width: 860px) {
  body { font-size: 15px; }
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .mobile-bar {
    display: flex; align-items: center; gap: 8px; padding: 10px 12px 10px 16px; position: sticky; top: 0; z-index: 20;
    background: var(--header); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--border);
  }
  .mobile-bar .brand { padding: 0; flex: 1; gap: 10px; }
  .mobile-bar .brand-mark { width: 34px; height: 34px; border-radius: 10px; }
  .mobile-bar .brand-sub { display: none; }
  .mobile-bar .brand-name { font-size: 17px; }
  .topbar { position: static; flex-wrap: wrap; min-height: 0; padding: 16px 16px 4px; background: none; border: 0; backdrop-filter: none; -webkit-backdrop-filter: none; }
  .topbar h1 { font-size: 22px; }
  .head-actions { width: 100%; justify-content: flex-start; }
  .date-badge { display: none; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1 1 auto; }
  .view { padding: 12px 16px 100px; }
  .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .dash { gap: 20px; }
  .dash-row { grid-template-columns: 1fr; gap: 16px; }
  .train-grid { gap: 16px; }
  .spot, .meals-dash { padding: 18px; }
  .spot-title h3 { font-size: 21px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 16px 0; }
  .meal-grid { grid-template-columns: 1fr; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--header); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; font-weight: 600; color: var(--text-3); text-decoration: none; padding: 4px 0; border-radius: 10px; }
  .tabbar a.active { color: var(--accent-strong); }
  .week-strip { grid-template-columns: repeat(7, 132px); overflow-x: auto; padding-bottom: 6px; }
  .day-card .table-wrap { display: none; }
  .ex-cards { display: flex; flex-direction: column; gap: 10px; }
  .ex-card { border: 1px solid var(--border); border-radius: 12px; padding: 12px; background: var(--surface-2); }
  .chat { height: calc(100vh - 250px); }
  .toasts { left: 16px; right: 16px; bottom: 84px; }
  .toast { max-width: none; }
  .rest-timer { bottom: 84px; }
  .ring-wrap { flex-direction: column; align-items: stretch; }
  .ring-wrap .ring-label { align-self: center; }
}
@media (max-width: 560px) {
  .sets-table .col-prev { display: none; }
  .prev-inline { display: block; }
  .sets-table th, .sets-table td { padding: 8px 6px; }
  .sets-table th:first-child, .sets-table td:first-child { padding-left: 10px; }
  .sets-table th:last-child, .sets-table td:last-child { padding-right: 10px; }
  .sets-table tr.next td:first-child small { display: none; }
  .cell-input { width: 62px; }
  .cell-input.reps { width: 46px; }
  .set-log-head { padding: 10px 12px; }
}
@media (max-width: 420px) {
  .kcal-ring { width: 160px; height: 160px; }
  .kcal-inner .v { font-size: 27px; }
  .spot-top .tags { display: none; }
}
