/* ============================================================
   FinishLine 2.0 – App Layout & Screens
   ============================================================ */

/* ===== SCREENS ===== */
.screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== LOGIN SCREEN ===== */
.login-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  background: linear-gradient(135deg, #FFF5F0 0%, #FFFFFF 50%, #F0F9F8 100%);
  min-height: 100vh;
}

.login-brand {
  text-align: center;
  margin-bottom: var(--space-2xl);
}

.login-logo {
  margin-bottom: var(--space-md);
}

.login-title {
  font-family: var(--font-display);
  font-size: var(--text-4xl);
  font-weight: 800;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-tagline {
  color: var(--text-secondary);
  font-size: var(--text-lg);
  margin-top: var(--space-xs);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  box-shadow: var(--shadow-lg);
}

.login-card h3 {
  margin-bottom: var(--space-lg);
  text-align: center;
}

.form-group {
  margin-bottom: var(--space-md);
}

.form-group label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}

.form-error {
  margin-top: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: var(--error-light);
  color: var(--error);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
}

/* Password visibility toggle */
.input-password-wrap {
  position: relative;
}
.input-password-wrap .input {
  padding-right: 48px;
}
.btn-pw-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: color var(--duration-fast);
  padding: 0;
}
.btn-pw-toggle:hover {
  color: var(--accent);
}
.btn-pw-toggle svg {
  width: 20px;
  height: 20px;
}

.login-links {
  display: flex;
  justify-content: space-between;
  margin-top: var(--space-md);
}

.login-links a {
  font-size: var(--text-sm);
  color: var(--accent);
  text-decoration: none;
}
.login-links a:hover { text-decoration: underline; }

/* ===== APP HEADER ===== */
.app-header {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-lg);
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  height: 60px;
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  min-width: 120px;
}
.header-right { justify-content: flex-end; position: relative; }

.header-logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.header-brand {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--text-lg);
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Header Share CTA – always hidden on desktop, shown only on mobile Step 3 */
.header-share-btn { display: none; }

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-gradient);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: 700;
}

/* Language Toggle (DE/EN pill) */
.lang-toggle {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--bg-tertiary);
  border-radius: 20px;
  padding: 2px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  height: 30px;
  border: 1px solid var(--border);
  transition: border-color 0.2s;
}
.lang-toggle:hover { border-color: var(--accent); }
.lang-option {
  position: relative;
  z-index: 1;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--text-tertiary);
  transition: color 0.25s;
  line-height: 1;
}
.lang-option.active { color: #fff; }
.lang-slider {
  position: absolute;
  top: 2px;
  left: 2px;
  width: calc(50% - 2px);
  height: calc(100% - 4px);
  background: var(--accent-gradient);
  border-radius: 18px;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}
.lang-slider.right { transform: translateX(100%); }

.desktop-only { display: none; }
@media (min-width: 768px) { .desktop-only { display: inline; } }

/* Dropdown */
.dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: var(--space-xs);
  min-width: 200px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-modal);
  overflow: hidden;
}

.dropdown-header {
  padding: var(--space-md);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  font-size: var(--text-sm);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  font-size: var(--text-sm);
  color: var(--text-primary);
  text-decoration: none;
  transition: background var(--duration-fast);
}
.dropdown-item:hover { background: var(--bg-tertiary); }
.dropdown-item.text-error { color: var(--error); }

.dropdown-icon { width: 16px; height: 16px; }

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-xs) 0;
}

/* ===== MOBILE HEADER OVERRIDES ===== */
@media (max-width: 767px) {
  .header-brand { display: none; }
  .header-left { min-width: auto; }
  .lang-toggle { display: none; }
  .header-right { min-width: auto; gap: var(--space-xs); }
  .app-header { padding: var(--space-sm) var(--space-sm); }

  /* Stepper: scrollbar auf Mobile */
  .stepper {
    overflow-x: auto;
    overflow-y: hidden;
    justify-content: flex-start;
    scrollbar-width: none;
    scroll-behavior: smooth;
    flex: 1;
    min-width: 0;
    -webkit-overflow-scrolling: touch;
  }
  .stepper::-webkit-scrollbar { display: none; }

  /* Step 3: Header-Share-Button einblenden (nur Mobile) */
  body.on-step-3 .header-share-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-full);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    font-family: var(--font-body);
    transition: background var(--duration-fast);
    flex-shrink: 0;
  }
  body.on-step-3 .header-share-btn:hover {
    background: var(--accent-hover);
  }
  body.on-step-3 .header-share-btn svg {
    width: 14px;
    height: 14px;
  }

  /* Step 3: Teilen-Button aus Action-Bar entfernen (ist jetzt im Header) */
  body.on-step-3 #btn-share-step3 { display: none; }
}

/* ===== STEP CONTENT ===== */
.step-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: var(--space-lg);
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.step-hero {
  text-align: center;
  margin-bottom: var(--space-xl);
}
.step-hero.compact { margin-bottom: var(--space-md); }
.step-hero h2 { margin-bottom: var(--space-xs); }

/* Step Navigation (Back / Next) – STICKY am unteren Rand */
.step-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  margin-top: auto;
  position: sticky;
  bottom: 0;
  background: var(--bg-primary);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
  z-index: var(--z-sticky);
  margin-left: calc(-1 * var(--space-lg));
  margin-right: calc(-1 * var(--space-lg));
}

/* Step 1 Footer Left: Info-Button + Language Globe */
.step1-footer-left {
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn-info-tour {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  transition: color var(--duration-fast), background var(--duration-fast);
  padding: 0;
}
.btn-info-tour:hover {
  color: var(--accent-hover);
  background: var(--accent-light);
}
.btn-info-tour svg {
  width: 20px;
  height: 20px;
}

.btn-lang-compact {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 40px;
  padding: 0 10px;
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: color var(--duration-fast), background var(--duration-fast);
  font-family: var(--font-body);
}
.btn-lang-compact:hover {
  color: var(--accent-hover);
  background: var(--accent-light);
}
.btn-lang-compact svg {
  width: 18px;
  height: 18px;
}

/* ===== STEP 1: ACTIVITY ===== */
.step1-filter-row {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.step1-filter-row .pill-nav {
  flex: 1;
  min-width: 0;
}

.step1-filter-row .btn {
  flex-shrink: 0;
}

.strava-connect-box {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-lg);
  background: linear-gradient(135deg, #FFF5F0, #FEF0E5);
  border: 2px dashed var(--accent);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-lg);
}

.strava-connect-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.activity-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  position: relative;
  min-height: 200px;
}

.step1-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
  margin-top: var(--space-lg);
}

.step1-divider {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  width: 200px;
}
.step1-divider::before, .step1-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ===== STEP 2: TEMPLATE ===== */
.step2-layout {
  display: flex;
  gap: var(--space-xl);
  flex: 1;
}

.step2-browser {
  flex: 1;
  min-width: 0;
}

.step2-preview {
  width: 340px;
  flex-shrink: 0;
  position: sticky;
  top: 80px;
  align-self: flex-start;
}

.step2-preview .preview-area {
  border-radius: var(--radius-lg);
  min-height: 500px;
}

.preview-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
}

@media (max-width: 1023px) {
  .step2-layout { flex-direction: column; }
  .step2-preview { display: none; }
}

/* ===== STEP 3: CUSTOMIZE ===== */
.step3-layout {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.step3-preview {
  flex: 1;
  border-radius: var(--radius-lg);
}

/* Unified Action Bar: Nav + Tools + Share in one row */
.step3-action-bar {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-primary);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
  margin-top: auto;
}
.step3-action-bar .step3-nav-btn {
  flex-shrink: 0;
  white-space: nowrap;
}

.step3-tools {
  display: flex;
  gap: 2px;
  flex: 1;
  justify-content: center;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.step3-tools::-webkit-scrollbar { display: none; }

.step3-tools .toolbar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 48px;
  padding: 6px 10px;
  border: none;
  background: none;
  border-radius: var(--radius-md);
  font-size: 10px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--duration-fast), color var(--duration-fast);
  flex-shrink: 0;
}
.step3-tools .toolbar-item .toolbar-icon,
.step3-tools .toolbar-item svg {
  width: 20px;
  height: 20px;
}
.step3-tools .toolbar-item:hover {
  background: var(--bg-tertiary);
}
.step3-tools .toolbar-item.active {
  background: var(--accent-light);
  color: var(--accent);
}

/* Mobile: hide tool labels, show only icons, ensure scrollable */
@media (max-width: 767px) {
  /* Step 3: remove bottom padding so sticky bar sits flush at viewport edge */
  #step-3.step-content {
    padding-bottom: 0;
  }

  .step3-action-bar {
    position: sticky;
    bottom: 0;
    z-index: 10;
    padding: var(--space-xs) var(--space-sm);
    gap: 2px;
  }
  .step3-tools .toolbar-item span {
    display: none;
  }
  .step3-tools .toolbar-item {
    min-width: 36px;
    padding: 6px;
  }
  .step3-tools {
    justify-content: flex-start;
    /* Fade hint on edges to indicate scroll */
    mask-image: linear-gradient(90deg, transparent 0%, black 8%, black 92%, transparent 100%);
    -webkit-mask-image: linear-gradient(90deg, transparent 0%, black 8%, black 92%, transparent 100%);
    padding: 0 4px;
  }
  .step3-action-bar .step3-nav-btn span {
    display: none;
  }
  .step3-action-bar .step3-nav-btn {
    padding: 6px;
    min-width: 36px;
  }
  .step3-undo-redo {
    gap: 0;
  }
  .step3-undo-redo .toolbar-item {
    padding: 4px 5px;
  }
  .step3-reset-btn {
    padding: 4px 6px !important;
    margin-right: 2px;
    padding-right: 6px !important;
  }
  .step3-reset-btn span {
    display: none;
  }

  /* Expand Button (mobile only) – accent color to draw attention */
  .step3-expand-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    border: 1.5px solid var(--accent);
    background: var(--accent-light);
    color: var(--accent);
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    transition: background var(--duration-fast), color var(--duration-fast), border-color var(--duration-fast);
  }
  .step3-expand-btn:hover,
  .step3-expand-btn:active {
    border-color: var(--accent-hover);
    color: white;
    background: var(--accent);
  }
  .step3-expand-btn svg {
    width: 16px;
    height: 16px;
    transition: transform var(--duration-normal);
  }

  /* Expanded state: toolbar becomes grid */
  .step3-action-bar.expanded {
    flex-wrap: wrap;
    padding: var(--space-sm);
    gap: var(--space-xs);
  }
  .step3-action-bar.expanded .step3-tools {
    order: 10;
    flex-basis: 100%;
    flex-wrap: wrap;
    justify-content: center;
    overflow: visible;
    gap: 4px;
    padding: var(--space-xs) 0 0;
    border-top: 1px solid var(--border);
    mask-image: none;
    -webkit-mask-image: none;
  }
  .step3-action-bar.expanded .step3-tools .toolbar-item {
    min-width: 52px;
    padding: 6px 8px;
  }
  .step3-action-bar.expanded .step3-tools .toolbar-item span {
    display: block;
    font-size: 9px;
  }
  .step3-action-bar.expanded .step3-expand-btn svg {
    transform: rotate(180deg);
  }
}

/* Hide expand button on desktop (768px+) */
@media (min-width: 768px) {
  .step3-expand-btn {
    display: none;
  }
}

/* ===== KONVA TEXT OVERLAY LAYER ===== */
#konva-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  touch-action: none;
}
/* Konva stage is sized to match container CSS dimensions via JS.
   No CSS override needed – stage.scale() handles the 1080x1920 mapping. */

/* Reset button in action bar */
.step3-reset-btn {
  color: var(--text-tertiary) !important;
  margin-right: 4px;
  border-right: 1px solid var(--border);
  padding-right: 10px !important;
}
.step3-reset-btn:hover {
  color: var(--error) !important;
}

/* Text overlay style presets */
.text-style-presets {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.text-style-presets .btn {
  flex: 1;
  min-width: 0;
  font-size: 11px;
  padding: 6px 4px;
}

/* Text overlay editing hint */
.text-overlay-hint {
  line-height: 1.5;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent);
}

/* Selected overlay card highlight */
.text-overlay-card.selected {
  border-color: var(--accent);
  background: var(--accent-light);
}

/* Stats-Tool Styles */
.stats-tool-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stats-tool-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
}
.stats-tool-item.no-data { opacity: 0.5; }
.stats-tool-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  flex-shrink: 0;
}
.stats-tool-label { flex: 1; }
.stats-tool-arrows {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}
.stats-tool-arrows button {
  padding: 2px 4px;
  min-width: 28px;
  min-height: 28px;
  height: 28px;
}
.stats-tool-arrows button svg,
.stats-tool-arrows button i {
  width: 16px;
  height: 16px;
}

/* ===== STEP 4: EXPORT ===== */
.step4-layout {
  display: flex;
  gap: var(--space-2xl);
  flex: 1;
  align-items: center;
}

.step4-preview {
  flex: 1;
  border-radius: var(--radius-lg);
  max-width: 400px;
}

.step4-options {
  flex: 1;
}

.export-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

@media (max-width: 767px) {
  .step4-layout { flex-direction: column; gap: var(--space-sm); }
  .step4-preview { max-width: 100%; flex: none; min-height: auto; }
  /* Cap preview height so export cards are visible without scrolling */
  .step4-preview .preview-frame { max-height: 33vh; }
  .step4-options h2 { font-size: var(--text-lg); margin-bottom: var(--space-2xs); }
  .step4-options .mb-md { margin-bottom: var(--space-xs) !important; }
  .export-list { gap: var(--space-sm); }
}

/* Video Loop Selector */
.video-options-panel {
  margin-top: var(--space-md);
  padding: var(--space-md);
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
}
.video-options-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}
.video-options-header h3 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
}
.video-start-btn {
  width: 100%;
  justify-content: center;
  gap: var(--space-xs);
  font-size: 1rem;
  padding: 14px 24px;
}
.loop-pills {
  display: flex;
  gap: var(--space-xs);
}
.loop-pill {
  flex: 1;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  border: 2px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-secondary);
  transition: all 0.15s ease;
  text-align: center;
}
.loop-pill:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}
.loop-pill.active {
  border-color: var(--accent);
  background: rgba(255, 107, 53, 0.08);
  color: var(--accent);
}
.fps-pills {
  display: flex;
  gap: var(--space-xs);
}
.fps-pill {
  flex: 1;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  border: 2px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-secondary);
  transition: all 0.15s ease;
  text-align: center;
}
.fps-pill:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}
.fps-pill.active {
  border-color: var(--accent);
  background: rgba(255, 107, 53, 0.08);
  color: var(--accent);
}

/* ===== COLOR TOOL ===== */

/* Color section grouping */
.color-section {
  padding-bottom: var(--space-md);
}
.color-section + .color-section {
  border-top: 1px solid var(--border);
  padding-top: var(--space-md);
}

/* Custom color row (picker + hex input) */
.color-custom {
  display: flex;
  gap: 8px;
  align-items: center;
}
.color-custom input[type="color"] {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  padding: 2px;
  background: var(--bg-secondary);
  -webkit-appearance: none;
  appearance: none;
}
.color-custom input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 2px;
}
.color-custom input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 4px;
}

/* Color swatches */
.color-swatches {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.color-swatch {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: all var(--duration-fast);
  box-shadow: var(--shadow-sm);
}
.color-swatch:hover { transform: scale(1.1); }
.color-swatch.active { border-color: var(--text-primary); box-shadow: 0 0 0 2px white, 0 0 0 4px var(--text-primary); }

/* ===== FONT LIST (Tool: Font) ===== */
.font-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.font-item {
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background var(--duration-fast);
}
.font-item:hover { background: var(--bg-tertiary); }
.font-item.active { background: var(--accent-light); color: var(--accent); }

.font-preview {
  font-size: var(--text-lg);
}
.font-group-header {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  padding: var(--space-sm) var(--space-md) 0;
  margin-top: var(--space-sm);
  border-top: 1px solid var(--border);
}

/* ===== RANGE SLIDER (Custom) ===== */
.range-group {
  margin-bottom: var(--space-md);
}

.range-group label {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--bg-tertiary);
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

/* ===== TEMPLATE LIVE CANVAS (animated preview in grid) ===== */
.template-live-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  border-radius: inherit;
  pointer-events: none;
}

/* ===== TEMPLATE CARD ENHANCEMENTS ===== */
.template-card {
  position: relative;
  overflow: hidden;
}

.template-card img {
  width: 100%;
  aspect-ratio: 9 / 16;
  object-fit: cover;
  display: block;
}

/* Template card overlay: shown on hover, always visible for cards with loaded preview */
.template-card-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: var(--space-sm) var(--space-md);
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
  display: flex;
  flex-direction: column;
  gap: 2px;
  opacity: 0;
  transition: opacity var(--duration-fast);
}

.template-card:hover .template-card-overlay {
  opacity: 1;
}

.template-card-overlay .template-name {
  font-size: var(--text-xs);
  font-weight: 600;
  color: white;
  text-transform: capitalize;
}

.template-card .badge-animated {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  color: #fbbf24;
  padding: 1px 6px;
  background: rgba(251, 191, 36, 0.15);
  border-radius: 4px;
  width: fit-content;
}

/* ===== LOADING OVERLAY ===== */
.loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  z-index: 5;
}

/* ===== FULLSCREEN PREVIEW ===== */
.btn-fullscreen {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  backdrop-filter: blur(4px);
  transition: background var(--duration-fast);
}
.btn-fullscreen:hover {
  background: rgba(0, 0, 0, 0.75);
}
.btn-fullscreen i, .btn-fullscreen svg {
  width: 20px;
  height: 20px;
}

.fullscreen-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
}
.fullscreen-overlay.hidden {
  display: none;
}

.fullscreen-canvas-wrap {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.fullscreen-canvas-wrap canvas {
  max-height: 100%;
  max-width: 100%;
  width: auto;
  height: auto;
  border-radius: 4px;
  object-fit: contain;
}

.fullscreen-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  transition: background var(--duration-fast);
  z-index: 10;
}
.fullscreen-close:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* Floating Action Button (tools) */
.fullscreen-fab-wrap {
  position: absolute;
  bottom: 24px;
  right: 24px;
  z-index: 10;
}
.fullscreen-fab {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(255, 107, 53, 0.4);
  transition: transform var(--duration-fast), background var(--duration-fast);
}
.fullscreen-fab:hover {
  transform: scale(1.08);
  background: var(--accent-hover, #e55e2a);
}
.fullscreen-fab svg, .fullscreen-fab i {
  width: 24px;
  height: 24px;
}

/* Floating tool menu */
.fullscreen-tools {
  position: absolute;
  bottom: 68px;
  right: 0;
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  padding: var(--space-sm);
  min-width: 180px;
  animation: toolsFadeIn 0.15s ease-out;
}
.fullscreen-tools.hidden {
  display: none;
}

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

.fullscreen-tool-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border: none;
  background: none;
  color: var(--text-primary);
  width: 100%;
  cursor: pointer;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  transition: background var(--duration-fast);
}
.fullscreen-tool-item:hover {
  background: var(--bg-tertiary);
}
.fullscreen-tool-item svg, .fullscreen-tool-item i {
  width: 18px;
  height: 18px;
  color: var(--text-secondary);
}

/* ===== UTILITY CLASSES (app-specific only; base utilities in design-system.css) ===== */
.mt-sm { margin-top: var(--space-sm); }
.mb-lg { margin-bottom: var(--space-lg); }
.text-error { color: var(--error) !important; }

/* ===== SUCCESS ANIMATION ===== */
.success-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-toast);
  pointer-events: none;
  animation: successPulse 1.5s ease forwards;
}

.success-check {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--success, #10B981);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: successScale 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  box-shadow: 0 4px 24px rgba(16, 185, 129, 0.4);
}

.success-check svg { width: 40px; height: 40px; color: white; }

@keyframes successScale {
  from { transform: scale(0); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes successPulse {
  0% { opacity: 1; }
  70% { opacity: 1; }
  100% { opacity: 0; }
}

/* ===== SKELETON LOADING ===== */
.skeleton {
  background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-secondary) 50%, var(--bg-tertiary) 75%);
  background-size: 200% 100%;
  animation: skeleton 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeleton {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-template {
  aspect-ratio: 9 / 16;
  border-radius: var(--radius-md);
}

/* ===== EMPTY STATE ===== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  padding: var(--space-2xl);
  text-align: center;
  color: var(--text-tertiary);
}
.empty-state-icon { font-size: 3rem; opacity: 0.5; }

/* Focus visible for accessibility */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Smooth page transitions */
.step-content {
  animation: fadeIn 0.3s var(--ease-default);
}

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

/* ===== FEATURE 6: TEMPLATE BUILDER ===== */
.template-builder-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: var(--space-sm) 0;
  color: var(--accent);
  font-weight: 600;
  font-size: var(--text-sm);
  border: 1px dashed var(--accent);
  border-radius: var(--radius-md);
  padding: 8px 16px;
  transition: all 0.15s ease;
}
.template-builder-btn:hover {
  background: rgba(255, 107, 53, 0.08);
}

.builder-dialog h3 {
  font-size: var(--text-xl);
  font-weight: 700;
  margin-bottom: var(--space-md);
  color: var(--text-primary);
}

.builder-layouts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.builder-layout-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 12px;
  border-radius: var(--radius-md);
  border: 2px solid var(--border);
  background: var(--bg-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
}
.builder-layout-btn:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}
.builder-layout-btn.active {
  border-color: var(--accent);
  background: rgba(255, 107, 53, 0.08);
  color: var(--accent);
}
.builder-layout-icon {
  font-size: 24px;
  line-height: 1;
}

/* ===== FEATURE 7: UNDO/REDO ===== */
.step3-undo-redo {
  display: flex;
  gap: 2px;
  align-items: center;
}
.step3-undo-redo .toolbar-item {
  padding: 6px 8px;
  min-width: unset;
}
.step3-undo-redo .toolbar-icon {
  width: 16px;
  height: 16px;
}

@media (max-width: 767px) {
  .step3-undo-redo {
    /* On mobile, keep undo/redo compact */
    gap: 0;
  }
  .step3-undo-redo .toolbar-item {
    padding: 4px 6px;
  }
}

/* ===== FEATURE 8: SWIPE HINT ===== */
.swipe-hint {
  display: none;
  text-align: center;
  padding: 8px;
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}
@media (max-width: 767px) {
  .swipe-hint {
    display: block;
  }
}

/* ===== STEP 2: TEMPLATE NAME (admin debug label) ===== */
.step2-template-name {
  font-size: 10px;
  color: var(--text-tertiary);
  opacity: 0.35;
  letter-spacing: 0.03em;
  user-select: text;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

/* ===== LOADING BUTTON (Step 1 "Weiter" Ladeanimation) ===== */
.btn-loading {
  position: relative;
  overflow: hidden;
  color: var(--accent) !important;
  background: transparent !important;
  border: 2px solid var(--accent) !important;
  pointer-events: none;
}
.btn-loading::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: inherit;
  z-index: 0;
  animation: btnFillUp 4s ease-in-out forwards;
}
.btn-loading span,
.btn-loading i,
.btn-loading svg {
  position: relative;
  z-index: 1;
  mix-blend-mode: difference;
  color: white !important;
}

@keyframes btnFillUp {
  0%   { width: 0%; }
  15%  { width: 25%; }
  40%  { width: 55%; }
  65%  { width: 75%; }
  85%  { width: 88%; }
  100% { width: 95%; }
}

/* When loading is done, flash to full green */
.btn-loading.btn-loading-done::before {
  width: 100% !important;
  animation: none;
  transition: width 0.2s ease;
}

/* ===== MAP LOADING INDICATOR ===== */
.map-loading-indicator {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  border-radius: 20px;
  z-index: 15;
  backdrop-filter: blur(8px);
  opacity: 0;
  animation: mapLoadFadeIn 0.3s ease forwards;
  pointer-events: none;
}
.map-loading-indicator.fade-out {
  animation: mapLoadFadeOut 0.3s ease forwards;
}
.map-loading-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: mapLoadSpin 0.8s linear infinite;
}
@keyframes mapLoadSpin {
  to { transform: rotate(360deg); }
}
@keyframes mapLoadFadeIn {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes mapLoadFadeOut {
  from { opacity: 1; transform: translateX(-50%) translateY(0); }
  to   { opacity: 0; transform: translateX(-50%) translateY(8px); }
}

/* ===== TRACK TOOL (GPS Track Customization) ===== */
.track-style-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.track-style-grid.track-style-grid-3 {
  grid-template-columns: 1fr 1fr 1fr;
}
.track-style-grid.track-style-grid-4 {
  grid-template-columns: 1fr 1fr 1fr 1fr;
}
.track-style-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 8px;
  border-radius: var(--radius-md);
  border: 2px solid var(--border);
  background: var(--bg-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  color: var(--text-secondary);
}
.track-style-btn:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}
.track-style-btn.active {
  border-color: var(--accent);
  background: rgba(255, 107, 53, 0.08);
  color: var(--accent);
}
.track-style-icon {
  font-size: 20px;
  line-height: 1;
}
.track-style-label {
  font-size: var(--text-xs);
  font-weight: 500;
}

/* ===== FEATURE 10: AUTO-COLOR SWATCHES ===== */
.color-section .color-swatches .color-swatch {
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.color-section .color-swatches .color-swatch:active {
  transform: scale(0.9);
}

/* ===== ONBOARDING TOUR ===== */
.tour-overlay {
  position: fixed;
  inset: 0;
  z-index: 600;
  background: rgba(0, 0, 0, 0.72);
  pointer-events: auto;
}
.tour-overlay.hidden {
  display: none !important;
}

.tour-spotlight {
  position: fixed;
  border-radius: var(--radius-lg);
  background: transparent;
  border: 3px solid rgba(255, 107, 53, 0.6);
  transition: top 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              left 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.3s;
  z-index: 601;
  pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.72);
}
/* When no target: hide spotlight, overlay bg is enough */
.tour-spotlight.no-target {
  display: none;
}

.tour-tooltip {
  position: fixed;
  z-index: 602;
  background: var(--bg-primary);
  border-radius: var(--radius-xl);
  padding: var(--space-lg) var(--space-xl);
  box-shadow: var(--shadow-xl);
  max-width: 300px;
  width: calc(100vw - 48px);
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.tour-tooltip-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
}

.tour-tooltip-text {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: var(--space-md);
}

.tour-tooltip-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tour-counter {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  font-weight: 500;
}

.tour-buttons {
  display: flex;
  gap: var(--space-sm);
}

.tour-btn-skip {
  padding: 6px 12px;
  border: none;
  background: none;
  color: var(--text-tertiary);
  font-size: var(--text-sm);
  cursor: pointer;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  transition: color var(--duration-fast);
}
.tour-btn-skip:hover {
  color: var(--text-primary);
}

.tour-btn-next {
  padding: 6px 16px;
  border: none;
  background: var(--accent-gradient);
  color: #fff;
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-full);
  font-family: var(--font-body);
  transition: opacity var(--duration-fast);
}
.tour-btn-next:hover {
  opacity: 0.9;
}
