/* ===== Custom Properties ===== */
:root {
  --green: #10b981;
  --green-dark: #059669;
  --green-light: #d1fae5;
  --text-primary: #1a1a1a;
  --text-secondary: #737373;
  --bg: #ffffff;
  --surface: #fafaf9;
  --border: #e5e5e5;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

body {
  font-family: var(--font);
  color: var(--text-primary);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ===== Layout ===== */
#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
  min-height: 100dvh;
}

/* ===== Typography ===== */
h1 { font-size: 20px; font-weight: 700; }
h2 { font-size: 18px; font-weight: 700; }

.label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-secondary);
}

/* ===== Buttons ===== */
.btn-primary {
  display: block;
  width: 100%;
  padding: 16px 24px;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  min-height: 48px;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--green-dark); }
.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  min-height: 44px;
  min-width: 44px;
  transition: background 0.15s;
}
.btn-secondary:hover { background: var(--border); }

/* ===== Screen Header ===== */
.screen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0 16px;
  gap: 12px;
}
.screen-header h1 { flex: 1; text-align: center; }

.back-link, .settings-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
}
.settings-link { justify-content: flex-end; font-size: 20px; }

/* ===== Home Screen ===== */
.home-header {
  text-align: center;
  padding: 32px 0 24px;
}
.home-header h1 {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 12px;
}
.home-intro {
  font-size: 14px;
  color: var(--text-secondary);
  max-width: 360px;
  margin: 0 auto;
}

.routine-cards { display: flex; flex-direction: column; gap: 12px; }

.routine-card {
  display: block;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.routine-card:hover {
  border-color: var(--green);
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.1);
}
.routine-card h2 { margin-bottom: 4px; }
.routine-meta {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.routine-categories {
  font-size: 12px;
  color: var(--green-dark);
  font-weight: 500;
}

/* ===== Exercise List (Routine Overview) ===== */
.exercise-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 8px 0 24px;
}
.exercise-item {
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.exercise-item-number {
  font-size: 11px;
  font-weight: 700;
  color: var(--green-dark);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
}
.exercise-item-name { font-weight: 600; margin-bottom: 4px; }
.exercise-item-meta { font-size: 13px; color: var(--text-secondary); }
.exercise-item-equipment {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.action-bar {
  position: sticky;
  bottom: 0;
  padding: 16px 0;
  background: var(--bg);
}

/* ===== Exercise Transition Screen ===== */
.exercise-transition { padding-bottom: 80px; }

.exercise-progress {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.category-badge {
  display: inline-block;
  padding: 4px 10px;
  background: var(--green-light);
  color: var(--green-dark);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  text-transform: capitalize;
  margin-bottom: 8px;
}

.exercise-detail h1 { font-size: 22px; margin-bottom: 16px; }
.exercise-image {
  width: 100%;
  max-height: 200px;
  object-fit: contain;
  margin-bottom: 16px;
}
.exercise-description {
  font-size: 15px;
  color: var(--text-primary);
  line-height: 1.6;
  margin-bottom: 20px;
}

.exercise-section {
  margin-bottom: 16px;
}
.exercise-section h3 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.exercise-section p {
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.5;
}

/* Settings Panel */
.settings-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin: 20px 0;
}
.settings-panel h3 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.setting-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
}
.setting-control + .setting-control { border-top: 1px solid var(--border); }

.setting-label { font-size: 14px; font-weight: 500; }
.setting-value {
  display: flex;
  align-items: center;
  gap: 12px;
}
.setting-number {
  font-size: 16px;
  font-weight: 700;
  min-width: 32px;
  text-align: center;
}

.btn-adjust {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  font-family: var(--font);
}
.btn-adjust:hover { background: var(--surface); }
.btn-adjust:disabled { opacity: 0.3; cursor: default; }

/* ===== Exercise Active Screen ===== */
.exercise-active {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: calc(100dvh - 32px);
  padding-top: 24px;
}

.exercise-context {
  text-align: center;
  margin-bottom: 16px;
}
.exercise-progress-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.exercise-active-name {
  font-size: 18px;
  font-weight: 700;
}

.timer-display {
  position: relative;
  width: 280px;
  height: 280px;
  margin-bottom: 24px;
}

.ring-timer { width: 100%; height: 100%; }

.ring-track {
  fill: none;
  stroke: var(--border);
  stroke-width: 8;
}
.ring-progress {
  fill: none;
  stroke: var(--green);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.1s linear;
}

.timer-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
}
.timer-seconds {
  font-size: 80px;
  font-weight: 800;
  line-height: 1;
  color: var(--text-primary);
}
.timer-label {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-secondary);
  margin-top: 6px;
  max-width: 160px;
}

.set-info {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.overall-progress {
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 32px;
}
.progress-fill {
  height: 100%;
  background: var(--green);
  transition: width 0.3s ease;
  width: 0%;
}

.timer-controls {
  display: flex;
  gap: 12px;
  margin-top: auto;
  padding-bottom: 24px;
  width: 100%;
}
.timer-controls .btn-pause {
  flex: 1;
}
.btn-pause {
  padding: 14px 24px;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  min-height: 48px;
}
.btn-pause:hover { background: var(--green-dark); }

.btn-end-set {
  padding: 14px 16px;
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  min-height: 48px;
}
.btn-end-set:hover { background: var(--border); }

.dropdown-wrapper { position: relative; }
.btn-menu {
  padding: 14px 16px;
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 14px;
  font-family: var(--font);
  cursor: pointer;
  min-height: 48px;
  min-width: 48px;
}
.btn-menu:hover { background: var(--border); }
.dropdown-menu {
  display: none;
  position: absolute;
  bottom: 100%;
  right: 0;
  margin-bottom: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  overflow: hidden;
  min-width: 180px;
  z-index: 10;
}
.dropdown-menu.open { display: block; }
.dropdown-item {
  display: block;
  width: 100%;
  padding: 14px 16px;
  background: none;
  border: none;
  text-align: left;
  font-size: 14px;
  font-family: var(--font);
  cursor: pointer;
  color: var(--text-primary);
}
.dropdown-item:hover { background: var(--surface); }
.dropdown-item + .dropdown-item { border-top: 1px solid var(--border); }

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.confirm-dialog {
  background: var(--bg);
  border-radius: 16px;
  padding: 24px;
  max-width: 320px;
  width: 100%;
  text-align: center;
}
.confirm-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}
.confirm-detail {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}
.confirm-actions {
  display: flex;
  gap: 12px;
}
.confirm-actions button { flex: 1; }
.modal-content {
  background: var(--bg);
  border-radius: 16px;
  padding: 24px;
  max-width: 440px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border: none;
  background: var(--surface);
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}
.modal-close:hover { background: var(--border); }

/* ===== Routine Complete Screen ===== */
.routine-complete {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100dvh - 32px);
  text-align: center;
}
.complete-icon { font-size: 48px; margin-bottom: 16px; }
.routine-complete h1 { font-size: 24px; margin-bottom: 8px; }
.complete-summary {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 32px;
}

/* ===== Global Settings Screen ===== */
.global-settings { padding-bottom: 80px; }
.settings-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}
.settings-group h3 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.toggle-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
}
.toggle-control + .toggle-control,
.toggle-control + .setting-control,
.setting-control + .toggle-control { border-top: 1px solid var(--border); }

.toggle-switch {
  position: relative;
  width: 48px;
  height: 28px;
  appearance: none;
  -webkit-appearance: none;
  background: var(--border);
  border-radius: 14px;
  cursor: pointer;
  transition: background 0.2s;
  border: none;
}
.toggle-switch:checked { background: var(--green); }
.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.toggle-switch:checked::after { transform: translateX(20px); }

/* ===== Utility ===== */
.text-secondary { color: var(--text-secondary); }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
