/* =================================================================
   HookHero AI - Unified Design System (style2.css)
   Professional, consistent, responsive design for all pages
   ================================================================= */

/* ---------- CSS Variables (Design System) ---------- */
:root {
  /* Colors */
  --bg-primary: #07070b;
  --bg-secondary: #141218;
  --accent-primary: #8c38d1;
  --accent-secondary: #b66dff;
  --accent-tertiary: #f0c9ff;
  --text-primary: #f1effa;
  --text-secondary: rgba(203,213,224,0.82);
  --muted: rgba(203,213,224,0.78);
  --border-subtle: rgba(255,255,255,0.04);
  --border-accent: rgba(166,77,255,0.14);
  --surface-glass: linear-gradient(180deg, rgba(32,18,48,0.78), rgba(10,8,20,0.82));
  --surface-muted: linear-gradient(180deg, rgba(24,16,36,0.55), rgba(10,8,20,0.82));
  --surface-hover: rgba(255,255,255,0.04);
  --glow-1: rgba(140,56,209,0.28);
  --glow-2: rgba(111,59,230,0.22);
  --glow-3: rgba(255,190,255,0.18);
  
  /* Spacing */
  --space-xs: 6px;
  --space-sm: 12px;
  --space-md: 18px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-xxl: 48px;
  
  /* Layout */
  --max-content-width: 980px;
  --sidebar-width: 72px;
  --sidebar-left-margin: 16px;
  --top-offset: 76px;
  
  /* Controls */
  --input-height: 52px;
  --input-max-width: 420px;
  --button-height: 52px;
  --button-min-width: 160px;
  
  /* Radius */
  --radius-sm: 10px;
  --radius-md: 12px;
  --radius-lg: 16px;
  
  /* Shadows */
  --shadow-sm: 0 4px 12px rgba(0,0,0,0.3);
  --shadow-md: 0 10px 28px rgba(0,0,0,0.45);
  --shadow-lg: 0 18px 48px rgba(0,0,0,0.6);
  --shadow-accent: 0 12px 36px rgba(140,56,209,0.14);
}

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

html {
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
}

body {
  font-family: "Inter", system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  margin: 0;
  padding: 0;
  color: var(--text-primary);
  background:
    radial-gradient(900px 480px at 12% 14%, rgba(159,122,234,0.12), transparent 58%),
    radial-gradient(840px 520px at 78% 18%, rgba(111,59,230,0.09), transparent 60%),
    radial-gradient(1200px 780px at 50% 90%, rgba(40,18,68,0.42), transparent 72%),
    var(--bg-primary);
  background-attachment: fixed;
  background-size: cover;
  overflow-x: hidden;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Layout Containers ---------- */
.page-wrap {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xxl) var(--space-lg);
}

.page-wrap::before {
  content: "";
  position: absolute;
  inset: 12% 18%;
  background: radial-gradient(circle at center, rgba(140,56,209,0.16), transparent 72%);
  filter: blur(40px);
  opacity: 0.9;
  pointer-events: none;
}

.center-ui.card-surface {
  position: relative;
  width: 100%;
  max-width: var(--max-content-width);
  background: var(--surface-glass);
  border-radius: var(--radius-lg);
  padding: var(--space-xl) var(--space-lg);
  color: var(--text-primary);
  box-shadow: 0 28px 68px rgba(5,3,12,0.62), inset 0 1px 0 rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  display: flex;
  flex-direction: column;
  gap: var(--gap-main, 18px);
  backdrop-filter: blur(14px) saturate(120%);
  overflow: hidden;
  transition: box-shadow 0.22s ease, transform 0.22s ease, border-color 0.22s ease;
}

.center-ui.card-surface::before {
  content: "";
  position: absolute;
  inset: -140px 35% auto -80px;
  height: 240px;
  width: 240px;
  background: radial-gradient(circle at center, rgba(182,109,255,0.26), rgba(182,109,255,0));
  opacity: 0.9;
  pointer-events: none;
}

.center-ui.card-surface::after {
  content: "";
  position: absolute;
  inset: auto -160px -160px 45%;
  height: 280px;
  width: 280px;
  background: radial-gradient(circle at center, rgba(111,59,230,0.24), rgba(111,59,230,0));
  opacity: 0.7;
  pointer-events: none;
}

.center-ui.card-surface:hover {
  transform: translateY(-4px);
  box-shadow: 0 34px 88px rgba(8,4,18,0.72);
  border-color: rgba(182,109,255,0.26);
}

/* ---------- Typography ---------- */
h1, #gen-title, #tools-title, #mainTitle, #prompt-title {
  font-size: 1.64rem;
  margin: 0 0 var(--space-xs) 0;
  font-weight: 820;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  line-height: 1.18;
  text-shadow: 0 8px 26px rgba(12,6,20,0.55);
}

p, .subtitle {
  margin: 0 0 var(--space-md) 0;
  color: var(--text-secondary);
  font-size: 0.99rem;
  line-height: 1.55;
}

/* ---------- Mode Navigation Tabs ---------- */
.modes {
  display: flex;
  gap: var(--space-sm);
  justify-content: center;
  align-items: center;
  margin: var(--space-md) 0;
  flex-wrap: wrap;
}

.mode-btn {
  padding: 10px 20px;
  border-radius: 999px;
  background: rgba(18,12,32,0.35);
  color: var(--text-secondary);
  border: none !important;
  font-weight: 700;
  font-size: 0.96rem;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
  white-space: nowrap;
  backdrop-filter: blur(8px);
  outline: none;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06);
}

.mode-btn:hover {
  background: rgba(182,109,255,0.12);
  color: var(--text-primary);
  border-color: rgba(182,109,255,0.25);
  box-shadow: 0 12px 32px rgba(12,6,22,0.45);
}

.mode-btn.active {
  background: linear-gradient(180deg, var(--accent-secondary), var(--accent-primary));
  color: #fff;
  box-shadow: var(--shadow-accent);
  transform: translateY(-2px);
  border-color: transparent;
}

/* ---------- Form Elements ---------- */
.prompt-wrap {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--gap-main, 18px);
}

/* TEXTAREA */
textarea.prompt {
  width: 100%;
  max-width: 100%;
  min-height: 110px;
  padding: var(--space-md);
  font-size: 1rem;
  line-height: 1.48;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, rgba(28,18,44,0.56), rgba(10,8,20,0.78));
  border: 1px solid rgba(255,255,255,0.05);
  color: var(--text-primary);
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
  resize: vertical;
  font-family: inherit;
  transition: box-shadow 0.2s ease, border-color 0.2s ease, transform 0.16s ease;
}

textarea.prompt:hover {
  transform: translateY(-1px);
  border-color: rgba(182,109,255,0.18);
}

textarea.prompt:focus {
  box-shadow: 0 0 0 1px rgba(182,109,255,0.35), 0 16px 38px rgba(10,6,18,0.55);
  border-color: rgba(182,109,255,0.45);
}

textarea.prompt::placeholder {
  color: var(--text-secondary);
  opacity: 0.6;
}

/* SELECT DROPDOWN */
select.format {
  width: 100%;
  max-width: var(--input-max-width);
  height: var(--input-height);
  padding: 14px 48px 14px 16px;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, rgba(20,16,36,0.92), rgba(8,6,16,0.96));
  color: #f5f2ff;
  border: 1px solid rgba(255,255,255,0.06);
  font-weight: 700;
  font-size: 0.96rem;
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
  cursor: pointer;
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'><path fill='%23dccfff' d='M5 7l5 5 5-5z'/></svg>"),
    linear-gradient(180deg, rgba(20,16,36,0.92), rgba(8,6,16,0.96));
  background-repeat: no-repeat, repeat;
  background-position: right 14px center, 0 0;
  background-size: 16px 16px, auto;
  transition: box-shadow 0.2s ease, transform 0.1s ease, border-color 0.2s ease;
}

select.format:hover {
  transform: translateY(-1px);
  border-color: rgba(182,109,255,0.28);
  box-shadow: 0 18px 36px rgba(10,6,18,0.55);
}

select.format:focus {
  outline: none;
  box-shadow: 0 0 0 1px rgba(182,109,255,0.35);
  border-color: rgba(182,109,255,0.45);
}

select.format option {
  background: #0f0f12;
  color: #fff;
}

/* INPUT FIELDS (general) */
input[type="text"],
input[type="email"],
input[type="number"] {
  width: 100%;
  max-width: var(--input-max-width);
  height: var(--input-height);
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, rgba(26,18,40,0.62), rgba(8,6,16,0.88));
  border: 1px solid rgba(255,255,255,0.05);
  color: var(--text-primary);
  font-size: 0.96rem;
  font-family: inherit;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
  transition: box-shadow 0.18s ease, border-color 0.18s ease, transform 0.12s ease;
}

input[type="text"]:hover,
input[type="email"]:hover,
input[type="number"]:hover {
  transform: translateY(-1px);
  border-color: rgba(182,109,255,0.2);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="number"]:focus {
  box-shadow: 0 0 0 1px rgba(182,109,255,0.35), 0 10px 28px rgba(10,6,18,0.55);
  border-color: rgba(182,109,255,0.4);
}

/* ---------- Buttons ---------- */
.generate, 
.generate-btn,
button[type="submit"].generate {
  min-width: var(--button-min-width);
  height: var(--button-height);
  padding: 14px 28px;
  border-radius: var(--radius-md);
  background: linear-gradient(94deg, rgba(248,213,255,0.98), rgba(150,88,255,0.96));
  color: #12071a;
  font-weight: 900;
  font-size: 1.05rem;
  border: none !important;
  outline: none;
  cursor: pointer;
  box-shadow: 0 24px 58px rgba(111,59,230,0.28), 0 8px 18px rgba(0,0,0,0.24), inset 0 1px 0 rgba(255,255,255,0.2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform 0.14s ease, box-shadow 0.2s ease, background 0.18s ease;
  white-space: nowrap;
  font-family: inherit;
}

.generate:hover,
.generate-btn:hover {
  box-shadow: 0 32px 78px rgba(120,64,224,0.34);
  transform: translateY(-3px);
  background: linear-gradient(94deg, rgba(255,225,255,1), rgba(164,102,255,1));
}

.generate:active,
.generate-btn:active {
  transform: translateY(-1px);
}

.generate:disabled,
.generate-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ---------- Controls Layout ---------- */
.controls {
  width: 100%;
  max-width: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  align-items: center;
  gap: var(--space-md);
  margin-top: var(--space-md);
}

.controls > * {
  min-width: 0;
}

/* Center the generate button when it's alone or spans */
.controls .generate,
.controls .generate-btn {
  justify-self: center;
}

/* ---------- Aspect Ratio Buttons ---------- */
.aspect-image-controls {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
  justify-content: center;
}

.aspect-group {
  display: flex;
  gap: var(--space-xs);
}

.aspect-btn {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.02);
  color: var(--text-primary);
  font-weight: 700;
  font-size: 0.94rem;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
  min-width: 72px;
  text-align: center;
}

.aspect-btn:hover {
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.08);
}

.aspect-btn.active {
  background: linear-gradient(90deg, var(--accent-secondary), var(--accent-primary));
  color: #fff;
  border: none;
  box-shadow: var(--shadow-accent);
}

/* ---------- Desktop Sidebar - Professional Full-Height ---------- */
.slim-sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 1400;
  display: flex;
  flex-direction: column;
  gap: 0;
  align-items: center;
  padding: 0;
  width: 72px;
  background: linear-gradient(180deg, rgba(14,10,24,0.98), rgba(8,6,16,0.99));
  backdrop-filter: blur(24px) saturate(160%);
  border-radius: 0;
  box-shadow: 2px 0 24px rgba(0,0,0,0.3);
  border: none;
  border-right: 1px solid rgba(120,90,180,0.1);
  transition: width 0.32s cubic-bezier(0.4,0,0.2,1);
}

/* Sidebar Header with Brand */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 12px 16px 12px;
  width: 100%;
  border-bottom: 1px solid rgba(120,90,180,0.08);
  flex-shrink: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  text-decoration: none;
  padding: 0;
  margin: 0;
  border-radius: 12px;
  transition: background 0.2s ease, gap 0.3s ease;
  cursor: pointer !important;
  width: 48px;
  height: 48px;
  background: transparent;
  position: relative;
}

.sidebar-brand:hover {
  background: rgba(140,100,200,0.1);
  text-decoration: none;
}

.sidebar-brand-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: rgba(140,100,200,0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid rgba(140,100,200,0.12);
  transition: background 0.2s ease, border-color 0.2s ease;
  margin: 0;
  padding: 4px;
  position: relative;
  box-sizing: border-box;
  overflow: hidden;
}

.sidebar-brand:hover .sidebar-brand-icon {
  background: rgba(140,100,200,0.15);
  border-color: rgba(140,100,200,0.2);
}

.sidebar-brand-icon img {
  width: 100%;
  height: 100%;
  max-width: 40px;
  max-height: 40px;
  object-fit: contain;
  display: block;
}

.sidebar-brand-text {
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  opacity: 0;
  width: 0;
  overflow: hidden;
  transition: opacity 0.25s ease 0.1s, width 0.32s cubic-bezier(0.4,0,0.2,1);
  letter-spacing: -0.01em;
}

/* When sidebar is expanded, add gap and show text */
body.desktop-sidebar-expanded .sidebar-brand {
  gap: 12px !important;
  width: auto !important;
  justify-content: flex-start !important;
  padding: 0 12px !important;
}

body.desktop-sidebar-expanded .sidebar-brand-text {
  opacity: 1 !important;
  width: auto !important;
  overflow: visible !important;
}

.slim-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  width: 100%;
  padding: 20px 12px;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.nav-item {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none !important;
  color: rgba(180,170,200,0.85);
  background: transparent;
  transition: all 0.2s ease;
  position: relative;
  box-shadow: none;
  border: 1px solid transparent;
  cursor: pointer !important;
  margin-bottom: 4px;
  flex-shrink: 0;
}

.nav-item .icon {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  stroke-width: 1.8;
  fill: none;
  display: block;
  transition: stroke 0.2s ease;
}

.nav-item .label {
  position: absolute;
  left: 60px;
  white-space: nowrap;
  background: rgba(20,16,32,0.95);
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  transform-origin: left center;
  transform: translateX(-6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  font-weight: 600;
  font-size: 0.85rem;
  border: 1px solid rgba(120,100,160,0.12);
  z-index: 100;
}

.nav-item:hover {
  background: rgba(140,100,200,0.1);
  color: #fff;
  border-color: rgba(140,100,200,0.12);
}

.nav-item:hover .label {
  opacity: 1;
  transform: translateX(0);
}

.nav-item.active {
  background: rgba(140,56,209,0.18);
  color: #fff;
  border-color: rgba(140,100,200,0.2);
}

.nav-item.active .icon {
  stroke: #fff;
}

.nav-item.active .label {
  opacity: 1;
  transform: translateX(0);
}

/* Separator */
.sep {
  width: 32px;
  opacity: 0.1;
  border: none;
  border-top: 1px solid rgba(180,150,220,0.4);
  margin: 10px 0;
}

/* ---------- AI Button (Legacy - Hidden on Desktop) ---------- */
/* AI button is now integrated into sidebar header */
.ai-btn {
  display: none !important;
}

/* ---------- Format Description Box ---------- */
.format-desc {
  width: 100%;
  overflow: hidden;
  transition: max-height 0.32s cubic-bezier(0.2,0.9,0.3,1), 
              opacity 0.24s ease, 
              padding 0.24s ease;
  max-height: 0;
  opacity: 0;
  border-radius: var(--radius-md);
  padding: 0;
}

.format-desc.open {
  max-height: 360px;
  opacity: 1;
  padding: var(--space-md);
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(0,0,0,0.02));
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
}

.format-desc-inner {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.format-desc-inner h3,
#format_title {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-primary);
  margin: 0;
}

.format-desc-inner p,
#format_text {
  color: var(--text-secondary);
  font-size: 0.96rem;
  line-height: 1.5;
  margin: 0;
}

/* ---------- Result Boxes ---------- */
.result {
  width: 100%;
  margin-top: var(--space-md);
}

.box {
  padding: var(--space-lg);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(28,22,52,0.88), rgba(14,10,28,0.94));
  border: 1px solid rgba(180,150,240,0.1);
  color: var(--text-primary);
  box-shadow: 0 24px 64px rgba(4,2,12,0.5), 0 0 0 1px rgba(255,255,255,0.02) inset;
  position: relative;
  transition: all 0.35s cubic-bezier(0.22,0.9,0.36,1);
  backdrop-filter: blur(20px) saturate(180%);
}

.box:hover {
  transform: translateY(-4px);
  box-shadow: 0 32px 80px rgba(8,4,18,0.6);
  border-color: rgba(182,109,255,0.22);
}

.box.error {
  border-color: rgba(255,80,80,0.18);
  background: linear-gradient(180deg, rgba(50,14,14,0.8), rgba(30,10,10,0.88));
  color: #ffbdbd;
  box-shadow: 0 20px 50px rgba(255,80,80,0.08);
}

.box.success {
  border-color: rgba(110,200,125,0.18);
  background: linear-gradient(180deg, rgba(16,40,20,0.8), rgba(10,30,14,0.88));
  box-shadow: 0 20px 50px rgba(110,200,125,0.08);
}

/* ---------- Loading Spinner ---------- */
.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255,255,255,0.12);
  border-top-color: var(--accent-secondary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: var(--space-md) auto;
  box-shadow: 0 0 20px rgba(182,109,255,0.32);
}

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

.thinking-text {
  font-size: 1.2rem;
  margin-bottom: var(--space-sm);
  font-weight: 700;
  color: var(--text-primary);
}

.thinking-note {
  font-size: 0.96rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-md);
}

/* ---------- Mobile Toggle Button ---------- */
.mobile-toggle {
  position: fixed;
  top: var(--space-lg);
  left: 80px; /* Between AI button (20px + 48px = 68px) and auth controls */
  z-index: 10002; /* Above auth controls and sidebar */
  display: none;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(28,22,52,0.95), rgba(14,10,28,0.98));
  backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(180,150,240,0.15);
  color: rgba(220,200,255,0.95);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.22,0.9,0.36,1);
  box-shadow: 0 10px 32px rgba(4,2,12,0.5);
}

.mobile-toggle:hover {
  background: linear-gradient(135deg, rgba(36,28,62,0.98), rgba(18,14,32,0.99));
  transform: translateY(-2px);
  box-shadow: 0 14px 40px rgba(140,56,209,0.25);
  border-color: rgba(182,109,255,0.3);
}

.mobile-toggle:active {
  transform: translateY(0) scale(0.96);
}

.mobile-toggle svg {
  width: 22px;
  height: 18px;
  display: block;
  stroke: currentColor;
  stroke-width: 2.2;
}

/* Hide mobile toggle when sidebar is open (button is below sidebar) */
body.mobile-sidebar-open .mobile-toggle {
  z-index: 20000 !important; /* Below sidebar (22000) but above backdrop (21000) */
}

/* ---------- Mobile Sidebar Backdrop ---------- */
.mobile-sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4,2,8,0.5);
  backdrop-filter: blur(6px);
  z-index: 21000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

body.mobile-sidebar-open .mobile-sidebar-backdrop {
  opacity: 1;
  pointer-events: auto;
}

/* ---------- Floating Bar (Mobile Header Background) ---------- */
.floating-bar {
  display: none;
  background: linear-gradient(200deg, rgba(18,12,28,0.92), rgba(8,6,16,0.94));
  box-shadow: 0 12px 32px rgba(4,2,10,0.58);
  border-bottom: 1px solid rgba(255,255,255,0.04);
  backdrop-filter: blur(12px);
}

/* =================================================================
   RESPONSIVE BREAKPOINTS
   ================================================================= */

/* ---------- TABLET (721px - 980px) ---------- */
@media (max-width: 980px) and (min-width: 721px) {
  .center-ui.card-surface {
    max-width: 95%;
    padding: var(--space-lg);
  }
  
  .controls {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
  }
  
  .generate,
  .generate-btn {
    grid-column: 1 / -1;
    width: 100%;
    max-width: 100%;
  }
  
  select.format {
    max-width: 100%;
  }
}

/* ---------- MOBILE (<= 720px) ---------- */
@media (max-width: 720px) {
  :root {
    --top-offset: 74px;
    --space-xxl: 24px;
  }
  
  /* Prevent horizontal overflow */
  html,
  body {
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100vw !important;
  }
  
  .floating-bar {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: calc(var(--top-offset) - 2px);
    background: rgba(10,10,12,0.85);
    backdrop-filter: blur(10px) saturate(110%);
    z-index: 1800;
    border-bottom: 1px solid rgba(255,255,255,0.04);
  }
  
  .page-wrap {
    padding: var(--space-lg) var(--space-md);
    padding-top: calc(var(--top-offset) + var(--space-sm));
    min-height: 100vh;
  }
  
  .center-ui.card-surface {
    width: 100% !important;
    max-width: 100% !important;
    padding: 24px 18px !important;
    border-radius: 20px 20px 0 0 !important;
    margin: 0 !important;
    box-sizing: border-box !important;
  }
  
  /* Typography */
  h1,
  #gen-title,
  #tools-title,
  #mainTitle,
  #prompt-title {
    font-size: 1.4rem;
    margin-bottom: var(--space-sm);
  }
  
  p,
  .subtitle {
    font-size: 0.94rem;
    margin-bottom: var(--space-md);
  }
  
  /* Mode buttons */
  .modes {
    gap: var(--space-xs);
    margin: var(--space-md) 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 2px;
  }
  
  .modes::-webkit-scrollbar {
    display: none;
  }
  
  .mode-btn {
    flex: 0 0 auto;
    min-width: 92px;
    padding: 10px 16px;
    font-size: 0.92rem;
  }
  
  /* Textarea */
  textarea.prompt {
    width: 100%;
    max-width: 100%;
    min-height: 120px;
    padding: var(--space-md);
    font-size: 1rem;
    margin: 0;
  }
  
  /* Controls - stack vertically */
  .controls {
    display: flex !important;
    flex-direction: column !important;
    gap: var(--space-md) !important;
    width: 100% !important;
    max-width: 100% !important;
    margin-top: var(--space-md) !important;
  }
  
  .controls > * {
    width: 100% !important;
    max-width: 100% !important;
  }
  
  /* Select */
  select.format {
    width: 100% !important;
    max-width: 100% !important;
    height: var(--input-height);
    padding: 14px 48px 14px 16px;
    font-size: 1rem;
  }
  
  /* Generate button - full width CTA */
  .generate,
  .generate-btn {
    width: 100% !important;
    max-width: 100% !important;
    height: 56px !important;
    padding: 16px 24px !important;
    font-size: 1.08rem !important;
    margin: 0 !important;
  }
  
  /* Sidebar - completely hidden when closed (only toggle button visible) */
  .slim-sidebar,
  #slimSidebar {
    transform: translateX(-100%);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    position: fixed;
    left: 0;
    top: 0;
    width: 280px;
    height: 100%;
  }
  
  .nav-item {
    width: 52px;
    height: 52px;
  }
  
  .nav-item .icon {
    width: 22px;
    height: 22px;
  }
  
  /* Sidebar - expanded when open */
  body.mobile-sidebar-open .slim-sidebar {
    right: 0 !important;
    left: auto !important;
    top: 0 !important;
    bottom: 0 !important;
    width: min(82vw, 320px) !important;
    max-width: 320px !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-height: 100vh !important;
    max-height: 100dvh !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(140,100,200,0.3) transparent;
    border-radius: 24px 0 0 24px !important;
    padding: 0 !important;
    background: linear-gradient(170deg, 
      rgba(22,16,40,0.97) 0%, 
      rgba(12,9,22,0.98) 100%) !important;
    backdrop-filter: blur(32px) saturate(160%) !important;
    box-shadow: -12px 0 48px rgba(0,0,0,0.6) !important;
    transform: translateX(0) !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    z-index: 22000 !important;
    gap: 0 !important;
    border-left: 1px solid rgba(140,100,200,0.15) !important;
    display: flex !important;
    flex-direction: column !important;
  }
  
  /* Webkit scrollbar styling for mobile sidebar */
  body.mobile-sidebar-open .slim-sidebar::-webkit-scrollbar {
    width: 6px;
  }
  
  body.mobile-sidebar-open .slim-sidebar::-webkit-scrollbar-track {
    background: transparent;
  }
  
  body.mobile-sidebar-open .slim-sidebar::-webkit-scrollbar-thumb {
    background: rgba(140,100,200,0.3);
    border-radius: 3px;
  }
  
  body.mobile-sidebar-open .slim-sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(140,100,200,0.5);
  }
  
  /* Reduce spacing between sidebar-header and nav items on mobile */
  body.mobile-sidebar-open .slim-sidebar .sidebar-header {
    padding: 16px 12px 12px 12px !important;
    flex-shrink: 0 !important;
  }
  
  /* Sidebar inner nav container - FULL WIDTH */
  body.mobile-sidebar-open .slim-sidebar .slim-nav {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    gap: 0 !important;
    padding: 16px 14px 28px 14px !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-y: visible !important;
  }
  
  /* Hide desktop toggle in mobile sidebar */
  body.mobile-sidebar-open .slim-sidebar .desktop-sidebar-toggle {
    display: none !important;
  }
  
  /* NAV ITEMS - FULL WIDTH, schön und professionell */
  body.mobile-sidebar-open .slim-sidebar .nav-item,
  body.mobile-sidebar-open .slim-sidebar a.nav-item,
  body.mobile-sidebar-open #slimSidebar .nav-item,
  body.mobile-sidebar-open #slimSidebar a.nav-item {
    position: relative !important;
    display: flex !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    min-height: 56px !important;
    padding: 16px 18px !important;
    flex-direction: row !important;
    justify-content: flex-start !important;
    align-items: center !important;
    gap: 14px !important;
    background: rgba(255,255,255,0.03) !important;
    border: 1px solid rgba(255,255,255,0.06) !important;
    border-radius: 14px !important;
    margin: 0 0 8px 0 !important;
    transition: all 0.2s ease !important;
    box-shadow: 0 2px 10px rgba(0,0,0,0.12) !important;
    box-sizing: border-box !important;
    text-decoration: none !important;
    cursor: pointer !important;
  }
  
  body.mobile-sidebar-open .slim-sidebar .nav-item:hover,
  body.mobile-sidebar-open .slim-sidebar .nav-item:active,
  body.mobile-sidebar-open #slimSidebar .nav-item:hover,
  body.mobile-sidebar-open #slimSidebar .nav-item:active {
    background: rgba(255,255,255,0.055) !important;
    border-color: rgba(160,120,220,0.2) !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15) !important;
  }
  
  body.mobile-sidebar-open .slim-sidebar .nav-item.active,
  body.mobile-sidebar-open #slimSidebar .nav-item.active {
    background: linear-gradient(135deg, rgba(140,90,220,0.18), rgba(100,60,180,0.1)) !important;
    border-color: rgba(160,120,220,0.35) !important;
    box-shadow: 0 4px 16px rgba(140,56,209,0.2), inset 0 1px 0 rgba(255,255,255,0.05) !important;
  }
  
  body.mobile-sidebar-open .slim-sidebar .nav-item.active::before,
  body.mobile-sidebar-open #slimSidebar .nav-item.active::before {
    content: '' !important;
    position: absolute !important;
    left: 0 !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    width: 4px !important;
    height: 26px !important;
    background: linear-gradient(180deg, #b66dff, #8c38d1) !important;
    border-radius: 0 4px 4px 0 !important;
  }
  
  /* Icons */
  body.mobile-sidebar-open .slim-sidebar .nav-item .icon,
  body.mobile-sidebar-open #slimSidebar .nav-item .icon {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 24px !important;
    height: 24px !important;
    min-width: 24px !important;
    flex-shrink: 0 !important;
    stroke: rgba(190,170,230,0.85) !important;
    visibility: visible !important;
    opacity: 1 !important;
  }
  
  body.mobile-sidebar-open .slim-sidebar .nav-item:hover .icon,
  body.mobile-sidebar-open #slimSidebar .nav-item:hover .icon {
    stroke: rgba(220,200,255,0.95) !important;
  }
  
  body.mobile-sidebar-open .slim-sidebar .nav-item.active .icon,
  body.mobile-sidebar-open #slimSidebar .nav-item.active .icon {
    stroke: #d8b4fe !important;
  }
  
  /* Labels */
  body.mobile-sidebar-open .slim-sidebar .nav-item .label,
  body.mobile-sidebar-open #slimSidebar .nav-item .label {
    display: block !important;
    position: static !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
    background: none !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    border: none !important;
    font-size: 1.02rem !important;
    font-weight: 500 !important;
    color: rgba(240,235,255,0.94) !important;
    pointer-events: auto !important;
    letter-spacing: 0.01em !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    flex: 1 1 auto !important;
  }
  
  body.mobile-sidebar-open .slim-sidebar .nav-item:hover .label,
  body.mobile-sidebar-open #slimSidebar .nav-item:hover .label {
    color: #fff !important;
  }
  
  body.mobile-sidebar-open .slim-sidebar .nav-item.active .label,
  body.mobile-sidebar-open #slimSidebar .nav-item.active .label {
    color: #fff !important;
    font-weight: 600 !important;
  }
  
  /* Separator */
  body.mobile-sidebar-open .slim-sidebar .sep,
  body.mobile-sidebar-open #slimSidebar .sep {
    width: 100% !important;
    margin: 6px 0 14px 0 !important;
    height: 1px !important;
    border: none !important;
    background: linear-gradient(90deg, transparent, rgba(160,120,220,0.18), transparent) !important;
    opacity: 1 !important;
  }
  
  /* Mobile toggle - positioned between AI button and auth controls */
  .mobile-toggle {
    display: inline-flex;
    left: 76px !important; /* After AI button */
    top: 18px !important;
    z-index: 10002 !important;
    width: 46px !important;
    height: 46px !important;
  }
  
  /* Mobile AI Button */
  .ai-btn {
    width: 46px;
    height: 46px;
    top: 18px;
    left: 18px;
    border-radius: 14px !important;
  }
  
  .ai-btn img {
    width: 26px;
    height: 26px;
  }
  
  /* Image elements */
  img,
  video {
    max-width: 100% !important;
    height: auto !important;
  }
}

/* ---------- VERY SMALL SCREENS (<= 420px) ---------- */
@media (max-width: 420px) {
  .center-ui.card-surface {
    padding: 16px 14px !important;
    border-radius: 0 !important;
    margin: 0 !important;
  }
  
  h1,
  #gen-title,
  #tools-title,
  #mainTitle,
  #prompt-title {
    font-size: 1.3rem;
  }
  
  textarea.prompt {
    min-height: 100px;
    padding: var(--space-sm);
  }
  
  .mode-btn {
    min-width: 76px;
    padding: 8px 12px;
    font-size: 0.88rem;
  }
  
  .generate,
  .generate-btn {
    height: 52px !important;
    font-size: 1.02rem !important;
    padding: 14px 20px !important;
  }
  
  .aspect-btn {
    min-width: 64px;
    padding: 8px 12px;
    font-size: 0.9rem;
  }
}

/* =================================================================
   ACCESSIBILITY
   ================================================================= */

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus styles */
textarea.prompt:focus,
select.format:focus,
.generate:focus,
.generate-btn:focus,
.mode-btn:focus,
.nav-item:focus,
.aspect-btn:focus {
  outline: 2px solid rgba(166,77,255,0.5);
  outline-offset: 2px;
}

/* High contrast mode */
@media (prefers-contrast: high) {
  .mode-btn,
  select.format,
  textarea.prompt,
  .generate,
  .generate-btn,
  .nav-item {
    border-width: 2px;
  }
}

/* Screen reader only content */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* =================================================================
   UTILITY CLASSES
   ================================================================= */
.hidden {
  display: none !important;
}

.text-center {
  text-align: center !important;
}

.flex-center {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

/* =================================================================
   COOKIE BANNER - Desktop Position Override
   ================================================================= */
@media (min-width: 769px) {
  .hh-cookie-banner {
    left: auto !important;
    right: 12.5% !important;
    transform: translateX(50%) !important;
    bottom: 10vh !important;
  }
}
