:root {
  --bg: #0a0d12;
  --surface: #121721;
  --surface-2: #19202e;
  --border: #253045;
  --text: #f3f6fc;
  --muted: #93a1b8;
  --green: #22c55e;
  --yellow: #f59e0b;
  --red: #ef4444;
  --accent: #38bdf8;
  --accent-ink: #04131d;
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

[hidden] {
  display: none !important;
}

.app-shell {
  max-width: 680px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: 16px 16px 96px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.02em;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 12px var(--green);
}

.ghost-btn {
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
}

.card-title {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtle {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 14px;
  line-height: 1.45;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.field label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

.input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 12px;
  padding: 13px 14px;
  font-size: 16px;
  outline: none;
}

.input:focus {
  border-color: var(--accent);
}

.primary-btn {
  width: 100%;
  min-height: 52px;
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.01em;
  cursor: pointer;
  padding: 12px 18px;
}

.secondary-btn {
  width: 100%;
  min-height: 48px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 14px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  padding: 10px 16px;
}

.fast-checkin-btn {
  width: 100%;
  min-height: 56px;
  background: var(--green);
  color: #04190c;
  border: none;
  border-radius: 14px;
  font-size: 17px;
  font-weight: 800;
  cursor: pointer;
  margin-bottom: 16px;
}

.rating-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.rating-label {
  font-size: 14px;
  font-weight: 600;
  min-width: 96px;
}

.pill-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.pill-btn {
  min-width: 42px;
  min-height: 42px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  padding: 0 10px;
}

.pill-btn[data-active="true"] {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

/* 3 кольца WHOOP (§6e) */
.rings-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.ring-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 10px;
  text-align: center;
}

.ring-circle {
  width: 68px;
  height: 68px;
  margin: 0 auto 8px;
  border-radius: 999px;
  border: 5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 800;
}

.ring-card[data-tone="green"] .ring-circle {
  border-color: var(--green);
  color: var(--green);
}

.ring-card[data-tone="yellow"] .ring-circle {
  border-color: var(--yellow);
  color: var(--yellow);
}

.ring-card[data-tone="red"] .ring-circle {
  border-color: var(--red);
  color: var(--red);
}

.ring-caption {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.explain-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 14px;
  line-height: 1.4;
}

.author-tag {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  background: rgba(56, 189, 248, 0.12);
  padding: 4px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.exercise-preview-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 11px 0;
  border-top: 1px solid var(--border);
}

.exercise-name {
  font-weight: 700;
  font-size: 15px;
}

.delta-note {
  font-size: 12px;
  color: var(--accent);
  margin-top: 3px;
}

.rehab-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: var(--yellow);
  background: rgba(245, 158, 11, 0.14);
  padding: 2px 7px;
  border-radius: 6px;
  margin-left: 6px;
}

/* Плеер: лог за 1–2 касания (§6a) */
.set-row {
  display: grid;
  grid-template-columns: 28px 1fr 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}

.set-num {
  font-size: 13px;
  color: var(--muted);
  font-weight: 700;
}

.stepper {
  display: inline-flex;
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 11px;
  overflow: hidden;
  touch-action: pan-y;
}

.step-btn {
  min-width: 34px;
  min-height: 42px;
  background: transparent;
  color: var(--muted);
  border: none;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
}

.step-val {
  min-width: 58px;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  user-select: none;
  cursor: ew-resize;
}

.done-btn {
  min-height: 44px;
  min-width: 104px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  padding: 0 12px;
}

.done-btn[data-completed="true"] {
  background: var(--green);
  border-color: var(--green);
  color: #04190c;
}

.rir-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}

.srpe-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-top: 12px;
}

/* Поиск незапланированного упражнения */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 13, 0.82);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  z-index: 40;
}

.modal-sheet {
  width: 100%;
  max-width: 640px;
  max-height: 82dvh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 18px;
}

.search-result-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
  margin-top: 8px;
  text-align: left;
  cursor: pointer;
}

.search-last {
  font-size: 13px;
  color: var(--green);
  font-weight: 700;
  white-space: nowrap;
}

/* График Прогресс e1RM */
.chart-box {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  margin-top: 12px;
}

.chart-svg {
  width: 100%;
  height: 180px;
  display: block;
}

.chart-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
}

.chart-goal-line {
  fill: none;
  stroke: var(--green);
  stroke-width: 1.5;
  stroke-dasharray: 5 5;
}

.chart-dot {
  fill: var(--accent);
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(18, 23, 33, 0.96);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  z-index: 30;
}

.nav-btn {
  flex: 1;
  max-width: 150px;
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.nav-btn[data-active="true"] {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}

.error-banner {
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid var(--red);
  color: #fecaca;
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 14px;
}

@media (max-width: 480px) {
  .set-row {
    grid-template-columns: 24px 1fr 1fr;
  }
  .done-btn {
    grid-column: 1 / -1;
    width: 100%;
  }
}

.health-links { display: flex; flex-wrap: wrap; gap: .5rem 1rem; margin-bottom: .75rem; }
.health-links a { color: inherit; padding: .25rem 0; }

.offline-status {
  padding: 0.7rem 1rem;
  background: #263248;
  color: #f1f5f9;
  font-size: 0.875rem;
}

[data-testid^="exercise-video-"] {
  margin: 0.5rem 0;
}

[data-testid^="exercise-video-"] video {
  display: block;
  width: 100%;
  max-height: 16rem;
}

.weekly-review {
  padding: 0.55rem 0;
  overflow-wrap: anywhere;
}

.weekly-review a {
  display: block;
  margin-bottom: 0.4rem;
}

.rebuild-box {
  margin-top: 10px;
}
.rebuild-box summary {
  cursor: pointer;
  font-weight: 600;
  padding: 6px 0;
}
.rebuild-box textarea {
  width: 100%;
  box-sizing: border-box;
  margin: 6px 0;
  resize: vertical;
}
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.override-banner {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  margin: 8px 0;
}
.override-banner ul {
  margin: 0;
  padding-left: 18px;
}
.override-banner p {
  margin: 0;
}
