/* === Variables === */
:root {
  --color-bg: #121212;
  --color-surface: #1e1e1e;
  --color-surface-hover: #2a2a2a;
  --color-accent: #ff2d78;
  --color-accent-dim: #c4205d;
  --color-teal: #00796b;
  --color-teal-light: #009688;
  --color-text: #ffffff;
  --color-text-muted: #999;
  --color-text-dim: #666;
  --color-active: #ff1744;
  --color-success: #4caf50;
  --color-warning: #ff9800;
  --color-switch-bg: #c8c8c8;

  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'Segoe UI', monospace;

  --touch-min: 48px;
  --touch-comfortable: 56px;
  --radius: 8px;
  --radius-lg: 12px;
}

/* === Reset === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  font-size: 18px;
  background: var(--color-bg);
  color: var(--color-text);
  -webkit-tap-highlight-color: transparent;
}

body {
  position: fixed;
  width: 100%;
  height: 100%;
}

#app {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

#screen-container {
  flex: 1;
  min-height: 0;
  position: relative;
}

/* === Screen Management === */
.screen {
  display: none;
  position: absolute;
  inset: 0;
  overflow-y: auto;
}

.screen.active {
  display: flex;
  flex-direction: column;
}

/* === Typography === */
h1 { font-size: 2rem; font-weight: 700; }
h2 { font-size: 1.5rem; font-weight: 600; }
h3 { font-size: 1.1rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-text-muted); }

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--touch-comfortable);
  padding: 14px 32px;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  user-select: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--color-accent);
  color: white;
}

.btn-primary:active {
  background: var(--color-accent-dim);
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid #444;
}

.btn-secondary:active {
  background: var(--color-surface-hover);
}

.btn-large {
  min-height: 64px;
  padding: 18px 40px;
  font-size: 1.3rem;
  border-radius: var(--radius-lg);
}

.btn-icon {
  width: var(--touch-comfortable);
  height: var(--touch-comfortable);
  padding: 0;
  border-radius: 50%;
  font-size: 1.5rem;
}

/* === Form Controls === */
.form-group {
  margin-bottom: 20px;
}

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

input[type="number"],
input[type="text"],
textarea {
  width: 100%;
  min-height: var(--touch-min);
  padding: 12px 16px;
  background: var(--color-surface);
  border: 1px solid #444;
  border-radius: var(--radius);
  color: var(--color-text);
  font-family: var(--font);
  font-size: 1.1rem;
}

input[type="number"]:focus,
input[type="text"]:focus,
textarea:focus {
  outline: none;
  border-color: var(--color-accent);
}

textarea {
  resize: vertical;
  min-height: 80px;
}

/* === Scale Input (1-5, 1-10) === */
.scale-input {
  display: flex;
  gap: 8px;
}

.scale-btn {
  flex: 1;
  min-height: var(--touch-comfortable);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface);
  border: 2px solid #444;
  border-radius: var(--radius);
  color: var(--color-text);
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}

.scale-btn.selected {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: white;
}

.scale-btn:active {
  transform: scale(0.95);
}

/* === Toggle (Yes/No) === */
.toggle-group {
  display: flex;
  gap: 8px;
}

.toggle-btn {
  flex: 1;
  min-height: var(--touch-comfortable);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface);
  border: 2px solid #444;
  border-radius: var(--radius);
  color: var(--color-text);
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}

.toggle-btn.selected {
  background: var(--color-success);
  border-color: var(--color-success);
  color: white;
}

.toggle-btn.selected-no {
  background: var(--color-active);
  border-color: var(--color-active);
  color: white;
}

/* === Cards === */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 20px;
  cursor: pointer;
  transition: background 0.15s;
}

.card:active {
  background: var(--color-surface-hover);
}

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

.card p {
  color: var(--color-text-muted);
  font-size: 0.95rem;
}

/* === Checklist === */
.checklist {
  list-style: none;
}

.checklist-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: var(--color-surface);
  border-radius: var(--radius);
  margin-bottom: 8px;
  cursor: pointer;
  transition: background 0.15s;
  user-select: none;
}

.checklist-item .check-box {
  width: 32px;
  height: 32px;
  border: 2px solid #666;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.2rem;
  transition: all 0.15s;
}

.checklist-item.checked .check-box {
  background: var(--color-success);
  border-color: var(--color-success);
}

.checklist-item.checked .check-label {
  text-decoration: line-through;
  color: var(--color-text-muted);
}

/* === RPE Slider === */
.rpe-container {
  display: flex;
  align-items: center;
  gap: 16px;
}

.rpe-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 8px;
  background: #444;
  border-radius: 4px;
  outline: none;
}

.rpe-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: var(--touch-comfortable);
  height: var(--touch-comfortable);
  border-radius: 50%;
  background: var(--color-accent);
  cursor: pointer;
  border: 3px solid white;
}

.rpe-value {
  font-size: 2rem;
  font-weight: 700;
  min-width: 48px;
  text-align: center;
}

/* === Page Layout Components === */
.page-header {
  padding: 24px 24px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.page-header .btn-back {
  width: var(--touch-comfortable);
  height: var(--touch-comfortable);
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--color-text);
  font-size: 1.5rem;
  cursor: pointer;
  border-radius: 50%;
}

.page-header .btn-back:active {
  background: var(--color-surface);
}

.page-content {
  flex: 1;
  padding: 0 24px 24px;
  overflow-y: auto;
}

.page-footer {
  padding: 16px 24px;
  border-top: 1px solid #333;
}

/* === Home Screen === */
.workout-list {
  display: grid;
  gap: 12px;
}

.workout-card .workout-meta {
  display: flex;
  gap: 16px;
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--color-text-dim);
}

.home-nav {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}

/* === Timer Screen === */
.timer-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
  user-select: none;
}

.timer-top {
  background: var(--color-accent);
  padding: 16px 24px;
  text-align: center;
  flex-shrink: 0;
  position: relative;
}

.timer-phase-badge {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.8;
}

.timer-countdown {
  font-size: clamp(64px, 15vw, 120px);
  font-weight: 900;
  line-height: 1;
  color: black;
  font-variant-numeric: tabular-nums;
}

.timer-info-bar {
  display: flex;
  justify-content: space-between;
  padding: 8px 24px;
  background: var(--color-accent);
  font-size: 0.9rem;
  font-weight: 600;
  color: rgba(0,0,0,0.7);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.timer-info-bar span {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.timer-info-bar .info-label {
  font-size: 0.7rem;
  opacity: 0.7;
}

.timer-info-bar .info-value {
  font-size: 1.1rem;
  font-weight: 700;
}

.timer-middle {
  display: flex;
  flex: 1;
  min-height: 0;
  background: var(--color-accent);
}

.timer-main-col {
  flex: 1;
  display: flex;
  gap: 16px;
  padding: 0 24px 16px;
  align-items: flex-end;
}

.timer-current-box {
  flex: 1;
  text-align: center;
}

.timer-current-box h3 {
  color: rgba(0,0,0,0.6);
  margin-bottom: 4px;
}

.timer-current-name {
  font-size: 1.6rem;
  font-weight: 700;
  color: black;
}

.timer-current-duration {
  font-size: 1.2rem;
  color: rgba(0,0,0,0.7);
}

.timer-next-box {
  flex: 1;
  background: var(--color-switch-bg);
  border-radius: var(--radius-lg);
  padding: 16px;
  text-align: center;
}

.timer-next-box h3 {
  color: #666;
  margin-bottom: 4px;
}

.timer-next-name {
  font-size: 1.3rem;
  font-weight: 700;
  color: #333;
}

.timer-next-duration {
  font-size: 1rem;
  color: #666;
}

.timer-progress {
  height: 6px;
  background: rgba(0,0,0,0.15);
  flex-shrink: 0;
}

.timer-progress-fill {
  height: 100%;
  background: rgba(255,255,255,0.6);
  transition: width 0.25s linear;
}

.timer-sidebar {
  width: 280px;
  background: var(--color-bg);
  padding: 12px;
  overflow-y: auto;
  flex-shrink: 0;
}

.timer-sidebar h3 {
  margin-bottom: 8px;
  padding: 0 8px;
}

.exercise-list {
  list-style: none;
}

.exercise-list li {
  padding: 6px 8px;
  font-size: 0.9rem;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--color-text-muted);
}

.exercise-list li.active {
  color: var(--color-active);
  font-weight: 700;
}

.exercise-list li.active::before {
  content: '>';
  margin-right: 6px;
  color: var(--color-active);
}

.exercise-list li.completed {
  color: var(--color-text-dim);
  text-decoration: line-through;
}

.timer-bottom {
  background: var(--color-teal);
  padding: 12px 24px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  min-height: 150px;
}

.timer-inputs {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 12px;
  min-height: 0;
}

.timer-controls {
  display: flex;
  gap: 12px;
  flex-shrink: 0;
  margin-top: 12px;
}

.timer-controls .btn {
  flex: 1;
}

.timer-tracking {
  display: flex;
  gap: 16px;
}

.track-input {
  display: flex;
  align-items: center;
  gap: 8px;
}

.track-input label {
  font-weight: 700;
  font-size: 1rem;
  white-space: nowrap;
}

.track-input input {
  width: 100px;
  min-height: var(--touch-min);
  padding: 8px 12px;
  background: white;
  border: none;
  border-radius: var(--radius);
  color: #333;
  font-size: 1.1rem;
  font-weight: 600;
}

.timer-rpe {
  display: flex;
  align-items: center;
  gap: 12px;
}

.timer-rpe label {
  font-weight: 700;
  font-size: 1rem;
}

.timer-rpe .rpe-slider {
  background: rgba(255,255,255,0.3);
}

/* === Timer Switch State === */
.timer-top.switch-state {
  background: var(--color-switch-bg);
}

.timer-top.switch-state .timer-countdown {
  color: #333;
}

.timer-top.switch-state .timer-phase-badge {
  color: #666;
}

.timer-middle.switch-state {
  background: var(--color-switch-bg);
}

.timer-info-bar.switch-state {
  background: var(--color-switch-bg);
}

/* === Timer Paused === */
.timer-top.paused .timer-countdown {
  animation: blink 1s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* === History Screen === */
.session-list {
  display: grid;
  gap: 12px;
}

.session-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  cursor: pointer;
  transition: background 0.15s;
}

.session-card:active {
  background: var(--color-surface-hover);
}

.session-card .session-date {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.session-card .session-name {
  font-size: 1.2rem;
  font-weight: 700;
}

.session-card .session-stats {
  display: flex;
  gap: 16px;
  margin-top: 8px;
  font-size: 0.9rem;
  color: var(--color-text-dim);
}

.session-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}

.stat-card .stat-value {
  font-size: 1.8rem;
  font-weight: 700;
}

.stat-card .stat-label {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.interval-table {
  width: 100%;
  border-collapse: collapse;
}

.interval-table th,
.interval-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid #333;
}

.interval-table th {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

/* === Completion / Post-Survey States === */
.completion-badge {
  display: inline-flex;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
}

.completion-badge.yes { background: var(--color-success); color: white; }
.completion-badge.partially { background: var(--color-warning); color: black; }
.completion-badge.no { background: var(--color-active); color: white; }

/* === Utility === */
.text-center { text-align: center; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.gap-12 { gap: 12px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* === Scrollbar Styling === */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #444;
  border-radius: 3px;
}
