/* Posture PWA — mobile-first dark theme */
:root {
  --bg: #0e1116;
  --surface: #161b22;
  --surface-2: #1f262e;
  --border: #2a323d;
  --text: #e6edf3;
  --text-2: #9aa6b2;
  --accent: #2d8c4f;
  --accent-2: #3aa765;
  --warn: #d97706;
  --danger: #c0392b;
  --pad: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
input, button { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

#app { padding-bottom: 90px; }

/* Header */
.header {
  position: sticky; top: 0; z-index: 50;
  display: grid; grid-template-columns: 44px 1fr 44px;
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 8px;
}
.header h1 {
  margin: 0; font-size: 17px; font-weight: 600; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px;
  border-radius: 10px; border: 0; background: transparent;
  font-size: 22px; color: var(--text);
}
.icon-btn:active { background: var(--surface-2); }

/* Screen container */
.screen { padding: var(--pad); display: flex; flex-direction: column; gap: 14px; }

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
}
.card h2 { margin: 0 0 10px; font-size: 15px; font-weight: 600; color: var(--text); }
.card.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.subtle { color: var(--text-2); font-size: 14px; }

/* Status panel on home */
.status-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.status-cell { background: var(--surface-2); border-radius: 10px; padding: 10px; text-align: center; }
.status-label { font-size: 12px; color: var(--text-2); }
.status-value { font-size: 22px; font-weight: 700; margin-top: 2px; }
.deload-banner {
  background: rgba(217, 119, 6, 0.15); color: #fbbf24;
  border: 1px solid rgba(217, 119, 6, 0.4);
  padding: 10px; border-radius: 10px; margin-top: 10px;
  font-size: 14px;
}

/* Days */
.cta { display: flex; flex-direction: column; gap: 8px; }
.days-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.day-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px; min-height: 84px; display: flex; flex-direction: column; gap: 4px;
}
.day-card.daily { background: linear-gradient(135deg, #1c3b2a, #122b1f); border-color: #2a5a3e; }
.day-code { font-size: 12px; color: var(--text-2); letter-spacing: 0.5px; }
.day-title { font-size: 15px; font-weight: 600; }
.day-sub { font-size: 12px; color: var(--text-2); }
.big-day-btn {
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  border: 0; padding: 18px; min-height: 100px;
  font-size: 16px; color: #fff;
}
.big-day-btn .day-code { color: rgba(255,255,255,0.85); }
.big-day-btn .day-title { font-size: 18px; }
.big-day-btn .day-sub { color: rgba(255,255,255,0.85); }

/* Buttons */
.btn {
  display: inline-flex; justify-content: center; align-items: center;
  gap: 6px; min-height: 48px; padding: 10px 14px;
  border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  font-size: 15px; font-weight: 500;
}
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:active { background: var(--accent-2); }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.big { width: 100%; min-height: 56px; font-size: 17px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.actions { display: flex; flex-direction: column; gap: 10px; }
.mini-btn {
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  padding: 6px 10px; border-radius: 8px; font-size: 13px;
}

/* Links */
.links { display: flex; flex-direction: column; gap: 8px; }
.link-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px; display: flex; align-items: center; gap: 10px;
  font-size: 15px;
}
.link-card:active { background: var(--surface-2); }

/* Warmup item */
.warmup, .cooldown { background: var(--surface); }
.warmup h2, .cooldown h2 { color: var(--accent-2); }
.cooldown h2 { color: #d97706; }
.wu-row {
  display: grid; grid-template-columns: 36px 1fr auto;
  align-items: start; gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.wu-row:last-child { border-bottom: 0; }
.wu-row.checked .wu-name { text-decoration: line-through; color: var(--text-2); }
.wu-cb-wrap {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  margin-top: -4px;
  cursor: pointer;
}
.wu-check {
  width: 24px; height: 24px; accent-color: var(--accent);
  pointer-events: none; /* клики ловит обёртка */
}
.wu-text.clickable { cursor: pointer; }
.wu-text.clickable:active { opacity: 0.6; }
.info-mark { color: var(--accent-2); font-size: 0.85em; vertical-align: middle; }
.ex-head.clickable { cursor: pointer; }
.ex-head.clickable:active .ex-name { opacity: 0.7; }
.wu-name { font-weight: 600; font-size: 14px; }
.wu-params { color: var(--accent-2); font-size: 13px; margin-top: 2px; }
.wu-note { color: var(--text-2); font-size: 12px; margin-top: 4px; line-height: 1.35; }

/* Exercise block */
.exercises { display: flex; flex-direction: column; gap: 14px; }
.exercise { padding: 12px; position: relative; }
.exercise.key-exercise {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 1px var(--accent-2) inset, 0 4px 14px rgba(58, 167, 101, 0.12);
}
.key-badge {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px; align-items: start;
  margin: 8px 0 10px;
  padding: 10px 12px;
  background: linear-gradient(90deg, rgba(58, 167, 101, 0.18), rgba(58, 167, 101, 0.04));
  border: 1px solid rgba(58, 167, 101, 0.4);
  border-radius: 10px;
}
.key-icon { font-size: 22px; line-height: 1; padding-top: 2px; }
.key-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.key-label {
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.6px; text-transform: uppercase;
  color: var(--accent-2);
}
.key-reason { font-size: 13px; line-height: 1.35; color: var(--text); }
.ex-head { display: grid; grid-template-columns: 28px 1fr; gap: 10px; align-items: start; }
.ex-num {
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}
.ex-name { font-size: 16px; font-weight: 600; }
.ex-target { font-size: 13px; color: var(--accent-2); margin-top: 2px; }
.ex-note { color: var(--text-2); font-size: 12px; margin-top: 6px; line-height: 1.4; }

.hint {
  margin-top: 10px; font-size: 13px;
  background: var(--surface-2); border-radius: 10px; padding: 8px 10px;
  color: var(--text-2); border: 1px dashed var(--border);
}
.hint.hint-up { color: #fbbf24; border-color: var(--warn); background: rgba(217, 119, 6, 0.1); }
.last-perf { font-size: 13px; color: var(--text-2); margin-top: 6px; }

.sets { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.set-row {
  display: grid; grid-template-columns: 32px 1fr auto 1fr 56px;
  align-items: center; gap: 8px;
  padding: 6px 0;
}
.set-row.done { opacity: 0.6; }
.set-idx {
  width: 32px; height: 32px; border-radius: 8px; background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 14px; color: var(--text-2);
}
.set-row.done .set-idx { background: var(--accent); color: #fff; }
.inp {
  width: 100%; min-height: 44px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 10px; font-size: 17px; text-align: center;
  color: var(--text);
}
.inp.r.wide { grid-column: 2 / span 3; }
.mul { color: var(--text-2); text-align: center; }
.iso-target { grid-column: 2 / span 3; text-align: center; font-size: 16px; color: var(--accent-2); }
.ok-btn {
  min-height: 44px; min-width: 56px; border-radius: 10px;
  background: var(--accent); color: #fff; border: 0;
  font-size: 18px; font-weight: 700;
}
.ok-btn:disabled { background: #1f3a2a; color: #6e8a78; }

/* Rest bar */
.rest-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 10px var(--pad) calc(10px + env(safe-area-inset-bottom));
  display: none;
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.3);
}
.rest-bar.active { display: block; }
.rest-progress {
  height: 4px; background: var(--accent); border-radius: 4px; width: 0%;
  transition: width 0.25s linear;
}
.rest-content {
  display: flex; align-items: center; gap: 8px;
  margin-top: 8px;
  font-weight: 600; font-size: 16px;
}
.rest-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; cursor: pointer; }
.rest-info.clickable:active { opacity: 0.65; }
.rest-info .rest-label { color: var(--text-2); font-weight: 500; font-size: 13px; }
.rest-info .rest-time { font-size: 22px; color: var(--accent-2); font-variant-numeric: tabular-nums; }
.rest-info .rest-name { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rest-content > .mini-btn { padding: 10px 12px; font-size: 14px; min-height: 40px; }
.rest-cue {
  display: flex; align-items: center; gap: 8px;
  margin: 8px 0 0;
  padding: 8px 10px;
  border-radius: 10px;
  background: linear-gradient(90deg, rgba(58, 167, 101, 0.18), rgba(58, 167, 101, 0.06));
  border: 1px solid rgba(58, 167, 101, 0.35);
  color: #cfe7d6;
  font-size: 13px;
  line-height: 1.3;
}
.rest-cue-icon { font-size: 18px; line-height: 1; flex: 0 0 auto; animation: rest-cue-breathe 4s ease-in-out infinite; }
@keyframes rest-cue-breathe {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50%      { transform: scale(1.18); opacity: 1; }
}

/* Overlay (timers) */
.overlay {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(0, 0, 0, 0.78);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.overlay-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 22px;
  width: 100%; max-width: 360px;
  display: flex; flex-direction: column; gap: 14px; align-items: center; text-align: center;
}
.overlay-card h3 { margin: 0; font-size: 16px; }
.big-counter {
  font-size: 90px; font-weight: 800; color: var(--accent-2);
  line-height: 1; font-variant-numeric: tabular-nums;
}

/* History */
.history-item { display: flex; flex-direction: column; gap: 4px; }
.history-item .h-date { font-size: 12px; color: var(--text-2); }
.history-item .h-name { font-weight: 600; }
.tag {
  display: inline-block; padding: 2px 6px; border-radius: 6px;
  background: var(--surface-2); color: var(--text-2);
  font-size: 11px; align-self: flex-start;
}

/* Reference */
.ref-row {
  display: grid; grid-template-columns: 110px 90px 1fr;
  gap: 8px; padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.ref-row:last-child { border-bottom: 0; }
.ref-row b { font-weight: 600; }
.ref-note { padding: 6px 0; font-size: 13px; border-bottom: 1px dashed var(--border); }
.ref-note:last-child { border-bottom: 0; }
.target-row {
  display: grid; grid-template-columns: 1fr;
  padding: 8px 0; border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.target-row:last-child { border-bottom: 0; }
.target-prob { font-weight: 600; }
.target-cause { color: var(--text-2); }
.target-target { color: var(--accent-2); margin-top: 2px; }

.set-label { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; font-size: 14px; color: var(--text-2); }
.set-label.inline { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.set-label input[type="date"], .set-label input[type="number"] {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px; color: var(--text); min-height: 44px; font-size: 16px;
}
.set-label input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--accent); }
.sum-ex { padding: 8px 0; border-bottom: 1px solid var(--border); }
.sum-ex:last-child { border-bottom: 0; }

/* Touch sizing for inputs (avoid iOS zoom) */
input { font-size: 16px; }

/* Guide overlay (exercise description) */
.guide-overlay { padding: 12px; align-items: flex-start; padding-top: 24px; padding-bottom: 24px; }
.guide-card {
  max-width: 520px; width: 100%;
  align-items: stretch; text-align: left;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
}
.guide-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 8px; margin-bottom: 4px;
  position: sticky; top: -16px;
  background: var(--surface);
  padding-top: 16px; margin-top: -16px;
  z-index: 1;
}
.guide-head h3 { margin: 0; font-size: 18px; line-height: 1.25; flex: 1; }
.guide-head .icon-btn { flex: 0 0 auto; }
.guide-goal {
  background: var(--surface-2); padding: 10px 12px; border-radius: 10px;
  font-size: 14px; line-height: 1.4; margin: 6px 0 4px;
  border-left: 3px solid var(--accent-2);
}
.guide-card h4 {
  margin: 16px 0 8px; font-size: 14px; color: var(--text-2);
  text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600;
}
.guide-steps { padding-left: 22px; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.guide-steps li { font-size: 14px; line-height: 1.45; }
.guide-steps li::marker { color: var(--accent-2); font-weight: 700; }
.mistake-row {
  display: flex; flex-direction: column; gap: 4px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
  font-size: 14px; line-height: 1.4;
}
.mistake-row:last-of-type { border-bottom: 0; }
.mistake-wrong { color: #fda4af; }
.mistake-right { color: #86efac; }
.tag-bad { color: var(--danger); font-weight: 800; }
.tag-good { color: var(--accent-2); font-weight: 800; }
.guide-rules {
  margin-top: 14px; padding-top: 12px;
  border-top: 1px dashed var(--border);
  font-size: 13px; color: var(--text-2);
  display: flex; flex-direction: column; gap: 6px;
}
.guide-rules .rule-row { line-height: 1.45; }

/* Видео в гайде */
.video-list { display: flex; flex-direction: column; gap: 12px; margin-top: 4px; }
.video-link {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  align-items: center; gap: 8px;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  color: var(--text);
  text-decoration: none;
  min-height: 52px;
}
.video-link:active { background: rgba(58, 167, 101, 0.12); }
.video-icon {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 14px; font-weight: 700;
}
.video-title { line-height: 1.3; }
.video-host { font-size: 11px; flex-shrink: 0; }

/* Встроенный YouTube */
.video-embed {
  display: flex; flex-direction: column; gap: 6px;
}
.video-facade, .video-iframe {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #000;
}
.video-facade { cursor: pointer; }
.video-thumb {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.video-play-btn {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 64px; height: 64px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.7);
  border: 2px solid rgba(255, 255, 255, 0.8);
  color: #fff;
  font-size: 24px;
  display: inline-flex; align-items: center; justify-content: center;
  padding-left: 4px;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}
.video-facade:active .video-play-btn { transform: translate(-50%, -50%) scale(0.92); background: rgba(0, 0, 0, 0.85); }
.video-title-bar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0.7) 60%, rgba(0,0,0,0.85) 100%);
  color: #fff;
  padding: 18px 12px 8px;
  font-size: 13px;
  line-height: 1.3;
}
.video-iframe { display: block; border: 1px solid var(--border); }
.video-yt-link {
  align-self: flex-end;
  font-size: 12px;
  color: var(--text-2);
  text-decoration: none;
  padding: 4px 8px;
  border-radius: 6px;
}
.video-yt-link:active { background: var(--surface-2); }
