:root {
  --bg: #070816;
  --ink: #eef0ff;
  --muted: #9aa1d4;
  --faint: #6c73a8;
  --line: rgba(255, 255, 255, .12);
  --glass: rgba(255, 255, 255, .06);
  --glass-strong: rgba(255, 255, 255, .1);
  --blue: #4f8cff;
  --violet: #8a5cff;
  --magenta: #d04dff;
  --mint: #3ee6a8;
  --amber: #ffb84d;
  --red: #ff5c7a;
  --grad: linear-gradient(135deg, #4f8cff 0%, #7a5cff 55%, #c04dff 100%);
  --grad-soft: linear-gradient(135deg, rgba(79, 140, 255, .28), rgba(192, 77, 255, .28));
  --nav-h: 70px;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; line-height: 1.15; letter-spacing: -.02em; }
h1 { font-size: 30px; font-weight: 800; }
h2 { font-size: 19px; font-weight: 700; }
h3 { font-size: 17px; font-weight: 700; }
p { margin: 0; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }

/* ---------- background ---------- */
.bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; background: radial-gradient(120% 70% at 85% -10%, rgba(40, 50, 160, .35), transparent 60%), var(--bg); }
.orb { position: absolute; border-radius: 50%; filter: blur(80px); opacity: .5; will-change: transform; }
.o1 { width: 340px; height: 340px; background: #2f66ff; top: -90px; left: -110px; animation: drift1 26s ease-in-out infinite alternate; }
.o2 { width: 320px; height: 320px; background: #8a3dff; top: 38%; right: -140px; animation: drift2 31s ease-in-out infinite alternate; }
.o3 { width: 300px; height: 300px; background: #d04dff; bottom: -110px; left: 8%; opacity: .32; animation: drift1 34s ease-in-out infinite alternate-reverse; }
@keyframes drift1 { to { transform: translate(60px, 80px) scale(1.12); } }
@keyframes drift2 { to { transform: translate(-70px, -60px) scale(.92); } }

/* ---------- layout ---------- */
#view {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top)) 16px calc(var(--nav-h) + 34px + env(safe-area-inset-bottom));
}
.top { display: flex; justify-content: space-between; align-items: flex-end; margin: 4px 2px 16px; gap: 12px; }
.eyebrow { color: var(--muted); font-size: 14px; margin-bottom: 4px; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.section-title { margin: 22px 2px 10px; display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }

.glass, .card {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 22px;
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  backdrop-filter: blur(20px) saturate(1.5);
  box-shadow: 0 10px 34px rgba(0, 0, 0, .34), inset 0 1px 0 rgba(255, 255, 255, .09);
}
.card { padding: 16px; }
.card.tight { padding: 12px 14px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: var(--glass-strong); border: 1px solid var(--line); white-space: nowrap;
}
.pill.grad { background: var(--grad); border-color: transparent; }

/* ---------- buttons ---------- */
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--glass-strong);
  padding: 12px 16px; border-radius: 14px; font-weight: 600; min-height: 46px;
  touch-action: manipulation; transition: transform .08s ease, filter .15s ease;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--grad); border-color: transparent; box-shadow: 0 8px 22px rgba(122, 92, 255, .4); }
.btn.ghost { background: transparent; }
.btn.danger { border-color: rgba(255, 92, 122, .5); color: #ff9db0; background: rgba(255, 92, 122, .08); }
.btn.small { min-height: 38px; padding: 8px 12px; font-size: 14px; border-radius: 12px; }
.btn.block { display: block; width: 100%; }
.btn[disabled] { opacity: .5; }
:focus-visible { outline: 2px solid #9ab8ff; outline-offset: 2px; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  appearance: none; border: 1px solid var(--line); background: var(--glass); border-radius: 999px;
  padding: 7px 14px; font-size: 14px; font-weight: 600; min-height: 36px; touch-action: manipulation;
}
.chip.on { background: var(--grad); border-color: transparent; }

/* ---------- mascot ---------- */
.mascot { display: flex; gap: 12px; align-items: center; cursor: pointer; padding: 14px; position: relative; overflow: hidden; }
.mascot::after { content: ""; position: absolute; inset: 0; background: var(--grad-soft); opacity: .55; pointer-events: none; }
.mascot > * { position: relative; z-index: 1; }
.pip { width: 92px; flex: none; animation: bob 3.4s ease-in-out infinite; }
.pip-svg { width: 100%; display: block; overflow: visible; }
.bubble { flex: 1; min-width: 0; }
.bname { font-size: 13px; font-weight: 700; color: #c9d1ff; margin-bottom: 3px; }
.btext { font-size: 16px; line-height: 1.38; font-weight: 550; }
.dots { display: flex; gap: 5px; margin-top: 9px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: rgba(255, 255, 255, .25); }
.dots i.on { background: #fff; width: 16px; border-radius: 4px; }
.eyes { transform-box: fill-box; transform-origin: center; animation: blink 5.5s infinite; }
.spark { transform-box: fill-box; transform-origin: center; animation: twinkle 1.6s ease-in-out infinite; }
.spark.t2 { animation-delay: .5s; } .spark.t3 { animation-delay: 1s; }
.z { animation: floatz 2.6s ease-in-out infinite; } .z2 { animation-delay: 1.3s; }
.sweat { animation: drip 2s ease-in infinite; }
@keyframes bob { 50% { transform: translateY(-5px); } }
@keyframes blink { 0%, 93%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.1); } }
@keyframes twinkle { 50% { transform: scale(.4) rotate(25deg); opacity: .5; } }
@keyframes floatz { 50% { transform: translate(3px, -5px); opacity: .5; } }
@keyframes drip { 70%, 100% { transform: translateY(10px); opacity: 0; } }

/* ---------- shake + weight cards ---------- */
.shake { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; padding: 14px 16px; }
.shake .big { font-weight: 700; font-size: 17px; }
.tickbox {
  width: 46px; height: 46px; border-radius: 15px; flex: none; display: grid; place-items: center;
  border: 2px solid rgba(255, 255, 255, .28); background: rgba(255, 255, 255, .04); transition: all .15s ease;
}
.tickbox svg, .check svg { width: 24px; height: 24px; stroke: #fff; fill: none; stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; opacity: 0; transform: scale(.4); transition: all .18s cubic-bezier(.3, 1.6, .5, 1); }
.shake.on .tickbox { background: var(--grad); border-color: transparent; box-shadow: 0 6px 18px rgba(122, 92, 255, .5); }
.shake.on .tickbox svg, .check.on svg { opacity: 1; transform: scale(1); }

.stepper { display: flex; align-items: center; gap: 10px; }
.step-btn {
  appearance: none; width: 52px; height: 52px; border-radius: 16px; border: 1px solid var(--line);
  background: var(--glass-strong); font-size: 28px; font-weight: 500; line-height: 1; flex: none;
  touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.step-btn:active { background: var(--grad); border-color: transparent; }
.wbox { flex: 1; display: flex; align-items: baseline; justify-content: center; gap: 6px; min-width: 0; }
.wval {
  width: 100%; max-width: 130px; text-align: center; background: transparent; border: 0; border-bottom: 2px solid rgba(255, 255, 255, .15);
  font-size: 34px; font-weight: 800; padding: 0; letter-spacing: -.02em; border-radius: 0;
}
.wval:focus { outline: none; border-bottom-color: var(--blue); }
.unit { color: var(--muted); font-weight: 600; flex: none; }

/* ---------- exercise cards ---------- */
.ex { padding: 16px 14px 14px; }
.ex.complete { border-color: rgba(62, 230, 168, .55); box-shadow: 0 10px 34px rgba(0, 0, 0, .34), 0 0 0 1px rgba(62, 230, 168, .2), inset 0 1px 0 rgba(255, 255, 255, .09); }
.ex-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 2px; }
.ex-name { font-size: 19px; font-weight: 750; }
.ex-target { color: var(--muted); font-weight: 650; white-space: nowrap; }
.ex-last { color: var(--muted); font-size: 13.5px; margin-bottom: 10px; }
.ready {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%;
  margin: 2px 0 12px; padding: 10px 12px; border-radius: 14px; border: 1px solid rgba(62, 230, 168, .5);
  background: rgba(62, 230, 168, .12); color: #b9ffe4; font-weight: 650; font-size: 14.5px; text-align: left;
}
.ready b { color: #fff; white-space: nowrap; }
.nowt { color: var(--amber); font-size: 13px; margin: -4px 0 8px; }
.sets { margin-top: 14px; }
.set { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid rgba(255, 255, 255, .07); }
.set-n { width: 46px; color: var(--muted); font-weight: 650; font-size: 14px; }
.reps { display: flex; align-items: center; gap: 4px; }
.reps button {
  appearance: none; width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--line); background: var(--glass);
  font-size: 22px; line-height: 1; touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
.reps .rv { min-width: 38px; text-align: center; font-size: 20px; font-weight: 750; }
.set-w { flex: 1; text-align: right; color: var(--muted); font-size: 14px; white-space: nowrap; }
.set.done .set-w { color: #fff; font-weight: 650; }
.pr { display: inline-block; margin-left: 6px; padding: 2px 7px; border-radius: 8px; font-size: 11.5px; font-weight: 800; background: linear-gradient(135deg, #ffd45e, #ff8a4d); color: #2a1500; }
.check {
  width: 48px; height: 48px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .28); background: rgba(255, 255, 255, .04);
  display: grid; place-items: center; flex: none; touch-action: manipulation; transition: all .15s ease; padding: 0;
}
.check.on { background: var(--grad); border-color: transparent; box-shadow: 0 6px 18px rgba(122, 92, 255, .5); }
.set-tools { display: flex; gap: 8px; margin-top: 8px; }

.progress { height: 8px; border-radius: 6px; background: rgba(255, 255, 255, .1); overflow: hidden; margin-top: 10px; }
.progress i { display: block; height: 100%; background: var(--grad); border-radius: 6px; transition: width .25s ease; }

select, input[type=text], input[type=number], input[type=time], input[type=password], input[type=search] {
  background: rgba(255, 255, 255, .07); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; min-height: 44px; width: 100%;
  color-scheme: dark;
}
select option { background: #15173a; color: #fff; }
input.num { width: 58px; text-align: center; padding: 8px 4px; }

/* ---------- plan ---------- */
.plan-day { padding: 0; overflow: hidden; }
.plan-day summary { list-style: none; padding: 16px; cursor: pointer; display: flex; align-items: center; gap: 12px; }
.plan-day summary::-webkit-details-marker { display: none; }
.plan-day summary::after { content: ""; width: 9px; height: 9px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); margin-left: auto; transition: transform .2s; flex: none; }
.plan-day[open] summary::after { transform: rotate(-135deg); }
.ps-day { font-weight: 800; width: 40px; }
.ps-name { font-weight: 600; }
.ps-count { color: var(--muted); font-size: 13.5px; }
.plan-body { padding: 0 16px 16px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 5px; border-radius: 14px; background: rgba(0, 0, 0, .25); margin-bottom: 12px; }
.seg button { appearance: none; border: 0; background: transparent; border-radius: 10px; padding: 10px; font-weight: 650; color: var(--muted); }
.seg button.on { background: var(--grad); color: #fff; }
.prow { display: flex; align-items: center; gap: 6px; padding: 8px 0; border-top: 1px solid rgba(255, 255, 255, .07); }
.pname { flex: 1; min-width: 0; font-weight: 600; font-size: 15px; }
.x { color: var(--faint); }
.icon-btn { appearance: none; width: 34px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--glass); font-size: 15px; padding: 0; flex: none; }
.icon-btn.del { color: #ff9db0; }
.icon-btn[disabled] { opacity: .3; }
.field { display: block; margin-top: 10px; }
.field > span { display: block; color: var(--muted); font-size: 13px; margin-bottom: 5px; }

/* ---------- body / stats ---------- */
.verdict { font-size: 17px; font-weight: 600; line-height: 1.4; }
.verdict.good { color: #b9ffe4; }
.verdict.warn { color: #ffd9a0; }
.verdict.bad { color: #ffb3c1; }
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 10px; }
.hist { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-top: 1px solid rgba(255, 255, 255, .07); }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.wd { text-align: center; font-size: 12px; color: var(--muted); }
.wd i { display: grid; place-items: center; width: 100%; aspect-ratio: 1; border-radius: 12px; margin-top: 5px; border: 1px solid var(--line); background: var(--glass); font-style: normal; font-size: 15px; color: #fff; }
.wd.done i { background: var(--grad); border-color: transparent; }
.wd.today i { border: 2px solid #9ab8ff; }
.wd.missed i { background: rgba(255, 92, 122, .14); border-color: rgba(255, 92, 122, .4); color: #ff9db0; }
.wd.rest i { opacity: .45; }
.bignum { font-size: 38px; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ex-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid rgba(255, 255, 255, .07); }
.ex-row:first-child { border-top: 0; }
.badge-up { font-size: 11.5px; font-weight: 800; padding: 3px 8px; border-radius: 8px; background: rgba(62, 230, 168, .18); color: #b9ffe4; border: 1px solid rgba(62, 230, 168, .5); white-space: nowrap; }
.spark-svg { width: 74px; height: 28px; flex: none; }
.empty { text-align: center; padding: 24px 12px; color: var(--muted); }

/* ---------- nav / toast / modal ---------- */
#tabs {
  position: fixed; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 20;
  max-width: 536px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); gap: 2px;
  padding: 6px; border-radius: 24px; background: rgba(16, 18, 52, .68);
}
#tabs button {
  appearance: none; border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 2px 7px; border-radius: 18px; color: var(--faint); font-size: 11.5px; font-weight: 650; touch-action: manipulation;
}
#tabs svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#tabs button.on { color: #fff; background: var(--grad); box-shadow: 0 6px 18px rgba(122, 92, 255, .45); }

#toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); z-index: 40;
  max-width: 520px; margin: 0 auto; padding: 12px 16px; border-radius: 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: rgba(30, 33, 90, .92); border: 1px solid var(--line); font-weight: 600;
  transform: translateY(20px); opacity: 0; pointer-events: none; transition: all .22s ease;
}
#toast.show { transform: none; opacity: 1; pointer-events: auto; }
.toast-btn { appearance: none; border: 0; background: transparent; color: #9ab8ff; font-weight: 800; padding: 6px 8px; }

.modal { position: fixed; inset: 0; z-index: 60; background: rgba(4, 5, 16, .66); display: grid; place-items: center; padding: 18px; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.modal-card { width: 100%; max-width: 420px; padding: 20px; background: rgba(22, 25, 70, .92); }
.modal-card h3 { margin-bottom: 6px; }
.modal-card .row { margin-top: 16px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (min-width: 640px) {
  #view { padding-top: 32px; }
}
