/* ===========================================================
   Fat Loss Tracker — mobile-first dark theme
   =========================================================== */
:root {
  --bg: #0b0f14;
  --bg-elev: #131a22;
  --bg-elev-2: #1a232e;
  --card: #141c26;
  --line: #26313d;
  --line-soft: #1e2731;
  --txt: #e8eef4;
  --txt-dim: #97a6b6;
  --txt-faint: #6b7a8a;
  --accent: #34d399;
  --accent-2: #22d3ee;
  --danger: #f87171;
  --warn: #fbbf24;
  --good: #34d399;
  --radius: 16px;
  --radius-sm: 11px;
  --tap: 48px;
  --nav-h: 64px;
  --maxw: 620px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--txt);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
p { margin: 0 0 10px; }
button { font-family: inherit; cursor: pointer; border: none; color: inherit; }
a { color: var(--accent-2); }
input, select { font-family: inherit; }

/* ---------- Layout ---------- */
.app {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: calc(var(--safe-t) + 8px) 16px calc(var(--nav-h) + var(--safe-b) + 24px);
  min-height: 100dvh;
}
.view { animation: fade .22s ease; }
.view[hidden] { display: none; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.topbar { display: flex; align-items: center; justify-content: space-between; padding: 6px 2px 14px; }
.topbar .brand { display: flex; align-items: center; gap: 10px; }
.topbar .logo {
  width: 34px; height: 34px; border-radius: 9px; flex: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; color: #06231b; font-weight: 900; font-size: 18px;
}
.topbar .ttl { font-size: 15px; font-weight: 800; letter-spacing: .2px; }
.topbar .sub { font-size: 11.5px; color: var(--txt-faint); }
.pill {
  font-size: 11px; font-weight: 700; color: var(--txt-dim);
  background: var(--bg-elev); border: 1px solid var(--line);
  padding: 6px 11px; border-radius: 999px;
}

/* ---------- Cards ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 14px;
}
.card.tight { padding: 13px 14px; }
.section-label { font-size: 12px; letter-spacing: .09em; text-transform: uppercase; color: var(--txt-faint); font-weight: 700; margin: 22px 2px 10px; }
.muted { color: var(--txt-dim); }
.faint { color: var(--txt-faint); }
.small { font-size: 13px; }
.xsmall { font-size: 11.5px; }

/* ---------- Today hero ---------- */
.hero {
  position: relative; overflow: hidden;
  border-radius: 20px; padding: 20px; margin-bottom: 16px;
  background: radial-gradient(120% 140% at 100% 0%, rgba(52,211,153,.16), transparent 55%), var(--bg-elev);
  border: 1px solid var(--line);
}
.hero .day-dot { font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }
.hero h1 { font-size: 25px; margin: 6px 0 3px; line-height: 1.1; }
.hero .focus { color: var(--txt-dim); font-size: 14px; }
.hero .blocks { display: flex; gap: 8px; margin-top: 15px; flex-wrap: wrap; }
.hero .chip {
  font-size: 12.5px; font-weight: 600; color: var(--txt);
  background: rgba(255,255,255,.04); border: 1px solid var(--line);
  padding: 7px 12px; border-radius: 10px; display: inline-flex; align-items: center; gap: 6px;
}
.hero .chip svg { width: 15px; height: 15px; opacity: .85; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  min-height: var(--tap); width: 100%; padding: 0 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #04241b;
  font-weight: 800; font-size: 16px; border-radius: 13px; letter-spacing: .2px;
  transition: transform .08s ease, filter .15s ease;
}
.btn:active { transform: scale(.985); filter: brightness(1.05); }
.btn.secondary { background: var(--bg-elev-2); color: var(--txt); border: 1px solid var(--line); }
.btn.ghost { background: transparent; color: var(--txt-dim); border: 1px solid var(--line); font-weight: 700; }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid rgba(248,113,113,.35); font-weight: 700; }
.btn.sm { min-height: 40px; font-size: 14px; width: auto; padding: 0 15px; border-radius: 10px; }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { width: auto; flex: 1; }

/* ---------- Weekly strip ---------- */
.week-strip { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; margin-bottom: 6px; }
.week-strip .d {
  text-align: center; padding: 10px 4px; border-radius: 12px;
  background: var(--bg-elev); border: 1px solid var(--line-soft);
}
.week-strip .d.today { border-color: var(--accent); background: rgba(52,211,153,.08); }
.week-strip .d .dn { font-size: 11px; font-weight: 800; color: var(--txt-dim); }
.week-strip .d .df { font-size: 10px; color: var(--txt-faint); margin-top: 2px; }
.week-strip .d .mk { margin-top: 7px; height: 18px; display: grid; place-items: center; }
.week-strip .d .mk .done { color: var(--good); }
.week-strip .d .mk .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--line); display: inline-block; }

/* ---------- Stat tiles ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: 13px; padding: 13px 14px;
}
.stat .k { font-size: 11.5px; color: var(--txt-faint); font-weight: 600; letter-spacing: .03em; }
.stat .v { font-size: 23px; font-weight: 800; margin-top: 3px; letter-spacing: -.02em; }
.stat .v small { font-size: 13px; color: var(--txt-dim); font-weight: 600; }
.stat .sub { font-size: 11.5px; margin-top: 2px; }
.up { color: var(--good); } .down { color: var(--accent-2); } .neg { color: var(--danger); }

/* ---------- Exercise / list rows ---------- */
.ex-row {
  display: flex; align-items: center; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line-soft);
}
.ex-row:last-child { border-bottom: none; }
.ex-row .idx {
  width: 30px; height: 30px; flex: none; border-radius: 9px; display: grid; place-items: center;
  background: var(--bg-elev-2); color: var(--txt-dim); font-weight: 800; font-size: 13px;
}
.ex-row .info { flex: 1; min-width: 0; }
.ex-row .info .nm { font-weight: 700; font-size: 15px; }
.ex-row .info .meta { font-size: 12.5px; color: var(--txt-dim); margin-top: 1px; }
.ex-row .vbtn {
  flex: none; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center;
  background: var(--bg-elev-2); border: 1px solid var(--line);
}
.ex-row .vbtn svg { width: 18px; height: 18px; color: var(--txt); }

/* ---------- Reference / guide ---------- */
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); font-size: 14px; }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--txt-dim); }
.kv .v { font-weight: 700; text-align: right; }
.note-card { border-left: 3px solid var(--accent); }
details.acc { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; background: var(--card); overflow: hidden; }
details.acc summary { padding: 14px 16px; font-weight: 700; font-size: 14.5px; list-style: none; display: flex; justify-content: space-between; align-items: center; cursor: pointer; }
details.acc summary::-webkit-details-marker { display: none; }
details.acc summary::after { content: '+'; color: var(--txt-faint); font-size: 20px; font-weight: 400; }
details.acc[open] summary::after { content: '–'; }
details.acc .body { padding: 0 16px 16px; font-size: 13.5px; color: var(--txt-dim); }

/* ---------- Bottom nav ---------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: rgba(11,15,20,.86); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  display: flex; justify-content: center;
}
.nav-inner { display: flex; width: 100%; max-width: var(--maxw); }
.nav button {
  flex: 1; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: var(--txt-faint); font-size: 10.5px; font-weight: 700; letter-spacing: .02em;
}
.nav button svg { width: 23px; height: 23px; }
.nav button.active { color: var(--accent); }

/* ---------- Session overlay ---------- */
.session {
  position: fixed; inset: 0; z-index: 60; background: var(--bg);
  display: flex; flex-direction: column; animation: slideup .28s cubic-bezier(.22,1,.36,1);
}
.session[hidden] { display: none; }
@keyframes slideup { from { transform: translateY(100%); } to { transform: none; } }
.session-top {
  padding: calc(var(--safe-t) + 12px) 16px 12px; display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--line);
}
.session-top .x { width: 38px; height: 38px; flex: none; border-radius: 10px; background: var(--bg-elev-2); display: grid; place-items: center; }
.session-top .x svg { width: 18px; height: 18px; }
.session-top .st-title { flex: 1; min-width: 0; }
.session-top .st-title .t1 { font-weight: 800; font-size: 15px; }
.session-top .st-title .t2 { font-size: 11.5px; color: var(--txt-faint); }
.progress-track { height: 4px; background: var(--line-soft); }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .35s ease; border-radius: 0 3px 3px 0; }
.session-body { flex: 1; overflow-y: auto; padding: 18px 16px 130px; -webkit-overflow-scrolling: touch; }
.session-foot {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 12px 16px calc(12px + var(--safe-b));
  background: linear-gradient(to top, var(--bg) 62%, transparent); display: flex; gap: 10px;
}
.session-foot .btn { flex: 1; }

.step-kicker { font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); margin-bottom: 6px; }
.step-h { font-size: 22px; margin-bottom: 6px; }

/* ---------- Timer ---------- */
.timer-wrap { display: flex; flex-direction: column; align-items: center; margin: 6px 0 16px; }
.timer-ring { position: relative; width: 240px; height: 240px; }
.timer-ring svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.timer-ring .bg { stroke: var(--line); }
.timer-ring .fg { stroke: var(--accent); transition: stroke-dashoffset .3s linear, stroke .3s ease; stroke-linecap: round; }
.timer-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.timer-center .zone { font-size: 12.5px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.timer-center .clock { font-size: 52px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; line-height: 1; margin: 4px 0; }
.timer-center .phase-detail { font-size: 12.5px; color: var(--txt-dim); text-align: center; max-width: 170px; }
.timer-center .upnext { font-size: 11px; color: var(--txt-faint); margin-top: 8px; }
.z-warm .fg, .z-warm .clock { stroke: var(--warn); }
.zone.z-warm { color: var(--warn); } .zone.z-easy, .zone.z-steady { color: var(--accent-2); }
.zone.z-hard { color: var(--danger); }
.timer-ring.z-hard .fg { stroke: var(--danger); }
.timer-ring.z-warm .fg { stroke: var(--warn); }
.timer-ring.z-easy .fg, .timer-ring.z-steady .fg { stroke: var(--accent-2); }
.timer-ctrls { display: flex; gap: 10px; margin-top: 4px; width: 100%; }
.timer-ctrls .btn { flex: 1; }
.phase-list { margin-top: 14px; }
.phase-list .p { display: flex; align-items: center; gap: 10px; font-size: 12.5px; padding: 5px 0; color: var(--txt-faint); }
.phase-list .p.active { color: var(--txt); font-weight: 700; }
.phase-list .p.done { color: var(--txt-faint); text-decoration: line-through; opacity: .6; }
.phase-list .p .bar { width: 8px; height: 8px; border-radius: 50%; background: var(--line); flex: none; }
.phase-list .p.active .bar { background: var(--accent); box-shadow: 0 0 0 4px rgba(52,211,153,.18); }

/* ---------- Set logging ---------- */
.set-table { width: 100%; margin-top: 6px; }
.set-head, .set-line { display: grid; grid-template-columns: 42px 1fr 1fr 46px; gap: 8px; align-items: center; }
.set-head { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--txt-faint); font-weight: 700; padding: 0 2px 6px; }
.set-line { padding: 6px 0; }
.set-line .sn { font-weight: 800; color: var(--txt-dim); font-size: 14px; text-align: center; }
.set-line input {
  width: 100%; height: 46px; text-align: center; font-size: 17px; font-weight: 700;
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: 11px; color: var(--txt);
}
.set-line input:focus { outline: none; border-color: var(--accent); }
.set-line input::placeholder { color: var(--txt-faint); font-weight: 500; }
.set-check {
  width: 46px; height: 46px; border-radius: 11px; background: var(--bg-elev); border: 1px solid var(--line);
  display: grid; place-items: center; transition: all .12s ease;
}
.set-check svg { width: 20px; height: 20px; color: var(--txt-faint); }
.set-check.on { background: var(--good); border-color: var(--good); }
.set-check.on svg { color: #04241b; }
.set-line.done input { border-color: rgba(52,211,153,.35); }

.target-badge { display: inline-flex; gap: 6px; align-items: center; background: var(--bg-elev-2); border: 1px solid var(--line); padding: 6px 11px; border-radius: 9px; font-size: 13px; font-weight: 700; }
.target-badge .lbl { color: var(--txt-faint); font-weight: 600; }

/* video embed */
.video-box { position: relative; width: 100%; aspect-ratio: 16/9; border-radius: 12px; overflow: hidden; background: #000; border: 1px solid var(--line); margin-top: 4px; }
.video-box iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; color: var(--accent-2); background: none; padding: 8px 0; }
.video-toggle svg { width: 17px; height: 17px; }

/* rest timer bar */
.rest-bar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(88px + var(--safe-b)); z-index: 70;
  width: min(92%, calc(var(--maxw) - 20px)); background: var(--bg-elev-2); border: 1px solid var(--accent);
  border-radius: 14px; padding: 12px 15px; display: flex; align-items: center; gap: 13px;
  box-shadow: 0 10px 30px rgba(0,0,0,.5); animation: fade .2s ease;
}
.rest-bar[hidden] { display: none; }
.rest-bar .rt-clock { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--accent); min-width: 62px; }
.rest-bar .rt-lbl { flex: 1; font-size: 12.5px; color: var(--txt-dim); }
.rest-bar .rt-lbl b { color: var(--txt); display: block; font-size: 13.5px; }
.rest-bar button { font-size: 12.5px; font-weight: 700; color: var(--txt-dim); background: var(--bg-elev); border: 1px solid var(--line); padding: 8px 11px; border-radius: 9px; }

/* metric input */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.field .hint { font-size: 12px; color: var(--txt-faint); font-weight: 500; }
.field input, .field select, .field textarea {
  width: 100%; height: 50px; background: var(--bg-elev); border: 1px solid var(--line); border-radius: 12px;
  color: var(--txt); font-size: 16px; padding: 0 14px; font-weight: 600;
}
.field textarea { height: auto; padding: 12px 14px; min-height: 64px; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--accent); }

/* summary */
.summary-hero { text-align: center; padding: 18px 0 8px; }
.summary-hero .ring { width: 96px; height: 96px; margin: 0 auto 12px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-2)); display: grid; place-items: center; }
.summary-hero .ring svg { width: 46px; height: 46px; color: #04241b; }
.summary-hero h2 { font-size: 24px; }

/* history */
.hist-item { display: flex; align-items: center; gap: 13px; }
.hist-item .badge { width: 46px; height: 46px; flex: none; border-radius: 12px; display: grid; place-items: center; font-weight: 800; font-size: 12px; color: #04241b; }
.hist-item .hi-main { flex: 1; min-width: 0; }
.hist-item .hi-main .d { font-weight: 700; font-size: 14.5px; }
.hist-item .hi-main .s { font-size: 12px; color: var(--txt-dim); margin-top: 1px; }
.hist-item .chev { color: var(--txt-faint); }

/* charts */
.chart { width: 100%; height: 130px; margin-top: 8px; }
.chart .grid-line { stroke: var(--line-soft); stroke-width: 1; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: url(#areaGrad); opacity: .5; }
.chart .dot { fill: var(--accent); }
.chart-empty { padding: 26px 0; text-align: center; color: var(--txt-faint); font-size: 13px; }
.legend { display: flex; gap: 14px; font-size: 11.5px; color: var(--txt-dim); margin-top: 4px; }

/* toast */
.toast { position: fixed; bottom: calc(var(--nav-h) + var(--safe-b) + 14px); left: 50%; transform: translateX(-50%) translateY(20px); background: var(--bg-elev-2); border: 1px solid var(--line); color: var(--txt); padding: 11px 18px; border-radius: 12px; font-size: 13.5px; font-weight: 600; z-index: 90; opacity: 0; transition: all .25s ease; pointer-events: none; box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.empty { text-align: center; padding: 40px 20px; color: var(--txt-faint); }
.empty svg { width: 46px; height: 46px; opacity: .4; margin-bottom: 12px; }
hr.sep { border: none; border-top: 1px solid var(--line-soft); margin: 16px 0; }
.rest-note { font-size: 12px; color: var(--txt-faint); text-align: center; margin-top: 8px; }
.inline-tip { display: flex; gap: 9px; font-size: 12.5px; color: var(--txt-dim); background: rgba(52,211,153,.06); border: 1px solid rgba(52,211,153,.16); border-radius: 11px; padding: 11px 13px; margin-top: 12px; }
.inline-tip svg { width: 17px; height: 17px; flex: none; color: var(--accent); margin-top: 1px; }
