/* ==========================================================================
   STUMBLE — MODERN SERENDIPITOUS WEB DISCOVERY
   Design System: Deep Dark Cyber-Glass, Retro-Neon Accents, Tactile Controls
   Optimized for Mobile (iOS/Android), PWA, and Desktop Workstations
   ========================================================================== */

:root {
  --bg-core: #0a0c14;
  --bg-panel: rgba(18, 22, 36, 0.9);
  --bg-panel-solid: #121624;
  --bg-card: rgba(28, 34, 54, 0.7);
  --bg-card-hover: rgba(38, 46, 72, 0.85);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-highlight: rgba(255, 255, 255, 0.18);
  --border-glow: rgba(5, 217, 232, 0.35);

  --accent-coral: #FF5E3A;
  --accent-magenta: #FF2A6D;
  --accent-cyan: #05D9E8;
  --accent-lime: #00F5A0;
  --accent-purple: #7928CA;
  --accent-danger: #ff4757;

  --text-primary: #FFFFFF;
  --text-secondary: #9DA6B8;
  --text-muted: #647087;

  --grad-stumble: linear-gradient(135deg, #FF5E3A 0%, #FF2A6D 50%, #7928CA 100%);
  --grad-stumble-hover: linear-gradient(135deg, #FF7B54 0%, #FF4181 50%, #903AF0 100%);
  --grad-cyan: linear-gradient(135deg, #05D9E8 0%, #00F5A0 100%);
  --grad-glow: radial-gradient(circle, rgba(255, 42, 109, 0.25) 0%, rgba(5, 217, 232, 0) 70%);

  --shadow-lg: 0 16px 40px -10px rgba(0, 0, 0, 0.6);
  --shadow-stumble: 0 8px 30px rgba(255, 42, 109, 0.45);
  --shadow-card: 0 10px 25px rgba(0, 0, 0, 0.3);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --header-height: 64px;
  --strip-height: 48px;
  --dock-height: 0px;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-display: 'Space Grotesk', var(--font-sans);

  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

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

html, body {
  width: 100%;
  height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
  background-color: var(--bg-core);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

/* Ambient Glows */
.ambient-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.35;
  animation: floatGlow 18s ease-in-out infinite alternate;
}
.glow-1 {
  width: 500px;
  height: 500px;
  top: -100px;
  left: 20%;
  background: radial-gradient(circle, var(--accent-magenta), transparent 70%);
}
.glow-2 {
  width: 600px;
  height: 600px;
  bottom: -150px;
  right: 15%;
  background: radial-gradient(circle, var(--accent-cyan), transparent 70%);
  animation-delay: -9s;
}
@keyframes floatGlow {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(40px, 30px) scale(1.1); }
  100% { transform: translate(-30px, -20px) scale(0.95); }
}

/* ==========================================================================
   APP HEADER & THE STUMBLE TOOLBAR
   ========================================================================== */

.stumble-header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  max-width: 100vw;
  box-sizing: border-box;
  z-index: 50;
  background: var(--bg-panel);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top, 0px);
  overflow-x: clip;
}

.header-inner {
  height: var(--header-height);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

/* Brand Logo */
.brand-group {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--radius-md);
  transition: var(--transition-fast);
}
.brand-group:hover {
  background: rgba(255, 255, 255, 0.05);
}

/* Quick Update PWA Button (Header) */
.btn-update-pwa {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.2), rgba(255, 42, 109, 0.25));
  border: 1px solid rgba(56, 189, 248, 0.45);
  color: #fff;
  padding: 5px 12px;
  border-radius: 999px;
  font-family: var(--font-main, sans-serif);
  font-size: 0.76rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.3);
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.btn-update-pwa:hover {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.35), rgba(255, 42, 109, 0.45));
  border-color: var(--accent-cyan);
  box-shadow: 0 0 18px rgba(56, 189, 248, 0.6);
  transform: scale(1.05);
}

.btn-update-pwa:active {
  transform: scale(0.95);
}
.logo-icon-wrap {
  position: relative;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.brand-svg {
  width: 36px;
  height: 36px;
  filter: drop-shadow(0 2px 8px rgba(255, 42, 109, 0.4));
  transition: transform 0.3s ease;
}
.brand-group:hover .brand-svg {
  transform: rotate(15deg) scale(1.08);
}
.pulse-dot {
  position: absolute;
  top: 0;
  right: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-lime);
  box-shadow: 0 0 10px var(--accent-lime);
  animation: pulseLight 2s infinite;
}
@keyframes pulseLight {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.6; }
}
.brand-text {
  display: flex;
  flex-direction: column;
}
.brand-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: var(--grad-stumble);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.1;
}
.brand-tagline {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  font-weight: 600;
}

/* Center Controls */
.center-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 1 auto;
  max-width: 580px;
  min-width: 0;
  justify-content: center;
}

/* Tactile Stumble Button */
.btn-stumble {
  position: relative;
  overflow: hidden;
  height: 44px;
  padding: 0 20px;
  background: var(--grad-stumble);
  border: none;
  border-radius: var(--radius-full);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.5px;
  cursor: pointer;
  box-shadow: var(--shadow-stumble);
  transition: var(--transition-fast);
  flex-shrink: 0;
}
.btn-stumble:hover {
  background: var(--grad-stumble-hover);
  transform: translateY(-1px) scale(1.02);
  box-shadow: 0 10px 35px rgba(255, 42, 109, 0.6);
}
.btn-stumble:active {
  transform: translateY(1px) scale(0.98);
  box-shadow: 0 4px 15px rgba(255, 42, 109, 0.4);
}
.btn-stumble.stumbling .stumble-svg-icon {
  animation: spinStumble 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes spinStumble {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
.stumble-svg-icon {
  width: 20px;
  height: 20px;
}
.kbd-hint {
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  padding: 2px 6px;
  letter-spacing: 0.5px;
  opacity: 0.9;
}

/* Category Pill Selector */
.category-selector-wrapper {
  position: relative;
  flex-shrink: 1;
  min-width: 0;
}
.category-pill-btn {
  height: 42px;
  padding: 0 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-highlight);
  border-radius: var(--radius-full);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
  max-width: 190px;
}
.cat-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 110px;
}
.category-pill-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-cyan);
}
.category-pill-btn[aria-expanded="true"] {
  border-color: var(--accent-magenta);
  box-shadow: 0 0 16px rgba(255, 42, 109, 0.3);
}
.cat-icon {
  font-size: 16px;
}
.cat-count-badge {
  font-size: 11px;
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  color: var(--accent-cyan);
}
.chevron-icon {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}
.category-pill-btn[aria-expanded="true"] .chevron-icon {
  transform: rotate(180deg);
}

/* Auto-Refresh / Hands-Free Stumble Toggle Button */
.btn-auto-refresh {
  height: 42px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
}

.btn-auto-refresh:hover {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.btn-auto-refresh.active {
  background: rgba(5, 217, 232, 0.15);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  box-shadow: 0 0 18px rgba(5, 217, 232, 0.35);
}

.btn-auto-refresh.active .refresh-icon {
  animation: spinRefresh 2.5s linear infinite;
  color: var(--accent-cyan);
}

.refresh-icon {
  width: 16px;
  height: 16px;
  transition: transform var(--transition-fast);
}

.auto-timer-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}

.btn-auto-refresh.active .auto-timer-badge {
  background: rgba(5, 217, 232, 0.25);
  color: var(--accent-cyan);
}

@keyframes spinRefresh {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Category Backdrop (for both desktop and mobile drawer) */
.category-menu-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.category-menu-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

/* Category Menu (Free from backdrop-filter containing block trap) */
.category-menu {
  position: fixed;
  z-index: 999;
  width: 340px;
  background: var(--bg-panel-solid);
  border: 1px solid var(--border-highlight);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(255, 255, 255, 0.08);
  padding: 12px;
  display: none;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  max-height: 80vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.category-menu.open {
  display: block;
  opacity: 1;
  transform: translateY(0);
}
.cat-menu-header {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  padding: 8px 12px 6px;
}

.cat-search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin: 2px 6px 10px;
  transition: all var(--transition-fast);
}

.cat-search-box:focus-within {
  border-color: var(--accent-cyan);
  background: rgba(255, 255, 255, 0.09);
  box-shadow: 0 0 12px rgba(5, 217, 232, 0.25);
}

.search-svg {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.cat-search-box input {
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-size: 12.5px;
  width: 100%;
}

.cat-search-box input::placeholder {
  color: var(--text-muted);
}
.cat-menu-items {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cat-menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: left;
  transition: var(--transition-fast);
}
.cat-menu-item:hover {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-primary);
}
.cat-menu-item.active {
  background: rgba(5, 217, 232, 0.12);
  color: var(--accent-cyan);
  border: 1px solid rgba(5, 217, 232, 0.25);
}
.cat-item-icon {
  font-size: 20px;
  line-height: 1;
}
.cat-item-info {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.cat-item-title {
  font-size: 13.5px;
  font-weight: 600;
  color: inherit;
}
.cat-item-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}
.cat-item-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 7px;
  border-radius: var(--radius-full);
}
.cat-menu-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 6px 0;
}
.nsfw-toggle-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: rgba(255, 42, 109, 0.05);
  border: 1px solid rgba(255, 42, 109, 0.15);
}
.nsfw-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-turn-off-nsfw {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(255, 42, 109, 0.15);
  border: 1px solid rgba(255, 42, 109, 0.35);
  color: var(--accent-magenta);
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  margin: 6px 0;
  transition: var(--transition-fast);
}
.btn-turn-off-nsfw:hover {
  background: rgba(255, 42, 109, 0.28);
  border-color: var(--accent-magenta);
}

/* Switch Component */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(255, 255, 255, 0.15);
  transition: .3s cubic-bezier(0.4, 0, 0.2, 1);
}
.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s cubic-bezier(0.4, 0, 0.2, 1);
}
input:checked + .slider {
  background: var(--grad-stumble);
}
input:checked + .slider:before {
  transform: translateX(20px);
}
.slider.round {
  border-radius: 34px;
}
.slider.round:before {
  border-radius: 50%;
}

/* Right Actions */
.right-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-btn-group {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 2px;
}
.divider-v {
  width: 1px;
  height: 24px;
  background: var(--border-subtle);
  margin: 0 4px;
}
.icon-btn, .action-btn {
  height: 38px;
  padding: 0 12px;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: var(--transition-fast);
}
.icon-btn {
  width: 38px;
  padding: 0;
}
.icon-btn svg, .action-btn svg {
  width: 18px;
  height: 18px;
}
.icon-btn:hover, .action-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--border-highlight);
}
.icon-btn:active, .action-btn:active {
  transform: scale(0.92);
  background: var(--bg-card-hover);
}
.icon-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.action-btn.highlight-btn {
  background: rgba(5, 217, 232, 0.12);
  border-color: rgba(5, 217, 232, 0.3);
  color: var(--accent-cyan);
}
.action-btn.highlight-btn:hover {
  background: rgba(5, 217, 232, 0.25);
  box-shadow: 0 0 15px rgba(5, 217, 232, 0.35);
}
.thumbs-btn.liked {
  background: rgba(0, 245, 160, 0.2);
  border-color: var(--accent-lime);
  color: var(--accent-lime);
}
.fav-count {
  font-size: 11px;
  font-weight: 700;
}

/* ==========================================================================
   ACTIVE SITE INFO STRIP
   ========================================================================== */

.site-info-strip {
  height: var(--strip-height);
  padding: 0 16px;
  background: rgba(10, 12, 20, 0.95);
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  max-width: 100vw;
  box-sizing: border-box;
  overflow: hidden;
}
.site-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  white-space: nowrap;
  flex: 1 1 auto;
  min-width: 0;
}
.site-badge {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--accent-cyan);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(5, 217, 232, 0.2);
  flex-shrink: 0;
}
.site-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
  flex-shrink: 0;
}
.site-domain {
  font-size: 12.5px;
  color: var(--accent-coral);
  text-decoration: none;
  font-weight: 500;
  opacity: 0.9;
  flex-shrink: 0;
}
.site-domain:hover {
  text-decoration: underline;
}
.site-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 38vw;
  min-width: 0;
}
.strip-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.strip-btn {
  height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition-fast);
}
.strip-btn svg {
  width: 14px;
  height: 14px;
}
.strip-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}
.strip-btn.primary {
  background: var(--accent-cyan);
  border-color: var(--accent-cyan);
  color: #000;
  font-weight: 700;
}
.strip-btn.primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 0 15px rgba(5, 217, 232, 0.5);
}

/* ==========================================================================
   VIEWPORT STAGE & IFRAME
   ========================================================================== */

.viewport-stage {
  position: absolute;
  top: calc(var(--header-height) + var(--strip-height) + env(safe-area-inset-top, 0px));
  left: 0;
  right: 0;
  bottom: var(--dock-height);
  background: #000;
  z-index: 10;
  display: flex;
  flex-direction: column;
}

/* Top Progress Loader */
.loader-line {
  position: absolute;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: var(--grad-cyan);
  z-index: 30;
  box-shadow: 0 0 12px var(--accent-cyan);
  transition: width 0.3s ease;
}
.loader-line.loading {
  animation: loadSim 1.8s infinite ease-in-out;
}
@keyframes loadSim {
  0% { width: 0%; left: 0%; }
  50% { width: 60%; left: 20%; }
  100% { width: 100%; left: 100%; }
}

.iframe-container {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#stumbleFrame {
  width: 100%;
  height: 100%;
  border: none;
  background: #000;
  display: block;
}

/* Floating Quick Popout Pill */
.floating-quick-pill {
  position: absolute;
  bottom: 20px;
  right: 20px;
  z-index: 25;
  background: rgba(18, 22, 36, 0.85);
  border: 1px solid var(--border-highlight);
  color: var(--accent-cyan);
  padding: 8px 14px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  transition: var(--transition-fast);
}
.floating-quick-pill:hover {
  background: rgba(5, 217, 232, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(5, 217, 232, 0.3);
}
.floating-quick-pill svg {
  width: 14px;
  height: 14px;
}

/* ==========================================================================
   IMAGE & GALLERY SERIES VIEWER
   ========================================================================== */
.image-viewer-container {
  position: absolute;
  inset: 0;
  background: #06080e;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  user-select: none;
}

.img-backdrop-glow {
  position: absolute;
  width: 70%;
  height: 70%;
  background: radial-gradient(circle, rgba(5, 217, 232, 0.12) 0%, rgba(255, 42, 109, 0.08) 50%, transparent 75%);
  filter: blur(80px);
  pointer-events: none;
}

.image-wrapper {
  position: relative;
  max-width: 95%;
  max-height: 90%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: transform var(--transition-smooth);
}

.image-series-display {
  max-width: 100%;
  max-height: calc(100dvh - 160px);
  object-fit: contain;
  border-radius: var(--radius-md);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.08);
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.image-series-display.loaded {
  opacity: 1;
  transform: scale(1);
}

.image-caption-overlay {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(12, 15, 26, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-highlight);
  border-radius: var(--radius-full);
  padding: 6px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 20;
  max-width: 90%;
  box-shadow: var(--shadow-card);
}

.img-caption-title {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.img-caption-badge {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: rgba(5, 217, 232, 0.15);
  color: var(--accent-cyan);
}

/* Floating Image Series Navigation Toolbar */
.image-series-nav {
  position: absolute;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(18, 22, 38, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(5, 217, 232, 0.35);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7), 0 0 20px rgba(5, 217, 232, 0.25);
  border-radius: var(--radius-full);
  padding: 6px 8px;
  z-index: 30;
  transition: all var(--transition-fast);
}

.img-nav-btn {
  height: 38px;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-fast);
}

.img-nav-btn svg {
  width: 16px;
  height: 16px;
}

.img-nav-btn:hover {
  background: var(--accent-cyan);
  color: #000;
  border-color: var(--accent-cyan);
  box-shadow: 0 0 16px rgba(5, 217, 232, 0.5);
}

.img-nav-btn:active {
  transform: scale(0.96);
}

.img-nav-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.img-series-indicator {
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 800;
  color: var(--text-primary);
}

.img-series-icon {
  font-size: 14px;
  margin-right: 2px;
}

.img-idx {
  color: var(--accent-cyan);
}

.img-sep {
  color: var(--text-muted);
}

.img-total {
  color: var(--text-secondary);
}

/* Fallback / Protected Website Banner */
.iframe-fallback-card {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle at center, #151a2a 0%, #0a0c14 100%);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 20;
  text-align: center;
}
.iframe-fallback-card.active {
  display: flex;
}
.fallback-glow {
  position: absolute;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(255, 42, 109, 0.2) 0%, transparent 70%);
  filter: blur(80px);
  pointer-events: none;
}
.fallback-content {
  position: relative;
  max-width: 540px;
  background: var(--bg-panel);
  border: 1px solid var(--border-highlight);
  border-radius: var(--radius-lg);
  padding: 36px 28px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(25px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.fallback-badge {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-coral);
  background: rgba(255, 94, 58, 0.12);
  border: 1px solid rgba(255, 94, 58, 0.25);
  padding: 4px 12px;
  border-radius: var(--radius-full);
}
.fallback-content h2 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
}
.fallback-content p {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.6;
}
.fallback-btn-row {
  display: flex;
  gap: 12px;
  width: 100%;
  margin-top: 8px;
}
.btn-launch-fallback {
  flex: 2;
  height: 48px;
  background: var(--grad-stumble);
  border: none;
  border-radius: var(--radius-md);
  color: #fff;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: var(--shadow-stumble);
  transition: var(--transition-fast);
}
.btn-launch-fallback:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(255, 42, 109, 0.5);
}
.btn-launch-fallback svg {
  width: 20px;
  height: 20px;
}
.btn-skip-fallback {
  flex: 1;
  height: 48px;
  background: var(--bg-card);
  border: 1px solid var(--border-highlight);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}
.btn-skip-fallback:hover {
  background: var(--bg-card-hover);
}
.fallback-toggle-hint {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-muted);
}
.fallback-toggle-hint label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

/* ==========================================================================
   MODALS & DIALOGS
   ========================================================================== */

.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.modal-overlay.open {
  display: flex;
  opacity: 1;
}
.modal-card {
  width: 100%;
  max-width: 620px;
  max-height: 85vh;
  background: var(--bg-panel-solid);
  border: 1px solid var(--border-highlight);
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(15px);
  transition: transform 0.25s ease;
}
.modal-overlay.open .modal-card {
  transform: translateY(0);
}
.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}
.modal-title-group svg {
  width: 22px;
  height: 22px;
  color: var(--accent-magenta);
}
.modal-title-group h3 {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  color: var(--text-primary);
}
.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 26px;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
  transition: var(--transition-fast);
}
.modal-close-btn:hover {
  color: var(--text-primary);
}
.modal-tabs {
  display: flex;
  padding: 0 24px;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid var(--border-subtle);
}
.modal-tab-btn {
  padding: 12px 16px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition-fast);
}
.modal-tab-btn:hover {
  color: var(--text-primary);
}
.modal-tab-btn.active {
  color: var(--accent-cyan);
  border-bottom-color: var(--accent-cyan);
}
.modal-body {
  padding: 24px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.modal-subtitle {
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Vault Search & List */
.vault-search-row {
  display: flex;
  gap: 10px;
}
.stumble-input, .stumble-select, .stumble-textarea {
  width: 100%;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  transition: var(--transition-fast);
}
.stumble-input:focus, .stumble-select:focus, .stumble-textarea:focus {
  outline: none;
  border-color: var(--accent-cyan);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 15px rgba(5, 217, 232, 0.2);
}
.stumble-input.mono {
  font-family: monospace;
  letter-spacing: 1px;
}
.vault-list-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 400px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.vault-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: var(--transition-fast);
}
.vault-item:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-highlight);
}
.vault-item-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
  max-width: 75%;
}
.vault-item-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.vault-item-sub {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.vault-item-cat {
  color: var(--accent-cyan);
  font-weight: 600;
}
.vault-item-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.btn-mini {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
}
.btn-mini:hover {
  background: rgba(255, 255, 255, 0.15);
  color: var(--text-primary);
}
.btn-mini.danger:hover {
  background: rgba(255, 71, 87, 0.2);
  color: var(--accent-danger);
  border-color: var(--accent-danger);
}
.vault-empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}
.vault-empty-state p {
  margin-top: 8px;
  font-size: 14px;
}

/* Forms */
.stumble-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}
.form-group label .required {
  color: var(--accent-magenta);
}
.form-row {
  display: flex;
  gap: 12px;
}
.form-group.half {
  flex: 1;
}
.form-checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: var(--text-secondary);
}
.checkbox-container {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
}

/* Buttons */
.btn-primary {
  height: 42px;
  padding: 0 20px;
  background: var(--grad-stumble);
  border: none;
  border-radius: var(--radius-md);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  box-shadow: var(--shadow-stumble);
  transition: var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}
.btn-secondary {
  height: 42px;
  padding: 0 16px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  transition: var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}
.btn-danger {
  height: 38px;
  padding: 0 16px;
  background: rgba(255, 71, 87, 0.15);
  border: 1px solid rgba(255, 71, 87, 0.3);
  border-radius: var(--radius-md);
  color: var(--accent-danger);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition-fast);
}
.btn-danger:hover {
  background: rgba(255, 71, 87, 0.25);
}

/* Sync Cards & QR */
.sync-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.sync-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sync-card-header h4 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}
.pill-badge {
  font-size: 11px;
  background: rgba(5, 217, 232, 0.15);
  color: var(--accent-cyan);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: 700;
}
.sync-text {
  font-size: 13px;
  color: var(--text-secondary);
}
.sync-key-row {
  display: flex;
  gap: 8px;
}
.sync-status {
  font-size: 12px;
  color: var(--text-muted);
}
.sync-qr-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: var(--radius-md);
  margin-top: 6px;
}
.sync-qr-img {
  width: 140px;
  height: 140px;
  border-radius: var(--radius-sm);
  background: #fff;
  padding: 6px;
}
.sync-qr-caption {
  font-size: 11.5px;
  color: var(--text-muted);
  text-align: center;
}
.backup-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.file-upload-btn {
  cursor: pointer;
}

/* Settings List */
.settings-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  gap: 12px;
}
.setting-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}
.setting-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
}
.setting-desc {
  font-size: 12px;
  color: var(--text-muted);
}
.setting-item.danger-zone {
  border-color: rgba(255, 71, 87, 0.3);
  background: rgba(255, 71, 87, 0.05);
}
.about-stumble-box {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}
.about-stumble-box h4 {
  color: var(--text-primary);
  margin-bottom: 6px;
}
.version-tag {
  margin-top: 10px;
  font-size: 11px;
  color: var(--text-muted);
}
.version-tag a {
  color: var(--accent-cyan);
  text-decoration: none;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 80px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 300;
  pointer-events: none;
}
.toast {
  padding: 12px 20px;
  background: rgba(18, 22, 36, 0.95);
  border: 1px solid var(--border-highlight);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  color: var(--text-primary);
  font-size: 13.5px;
  font-weight: 500;
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  animation: slideToast 0.3s ease, fadeOutToast 0.3s 2.7s ease forwards;
}
@keyframes slideToast {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes fadeOutToast {
  to { opacity: 0; transform: translateY(-5px); }
}

/* Mobile Dock (Bottom Bar) */
.mobile-dock {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(60px + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--bg-panel);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-subtle);
  z-index: 60;
  align-items: center;
  justify-content: space-around;
  padding-left: 10px;
  padding-right: 10px;
}
.dock-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: var(--radius-full);
}
.dock-btn:active {
  background: rgba(255, 255, 255, 0.1);
}
.dock-btn svg {
  width: 22px;
  height: 22px;
}
.dock-stumble-btn {
  height: 44px;
  padding: 0 20px;
  background: var(--grad-stumble);
  border: none;
  border-radius: var(--radius-full);
  color: #fff;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-stumble);
}
.dock-stumble-btn:active {
  transform: scale(0.96);
}
.dock-stumble-btn svg {
  width: 18px;
  height: 18px;
}

/* ==========================================================================
   RESPONSIVE ADJUSTMENTS
   ========================================================================== */

/* Responsive Desktop Header Optimization */
@media (max-width: 1400px) {
  .desktop-secondary {
    display: none !important;
  }
  .brand-tagline {
    display: none !important;
  }
  .cat-text {
    max-width: 100px;
  }
}

@media (max-width: 1220px) {
  .kbd-hint {
    display: none !important;
  }
  .btn-stumble {
    padding: 0 14px;
    font-size: 14px;
  }
  .cat-count-badge {
    display: none !important;
  }
  .site-desc {
    display: none !important;
  }
}

@media (max-width: 1080px) {
  .btn-auto-refresh .auto-label {
    display: none !important;
  }
  .btn-auto-refresh {
    padding: 0 8px;
  }
  .category-pill-btn {
    padding: 0 8px;
  }
  .right-actions {
    gap: 4px;
  }
  .header-inner {
    padding: 0 10px;
    gap: 8px;
  }
}

/* Universal Desktop/Mobile Visibility Utilities */
.desktop-only {
  display: flex !important;
}
.mobile-header-info {
  display: none;
}

@media (max-width: 960px) {
  :root {
    --header-height: 44px;
    --strip-height: 0px;
    --dock-height: calc(60px + env(safe-area-inset-bottom, 0px));
  }

  /* Universal element elimination for mobile viewports */
  .desktop-only,
  .site-info-strip,
  .btn-stumble,
  .brand-text,
  .right-actions,
  .nav-btn-group,
  .thumbs-btn,
  .divider-v,
  .highlight-btn,
  .site-desc,
  .kbd-hint {
    display: none !important;
  }

  .stumble-header {
    height: var(--header-height);
    background: rgba(10, 12, 20, 0.96);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-subtle);
    padding: 0;
  }

  .header-inner {
    height: var(--header-height);
    padding: 0 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    width: 100%;
  }

  /* Minimalist glowing S brand logo */
  .brand-group {
    flex-shrink: 0;
    gap: 0;
    cursor: pointer;
    padding: 0;
  }
  .logo-icon-wrap {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
  }
  .brand-svg {
    width: 32px;
    height: 32px;
  }

  .btn-update-pwa {
    padding: 4px 8px;
    font-size: 0.7rem;
    gap: 4px;
    border-radius: 999px;
  }

  /* Sleek, uncluttered center site pill */
  .mobile-header-info {
    display: flex !important;
    flex-direction: column;
    justify-content: center;
    flex: 1 1 auto;
    min-width: 0;
    padding: 3px 8px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
  }
  .mobile-header-info:active {
    background: rgba(255, 255, 255, 0.12);
  }
  .mobile-header-title {
    font-size: 11.5px;
    font-weight: 700;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
  }
  .mobile-header-domain {
    font-size: 9.5px;
    font-weight: 600;
    color: var(--accent-cyan);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0.9;
    line-height: 1.15;
  }

  /* Compact Right Controls: Category Pill + Refresh */
  .center-controls {
    flex: 0 0 auto;
    margin: 0;
    gap: 5px;
    display: flex;
    align-items: center;
  }
  .btn-auto-refresh {
    height: 30px;
    width: 30px;
    padding: 0;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
  }
  .btn-auto-refresh .auto-label,
  .btn-auto-refresh .auto-timer-badge {
    display: none !important;
  }
  .btn-auto-refresh .refresh-icon {
    width: 13px;
    height: 13px;
  }
  .category-selector-wrapper {
    margin: 0;
  }
  .category-pill-btn {
    height: 30px;
    padding: 0 7px;
    gap: 4px;
    border-radius: var(--radius-full);
    background: rgba(25, 30, 48, 0.9);
    border: 1px solid var(--border-subtle);
    max-width: 95px;
  }
  .cat-icon {
    font-size: 12px;
  }
  .cat-text {
    max-width: 50px;
    font-size: 11px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .cat-count-badge {
    display: none !important;
  }
  .chevron-icon {
    width: 10px;
    height: 10px;
  }

  /* Viewport Stage starts immediately under the 44px header */
  .viewport-stage {
    top: calc(var(--header-height) + env(safe-area-inset-top, 0px));
    bottom: var(--dock-height);
  }

  .mobile-dock {
    display: flex !important;
  }
  .floating-quick-pill {
    bottom: calc(var(--dock-height) + 12px);
    right: 14px;
  }
  .toast-container {
    bottom: calc(var(--dock-height) + 12px);
    right: 14px;
    left: 14px;
  }
  .image-series-nav {
    bottom: calc(var(--dock-height) + 12px);
    padding: 5px 6px;
    gap: 6px;
  }
  .img-nav-btn {
    height: 36px;
    padding: 0 10px;
    font-size: 12px;
  }
  .img-nav-btn .img-nav-text {
    display: none;
  }
  .img-series-indicator {
    padding: 0 6px;
    font-size: 12px;
  }
  .image-caption-overlay {
    top: 10px;
    padding: 4px 12px;
  }
  .img-caption-title {
    font-size: 11px;
    max-width: 170px;
  }
  .category-menu {
    position: fixed;
    top: auto;
    bottom: calc(var(--dock-height) + 12px);
    left: 12px;
    right: 12px;
    width: auto;
    max-height: 65vh;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.95);
  }
  .fallback-content {
    padding: 28px 18px;
  }
  .fallback-content h2 {
    font-size: 19px;
  }
  .fallback-btn-row {
    flex-direction: column;
  }
  .modal-card {
    max-height: 90vh;
  }
}

/* ==========================================================================
   LEARNING BRAIN & TASTE DASHBOARD
   ========================================================================== */

.brain-dashboard {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.brain-header-banner {
  background: linear-gradient(135deg, rgba(121, 40, 202, 0.25) 0%, rgba(5, 217, 232, 0.15) 100%);
  border: 1px solid rgba(121, 40, 202, 0.35);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brain-header-text h4 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.brain-header-text p {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-top: 4px;
}
.dwell-stat-badge {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  text-align: center;
  flex-shrink: 0;
}
.dwell-stat-val {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 800;
  color: var(--accent-lime);
}
.dwell-stat-lbl {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}
.brain-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}
.affinity-bars-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
}
.affinity-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.affinity-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
}
.affinity-bar-track {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.affinity-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--grad-cyan);
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}
.affinity-bar-fill.ai { background: linear-gradient(90deg, #7928CA, #FF2A6D); }
.affinity-bar-fill.toys { background: linear-gradient(90deg, #FF5E3A, #FFB800); }
.affinity-bar-fill.oddities { background: linear-gradient(90deg, #05D9E8, #00F5A0); }
.affinity-bar-fill.science { background: linear-gradient(90deg, #0070F3, #05D9E8); }
.affinity-bar-fill.retro { background: linear-gradient(90deg, #FF2A6D, #7928CA); }
.affinity-bar-fill.tools { background: linear-gradient(90deg, #00F5A0, #05D9E8); }

/* Harvester Card */
.harvester-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.harvester-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.harvester-title {
  font-size: 14.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-lime);
  box-shadow: 0 0 10px var(--accent-lime);
  animation: pulseLight 1.5s infinite;
}
.harvester-desc {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.5;
}
.harvester-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}
.btn-harvest {
  height: 38px;
  padding: 0 16px;
  background: rgba(5, 217, 232, 0.15);
  border: 1px solid rgba(5, 217, 232, 0.35);
  color: var(--accent-cyan);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition-fast);
}
.btn-harvest:hover {
  background: rgba(5, 217, 232, 0.25);
  box-shadow: 0 0 15px rgba(5, 217, 232, 0.3);
}
.harvested-count-pill {
  font-size: 11.5px;
  color: var(--text-muted);
}

/* ==========================================================================
   MOBILE QUICK MENU SHEET
   ========================================================================== */
.mobile-sheet-card {
  max-width: 420px;
  width: 92%;
  border-radius: var(--radius-lg);
}

.mobile-menu-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mobile-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  transition: all var(--transition-fast);
  width: 100%;
}

.mobile-menu-item:hover, .mobile-menu-item:active {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
  transform: translateY(-1px);
}

.m-item-icon {
  font-size: 20px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.m-item-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.m-item-title {
  font-size: 13.5px;
  font-weight: 700;
  color: #ffffff;
}

.m-item-sub {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.m-item-arrow {
  font-size: 18px;
  color: var(--text-muted);
  font-weight: 700;
}

.m-item-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(5, 217, 232, 0.15);
  color: var(--accent-cyan);
}

/* Shortcuts Cheat Sheet Modal Grid */
.shortcuts-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}

.shortcut-row:hover {
  background: rgba(255, 255, 255, 0.06);
}

.shortcut-desc {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.shortcut-keys {
  display: flex;
  align-items: center;
  gap: 4px;
}

.shortcut-kbd {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 5px;
  padding: 3px 8px;
  color: var(--accent-cyan);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.shortcut-or {
  font-size: 10px;
  color: var(--text-muted);
  margin: 0 3px;
}

/* Tightened touch response and native app feel */
button, .dock-btn, .mobile-menu-item, .cat-menu-item, .modal-tab-btn, .action-pill {
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.modal-tab-btn:active {
  transform: scale(0.96);
}

.action-pill:active {
  transform: scale(0.94);
}

/* ==========================================================================
   Global Ecosystem Hub Dock (Unified App Navigation)
   ========================================================================== */
.hub-dock-details {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
  max-width: 600px;
}

.hub-dock-summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 5px 16px;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-muted, #94a3b8);
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  transition: all 0.2s ease;
  user-select: none;
}
.hub-dock-summary::-webkit-details-marker { display: none; }

.hub-dock-summary:hover {
  color: var(--text-primary, #ffffff);
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.09);
}

.hub-dock-details[open] .hub-summary-arrow {
  transform: rotate(180deg);
}

.hub-summary-arrow {
  font-size: 0.7rem;
  transition: transform 0.2s ease;
}

.hub-dock-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: #0d111a;
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  border-radius: 9999px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  overflow-x: auto;
  max-width: 100%;
  scrollbar-width: none;
  margin-top: 8px;
}
.hub-dock-pill::-webkit-scrollbar { display: none; }

.hub-dock-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 9999px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #cbd5e1;
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.hub-dock-item:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

.hub-dock-item.active {
  background: rgba(6, 182, 212, 0.2);
  color: #22d3ee;
  border: 1px solid rgba(6, 182, 212, 0.4);
  font-weight: 700;
}



