:root {
  --bg: #000;
  --card: #12161a;
  --card2: #1a2026;
  --line: #262d34;
  --text: #f2f5f7;
  --muted: #8a96a3;
  --accent: #14b8b0;
  --accent-ink: #001a19;
  --danger: #ff5c6c;
  --body-base: #3a4148;
  --body-muscle: #5b636b;
  --nav-h: 64px;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: calc(56px + env(safe-area-inset-top)) 16px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom));
  overscroll-behavior-y: contain;
}
body.modal-open { overflow: hidden; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2 { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13.5px; }
.accent { color: var(--accent); }
.h2 { font-size: 20px; font-weight: 700; }
.h3 { font-size: 16px; font-weight: 600; }
.empty { text-align: center; padding: 32px 12px; }
.gap { margin-top: 10px; }
.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row-sb { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.row-gap { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.row-gap form { margin: 0; }

/* viršus */
#top {
  position: fixed; inset: 0 0 auto 0; z-index: 10;
  height: calc(56px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 8px 0;
  display: grid; grid-template-columns: 48px 1fr auto; align-items: center;
  background: rgba(0,0,0,.92); backdrop-filter: blur(8px); border-bottom: 1px solid #111;
}
#top h1 { font-size: 19px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-r { display: flex; align-items: center; gap: 6px; justify-content: flex-end; min-width: 48px; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; background: none; border: 0; color: var(--accent); padding: 0; cursor: pointer; }
.icon-btn svg { width: 24px; height: 24px; }
.sync-dot { width: 28px; height: 28px; border: 0; background: none; padding: 0; position: relative; cursor: pointer; }
.sync-dot::after { content: ""; position: absolute; inset: 9px; border-radius: 50%; background: #444; }
.sync-dot.ok::after { background: #2ecc71; }
.sync-dot.pending::after, .sync-dot.error::after { background: #f5a623; }
.sync-dot.syncing::after { background: var(--accent); animation: pulse 1s infinite; }
.sync-dot.offline::after { background: #666; box-shadow: 0 0 0 2px #333; }
.sync-dot.auth::after { background: var(--danger); }
@keyframes pulse { 50% { opacity: .3; } }
#auth-banner { background: #3a1d22; color: #ffd7dc; padding: 10px 12px; border-radius: 12px; margin-bottom: 12px; font-size: 14px; }
#auth-banner a { color: #fff; font-weight: 700; text-decoration: underline; }

/* apačios meniu */
nav {
  position: fixed; inset: auto 0 0 0; z-index: 10;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: #0a0c0e; border-top: 1px solid var(--line);
}
nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11.5px; color: var(--muted); }
nav a svg { width: 26px; height: 26px; }
nav a.on { color: var(--accent); font-weight: 600; }

/* mygtukai */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card2); font-weight: 600; cursor: pointer; letter-spacing: .2px;
}
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn.big { min-height: 54px; font-size: 17px; text-transform: uppercase; letter-spacing: 1.5px; }
.btn.wide { width: 100%; margin: 10px 0; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:disabled { opacity: .45; }
.btn.ghost { background: transparent; }
.btn.dashed { background: transparent; border-style: dashed; color: var(--accent); }
.btn.danger-link { background: none; border: 0; color: var(--danger); font-weight: 500; }
.link { background: none; border: 0; color: var(--accent); font-weight: 600; font-size: 15px; cursor: pointer; padding: 6px 0; }

/* kortelės */
.card { display: block; background: var(--card); border: 1px solid #1c2228; border-radius: 16px; padding: 14px; margin: 10px 0; }
.sec-h { display: flex; justify-content: space-between; align-items: baseline; margin: 22px 2px 4px; }
.sec-h h2 { font-size: 15px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.resume { display: flex; justify-content: space-between; align-items: center; gap: 12px; border-color: var(--accent); background: linear-gradient(135deg, #0f2a29, var(--card)); }
.tpl { display: flex; align-items: center; gap: 12px; }
.tpl-body { flex: 1; min-width: 0; }
.wcard .h3 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wcard > div { margin-top: 3px; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.stat { background: var(--card); border-radius: 14px; padding: 12px 8px; text-align: center; }
.stat b { display: block; font-size: 20px; }
.stat span { font-size: 12px; color: var(--muted); }
.done-banner { border-color: var(--accent); text-align: center; }
.done-banner .stat { background: var(--card2); }

/* treniruotė */
.w-head { margin: 4px 0 6px; }
.w-title { width: 100%; background: none; border: 0; border-bottom: 1px solid transparent; font-size: 22px; font-weight: 700; padding: 4px 0; }
.w-title:focus { outline: none; border-bottom-color: var(--accent); }
.w-note { width: 100%; min-height: 70px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin: 6px 0; resize: vertical; }
.ex-card { padding: 12px 12px 8px; }
.ex-h { display: flex; gap: 12px; align-items: center; }
.ex-t { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.thumb { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; background: #fff; flex: none; }
.thumb-ph { display: grid; place-items: center; background: var(--card2); color: var(--accent); font-weight: 700; font-size: 22px; }
.up { color: #2ecc71; font-weight: 600; }
.note { margin: 8px 0 0; color: #cfd8df; }
.sets { margin-top: 10px; }
.set-row { display: grid; grid-template-columns: 26px 1fr 1fr 64px 48px; gap: 6px; align-items: center; padding: 3px 0; }
.set-row.head { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; text-align: center; }
.set-n { text-align: center; color: var(--muted); font-weight: 600; }
.set-row input {
  width: 100%; height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--card2);
  text-align: center; font-size: 18px; font-weight: 600; padding: 0 4px;
}
.set-row input::placeholder { color: #5a6570; font-weight: 500; }
.set-row input:focus { outline: none; border-color: var(--accent); }
.chk { height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--card2); color: #55606a; display: grid; place-items: center; cursor: pointer; }
.chk svg { width: 22px; height: 22px; }
.set-row.done input { background: #0d2b29; border-color: #145a56; }
.set-row.done .chk { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.ex-actions { display: flex; gap: 8px; margin-top: 8px; }

/* poilsio juosta */
#rest {
  position: fixed; left: 8px; right: 8px; bottom: calc(var(--nav-h) + 8px + env(safe-area-inset-bottom)); z-index: 11;
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 16px; overflow: hidden;
  background: #0e2423; border: 1px solid var(--accent); box-shadow: 0 8px 30px rgba(0,0,0,.6);
}
#rest[hidden] { display: none; }
.rest-fill { position: absolute; inset: 0 auto 0 0; background: rgba(20,184,176,.18); transition: width .25s linear; }
.rest-l { position: relative; font-size: 13px; color: var(--muted); }
.rest-t { position: relative; font-size: 26px; font-variant-numeric: tabular-nums; flex: 1; }
#rest .btn { position: relative; }

/* paieška, lustai, sąrašas */
.search { width: 100%; height: 46px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); padding: 0 14px; margin: 4px 0 8px; }
.search:focus { outline: none; border-color: var(--accent); }
.chips { display: flex; gap: 8px; margin: 8px 0; }
.chips.scroll { overflow-x: auto; scrollbar-width: none; margin-left: -16px; margin-right: -16px; padding: 0 16px; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chips.wrap { flex-wrap: wrap; }
.chip { flex: none; height: 36px; padding: 0 14px; border-radius: 18px; border: 1px solid var(--line); background: none; display: inline-flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; white-space: nowrap; }
.chip.on { border-color: var(--accent); color: #fff; background: #0f2a29; }
.chip.static { cursor: default; height: 30px; font-size: 13px; color: var(--muted); }
.chip input { accent-color: var(--accent); margin: 0; }
.count { margin: 2px 2px 6px; }
.ex-list { display: flex; flex-direction: column; }
.ex-row { display: flex; align-items: center; gap: 12px; text-align: left; background: none; border: 0; border-bottom: 1px solid #14191e; padding: 10px 2px; cursor: pointer; }
.ex-row.sel { background: #0f2a29; }
.ex-row .tick { width: 26px; color: var(--accent); }

/* pratimo kortelė */
.ex-anim { position: relative; aspect-ratio: 4 / 3; background: #fff; border-radius: 16px; overflow: hidden; margin: 4px 0 12px; }
.ex-anim img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.ex-anim.two img:last-child { animation: flip 2s steps(1) infinite; }
@keyframes flip { 0% { opacity: 0; } 50% { opacity: 1; } }
.ex-name { font-size: 22px; }
.hist-row { display: flex; justify-content: space-between; gap: 10px; padding: 12px 14px; }
details summary { cursor: pointer; font-weight: 600; }
details ol { padding-left: 20px; color: #cfd8df; font-size: 14.5px; }
.chart { width: 100%; height: auto; display: block; }
.chart .ln { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; }
.chart .pt { fill: var(--accent); }
.chart .ax { fill: var(--muted); font-size: 10px; }

/* kūno žemėlapis */
.map-card { text-align: center; }
.body-map { width: 100%; max-width: 420px; height: auto; }
.map-card.compact .body-map { max-width: 280px; }
.body-map path[data-m] { stroke: #0b0d0f; stroke-width: .5; }
.body-map .bm-l { fill: var(--muted); font-size: 7px; text-anchor: middle; }
.legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; font-size: 13px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 34px; gap: 8px; align-items: center; font-size: 14px; margin: 7px 0; }
.bar { height: 10px; background: var(--card2); border-radius: 5px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 5px; }
.bar-row b { text-align: right; }
.weeks { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; height: 140px; align-items: end; margin-top: 10px; }
.wk { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; gap: 3px; }
.wk i { width: 70%; background: var(--accent); border-radius: 5px 5px 2px 2px; min-height: 2px; }
.wk-v { font-size: 11px; color: var(--muted); }
.wk-l { font-size: 11px; color: var(--muted); }

/* formos */
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); margin: 10px 0; }
.form .lbl { font-size: 14px; color: var(--muted); margin-top: 14px; }
.form input:not([type=checkbox]), .form select, .tpl-nums input {
  height: 46px; border-radius: 12px; border: 1px solid var(--line); background: var(--card2); padding: 0 12px; color: var(--text); font-size: 16px;
}
.tpl-nums { display: grid; grid-template-columns: 1fr 1fr 1.3fr; gap: 8px; margin-top: 10px; }
.tpl-nums label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.tpl-nums input { width: 100%; text-align: center; font-weight: 600; }

/* modalai */
#modal { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; }
#modal[hidden] { display: none; }
.sheet { width: 100%; background: #101417; border-radius: 20px 20px 0 0; padding: 8px 12px calc(12px + env(safe-area-inset-bottom)); max-height: 90vh; }
.sheet.full { height: 100%; max-height: none; border-radius: 0; padding-top: env(safe-area-inset-top); display: flex; flex-direction: column; }
.sheet-top { display: grid; grid-template-columns: 48px 1fr auto; align-items: center; height: 56px; }
.sheet-top h1 { font-size: 18px; text-align: center; }
.sheet-scroll { flex: 1; overflow-y: auto; margin: 0 -12px; padding: 0 12px 20px; }
.sheet-title { text-align: center; color: var(--muted); font-size: 14px; padding: 10px; }
.sheet-opt { display: block; width: 100%; min-height: 52px; background: var(--card); border: 0; border-radius: 12px; margin: 6px 0; font-size: 16px; cursor: pointer; }
.sheet-opt.danger { color: var(--danger); }

/* prisijungimas */
body.login { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-box { width: 100%; max-width: 340px; text-align: center; }
.login-box img { border-radius: 18px; }
.login-box h1 { margin: 12px 0 24px; }
.login-box input { width: 100%; height: 52px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); padding: 0 14px; font-size: 17px; }
.err { color: var(--danger); }

@media (min-width: 700px) {
  body { max-width: 640px; margin: 0 auto; }
}

/* treneris */
.center { text-align: center; }
.req { color: var(--accent); font-weight: 700; }
.err { color: var(--danger); }
.err-card { border-color: #5a2228; background: #1d1012; }
.err-card .btn { margin-top: 10px; }
.working { display: flex; gap: 14px; align-items: center; border-color: var(--accent); }
.spin { width: 28px; height: 28px; flex: none; border: 3px solid var(--accent); border-right-color: transparent; border-radius: 50%; animation: rot .9s linear infinite; }
@keyframes rot { to { transform: rotate(1turn); } }
.onboard p { margin: 8px 0; }
.steps { padding-left: 22px; margin: 10px 0 14px; }
.steps li { margin: 6px 0; }
.steps li.ok { color: #2ecc71; }
.today { border-color: var(--accent); background: linear-gradient(135deg, #0f2a29, var(--card)); }
.macros { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0 6px; text-align: center; }
.macros div { background: var(--card2); border-radius: 12px; padding: 10px 4px; }
.macros b { display: block; font-size: 18px; }
.macros span { font-size: 12px; color: var(--muted); }
.prio { display: flex; gap: 12px; align-items: flex-start; }
.prio-n { flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-weight: 800; display: grid; place-items: center; }
.checkin-due, .step { display: flex; gap: 12px; align-items: center; }
.checkin-due > div, .step > div { flex: 1; }
.step-n { flex: none; width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-weight: 700; color: var(--muted); }
.step-n.ok { border-color: #2ecc71; color: #2ecc71; }
.step .btn { margin-bottom: 4px; }
.prose p { margin: 6px 0; }
.card ul, .card ol { padding-left: 20px; margin: 8px 0 0; }
.card li { margin: 4px 0; }
ul.plain { list-style: none; padding-left: 0; }
.lbl { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin: 12px 0 2px; }
.plan-ex li { margin: 8px 0; }
.kv { display: grid; grid-template-columns: 80px 1fr; gap: 6px 10px; margin: 10px 0 0; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.meal { padding: 8px 0; border-bottom: 1px solid #1c2228; }
.meal:last-child { border-bottom: 0; }
.shots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 6px; }
.shots img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 12px; background: var(--card); }
.coach-note { color: #9fe3dc; }
.fld { display: flex; flex-direction: column; gap: 6px; margin: 14px 0 4px; font-size: 15px; }
.fld input, .fld textarea { height: 46px; border-radius: 12px; border: 1px solid var(--line); background: var(--card2); padding: 0 12px; color: var(--text); font-size: 16px; }
.fld textarea { height: auto; min-height: 72px; padding: 10px 12px; resize: vertical; }
.fld .unit { display: flex; align-items: center; gap: 8px; }
.fld .unit input { width: 120px; }
.fld .unit i { font-style: normal; color: var(--muted); }
.fld .chips { margin: 2px 0; }

/* 3D kūnas */
.body3d { position: relative; height: 440px; margin: -6px -6px 0; touch-action: none; }
.map-card.compact .body3d { height: 340px; }
.body3d svg.body-map { height: 100%; }
.body3d canvas { width: 100% !important; height: 100% !important; display: block; border-radius: 12px; }
.body3d.loading::after { content: "Kraunamas 3D modelis…"; position: absolute; left: 0; right: 0; bottom: 8px; font-size: 12px; color: var(--muted); }
.b3d-ui { position: absolute; left: 6px; right: 6px; bottom: 6px; display: flex; gap: 6px; align-items: center; pointer-events: none; }
.b3d-ui button { pointer-events: auto; height: 32px; padding: 0 12px; border-radius: 16px; border: 1px solid var(--line); background: rgba(10,12,14,.8); font-size: 13px; cursor: pointer; }
.b3d-pick { margin-left: auto; font-size: 13px; color: var(--text); background: rgba(10,12,14,.8); border-radius: 10px; padding: 4px 8px; }
.b3d-pick:empty { display: none; }
.map-card a { color: var(--accent); }

/* pratimo gidas */
.yt { position: relative; display: block; width: 100%; aspect-ratio: 16 / 9; border: 0; padding: 0; margin: 10px 0; border-radius: 16px; overflow: hidden; background: #000; cursor: pointer; }
.yt img { width: 100%; height: 100%; object-fit: cover; opacity: .85; }
.yt-play { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 68px; height: 48px; border-radius: 14px; background: #e62117; color: #fff; display: grid; place-items: center; font-size: 22px; }
.yt-t { position: absolute; left: 0; right: 0; bottom: 0; padding: 22px 12px 10px; text-align: left; font-size: 14px; font-weight: 600; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.85)); }
.yt-t i { display: block; font-style: normal; font-weight: 400; font-size: 12px; color: #c9d1d8; }
.yt.on iframe { width: 100%; height: 100%; border: 0; display: block; }
.guide p { margin: 6px 0; }
.g-list { margin: 4px 0 0; padding-left: 20px; }
.g-list li { margin: 5px 0; }
.g-personal { background: #0f2a29; border: 1px solid #145a56; border-radius: 12px; padding: 10px 12px; margin: 10px 0; font-size: 14.5px; }
.g-mis { display: flex; flex-direction: column; gap: 2px; padding: 8px 0; border-bottom: 1px solid #1c2228; font-size: 14.5px; }
.g-mis span:first-child { color: #ff9aa6; }
.g-mis span:last-child { color: #9fe3dc; }
.chip.cue { color: var(--text); border-color: #145a56; height: auto; padding: 6px 12px; white-space: normal; }
