/* ═════════════════════════════════════════════════════════════════════
   ANYPOD SETS — OLED HIGH-CONTRAST GYM DESIGN SYSTEM + LOOP STUDIO
   Zero external dependencies · 100% CSP Compliant
   ═════════════════════════════════════════════════════════════════════ */
:root {
  --bg-oled: #050505;
  --bg-surface: #111116;
  --bg-surface-elevated: #181820;
  --border-surface: #22222c;
  --border-subtle: #191922;

  --work-primary: #ef4444;
  --work-glow: rgba(239, 68, 68, 0.45);
  --work-bg: #220808;
  --work-badge-bg: rgba(69, 10, 10, 0.8);
  --work-badge-border: rgba(185, 28, 28, 0.6);

  --rest-primary: #06b6d4;
  --rest-glow: rgba(6, 182, 212, 0.45);
  --rest-bg: #041d24;
  --rest-badge-bg: rgba(8, 51, 68, 0.8);
  --rest-badge-border: rgba(14, 116, 144, 0.6);

  --warmup-primary: #f59e0b;
  --warmup-glow: rgba(245, 158, 11, 0.45);
  --warmup-bg: #241805;
  --warmup-badge-bg: rgba(69, 39, 4, 0.8);
  --warmup-badge-border: rgba(180, 83, 9, 0.6);

  --cooldown-primary: #10b981;
  --cooldown-glow: rgba(16, 185, 129, 0.45);
  --cooldown-bg: #052218;
  --cooldown-badge-bg: rgba(6, 78, 59, 0.8);
  --cooldown-badge-border: rgba(4, 120, 87, 0.6);

  --studio-primary: #a855f7;
  --studio-glow: rgba(168, 85, 247, 0.45);
  --active-phase-color: #ef4444;
  --beat-scale: 1;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-oled);
  color: #f3f4f6;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: manipulation;
  min-height: 100vh;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Full-screen Phase Transition Flash */
.phase-flash-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 990;
  opacity: 0;
  transition: opacity 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

.phase-flash-overlay.flash-active {
  opacity: 0.32;
  transition: none;
}

/* Ambient Beat Pulse Halo */
.ambient-beat-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(circle at 50% 42%, var(--active-phase-color) 0%, transparent 65%);
  opacity: 0.06;
  transform: scale(var(--beat-scale, 1));
  transition: background 0.4s ease, opacity 0.3s ease;
}

/* Container */
.app-container {
  max-width: 760px;
  margin: 0 auto;
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 14px 16px;
  position: relative;
  z-index: 1;
}

@media (min-width: 640px) {
  .app-container {
    padding: 20px 24px;
  }
}

/* Top Nav */
.header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-surface);
  gap: 8px;
  flex-wrap: wrap;
}

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

.brand-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: #dc2626;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 16px;
  color: #000;
  box-shadow: 0 0 14px rgba(220, 38, 38, 0.4);
  flex-shrink: 0;
}

.brand-title {
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.12em;
  color: #f9fafb;
}

.brand-title span {
  color: #ef4444;
}

.brand-subtitle {
  font-size: 10px;
  color: #9ca3af;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: -2px;
  display: block;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.btn-icon {
  background: var(--bg-surface);
  border: 1px solid var(--border-surface);
  border-radius: 11px;
  padding: 8px;
  color: #9ca3af;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.btn-icon:hover {
  border-color: #4b5563;
  color: #fff;
}

.btn-icon.active {
  background: #1f2937;
  border-color: #ef4444;
  color: #f87171;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.25);
}

/* Mode Navigation Tabs */
.mode-tabs-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border-surface);
  border-radius: 14px;
  padding: 4px;
  margin-top: 10px;
}

.mode-tab-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 10px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #9ca3af;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.18s ease;
}

.mode-tab-btn:hover {
  color: #f3f4f6;
}

.mode-tab-btn.active {
  background: #dc2626;
  border-color: #ef4444;
  color: #fff;
  box-shadow: 0 0 16px rgba(220, 38, 38, 0.35);
}

.mode-tab-btn[data-tab="studio"].active {
  background: #7e22ce;
  border-color: #a855f7;
  box-shadow: 0 0 16px rgba(168, 85, 247, 0.35);
}

/* Status Pill */
.wake-badge {
  display: none;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(69, 39, 4, 0.6);
  border: 1px solid #b45309;
  font-size: 10px;
  font-weight: 800;
  color: #fbbf24;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.wake-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fbbf24;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

/* ═════════════════════════════════════════════════════════════════════
   PLAYER VIEW (MASSIVE GYM DIGITS & HIGH CONTRAST)
   ═════════════════════════════════════════════════════════════════════ */
.player-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 12px 0 4px;
  gap: 10px;
}

.player-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.top-badges-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.interval-type-badge {
  padding: 6px 14px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  border: 1px solid transparent;
  transition: all 0.3s ease;
}

.badge-work {
  background: var(--work-badge-bg);
  border-color: var(--work-badge-border);
  color: #f87171;
}

.badge-rest {
  background: var(--rest-badge-bg);
  border-color: var(--rest-badge-border);
  color: #67e8f9;
}

.badge-warmup {
  background: var(--warmup-badge-bg);
  border-color: var(--warmup-badge-border);
  color: #fcd34d;
}

.badge-cooldown {
  background: var(--cooldown-badge-bg);
  border-color: var(--cooldown-badge-border);
  color: #6ee7b7;
}

.flow-mode-badge {
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: rgba(168, 85, 247, 0.15);
  border: 1px solid rgba(168, 85, 247, 0.45);
  color: #d8b4fe;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.round-meta {
  text-align: right;
}

.round-title {
  font-size: 13px;
  font-weight: 800;
  color: #e5e7eb;
}

.total-time-val {
  font-size: 11px;
  color: #9ca3af;
  font-family: ui-monospace, SFMono-Regular, monospace;
}

/* Segmented 30-Minute Routine Timeline Map */
.segmented-timeline-wrap {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.segmented-timeline-bar {
  display: flex;
  align-items: stretch;
  width: 100%;
  height: 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-surface);
  border-radius: 8px;
  overflow: hidden;
  padding: 2px;
  gap: 2px;
}

.seg-block {
  height: 100%;
  border-radius: 4px;
  opacity: 0.35;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.15s ease;
  position: relative;
  min-width: 3px;
}

.seg-block:hover {
  opacity: 0.85;
}

.seg-block.seg-completed {
  opacity: 0.65;
}

.seg-block.seg-active {
  opacity: 1;
  box-shadow: 0 0 10px currentColor;
  transform: scaleY(1.15);
}

.seg-block.seg-work { background: var(--work-primary); color: var(--work-primary); }
.seg-block.seg-rest { background: var(--rest-primary); color: var(--rest-primary); }
.seg-block.seg-warmup { background: var(--warmup-primary); color: var(--warmup-primary); }
.seg-block.seg-cooldown { background: var(--cooldown-primary); color: var(--cooldown-primary); }

/* Hero Timer Display */
.hero-timer-display {
  margin: auto 0;
  text-align: center;
  padding: 10px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.interval-label-heading {
  font-size: clamp(15px, 3.8vw, 20px);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #e5e7eb;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.giant-digits {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-weight: 900;
  font-size: clamp(78px, 23vw, 128px);
  line-height: 0.92;
  letter-spacing: -0.06em;
  user-select: none;
  transform: scale(var(--beat-scale, 1));
  transition: color 0.3s ease, text-shadow 0.3s ease, transform 0.08s ease-out;
}

.digits-work {
  color: var(--work-primary);
  text-shadow: 0 0 35px var(--work-glow), 0 0 70px rgba(239, 68, 68, 0.25);
}

.digits-rest {
  color: var(--rest-primary);
  text-shadow: 0 0 35px var(--rest-glow), 0 0 70px rgba(6, 182, 212, 0.25);
}

.digits-warmup {
  color: var(--warmup-primary);
  text-shadow: 0 0 35px var(--warmup-glow), 0 0 70px rgba(245, 158, 11, 0.25);
}

.digits-cooldown {
  color: var(--cooldown-primary);
  text-shadow: 0 0 35px var(--cooldown-glow), 0 0 70px rgba(16, 185, 129, 0.25);
}

/* Interval Progress Bar */
.interval-progress-wrapper {
  max-width: 500px;
  margin: 14px auto 0;
  width: 100%;
}

.progress-track {
  width: 100%;
  height: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-surface);
  border-radius: 999px;
  overflow: hidden;
  padding: 2px;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.1s linear;
}

.progress-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-family: ui-monospace, monospace;
  color: #9ca3af;
  margin-top: 5px;
  padding: 0 4px;
}

/* Live Loop Visualizer & Mini YouTube/Shorts Viewport */
.player-media-deck {
  max-width: 500px;
  width: 100%;
  margin-top: 12px;
  background: rgba(17, 17, 22, 0.9);
  border: 1px solid var(--border-surface);
  border-radius: 16px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.media-deck-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Embedded YouTube / Shorts Viewport */
.player-yt-viewport {
  width: 86px;
  height: 54px;
  border-radius: 10px;
  overflow: hidden;
  background: #000;
  border: 1px solid #374151;
  flex-shrink: 0;
  position: relative;
  display: none;
}

.player-yt-viewport.yt-shorts-mode {
  width: 54px;
  height: 86px;
}

.player-yt-viewport.yt-visible {
  display: block;
}

.player-yt-slot {
  width: 100%;
  height: 100%;
}

.media-deck-info {
  flex: 1;
  text-align: left;
  min-width: 0;
}

.audio-cue-header {
  display: flex;
  align-items: center;
  gap: 6px;
}

.audio-cue-title {
  font-size: 12px;
  font-weight: 800;
  color: #f3f4f6;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.audio-cue-sub {
  font-size: 10px;
  color: #9ca3af;
  font-family: ui-monospace, monospace;
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.audio-bpm-tag {
  font-size: 10px;
  font-family: ui-monospace, monospace;
  padding: 2px 6px;
  border-radius: 6px;
  background: #1f2937;
  color: #fbbf24;
  font-weight: 700;
}

.loop-range-pill {
  font-size: 10px;
  font-family: ui-monospace, monospace;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(168, 85, 247, 0.2);
  border: 1px solid rgba(168, 85, 247, 0.4);
  color: #e9d5ff;
}

.audio-dj-link {
  color: #9ca3af;
  text-decoration: none;
  display: flex;
  align-items: center;
  padding: 5px;
  border-radius: 8px;
  background: var(--bg-oled);
  border: 1px solid var(--border-surface);
}

.audio-dj-link:hover {
  color: #fff;
  border-color: #6b7280;
}

/* Mini Live Loop Waveform Canvas inside Player */
.player-loop-wave-wrap {
  width: 100%;
  height: 28px;
  background: var(--bg-oled);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.player-loop-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Quick On-Screen Gym Action Pills */
.gym-quick-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.btn-gym-pill {
  background: var(--bg-surface);
  border: 1px solid var(--border-surface);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 800;
  color: #d1d5db;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.btn-gym-pill:hover {
  border-color: #6b7280;
  color: #fff;
}

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

.btn-gym-pill.active-hold {
  background: rgba(168, 85, 247, 0.25);
  border-color: #a855f7;
  color: #f3e8ff;
  box-shadow: 0 0 14px rgba(168, 85, 247, 0.4);
}

.btn-gym-pill.active-beat {
  background: rgba(239, 68, 68, 0.22);
  border-color: #ef4444;
  color: #fecaca;
  box-shadow: 0 0 14px rgba(239, 68, 68, 0.35);
}

.up-next-row {
  margin-top: 10px;
  font-size: 12px;
  color: #9ca3af;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.up-next-tag {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #6b7280;
}

.up-next-label {
  font-weight: 700;
  color: #e5e7eb;
}

/* ═════════════════════════════════════════════════════════════════════
   OVERSIZED TOUCH CONTROLS (88px Primary Gym Button)
   ═════════════════════════════════════════════════════════════════════ */
.player-controls-zone {
  padding-top: 12px;
  border-top: 1px solid var(--border-surface);
}

.controls-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

@media (min-width: 480px) {
  .controls-row {
    gap: 22px;
  }
}

.btn-gym-secondary {
  width: 60px;
  height: 60px;
  border-radius: 18px;
  background: var(--bg-surface);
  border: 1px solid var(--border-surface);
  color: #d1d5db;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  transition: all 0.15s ease;
}

.btn-gym-secondary:hover {
  border-color: #4b5563;
  color: #fff;
}

.btn-gym-secondary:active {
  transform: scale(0.92);
}

.btn-gym-primary {
  width: 86px;
  height: 86px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.btn-gym-primary.state-idle {
  background: #dc2626;
  color: #fff;
  box-shadow: 0 0 35px rgba(220, 38, 38, 0.55);
  border: 4px solid rgba(239, 68, 68, 0.25);
}

.btn-gym-primary.state-idle:hover {
  background: #ef4444;
}

.btn-gym-primary.state-running {
  background: #f59e0b;
  color: #000;
  box-shadow: 0 0 35px rgba(245, 158, 11, 0.55);
  border: 4px solid rgba(245, 158, 11, 0.25);
}

.btn-gym-primary.state-running:hover {
  background: #fbbf24;
}

.overall-progress-bar {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.overall-time-label {
  font-size: 11px;
  font-family: ui-monospace, monospace;
  color: #6b7280;
  min-width: 42px;
}

.overall-track {
  flex: 1;
  height: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border-surface);
  border-radius: 999px;
  overflow: hidden;
}

.overall-fill {
  height: 100%;
  background: #d1d5db;
  border-radius: 999px;
  transition: width 0.15s linear;
}

/* ═════════════════════════════════════════════════════════════════════
   VIEW 2: ROUTINE BUILDER (THE ASSEMBLER + 30-MIN PRESETS)
   ═════════════════════════════════════════════════════════════════════ */
.builder-view {
  flex: 1;
  overflow-y: auto;
  padding: 14px 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.preset-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  gap: 8px;
  flex-wrap: wrap;
}

.preset-title {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #9ca3af;
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

@media (min-width: 520px) {
  .preset-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.preset-btn {
  background: var(--bg-oled);
  border: 1px solid var(--border-surface);
  border-radius: 12px;
  padding: 10px;
  text-align: left;
  cursor: pointer;
  color: inherit;
  transition: all 0.15s ease;
  position: relative;
}

.preset-btn:hover {
  border-color: #ef4444;
}

.preset-btn.preset-30m {
  border-color: rgba(239, 68, 68, 0.35);
  background: linear-gradient(145deg, #14080a 0%, #070709 100%);
}

.preset-btn.preset-30m:hover {
  border-color: #ef4444;
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.25);
}

.preset-badge-30m {
  display: inline-block;
  font-size: 9px;
  font-weight: 900;
  padding: 1px 5px;
  border-radius: 4px;
  background: #dc2626;
  color: #fff;
  margin-bottom: 4px;
  letter-spacing: 0.06em;
}

.preset-btn-name {
  font-size: 12px;
  font-weight: 800;
  color: #e5e7eb;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preset-btn-sub {
  font-size: 10px;
  color: #9ca3af;
  margin-top: 2px;
}

/* Saved Routines Bar */
.routine-manage-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.btn-save-routine {
  background: #dc2626;
  border: 1px solid #ef4444;
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
}

.btn-save-routine:hover {
  background: #ef4444;
}

.saved-routines-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.saved-routine-chip {
  background: var(--bg-oled);
  border: 1px solid var(--border-surface);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 700;
  color: #d1d5db;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.saved-routine-chip:hover {
  border-color: #06b6d4;
  color: #fff;
}

.saved-routine-del {
  color: #6b7280;
  font-weight: 900;
  padding: 0 2px;
}

.saved-routine-del:hover {
  color: #ef4444;
}

/* Section Card */
.section-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-surface);
  border-radius: 18px;
  padding: 14px;
  margin-bottom: 12px;
}

.section-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-surface);
  margin-bottom: 10px;
  gap: 10px;
}

.input-section-title {
  background: transparent;
  border: none;
  font-size: 14px;
  font-weight: 800;
  color: #f3f4f6;
  outline: none;
  flex: 1;
}

.repeat-selector {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-oled);
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-surface);
  font-size: 11px;
  font-weight: 800;
  color: #9ca3af;
  text-transform: uppercase;
}

.repeat-select {
  background: transparent;
  border: none;
  color: #ef4444;
  font-weight: 900;
  outline: none;
  cursor: pointer;
}

.btn-delete-section {
  background: transparent;
  border: none;
  color: #6b7280;
  cursor: pointer;
  padding: 4px;
}

.btn-delete-section:hover {
  color: #ef4444;
}

/* Block Items */
.block-item {
  padding: 12px;
  border-radius: 14px;
  background: var(--bg-oled);
  border: 1px solid var(--border-surface);
  border-left-width: 5px;
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.block-item.type-work { border-left-color: var(--work-primary); }
.block-item.type-rest { border-left-color: var(--rest-primary); }
.block-item.type-warmup { border-left-color: var(--warmup-primary); }
.block-item.type-cooldown { border-left-color: var(--cooldown-primary); }

.block-main-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.select-block-type {
  background: var(--bg-surface);
  border: 1px solid var(--border-surface);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 800;
  color: #e5e7eb;
  text-transform: uppercase;
  outline: none;
  cursor: pointer;
}

.input-block-label {
  flex: 1;
  background: transparent;
  border: none;
  font-size: 12px;
  font-weight: 700;
  color: #e5e7eb;
  outline: none;
}

.duration-input-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
}

.input-duration {
  width: 54px;
  background: var(--bg-surface);
  border: 1px solid var(--border-surface);
  border-radius: 8px;
  padding: 5px;
  text-align: center;
  font-family: ui-monospace, monospace;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  outline: none;
}

.duration-unit {
  font-size: 10px;
  color: #6b7280;
}

.btn-delete-block {
  background: transparent;
  border: none;
  color: #6b7280;
  cursor: pointer;
  padding: 4px;
}

.btn-delete-block:hover {
  color: #ef4444;
}

.block-audio-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  padding-top: 6px;
  border-top: 1px solid var(--border-subtle);
  gap: 8px;
  flex-wrap: wrap;
}

.btn-attach-audio {
  background: transparent;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  padding: 0;
  text-align: left;
}

.btn-attach-audio:hover {
  color: #e5e7eb;
}

.block-loop-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.badge-playback-mode {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid #374151;
  background: #181820;
  color: #d1d5db;
}

.badge-playback-mode.mode-loop {
  background: rgba(168, 85, 247, 0.2);
  border-color: rgba(168, 85, 247, 0.5);
  color: #e9d5ff;
}

.badge-playback-mode.mode-flow {
  background: rgba(6, 182, 212, 0.2);
  border-color: rgba(6, 182, 212, 0.5);
  color: #a5f3fc;
}

.btn-clear-audio {
  background: transparent;
  border: none;
  color: #6b7280;
  cursor: pointer;
  font-size: 10px;
}

.btn-clear-audio:hover {
  color: #ef4444;
}

.btn-add-block {
  width: 100%;
  padding: 10px;
  border-radius: 12px;
  background: var(--bg-oled);
  border: 1px dashed var(--border-surface);
  color: #9ca3af;
  font-size: 12px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  margin-top: 10px;
  transition: all 0.15s ease;
}

.btn-add-block:hover {
  border-color: #6b7280;
  color: #fff;
}

.btn-add-section {
  width: 100%;
  padding: 14px;
  border-radius: 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-surface);
  color: #e5e7eb;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-add-section:hover {
  border-color: #4b5563;
  background: var(--bg-surface-elevated);
}

/* ═════════════════════════════════════════════════════════════════════
   VIEW 3: LOOP STUDIO & CONTENT CREATOR VIEW
   ═════════════════════════════════════════════════════════════════════ */
.studio-view {
  flex: 1;
  overflow-y: auto;
  padding: 14px 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.studio-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-surface);
  border-radius: 18px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.studio-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.studio-card-title {
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #e5e7eb;
  display: flex;
  align-items: center;
  gap: 6px;
}

.studio-source-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.source-tab-btn {
  background: var(--bg-oled);
  border: 1px solid var(--border-surface);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 800;
  color: #9ca3af;
  cursor: pointer;
  transition: all 0.15s ease;
}

.source-tab-btn:hover {
  color: #fff;
}

.source-tab-btn.active {
  background: rgba(168, 85, 247, 0.2);
  border-color: #a855f7;
  color: #f3e8ff;
}

.studio-library-list {
  max-height: 175px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 2px;
}

.studio-track-row {
  background: var(--bg-oled);
  border: 1px solid var(--border-surface);
  border-radius: 10px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.studio-track-row:hover {
  border-color: #a855f7;
}

.studio-track-meta {
  min-width: 0;
  flex: 1;
}

.studio-track-title {
  font-size: 12px;
  font-weight: 800;
  color: #f3f4f6;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.studio-track-sub {
  font-size: 10px;
  color: #9ca3af;
  margin-top: 2px;
}

/* Clipper Waveform & Video Preview Deck */
.clipper-stage {
  background: var(--bg-oled);
  border: 1px solid var(--border-surface);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.clipper-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.studio-yt-preview {
  width: 120px;
  height: 68px;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #374151;
  display: none;
  flex-shrink: 0;
}

.studio-yt-preview.yt-visible {
  display: block;
}

.waveform-clipper-box {
  position: relative;
  width: 100%;
  height: 92px;
  background: #09090d;
  border: 1px solid #272733;
  border-radius: 12px;
  overflow: hidden;
  cursor: ew-resize;
  touch-action: none;
}

.studio-waveform-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.clipper-time-readout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 11px;
  color: #9ca3af;
  flex-wrap: wrap;
  gap: 6px;
}

.time-pill-in {
  color: #4ade80;
  font-weight: 800;
}

.time-pill-out {
  color: #f472b6;
  font-weight: 800;
}

.time-pill-len {
  color: #d8b4fe;
  font-weight: 800;
}

/* Quick Loop-Length & Tap IN/OUT Controls */
.clipper-controls-grid {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.loop-len-group {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.btn-loop-len {
  background: var(--bg-surface);
  border: 1px solid var(--border-surface);
  border-radius: 8px;
  padding: 6px 9px;
  font-size: 11px;
  font-weight: 800;
  font-family: ui-monospace, monospace;
  color: #d1d5db;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-loop-len:hover,
.btn-loop-len.active {
  background: #7e22ce;
  border-color: #a855f7;
  color: #fff;
}

.btn-studio-action {
  background: var(--bg-surface);
  border: 1px solid var(--border-surface);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 800;
  color: #e5e7eb;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.btn-studio-action:hover {
  border-color: #a855f7;
  color: #fff;
}

.btn-studio-action.primary-purple {
  background: #7e22ce;
  border-color: #a855f7;
  color: #fff;
}

.btn-studio-action.primary-purple:hover {
  background: #9333ea;
}

.btn-studio-action.primary-red {
  background: #dc2626;
  border-color: #ef4444;
  color: #fff;
}

.btn-studio-action.primary-red:hover {
  background: #ef4444;
}

/* Auto-Slicer 30-Min Workout Generator Card */
.autoslicer-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

@media (min-width: 520px) {
  .autoslicer-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.slicer-field {
  background: var(--bg-oled);
  border: 1px solid var(--border-surface);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.slicer-field label {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  color: #9ca3af;
}

.slicer-field select,
.slicer-field input {
  background: transparent;
  border: none;
  color: #f3f4f6;
  font-size: 12px;
  font-weight: 800;
  outline: none;
  width: 100%;
}

/* Saved Loop Crate Grid */
.loop-crate-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

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

.crate-loop-card {
  background: var(--bg-oled);
  border: 1px solid var(--border-surface);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all 0.15s ease;
}

.crate-loop-card:hover {
  border-color: #a855f7;
}

.crate-loop-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.crate-loop-title {
  font-size: 12px;
  font-weight: 800;
  color: #f3f4f6;
}

.crate-loop-meta {
  font-size: 10px;
  font-family: ui-monospace, monospace;
  color: #9ca3af;
  margin-top: 2px;
}

.crate-loop-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.btn-crate-mini {
  background: var(--bg-surface);
  border: 1px solid var(--border-surface);
  border-radius: 7px;
  padding: 4px 8px;
  font-size: 10px;
  font-weight: 800;
  color: #d1d5db;
  cursor: pointer;
}

.btn-crate-mini:hover {
  border-color: #a855f7;
  color: #fff;
}

/* ═════════════════════════════════════════════════════════════════════
   MODAL STYLES
   ═════════════════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(4px);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-surface);
  border-radius: 24px;
  max-width: 520px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 20px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.8);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-surface);
  margin-bottom: 16px;
}

.modal-title {
  font-size: 15px;
  font-weight: 800;
  color: #f3f4f6;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-modal-close {
  background: transparent;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  padding: 4px;
}

.btn-modal-close:hover {
  color: #fff;
}

.modal-subhead {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #9ca3af;
  margin-bottom: 8px;
}

.modal-sample-item {
  background: var(--bg-oled);
  border: 1px solid var(--border-surface);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.15s ease;
}

.modal-sample-item:hover {
  border-color: #ef4444;
}

.sample-name {
  font-size: 12px;
  font-weight: 800;
  color: #e5e7eb;
}

.sample-sub {
  font-size: 10px;
  color: #6b7280;
  margin-top: 2px;
}

.btn-sample-pick {
  font-size: 12px;
  font-weight: 800;
  color: #ef4444;
}

.active-ep-card {
  background: var(--bg-oled);
  border: 1px solid rgba(8, 145, 178, 0.6);
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.active-ep-card:hover {
  border-color: #06b6d4;
}

.url-form {
  background: var(--bg-oled);
  border: 1px solid var(--border-surface);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.url-input {
  background: var(--bg-surface);
  border: 1px solid var(--border-surface);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 12px;
  color: #fff;
  outline: none;
  width: 100%;
}

.btn-submit-audio {
  background: #dc2626;
  border: none;
  border-radius: 10px;
  padding: 10px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #fff;
  cursor: pointer;
}

.btn-submit-audio:hover {
  background: #ef4444;
}

.share-input-row {
  display: flex;
  gap: 8px;
  margin: 12px 0 16px;
}

.share-link-input {
  flex: 1;
  background: var(--bg-oled);
  border: 1px solid var(--border-surface);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 11px;
  font-family: ui-monospace, monospace;
  color: #d1d5db;
  outline: none;
}

.btn-copy-share {
  background: #dc2626;
  border: none;
  border-radius: 12px;
  padding: 0 18px;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  cursor: pointer;
}

.btn-copy-share:hover {
  background: #ef4444;
}

/* Toast Notification */
.sets-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #181820;
  border: 1px solid #a855f7;
  color: #f3f4f6;
  padding: 10px 18px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
}

.sets-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
