:root {
  color-scheme: dark;
  --bg: #08131f;
  --bg-2: #0c1b2b;
  --panel: rgba(18, 36, 55, 0.92);
  --panel-2: #132a40;
  --panel-3: #17344f;
  --text: #f6fbff;
  --muted: #91a8ba;
  --line: rgba(255,255,255,.09);
  --aqua: #2ce6d0;
  --aqua-2: #11b9ca;
  --orange: #ff9f43;
  --red: #ff6577;
  --green: #6ee7a8;
  --yellow: #ffd166;
  --shadow: 0 18px 50px rgba(0,0,0,.28);
  --radius: 20px;
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 90% -10%, rgba(44,230,208,.18), transparent 35%),
    linear-gradient(180deg, #08131f 0%, #091724 55%, #07111b 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--aqua); outline-offset: 2px;
}
.app-shell { width: min(100%, 920px); margin: 0 auto; min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: max(18px, env(safe-area-inset-top)) 18px 14px;
  background: linear-gradient(180deg, rgba(8,19,31,.98) 65%, rgba(8,19,31,.72) 85%, transparent);
  backdrop-filter: blur(18px);
}
.eyebrow { color: var(--aqua); font-weight: 800; letter-spacing: .16em; font-size: 11px; }
h1 { margin: 4px 0 0; font-size: clamp(26px, 7vw, 38px); line-height: 1; }
.sync-pill {
  border: 1px solid var(--line); background: rgba(255,255,255,.045); color: var(--muted);
  border-radius: 999px; padding: 9px 11px; display: flex; align-items: center; gap: 8px;
  font-size: 12px;
}
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 12px rgba(110,231,168,.7); }
.sync-pill.syncing .sync-dot { background: var(--yellow); }
.sync-pill.error .sync-dot { background: var(--red); }
.view { padding: 4px 14px 112px; }
.section { margin: 0 0 18px; }
.section-head { display: flex; align-items: end; justify-content: space-between; margin: 8px 2px 10px; gap: 12px; }
.section-head h2 { margin: 0; font-size: 18px; }
.section-head p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.card {
  background: linear-gradient(145deg, rgba(22,47,71,.94), rgba(14,31,49,.94));
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 12px;
}
.hero-card { overflow: hidden; position: relative; padding: 19px; }
.hero-card::after {
  content: ""; position: absolute; width: 190px; height: 190px; border-radius: 50%; right: -75px; top: -85px;
  background: radial-gradient(circle, rgba(44,230,208,.25), rgba(44,230,208,0) 68%);
}
.hero-kicker { color: var(--aqua); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .11em; }
.hero-card h2 { margin: 5px 0 6px; font-size: 27px; }
.hero-card p { color: var(--muted); margin: 0 0 16px; line-height: 1.45; max-width: 580px; }
.inline-actions { display: flex; flex-wrap: wrap; gap: 9px; }
.btn {
  appearance: none; border: 0; border-radius: 14px; padding: 12px 15px; font-weight: 800;
  background: var(--aqua); color: #03211e; min-height: 44px;
}
.btn:hover { filter: brightness(1.04); }
.btn.secondary { background: rgba(255,255,255,.075); color: var(--text); border: 1px solid var(--line); }
.btn.ghost { background: transparent; color: var(--aqua); border: 1px solid rgba(44,230,208,.32); }
.btn.danger { background: rgba(255,101,119,.13); color: #ff9fac; border: 1px solid rgba(255,101,119,.25); }
.btn.small { min-height: 35px; padding: 8px 11px; font-size: 12px; border-radius: 11px; }
.btn.block { width: 100%; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; }
.stat-card { padding: 14px; }
.stat-label { color: var(--muted); font-size: 12px; }
.stat-value { font-weight: 900; font-size: 24px; margin-top: 4px; }
.stat-sub { color: var(--muted); font-size: 11px; margin-top: 3px; }
.progress-line { margin: 11px 0 0; }
.progress-meta { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; margin-bottom: 7px; }
.progress-meta span:last-child { color: var(--muted); }
.progress-track { height: 9px; background: rgba(255,255,255,.065); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg,var(--aqua-2),var(--aqua)); }
.progress-fill.orange { background: linear-gradient(90deg,#ff824d,var(--orange)); }
.progress-fill.red { background: linear-gradient(90deg,#ff5268,#ff8d9a); }
.mini-list { display: grid; gap: 9px; margin-top: 13px; }
.mini-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.mini-row:first-child { border-top: 0; }
.mini-title { font-weight: 750; }
.mini-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 5px 9px; font-size: 11px; font-weight: 800; background: rgba(44,230,208,.12); color: var(--aqua); border: 1px solid rgba(44,230,208,.2); }
.badge.orange { background: rgba(255,159,67,.12); color: #ffc287; border-color: rgba(255,159,67,.2); }
.badge.red { background: rgba(255,101,119,.12); color: #ff9fac; border-color: rgba(255,101,119,.2); }
.notice { padding: 13px 14px; border-radius: 15px; color: #d9f9f5; background: rgba(44,230,208,.09); border: 1px solid rgba(44,230,208,.16); line-height: 1.45; font-size: 13px; }
.notice.warn { color: #ffddb5; background: rgba(255,159,67,.09); border-color: rgba(255,159,67,.18); }
.workout-summary { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.workout-summary h2 { margin: 2px 0 4px; font-size: 24px; }
.exercise-card { padding: 0; overflow: hidden; }
.exercise-head { padding: 15px 15px 12px; display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.exercise-num { width: 29px; height: 29px; border-radius: 10px; display: grid; place-items: center; background: rgba(44,230,208,.13); color: var(--aqua); font-weight: 900; flex: 0 0 auto; }
.exercise-heading { display: flex; gap: 10px; align-items: flex-start; flex: 1; }
.exercise-title { font-weight: 900; font-size: 17px; }
.exercise-meta { color: var(--muted); font-size: 12px; margin-top: 3px; }
.exercise-actions { display: flex; gap: 6px; }
.icon-btn { width: 35px; height: 35px; border-radius: 11px; border: 1px solid var(--line); color: var(--text); background: rgba(255,255,255,.055); display: grid; place-items: center; }
.recommendation { margin: 0 15px 12px; padding: 10px 11px; border-radius: 12px; background: rgba(255,255,255,.045); color: var(--muted); font-size: 12px; line-height: 1.4; }
.set-table { border-top: 1px solid var(--line); }
.set-header, .set-row { display: grid; grid-template-columns: 34px minmax(65px,1fr) minmax(58px,.85fr) minmax(55px,.75fr) 42px; gap: 7px; align-items: center; padding: 8px 12px; }
.set-header { color: var(--muted); text-transform: uppercase; letter-spacing: .07em; font-size: 9px; font-weight: 800; }
.set-row { border-top: 1px solid rgba(255,255,255,.05); }
.set-row.complete { background: rgba(44,230,208,.055); }
.set-number { color: var(--muted); font-weight: 800; text-align: center; }
.field, .select, .textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 11px; background: rgba(4,15,25,.48); color: var(--text); padding: 10px 10px;
}
.field.compact, .select.compact { padding: 8px 7px; text-align: center; }
.check-btn { width: 36px; height: 36px; border-radius: 11px; border: 1px solid var(--line); background: rgba(255,255,255,.055); color: var(--muted); font-weight: 900; }
.check-btn.done { background: var(--aqua); color: #03211e; border-color: transparent; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.form-field { display: grid; gap: 6px; }
.form-field.full { grid-column: 1 / -1; }
.form-field label { color: var(--muted); font-size: 12px; font-weight: 700; }
.textarea { resize: vertical; min-height: 82px; }
.segmented { display: flex; padding: 4px; border-radius: 13px; background: rgba(0,0,0,.18); gap: 4px; }
.segmented button { flex: 1; border: 0; border-radius: 10px; padding: 9px 8px; background: transparent; color: var(--muted); font-weight: 800; font-size: 12px; }
.segmented button.active { background: var(--panel-3); color: var(--text); }
.food-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); }
.food-row:first-child { border-top: 0; }
.food-name { font-weight: 850; }
.food-meta { color: var(--muted); font-size: 12px; margin-top: 3px; }
.metric-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.metric-row:first-child { border-top: 0; }
.metric-value { text-align: right; font-weight: 850; }
.chart-wrap { background: rgba(0,0,0,.12); border-radius: 15px; padding: 10px 8px 5px; overflow: hidden; }
.chart { width: 100%; height: auto; display: block; }
.chart-label { fill: #8fa6b8; font-size: 10px; }
.chart-line { fill: none; stroke: var(--aqua); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.chart-area { fill: url(#areaGradient); }
.chart-dot { fill: #07131e; stroke: var(--aqua); stroke-width: 2; }
.empty { text-align: center; padding: 30px 18px; color: var(--muted); }
.empty-icon { font-size: 34px; margin-bottom: 7px; }
.photo-box { border: 1px dashed rgba(255,255,255,.18); background: rgba(0,0,0,.12); border-radius: 14px; padding: 15px; text-align: center; color: var(--muted); }
.photo-box img { display: block; width: 100%; max-height: 240px; object-fit: cover; border-radius: 12px; margin-bottom: 10px; }
.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(1,8,14,.76); backdrop-filter: blur(8px); display: flex; align-items: flex-end; justify-content: center; padding: 12px; }
.modal { width: min(100%,680px); max-height: 90vh; overflow: auto; border-radius: 24px 24px 18px 18px; background: #102338; border: 1px solid var(--line); box-shadow: 0 28px 70px rgba(0,0,0,.55); }
.modal-head { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px; background: rgba(16,35,56,.96); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px); }
.modal-head h2 { margin: 0; font-size: 20px; }
.modal-body { padding: 16px; }
.modal-close { width: 37px; height: 37px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255,255,255,.05); color: var(--text); }
.diagram { background: #e9f3f5; border-radius: 16px; padding: 10px; color: #143146; }
.diagram svg { width: 100%; height: auto; display: block; }
.instruction-list { padding-left: 19px; line-height: 1.5; color: #d8e7f1; }
.toast-root { position: fixed; z-index: 200; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(calc(100% - 26px),540px); display: grid; gap: 8px; pointer-events: none; }
.toast { background: #effaf9; color: #09231f; border-radius: 13px; padding: 12px 14px; box-shadow: 0 16px 45px rgba(0,0,0,.38); font-size: 13px; font-weight: 750; animation: toastIn .22s ease-out; }
.toast.error { background: #ffe9ed; color: #5d1320; }
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } }
.bottom-nav {
  position: fixed; z-index: 50; bottom: 0; left: 50%; transform: translateX(-50%); width: min(100%,920px);
  display: grid; grid-template-columns: repeat(5,1fr); padding: 8px 8px max(8px,env(safe-area-inset-bottom));
  background: rgba(7,17,27,.94); border-top: 1px solid var(--line); backdrop-filter: blur(18px);
}
.nav-item { border: 0; background: transparent; color: #7890a3; display: grid; place-items: center; gap: 3px; padding: 6px 2px; font-size: 10px; font-weight: 750; }
.nav-item.active { color: var(--aqua); }
.nav-icon { font-size: 19px; line-height: 1; }
.settings-link { border: 0; background: transparent; color: var(--muted); padding: 3px; text-decoration: underline; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
@media (min-width: 700px) {
  .view { padding-left: 22px; padding-right: 22px; }
  .dashboard-grid { display: grid; grid-template-columns: 1.25fr .75fr; gap: 12px; }
  .modal-backdrop { align-items: center; }
  .modal { border-radius: 24px; }
}
@media (max-width: 480px) {
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-field.full { grid-column: auto; }
  .set-header, .set-row { grid-template-columns: 27px minmax(58px,1fr) minmax(52px,.8fr) minmax(48px,.7fr) 39px; padding-left: 8px; padding-right: 8px; gap: 5px; }
}

.set-target{font-size:12px;font-weight:800;color:var(--muted);text-align:center;line-height:1.15;padding:0 3px}
.preview-caption {
  padding: 11px 14px 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  border-top: 1px solid var(--line);
}
.preview-row .field::placeholder { color: #6f8799; opacity: 1; }

/* Supabase login and cloud state */
.app-shell.locked { display: none; }
.auth-gate {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 22px;
  background:
    radial-gradient(circle at 15% 15%, rgba(44,230,208,.14), transparent 32%),
    radial-gradient(circle at 85% 80%, rgba(255,159,67,.10), transparent 30%),
    var(--bg);
}
.auth-gate.hidden { display: none; }
.auth-card {
  width: min(100%, 470px);
  padding: 24px;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: rgba(13, 31, 48, .96);
  box-shadow: 0 24px 70px rgba(0,0,0,.38);
}
.auth-card h1 { margin: 7px 0 8px; font-size: 28px; }
.auth-message { margin: 0 0 18px; color: var(--muted); line-height: 1.5; }
.auth-controls { display: grid; gap: 13px; }
.auth-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.auth-help { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.auth-card .form-field span { color: var(--muted); font-size: 12px; font-weight: 700; }
@media (max-width: 430px) {
  .auth-actions { grid-template-columns: 1fr; }
  .auth-card { padding: 20px; }
}
