/* Weight Tracker — styles. Tokens on :root, themes swap only accent tokens,
   light/dark swaps surfaces. No framework, no build step. */

@font-face {
  font-family: "InterVar";
  src: url("fonts/inter-variable.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --font: "InterVar", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* surfaces (light) */
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --surface-3: #eef0f3;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --text: #101828;
  --text-2: #475467;
  --text-3: #667085;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .05);
  --shadow-lg: 0 20px 48px rgba(16, 24, 40, .18);

  /* status — reserved, always paired with icon/sign + label */
  --good: #12a150;
  --good-soft: #e7f6ee;
  --warn: #c98500;
  --warn-soft: #fdf4e1;
  --bad: #d92d20;
  --bad-soft: #fdecea;

  /* chart */
  --grid: #eceef2;
  --axis: #98a2b3;
  --goal-line: #667085;

  /* categorical series (validated palette, light) */
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300;

  /* default accent = green */
  --accent: #16a34a;
  --accent-strong: #15803d;
  --accent-2: #0d9488;
  --on-accent: #ffffff;

  --accent-soft: color-mix(in srgb, var(--accent) 12%, var(--surface));
  --accent-softer: color-mix(in srgb, var(--accent) 6%, var(--surface));

  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 8px;
  --nav-w: 248px;

  color-scheme: light;
}

/* ---------- themes ---------- */
[data-theme="green"]  { --accent: #16a34a; --accent-strong: #15803d; --accent-2: #0d9488; }
[data-theme="blue"]   { --accent: #2563eb; --accent-strong: #1d4ed8; --accent-2: #0891b2; }
[data-theme="red"]    { --accent: #dc2626; --accent-strong: #b91c1c; --accent-2: #e11d48; }
[data-theme="purple"] { --accent: #7c3aed; --accent-strong: #6d28d9; --accent-2: #c026d3; }
[data-theme="orange"] { --accent: #ea580c; --accent-strong: #c2410c; --accent-2: #d97706; }
[data-theme="teal"]   { --accent: #0d9488; --accent-strong: #0f766e; --accent-2: #0284c7; }
[data-theme="pink"]   { --accent: #db2777; --accent-strong: #be185d; --accent-2: #9333ea; }
[data-theme="slate"]  { --accent: #475569; --accent-strong: #334155; --accent-2: #0f172a; }

/* ---------- dark mode: explicit, or system when mode=system ---------- */
:root[data-mode="dark"] {
  color-scheme: dark;
  --bg: #0b0d12;
  --surface: #151821;
  --surface-2: #1b1f2a;
  --surface-3: #232836;
  --border: #262b38;
  --border-strong: #343a4a;
  --text: #f2f4f7;
  --text-2: #c0c6d2;
  --text-3: #8b93a5;
  --shadow-sm: none;
  --shadow: 0 1px 2px rgba(0,0,0,.4);
  --shadow-lg: 0 20px 48px rgba(0,0,0,.6);
  --good: #32c574; --good-soft: #12291d;
  --warn: #e0a42a; --warn-soft: #2b2310;
  --bad: #f2675b; --bad-soft: #301615;
  --grid: #222734;
  --axis: #6b7385;
  --goal-line: #9aa3b5;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #2f9e2f;
}
@media (prefers-color-scheme: dark) {
  :root[data-mode="system"] {
    color-scheme: dark;
    --bg: #0b0d12;
    --surface: #151821;
    --surface-2: #1b1f2a;
    --surface-3: #232836;
    --border: #262b38;
    --border-strong: #343a4a;
    --text: #f2f4f7;
    --text-2: #c0c6d2;
    --text-3: #8b93a5;
    --shadow-sm: none;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
    --shadow-lg: 0 20px 48px rgba(0,0,0,.6);
    --good: #32c574; --good-soft: #12291d;
    --warn: #e0a42a; --warn-soft: #2b2310;
    --bad: #f2675b; --bad-soft: #301615;
    --grid: #222734;
    --axis: #6b7385;
    --goal-line: #9aa3b5;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #2f9e2f;
  }
}
/* lighter accents read better on dark surfaces */
:root[data-mode="dark"][data-theme="green"]  { --accent: #22c55e; }
:root[data-mode="dark"][data-theme="blue"]   { --accent: #3b82f6; }
:root[data-mode="dark"][data-theme="red"]    { --accent: #ef4444; }
:root[data-mode="dark"][data-theme="purple"] { --accent: #8b5cf6; }
:root[data-mode="dark"][data-theme="orange"] { --accent: #f97316; }
:root[data-mode="dark"][data-theme="teal"]   { --accent: #14b8a6; }
:root[data-mode="dark"][data-theme="pink"]   { --accent: #ec4899; }
:root[data-mode="dark"][data-theme="slate"]  { --accent: #94a3b8; --on-accent: #0b0d12; }
@media (prefers-color-scheme: dark) {
  :root[data-mode="system"][data-theme="green"]  { --accent: #22c55e; }
  :root[data-mode="system"][data-theme="blue"]   { --accent: #3b82f6; }
  :root[data-mode="system"][data-theme="red"]    { --accent: #ef4444; }
  :root[data-mode="system"][data-theme="purple"] { --accent: #8b5cf6; }
  :root[data-mode="system"][data-theme="orange"] { --accent: #f97316; }
  :root[data-mode="system"][data-theme="teal"]   { --accent: #14b8a6; }
  :root[data-mode="system"][data-theme="pink"]   { --accent: #ec4899; }
  :root[data-mode="system"][data-theme="slate"]  { --accent: #94a3b8; --on-accent: #0b0d12; }
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 0; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }
.small { font-size: 13px; }
.hidden { display: none !important; }
[hidden] { display: none !important; }
svg.i { width: 20px; height: 20px; flex: none; }

/* ---------- app shell ---------- */
.app { display: flex; min-height: 100vh; min-height: 100dvh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--nav-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 20px 14px;
  padding-top: calc(20px + env(safe-area-inset-top, 0px));
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--on-accent);
}
.brand-mark svg { width: 20px; height: 20px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  text-decoration: none; color: var(--text-2); font-weight: 550; font-size: 14.5px;
  transition: background .15s, color .15s;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent-strong); }
:root[data-mode="dark"] .nav a.active { color: var(--accent); }
@media (prefers-color-scheme: dark) { :root[data-mode="system"] .nav a.active { color: var(--accent); } }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: var(--radius-sm); background: var(--surface-2); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 700; font-size: 14px;
  background: var(--accent-soft); color: var(--accent);
}
.user-chip .who { min-width: 0; }
.user-chip .who b { display: block; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .who span { font-size: 12px; color: var(--text-3); }

.main { flex: 1; margin-left: var(--nav-w); min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: 16px 32px;
  padding-top: calc(16px + env(safe-area-inset-top, 0px));
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
}
.topbar .title { flex: 1; min-width: 0; }
.topbar .title p { color: var(--text-3); font-size: 13.5px; }
.topbar .mobile-brand { display: none; }
.content { padding: 8px 32px 48px; max-width: 1200px; }

.bottom-nav { display: none; }

@media (max-width: 900px) {
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .topbar { padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top, 0px)); }
  .topbar .title h1 { font-size: 21px; }
  .topbar .title p { display: none; }
  .topbar .mobile-brand { display: grid; }
  .content { padding: 4px 16px calc(96px + env(safe-area-inset-bottom, 0px)); }
  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--border);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
  }
  .bottom-nav a {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 6px 0; border-radius: 10px;
    font-size: 11px; font-weight: 600; color: var(--text-3); text-decoration: none;
  }
  .bottom-nav a svg { width: 22px; height: 22px; }
  .bottom-nav a.active { color: var(--accent); }
}

/* ---------- buttons & form controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s, box-shadow .15s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); box-shadow: 0 1px 2px rgba(16,24,40,.1), 0 4px 12px color-mix(in srgb, var(--accent) 30%, transparent); }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--border)); }
.btn-danger:hover { background: var(--bad-soft); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-icon { width: 36px; height: 36px; padding: 0; }
.btn-block { width: 100%; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.hint { font-size: 12.5px; color: var(--text-3); }
.input, select.input, textarea.input {
  width: 100%; height: 42px; padding: 0 12px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; min-height: 72px; padding: 10px 12px; resize: vertical; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
.input-group { display: flex; align-items: stretch; }
.input-group .input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .suffix {
  display: grid; place-items: center; padding: 0 12px; min-width: 44px;
  border: 1px solid var(--border-strong); border-left: 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--surface-2); color: var(--text-3); font-size: 13.5px; font-weight: 600;
}
.weight-input { display: flex; gap: 8px; }
.weight-input .input-group { flex: 1; }
.big-input .input { height: 54px; font-size: 22px; font-weight: 650; }
.big-input .suffix { font-size: 15px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 6px; }
.form-error { color: var(--bad); font-size: 13.5px; min-height: 0; }
.form-error:empty { display: none; }

.seg {
  display: inline-flex; padding: 3px; gap: 2px; border-radius: 11px;
  background: var(--surface-3); flex-wrap: wrap;
}
.seg button {
  border: 0; background: transparent; padding: 6px 12px; border-radius: 8px;
  font-size: 13px; font-weight: 600; color: var(--text-2); cursor: pointer;
}
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border); }

.switch { position: relative; display: inline-block; width: 44px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--border-strong); transition: background .2s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 25%, transparent); }

/* ---------- cards & layout ---------- */
.grid { display: grid; gap: 16px; }
.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)); }
.span-2 { grid-column: span 2; }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) { .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); } .span-2 { grid-column: auto; } }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.section { margin-top: 24px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; min-width: 0;
}
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head p { color: var(--text-3); font-size: 13px; margin-top: 2px; }
.card.flush { padding: 0; overflow: hidden; }

/* hero */
.hero {
  position: relative; overflow: hidden;
  border-radius: calc(var(--radius) + 4px);
  padding: 24px;
  color: #fff;
  background:
    radial-gradient(120% 140% at 100% 0%, color-mix(in srgb, var(--accent-2) 85%, transparent) 0%, transparent 55%),
    linear-gradient(135deg, var(--accent-strong), var(--accent));
  box-shadow: 0 10px 30px color-mix(in srgb, var(--accent) 30%, transparent);
  display: grid; grid-template-columns: 1fr auto; gap: 20px; align-items: center;
}
:root[data-theme="slate"] .hero { color: #fff; }
.hero::after {
  content: ""; position: absolute; right: -60px; bottom: -80px; width: 260px; height: 260px; border-radius: 50%;
  background: rgba(255,255,255,.08); pointer-events: none;
}
.hero .eyebrow { font-size: 13px; font-weight: 600; opacity: .85; text-transform: uppercase; letter-spacing: .06em; }
.hero .current { font-size: 46px; font-weight: 750; letter-spacing: -0.03em; line-height: 1.1; margin: 6px 0 4px; }
.hero .current small { font-size: 20px; font-weight: 600; opacity: .85; margin-left: 4px; letter-spacing: 0; }
.hero .sub { opacity: .92; font-size: 14px; }
.hero-stats { display: flex; gap: 22px; margin-top: 16px; flex-wrap: wrap; }
.hero-stats div span { display: block; font-size: 12px; opacity: .8; font-weight: 500; }
.hero-stats div b { font-size: 17px; font-weight: 700; }
.hero .pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: rgba(255,255,255,.18); font-size: 12.5px; font-weight: 600; }
.ring { position: relative; width: 132px; height: 132px; z-index: 1; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .ring-label { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; line-height: 1.15; }
.ring .ring-label b { font-size: 26px; font-weight: 750; display: block; }
.ring .ring-label span { font-size: 11.5px; opacity: .85; }
@media (max-width: 600px) {
  .hero { grid-template-columns: 1fr; padding: 20px; }
  .hero .current { font-size: 38px; }
  .ring { position: absolute; right: 16px; top: 16px; width: 92px; height: 92px; }
  .ring .ring-label b { font-size: 19px; }
  .ring .ring-label span { font-size: 10px; }
}

/* stat tiles */
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat .k { font-size: 12.5px; font-weight: 600; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.stat .k svg { width: 15px; height: 15px; }
.stat .v { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 14px; font-weight: 600; color: var(--text-3); margin-left: 3px; letter-spacing: 0; }
.stat .d { font-size: 12.5px; color: var(--text-3); }

.delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; font-variant-numeric: tabular-nums; }
.delta svg { width: 14px; height: 14px; }
.delta.good { color: var(--good); }
.delta.bad { color: var(--bad); }
.delta.flat { color: var(--text-3); }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.badge svg { width: 13px; height: 13px; }
.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.accent { background: var(--accent-soft); color: var(--accent); }

.progress { height: 10px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress > div { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .6s cubic-bezier(.2,.8,.2,1); }
.progress.thin { height: 6px; }
.progress.over > div { background: var(--bad); }

/* insights */
.insights { display: flex; flex-direction: column; gap: 10px; }
.insight { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border-radius: var(--radius-sm); background: var(--surface-2); }
.insight .ic { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; flex: none; background: var(--accent-soft); color: var(--accent); }
.insight .ic svg { width: 17px; height: 17px; }
.insight.good .ic { background: var(--good-soft); color: var(--good); }
.insight.warn .ic { background: var(--warn-soft); color: var(--warn); }
.insight b { font-weight: 600; }
.insight p { font-size: 13.5px; color: var(--text-2); }

/* achievements */
.achievements { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.ach { text-align: center; padding: 14px 8px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.ach .medal { width: 42px; height: 42px; border-radius: 50%; margin: 0 auto 8px; display: grid; place-items: center; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }
.ach .medal svg { width: 20px; height: 20px; }
.ach b { display: block; font-size: 12.5px; font-weight: 650; line-height: 1.3; }
.ach span { font-size: 11px; color: var(--text-3); }
.ach.locked { opacity: .55; }
.ach.locked .medal { background: var(--surface-3); color: var(--text-3); }

/* lists / tables */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 14px; padding: 12px 20px; border-top: 1px solid var(--border); }
.list-item:first-child { border-top: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .primary { font-weight: 600; }
.list-item .secondary { font-size: 13px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .actions { display: flex; gap: 2px; opacity: .8; }
.list-item:hover .actions { opacity: 1; }
.list-group-title { padding: 10px 20px; font-size: 12px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; background: var(--surface-2); border-top: 1px solid var(--border); }
.list-group-title:first-child { border-top: 0; }
.date-chip { width: 46px; text-align: center; flex: none; line-height: 1.1; }
.date-chip b { display: block; font-size: 18px; font-weight: 700; }
.date-chip span { font-size: 11px; font-weight: 600; color: var(--text-3); text-transform: uppercase; }
.weight-cell { text-align: right; min-width: 92px; }
.weight-cell b { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); font-weight: 650; padding: 10px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 11px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table .r { text-align: right; }

.empty { text-align: center; padding: 40px 20px; color: var(--text-3); }
.empty .em-ic { width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 14px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.empty .em-ic svg { width: 26px; height: 26px; }
.empty h3 { color: var(--text); margin-bottom: 4px; }

/* charts */
.chart-box { position: relative; height: 320px; }
.chart-box.sm { height: 220px; }
.chart-box.xs { height: 160px; }
@media (max-width: 600px) { .chart-box { height: 260px; } .chart-box.sm { height: 200px; } }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; background: currentColor; }
.legend i.dot { width: 8px; height: 8px; border-radius: 50%; }
.legend i.dash { background: repeating-linear-gradient(90deg, currentColor 0 4px, transparent 4px 7px); }

/* theme picker */
.themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.theme-opt {
  border: 2px solid var(--border); border-radius: 12px; padding: 10px; cursor: pointer; background: var(--surface);
  display: flex; flex-direction: column; gap: 8px; align-items: flex-start; font-size: 13px; font-weight: 600;
  transition: border-color .15s, transform .1s;
}
.theme-opt:hover { transform: translateY(-1px); }
.theme-opt .sw { width: 100%; height: 34px; border-radius: 8px; }
.theme-opt.on { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }

/* settings rows */
.setting { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-top: 1px solid var(--border); flex-wrap: wrap; }
.setting:first-of-type { border-top: 0; padding-top: 0; }
.setting .txt { flex: 1; min-width: 200px; }
.setting .txt b { display: block; font-weight: 600; font-size: 14.5px; }
.setting .txt span { font-size: 13px; color: var(--text-3); }

/* food */
.day-nav { display: flex; align-items: center; gap: 8px; }
.day-nav .day-label { min-width: 150px; text-align: center; font-weight: 650; }
.meal { border-top: 1px solid var(--border); }
.meal:first-child { border-top: 0; }
.meal-head { display: flex; align-items: center; gap: 10px; padding: 14px 20px; }
.meal-head h3 { flex: 1; }
.meal-head .kcal { font-weight: 650; color: var(--text-2); font-variant-numeric: tabular-nums; }
.food-item { display: flex; align-items: center; gap: 12px; padding: 9px 20px 9px 32px; }
.food-item .grow { flex: 1; min-width: 0; }
.food-item .nm { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.food-item .mac { font-size: 12px; color: var(--text-3); }
.food-item .kc { font-weight: 650; font-variant-numeric: tabular-nums; }
.macros { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.macro .row { justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.recent-list { display: flex; flex-wrap: wrap; gap: 6px; max-height: 140px; overflow-y: auto; }
.chip { border: 1px solid var(--border-strong); background: var(--surface-2); border-radius: 999px; padding: 5px 11px; font-size: 13px; cursor: pointer; }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.calorie-ring { position: relative; width: 150px; height: 150px; margin: 0 auto; }
.calorie-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.calorie-ring .lbl { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; line-height: 1.15; }
.calorie-ring .lbl b { font-size: 28px; font-weight: 750; display: block; font-variant-numeric: tabular-nums; }
.calorie-ring .lbl span { font-size: 12px; color: var(--text-3); }

/* modal */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(10, 13, 20, .5);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 16px;
  animation: fade .15s ease-out;
}
.modal {
  width: 100%; max-width: 480px; max-height: calc(100dvh - 32px); overflow-y: auto;
  background: var(--surface); border-radius: 20px; box-shadow: var(--shadow-lg); border: 1px solid var(--border);
  padding: 24px;
  animation: pop .18s cubic-bezier(.2,.8,.2,1);
}
.modal.wide { max-width: 640px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.modal-head h2 { font-size: 19px; }
@media (max-width: 600px) {
  .modal-backdrop { place-items: end center; padding: 0; }
  .modal { max-width: none; border-radius: 22px 22px 0 0; padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px)); max-height: 92dvh; animation: slideup .22s cubic-bezier(.2,.8,.2,1); }
}
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.97) translateY(6px); } }
@keyframes slideup { from { transform: translateY(40px); opacity: .4; } }

/* toast */
.toasts { position: fixed; z-index: 200; left: 50%; transform: translateX(-50%); bottom: calc(24px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
@media (max-width: 900px) { .toasts { bottom: calc(86px + env(safe-area-inset-bottom, 0px)); } }
.toast { background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 550; box-shadow: var(--shadow-lg); animation: pop .2s; pointer-events: auto; max-width: 90vw; }
.toast.error { background: var(--bad); color: #fff; }

/* fab */
.fab {
  display: none; position: fixed; right: 18px; bottom: calc(84px + env(safe-area-inset-bottom, 0px)); z-index: 25;
  width: 56px; height: 56px; border-radius: 18px; border: 0; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--on-accent);
  box-shadow: 0 8px 24px color-mix(in srgb, var(--accent) 45%, transparent);
}
.fab svg { width: 26px; height: 26px; }
@media (max-width: 900px) { .fab { display: grid; place-items: center; } .topbar .log-btn { display: none; } }

/* auth */
.auth-shell { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-art {
  position: relative; overflow: hidden; color: #fff; padding: 48px;
  display: flex; flex-direction: column; justify-content: space-between;
  background:
    radial-gradient(90% 90% at 100% 0%, color-mix(in srgb, var(--accent-2) 90%, transparent), transparent 60%),
    linear-gradient(150deg, var(--accent-strong), var(--accent));
}
.auth-art h2 { font-size: 38px; font-weight: 750; letter-spacing: -0.03em; line-height: 1.12; max-width: 460px; }
.auth-art p { opacity: .9; margin-top: 12px; max-width: 420px; font-size: 16px; }
.auth-art svg.art { position: absolute; right: -40px; bottom: 40px; width: 82%; max-width: 560px; opacity: .95; }
.auth-feats { display: flex; gap: 10px; flex-wrap: wrap; position: relative; z-index: 1; }
.auth-feats span { background: rgba(255,255,255,.16); border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600; }
.auth-panel { display: grid; place-items: center; padding: 32px 20px; background: var(--surface); }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h1 { margin: 22px 0 6px; }
.auth-card .sub { color: var(--text-3); margin-bottom: 24px; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; }
.auth-card .seg { width: 100%; margin-bottom: 4px; }
.auth-card .seg button { flex: 1; padding: 8px; }
@media (max-width: 860px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-art { padding: 28px 20px 24px; padding-top: calc(28px + env(safe-area-inset-top, 0px)); min-height: 220px; }
  .auth-art h2 { font-size: 26px; }
  .auth-art p { font-size: 14px; }
  .auth-art svg.art { display: none; }
  .auth-panel { place-items: start center; }
}

.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 8px; }
@keyframes shimmer { to { background-position: -200% 0; } }

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

/* ---------- v2: privacy, more, habits, photos, sharing, scanner ---------- */
.privacy-btn { width: 40px; height: 40px; border-radius: 12px; }
.privacy-btn.on { background: var(--accent-soft); color: var(--accent); }
.hero .pill svg { width: 13px; height: 13px; }
a.list-item { text-decoration: none; color: inherit; }
.more-link .avatar svg { width: 18px; height: 18px; }
.list-item > svg.i { color: var(--text-3); }

.glasses { display: flex; flex-wrap: wrap; gap: 6px; }
.glass { width: 34px; height: 40px; border-radius: 6px 6px 10px 10px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-3); transition: background .2s, color .2s; }
.glass svg { width: 18px; height: 18px; }
.glass.full { background: color-mix(in srgb, var(--s1) 18%, var(--surface)); color: var(--s1); }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
@media (max-width: 600px) { .photo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } }
.photo { position: relative; margin: 0; border-radius: 14px; overflow: hidden; background: var(--surface-2); border: 2px solid transparent; cursor: pointer; aspect-ratio: 3 / 4; box-shadow: var(--shadow); }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo figcaption { position: absolute; left: 0; right: 0; bottom: 0; padding: 22px 10px 8px; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.65)); font-size: 12.5px; line-height: 1.3; }
.photo figcaption b { display: block; font-size: 13.5px; }
.photo figcaption span { opacity: .85; text-transform: capitalize; }
.photo .pick { position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; border-radius: 50%; border: 2px solid #fff; background: rgba(0,0,0,.25); color: transparent; display: grid; place-items: center; cursor: pointer; padding: 0; }
.photo .pick svg { width: 16px; height: 16px; }
.photo.picked { border-color: var(--accent); }
.photo.picked .pick { background: var(--accent); color: #fff; border-color: var(--accent); }
.dropzone { display: block; border: 2px dashed var(--border-strong); border-radius: 14px; padding: 24px; text-align: center; cursor: pointer; background: var(--surface-2); }
.dropzone:hover { border-color: var(--accent); }
#pu-prev { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--text-2); }
#pu-prev > svg { width: 30px; height: 30px; color: var(--accent); }
.cmp-side { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cmp-side figure { margin: 0; }
.cmp-side img { width: 100%; border-radius: 12px; display: block; aspect-ratio: 3 / 4; object-fit: cover; background: var(--surface-2); }
.cmp-side figcaption { font-size: 13px; color: var(--text-2); text-align: center; margin-top: 6px; font-weight: 600; }
.cmp-slider { position: relative; border-radius: 12px; overflow: hidden; touch-action: none; user-select: none; cursor: ew-resize; background: var(--surface-2); }
.cmp-slider > img { width: 100%; display: block; max-height: 65dvh; object-fit: cover; }
.cmp-top { position: absolute; inset: 0 auto 0 0; overflow: hidden; border-right: 2px solid #fff; }
.cmp-top img { height: 100%; object-fit: cover; display: block; max-width: none; }
.cmp-handle { position: absolute; top: 50%; width: 34px; height: 34px; margin: -17px 0 0 -17px; border-radius: 50%; background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.3); pointer-events: none; }
.cmp-tag { position: absolute; top: 10px; padding: 3px 9px; border-radius: 999px; background: rgba(0,0,0,.5); color: #fff; font-size: 12px; font-weight: 600; }
.cmp-tag.l { left: 10px; } .cmp-tag.r { right: 10px; }

.share-card h3 { font-size: 16px; }
.copy-btn svg { width: 16px; height: 16px; }

.scanner { position: relative; border-radius: 14px; overflow: hidden; background: #000; aspect-ratio: 4 / 3; }
.scanner video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-frame { position: absolute; left: 12%; right: 12%; top: 30%; bottom: 30%; border: 3px solid rgba(255,255,255,.9); border-radius: 12px; box-shadow: 0 0 0 999px rgba(0,0,0,.35); }
.scan-frame::after { content: ""; position: absolute; left: 6%; right: 6%; top: 50%; height: 2px; background: var(--bad); animation: scanline 1.6s ease-in-out infinite alternate; }
@keyframes scanline { from { transform: translateY(-28px); } to { transform: translateY(28px); } }
.scan-status { position: absolute; left: 0; right: 0; bottom: 0; padding: 10px; text-align: center; color: #fff; font-size: 13.5px; font-weight: 600; background: linear-gradient(transparent, rgba(0,0,0,.7)); }
.result-list { max-height: 50dvh; overflow-y: auto; border: 1px solid var(--border); border-radius: 12px; padding: 0 10px; }
.result-list .list-item:hover { background: var(--surface-2); }

/* share viewer */
.viewer-head { display: flex; align-items: center; gap: 12px; padding: 16px 0; flex-wrap: wrap; }
.viewer-wrap { max-width: 1100px; margin: 0 auto; padding: calc(8px + env(safe-area-inset-top, 0px)) 20px 48px; }
