[hidden] { display: none !important; }
:root {
  --bg: #f5f4fb;
  --card: #ffffff;
  --ink: #1b1f3b;
  --muted: #6b6f8e;
  --line: #e6e4f2;
  --primary: #ff5a5f;
  --primary-ink: #ffffff;
  --accent: #ffc93c;
  --navy: #1b1f3b;
  --ok: #00a88f;
  --radius: 18px;
  --shadow: 0 6px 20px rgba(27, 31, 59, .08);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10122a;
    --card: #1b1f3b;
    --ink: #f3f2fb;
    --muted: #a9acc9;
    --line: #2c315a;
    --shadow: 0 6px 20px rgba(0,0,0,.3);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
main { max-width: 640px; margin: 0 auto; padding: 16px 16px calc(110px + var(--safe-b)); }
h1, h2, h3 { margin: 0 0 8px; line-height: 1.2; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; margin-top: 24px; }
p { line-height: 1.5; }
a { color: inherit; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* --- Hero --- */
.hero {
  background: linear-gradient(135deg, var(--navy), #3a2f7a 60%, var(--primary));
  color: #fff; border-radius: 24px; padding: 20px; margin: 0 -4px 16px;
  box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.hero::after {
  content: "🏐"; position: absolute; right: -10px; top: -14px; font-size: 6rem; opacity: .15; transform: rotate(20deg);
}
.hero .quote { font-size: .95rem; opacity: .9; margin: 8px 0 0; font-style: italic; }
.mode-pill { display: inline-block; font-size: .72rem; background: rgba(255,255,255,.18); padding: 3px 9px; border-radius: 99px; margin-bottom: 8px; }

/* --- Cards --- */
.card {
  background: var(--card); border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow); margin-bottom: 12px; border: 1px solid var(--line);
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat { text-align: center; }
.stat .big { font-size: 1.9rem; font-weight: 800; }
.stat .lbl { font-size: .8rem; color: var(--muted); }

.progress { height: 14px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 10px 0 6px; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); border-radius: 99px; transition: width .8s ease; }

.ring { --p: 0; width: 84px; height: 84px; border-radius: 50%; margin: 0 auto 6px;
  background: conic-gradient(var(--primary) calc(var(--p) * 1%), var(--line) 0);
  display: grid; place-items: center; }
.ring > span { width: 64px; height: 64px; border-radius: 50%; background: var(--card); display: grid; place-items: center; font-weight: 800; font-size: 1.15rem; }

/* --- Workout cards --- */
.wcard { display: flex; gap: 14px; align-items: center; text-decoration: none; }
.wcard .icon { flex: 0 0 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; font-size: 1.7rem; }
.wcard .t { font-weight: 700; margin-bottom: 4px; }
.wcard .meta { font-size: .82rem; color: var(--muted); }
.wcard .done-badge { margin-left: auto; font-size: .75rem; background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); padding: 3px 8px; border-radius: 99px; white-space: nowrap; font-weight: 600; }
.featured { border: 2px solid var(--accent); }
.featured .tag { font-size: .72rem; font-weight: 700; color: #a87700; text-transform: uppercase; letter-spacing: .05em; }
@media (prefers-color-scheme: dark) { .featured .tag { color: var(--accent); } }
.level { letter-spacing: 1px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: 8px 14px; border-radius: 99px; white-space: nowrap; font-size: .9rem; cursor: pointer; }
.chip.on { background: var(--navy); color: #fff; border-color: var(--navy); }
@media (prefers-color-scheme: dark) { .chip.on { background: var(--primary); border-color: var(--primary); } }

/* --- Detail --- */
.detail-head { border-radius: 24px; padding: 20px; color: #fff; margin: 0 -4px 14px; }
.detail-head .back { color: #fff; text-decoration: none; opacity: .9; font-size: .9rem; }
.facts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.facts span { background: rgba(255,255,255,.2); padding: 5px 10px; border-radius: 99px; font-size: .85rem; }
.video { position: relative; aspect-ratio: 16/9; border-radius: var(--radius); overflow: hidden; background: #000; margin-bottom: 12px; }
.video img, .video iframe { width: 100%; height: 100%; object-fit: cover; border: 0; display: block; }
.video button { position: absolute; inset: 0; background: rgba(0,0,0,.25); border: 0; cursor: pointer; display: grid; place-items: center; }
.video button span { width: 72px; height: 72px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 1.8rem; display: grid; place-items: center; box-shadow: 0 6px 20px rgba(0,0,0,.4); }
.video .placeholder { color: #fff; display: grid; place-items: center; height: 100%; text-align: center; padding: 20px; background: linear-gradient(135deg, #2c315a, #1b1f3b); }
.why { border-left: 4px solid var(--accent); }
.mini { border-left: 4px solid var(--ok); }

/* --- Buttons & Forms --- */
.btn { appearance: none; border: 0; border-radius: 14px; padding: 14px 18px; font-size: 1rem; font-weight: 700; cursor: pointer; font-family: inherit; }
.btn.primary { background: var(--primary); color: var(--primary-ink); box-shadow: 0 6px 16px color-mix(in srgb, var(--primary) 40%, transparent); }
.btn.secondary { background: var(--navy); color: #fff; }
.btn.ghost { background: transparent; color: inherit; border: 1px solid var(--line); }
.btn.block { width: 100%; display: block; }
.btn.small { padding: 8px 12px; font-size: .88rem; border-radius: 10px; }
.btn:active { transform: scale(.98); }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
label { display: block; font-weight: 600; margin: 14px 0 6px; }
input[type=text], input[type=password], input[type=number] {
  width: 100%; padding: 14px; font-size: 1rem; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font-family: inherit;
}
.picker { display: flex; flex-wrap: wrap; gap: 8px; }
.picker button { font-size: 1.5rem; width: 52px; height: 52px; border-radius: 14px; border: 2px solid var(--line); background: var(--card); cursor: pointer; }
.picker button.on { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 12%, var(--card)); }
.picker.num button { font-size: 1.1rem; font-weight: 700; color: var(--ink); }

/* --- Feed --- */
.feed { list-style: none; padding: 0; margin: 0; }
.feed li { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.feed li:last-child { border-bottom: 0; }
.feed .av { width: 36px; height: 36px; border-radius: 50%; background: var(--bg); display: grid; place-items: center; font-size: 1.2rem; flex: 0 0 36px; }
.feed .txt { font-size: .92rem; }

/* --- Badges --- */
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.badge { text-align: center; padding: 12px 6px; border-radius: 14px; background: var(--bg); }
.badge .e { font-size: 2rem; }
.badge .n { font-size: .78rem; font-weight: 700; margin-top: 4px; }
.badge.locked { opacity: .35; filter: grayscale(1); }

/* --- Tab bar --- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; display: flex; justify-content: space-around;
  background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line); padding: 6px 0 calc(6px + var(--safe-b)); z-index: 20;
}
.tabbar a { text-decoration: none; display: flex; flex-direction: column; align-items: center; font-size: .72rem; color: var(--muted); padding: 4px 12px; border-radius: 12px; }
.tabbar a span { font-size: 1.35rem; }
.tabbar a.on { color: var(--primary); font-weight: 700; }

.timerbar {
  position: fixed; left: 12px; right: 12px; bottom: calc(72px + var(--safe-b)); z-index: 25;
  max-width: 616px; margin: 0 auto; background: var(--navy); color: #fff; border-radius: 16px; padding: 12px 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.3);
}
.timerbar #timer-name { opacity: .8; font-size: .85rem; }
.timer-label { font-size: .8rem; opacity: .7; }
.timer-actions { display: flex; gap: 6px; flex-shrink: 0; }
.timerbar .btn.ghost { color: #fff; border-color: rgba(255,255,255,.3); }

/* --- Modal --- */
.modal { position: fixed; inset: 0; background: rgba(16,18,42,.6); z-index: 50; display: grid; place-items: end center; padding: 12px; }
.modal[hidden] { display: none; }
.sheet { background: var(--card); border-radius: 24px; padding: 22px; width: 100%; max-width: 520px; animation: up .25s ease; margin-bottom: var(--safe-b); max-height: 90vh; overflow: auto; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.feel { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 12px 0; }
.feel button { border: 2px solid var(--line); background: var(--card); color: var(--ink); border-radius: 14px; padding: 10px 2px; cursor: pointer; font-family: inherit; }
.feel button .e { font-size: 1.8rem; display: block; }
.feel button small { font-size: .72rem; }
.feel button.on { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 12%, var(--card)); }
.check { display: flex; gap: 10px; align-items: center; font-weight: 500; }
.check input { width: 22px; height: 22px; accent-color: var(--ok); }
.celebrate { text-align: center; }
.celebrate .e { font-size: 4rem; }
.newbadge { display: flex; gap: 12px; align-items: center; background: var(--bg); border-radius: 14px; padding: 10px 12px; margin-top: 8px; text-align: left; }
.newbadge .e { font-size: 2rem; }

#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; width: 100%; height: 100%; }

/* --- Trainer --- */
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { text-align: left; padding: 9px 6px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: .78rem; }
td.num, th.num { text-align: right; }
.table-wrap { overflow-x: auto; }
.warn { color: #d9480f; }
.notice { background: color-mix(in srgb, var(--accent) 25%, var(--card)); border-radius: 14px; padding: 12px; font-size: .88rem; margin-bottom: 12px; }
.res { display: block; text-decoration: none; }
.res .t { font-weight: 700; }
.res .u { font-size: .78rem; color: var(--muted); word-break: break-all; }
.plan { display: flex; gap: 10px; align-items: center; }
body.timing main { padding-bottom: calc(190px + var(--safe-b)); }
