/* ==========================================================================
   THE CYCLIST BODY RESET — MVP APPLICATION STYLESHEET
   Visual System: Tarmac & Signal (Carbon Tarmac #11161B & Solar Signal #FF4800)
   Mobile-First • Zero Dependencies • Fast • High Contrast
   ========================================================================== */

:root {
  /* Color System */
  color-scheme: light;
  --bg-core: #F4F6F8;
  --bg-card: #FFFFFF;
  --bg-card-hover: #F1F4F6;
  --bg-card-active: #E7EBEF;
  --border-subtle: #D9E0E6;
  --border-focus: #AAB6C2;
  
  --text-white: #17212B;
  --text-light: #263442;
  --text-secondary: #526171;
  --text-muted: #6B7785;
  
  --accent-signal: #FF4800;
  --accent-signal-hover: #FF6629;
  --accent-signal-subtle: rgba(255, 72, 0, 0.10);
  
  /* Phase Accents */
  --phase-move: #38BDF8;
  --phase-activate: #34D399;
  --phase-build: #F59E0B;
  --phase-control: #A78BFA;
  --phase-reset: #FF4800;
  
  --success: #10B981;
  --success-bg: rgba(16, 185, 129, 0.12);
  
  /* Typography */
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  
  /* Layout & Spacing */
  --max-width: 960px;
  --nav-height: 64px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 1px 3px rgba(24, 39, 54, 0.08);
  --shadow-md: 0 4px 12px rgba(24, 39, 54, 0.10);
  --shadow-lg: 0 12px 28px rgba(24, 39, 54, 0.16);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg-core: #11161B;
  --bg-card: #182028;
  --bg-card-hover: #222C38;
  --bg-card-active: #2C3847;
  --border-subtle: #2A3644;
  --border-focus: #3F5268;
  --text-white: #FFFFFF;
  --text-light: #F1F5F9;
  --text-secondary: #94A3B8;
  --text-muted: #94A3B8;
  --accent-signal-subtle: rgba(255, 72, 0, 0.15);
  --success-bg: rgba(16, 185, 129, 0.15);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 28px rgba(0,0,0,0.6);
}

/* Base Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-core);
  color: var(--text-light);
  font-family: var(--font-family);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--nav-height) + 24px);
  min-height: 100vh;
}

/* Typography Helpers */
h1, h2, h3, h4 {
  color: var(--text-white);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

p {
  color: var(--text-secondary);
}

strong {
  color: var(--text-white);
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

button:focus-visible, [role="button"]:focus-visible, input:focus-visible {
  outline: 3px solid var(--accent-signal);
  outline-offset: 3px;
}

/* App Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background-color: color-mix(in srgb, var(--bg-core) 95%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 16px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  cursor: pointer;
}

.brand-logo-icon {
  width: 28px;
  height: 28px;
  background-color: var(--accent-signal);
  color: #fff;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 14px;
}

.brand-title {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-white);
}

.brand-subtitle {
  font-size: 11px;
  color: var(--accent-signal);
  font-weight: 600;
  letter-spacing: 0.04em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  background: var(--bg-card);
  color: var(--text-light);
  font-size: 12px;
  font-weight: 700;
}

.theme-toggle:hover { background: var(--bg-card-hover); }
.theme-toggle-icon { color: var(--accent-signal); display: inline-flex; align-items: center; }
.theme-toggle-icon svg { width: 16px; height: 16px; }
.theme-toggle-icon .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle-icon .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle-icon .icon-sun { display: inline; }

@media (max-width: 390px) {
  .theme-toggle-label { display: none; }
  .theme-toggle { padding: 0 9px; }
  .quick-streak-badge { padding-left: 7px; padding-right: 7px; }
}

.quick-streak-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-light);
}

.quick-streak-badge .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--success);
}

/* App Container */
.app-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 20px 16px;
}

/* Persistent bottom navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background-color: color-mix(in srgb, var(--bg-core) 96%, transparent);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-subtle);
  height: var(--nav-height);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 0 8px;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 6px 4px;
  border-radius: var(--radius-md);
  transition: all 0.15s ease;
  min-width: 0;
  white-space: nowrap;
}

.nav-item svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

.nav-item.active {
  color: var(--accent-signal);
}

.nav-item:hover {
  color: var(--text-white);
}

/* View Sections */
.view-section {
  display: none;
  animation: fadeIn 0.2s ease-in-out;
}

.view-section.active {
  display: block;
}

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

/* Buttons */
.btn-primary {
  background-color: var(--accent-signal);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  padding: 14px 24px;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  letter-spacing: 0.02em;
  transition: background 0.15s ease, transform 0.1s ease;
  width: 100%;
  box-shadow: var(--shadow-md);
}

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

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

.btn-primary:disabled {
  opacity: .48;
  cursor: not-allowed;
  box-shadow: none;
}

[hidden] { display: none !important; }

.checkin-save-hint {
  margin-top: 8px;
  text-align: center;
  font-size: 12px;
}

.btn-secondary {
  background-color: var(--bg-card);
  color: var(--text-light);
  border: 1px solid var(--border-subtle);
  font-weight: 600;
  font-size: 14px;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.15s ease;
}

.btn-secondary:hover {
  background-color: var(--bg-card-hover);
  border-color: var(--border-focus);
  color: #fff;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-sm);
}

/* Cards */
.cbr-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.cbr-card-clickable {
  cursor: pointer;
}

.cbr-card-clickable:hover {
  border-color: var(--border-focus);
  transform: translateY(-2px);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.badge-move { background: rgba(56, 189, 248, 0.15); color: var(--phase-move); border: 1px solid rgba(56, 189, 248, 0.3); }
.badge-activate { background: rgba(52, 211, 153, 0.15); color: var(--phase-activate); border: 1px solid rgba(52, 211, 153, 0.3); }
.badge-build { background: rgba(245, 158, 11, 0.15); color: var(--phase-build); border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-control { background: rgba(167, 139, 250, 0.15); color: var(--phase-control); border: 1px solid rgba(167, 139, 250, 0.3); }
.badge-reset, .badge-thereset { background: rgba(255, 72, 0, 0.15); color: var(--phase-reset); border: 1px solid rgba(255, 72, 0, 0.3); }
.badge-success { background: var(--success-bg); color: var(--success); }

/* ==========================================================================
   VIEW 1: HOME / COVER & START HERE
   ========================================================================== */

.hero-cover {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.95fr);
  align-items: center;
  gap: 22px;
  text-align: left;
  padding: 22px;
  background: radial-gradient(circle at 50% 20%, rgba(255, 72, 0, 0.10) 0%, transparent 70%);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  margin-bottom: 24px;
}

.hero-cover-content { min-width: 0; }

.hero-cover-image {
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-card-hover);
}

.hero-cover-image img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  object-position: 34% center;
}

.hero-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background-color: var(--accent-signal-subtle);
  color: var(--accent-signal);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  margin-bottom: 14px;
  border: 1px solid rgba(255, 72, 0, 0.3);
}

.hero-title {
  font-size: clamp(24px, 3.4vw, 36px);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.hero-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 20px;
}

.hero-graphic-wrap {
  margin: 16px auto 24px;
  max-width: 280px;
}

.bike-graphic-svg {
  width: 100%;
  height: auto;
}

.exercise-image-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
  height: 100%;
}

.exercise-image-pair figure {
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-card-hover);
}

.exercise-image-pair img {
  width: 100%;
  height: 100%;
  min-height: 0;
  flex: 1;
  object-fit: contain;
  background: #F5F5F2;
}

.exercise-image-pair figcaption {
  padding: 3px 6px;
  color: var(--text-muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .08em;
  text-align: center;
}

.today-action-card {
  background: linear-gradient(135deg, var(--bg-card-hover) 0%, var(--bg-card) 100%);
  border: 1px solid var(--border-focus);
  border-left: 4px solid var(--accent-signal);
}

.card-label-small {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent-signal);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.today-title {
  font-size: 20px;
  margin-bottom: 6px;
}

.today-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

/* Start Here Steps List */
.steps-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 16px 0 24px;
}

.step-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  padding: 14px;
  border-radius: var(--radius-md);
}

.step-num-badge {
  background-color: var(--bg-card-hover);
  color: var(--text-white);
  border: 1px solid var(--border-focus);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
  flex-shrink: 0;
}

.step-content h4 {
  font-size: 14px;
  margin-bottom: 2px;
}

.step-content p {
  font-size: 13px;
  line-height: 1.4;
}

/* ==========================================================================
   VIEW 2: BODY CHECK-IN
   ========================================================================== */

.checkin-card {
  margin-bottom: 16px;
}

.checkin-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}

.checkin-name {
  font-size: 17px;
  font-weight: 700;
}

.checkin-target {
  font-size: 12px;
  color: var(--accent-signal);
  font-weight: 600;
}

.checkin-instruction {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

.score-selector-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.score-btn {
  background-color: var(--bg-card-hover);
  border: 1px solid var(--border-subtle);
  color: var(--text-light);
  height: 44px;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 16px;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.score-btn:hover {
  background-color: var(--bg-card-active);
  border-color: var(--border-focus);
}

.score-btn.active {
  background-color: var(--accent-signal);
  border-color: var(--accent-signal);
  color: #fff;
  transform: scale(1.02);
}

.scale-hint-text {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  min-height: 20px;
}

.total-score-banner {
  background-color: var(--bg-card);
  border: 1px solid var(--border-focus);
  padding: 16px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 20px;
}

.total-score-val {
  font-size: 24px;
  font-weight: 900;
  color: var(--accent-signal);
}

/* ==========================================================================
   VIEW 3: 30-DAY DASHBOARD
   ========================================================================== */

.phase-header-block {
  margin: 24px 0 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.phase-header-block:first-child {
  margin-top: 8px;
}

.phase-title-text {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.phase-days-count {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

.days-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

@media (min-width: 600px) {
  .days-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.day-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  width: 100%;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.15s ease;
}

.day-card:hover {
  background-color: var(--bg-card-hover);
  border-color: var(--border-focus);
}

.day-card.completed {
  border-color: rgba(16, 185, 129, 0.4);
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.05) 0%, var(--bg-card) 100%);
}

.day-card.active-day {
  border-color: var(--accent-signal);
  box-shadow: 0 0 0 1px var(--accent-signal);
}

.day-card-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.day-number-badge {
  font-size: 13px;
  font-weight: 800;
  font-family: var(--font-mono);
  background-color: var(--bg-card-hover);
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-light);
  min-width: 38px;
  text-align: center;
}

.day-status-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--border-focus);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: transparent;
}

.day-card.completed .day-status-icon {
  background-color: var(--success);
  border-color: var(--success);
  color: #fff;
}

/* ==========================================================================
   VIEW 4: ACTIVE DAILY SESSION
   ========================================================================== */

.session-header-card {
  background: linear-gradient(180deg, var(--bg-card-hover) 0%, var(--bg-card) 100%);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 20px;
}

.session-top-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.session-day-title {
  font-size: 24px;
  margin-bottom: 8px;
}

.cycling-transfer-callout {
  background-color: rgba(255, 72, 0, 0.08);
  border-left: 3px solid var(--accent-signal);
  padding: 10px 12px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 13px;
  color: var(--text-light);
  margin-top: 12px;
  line-height: 1.4;
}

.cycling-transfer-callout strong {
  color: var(--accent-signal);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.05em;
  display: block;
  margin-bottom: 2px;
}

.day-card:focus-visible { outline-offset: 1px; }

.day-info-text strong {
  display: block;
  color: var(--text-white);
  font-size: 14px;
  line-height: 1.25;
  margin-bottom: 2px;
}

.day-card[role="button"] { color: var(--text-light); }
.day-info-text > span { display: block; font-size: 12px; color: var(--text-secondary); }

@media (max-width: 599px) {
  .hero-cover { grid-template-columns: 1fr; gap: 16px; padding: 16px; }
  .hero-cover-image { order: -1; }
  .hero-cover-image img { aspect-ratio: 16 / 10; object-position: 34% 45%; }
  .hero-cover-content { text-align: center; }
  .hero-pill { margin-bottom: 10px; }
  .hero-subtitle { margin-bottom: 14px; }
}

.session-mode-choice {
  padding: 18px;
  margin-bottom: 16px;
  border: 1px solid var(--border-focus);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
}

.session-mode-choice h3 {
  margin-bottom: 12px;
  font-size: 16px;
}

.session-mode-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.session-mode-actions button { min-height: 48px; }

.session-mode-choice p {
  margin-top: 10px;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.45;
}

.session-exercises-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 30px;
}

@media (max-width: 520px) {
  .session-mode-actions { grid-template-columns: 1fr; }
}

.session-ex-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.session-ex-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.session-ex-step {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 800;
  color: var(--accent-signal);
  margin-bottom: 2px;
}

.session-ex-title {
  font-size: 18px;
  font-weight: 700;
}

.session-ex-timing {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-white);
  background-color: var(--bg-card-hover);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.session-ex-visual {
  background-color: var(--bg-card-hover);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.session-ex-cue-box {
  background-color: var(--accent-signal-subtle);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border-left: 2px solid var(--phase-move);
}

.session-ex-cue-box p {
  font-size: 14px;
  color: var(--text-light);
}

.session-ex-cue-box strong {
  color: var(--accent-signal);
}

.session-ex-actions {
  display: flex;
  gap: 10px;
}

.session-complete-box {
  background-color: var(--bg-card);
  border: 1px solid var(--border-focus);
  padding: 24px 20px;
  border-radius: var(--radius-lg);
  text-align: center;
  margin-top: 20px;
}

.session-complete-box h3 {
  font-size: 20px;
  margin-bottom: 6px;
}

.session-complete-box p {
  font-size: 14px;
  margin-bottom: 16px;
}

/* ==========================================================================
   VIEW 5: QUICK ROUTINES
   ========================================================================== */

.qr-card {
  margin-bottom: 16px;
  border-left: 4px solid var(--accent-signal);
}

.qr-top-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}

.qr-title {
  font-size: 18px;
  font-weight: 700;
}

.qr-duration {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-signal);
}

.qr-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

.qr-ex-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.chip {
  background-color: var(--bg-card-hover);
  border: 1px solid var(--border-subtle);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  color: var(--text-light);
}

/* ==========================================================================
   VIEW 6: EXERCISE LIBRARY
   ========================================================================== */

.library-controls {
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.search-input-wrap {
  position: relative;
}

.search-input {
  width: 100%;
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  padding: 12px 16px 12px 40px;
  border-radius: var(--radius-md);
  color: var(--text-white);
  font-size: 15px;
  outline: none;
}

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

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  stroke: var(--text-muted);
}

.category-filter-pills {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}

.filter-pill {
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.filter-pill.active {
  background-color: var(--text-white);
  color: var(--bg-core);
  border-color: var(--text-white);
}

.library-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 600px) {
  .library-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.lib-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.lib-card:hover {
  background-color: var(--bg-card-hover);
  border-color: var(--border-focus);
}

.lib-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.lib-card-id {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 700;
}

.lib-card-name {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}

.lib-card-focus {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ==========================================================================
   VIEW 7: PROGRESS
   ========================================================================== */

.progress-hero-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.lib-card[role="button"]:focus-visible { outline-offset: 1px; }

@media (min-width: 600px) {
  .progress-hero-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.stat-comparison-box { text-align: left; }
.stat-comparison { color: var(--text-white); font-size: 15px; font-weight: 750; line-height: 1.4; }
.stat-note { margin-top: 6px; color: var(--text-muted); font-size: 11px; line-height: 1.4; }

.stat-box {
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px;
  text-align: center;
}

.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.stat-num {
  font-size: 28px;
  font-weight: 900;
  color: var(--text-white);
  font-family: var(--font-mono);
}

.progress-bar-wrap {
  background-color: var(--bg-card-hover);
  height: 8px;
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-top: 10px;
}

.progress-bar-fill {
  background-color: var(--accent-signal);
  height: 100%;
  width: 0%;
  transition: width 0.3s ease;
}

.wall-matrix-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  margin: 16px 0 24px;
}

.matrix-dot {
  width: 100%;
  aspect-ratio: 1;
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.matrix-dot.completed {
  background-color: var(--success);
  border-color: var(--success);
  color: #fff;
  font-weight: 800;
}

.matrix-dot.current {
  border-color: var(--accent-signal);
  box-shadow: 0 0 0 1px var(--accent-signal);
  color: var(--accent-signal);
  font-weight: 800;
}

/* ==========================================================================
   MODALS: EXERCISE DETAIL & SESSION COMPLETE
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop.active {
  display: flex;
}

.modal-window {
  background-color: var(--bg-card);
  border: 1px solid var(--border-focus);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background-color: var(--bg-card);
  z-index: 2;
}

.modal-title-wrap h3 {
  font-size: 18px;
}

.modal-title-wrap p {
  font-size: 12px;
  color: var(--accent-signal);
  font-family: var(--font-mono);
}

.modal-close-btn {
  background-color: var(--bg-card-hover);
  border: 1px solid var(--border-subtle);
  color: var(--text-light);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.modal-body {
  padding: 20px;
}

.guided-session-window { max-width: 720px; }
.guided-session-window .modal-header { gap: 10px; }
.guided-header-actions { display: flex; align-items: center; gap: 8px; }
.guided-voice-options { margin: 0 20px 8px; color: var(--text-secondary); }
.guided-voice-options summary { min-height: 40px; padding: 11px 0; color: var(--text-white); font-size: 11px; font-weight: 800; letter-spacing: .06em; cursor: pointer; }
.guided-voice-picker-row { display: flex; gap: 8px; align-items: center; }
.guided-voice-picker-row select { flex: 1; min-width: 0; min-height: 44px; padding: 8px 10px; border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); background: var(--bg-card); color: var(--text-white); font: inherit; }
.guided-voice-picker-row select:disabled, .guided-voice-picker-row button:disabled { opacity: .55; }
#guided-voice-help { margin: 7px 0 0; color: var(--text-muted); font-size: 11px; line-height: 1.45; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.guided-session-body { overflow-y: auto; }
.guided-progress-track { height: 5px; margin-bottom: 16px; overflow: hidden; border-radius: 99px; background: var(--bg-card-active); }
.guided-progress-track span { display: block; height: 100%; background: var(--accent-signal); transition: width .2s ease; }
.guided-movement-visual { height: 210px; margin-bottom: 12px; }
.guided-key-cue { border-left: 3px solid var(--accent-signal); padding: 10px 12px; background: var(--accent-signal-subtle); }
.guided-speak-button { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 44px; margin: 4px 0 14px; }
.guided-timer-panel { margin-top: 16px; padding: 18px; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--bg-card-hover); text-align: center; }
.guided-timer-side { color: var(--accent-signal); font-size: 12px; font-weight: 850; letter-spacing: .08em; }
.guided-timer-display { display: block; margin: 3px 0; color: var(--text-white); font: 900 54px/1.1 var(--font-mono); font-variant-numeric: tabular-nums; }
.guided-timer-caption, .guided-timer-status { color: var(--text-secondary); font-size: 13px; }
.guided-timer-status { min-height: 20px; margin: 4px 0 12px; }
.guided-timer-button { max-width: 300px; }
.guided-timer-actions { display: flex; justify-content: center; gap: 10px; }
.guided-session-controls { display: flex; gap: 8px; padding: 0 20px 10px; justify-content: flex-end; }
.guided-session-controls > button {
  flex: 1;
  padding: 8px 14px !important;
  font-size: 13px !important;
  font-weight: 700 !important;
  min-height: 38px;
  border-radius: var(--radius-sm) !important;
}
.guided-wake-hint { padding: 0 20px 10px; color: var(--text-muted); font-size: 11px; text-align: center; }

@media (max-width: 520px) {
  .guided-session-window { max-height: 96vh; }
  .guided-session-window .modal-header { align-items: flex-start; }
  .guided-header-actions { gap: 4px; }
  .guided-header-actions .btn-sm { padding: 6px 8px; font-size: 10px; }
  .guided-voice-options { margin-left: 14px; margin-right: 14px; }
  .guided-voice-picker-row { align-items: stretch; }
  .guided-session-body { padding: 14px; }
  .guided-movement-visual { height: 160px; }
  .guided-timer-actions { flex-direction: column; }
  .guided-timer-button, .guided-timer-reset { width: 100%; max-width: none; }
  .guided-session-controls { padding-left: 14px; padding-right: 14px; }
}

.detail-section {
  margin-bottom: 16px;
}

.detail-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-signal);
  font-weight: 800;
  margin-bottom: 4px;
}

.detail-text {
  font-size: 14px;
  color: var(--text-light);
  line-height: 1.5;
}

.exercise-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 10px 0 14px;
}

.exercise-meta-item {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-card-hover);
}

.exercise-meta-item span {
  display: block;
  margin-bottom: 4px;
  color: var(--accent-signal);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .06em;
}

.exercise-meta-item strong {
  display: block;
  color: var(--text-light);
  font-size: 12px;
  line-height: 1.35;
}

.lib-card-equipment {
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 11px;
  padding: 0;
  font-weight: 700;
}

.routine-movement-list { display: flex; flex-direction: column; gap: 14px; }
.routine-movement-card {
  padding: 14px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-card);
}
.routine-movement-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--text-white);
}
.routine-movement-heading > div { display: flex; align-items: flex-start; gap: 8px; }
.routine-movement-heading strong { font-size: 14px; line-height: 1.35; }
.routine-step-number { color: var(--accent-signal); font: 800 12px var(--font-mono); }
.routine-image { height: 116px; margin-top: 10px; }

/* Video Mockup Player */
.video-player-mockup {
  background-color: #0B0E11;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-focus);
  aspect-ratio: 16 / 9;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
  position: relative;
  margin-bottom: 16px;
}

.video-play-icon {
  width: 56px;
  height: 56px;
  background-color: var(--accent-signal);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  color: #fff;
  box-shadow: 0 0 20px rgba(255, 72, 0, 0.4);
}

.video-player-tag {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-white);
  font-family: var(--font-mono);
}

.video-player-sub {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Completion Celebration Modal */
.celebrate-card {
  text-align: center;
  padding: 30px 20px;
}

.trophy-badge {
  font-size: 48px;
  margin-bottom: 12px;
}

/* ==========================================================================
   VERSION 2.1 REFINEMENTS: TIMERS, ACCORDIONS & COMPATIBILITY
   ========================================================================== */

/* Integrated In-App Timer Box */
.inapp-timer-box {
  background-color: var(--bg-card-hover);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}

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

.timer-digits {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 800;
  color: var(--accent-signal);
  min-width: 50px;
}

.timer-side-label { min-width: 94px; color: var(--accent-signal); font-size: 10px; font-weight: 850; letter-spacing: .05em; }

.timer-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 700;
}

.timer-btn-action {
  background-color: var(--accent-signal);
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  letter-spacing: 0.03em;
  transition: all 0.15s ease;
}

.timer-btn-action.running {
  background-color: #EF4444;
}

/* Inline Accordion Details */
.inline-tech-details {
  display: none;
  background-color: var(--bg-card-hover);
  border-top: 1px solid var(--border-subtle);
  padding: 14px 4px 6px;
  margin-top: 8px;
}

.inline-tech-details.open {
  display: block;
  animation: fadeIn 0.2s ease-in-out;
}

/* Golden Rule Alert Banner */
.golden-rule-banner {
  background: linear-gradient(90deg, rgba(255, 72, 0, 0.15) 0%, rgba(24, 32, 40, 0.95) 100%);
  border: 1px solid var(--accent-signal);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.golden-rule-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.golden-rule-text {
  font-size: 13px;
  color: var(--text-light);
  line-height: 1.4;
}

.golden-rule-text strong {
  color: var(--accent-signal);
}

/* 5-Min Quick Reset Shortcut Pill on Home */
.quick-desk-banner {
  background-color: var(--bg-card);
  border: 1px dashed var(--accent-signal);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin-top: 12px;
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  color: var(--text-white);
  text-align: left;
  font: inherit;
  transition: all 0.15s ease;
}

.quick-desk-banner:hover {
  background-color: var(--bg-card-hover);
  border-style: solid;
}

.quick-desk-left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-white);
}

.quick-desk-tag {
  font-size: 11px;
  color: var(--accent-signal);
  font-weight: 800;
  font-family: var(--font-mono);
}

/* High Contrast Badges */
.session-ex-timing {
  background-color: var(--accent-signal) !important;
  color: #fff !important;
  font-weight: 800 !important;
}

/* Print Optimization */
@media print {
  body {
    background: #fff !important;
    color: #000 !important;
    padding-bottom: 0 !important;
  }
  .app-header, .bottom-nav, .btn-primary, .btn-secondary, .modal-backdrop {
    display: none !important;
  }
  .cbr-card {
    border: 1px solid #ccc !important;
    background: #fff !important;
    color: #000 !important;
  }
}
