:root {
  --a: #0E78AE;
  --b: #0F8460;
  --grad: linear-gradient(135deg, var(--a) 0%, var(--b) 100%);
  --ink: #12313A;
  --muted: #4E6670;
  --line: rgba(18, 49, 58, 0.1);
  --glass: rgba(255, 255, 255, 0.66);
  --glass-strong: rgba(255, 255, 255, 0.82);
  --glass-border: rgba(255, 255, 255, 0.9);
  --soft: rgba(15, 132, 96, 0.14);
  --soft-blue: rgba(14, 120, 174, 0.12);
  --warn-bg: #FFF1E3;
  --warn: #8F4210;
  --danger: #B42318;
  --ok: #127A55;
  --wa: #1A8F4E;
  --shadow: 0 8px 24px rgba(18, 60, 80, 0.07);
  --radius: 22px;
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: 'Heebo', system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: linear-gradient(165deg, #DDF1FB 0%, #E6F7F0 55%, #F3FBF8 100%) fixed;
  -webkit-font-smoothing: antialiased;
}
body::before, body::after {
  content: ""; position: fixed; z-index: -1; border-radius: 50%; pointer-events: none;
  filter: blur(60px); opacity: 0.45;
}
body::before { width: 320px; height: 320px; top: -100px; left: -90px; background: var(--a); }
body::after { width: 340px; height: 340px; bottom: -120px; right: -120px; background: var(--b); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: #0E6E9E; }
.app { max-width: 520px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
main { flex: 1; padding: 20px 16px 120px; display: flex; flex-direction: column; gap: 18px; }

/* logo */
.logo { display: inline-flex; align-items: center; gap: 8px; direction: ltr; font-family: 'Jost', 'Heebo', sans-serif; font-weight: 400; letter-spacing: 0.3em; font-size: 13px; color: var(--ink); }
.logo.big { font-size: 26px; font-weight: 300; gap: 16px; letter-spacing: 0.3em; }
.logo svg { flex: none; }

/* type */
h1 { margin: 0; font-size: 26px; font-weight: 800; letter-spacing: -0.01em; }
h2 { margin: 0; font-size: 18px; font-weight: 700; }
h3 { margin: 0; font-size: 16px; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.xs { font-size: 12px; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 10px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.grow { flex: 1; min-width: 0; }
.hidden { display: none !important; }

/* surfaces */
.card {
  background: var(--glass); border: 1px solid var(--glass-border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
}
.card.tight { padding: 12px 14px; }
.hero { background: var(--grad); color: #fff; border-radius: 26px; padding: 20px; box-shadow: 0 14px 30px rgba(14, 120, 174, 0.28); display: flex; flex-direction: column; gap: 10px; }
.hero .muted { color: rgba(255,255,255,0.9); }
.stat { display: flex; flex-direction: column; gap: 3px; }
.stat b { font-size: 24px; font-weight: 800; }
.list > * + * { border-top: 1px solid var(--line); }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px; border-radius: 16px; border: 1px solid var(--glass-border);
  background: var(--glass-strong); color: var(--ink); font-weight: 600; font-size: 15px; cursor: pointer; text-decoration: none;
}
.btn.primary { background: var(--grad); color: #fff; border: none; font-weight: 700; }
.btn.wa { background: var(--wa); color: #fff; border: none; font-weight: 700; box-shadow: 0 10px 22px rgba(26,143,78,0.22); }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid rgba(180,35,24,0.3); }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 12px; }
.btn.block { width: 100%; }
.btn.on-hero { background: rgba(255,255,255,0.22); color: #fff; border: 1px solid rgba(255,255,255,0.6); }
.btn:disabled { opacity: 0.5; cursor: default; }
.icon-btn {
  width: 44px; height: 44px; flex: none; border-radius: 22px; border: 1px solid var(--glass-border);
  background: var(--glass); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; position: relative;
}
.badge { position: absolute; top: -2px; left: -2px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: #D4483B; color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; border: 2px solid #fff; }
.link { background: none; border: none; color: #0E6E9E; font-weight: 600; cursor: pointer; padding: 0; min-height: 44px; display: inline-flex; align-items: center; gap: 6px; }
.chip { min-height: 36px; padding: 0 14px; border-radius: 18px; border: 1px solid var(--glass-border); background: var(--glass); font-size: 14px; font-weight: 600; cursor: pointer; }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.pill { display: inline-flex; align-items: center; font-size: 12px; font-weight: 700; padding: 4px 9px; border-radius: 10px; background: var(--soft); white-space: nowrap; }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.blue { background: var(--soft-blue); }
.pill.gray { background: rgba(18,49,58,0.08); color: var(--muted); }
.avatar { width: 44px; height: 44px; flex: none; border-radius: 22px; background: var(--grad); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 17px; }
.avatar.lg { width: 64px; height: 64px; border-radius: 32px; font-size: 26px; }

/* forms */
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; }
label.field .hint { font-weight: 400; color: var(--muted); font-size: 12px; }
.input, select.input, textarea.input {
  width: 100%; min-height: 46px; padding: 10px 14px; border-radius: 14px; border: 1px solid rgba(18,49,58,0.14);
  background: rgba(255,255,255,0.88); font-size: 16px;
}
textarea.input { min-height: 80px; resize: vertical; }
.input:focus { outline: 2px solid rgba(14,120,174,0.45); outline-offset: 1px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 500; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--b); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0,1fr); background: rgba(255,255,255,0.5); border: 1px solid var(--glass-border); border-radius: 16px; padding: 4px; gap: 4px; }
.seg button { min-height: 40px; border: none; border-radius: 12px; background: transparent; font-weight: 700; font-size: 14px; color: var(--muted); cursor: pointer; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.err { color: var(--danger); font-size: 14px; font-weight: 500; }

/* bars, progress */
.bar { height: 10px; border-radius: 5px; background: rgba(18,49,58,0.08); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 5px; background: var(--grad); }
.punch { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 5px; }
.punch i { height: 10px; border-radius: 5px; background: rgba(18,49,58,0.1); }
.punch i.on { background: var(--grad); }

/* exercise + set rows */
.ex { padding: 0; overflow: hidden; }
.ex-head { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px; background: none; border: none; text-align: right; cursor: pointer; }
.ex-body { padding: 0 14px 14px; display: flex; flex-direction: column; gap: 6px; }
.set { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 12px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255,255,255,0.85); cursor: pointer; text-align: right; width: 100%; }
.set.done { background: var(--soft); border-color: rgba(15,132,96,0.35); }
.dot { width: 26px; height: 26px; flex: none; border-radius: 13px; border: 2px solid rgba(14,120,174,0.6); background: #fff; display: flex; align-items: center; justify-content: center; }
.done .dot, .dot.on { background: var(--b); border-color: var(--b); }
.dot svg { opacity: 0; }
.done .dot svg, .dot.on svg { opacity: 1; }
.rest { position: sticky; top: 8px; z-index: 5; }

/* chart */
.chart { width: 100%; height: 150px; display: block; }

/* editor rows */
.edit-row { display: grid; gap: 8px; padding: 12px; border-radius: 16px; background: rgba(255,255,255,0.6); border: 1px solid var(--glass-border); }
.edit-row .grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.edit-row .input { min-height: 40px; padding: 6px 10px; font-size: 15px; }
.mini { font-size: 11px; color: var(--muted); font-weight: 600; }

/* messages */
.thread { display: flex; flex-direction: column; gap: 8px; }
.bubble { max-width: 82%; padding: 10px 12px; border-radius: 18px; font-size: 15px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.bubble.me { align-self: flex-start; background: var(--a); color: #fff; }
.bubble.them { align-self: flex-end; background: var(--glass-strong); border: 1px solid var(--glass-border); }
.bubble .t { display: block; font-size: 11px; opacity: 0.75; margin-top: 4px; }

/* days strip */
.days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
.day { min-height: 58px; border-radius: 16px; border: 1px solid var(--glass-border); background: var(--glass); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer; font-size: 12px; position: relative; }
.day b { font-size: 15px; }
.day.on { background: var(--grad); color: #fff; border-color: transparent; }
.day .has { position: absolute; bottom: 6px; width: 5px; height: 5px; border-radius: 3px; background: var(--b); }
.day.on .has { background: #fff; }
.slots { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.slot-btn { min-height: 48px; border-radius: 14px; border: 1px solid var(--glass-border); background: var(--glass-strong); font-weight: 700; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.2; }
.slot-btn small { font-weight: 500; font-size: 11px; color: var(--muted); }
.slot-btn.on { background: var(--grad); color: #fff; border-color: transparent; }
.slot-btn.on small { color: #fff; }

/* nav */
nav.tabbar {
  position: fixed; bottom: 12px; left: 50%; transform: translateX(-50%); width: calc(100% - 24px); max-width: 496px; z-index: 20;
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 2px; padding: 6px;
  background: rgba(255,255,255,0.78); border: 1px solid var(--glass-border); border-radius: 24px;
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); box-shadow: 0 10px 30px rgba(18,60,80,0.14);
  padding-bottom: calc(6px + env(safe-area-inset-bottom) * 0.5);
}
nav.tabbar a { min-height: 54px; border-radius: 18px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 600; position: relative; }
nav.tabbar a.on { background: var(--soft); color: var(--ink); }
nav.tabbar a .badge { top: 4px; left: calc(50% - 22px); }

/* sheet / modal */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; background: rgba(18,49,58,0.28); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; background: #F6FBFA; border-radius: 26px 26px 0 0; padding: 20px 16px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; }
@media (min-width: 560px) { .sheet-wrap { align-items: center; } .sheet { border-radius: 26px; } }

/* toast */
.toast { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 60; background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 14px; font-size: 14px; font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,0.2); max-width: calc(100% - 32px); }
.toast.err { background: var(--danger); }

/* auth */
.auth { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; gap: 22px; padding: 32px 20px; max-width: 440px; margin: 0 auto; }
.loading { min-height: 60vh; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid rgba(14,120,174,0.2); border-top-color: var(--a); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } }
.empty { padding: 22px; text-align: center; color: var(--muted); font-size: 14px; }

/* ── exercise library, video, set logging, deload ── */
.video { border-radius: 18px; overflow: hidden; background: #0d1b20; }
.video video { display: block; width: 100%; max-height: 62vh; background: #0d1b20; }
.video.yt { aspect-ratio: 16 / 9; }
.video iframe { width: 100%; height: 100%; border: 0; display: block; }
ol.steps, ul.steps { margin: 0; padding-inline-start: 22px; display: flex; flex-direction: column; gap: 6px; line-height: 1.55; font-size: 15px; }
ol.steps li::marker { font-weight: 700; color: var(--a); }
.chips-scroll { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.chips-scroll::-webkit-scrollbar { display: none; }
.chips-scroll .chip { flex: none; }
fieldset.plain { border: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.legend { font-size: 14px; font-weight: 600; padding: 0; }
.chip-check { position: relative; display: inline-flex; cursor: pointer; }
.chip-check input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip-check span { min-height: 36px; padding: 0 14px; border-radius: 18px; border: 1px solid rgba(18,49,58,0.14); background: rgba(255,255,255,0.85); font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; }
.chip-check input:checked + span { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip-check input:focus-visible + span { outline: 2px solid rgba(14,120,174,0.6); outline-offset: 2px; }
.alt-box { max-height: 170px; overflow-y: auto; }
.btn.upload { position: relative; overflow: hidden; }
.btn.upload input { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0; }
.set-head, .set-row { display: grid; grid-template-columns: 48px minmax(0, 1fr) minmax(0, 1fr) 48px; gap: 8px; align-items: center; }
.set-head { padding: 0 10px; text-align: center; }
.set-row { padding: 6px 10px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255,255,255,0.85); }
.set-row.done { background: var(--soft); border-color: rgba(15,132,96,0.35); }
.set-row .input { min-height: 42px; padding: 6px 8px; text-align: center; font-size: 16px; }
.dot-btn { width: 44px; height: 44px; border: none; background: none; padding: 0; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.prev { background: var(--soft-blue); border-radius: 12px; padding: 8px 12px; line-height: 1.5; }
.card.deload { background: rgba(255, 247, 238, 0.85); border-color: rgba(143, 66, 16, 0.25); }
details summary { cursor: pointer; font-weight: 600; font-size: 14px; color: #0E6E9E; min-height: 32px; display: flex; align-items: center; }
