/**
 * SaveManager - Human-Crafted Studio UI Design System
 * Inspired by Linear, Raycast, and tactile audio/video hardware
 */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;700&family=Space+Grotesk:wght@500;600;700&display=swap');

:root {
  /* Obsidian Studio Palette */
  --bg-base: #090a0f;
  --bg-surface: #0f1118;
  --bg-card: #141722;
  --bg-card-hover: #191d2c;
  --bg-input: #0a0c12;
  --bg-elevated: #1a1e2e;

  /* Borders & Mechanical Lines */
  --border-hairline: rgba(255, 255, 255, 0.06);
  --border-subtle: rgba(255, 255, 255, 0.1);
  --border-prominent: rgba(255, 255, 255, 0.18);
  --border-focus: #6366f1;

  /* Accents */
  --accent: #6366f1;
  --accent-light: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.35);
  
  /* Platform Authentic Brand Tints */
  --brand-ig: #e1306c;
  --brand-ig-glow: rgba(225, 48, 108, 0.3);
  --brand-fb: #1877f2;
  --brand-fb-glow: rgba(24, 119, 242, 0.3);
  --brand-pin: #e60023;
  --brand-pin-glow: rgba(230, 0, 35, 0.3);
  --brand-yt: #ff0000;
  --brand-yt-glow: rgba(255, 0, 0, 0.3);

  /* Typography */
  --font-main: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Text Colors */
  --text-pure: #ffffff;
  --text-high: #e2e8f0;
  --text-mid: #94a3b8;
  --text-low: #64748b;
  --text-dim: #475569;

  /* Radii */
  --radius-xs: 6px;
  --radius-sm: 9px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  /* Tactile Physics */
  --ease-spring: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-snap: cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  overflow-x: hidden;
  max-width: 100%;
  width: 100%;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-base);
  color: var(--text-high);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
  max-width: 100%;
  width: 100%;
  position: relative;
  -webkit-font-smoothing: antialiased;
  background-image: 
    radial-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    radial-gradient(circle at 50% 0%, rgba(99, 102, 241, 0.09) 0%, transparent 50%),
    radial-gradient(circle at 100% 30%, rgba(225, 48, 108, 0.06) 0%, transparent 40%);
  background-size: 32px 32px, 100% 100%, 100% 100%;
}


.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
}

/* Atmospheric Glow */
.mesh-glow {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 900px;
  height: 480px;
  background: radial-gradient(ellipse at 50% 0%, rgba(99, 102, 241, 0.16), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 90;
  background: rgba(9, 10, 15, 0.82);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-hairline);
  padding: 14px 0;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text-pure);
}

.brand-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  padding: 0 !important;
  width: auto !important;
  height: 40px;
  overflow: visible !important;
  flex-shrink: 0;
  transition: transform var(--ease-spring) 0.2s;
}

.brand-logo-img {
  height: 40px;
  width: auto;
  max-width: 150px;
  object-fit: contain;
  display: block;
}

.brand:hover .brand-glyph {
  transform: scale(1.04);
}

.brand-text {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand-sub {
  color: var(--text-dim);
  font-size: 0.85rem;
  font-weight: 500;
  font-family: var(--font-mono);
}

.nav-cluster {
  display: flex;
  align-items: center;
  gap: 24px;
}

.nav-link {
  color: var(--text-mid);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
  transition: color 0.15s ease;
}

.nav-link:hover {
  color: var(--text-pure);
}

.action-cluster {
  display: flex;
  align-items: center;
  gap: 10px;
}

.theme-icon-btn,
#themeToggleBtn {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 6px !important;
  border-radius: 50% !important;
  color: var(--text-pure, #ffffff) !important;
  cursor: pointer !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: transform 0.2s ease, color 0.2s ease !important;
  outline: none !important;
  line-height: 1 !important;
}

.theme-icon-btn:hover,
#themeToggleBtn:hover {
  transform: scale(1.15) !important;
  color: var(--accent-light, #818cf8) !important;
  background: transparent !important;
}

.theme-icon-btn .theme-icon,
#themeToggleBtn .theme-icon {
  width: 20px !important;
  height: 20px !important;
  display: block !important;
}

.tactile-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-high);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transition: all 0.15s ease;
}

.tactile-btn:hover {
  background: var(--bg-card);
  border-color: var(--border-prominent);
  color: var(--text-pure);
}

.history-pill {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  background: rgba(99, 102, 241, 0.18);
  color: var(--accent-light);
  padding: 1px 6px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(99, 102, 241, 0.3);
}

/* Hero Section */
.hero-wrapper {
  padding: 64px 24px 30px;
  text-align: center;
  position: relative;
  z-index: 1;
}

.hero-headline {
  font-family: var(--font-display);
  font-size: 3.6rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.12;
  color: var(--text-pure);
  max-width: 820px;
  margin: 0 auto 16px;
}

.headline-gradient {
  background: linear-gradient(135deg, #ffffff 30%, #94a3b8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-subhead {
  font-size: 1.15rem;
  color: var(--text-mid);
  max-width: 620px;
  margin: 0 auto 36px;
  line-height: 1.6;
}

/* Tactile Segmented Platform Switcher (Hardware feel) */
.segmented-control {
  display: inline-flex;
  background: #0c0e15;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 4px;
  gap: 4px;
  margin-bottom: 30px;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.6);
  position: relative;
  max-width: 100%;
  overflow-x: auto;
}

.segment-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: none;
  color: var(--text-mid);
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  font-family: var(--font-main);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s var(--ease-snap);
}

.segment-item:hover {
  color: var(--text-pure);
}

.segment-item.is-active {
  background: #1e2233;
  color: var(--text-pure);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.1);
}

/* Master Input Console */
.input-console {
  max-width: 780px;
  margin: 0 auto 32px;
  background: var(--bg-card);
  border: 1px solid var(--border-prominent);
  border-radius: var(--radius-lg);
  padding: 10px;
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.05);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input-console:focus-within {
  border-color: rgba(99, 102, 241, 0.6);
  box-shadow: 0 25px 50px -10px rgba(0, 0, 0, 0.9), 0 0 30px rgba(99, 102, 241, 0.2);
}

.console-form {
  display: flex;
  align-items: center;
  gap: 10px;
}

.input-field-chassis {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.platform-indicator-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-hairline);
  padding: 4px 10px;
  border-radius: var(--radius-xs);
  font-size: 0.76rem;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-low);
  user-select: none;
  transition: all 0.2s ease;
}

.platform-indicator-tag.detected-instagram {
  background: rgba(225, 48, 108, 0.15);
  border-color: rgba(225, 48, 108, 0.35);
  color: #f43f5e;
}

.platform-indicator-tag.detected-facebook {
  background: rgba(24, 119, 242, 0.15);
  border-color: rgba(24, 119, 242, 0.35);
  color: #60a5fa;
}

.platform-indicator-tag.detected-pinterest {
  background: rgba(230, 0, 35, 0.15);
  border-color: rgba(230, 0, 35, 0.35);
  color: #f87171;
}

.platform-indicator-tag.detected-youtube {
  background: rgba(255, 0, 0, 0.15);
  border-color: rgba(255, 0, 0, 0.35);
  color: #f87171;
}

.native-url-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-pure);
  font-family: var(--font-main);
  font-size: 1rem;
  padding: 8px 0;
}

.native-url-input::placeholder {
  color: var(--text-dim);
}

.keycap-btn {
  background: #1a1e2d;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-mid);
  padding: 6px 12px;
  border-radius: var(--radius-xs);
  font-size: 0.8rem;
  font-family: var(--font-mono);
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition: all 0.12s ease;
}

.keycap-btn:hover {
  background: #23293d;
  color: var(--text-pure);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.keycap-btn:active {
  transform: translateY(1px);
  box-shadow: none;
}

.icon-clear-btn {
  background: transparent;
  border: none;
  color: var(--text-low);
  cursor: pointer;
  padding: 4px;
  display: inline-flex;
}

.icon-clear-btn:hover {
  color: var(--text-pure);
}

.action-fetch-btn {
  background: linear-gradient(180deg, #6366f1 0%, #4f46e5 100%);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  padding: 14px 32px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 15px rgba(79, 70, 229, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transition: all 0.15s ease;
  min-width: 140px;
  justify-content: center;
}

.action-fetch-btn:hover {
  background: linear-gradient(180deg, #7175f7 0%, #5850ec 100%);
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(79, 70, 229, 0.55);
}

.action-fetch-btn:active {
  transform: translateY(0);
}

/* Sample Bar */
.sample-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.sample-label {
  font-size: 0.78rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

.sample-token {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-hairline);
  color: var(--text-mid);
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.12s ease;
}

.sample-token:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-subtle);
  color: var(--text-pure);
}

.sample-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.dot-ig { background: #e1306c; box-shadow: 0 0 6px rgba(225, 48, 108, 0.6); }
.dot-fb { background: #1877f2; box-shadow: 0 0 6px rgba(24, 119, 242, 0.6); }
.dot-pin { background: #e60023; box-shadow: 0 0 6px rgba(230, 0, 35, 0.6); }
.dot-yt { background: #ff0000; box-shadow: 0 0 6px rgba(255, 0, 0, 0.6); }

/* =========================================================
   CUSTOM HAND-CRAFTED ORGANIC SVG GOOEY MORPHING LOADER
   ========================================================= */

.gegga {
  width: 0;
  height: 0;
  position: absolute;
  pointer-events: none;
}

.snurra-stage {
  position: relative;
  width: 140px;
  height: 140px;
  margin: 0 auto 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.snurra {
  filter: url(#gegga);
  position: relative;
  z-index: 2;
  width: 140px;
  height: 140px;
}

.stopp1 {
  stop-color: #f700a8;
}

.stopp2 {
  stop-color: #ff8000;
}

.halvan {
  animation: Snurra1 10s infinite linear;
  stroke-dasharray: 180 800;
  fill: none;
  stroke: url(#gradient);
  stroke-width: 23;
  stroke-linecap: round;
}

.strecken {
  animation: Snurra1 3s infinite linear;
  stroke-dasharray: 26 54;
  fill: none;
  stroke: url(#gradient);
  stroke-width: 23;
  stroke-linecap: round;
}

.skugga {
  filter: blur(5px);
  opacity: 0.35;
  position: absolute;
  top: 3px;
  left: 3px;
  z-index: 1;
  width: 140px;
  height: 140px;
}

@keyframes Snurra1 {
  0% {
    stroke-dashoffset: 0;
  }
  100% {
    stroke-dashoffset: -403px;
  }
}

.quantum-loader-stage {
  max-width: 780px;
  margin: 0 auto 30px;
  background: var(--bg-card);
  border: 1px solid var(--border-prominent);
  border-radius: var(--radius-lg);
  padding: 48px 24px;
  text-align: center;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.8);
}

.gyro-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2.5px solid transparent;
}

.gyro-ring.ring-1 {
  border-top-color: #6366f1;
  border-bottom-color: #a855f7;
  animation: gyroSpinX 1.4s linear infinite;
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.4);
}

.gyro-ring.ring-2 {
  border-left-color: #ec4899;
  border-right-color: #f43f5e;
  animation: gyroSpinY 1.8s linear infinite reverse;
  box-shadow: 0 0 12px rgba(236, 72, 153, 0.4);
}

.gyro-ring.ring-3 {
  border-top-color: #06b6d4;
  border-right-color: #3b82f6;
  animation: gyroSpinZ 2.2s linear infinite;
  box-shadow: 0 0 12px rgba(6, 182, 212, 0.4);
}

.gyro-core {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 0 18px #fff, 0 0 35px var(--accent);
  animation: pulseCore 1.2s ease-in-out infinite alternate;
}

@keyframes gyroSpinX {
  0% { transform: rotateX(0deg) rotateY(40deg); }
  100% { transform: rotateX(360deg) rotateY(40deg); }
}

@keyframes gyroSpinY {
  0% { transform: rotateY(0deg) rotateX(40deg); }
  100% { transform: rotateY(360deg) rotateX(40deg); }
}

@keyframes gyroSpinZ {
  0% { transform: rotateZ(0deg) rotateX(60deg); }
  100% { transform: rotateZ(360deg) rotateX(60deg); }
}

@keyframes pulseCore {
  from { transform: scale(0.7); opacity: 0.6; }
  to { transform: scale(1.2); opacity: 1; }
}

/* Audio-Visual Equalizer Wave Loader (Secondary state) */
.waveform-equalizer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 36px;
  margin: 16px auto;
}

.eq-bar {
  width: 4px;
  background: linear-gradient(180deg, #818cf8 0%, #4f46e5 100%);
  border-radius: 2px;
  animation: eqBounce 1.2s ease-in-out infinite alternate;
}

.eq-bar:nth-child(1) { height: 12px; animation-delay: 0.1s; }
.eq-bar:nth-child(2) { height: 24px; animation-delay: 0.3s; }
.eq-bar:nth-child(3) { height: 32px; animation-delay: 0.15s; }
.eq-bar:nth-child(4) { height: 18px; animation-delay: 0.4s; }
.eq-bar:nth-child(5) { height: 36px; animation-delay: 0.25s; }
.eq-bar:nth-child(6) { height: 20px; animation-delay: 0.5s; }
.eq-bar:nth-child(7) { height: 28px; animation-delay: 0.2s; }
.eq-bar:nth-child(8) { height: 14px; animation-delay: 0.35s; }

@keyframes eqBounce {
  0% { transform: scaleY(0.25); }
  100% { transform: scaleY(1); }
}

/* Terminal Ticker inside Loader */
.terminal-ticker {
  background: #090b10;
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  max-width: 480px;
  margin: 18px auto 0;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: #38bdf8;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.6);
}

.ticker-cursor {
  display: inline-block;
  width: 6px;
  height: 14px;
  background: #38bdf8;
  animation: blink 0.8s infinite;
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* Studio Button Loader */
.button-dual-spinner {
  display: none;
  width: 18px;
  height: 18px;
  position: relative;
}

.button-dual-spinner::before,
.button-dual-spinner::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid transparent;
}

.button-dual-spinner::before {
  border-top-color: #fff;
  border-left-color: #fff;
  animation: spinSmooth 0.7s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.button-dual-spinner::after {
  border-bottom-color: rgba(255, 255, 255, 0.4);
  border-right-color: rgba(255, 255, 255, 0.4);
  animation: spinSmooth 0.7s cubic-bezier(0.4, 0, 0.2, 1) infinite reverse;
}

@keyframes spinSmooth {
  to { transform: rotate(360deg); }
}

.action-fetch-btn.is-loading .btn-text,
.action-fetch-btn.is-loading .btn-icon {
  display: none;
}

.action-fetch-btn.is-loading .button-dual-spinner {
  display: block;
}

/* Studio Media Result Console */
.result-console {
  max-width: 820px;
  margin: 0 auto 40px;
  text-align: left;
}

.studio-card {
  background: var(--bg-card);
  border: 1px solid var(--border-prominent);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.8), 0 0 30px rgba(99, 102, 241, 0.15);
}

.studio-card-toolbar {
  background: #0f121b;
  border-bottom: 1px solid var(--border-hairline);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.source-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-mid);
}

.status-pill-ready {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.74rem;
  font-family: var(--font-mono);
  font-weight: 600;
}

.studio-card-body {
  padding: 24px;
  display: grid;
  grid-template-columns: 290px 1fr;
  gap: 24px;
}

.media-monitor {
  position: relative;
  background: #000;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-hairline);
  overflow: hidden;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.6);
  aspect-ratio: 9/16;
  max-height: 420px;
}

.media-monitor video,
.media-monitor img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.monitor-hud {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  gap: 6px;
}

.hud-tag {
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 4px;
}

.monitor-play-trigger {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
  cursor: pointer;
  transition: background 0.15s ease;
}

.monitor-play-trigger:hover {
  background: rgba(0, 0, 0, 0.2);
}

.play-circle {
  width: 58px;
  height: 58px;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  transition: transform 0.15s ease;
}

.monitor-play-trigger:hover .play-circle {
  transform: scale(1.1);
  background: rgba(99, 102, 241, 0.8);
}

/* Media Inspector Meta Column */
.media-inspector {
  display: flex;
  flex-direction: column;
}

.inspector-title {
  font-family: var(--font-display);
  font-size: 1.28rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text-pure);
  margin-bottom: 10px;
}

.inspector-author-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.author-chip {
  font-size: 0.85rem;
  color: var(--text-mid);
  font-weight: 600;
}

.tech-spec-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  background: #0d1017;
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 20px;
}

.tech-spec-item {
  display: flex;
  flex-direction: column;
}

.spec-k {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-dim);
  text-transform: uppercase;
}

.spec-v {
  font-family: var(--font-mono);
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-high);
}

/* Download Action Rows */
.download-deck-header {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 10px;
  letter-spacing: 0.05em;
}

.download-deck-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.deck-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #0d1019;
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  transition: all 0.15s ease;
}

.deck-item-row:hover {
  background: #141826;
  border-color: rgba(99, 102, 241, 0.4);
}

.deck-meta-info {
  display: flex;
  flex-direction: column;
}

.deck-format-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-pure);
}

.deck-format-sub {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--text-dim);
}

.tactile-download-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #1e2438;
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #fff;
  padding: 8px 16px;
  border-radius: var(--radius-xs);
  font-size: 0.84rem;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  transition: all 0.12s ease;
}

.tactile-download-link:hover {
  background: linear-gradient(180deg, #6366f1 0%, #4f46e5 100%);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

/* Card Bottom Controls */
.studio-bottom-actions {
  display: flex;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--border-hairline);
}

/* Monetization / Ad units (High-end partner feel) */
.ad-unit {
  background: rgba(15, 18, 28, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  position: relative;
  transition: all 0.15s ease;
}

.ad-unit:hover {
  border-color: rgba(99, 102, 241, 0.3);
  background: rgba(20, 24, 38, 0.7);
}

.ad-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.ad-badge {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
  padding: 1px 6px;
  border-radius: 4px;
}

.ad-label {
  font-size: 0.72rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

.ad-content {
  display: flex;
  align-items: center;
  gap: 16px;
}

.ad-headline {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-pure);
  margin-bottom: 2px;
}

.ad-description {
  font-size: 0.8rem;
  color: var(--text-mid);
}

.ad-cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
  color: #fff;
  padding: 8px 14px;
  border-radius: var(--radius-xs);
  font-size: 0.8rem;
  font-weight: 700;
  text-decoration: none;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.ad-cta-btn:hover {
  background: var(--accent);
  border-color: transparent;
}

/* Bottom Sticky Ad Bar */
.ad-sticky-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 85;
  background: rgba(10, 12, 18, 0.95);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-subtle);
  padding: 8px 16px;
}

.ad-sticky-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
}

.ad-sticky-close {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: var(--text-mid);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Platform Features Cards */
.platforms-matrix {
  padding: 80px 24px 40px;
}

.matrix-header {
  text-align: center;
  max-width: 600px;
  margin: 0 auto 48px;
}

.matrix-tag {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--accent-light);
  display: block;
  margin-bottom: 8px;
}

.matrix-title {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-pure);
}

.matrix-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.matrix-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 24px;
  display: flex;
  flex-direction: column;
  transition: all 0.2s ease;
}

.matrix-card:hover {
  border-color: var(--border-prominent);
  transform: translateY(-4px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
}

.card-icon-box {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  font-size: 1.2rem;
}

.matrix-card-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-pure);
}

.matrix-card-desc {
  font-size: 0.85rem;
  color: var(--text-mid);
  line-height: 1.5;
  margin-bottom: 16px;
  flex-grow: 1;
}

.specs-list {
  list-style: none;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.specs-list li::before {
  content: '▸ ';
  color: var(--accent-light);
}

/* FAQ Accordion */
.faq-wrap {
  padding: 60px 24px 80px;
}

.faq-list {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.faq-item {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.faq-item:hover {
  border-color: var(--border-prominent);
}

.faq-item[open] {
  border-color: rgba(99, 102, 241, 0.4);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.25);
}

.faq-question {
  padding: 16px 20px;
  font-size: 0.98rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
  transition: color 0.15s ease;
}

.faq-question::-webkit-details-marker {
  display: none;
}

.faq-toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  font-size: 1.15rem;
  font-family: var(--font-mono);
  color: var(--accent-light);
  transition: transform 0.22s var(--ease-spring), background 0.2s ease, color 0.2s ease;
  flex-shrink: 0;
  margin-left: 14px;
}

.faq-item[open] .faq-toggle-icon {
  transform: rotate(45deg);
  background: rgba(99, 102, 241, 0.25);
  color: #fff;
}

.faq-item[open] .faq-question {
  border-bottom: 1px solid var(--border-hairline);
  color: var(--text-pure);
}

.faq-answer {
  padding: 14px 20px 18px;
  font-size: 0.9rem;
  color: var(--text-mid);
  line-height: 1.65;
}

/* History / Media Vault Drawer */
.history-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 380px;
  max-width: 86vw;
  height: 100%;
  height: 100dvh;
  background: #0d1017;
  border-left: 1px solid var(--border-prominent);
  z-index: 1210;
  display: flex;
  flex-direction: column;
  box-shadow: -15px 0 45px rgba(0, 0, 0, 0.85);
  transform: translateX(100%);
  visibility: hidden;
  pointer-events: none;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.3s;
}

.history-drawer.is-open {
  transform: translateX(0);
  visibility: visible;
  pointer-events: auto;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 1200;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.25s ease, visibility 0.25s;
}

.drawer-backdrop.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}


.history-drawer-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-hairline);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-item-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-xs);
  padding: 8px;
}

.history-thumb {
  width: 46px;
  height: 46px;
  border-radius: 4px;
  object-fit: cover;
  background: #000;
}

.history-info {
  flex: 1;
  min-width: 0;
}

.history-item-title {
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item-sub {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-dim);
}

/* Toasts */
.toast-container {
  position: fixed;
  bottom: 80px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: #141826;
  border: 1px solid var(--border-prominent);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius-xs);
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6);
}

/* Footer */
.app-footer {
  background: #07080c;
  border-top: 1px solid var(--border-hairline);
  padding: 60px 0 100px;
  color: var(--text-mid);
}

.footer-inner {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 40px;
  margin-bottom: 40px;
}

.footer-desc {
  font-size: 0.88rem;
  color: var(--text-dim);
  max-width: 320px;
  margin: 12px 0 16px;
}

.footer-links h4 {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  color: var(--text-pure);
  margin-bottom: 14px;
}

.footer-links ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.footer-links a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.84rem;
}

.footer-links a:hover {
  color: var(--text-pure);
}

.footer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 24px;
  border-top: 1px solid var(--border-hairline);
  font-size: 0.8rem;
  color: var(--text-dim);
}

/* =========================================================
   COMPREHENSIVE MOBILE & TABLET RESPONSIVE SYSTEM
   ========================================================= */

html {
  scroll-behavior: smooth;
  -webkit-tap-highlight-color: transparent;
}

body {
  padding-bottom: calc(75px + env(safe-area-inset-bottom, 0px));
}

@media (max-width: 1024px) {
  .matrix-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .footer-inner {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 768px) {
  .container {
    padding: 0 16px;
  }

  /* Header Optimization on Mobile */
  .app-header {
    padding: 8px 0;
  }

  .nav-cluster {
    display: none;
  }

  .brand-sub {
    display: none;
  }

  .brand-glyph {
    width: 34px;
    height: 34px;
  }

  .brand-text {
    font-size: 1.15rem;
  }

  .action-cluster {
    gap: 8px;
  }

  .action-cluster .tactile-btn {
    padding: 7px 11px;
    min-height: 38px;
    font-size: 0.82rem;
  }

  /* Hero Section on Mobile */
  .hero-wrapper {
    padding: 28px 12px 16px;
  }

  .hero-headline {
    font-size: clamp(1.75rem, 6.5vw, 2.3rem);
    letter-spacing: -0.035em;
    line-height: 1.15;
    margin-bottom: 10px;
  }

  .hero-subhead {
    font-size: 0.92rem;
    line-height: 1.5;
    margin-bottom: 20px;
    padding: 0;
    max-width: 95%;
  }

  /* Segmented Platform Control on Mobile */
  .segmented-control {
    width: 100%;
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 4px;
    margin-bottom: 18px;
    scroll-snap-type: x mandatory;
    gap: 4px;
  }

  .segmented-control::-webkit-scrollbar {
    display: none;
  }

  .segment-item {
    scroll-snap-align: start;
    padding: 8px 13px;
    font-size: 0.8rem;
    font-weight: 600;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 36px;
  }

  .segment-item svg {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
  }

  /* Input Console on Mobile */
  .input-console {
    padding: 8px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
  }

  .console-form {
    flex-direction: column;
    gap: 10px;
    width: 100%;
  }

  .input-field-chassis {
    width: 100%;
    min-height: 52px;
    padding: 6px 10px;
    gap: 8px;
    border-radius: var(--radius-sm);
  }

  .native-url-input {
    font-size: 16px; /* Crucial: Prevents iOS Safari auto-zoom */
    padding: 8px 0;
    width: 100%;
    line-height: 1.4;
  }

  .native-url-input::placeholder {
    font-size: 0.88rem;
  }

  .platform-indicator-tag {
    padding: 4px 8px;
    font-size: 0.72rem;
    min-height: 28px;
    flex-shrink: 0;
  }

  .keycap-btn {
    padding: 7px 11px;
    font-size: 0.78rem;
    min-height: 34px;
    flex-shrink: 0;
  }

  .icon-clear-btn {
    padding: 6px;
    min-width: 28px;
    min-height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .action-fetch-btn {
    width: 100%;
    height: 48px;
    padding: 12px;
    font-size: 1rem;
    font-weight: 700;
    border-radius: var(--radius-sm);
    justify-content: center;
    box-shadow: 0 4px 18px rgba(99, 102, 241, 0.45);
  }

  /* Sample Chips on Mobile: Swipeable Carousel */
  .sample-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding: 4px 2px;
    justify-content: flex-start;
    margin-top: 10px;
  }

  .sample-bar::-webkit-scrollbar {
    display: none;
  }

  .sample-label {
    flex-shrink: 0;
    font-size: 0.72rem;
    margin-right: 2px;
    white-space: nowrap;
  }

  .sample-token {
    flex-shrink: 0;
    padding: 6px 12px;
    font-size: 0.76rem;
    border-radius: var(--radius-full);
    white-space: nowrap;
    min-height: 28px;
  }

  /* Loader Stage on Mobile */
  .quantum-loader-stage {
    padding: 28px 16px;
    border-radius: var(--radius-md);
  }

  .snurra-stage {
    width: 110px;
    height: 110px;
    margin: 0 auto 16px;
  }

  .snurra, .skugga {
    width: 110px;
    height: 110px;
  }

  .quantum-loader-stage h3 {
    font-size: 1.05rem;
  }

  .terminal-ticker {
    width: 100%;
    padding: 8px 12px;
    font-size: 0.74rem;
    border-radius: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Result Console on Mobile */
  .result-console {
    margin: 0 auto 28px;
  }

  .studio-card-toolbar {
    padding: 10px 14px;
    gap: 8px;
  }

  .source-badge {
    max-width: 65%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.75rem;
  }

  .studio-card-body {
    grid-template-columns: 1fr;
    padding: 14px;
    gap: 18px;
  }

  .media-monitor {
    max-width: 320px;
    max-height: 380px;
    margin: 0 auto;
    width: 100%;
    border-radius: 12px;
  }

  .media-monitor video,
  .media-monitor img {
    object-fit: contain;
    background: #080a10;
  }

  .inspector-title {
    font-size: 1.1rem;
    line-height: 1.35;
    margin-bottom: 8px;
    word-break: break-word;
  }

  .tech-spec-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    padding: 8px 10px;
    border-radius: var(--radius-xs);
  }

  .tech-spec-item {
    text-align: center;
  }

  .spec-k {
    font-size: 0.62rem;
  }

  .spec-v {
    font-size: 0.78rem;
  }

  .deck-item-row {
    padding: 12px 14px;
    gap: 10px;
    border-radius: var(--radius-sm);
  }

  .deck-format-name {
    font-size: 0.88rem;
    font-weight: 700;
  }

  .deck-format-sub {
    font-size: 0.72rem;
  }

  .tactile-download-link {
    min-height: 42px;
    padding: 8px 16px;
    font-size: 0.84rem;
    font-weight: 700;
    border-radius: var(--radius-xs);
    white-space: nowrap;
    flex-shrink: 0;
  }

  .studio-bottom-actions {
    flex-direction: column;
    gap: 8px;
    width: 100%;
  }

  .studio-bottom-actions .tactile-btn {
    width: 100%;
    min-height: 44px;
    justify-content: center;
    font-size: 0.88rem;
  }

  /* Matrix & FAQ on Mobile */
  .platforms-matrix {
    padding: 44px 14px 20px;
  }

  .matrix-header {
    margin-bottom: 24px;
  }

  .matrix-title {
    font-size: 1.6rem;
  }

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

  .matrix-card {
    padding: 18px 16px;
    border-radius: var(--radius-sm);
  }

  .card-icon-box {
    width: 38px;
    height: 38px;
    margin-bottom: 12px;
  }

  .faq-wrap {
    padding: 36px 14px 44px;
  }

  .faq-question {
    padding: 14px 16px;
    font-size: 0.92rem;
    min-height: 50px;
  }

  .faq-toggle-icon {
    width: 24px;
    height: 24px;
    font-size: 1rem;
    margin-left: 10px;
  }

  .faq-answer {
    padding: 0 16px 16px;
    font-size: 0.86rem;
    line-height: 1.6;
  }

  /* In-Page Ad Cards on Mobile */
  .ad-topBanner .ad-content,
  .ad-inFeed .ad-content,
  .ad-downloadReady .ad-content {
    flex-direction: column;
    text-align: center;
    gap: 12px;
  }

  .ad-topBanner .ad-cta-btn,
  .ad-inFeed .ad-cta-btn,
  .ad-downloadReady .ad-cta-btn {
    width: 100%;
    min-height: 40px;
    justify-content: center;
  }

  /* Vault Drawer on Mobile: Slide-in Side View from Right to Left */
  .history-drawer {
    width: 86vw;
    max-width: 360px;
    right: 0;
    left: auto;
    border-left: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: -10px 0 45px rgba(0, 0, 0, 0.9);
  }


  .history-drawer-header {
    padding: 16px;
  }

  .toast-container {
    left: 14px;
    right: 14px;
    bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  }

  .toast {
    width: 100%;
    justify-content: center;
    font-size: 0.84rem;
    padding: 10px 14px;
  }

  /* Footer on Mobile */
  .app-footer {
    padding: 44px 0 96px;
  }

  .footer-inner {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .footer-bottom {
    flex-direction: column;
    text-align: center;
    gap: 10px;
    font-size: 0.78rem;
  }
}

/* Smartphone Small Screen Optimization (<= 600px) */
@media (max-width: 600px) {
  .btn-label-text {
    display: none;
  }

  .action-cluster .tactile-btn {
    padding: 7px 10px;
    min-width: 38px;
    justify-content: center;
  }
}

/* Compact Mobile Breakpoint (<= 520px, e.g. standard mobile phone view) */
@media (max-width: 520px) {
  #detectedPlatformName {
    display: none;
  }

  .platform-indicator-tag {
    padding: 4px 6px;
    min-width: 28px;
    justify-content: center;
  }

  .hero-headline {
    font-size: 1.85rem;
  }

  .hero-subhead {
    font-size: 0.88rem;
  }

  .legal-modal-box {
    width: 95vw;
    max-height: 86vh;
    border-radius: var(--radius-md);
  }

  .legal-modal-header {
    padding: 14px 16px;
  }

  .legal-modal-header h3 {
    font-size: 1.1rem;
  }

  .legal-modal-body {
    padding: 14px 16px;
    font-size: 0.86rem;
  }

  .legal-modal-footer {
    padding: 10px 16px;
  }
}

/* Extra Compact Smartphone Breakpoint (<= 360px, e.g. Galaxy Z Flip outer, small screens) */
@media (max-width: 360px) {
  .hero-headline {
    font-size: 1.65rem;
  }

  .deck-item-row {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
    gap: 8px;
  }

  .tactile-download-link {
    width: 100%;
    justify-content: center;
  }
}

/* =========================================================
   LEGAL MODAL DIALOG
   ========================================================= */

.legal-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.legal-modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border-prominent);
  border-radius: var(--radius-lg);
  max-width: 640px;
  width: 100%;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.9);
  animation: modalPop 0.2s var(--ease-spring);
}

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

.legal-modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-hairline);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.legal-modal-header h3 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-pure);
}

.legal-modal-close {
  background: transparent;
  border: none;
  color: var(--text-mid);
  font-size: 1.5rem;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xs);
  transition: all 0.12s ease;
}

.legal-modal-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-pure);
}

.legal-modal-body {
  padding: 24px;
  overflow-y: auto;
  font-size: 0.92rem;
  color: var(--text-mid);
  line-height: 1.7;
}

.legal-modal-body h4 {
  font-family: var(--font-display);
  color: var(--text-pure);
  font-size: 1rem;
  margin: 16px 0 6px;
}

.legal-modal-body p {
  margin-bottom: 12px;
}

.legal-modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border-hairline);
  display: flex;
  justify-content: flex-end;
}

/* =========================================================
   LIGHT MODE DESIGN TOKENS
   ========================================================= */

[data-theme="light"] {
  --bg-base: #f8fafc;
  --bg-surface: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-input: #ffffff;
  --bg-elevated: #ffffff;

  --border-hairline: rgba(0, 0, 0, 0.08);
  --border-subtle: rgba(0, 0, 0, 0.12);
  --border-prominent: rgba(0, 0, 0, 0.18);
  --border-focus: #4f46e5;

  --text-pure: #0f172a;
  --text-high: #1e293b;
  --text-mid: #475569;
  --text-low: #64748b;
  --text-dim: #94a3b8;
}

[data-theme="light"] body {
  background-color: #f8fafc;
  color: #1e293b;
  background-image: 
    radial-gradient(rgba(0, 0, 0, 0.05) 1px, transparent 1px),
    radial-gradient(circle at 50% 0%, rgba(99, 102, 241, 0.08) 0%, transparent 60%);
  background-size: 32px 32px, 100% 100%;
}

/* Header & Navigation in Light Mode */
[data-theme="light"] .app-header {
  background: rgba(255, 255, 255, 0.88);
  border-bottom-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .brand {
  color: #0f172a;
}

[data-theme="light"] .theme-icon-btn,
[data-theme="light"] #themeToggleBtn {
  color: #0f172a !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

[data-theme="light"] .theme-icon-btn:hover,
[data-theme="light"] #themeToggleBtn:hover {
  color: #6366f1 !important;
}

[data-theme="light"] .brand-sub {
  color: #64748b;
}

[data-theme="light"] .nav-link {
  color: #475569;
}

[data-theme="light"] .nav-link:hover {
  color: #0f172a;
}

[data-theme="light"] .tactile-btn {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.14);
  color: #0f172a;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), inset 0 1px 0 rgba(255, 255, 255, 1);
}

[data-theme="light"] .tactile-btn:hover {
  background: #f1f5f9;
  border-color: rgba(0, 0, 0, 0.22);
  color: #0f172a;
}

[data-theme="light"] .history-pill {
  background: rgba(99, 102, 241, 0.12);
  color: #4f46e5;
  border-color: rgba(99, 102, 241, 0.25);
}

/* Hero & Headline in Light Mode */
[data-theme="light"] .hero-headline {
  color: #0f172a;
}

[data-theme="light"] .headline-gradient {
  background: linear-gradient(135deg, #1e293b 20%, #4f46e5 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

[data-theme="light"] .hero-subhead {
  color: #475569;
}

/* Segmented Control in Light Mode */
[data-theme="light"] .segmented-control {
  background: #e2e8f0;
  border-color: rgba(0, 0, 0, 0.1);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .segment-item {
  color: #475569;
}

[data-theme="light"] .segment-item:hover {
  color: #0f172a;
}

[data-theme="light"] .segment-item.is-active {
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.05);
}

/* Input Console in Light Mode */
[data-theme="light"] .input-console {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.14);
  box-shadow: 0 15px 35px -10px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .input-console:focus-within {
  border-color: #6366f1;
  box-shadow: 0 20px 45px -10px rgba(99, 102, 241, 0.18), 0 0 0 2px rgba(99, 102, 241, 0.2);
}

[data-theme="light"] .input-field-chassis {
  background: #f8fafc;
  border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .platform-indicator-tag {
  background: #e2e8f0;
  border-color: rgba(0, 0, 0, 0.1);
  color: #334155;
}

[data-theme="light"] .native-url-input {
  color: #0f172a;
}

[data-theme="light"] .native-url-input::placeholder {
  color: #94a3b8;
}

[data-theme="light"] .keycap-btn {
  background: #e2e8f0;
  border-color: rgba(0, 0, 0, 0.12);
  color: #1e293b;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .keycap-btn:hover {
  background: #cbd5e1;
  color: #0f172a;
}

[data-theme="light"] .icon-clear-btn {
  color: #64748b;
}

[data-theme="light"] .icon-clear-btn:hover {
  color: #0f172a;
}

/* Sample Bar in Light Mode */
[data-theme="light"] .sample-label {
  color: #64748b;
}

[data-theme="light"] .sample-token {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.12);
  color: #475569;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .sample-token:hover {
  background: #f1f5f9;
  border-color: rgba(0, 0, 0, 0.2);
  color: #0f172a;
}

/* Loader Stage in Light Mode */
[data-theme="light"] .quantum-loader-stage {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.12);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .quantum-loader-stage h3 {
  color: #0f172a;
}

[data-theme="light"] .terminal-ticker {
  background: #f1f5f9;
  border-color: rgba(0, 0, 0, 0.1);
  color: #0369a1;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .ticker-cursor {
  background: #0369a1;
}

/* Studio Result Console in Light Mode */
[data-theme="light"] .studio-card {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.12);
  box-shadow: 0 20px 45px -10px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .studio-card-toolbar {
  background: #f8fafc;
  border-bottom-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .source-badge {
  color: #1e293b;
}

[data-theme="light"] .status-pill-ready {
  background: rgba(16, 185, 129, 0.12);
  color: #059669;
  border-color: rgba(16, 185, 129, 0.3);
}

[data-theme="light"] .inspector-title {
  color: #0f172a;
}

[data-theme="light"] .author-chip {
  color: #475569;
}

[data-theme="light"] .tech-spec-grid {
  background: #f8fafc;
  border-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .spec-k {
  color: #64748b;
}

[data-theme="light"] .spec-v {
  color: #0f172a;
}

[data-theme="light"] .download-deck-header {
  color: #64748b;
}

[data-theme="light"] .deck-item-row {
  background: #f8fafc;
  border-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .deck-item-row:hover {
  background: #f1f5f9;
  border-color: rgba(99, 102, 241, 0.3);
}

[data-theme="light"] .deck-format-name {
  color: #0f172a;
}

[data-theme="light"] .deck-format-sub {
  color: #64748b;
}

[data-theme="light"] .tactile-download-link {
  background: linear-gradient(180deg, #4f46e5 0%, #4338ca 100%);
  border-color: rgba(0, 0, 0, 0.1);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.25);
}

[data-theme="light"] .tactile-download-link:hover {
  background: linear-gradient(180deg, #6366f1 0%, #4f46e5 100%);
}

[data-theme="light"] .studio-bottom-actions {
  border-top-color: rgba(0, 0, 0, 0.08);
}

/* Monetization Ad Units in Light Mode */
[data-theme="light"] .ad-unit {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.12);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .ad-unit:hover {
  background: #f8fafc;
  border-color: rgba(99, 102, 241, 0.3);
}

[data-theme="light"] .ad-headline {
  color: #0f172a;
}

[data-theme="light"] .ad-description {
  color: #475569;
}

[data-theme="light"] .ad-label {
  color: #64748b;
}

[data-theme="light"] .ad-cta-btn {
  background: #0f172a;
  border-color: #0f172a;
  color: #ffffff;
}

[data-theme="light"] .ad-cta-btn:hover {
  background: #4f46e5;
  border-color: #4f46e5;
}

[data-theme="light"] .ad-sticky-bar {
  background: rgba(255, 255, 255, 0.96);
  border-top-color: rgba(0, 0, 0, 0.1);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .ad-sticky-close {
  background: rgba(0, 0, 0, 0.06);
  color: #475569;
}

[data-theme="light"] .ad-sticky-close:hover {
  background: rgba(0, 0, 0, 0.12);
  color: #0f172a;
}

/* Platform Matrix & FAQ in Light Mode */
[data-theme="light"] .matrix-tag {
  color: #4f46e5;
}

[data-theme="light"] .matrix-title {
  color: #0f172a;
}

[data-theme="light"] .matrix-card {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.1);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .matrix-card:hover {
  border-color: rgba(0, 0, 0, 0.2);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .matrix-card-title {
  color: #0f172a;
}

[data-theme="light"] .matrix-card-desc {
  color: #475569;
}

[data-theme="light"] .specs-list {
  color: #64748b;
}

[data-theme="light"] .faq-item {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}

[data-theme="light"] .faq-question {
  color: #0f172a;
}

[data-theme="light"] .faq-toggle-icon {
  background: rgba(0, 0, 0, 0.05);
  color: #4f46e5;
}

[data-theme="light"] .faq-item[open] .faq-toggle-icon {
  background: rgba(99, 102, 241, 0.15);
  color: #4f46e5;
}

[data-theme="light"] .faq-item[open] .faq-question {
  border-bottom-color: rgba(0, 0, 0, 0.08);
  color: #0f172a;
}

[data-theme="light"] .faq-answer {
  color: #475569;
}

/* Vault / History Drawer in Light Mode */
[data-theme="light"] .history-drawer {
  background: #ffffff;
  border-left-color: rgba(0, 0, 0, 0.12);
  box-shadow: -10px 0 35px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .history-drawer-header {
  border-bottom-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .history-item-card {
  background: #f8fafc;
  border-color: rgba(0, 0, 0, 0.08);
  color: #0f172a;
}

[data-theme="light"] .history-item-title {
  color: #0f172a;
}

[data-theme="light"] .history-item-sub {
  color: #64748b;
}

/* Legal Modal in Light Mode */
[data-theme="light"] .legal-modal-box {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.15);
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.25);
}

[data-theme="light"] .legal-modal-header {
  border-bottom-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .legal-modal-header h3 {
  color: #0f172a;
}

[data-theme="light"] .legal-modal-body {
  color: #475569;
}

[data-theme="light"] .legal-modal-body h4 {
  color: #0f172a;
}

[data-theme="light"] .legal-modal-footer {
  border-top-color: rgba(0, 0, 0, 0.08);
}

/* Footer & Toasts in Light Mode */
[data-theme="light"] .app-footer {
  background: #f1f5f9;
  border-top-color: rgba(0, 0, 0, 0.08);
  color: #475569;
}

[data-theme="light"] .footer-desc {
  color: #64748b;
}

[data-theme="light"] .footer-links h4 {
  color: #0f172a;
}

[data-theme="light"] .footer-links a {
  color: #64748b;
}

[data-theme="light"] .footer-links a:hover {
  color: #0f172a;
}

[data-theme="light"] .footer-bottom {
  border-top-color: rgba(0, 0, 0, 0.08);
  color: #64748b;
}

[data-theme="light"] .toast {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.15);
  color: #0f172a;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
}

/* ==========================================================================
   Ads & Sponsorship Units - Fully Responsive Design System
   ========================================================================== */
.ad-container {
  margin: 20px auto;
  width: 100%;
  max-width: 900px;
  display: block;
}

.ad-unit {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md, 14px);
  padding: 14px 18px;
  position: relative;
  transition: border-color 0.25s, background 0.25s, transform 0.2s;
  overflow: hidden;
}

.ad-unit:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(99, 102, 241, 0.3);
}

.ad-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.ad-badge {
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.3);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 4px;
  letter-spacing: 0.5px;
  line-height: 1;
}

.ad-label {
  font-size: 0.72rem;
  color: var(--text-dim, #64748b);
  font-family: var(--font-mono, monospace);
}

.ad-content {
  display: flex;
  align-items: center;
  gap: 14px;
  justify-content: space-between;
}

.ad-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(168, 85, 247, 0.2));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #a855f7;
  flex-shrink: 0;
}

.ad-text-block {
  flex: 1;
  min-width: 0;
}

.ad-headline {
  font-size: 0.94rem;
  font-weight: 600;
  margin: 0 0 3px 0;
  color: var(--text-bright, #f8fafc);
  line-height: 1.3;
}

.ad-description {
  font-size: 0.8rem;
  color: var(--text-mid, #94a3b8);
  margin: 0;
  line-height: 1.4;
}

.ad-cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm, 8px);
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #ffffff !important;
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  transition: transform 0.15s, box-shadow 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}

.ad-cta-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.5);
  color: #ffffff !important;
}

/* Bottom Sticky Sponsor Bar Styling */
.sponsor-sticky-bar,
.ad-sticky-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  max-width: 100vw;
  z-index: 998;
  background: rgba(13, 17, 23, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding: 8px 14px;
  padding-bottom: max(8px, env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -8px 25px rgba(0, 0, 0, 0.5);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.sponsor-hiding,
.ad-sticky-hiding {
  transform: translateY(105%) !important;
}

.sponsor-sticky-inner,
.ad-sticky-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-width: 0;
}

.sponsor-sticky-card {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-width: 0;
  padding: 0;
}

.sponsor-icon {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 6px;
  background: rgba(99, 102, 241, 0.2);
  border: 1px solid rgba(99, 102, 241, 0.4);
  color: var(--accent-light, #818cf8);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sponsor-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sponsor-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(99, 102, 241, 0.2);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.3);
  flex-shrink: 0;
}

.sponsor-headline {
  font-size: 0.8rem;
  font-weight: 600;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.sponsor-cta-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  min-height: 30px;
  padding: 4px 12px;
  font-size: 0.74rem;
  font-weight: 600;
  border-radius: 6px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #ffffff !important;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  gap: 5px;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
  transition: transform 0.15s;
}

.sponsor-cta-btn:hover {
  transform: translateY(-1px);
}

.sponsor-sticky-close,
.ad-sticky-close {
  background: rgba(255, 255, 255, 0.08) !important;
  border: 1px solid rgba(255, 255, 255, 0.14) !important;
  color: var(--text-mid, #94a3b8) !important;
  width: 26px !important;
  height: 26px !important;
  min-width: 26px !important;
  border-radius: 50% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 15px !important;
  line-height: 1 !important;
  cursor: pointer !important;
  transition: all 0.2s !important;
  flex-shrink: 0 !important;
  padding: 0 !important;
  margin-left: 2px !important;
}

.sponsor-sticky-close:hover,
.ad-sticky-close:hover {
  background: rgba(255, 255, 255, 0.18) !important;
  color: #ffffff !important;
  transform: scale(1.08) !important;
}

/* Ensure body does not get occluded by sticky bar */
body {
  padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px));
}

/* Light Theme for Sponsors */
[data-theme="light"] .sponsor-sticky-bar,
[data-theme="light"] .ad-sticky-bar {
  background: rgba(255, 255, 255, 0.96);
  border-top-color: rgba(0, 0, 0, 0.08);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .sponsor-headline {
  color: #0f172a !important;
}

[data-theme="light"] .sponsor-sticky-close,
[data-theme="light"] .ad-sticky-close {
  background: rgba(0, 0, 0, 0.05) !important;
  border-color: rgba(0, 0, 0, 0.1) !important;
  color: #475569 !important;
}

[data-theme="light"] .sponsor-sticky-close:hover,
[data-theme="light"] .ad-sticky-close:hover {
  background: rgba(0, 0, 0, 0.1) !important;
  color: #0f172a !important;
}

/* Mobile Specific Tuning */
@media (max-width: 640px) {
  .sponsor-sticky-bar,
  .ad-sticky-bar {
    padding: 6px 10px;
    padding-bottom: max(6px, env(safe-area-inset-bottom, 0px));
  }

  .sponsor-sticky-card {
    gap: 8px;
  }

  .sponsor-icon {
    width: 24px;
    height: 24px;
    min-width: 24px;
  }

  .sponsor-badge {
    display: none;
  }

  .sponsor-headline {
    font-size: 0.74rem;
  }

  .sponsor-cta-btn {
    height: 28px;
    min-height: 28px;
    padding: 3px 8px;
    font-size: 0.68rem;
  }

  .sponsor-sticky-close,
  .ad-sticky-close {
    width: 24px !important;
    height: 24px !important;
    min-width: 24px !important;
    font-size: 14px !important;
  }
}
