/* ---------- Tokens ---------- */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --border: #e2e5ea;
  --text: #0e1116;
  --muted: #687082;
  --accent: #4d7c0f;
  --accent-ink: #ffffff;
  --accent-soft: rgba(77, 124, 15, 0.12);
  --prot: #e11d48;
  --carb: #0284c7;
  --fat: #d97706;
  --water: #0ea5e9;
  --warn: #ea580c;
  --danger: #dc2626;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 16px rgba(16, 24, 40, 0.06);
  --radius: 16px;
  --radius-sm: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0d10;
    --surface: #14171c;
    --surface-2: #1d2128;
    --border: #272c35;
    --text: #eef1f5;
    --muted: #8d95a3;
    --accent: #a3e635;
    --accent-ink: #0b0d10;
    --accent-soft: rgba(163, 230, 53, 0.13);
    --prot: #fb7185;
    --carb: #38bdf8;
    --fat: #fbbf24;
    --water: #38bdf8;
    --warn: #fb923c;
    --danger: #f87171;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0d10;
  --surface: #14171c;
  --surface-2: #1d2128;
  --border: #272c35;
  --text: #eef1f5;
  --muted: #8d95a3;
  --accent: #a3e635;
  --accent-ink: #0b0d10;
  --accent-soft: rgba(163, 230, 53, 0.13);
  --prot: #fb7185;
  --carb: #38bdf8;
  --fat: #fbbf24;
  --water: #38bdf8;
  --warn: #fb923c;
  --danger: #f87171;
  --shadow: none;
  color-scheme: dark;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
body.lock { overflow: hidden; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 26px; letter-spacing: -0.02em; font-weight: 750; }
h2 { font-size: 17px; font-weight: 680; letter-spacing: -0.01em; }
h3 { font-size: 14px; font-weight: 650; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: inherit; text-decoration: none; }
svg.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.num, .tnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* ---------- Layout ---------- */
#app { display: flex; min-height: 100dvh; }
main {
  flex: 1;
  min-width: 0;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(96px + env(safe-area-inset-bottom));
}
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 16px; min-height: 40px; }
.stack { display: grid; gap: 12px; }
.grid-2 { display: grid; gap: 12px; }
@media (min-width: 900px) {
  .grid-2 { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 16px; align-items: start; }
  .grid-2.even { grid-template-columns: 1fr 1fr; }
  .sticky-col { position: sticky; top: 24px; }
}

/* ---------- Nav ---------- */
.nav {
  position: fixed; z-index: 30; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: space-around;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(16px);
  -webkit-backdrop-filter: saturate(1.6) blur(16px);
  border-top: 1px solid var(--border);
}
.nav .brand { display: none; }
.nav a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 12px; border-radius: 12px; color: var(--muted); font-size: 11px; font-weight: 600; min-width: 64px;
}
.nav a.on { color: var(--text); }
.nav a.on svg { color: var(--accent); }
.nav a .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); position: absolute; margin-left: 18px; }
@media (min-width: 900px) {
  .nav {
    position: sticky; top: 0; height: 100dvh; width: 232px; flex: none;
    flex-direction: column; justify-content: flex-start; gap: 4px;
    padding: 24px 14px; border-top: 0; border-right: 1px solid var(--border);
    background: var(--surface); backdrop-filter: none;
  }
  .nav .brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 20px; font-weight: 750; font-size: 18px; letter-spacing: -0.02em; }
  .nav .brand img { width: 30px; height: 30px; border-radius: 8px; }
  .nav a { flex-direction: row; gap: 12px; font-size: 15px; padding: 10px 12px; min-width: 0; }
  .nav a:hover { background: var(--surface-2); }
  .nav a.on { background: var(--accent-soft); }
  main { padding: 32px 40px 48px; }
}

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.card-head .sub { color: var(--muted); font-size: 13px; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 20px 2px 8px; }
.section-title h2 { font-size: 15px; color: var(--muted); font-weight: 650; }
.empty { text-align: center; color: var(--muted); padding: 20px 8px; }
.empty.small { padding: 12px 8px; font-size: 13px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 16px; border-radius: 12px; font-weight: 620;
  background: var(--surface-2); color: var(--text); white-space: nowrap;
  transition: transform .08s ease, background .15s ease;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); color: #fff; }
.btn.sm { height: 34px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn.icon { width: 42px; padding: 0; }
.btn.icon.sm { width: 34px; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; color: var(--muted); }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.add-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Forms ---------- */
.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; color: var(--muted); font-weight: 560; }
.input, select.input {
  width: 100%; height: 44px; padding: 0 12px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid transparent; outline: none;
  font-size: 16px; /* avoid iOS zoom */
}
.input:focus { border-color: var(--accent); background: var(--surface); }
.input-unit { position: relative; }
.input-unit .input { padding-right: 44px; }
.input-unit > em { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-style: normal; font-size: 14px; pointer-events: none; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.search { position: relative; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search .input { padding-left: 40px; }
.seg { display: flex; background: var(--surface-2); padding: 3px; border-radius: 12px; gap: 2px; }
.seg button { flex: 1; height: 36px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--muted); padding: 0 8px; white-space: nowrap; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; height: 32px; padding: 0 12px; border-radius: 999px; background: var(--surface-2); font-size: 13px; font-weight: 600; color: var(--muted); }
.chip.on { background: var(--accent); color: var(--accent-ink); }

/* ---------- Day switcher ---------- */
.day-switch { display: flex; align-items: center; gap: 2px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 3px; }
.day-label { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 128px; height: 36px; padding: 0 10px; border-radius: 9px; font-size: 14px; font-weight: 650; }
.day-label:hover { background: var(--surface-2); }
.day-label svg { width: 16px; height: 16px; color: var(--accent); }

/* ---------- Calendrier ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-head b { font-size: 16px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { margin-bottom: 4px; }
.cal-dow span { text-align: center; font-size: 12px; color: var(--muted); font-weight: 650; }
.cal-day { aspect-ratio: 1; max-height: 56px; border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-variant-numeric: tabular-nums; }
.cal-day:hover { background: var(--surface-2); }
.cal-day .cal-n { font-size: 15px; font-weight: 600; line-height: 1; }
.cal-day.future .cal-n { color: var(--muted); }
.cal-day.today { box-shadow: inset 0 0 0 1.5px var(--accent); }
.cal-day.sel { background: var(--accent); color: var(--accent-ink); }
.cal-day.sel .cal-n { color: var(--accent-ink); }
.cal-marks { display: flex; gap: 3px; height: 6px; }
.cal-marks i, .cal-legend i { display: inline-block; width: 6px; height: 6px; border-radius: 50%; }
.nut.ok { background: var(--accent); }
.nut.under { background: var(--carb); }
.nut.over { background: var(--warn); }
i.gym { background: var(--text); border-radius: 2px; }
.cal-day.sel .cal-marks i { box-shadow: 0 0 0 1.5px var(--accent-ink); }
.cal-legend { margin-top: 12px; }
.cal-legend span { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- Summary / ring ---------- */
.summary { display: grid; grid-template-columns: auto 1fr; gap: 20px; align-items: center; }
.ring { position: relative; width: 140px; height: 140px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 12; stroke-linecap: round; }
.ring .track { stroke: var(--surface-2); }
.ring .val { stroke: var(--accent); transition: stroke-dasharray .4s ease; }
.ring.over .val { stroke: var(--warn); }
.ring .center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring .center b { font-size: 28px; font-weight: 760; letter-spacing: -0.03em; line-height: 1.1; }
.ring .center span { font-size: 12px; color: var(--muted); }
.kpis { display: grid; gap: 10px; }
.kpi { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.kpi span { color: var(--muted); font-size: 13px; }
.kpi b { font-size: 16px; }
.macros { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 18px; }
.macro .lbl { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.macro .lbl b { color: var(--text); font-weight: 650; }
.bar { height: 7px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: inherit; background: var(--accent); max-width: 100%; transition: width .4s ease; }
.macro.p .bar > i { background: var(--prot); }
.macro.c .bar > i { background: var(--carb); }
.macro.f .bar > i { background: var(--fat); }
.macro .of { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---------- Water ---------- */
.water { display: flex; align-items: center; gap: 14px; }
.water .ico { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: color-mix(in srgb, var(--water) 15%, transparent); color: var(--water); }
.water .info { flex: 1; min-width: 0; }
.water .bar > i { background: var(--water); }
.water .info .t { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 6px; }

/* ---------- Lists ---------- */
.list { display: grid; }
.item {
  display: flex; align-items: center; gap: 12px; padding: 11px 4px; text-align: left; width: 100%;
  border-top: 1px solid var(--border);
}
.item:first-child { border-top: 0; }
button.item:hover, a.item:hover { background: color-mix(in srgb, var(--surface-2) 50%, transparent); border-radius: 10px; }
.item .main { flex: 1; min-width: 0; }
.item .name { font-weight: 580; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .meta { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .end { text-align: right; font-weight: 650; white-space: nowrap; }
.item .end small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; }
img.thumb, .thumb { width: 40px; height: 40px; border-radius: 10px; object-fit: cover; background: var(--surface-2); flex: none; display: grid; place-items: center; color: var(--muted); }
.meal .card-head { margin-bottom: 4px; }
.meal .card-head h2 { font-size: 16px; }
.meal-kcal { color: var(--muted); font-size: 13px; font-weight: 500; margin-left: 6px; }
.list-label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 650; margin: 14px 4px 2px; }

/* ---------- Sheet ---------- */
#sheet-root { position: fixed; inset: 0; z-index: 60; display: none; }
#sheet-root.open { display: block; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(5, 8, 12, .5); animation: fade .2s ease; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border-radius: 22px 22px 0 0; padding: 8px 16px calc(20px + env(safe-area-inset-bottom));
  animation: up .25s cubic-bezier(.2,.9,.3,1);
}
.sheet-grip { width: 40px; height: 5px; border-radius: 9px; background: var(--border); margin: 0 auto 12px; }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.sheet-head h2 { font-size: 19px; }
.sheet-actions { display: flex; gap: 8px; margin-top: 18px; }
.sheet-actions .btn { flex: 1; }
.sheet .stack { gap: 14px; }
@media (min-width: 700px) {
  .sheet { left: 50%; top: 50%; bottom: auto; width: min(560px, calc(100vw - 48px)); transform: translate(-50%, -50%); border-radius: 22px; max-height: 86dvh; padding: 20px 22px 22px; animation: pop .2s ease; }
  .sheet-grip { display: none; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: .4; } }
@keyframes pop { from { transform: translate(-50%, -48%) scale(.98); opacity: 0; } }

/* ---------- Food detail ---------- */
.nut-big { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; background: var(--surface-2); border-radius: 14px; padding: 12px 6px; }
.nut-big b { display: block; font-size: 19px; font-weight: 720; }
.nut-big span { font-size: 12px; color: var(--muted); }
.nut-big .p b { color: var(--prot); } .nut-big .c b { color: var(--carb); } .nut-big .f b { color: var(--fat); }
.nut-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.nut-table td { padding: 6px 2px; border-top: 1px solid var(--border); }
.nut-table td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
details summary { cursor: pointer; color: var(--muted); font-size: 14px; font-weight: 600; padding: 4px 0; }

/* ---------- Gym ---------- */
.hero { background: linear-gradient(135deg, var(--accent-soft), transparent 70%), var(--surface); }
.hero .eyebrow { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); font-weight: 700; }
.hero h2 { font-size: 22px; margin: 4px 0 6px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 14px; }
.tag { font-size: 12px; padding: 3px 9px; border-radius: 99px; background: var(--surface-2); color: var(--muted); font-weight: 600; }
.routines { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.routine { display: flex; flex-direction: column; gap: 4px; }
.routine .r-actions { display: flex; gap: 6px; margin-top: 10px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 12px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 21px; font-weight: 740; letter-spacing: -0.02em; }
.stat span { font-size: 12px; color: var(--muted); }

.session-head {
  position: sticky; top: 0; z-index: 20; margin: calc(-16px - env(safe-area-inset-top)) -16px 14px; padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--border);
}
@media (min-width: 900px) { .session-head { margin: -32px -40px 18px; padding: 18px 40px; } }
.session-head .title { flex: 1; min-width: 0; }
.session-head input { background: none; border: 0; outline: none; font-size: 19px; font-weight: 720; width: 100%; padding: 0; }
.session-head .clock { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.ex-card .card-head { margin-bottom: 6px; }
.ex-card .prev-line { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.sets { display: grid; gap: 6px; }
.set, .set-h { display: grid; grid-template-columns: 26px minmax(0, 1fr) 70px 70px 42px; gap: 8px; align-items: center; }
.set-h { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; padding: 0 0 2px; }
.set-h span:nth-child(n+3) { text-align: center; }
.set-n { font-weight: 700; color: var(--muted); text-align: center; font-size: 14px; height: 40px; border-radius: 10px; display: grid; place-items: center; }
.set-n:hover { background: var(--surface-2); }
.set-n svg { width: 16px; height: 16px; }
.t-wu .set-n { color: var(--carb); }
.t-wu .set-in, .t-wu .set-prev { opacity: .75; }
.t-fail .set-n { color: var(--warn); font-size: 12px; }
.t-drop .set-n { color: var(--prot); }
.set-legend { font-size: 12px; color: var(--muted); margin-top: 8px; }
.set-legend .badge { display: inline-block; min-width: 22px; padding: 1px 6px; margin: 2px 2px 2px 6px; border-radius: 6px; background: var(--surface-2); font-weight: 700; font-size: 11px; text-align: center; }
.set-legend .badge:first-child { margin-left: 4px; }
.badge.t-wu { color: var(--carb); } .badge.t-fail { color: var(--warn); } .badge.t-drop { color: var(--prot); }
.ex-hint { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); background: var(--surface-2); border-radius: 10px; padding: 7px 10px; margin: 2px 0 10px; }
.ex-hint svg { width: 15px; height: 15px; flex: none; }
.ex-hint.up { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.toggle { display: flex; align-items: center; gap: 10px; font-size: 14px; text-align: left; color: var(--text); padding: 4px 0; }
.toggle i { width: 38px; height: 22px; border-radius: 99px; background: var(--border); position: relative; flex: none; transition: background .15s; }
.toggle i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.toggle.on i { background: var(--accent); }
.toggle.on i::after { transform: translateX(16px); }
.r-edit-item .nums.four { grid-template-columns: repeat(4, 1fr); }
.set-prev { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.set-in { height: 40px; width: 100%; text-align: center; border-radius: 10px; background: var(--surface-2); border: 1px solid transparent; outline: none; font-size: 16px; font-weight: 650; font-variant-numeric: tabular-nums; }
.set-in:focus { border-color: var(--accent); }
.set-check { height: 40px; border-radius: 10px; background: var(--surface-2); color: var(--muted); display: grid; place-items: center; }
.set.done .set-check { background: var(--accent); color: var(--accent-ink); }
.set.done .set-in { background: var(--accent-soft); }
.set.pr .set-n { color: var(--fat); }
.set-tools { display: flex; gap: 6px; margin-top: 10px; }

.rest {
  position: fixed; z-index: 40; left: 12px; right: 12px; bottom: calc(76px + env(safe-area-inset-bottom));
  background: var(--text); color: var(--bg); border-radius: 16px; padding: 10px 10px 10px 16px;
  display: flex; align-items: center; gap: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.25); overflow: hidden;
}
.rest .rest-fill { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--accent); }
.rest .rest-t { flex: 1; font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 8px; }
.rest .rest-t small { font-weight: 500; font-size: 13px; opacity: .7; }
.rest button { height: 34px; padding: 0 10px; border-radius: 9px; background: color-mix(in srgb, var(--bg) 14%, transparent); font-weight: 650; font-size: 13px; }
@media (min-width: 900px) { .rest { left: auto; right: 24px; bottom: 24px; width: 380px; } }

.ex-link { display: flex; align-items: center; gap: 10px; text-align: left; min-width: 0; flex: 1; border-radius: 10px; }
.ex-link h2 { text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 3px; }
.ex-link:hover h2, .ex-link:hover span { text-decoration-color: var(--accent); }
.ex-link > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
img.ex-thumb { background: #fff; object-fit: cover; }
button.tag:hover { color: var(--text); }
.tag.on { background: var(--accent-soft); color: var(--accent); }
.ex-anim { position: relative; aspect-ratio: 3 / 2; border-radius: 14px; overflow: hidden; background: #fff; }
.ex-anim img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.ex-anim img.f1 { animation: exframe 1.8s infinite; }
@keyframes exframe { 0%, 42% { opacity: 0; } 50%, 92% { opacity: 1; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .ex-anim img.f1 { animation-duration: 4s; } }
.steps { margin: 8px 0 0; padding-left: 20px; display: grid; gap: 6px; font-size: 14px; color: var(--muted); }
.r-edit-item .top .ex-link .thumb { width: 32px; height: 32px; }
.r-edit-item { padding: 10px 0; border-top: 1px solid var(--border); display: grid; gap: 8px; }
.r-edit-item:first-child { border-top: 0; }
.r-edit-item .top { display: flex; align-items: center; gap: 6px; }
.r-edit-item .top .name { flex: 1; font-weight: 600; min-width: 0; }
.r-edit-item .nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.r-edit-item .nums .input { height: 38px; font-size: 15px; }

/* ---------- Charts ---------- */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { fill: var(--muted); font-size: 18px; font-family: inherit; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .goal { stroke: var(--muted); stroke-width: 2; stroke-dasharray: 6 6; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--accent-soft); }
.chart .dot { fill: var(--accent); }
.chart .b { fill: var(--accent); }
.chart .b.hi { fill: var(--warn); }
.chart .b.zero { fill: var(--surface-2); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 8px; flex-wrap: wrap; }
.big-num { font-size: 30px; font-weight: 760; letter-spacing: -0.03em; }
.delta { font-size: 13px; font-weight: 650; }
.delta.down { color: var(--accent); } .delta.up { color: var(--warn); }

/* ---------- Target card (profile) ---------- */
.target { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; text-align: center; }
.target b { display: block; font-size: 20px; font-weight: 740; }
.target span { font-size: 12px; color: var(--muted); }
.target .main b { color: var(--accent); font-size: 26px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; z-index: 80; left: 50%; top: calc(14px + env(safe-area-inset-top)); transform: translate(-50%, -140%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: 14px;
  transition: transform .25s ease; max-width: calc(100vw - 32px); display: flex; align-items: center; gap: 8px;
}
.toast.show { transform: translate(-50%, 0); }

/* ---------- Scanner ---------- */
.scanner { position: fixed; inset: 0; z-index: 90; background: #000; display: flex; flex-direction: column; }
.scanner video { flex: 1; width: 100%; object-fit: cover; min-height: 0; }
.scan-frame { position: absolute; left: 50%; top: 40%; width: min(78vw, 360px); height: 170px; transform: translate(-50%, -50%); border: 3px solid #a3e635; border-radius: 18px; box-shadow: 0 0 0 9999px rgba(0,0,0,.45); pointer-events: none; }
.scan-bar { padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); background: #111; display: grid; gap: 10px; }
.scan-bar form { display: flex; gap: 8px; }
.scan-bar .input { background: #222; color: #fff; }
.scan-msg { position: absolute; top: calc(20px + env(safe-area-inset-top)); left: 0; right: 0; text-align: center; color: #fff; font-weight: 600; padding: 0 20px; }

.spinner { width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid var(--border); border-top-color: var(--accent); animation: spin .7s linear infinite; margin: 16px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.sync-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.sync-dot.syncing { background: var(--carb); animation: pulse 1s ease-in-out infinite; }
.sync-dot.offline { background: var(--muted); }
.sync-dot.error { background: var(--warn); }
@keyframes pulse { 50% { opacity: .35; } }
.note { font-size: 13px; color: var(--muted); background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.warn-text { color: var(--warn); font-size: 13px; }
