:root {
  --bg: #0a0a0a;
  --surface: #151515;
  --surface-2: #1e1e1e;
  --line: #2a2a2a;
  --text: #f4f4f4;
  --muted: #8a8a8a;
  --muted-2: #5e5e5e;
  --accent: #fab700;
  --accent-dim: #6b5200;
  --good: #46d17a;
  --danger: #ff5a5a;
  --radius: 16px;
  --tabbar-h: 64px;
  --topbar-h: 52px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); overscroll-behavior-y: none; }
body { font-size: 16px; line-height: 1.4; }

#app { min-height: 100vh; }

/* Top bar */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; height: calc(var(--topbar-h) + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  display: grid; grid-template-columns: 64px 1fr 64px; align-items: center;
  background: rgba(10,10,10,0.8); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line); z-index: 50;
}
#topbar-title { text-align: center; font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }
#topbar-left, #topbar-right { display: flex; align-items: center; padding: 0 12px; }
#topbar-left { justify-content: flex-start; }
#topbar-right { justify-content: flex-end; }
.topbtn { background: none; border: none; color: var(--accent); font-size: 15px; font-weight: 600; padding: 8px 0; cursor: pointer; }
.backbtn { background: none; border: none; color: var(--accent); font-size: 16px; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 2px; }

/* View area */
#view {
  padding: calc(var(--topbar-h) + env(safe-area-inset-top) + 12px) 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 24px);
  max-width: 640px; margin: 0 auto;
}

/* Tab bar */
#tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex; background: rgba(10,10,10,0.9); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--line); z-index: 50;
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  background: none; border: none; color: var(--muted-2); cursor: pointer; padding: 8px 0;
}
.tab.active { color: var(--accent); }
.tab-ico { font-size: 20px; line-height: 1; }
.tab-label { font-size: 10px; font-weight: 600; letter-spacing: 0.02em; }

/* Cards + layout */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.card-tap { cursor: pointer; transition: transform .08s ease, background .15s ease; }
.card-tap:active { transform: scale(0.985); background: var(--surface-2); }

.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.h1 { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; margin: 4px 0 2px; }
.h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 10px; }
.sub { color: var(--muted); font-size: 14px; }
.section-label { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin: 22px 4px 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.accent { color: var(--accent); }
.muted { color: var(--muted); }
.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.pill.accent { background: var(--accent-dim); color: var(--accent); }
.pill.good { background: rgba(70,209,122,0.15); color: var(--good); }

/* Buttons */
.btn {
  display: block; width: 100%; text-align: center; border: none; border-radius: 14px;
  padding: 16px; font-size: 16px; font-weight: 700; cursor: pointer; margin-top: 8px;
}
.btn-primary { background: var(--accent); color: #1a1300; }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.btn-ghost { background: none; color: var(--accent); }
.btn-danger { background: none; color: var(--danger); border: 1px solid var(--line); }
.btn:active { opacity: 0.85; }

/* Today hero */
.hero { background: linear-gradient(160deg, #1c1a10, #121212); border: 1px solid var(--line); }
.hero .h1 { font-size: 32px; }

/* Exercise list */
.ex-item { display: flex; align-items: center; gap: 14px; padding: 14px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.ex-item:last-child { border-bottom: none; }
.ex-check { width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--line); flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 15px; color: var(--bg); }
.ex-check.done { background: var(--good); border-color: var(--good); }
.ex-main { flex: 1; min-width: 0; }
.ex-name { font-weight: 600; font-size: 16px; }
.ex-meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.ex-last { font-size: 13px; color: var(--accent); font-weight: 600; white-space: nowrap; }
.chev { color: var(--muted-2); font-size: 18px; }

/* Set logger */
.set-row { display: grid; grid-template-columns: 38px 1fr 1fr 48px; align-items: center; gap: 10px; padding: 8px 0; }
.set-row.head { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.set-no { color: var(--muted); font-weight: 700; text-align: center; }
.set-input {
  width: 100%; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
  color: var(--text); font-size: 18px; font-weight: 700; text-align: center; padding: 12px 4px;
  -moz-appearance: textfield;
}
.set-input::-webkit-outer-spin-button, .set-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.set-input:focus { outline: none; border-color: var(--accent); }
.set-input.ghost::placeholder { color: var(--muted-2); font-weight: 600; }
.set-done {
  width: 40px; height: 40px; border-radius: 10px; border: 2px solid var(--line); background: var(--surface-2);
  color: var(--muted-2); font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.set-done.on { background: var(--good); border-color: var(--good); color: #07210f; }

.unit-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.unit-toggle button { background: var(--surface); color: var(--muted); border: none; padding: 8px 14px; font-weight: 700; font-size: 13px; cursor: pointer; }
.unit-toggle button.on { background: var(--accent); color: #1a1300; }

/* Stats grid */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat { background: var(--surface-2); border-radius: 12px; padding: 14px; }
.stat-val { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.04em; }

/* Macro bars */
.macro { margin-bottom: 12px; }
.macro-top { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 6px; }
.macro-name { font-weight: 600; }
.macro-val { color: var(--muted); font-weight: 600; }
.macro-track { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.macro-fill { height: 100%; border-radius: 999px; }

/* Meals */
.meal { padding: 12px 0; border-bottom: 1px solid var(--line); }
.meal:last-child { border-bottom: none; }
.meal-name { font-weight: 700; font-size: 15px; margin-bottom: 6px; }
.meal-time { font-weight: 600; font-size: 12px; color: var(--muted-2); margin-left: 4px; }
.meal-items { margin: 0; padding-left: 18px; color: var(--muted); font-size: 14px; }
.meal-items li { margin: 3px 0; }
.supps { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.supp { font-size: 11px; font-weight: 600; padding: 4px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }

/* Block headers (superset / tabata) */
.block-head { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.block-tag { font-weight: 700; letter-spacing: 0.02em; text-transform: none; color: var(--muted-2); }
.tabata-card { border-style: dashed; }
.tabata-card .block-head { color: var(--accent); }
.cardio-card { border-color: var(--accent-dim); background: linear-gradient(160deg, #1c1a10, #141414); }
.cardio-card .block-head { margin-bottom: 4px; }
.tab-item { display: flex; align-items: center; gap: 14px; padding: 12px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.tab-item:last-child { border-bottom: none; }

/* Mini chart */
.spark { width: 100%; height: 90px; display: block; }
.hist-row { display: flex; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.hist-row:last-child { border-bottom: none; }
.hist-date { color: var(--muted); }
.hist-top { font-weight: 700; }

/* Misc */
.empty { text-align: center; color: var(--muted); padding: 48px 16px; }
.empty-ico { font-size: 40px; margin-bottom: 8px; opacity: 0.5; }
.list-link { display: flex; align-items: center; justify-content: space-between; padding: 16px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.list-link:last-child { border-bottom: none; }
.day-tabs { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 12px; -webkit-overflow-scrolling: touch; }
.day-tab { flex: 0 0 auto; padding: 10px 16px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); color: var(--muted); font-weight: 700; font-size: 14px; cursor: pointer; text-align: center; line-height: 1.25; }
.day-tab.active { background: var(--accent); color: #1a1300; border-color: var(--accent); }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text); padding: 12px 18px; border-radius: 12px;
  font-weight: 600; font-size: 14px; z-index: 100; opacity: 0; transition: opacity .2s; pointer-events: none; box-shadow: 0 8px 30px rgba(0,0,0,0.5);
}
.toast.show { opacity: 1; }
.fade-in { animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
