:root {
  /* Base surfaces */
  --bg: #0a0e1a;
  --bg-grad-1: #0d1322;
  --bg-grad-2: #0a0e1a;
  --surface: rgba(30, 41, 59, 0.55);
  --surface-solid: #161e2e;
  --surface2: rgba(51, 65, 85, 0.55);
  --surface2-solid: #25324a;
  --border: rgba(148, 163, 184, 0.12);
  --border-strong: rgba(148, 163, 184, 0.22);

  /* Brand / accent */
  --accent: #38bdf8;
  --accent-2: #6366f1;
  --accent-3: #818cf8;
  --grad-primary: linear-gradient(135deg, #38bdf8 0%, #6366f1 100%);
  --grad-success: linear-gradient(135deg, #34d399 0%, #10b981 100%);
  --grad-text: linear-gradient(135deg, #7dd3fc 0%, #a5b4fc 100%);

  /* Semantic */
  --success: #4ade80;
  --warn: #fbbf24;
  --danger: #f87171;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --muted-dim: #64748b;

  /* Shape & motion */
  --radius: 20px;
  --radius-sm: 14px;
  --radius-lg: 26px;
  --tap: 56px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 8px 24px -8px rgba(56, 189, 248, 0.45);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
  background: var(--bg);
  background-image:
    radial-gradient(1100px 600px at 50% -10%, rgba(99, 102, 241, 0.18), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(56, 189, 248, 0.12), transparent 55%),
    linear-gradient(180deg, var(--bg-grad-1) 0%, var(--bg-grad-2) 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom);
}

/* ---------- Header ---------- */
.header {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: calc(env(safe-area-inset-top) + 14px) 4px 12px;
  margin: 0 -16px 4px;
  padding-left: 20px;
  padding-right: 20px;
  text-align: center;
  background: linear-gradient(180deg, rgba(10, 14, 26, 0.92) 0%, rgba(10, 14, 26, 0.55) 80%, transparent 100%);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.header h1 {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: var(--grad-text);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.readiness {
  margin: 10px 0 0;
  padding: 11px 15px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  line-height: 1.4;
  border: 1px solid var(--border);
  text-align: left;
}

.readiness.ready {
  background: linear-gradient(135deg, rgba(74, 222, 128, 0.16), rgba(16, 185, 129, 0.08));
  border-color: rgba(74, 222, 128, 0.3);
  color: var(--success);
}

.readiness.not-ready {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.14), rgba(99, 102, 241, 0.08));
  border-color: rgba(56, 189, 248, 0.28);
  color: var(--accent);
}

.readiness.hidden {
  display: none;
}

/* ---------- Screen ---------- */
.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 6px 0 28px;
  animation: screenIn 0.32s var(--ease);
}

@keyframes screenIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Buttons ---------- */
.btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 16px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  cursor: pointer;
  width: 100%;
  color: var(--text);
  transition: transform 0.12s var(--ease), box-shadow 0.2s var(--ease), filter 0.2s var(--ease), background 0.2s var(--ease);
}

.btn:active {
  transform: scale(0.975);
  filter: brightness(0.95);
}

.btn-primary {
  background: var(--grad-primary);
  color: #06121f;
  font-weight: 700;
  box-shadow: var(--shadow-glow);
}

.btn-primary:active {
  box-shadow: 0 4px 14px -6px rgba(56, 189, 248, 0.5);
}

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border-strong);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.btn-success {
  background: var(--grad-success);
  color: #04140d;
  font-weight: 700;
  box-shadow: 0 8px 24px -8px rgba(52, 211, 153, 0.45);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  min-height: 46px;
  font-size: 0.95rem;
  font-weight: 600;
}

.btn-ghost:active {
  background: var(--surface2);
}

.btn-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.card h2 {
  margin: 0 0 10px;
  font-size: 1.3rem;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.card h3 {
  margin: 0 0 10px;
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.card p, .card li {
  color: var(--muted);
  line-height: 1.55;
  margin: 0 0 8px;
}

.card ul {
  padding-left: 1.2rem;
  margin: 0;
}

.card strong {
  color: var(--text);
  font-weight: 650;
}

.exercise-img {
  width: 100%;
  max-height: 200px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: var(--surface2-solid);
  border: 1px solid var(--border);
  margin-bottom: 14px;
}

/* ---------- Badge ---------- */
.badge {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.25);
  color: var(--accent);
  margin-bottom: 10px;
}

/* ---------- Timer ---------- */
.timer-display {
  font-size: 4.5rem;
  font-weight: 800;
  text-align: center;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
  line-height: 1;
  margin: 18px 0;
  background: var(--grad-text);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.timer-phase {
  text-align: center;
  font-size: 1rem;
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.timer-phase.rest {
  color: var(--warn);
}

.timer-phase.work {
  color: var(--success);
}

/* ---------- Forms ---------- */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 8px;
  letter-spacing: 0.01em;
}

.extra-set-row {
  display: grid;
  grid-template-columns: auto 1fr 1fr;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.extra-set-row .set-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  min-width: 3.5rem;
}

.extra-set-row input,
.form-group input[type="number"],
.form-group input[type="text"],
.form-group textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 13px 16px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: rgba(10, 14, 26, 0.6);
  color: var(--text);
  font-family: inherit;
  font-size: 1.05rem;
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease), background 0.18s var(--ease);
}

.form-group textarea {
  min-height: 80px;
  resize: vertical;
  line-height: 1.5;
}

.extra-set-row input:focus,
.form-group input:focus,
.form-group textarea:focus,
.chart-card select:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(10, 14, 26, 0.85);
  box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.14);
}

input::placeholder, textarea::placeholder {
  color: var(--muted-dim);
}

/* ---------- Feel / side pickers (segmented) ---------- */
.feel-picker {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.feel-picker button,
.side-picker button {
  min-height: 52px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: rgba(10, 14, 26, 0.5);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 650;
  cursor: pointer;
  transition: transform 0.12s var(--ease), border-color 0.18s var(--ease), background 0.18s var(--ease), color 0.18s var(--ease);
}

.feel-picker button:active,
.side-picker button:active {
  transform: scale(0.97);
}

.feel-picker button.selected,
.side-picker button.selected {
  border-color: var(--accent);
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.2), rgba(99, 102, 241, 0.14));
  color: #e0f2fe;
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.3) inset;
}

.side-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.side-picker button {
  min-height: 52px;
}

/* ---------- Pain slider ---------- */
.pain-slider {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, #34d399 0%, #fbbf24 55%, #f87171 100%);
  outline: none;
  margin-top: 4px;
}

.pain-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--accent);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  cursor: pointer;
}

.pain-slider::-moz-range-thumb {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--accent);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  cursor: pointer;
}

.pain-value {
  font-size: 1.6rem;
  font-weight: 800;
  text-align: center;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.target-weight {
  font-size: 1.5rem;
  font-weight: 750;
  background: var(--grad-success);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-align: center;
  margin: 10px 0;
}

/* ---------- Progress dots ---------- */
.progress-dots {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 10px;
}

.progress-dots span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--surface2-solid);
  transition: all 0.25s var(--ease);
}

.progress-dots span.active {
  background: var(--accent);
  transform: scale(1.35);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.7);
}

.progress-dots span.done {
  background: var(--success);
}

/* ---------- Coach box ---------- */
.coach-box {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(56, 189, 248, 0.06));
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: var(--radius);
  padding: 16px;
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--text);
  white-space: pre-wrap;
  box-shadow: var(--shadow);
}

/* ---------- Toggle row ---------- */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  font-weight: 600;
}

.toggle-row input {
  width: 52px;
  height: 30px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ---------- History ---------- */
.history-item {
  border-bottom: 1px solid var(--border);
  padding: 13px 0;
}

.history-item:last-child {
  border-bottom: none;
}

.history-item time {
  font-size: 0.78rem;
  color: var(--muted-dim);
  font-weight: 500;
}

.history-item div {
  margin-top: 2px;
}

/* ---------- Mono finger grid ---------- */
.mono-finger-grid {
  display: grid;
  gap: 10px;
}

.mono-finger-grid .btn {
  text-align: left;
  justify-content: flex-start;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.mono-finger-grid .btn small {
  font-weight: 400;
  color: var(--muted);
  font-size: 0.85rem;
}

/* ---------- Today card ---------- */
.today-card {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.1), rgba(99, 102, 241, 0.08));
  border-color: rgba(99, 102, 241, 0.22);
}

.today-card h2 {
  margin-bottom: 4px;
}

.today-date {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
}

/* ---------- Section buttons ---------- */
.section-btn {
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  margin-bottom: 10px;
  gap: 4px;
}

.section-btn.done {
  border-color: rgba(74, 222, 128, 0.45);
  background: linear-gradient(135deg, rgba(74, 222, 128, 0.12), rgba(16, 185, 129, 0.05));
  color: var(--success);
}

.section-btn.active {
  border-color: var(--accent);
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.16), rgba(99, 102, 241, 0.08));
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.3) inset;
}

.section-btn small {
  font-weight: 500;
  font-size: 0.84rem;
  color: var(--muted);
}

/* ---------- Inline button row ---------- */
.btn-row-inline {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.btn-row-inline .btn {
  min-height: 48px;
  font-size: 0.95rem;
}

/* ---------- Check row ---------- */
.check-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  font-size: 1rem;
  font-weight: 550;
  cursor: pointer;
}

.check-row input {
  width: 22px;
  height: 22px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ---------- Alerts ---------- */
.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 550;
  margin-top: 10px;
  border: 1px solid transparent;
}

.alert-warn {
  background: rgba(248, 113, 113, 0.13);
  border-color: rgba(248, 113, 113, 0.3);
  color: var(--danger);
}

.hint {
  font-size: 0.8rem;
  color: var(--muted-dim);
  line-height: 1.5;
}

/* ---------- Compact / chart cards ---------- */
.card-compact {
  padding: 14px 16px;
}

.card-compact h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.chart-card h3 {
  margin: 0 0 4px;
  font-size: 1.05rem;
}

.chart-wrap {
  position: relative;
  height: 220px;
  width: 100%;
  margin-top: 10px;
}

.chart-card select {
  width: 100%;
  min-height: 48px;
  padding: 11px 14px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: rgba(10, 14, 26, 0.6);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
}
