:root {
  --bg: #07060d;
  --bg2: #0d0b18;
  --card: #141126;
  --card2: #1b1733;
  --line: rgba(255, 255, 255, 0.08);
  --text: #f5f3ff;
  --muted: #9b95bb;
  --dim: #6c6690;
  --cyan: #2ef2ff;
  --violet: #b14cff;
  --pink: #ff3cac;
  --lime: #c6ff3d;
  --amber: #ffb627;
  --red: #ff4d6d;
  --grad: linear-gradient(135deg, #2ef2ff 0%, #b14cff 52%, #ff3cac 100%);
  --grad-soft: linear-gradient(135deg, rgba(46, 242, 255, .16), rgba(177, 76, 255, .16) 52%, rgba(255, 60, 172, .16));
  --glow: 0 0 24px rgba(177, 76, 255, .45), 0 0 60px rgba(46, 242, 255, .12);
  --radius: 20px;
  --display: "Unbounded", "Space Grotesk", system-ui, sans-serif;
  --body: "Space Grotesk", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--body); }
body {
  min-height: 100dvh;
  background:
    radial-gradient(900px 500px at 110% -10%, rgba(177, 76, 255, .20), transparent 60%),
    radial-gradient(700px 420px at -20% 20%, rgba(46, 242, 255, .10), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  font-size: 15px;
  line-height: 1.45;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--cyan); }
h1, h2, h3 { font-family: var(--display); letter-spacing: -.01em; margin: 0 0 .4em; }
h1 { font-size: 26px; }
h2 { font-size: 19px; }
h3 { font-size: 15px; }
.muted { color: var(--muted); }
.dim { color: var(--dim); font-size: 13px; }
.grad-text { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hidden { display: none !important; }

/* ---------- layout ---------- */
#app { max-width: 560px; margin: 0 auto; padding: 0 16px calc(96px + env(safe-area-inset-bottom)); }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px; margin: 0 -16px 8px;
  background: rgba(7, 6, 13, .78); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.logo { font-family: var(--display); font-weight: 800; font-size: 18px; display: flex; gap: 8px; align-items: center; }
.logo svg { width: 26px; height: 26px; filter: drop-shadow(0 0 8px rgba(177, 76, 255, .7)); }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--grad); color: #0b0716;
  font-weight: 800; cursor: pointer; box-shadow: var(--glow);
}

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: center; padding: 8px 10px calc(10px + env(safe-area-inset-bottom));
  background: rgba(10, 8, 20, .9); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
.tabs .wrap { display: flex; width: 100%; max-width: 560px; justify-content: space-around; align-items: end; }
.tab {
  background: none; border: 0; color: var(--dim); display: flex; flex-direction: column; align-items: center;
  gap: 3px; font-size: 11px; font-weight: 600; padding: 4px 8px; cursor: pointer; min-width: 58px;
}
.tab svg { width: 24px; height: 24px; }
.tab.on { color: var(--text); }
.tab.on svg { color: var(--cyan); filter: drop-shadow(0 0 6px rgba(46, 242, 255, .8)); }
.tab.coach .bubble {
  width: 54px; height: 54px; margin-top: -26px; border-radius: 18px; display: grid; place-items: center;
  background: var(--grad); color: #0b0716; box-shadow: var(--glow); transform: rotate(-6deg);
}
.tab.coach .bubble svg { width: 28px; height: 28px; color: #0b0716; filter: none; transform: rotate(6deg); }

/* ---------- cards ---------- */
.card {
  background: linear-gradient(180deg, var(--card), var(--bg2));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 12px 0;
}
.card.glow { border: 1px solid transparent; background:
  linear-gradient(180deg, var(--card), var(--bg2)) padding-box, var(--grad) border-box; box-shadow: var(--glow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }

.stat { background: var(--card2); border: 1px solid var(--line); border-radius: 16px; padding: 12px; }
.stat b { display: block; font-family: var(--display); font-size: 20px; }
.stat span { color: var(--muted); font-size: 12px; }

.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px; font-size: 12px;
  font-weight: 700; background: var(--card2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.pill.easy { color: var(--cyan); border-color: rgba(46, 242, 255, .35); }
.pill.moderate { color: var(--lime); border-color: rgba(198, 255, 61, .35); }
.pill.hard { color: var(--amber); border-color: rgba(255, 182, 39, .4); }
.pill.very_hard { color: var(--pink); border-color: rgba(255, 60, 172, .45); }
.pill.rest { color: var(--dim); }
.pill.done { color: #0b0716; background: var(--lime); border-color: var(--lime); }
.pill.skipped { color: var(--red); border-color: rgba(255, 77, 109, .4); }
.pill.partial { color: var(--amber); }
.pill.adj { color: var(--violet); border-color: rgba(177, 76, 255, .5); }

/* ---------- buttons + forms ---------- */
.btn {
  border: 0; border-radius: 14px; padding: 13px 18px; font-weight: 700; cursor: pointer; display: inline-flex;
  align-items: center; justify-content: center; gap: 8px; background: var(--card2); color: var(--text);
  border: 1px solid var(--line); transition: transform .08s ease, box-shadow .2s ease;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--grad); color: #0b0716; border: 0; box-shadow: var(--glow); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); border-color: rgba(255, 77, 109, .4); background: transparent; }
.btn.block { width: 100%; }
.btn.sm { padding: 8px 12px; font-size: 13px; border-radius: 11px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

label.f { display: block; margin: 12px 0 0; font-size: 13px; color: var(--muted); font-weight: 600; }
.input, select.input, textarea.input {
  width: 100%; margin-top: 6px; padding: 12px 14px; border-radius: 14px; background: #0b0a16;
  border: 1px solid var(--line); outline: none; font-size: 16px;
}
.input:focus { border-color: var(--violet); box-shadow: 0 0 0 3px rgba(177, 76, 255, .25); }
textarea.input { min-height: 80px; resize: vertical; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chip {
  padding: 9px 13px; border-radius: 99px; background: #0b0a16; border: 1px solid var(--line); cursor: pointer;
  font-weight: 600; font-size: 14px; color: var(--muted);
}
.chip.on { color: #0b0716; background: var(--grad); border-color: transparent; box-shadow: 0 0 16px rgba(177, 76, 255, .4); }
.check { display: flex; gap: 10px; align-items: flex-start; margin-top: 14px; font-size: 14px; color: var(--muted); }
.check input { width: 20px; height: 20px; accent-color: var(--violet); flex: none; margin-top: 1px; }
.yn { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 0;
  border-bottom: 1px solid var(--line); font-size: 14px; }
.yn .chips { margin: 0; flex: none; }
.range { width: 100%; accent-color: var(--violet); margin-top: 10px; }
.lang { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 12px; background: #0b0a16; border: 1px solid var(--line); font-size: 14px; }
.logo { white-space: nowrap; }
.topbar .lang select { max-width: 110px; }
.lang select { background: transparent; border: 0; outline: none; font-size: 16px; font-weight: 600; color: var(--text); max-width: 190px; }
.lang select option { background: var(--bg2); }
.err { color: var(--red); font-size: 14px; margin-top: 10px; min-height: 1em; }

/* ---------- auth / landing ---------- */
.hero { padding: 40px 0 10px; text-align: center; }
.hero .big { font-family: var(--display); font-size: 44px; line-height: 1; font-weight: 900; letter-spacing: -.03em; }
.hero p { color: var(--muted); font-size: 16px; margin: 14px auto 0; max-width: 360px; }
.hero .badges { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
.seg { display: flex; background: #0b0a16; border: 1px solid var(--line); border-radius: 14px; padding: 4px; margin-bottom: 8px; }
.seg button { flex: 1; border: 0; background: none; padding: 10px; border-radius: 10px; font-weight: 700; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--card2); color: var(--text); }

/* ---------- wizard ---------- */
.progress-dots { display: flex; gap: 6px; margin: 8px 0 16px; }
.progress-dots i { flex: 1; height: 4px; border-radius: 4px; background: var(--card2); }
.progress-dots i.on { background: var(--grad); box-shadow: 0 0 10px rgba(177, 76, 255, .6); }
.wiz-nav { display: flex; gap: 10px; margin-top: 20px; }
.wiz-nav .btn { flex: 1; }

/* ---------- workout ---------- */
.w-title { font-family: var(--display); font-size: 21px; line-height: 1.15; margin: 4px 0 8px; }
.meta { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 10px; }
.target { padding: 10px 12px; border-radius: 14px; background: var(--grad-soft); border: 1px solid rgba(177, 76, 255, .3); font-weight: 600; }
.steps { list-style: none; padding: 0; margin: 12px 0 0; }
.steps li { display: grid; grid-template-columns: 10px 1fr auto; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.steps li .dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; background: var(--violet); box-shadow: 0 0 8px var(--violet); }
.steps li.warmup .dot { background: var(--cyan); box-shadow: 0 0 8px var(--cyan); }
.steps li.cooldown .dot { background: #7ab8ff; box-shadow: 0 0 8px #7ab8ff; }
.steps li.interval .dot { background: var(--pink); box-shadow: 0 0 8px var(--pink); }
.steps li.strength .dot { background: var(--lime); box-shadow: 0 0 8px var(--lime); }
.steps .nm { font-weight: 700; }
.steps .tg { color: var(--muted); font-size: 13px; }
.steps .dur { font-family: var(--display); font-size: 13px; color: var(--text); white-space: nowrap; }
.why { margin-top: 12px; color: var(--muted); font-size: 14px; }
.why b { color: var(--text); }

/* ---------- agents pipeline ---------- */
.pipe { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; align-items: center; gap: 6px; margin: 12px 0 6px; }
.agent { text-align: center; padding: 10px 4px; border-radius: 14px; background: #0b0a16; border: 1px solid var(--line); font-size: 12px; font-weight: 700; color: var(--dim); }
.agent .ic { font-size: 20px; display: block; margin-bottom: 2px; filter: grayscale(1); opacity: .6; }
.agent.on { color: var(--text); border-color: var(--violet); box-shadow: 0 0 18px rgba(177, 76, 255, .5); animation: pulse 1.4s ease-in-out infinite; }
.agent.on .ic, .agent.ok .ic { filter: none; opacity: 1; }
.agent.ok { color: var(--lime); border-color: rgba(198, 255, 61, .35); }
.pipe .arrow { color: var(--dim); }
@keyframes pulse { 50% { box-shadow: 0 0 28px rgba(46, 242, 255, .55); } }
.bar { height: 6px; border-radius: 6px; background: var(--card2); overflow: hidden; margin-top: 10px; }
.bar i { display: block; height: 100%; background: var(--grad); width: 30%; animation: slide 1.6s ease-in-out infinite; }
@keyframes slide { 0% { margin-left: -30%; } 100% { margin-left: 100%; } }

/* ---------- plan week ---------- */
.weektabs { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 8px; scrollbar-width: none; }
.weektabs::-webkit-scrollbar { display: none; }
.day {
  display: grid; grid-template-columns: 52px 1fr auto; gap: 12px; align-items: center; padding: 12px;
  border-radius: 16px; background: var(--card); border: 1px solid var(--line); margin: 8px 0; cursor: pointer;
}
.day.today { border-color: var(--cyan); box-shadow: 0 0 16px rgba(46, 242, 255, .3); }
.day .dd { text-align: center; }
.day .dd b { display: block; font-family: var(--display); font-size: 18px; }
.day .dd span { font-size: 11px; color: var(--muted); text-transform: uppercase; font-weight: 700; }
.day .tt { font-weight: 700; }
.day.rest .tt { color: var(--muted); }

/* ---------- meals ---------- */
.meal { padding: 12px 0; border-top: 1px solid var(--line); }
.meal:first-of-type { border-top: 0; }
.meal .top { display: flex; justify-content: space-between; gap: 10px; }
.meal .slot { font-size: 12px; color: var(--cyan); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.meal .nm { font-weight: 700; font-size: 16px; }
.macros { display: flex; gap: 10px; font-size: 12px; color: var(--muted); margin-top: 4px; flex-wrap: wrap; }
.macros b { color: var(--text); }
details { margin-top: 8px; }
details summary { cursor: pointer; color: var(--violet); font-weight: 700; font-size: 13px; list-style: none; }
details summary::-webkit-details-marker { display: none; }
details ul { margin: 8px 0; padding-left: 18px; color: var(--muted); font-size: 14px; }
.groc label { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.groc input { width: 18px; height: 18px; accent-color: var(--lime); }
.groc input:checked + span { text-decoration: line-through; color: var(--dim); }

.ringrow { display: flex; gap: 14px; align-items: center; }
.ring { width: 76px; height: 76px; flex: none; }
.ring circle { fill: none; stroke-width: 9; }
.ring .bg { stroke: var(--card2); }
.ring .fg { stroke: url(#rg); stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%; }

/* ---------- chat ---------- */
.chat { display: flex; flex-direction: column; gap: 10px; padding-bottom: 130px; }
.msg { max-width: 86%; padding: 10px 14px; border-radius: 18px; white-space: normal; word-wrap: break-word; font-size: 15px; }
.msg.user { align-self: flex-end; background: var(--grad); color: #0b0716; border-bottom-right-radius: 6px; font-weight: 600; }
.msg.assistant { align-self: flex-start; background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.msg ul { margin: 6px 0; padding-left: 18px; }
.msg p { margin: 0 0 6px; }
.msg p:last-child { margin: 0; }
.act { align-self: flex-start; font-size: 12px; color: var(--lime); margin-top: -4px; }
.composer {
  position: fixed; left: 0; right: 0; bottom: calc(74px + env(safe-area-inset-bottom)); z-index: 25;
  padding: 8px 16px; background: linear-gradient(180deg, transparent, rgba(7, 6, 13, .95) 30%);
}
.composer.solo { bottom: 0; padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
.composer .in { max-width: 528px; margin: 0 auto; display: flex; gap: 8px; }
.composer textarea { flex: 1; min-height: 48px; max-height: 120px; margin: 0; resize: none; }
.composer .btn { width: 52px; padding: 0; }
.sugg { display: flex; gap: 8px; overflow-x: auto; max-width: 528px; margin: 0 auto 8px; scrollbar-width: none; }
.sugg::-webkit-scrollbar { display: none; }
.sugg .chip { white-space: nowrap; font-size: 13px; padding: 7px 12px; }
.typing span { display: inline-block; width: 7px; height: 7px; margin: 0 2px; border-radius: 50%; background: var(--violet); animation: bob 1s infinite; }
.typing span:nth-child(2) { animation-delay: .15s; background: var(--cyan); }
.typing span:nth-child(3) { animation-delay: .3s; background: var(--pink); }
@keyframes bob { 50% { transform: translateY(-5px); } }

/* ---------- sheet / overlay ---------- */
.sheet-bg { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .6); backdrop-filter: blur(4px); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-width: 560px; max-height: 90dvh; overflow-y: auto; background: var(--bg2);
  border: 1px solid var(--line); border-bottom: 0; border-radius: 24px 24px 0 0;
  padding: 10px 16px calc(24px + env(safe-area-inset-bottom)); animation: up .22s ease;
}
.sheet .grab { width: 44px; height: 5px; border-radius: 5px; background: var(--card2); margin: 0 auto 12px; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }

.player { position: fixed; inset: 0; z-index: 60; background: var(--bg); display: flex; flex-direction: column; padding: calc(16px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom)); }
.player .inner { max-width: 560px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; height: 100%; }
.player .stage { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.player .kind { font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--cyan); }
.player .sname { font-family: var(--display); font-size: 28px; margin: 6px 0 4px; }
.player .clock { position: relative; width: min(72vw, 290px); aspect-ratio: 1; margin: 18px 0; }
.player .clock svg { width: 100%; height: 100%; }
.player .clock .t { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--display); font-size: 54px; font-weight: 800; }
.player .clock .t small { display: block; font-size: 14px; color: var(--muted); font-family: var(--body); font-weight: 600; }
.player .ptarget { font-weight: 700; font-size: 17px; }
.player .cue { color: var(--muted); margin-top: 6px; }
.player .next { color: var(--dim); font-size: 13px; margin-top: 14px; }
.player .ctrl { display: flex; gap: 12px; justify-content: center; }
.player .ctrl .btn { min-width: 64px; }
.player.resting .kind { color: var(--lime); }

.toast { position: fixed; left: 50%; top: calc(14px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 90;
  background: var(--card2); border: 1px solid var(--violet); padding: 10px 16px; border-radius: 14px; box-shadow: var(--glow); font-weight: 600; max-width: 90vw; }

table.z { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 8px; }
table.z td { padding: 7px 4px; border-top: 1px solid var(--line); }
table.z td:last-child { text-align: right; font-family: var(--display); font-size: 13px; }
.zdot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }

.chart { width: 100%; height: 180px; margin-top: 8px; }
.empty { text-align: center; padding: 26px 10px; }
.empty .em { font-size: 40px; }
.warn { border-color: rgba(255, 182, 39, .5); background: linear-gradient(180deg, rgba(255, 182, 39, .08), var(--bg2)); }
.src { font-size: 13px; color: var(--muted); padding: 6px 0; border-top: 1px solid var(--line); }
.src a { word-break: break-word; }
.timer-presets { display: flex; gap: 8px; flex-wrap: wrap; }

@media (max-width: 380px) {
  .grid4 { grid-template-columns: 1fr 1fr; }
  .hero .big { font-size: 36px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
