/* Guideable Web Viewer - Matches Expo App Exactly */
:root {
  --primary: #F7C948;
  --primary-dark: #E5B732;
  --text: #1A1A1A;
  --text-secondary: #6B7280;
  --bg: #FFFFFF;
  --surface: #F8F9FA;
  --border: #E5E7EB;
  --success: #10B981;
  --success-bg: rgba(34, 197, 94, 0.1);
  --safety: #FF9500;
  --safety-bg: rgba(255, 149, 0, 0.15);
  --blue: #007AFF;
  --blue-bg: rgba(0, 122, 255, 0.1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.screen { min-height: 100vh; display: flex; flex-direction: column; }
.hidden { display: none !important; }

/* Loading */
#loading-screen { justify-content: center; align-items: center; background: var(--bg); }
.loading-content { text-align: center; }
.loading-logo { height: 72px; margin-bottom: 28px; }
.loading-spinner {
  width: 28px; height: 28px; margin: 0 auto 12px;
  border: 3px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-content p { font-size: 14px; color: var(--text-secondary); font-weight: 500; }

/* Gate */
#access-gate { justify-content: center; align-items: center; padding: 24px; background: #F5F5F7; }
.gate-card {
  background: #fff; border-radius: 12px; padding: 48px 36px;
  max-width: 420px; width: 100%; text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.12), 0 0 1px rgba(0, 0, 0, 0.05);
  border: 1px solid #e5e7eb;
}
.gate-icon { 
  width: 56px; 
  height: 56px; 
  margin: 0 auto 20px; 
  color: #f7c948;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.gate-icon svg {
  width: 100%;
  height: 100%;
}
.gate-card h2 { font-size: 22px; font-weight: 700; margin-bottom: 8px; letter-spacing: -0.4px; color: #1a1a1a; }
.gate-card > p { font-size: 15px; color: #6b7280; margin-bottom: 28px; line-height: 1.5; }
.input-container { margin-bottom: 20px; }
.gate-input {
  width: 100%; padding: 14px 18px; font-size: 18px; font-weight: 600;
  border: 2px solid #e5e7eb; border-radius: 8px; text-align: center;
  letter-spacing: 3px; outline: none; transition: all 0.2s;
  background: #fff;
}
.gate-input:focus { 
  border-color: #f7c948; 
  box-shadow: 0 0 0 3px rgba(247, 201, 72, 0.15);
}
.error-message { color: #ef4444; font-size: 14px; margin-top: 12px; font-weight: 500; }
.primary-button {
  width: 100%; padding: 14px 24px; font-size: 16px; font-weight: 600;
  background: #f7c948; color: #1a1a1a; border: none; border-radius: 8px;
  cursor: pointer; transition: all 0.2s; letter-spacing: -0.2px;
}
.primary-button:hover { 
  background: #fad673; 
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(247, 201, 72, 0.25);
}

/* Header - Scribe-inspired layout */
.viewer-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  transition: top 0.3s ease;
}

/* When CTA banner is shown, push header down */
body.cta-active .viewer-header {
  top: 52px;
}

@media (max-width: 500px) {
  body.cta-active .viewer-header {
    top: 48px;
  }
}

.header-brand { display: flex; align-items: center; }
.brand-logo { height: 32px; }

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

/* Action Buttons */
.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
}

.action-btn.outline {
  width: 44px;
  height: 44px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  color: var(--text);
}
.action-btn.outline:hover {
  background: var(--surface);
  border-color: #ccc;
}

.action-btn.filled {
  padding: 12px 18px;
  background: var(--primary);
  color: var(--text);
}
.action-btn.filled:hover {
  background: var(--primary-dark);
}
.action-btn.filled svg {
  flex-shrink: 0;
}

/* CTA Banner - appears on scroll, ABOVE header */
.cta-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  background: #1A1A1A;
  transform: translateY(-100%);
  transition: transform 0.3s ease;
}
.cta-banner.show {
  transform: translateY(0);
}
.cta-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  width: 100%;
}
.cta-text {
  color: rgba(255,255,255,0.9);
  font-size: 14px;
  font-weight: 400;
  white-space: nowrap;
}
.cta-text strong {
  font-weight: 600;
  color: #fff;
}
/* Hide parts of message on smaller screens */
.cta-text .cta-long {
  display: inline;
}
.cta-text .cta-short {
  display: none;
}
.cta-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--primary);
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  flex-shrink: 0;
  transition: all 0.15s;
}
.cta-btn svg {
  width: 16px;
  height: 16px;
}
.cta-btn:hover {
  background: var(--primary-dark);
  transform: translateX(2px);
}

/* Medium screens - shorter message */
@media (max-width: 800px) {
  .cta-text .cta-long {
    display: none;
  }
  .cta-text .cta-short {
    display: inline;
  }
}

/* Small screens - even more compact */
@media (max-width: 500px) {
  .cta-banner {
    padding: 10px 16px;
  }
  .cta-content {
    gap: 12px;
  }
  .cta-text {
    font-size: 13px;
  }
  .cta-btn {
    width: 30px;
    height: 30px;
  }
}

/* Feedback Section */
.feedback-section {
  margin: 32px 0 16px;
  padding: 32px 24px;
  background: linear-gradient(135deg, #f8f7ff 0%, #fff5f5 50%, #fef9f3 100%);
  border-radius: 16px;
  text-align: center;
}
.feedback-content h3 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
  letter-spacing: -0.3px;
}
.feedback-content p {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}
.feedback-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.feedback-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
}
.feedback-btn:hover {
  border-color: var(--primary);
  background: #fffbeb;
}
.feedback-btn:active {
  transform: scale(0.97);
}
.feedback-btn svg {
  color: var(--text-secondary);
  transition: color 0.15s;
}
.feedback-btn:hover svg {
  color: var(--primary-dark);
}
.feedback-thanks {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 20px;
}
.feedback-thanks svg {
  color: var(--success);
}
.feedback-thanks span {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

@media (max-width: 480px) {
  .feedback-section {
    padding: 28px 20px;
    margin: 24px 0 12px;
  }
  .feedback-content h3 {
    font-size: 18px;
  }
  .feedback-content p {
    font-size: 14px;
  }
  .feedback-actions {
    flex-direction: column;
    gap: 10px;
  }
  .feedback-btn {
    width: 100%;
    justify-content: center;
  }
}

/* Guide Info Section */
.guide-info {
  padding: 20px 16px 16px;
  background: var(--bg);
}
.guide-info-left {
  display: flex;
  flex-direction: column;
}
.guide-info h1 {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
  color: var(--text);
}
.guide-info p {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 12px;
}
.meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
#published-date {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}
.meta-sep {
  color: var(--text-secondary);
  font-size: 12px;
}
#step-count {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* Org Badge */
.org-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 4px;
  background: var(--surface);
  border-radius: 20px;
  border: 1px solid var(--border);
}
.org-badge img {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  object-fit: cover;
}
.org-badge span {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.org-badge.hidden,
.org-sep.hidden {
  display: none;
}

/* Desktop hero video - hidden on mobile */
.desktop-hero-video {
  display: none;
}

/* Tabs */
.tab-bar { display: flex; background: var(--bg); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.tab {
  flex: 1; padding: 14px; font-size: 15px; font-weight: 600; color: var(--text-secondary);
  background: none; border: none; cursor: pointer; position: relative; transition: color 0.15s;
}
.tab.active { color: var(--text); }
.tab.active::after {
  content: ''; position: absolute; bottom: 0; left: 20%; right: 20%;
  height: 3px; background: var(--primary); border-radius: 3px 3px 0 0;
}

/* Tab Content */
.tab-content { flex: 1; padding: 12px 0 80px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Steps header - hidden on mobile */
.steps-header {
  display: none;
}

/* Step Cards - Matches EnhancedStepCard exactly */
#steps-list { display: flex; flex-direction: column; gap: 12px; padding: 0 16px; }
.step-card {
  background: var(--bg); border: 1px solid rgba(0,0,0,0.06); border-radius: 12px;
  position: relative; overflow: hidden; cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04); transition: all 0.15s;
  display: flex;
  align-items: stretch;
}
.step-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.step-card.safety { border-left: 3px solid var(--safety); }
.step-card.completed {
  opacity: 0.7;
  background: rgba(34, 197, 94, 0.05);
}

/* Step Checkbox */
.step-checkbox {
  padding: 20px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s;
}
.step-checkbox:hover {
  background: rgba(0, 0, 0, 0.02);
}
.checkbox-circle {
  width: 24px;
  height: 24px;
  border: 2px solid #e5e7eb;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #1a1a1a;
  transition: all 0.2s;
  background: #fff;
}
.checkbox-circle.checked {
  background: #f7c948;
  border-color: #f7c948;
}
.step-card.completed .checkbox-circle {
  background: #f7c948;
  border-color: #f7c948;
}

/* Corner Badge */
.corner-badge {
  position: absolute; top: 0; left: 0; padding: 6px 12px 10px 9px;
  border-bottom-right-radius: 18px; z-index: 1;
}
.corner-badge.safety { background: var(--safety-bg); }
.corner-badge.normal { background: var(--blue-bg); }
.corner-badge span { font-size: 17px; font-weight: 800; letter-spacing: -0.5px; }
.corner-badge.safety span { color: var(--safety); }
.corner-badge.normal span { color: var(--blue); }

/* Step Content */
.step-content { display: flex; padding: 12px 16px 18px; gap: 14px; flex: 1; }
.step-text { flex: 1; padding-top: 2px; padding-left: 32px; min-width: 0; }

/* When defensibility is enabled, adjust padding since checkbox provides spacing */
.step-card.has-checkbox .step-content { padding: 12px 16px 18px 0; }
.step-card.has-checkbox .step-text { padding-left: 0; }
.step-title { font-size: 18px; font-weight: 700; line-height: 1.4; letter-spacing: -0.4px; margin-bottom: 8px; }
.step-notes { font-size: 15px; line-height: 1.5; color: var(--text-secondary); margin-bottom: 10px; }

/* Ask AI Button */
.ask-ai-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 20px; border: 1px solid rgba(0,0,0,0.1);
  background: transparent; font-size: 13px; font-weight: 600; color: var(--text);
  cursor: pointer; transition: background 0.15s;
}
.ask-ai-btn:hover { background: var(--surface); }
.ask-ai-btn::before { content: '✨'; font-size: 14px; }

/* Thumbnail */
.step-thumb {
  width: 100px; height: 177px; border-radius: 8px; overflow: hidden;
  background: #f0f0f0; flex-shrink: 0; position: relative;
}
.step-thumb img { width: 100%; height: 100%; object-fit: cover; }
.step-thumb.placeholder { background: linear-gradient(135deg, #f0f0f0, #e0e0e0); }
.step-thumb.thumb-error img { display: none; }
.step-thumb.thumb-error { background: linear-gradient(135deg, #f0f0f0, #e0e0e0); }
.thumb-time {
  position: absolute; bottom: 6px; right: 6px;
  background: rgba(0,0,0,0.75); color: #fff; padding: 3px 6px;
  border-radius: 4px; font-size: 11px; font-weight: 700; letter-spacing: 0.2px;
}
.play-icon {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 32px; height: 32px; background: rgba(0,0,0,0.6); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 12px;
  opacity: 0.8; transition: opacity 0.15s;
}
.step-card.clickable { cursor: pointer; }
.step-card.clickable:hover .play-icon { opacity: 1; }
.step-card.clickable:active { transform: scale(0.98); }
.step-card.active { 
  border-color: var(--primary); 
  box-shadow: 0 0 0 2px var(--primary), 0 2px 8px rgba(0,0,0,0.08);
}

/* Completion */
.completion-card {
  background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
  color: #fff; border-radius: 16px; padding: 28px; text-align: center;
  margin: 20px 16px; box-shadow: 0 6px 20px rgba(16,185,129,0.25);
}
.completion-icon { font-size: 40px; margin-bottom: 8px; }
.completion-card h3 { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.completion-card p { font-size: 14px; opacity: 0.9; }

/* Watch Tab */
.video-wrap { padding: 0 16px; }
.video-wrap video { width: 100%; border-radius: 12px; background: #000; max-height: 70vh; }
.video-nav { padding: 16px; }
.video-nav p { font-size: 14px; font-weight: 600; color: var(--text-secondary); margin-bottom: 10px; }
#video-steps-list { display: flex; flex-wrap: wrap; gap: 8px; }
.vstep-btn {
  padding: 10px 16px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; font-size: 14px; font-weight: 500; cursor: pointer; transition: all 0.15s;
}
.vstep-btn:hover { background: var(--surface); }
.vstep-btn.active { background: var(--primary); border-color: var(--primary); font-weight: 600; }

/* Lead Banner */
.lead-banner {
  margin: 32px 0 48px 0;
  padding: 20px;
  background: linear-gradient(to right, #f8f8f8, #fff);
  border: 1px solid #e8e8e8;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
}
.lead-left {
  display: flex; flex-direction: column; gap: 4px;
}
.lead-label {
  font-size: 11px; font-weight: 600; color: var(--primary-dark); 
  text-transform: uppercase; letter-spacing: 0.5px;
}
.lead-text {
  font-size: 15px; font-weight: 600; color: var(--text);
}
.lead-cta {
  background: var(--text); color: #fff; 
  padding: 10px 18px; border-radius: 8px; 
  font-size: 14px; font-weight: 600; text-decoration: none;
  transition: all 0.15s; white-space: nowrap;
}
.lead-cta:hover { 
  background: #333;
  transform: translateY(-1px);
}

@media (max-width: 520px) {
  .lead-banner { flex-direction: column; text-align: center; gap: 14px; padding: 20px 16px; }
  .lead-left { align-items: center; }
  .lead-cta { width: 100%; text-align: center; }
}

/* Step Detail Modal - Matches App UI */
.step-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  background: #000;
}
.step-modal-bg {
  position: absolute;
  inset: 0;
  background: #000;
}

/* Top Bar - More breathing room */
.step-modal-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  padding-top: max(16px, env(safe-area-inset-top));
}
.step-modal-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 50%;
  color: rgba(255,255,255,0.9);
  cursor: pointer;
  transition: all 0.15s;
}
.step-modal-btn:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

/* Pagination Dots - More refined */
.step-modal-dots {
  display: flex;
  align-items: center;
  gap: 8px;
}
.step-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255,255,255,0.35);
  transition: all 0.25s ease;
  cursor: pointer;
}
.step-dot:hover {
  background: rgba(255,255,255,0.5);
}
.step-dot.active {
  background: var(--primary);
  transform: scale(1.1);
}

/* Media Container - Full height feel */
.step-modal-media {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 60px 48px 0;
}
.step-media-wrap {
  position: relative;
  width: 100%;
  max-width: 340px;
  aspect-ratio: 9/16;
  max-height: calc(100vh - 240px);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  overflow: hidden;
  background: #111;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}
.step-media-wrap video,
.step-media-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}
.step-media-wrap video.show,
.step-media-wrap img.show {
  display: block;
}

/* Zoom Hint - More subtle */
.step-zoom-hint {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 10px;
  color: rgba(255,255,255,0.9);
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}
.step-modal:not(.playing) .step-zoom-hint {
  opacity: 1;
}

/* Navigation Arrows - More elegant */
.step-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.08);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: none;
  border-radius: 50%;
  color: rgba(255,255,255,0.9);
  cursor: pointer;
  transition: all 0.2s ease;
  z-index: 5;
}
.step-nav-btn:hover {
  background: rgba(255,255,255,0.15);
  color: #fff;
  transform: translateY(-50%) scale(1.08);
}
.step-nav-btn:active {
  transform: translateY(-50%) scale(0.95);
}
.step-nav-btn:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}
.step-nav-btn:disabled:hover {
  background: rgba(255,255,255,0.08);
  transform: translateY(-50%);
}
.step-nav-btn.left { left: 4px; }
.step-nav-btn.right { right: 4px; }

/* Placeholder */
.step-placeholder {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: rgba(255,255,255,0.7);
  padding: 32px;
}
.step-placeholder.show {
  display: flex;
}
.step-placeholder svg {
  margin-bottom: 20px;
  opacity: 0.4;
}
.step-placeholder p {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 8px;
  color: #fff;
}
.step-placeholder span {
  font-size: 14px;
  opacity: 0.5;
  line-height: 1.5;
}

/* Bottom Info Card */
.step-modal-card {
  position: relative;
  z-index: 10;
  background: #fff;
  border-radius: 24px 24px 0 0;
  padding: 18px 20px;
  padding-bottom: max(18px, calc(env(safe-area-inset-bottom) + 8px));
  margin-top: auto;
  box-shadow: 0 -4px 30px rgba(0,0,0,0.12);
}
.step-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.step-badge {
  display: inline-block;
  padding: 5px 12px;
  background: var(--primary);
  border-radius: 16px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}
.step-time-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  background: var(--surface);
  border-radius: 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}
.step-time-badge svg {
  width: 12px;
  height: 12px;
}
.step-card-title {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.3px;
  color: var(--text);
  margin-bottom: 6px;
}
.step-card-desc {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-secondary);
  margin-bottom: 14px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.step-card-desc:empty {
  display: none;
  margin-bottom: 0;
}
.step-card-desc:empty + .step-card-nav {
  margin-top: -4px;
}
.step-card-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid rgba(0,0,0,0.06);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}
.step-card-nav svg {
  width: 14px;
  height: 14px;
  opacity: 0.4;
}

/* Mobile adjustments */
@media (max-width: 400px) {
  .step-modal-media {
    padding: 56px 40px 0;
  }
  .step-nav-btn {
    width: 38px;
    height: 38px;
  }
  .step-modal-card {
    padding: 16px 18px;
    padding-bottom: max(16px, calc(env(safe-area-inset-bottom) + 6px));
    border-radius: 20px 20px 0 0;
  }
  .step-card-title { font-size: 17px; }
  .step-card-desc { font-size: 13px; }
}

/* Tablet and desktop */
@media (min-width: 768px) {
  .step-modal-media {
    padding: 80px 80px 0;
  }
  .step-media-wrap {
    max-width: 320px;
    max-height: calc(100vh - 240px);
    border-radius: 20px;
  }
  .step-nav-btn {
    width: 48px;
    height: 48px;
  }
  .step-nav-btn.left { left: calc(50% - 220px); }
  .step-nav-btn.right { right: calc(50% - 220px); }
  .step-modal-card {
    max-width: 400px;
    margin: 0 auto;
    border-radius: 24px 24px 0 0;
  }
}

/* Error */
#error-screen { justify-content: center; align-items: center; padding: 24px; }
.error-box { text-align: center; max-width: 320px; }
.error-icon {
  width: 56px; height: 56px; margin: 0 auto 16px; background: var(--surface);
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 700; color: var(--text-secondary);
}
.error-box h2 { font-size: 22px; font-weight: 700; margin-bottom: 8px; }
.error-box p { font-size: 15px; color: var(--text-secondary); line-height: 1.5; }

/* Save Modal */
.save-modal {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: flex-end; justify-content: center;
}
.save-modal-bg {
  position: absolute; inset: 0; 
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}
.save-modal-content {
  position: relative; z-index: 1;
  width: 100%; max-width: 380px;
  background: var(--bg); 
  border-radius: 24px 24px 0 0;
  padding: 20px 20px 28px; 
  max-height: 85vh; overflow-y: auto;
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 -8px 40px rgba(0,0,0,0.12);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.save-modal-close {
  position: absolute; top: 14px; right: 14px;
  width: 28px; height: 28px; border-radius: 50%;
  background: transparent; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); transition: all 0.15s;
}
.save-modal-close svg { width: 18px; height: 18px; }
.save-modal-close:hover { background: var(--surface); color: var(--text); }

.save-view { text-align: center; padding-top: 8px; }
.save-icon {
  width: 48px; height: 48px; margin: 0 auto 14px;
  background: var(--primary);
  border-radius: 12px; 
  display: flex; align-items: center; justify-content: center;
  color: var(--text);
}
.save-icon svg { width: 24px; height: 24px; }
.save-view h2 { 
  font-size: 20px; font-weight: 700; 
  margin-bottom: 4px; letter-spacing: -0.3px; 
  color: var(--text);
}
.save-subtitle { 
  font-size: 14px; color: var(--text-secondary); 
  margin-bottom: 20px; 
}

.save-benefits {
  display: flex; flex-direction: column; gap: 10px;
  text-align: left; margin-bottom: 20px;
  background: var(--surface); border-radius: 10px; padding: 14px;
}
.benefit-item {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; color: var(--text);
}
.benefit-item svg { 
  width: 16px; height: 16px;
  color: var(--success); flex-shrink: 0; 
}

.save-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 12px 18px; border-radius: 10px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: all 0.15s; text-decoration: none; border: none;
}
.save-btn svg { width: 18px; height: 18px; }
.save-btn.primary {
  background: var(--text); color: #fff;
}
.save-btn.primary:hover { background: #333; }
.save-btn.secondary {
  background: transparent; color: var(--text-secondary);
  border: none; margin-top: 6px;
  font-weight: 500;
}
.save-btn.secondary:hover { color: var(--text); background: var(--surface); }

.save-form { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.save-input {
  width: 100%; padding: 12px 14px; font-size: 15px;
  border: 1.5px solid var(--border); border-radius: 10px;
  outline: none; transition: border-color 0.2s;
  background: var(--bg);
}
.save-input:focus { border-color: var(--primary); }
.save-input.error { border-color: #EF4444; animation: shake 0.3s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.save-signin {
  font-size: 13px; color: var(--text-secondary); margin-top: 14px;
}
.save-signin a { color: var(--text); font-weight: 600; text-decoration: none; }
.save-signin a:hover { text-decoration: underline; }

/* Tablet breakpoint */
@media (min-width: 640px) {
  .viewer-header { padding: 16px 32px; }
  .guide-info { padding: 24px 32px 20px; }
  .guide-info h1 { font-size: 28px; }
  #steps-list { padding: 0 32px; max-width: 680px; margin: 0 auto; }
  .tab-content { padding: 16px 0 100px; }
  .video-wrap, .video-nav { max-width: 640px; margin: 0 auto; padding: 0 32px; }
  
  /* Desktop save modal */
  .save-modal { align-items: center; }
  .save-modal-content { border-radius: 20px; max-width: 360px; padding: 24px; }
}

/* Desktop/Tablet breakpoint - Clean centered layout */
@media (min-width: 768px) {
  body {
    background: #F5F5F7;
  }
  
  /* CTA banner adjustments */
  .cta-banner {
    padding: 10px 24px;
  }
  .cta-text {
    font-size: 14px;
  }
  
  #guide-viewer {
    background: var(--bg);
    max-width: 680px;
    margin: 24px auto;
    border-radius: 16px;
    box-shadow: 0 2px 40px rgba(0,0,0,0.08);
    overflow: hidden;
  }
  
  body.cta-active #guide-viewer {
    margin-top: 76px;
  }
  
  /* Full-width header */
  .viewer-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    position: relative;
    top: 0;
  }
  
  body.cta-active .viewer-header {
    top: 0;
  }
  
  .brand-logo {
    height: 28px;
  }
  
  /* Guide info */
  .guide-info {
    padding: 28px 24px 20px;
  }
  
  .guide-info h1 {
    font-size: 26px;
    margin-bottom: 10px;
    letter-spacing: -0.5px;
  }
  
  .guide-info p {
    font-size: 15px;
    margin-bottom: 14px;
  }
  
  /* Hide hero video - always use modal */
  .desktop-hero-video {
    display: none;
  }
  
  /* Hide tabs on desktop */
  .tab-bar {
    display: none;
  }
  
  .tab-content {
    padding: 0;
  }
  
  .tab-panel {
    display: block !important;
  }
  
  #watch-tab {
    display: none !important;
  }
  
  /* Steps section */
  #steps-tab {
    padding: 0 24px 32px;
  }
  
  .steps-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
  }
  
  .steps-header h2 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.2px;
  }
  
  .steps-header span {
    font-size: 13px;
    color: var(--text-secondary);
  }
  
  #steps-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 0;
    max-width: none;
    margin: 0;
  }
  
  /* Larger thumbnails on tablet/desktop */
  .step-card {
    border-radius: 14px;
    transition: all 0.15s ease;
  }
  
  .step-content {
    padding: 16px 20px 20px;
    gap: 18px;
  }
  
  .step-thumb {
    width: 120px;
    height: 213px;
    border-radius: 10px;
  }
  
  .step-title {
    font-size: 19px;
  }
  
  .step-notes {
    font-size: 15px;
  }
  
  .step-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  }
  
  .step-card.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary);
  }
  
  .completion-card {
    margin: 16px 0 8px;
  }
  
  .lead-banner {
    margin: 20px 0 12px;
    border-radius: 12px;
  }
}

/* Large desktop - wider container, even larger thumbs */
@media (min-width: 1024px) {
  #guide-viewer {
    max-width: 760px;
    margin: 32px auto;
    border-radius: 20px;
  }
  
  body.cta-active #guide-viewer {
    margin-top: 76px;
  }
  
  .viewer-header {
    padding: 20px 32px;
  }
  
  .brand-logo {
    height: 30px;
  }
  
  .guide-info {
    padding: 32px 32px 24px;
  }
  
  .guide-info h1 {
    font-size: 30px;
  }
  
  .guide-info p {
    font-size: 16px;
    line-height: 1.6;
  }
  
  #steps-tab {
    padding: 0 32px 40px;
  }
  
  .steps-header {
    margin-bottom: 20px;
    padding-bottom: 16px;
  }
  
  .steps-header h2 {
    font-size: 16px;
  }
  
  #steps-list {
    gap: 16px;
  }
  
  .step-content {
    padding: 18px 24px 22px;
    gap: 20px;
  }
  
  /* Even larger thumbnails */
  .step-thumb {
    width: 140px;
    height: 249px;
    border-radius: 12px;
  }
  
  .step-title {
    font-size: 20px;
  }
  
  .corner-badge {
    padding: 7px 14px 11px 10px;
  }
  
  .corner-badge span {
    font-size: 18px;
  }
}

/* Extra large desktop */
@media (min-width: 1280px) {
  #guide-viewer {
    max-width: 840px;
  }
  
  .viewer-header {
    padding: 22px 40px;
  }
  
  .guide-info {
    padding: 36px 40px 28px;
  }
  
  .guide-info h1 {
    font-size: 32px;
  }
  
  #steps-tab {
    padding: 0 40px 48px;
  }
  
  .step-content {
    padding: 20px 28px 24px;
    gap: 24px;
  }
  
  .step-thumb {
    width: 160px;
    height: 284px;
  }
  
  .step-title {
    font-size: 21px;
  }
  
  .step-notes {
    font-size: 16px;
  }
}

/* Toast notification */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: #fff;
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  z-index: 300;
  opacity: 0;
  transition: all 0.3s ease;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ============================================ */
/* DEFENSIBILITY MODULE - Sign-Off Modal */
/* Guideable Brand Styling */
/* ============================================ */
.signoff-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.signoff-modal.hidden {
  display: none;
}
.signoff-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
}
.signoff-content {
  position: relative;
  background: #fff;
  border-radius: 12px;
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3), 0 0 1px rgba(0, 0, 0, 0.05);
}
.signoff-header {
  padding: 28px 28px 20px;
  border-bottom: 1px solid #e5e7eb;
  position: relative;
}
.signoff-header h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  color: #1a1a1a;
  letter-spacing: -0.4px;
}
.signoff-close {
  position: absolute;
  top: 24px;
  right: 24px;
  background: #f8f9fa;
  border: none;
  color: #6b7280;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: all 0.2s;
  font-size: 20px;
}
.signoff-close:hover {
  background: #e5e7eb;
  color: #1a1a1a;
}
.signoff-body {
  padding: 24px 28px;
}
.signoff-notice {
  display: flex;
  gap: 14px;
  padding: 16px;
  background: rgba(247, 201, 72, 0.12);
  border-radius: 12px;
  margin-bottom: 24px;
  align-items: flex-start;
  border: 1px solid rgba(247, 201, 72, 0.2);
}
.signoff-notice-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  fill: #f7c948;
}
.signoff-notice p {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  color: #4b5563;
}
.signoff-guide-info {
  padding: 18px;
  background: #f8f9fa;
  border-radius: 12px;
  margin-bottom: 24px;
  border: 1px solid #e5e7eb;
}
.signoff-guide-info strong {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #6b7280;
  margin-bottom: 8px;
  font-weight: 600;
}
.signoff-guide-info p {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #1a1a1a;
  letter-spacing: -0.2px;
}
.signoff-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.signoff-field label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 8px;
}
.signoff-field .required {
  color: #ef4444;
}
.signoff-field input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 16px;
  font-family: inherit;
  transition: all 0.2s;
  background: #fff;
}
.signoff-field input:focus {
  outline: none;
  border-color: #f7c948;
  box-shadow: 0 0 0 3px rgba(247, 201, 72, 0.15);
}
.signoff-confirmation {
  padding: 18px;
  background: #f8f9fa;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
}
.signoff-checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}
.signoff-checkbox-label input[type="checkbox"] {
  margin-top: 2px;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  cursor: pointer;
}
.signoff-checkbox-label span {
  font-size: 14px;
  line-height: 1.5;
  color: #0a0a0a;
}
.signoff-footer {
  padding: 20px 28px 28px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  gap: 12px;
}
.signoff-cancel,
.signoff-submit {
  flex: 1;
  padding: 14px 24px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  letter-spacing: -0.2px;
}
.signoff-cancel {
  background: #f8f9fa;
  color: #1a1a1a;
  border: 1px solid #e5e7eb;
}
.signoff-cancel:hover {
  background: #e5e7eb;
}
.signoff-submit {
  background: #f7c948;
  color: #1a1a1a;
}
.signoff-submit:hover:not(:disabled) {
  background: #fad673;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(247, 201, 72, 0.25);
}
.signoff-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.signoff-btn {
  background: #f7c948;
  color: #1a1a1a;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 16px;
  transition: all 0.2s;
  letter-spacing: -0.2px;
}
.signoff-btn:hover {
  background: #fad673;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(247, 201, 72, 0.25);
}

@media (max-width: 640px) {
  .signoff-content {
    max-height: 100vh;
    border-radius: 0;
    height: 100%;
  }
  .signoff-footer {
    flex-direction: column-reverse;
  }
  .signoff-cancel,
  .signoff-submit {
    width: 100%;
  }
}

/* ============================================
   MAGICAL TIMESTAMP UX ENHANCEMENTS
   ============================================ */

/* Step Progress Bar */
#step-progress-container {
  height: 4px;
  background: rgba(255,255,255,0.15);
  border-radius: 2px;
  overflow: hidden;
  margin: 12px 0;
}
#step-progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  transition: width 0.1s linear;
  width: 0%;
}

/* Smart Loop Continue Prompt */
#continue-prompt {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  background: rgba(59, 130, 246, 0.95);
  padding: 16px 28px;
  border-radius: 30px;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
  z-index: 50;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
#continue-prompt.show {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}
#continue-prompt:hover {
  background: rgba(59, 130, 246, 1);
  transform: translate(-50%, -50%) scale(1.05);
}

/* Safety Step Overlay */
#safety-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.85);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
#safety-overlay.show {
  opacity: 1;
  pointer-events: auto;
}
.safety-card {
  background: rgba(30, 30, 30, 0.98);
  border-radius: 20px;
  padding: 32px;
  max-width: 340px;
  text-align: center;
  border: 2px solid #F59E0B;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}
.safety-icon {
  font-size: 40px;
  margin-bottom: 12px;
}
.safety-card h3 {
  color: #F59E0B;
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 8px;
  letter-spacing: -0.3px;
}
.safety-card p {
  color: rgba(255,255,255,0.85);
  font-size: 15px;
  line-height: 1.5;
  margin-bottom: 20px;
}
#safety-acknowledge-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #10B981;
  color: #fff;
  border: none;
  padding: 14px 28px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}
#safety-acknowledge-btn:hover {
  background: #059669;
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(16, 185, 129, 0.4);
}

/* Safety badge variant for step badge */
.modal-step-badge.safety {
  background: #F59E0B;
  color: #fff;
}
