/* ============================================================
   A!LEY PORTAL — CSS Theme System
   Matches the A!ley Desktop App (Dark, Light, Cyber)
   ============================================================ */

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

/* ── Inline SVG Icons ───────────────────────────────────────── */
svg.icon {
  display: inline-block;
  vertical-align: -0.15em;
  width: 1em;
  height: 1em;
  flex-shrink: 0;
}
svg.icon-sm { width: 0.85em; height: 0.85em; }
svg.icon-lg { width: 1.25em; height: 1.25em; }
.nav-link svg.icon { margin-right: 0.3em; }

:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'Roboto Mono', 'SF Mono', 'Fira Code', monospace;
  --radius: 0.625rem;
  --radius-lg: 0.875rem;
  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --max-width: 900px;
  --sidebar-width: 280px;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body { font-family: var(--font-sans); line-height: 1.6; min-height: 100dvh; overflow: hidden; }

/* Allow scrolling on non-chat pages */
html:has(.settings-page) body,
html:has(.auth-page) body,
html:has(.legal-page) body,
html:has(.admin-page) body,
html:has(.gallery-page) body,
html:has(.blog-page) body,
html:has(.feed-page) body,
html:has(.about-page) body,
html:has(.faq-page) body,
html:has(.landing-page) body,
html:has(.book-page) body,
html:has(.learning-page) body,
html:has(.gen-page) body,
html:has(.forum-page) body {
  overflow-y: auto;
  overflow-x: hidden;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }
button { cursor: pointer; font-family: inherit; }
input, textarea { font-family: inherit; }

/* ── Focus styles ───────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ══════════════════════════════════════════════════════════════
   🌙 DARK THEME (default — matches .dark from globals.css)
   ══════════════════════════════════════════════════════════════ */
.theme-dark {
  --background: #000000;
  --foreground: #ffffff;
  --card: #1a1a1a;
  --card-foreground: #ffffff;
  --muted: #333333;
  --muted-foreground: #a3a3a3;
  --primary: #be123c;
  --primary-foreground: #ffffff;
  --secondary: #0891b2;
  --secondary-foreground: #ffffff;
  --accent: #0891b2;
  --accent-foreground: #ffffff;
  --destructive: #ef4444;
  --border: #be123c;
  --input: #333333;
  --ring: rgba(190, 18, 60, 0.5);
  --sidebar-bg: #1a1a1a;
  --sidebar-border: #be123c;
  --bubble-user: #be123c;
  --bubble-user-fg: #ffffff;
  --bubble-ai: #1a1a1a;
  --bubble-ai-fg: #ffffff;
  --glow: rgba(190, 18, 60, 0.15);
  color-scheme: dark;
}

/* ══════════════════════════════════════════════════════════════
   ☀️ LIGHT THEME (matches :root from globals.css)
   ══════════════════════════════════════════════════════════════ */
.theme-light {
  --background: #ffffff;
  --foreground: #000000;
  --card: #fdf2f8;
  --card-foreground: #000000;
  --muted: #f0fdf4;
  --muted-foreground: #374151;
  --primary: #be123c;
  --primary-foreground: #ffffff;
  --secondary: #0891b2;
  --secondary-foreground: #ffffff;
  --accent: #0891b2;
  --accent-foreground: #ffffff;
  --destructive: #be123c;
  --border: #e0e0e0;
  --input: #f9fafb;
  --ring: rgba(0, 0, 0, 0.2);
  --sidebar-bg: #fdf2f8;
  --sidebar-border: #e0e0e0;
  --bubble-user: #be123c;
  --bubble-user-fg: #ffffff;
  --bubble-ai: #fdf2f8;
  --bubble-ai-fg: #1a1a1a;
  --glow: rgba(190, 18, 60, 0.08);
  color-scheme: light;
}

/* ══════════════════════════════════════════════════════════════
   ⚡ CYBER THEME (matches .cyber from globals.css)
   ══════════════════════════════════════════════════════════════ */
.theme-cyber {
  --background: #1a1d23;
  --foreground: #c9d1d9;
  --card: #22262e;
  --card-foreground: #c9d1d9;
  --muted: #2d333b;
  --muted-foreground: #8b949e;
  --primary: #00d4aa;
  --primary-foreground: #0d1117;
  --secondary: #56d4dd;
  --secondary-foreground: #0d1117;
  --accent: #7ee787;
  --accent-foreground: #0d1117;
  --destructive: #f85149;
  --border: #00d4aa55;
  --input: #2d333b;
  --ring: rgba(0, 212, 170, 0.5);
  --sidebar-bg: #161920;
  --sidebar-border: #00d4aa55;
  --bubble-user: #00d4aa;
  --bubble-user-fg: #0d1117;
  --bubble-ai: #22262e;
  --bubble-ai-fg: #c9d1d9;
  --glow: rgba(0, 212, 170, 0.12);
  color-scheme: dark;
}

/* ══════════════════════════════════════════════════════════════
   🎭 AILEY THEME — Mood-reactive (default)
   Base = dark + rose, shifts with mood via JS
   ══════════════════════════════════════════════════════════════ */
.theme-ailey {
  --background: #0a0a0a;
  --foreground: #f0f0f0;
  --card: #161616;
  --card-foreground: #f0f0f0;
  --muted: #2a2a2a;
  --muted-foreground: #a0a0a0;
  --primary: #e11d48;
  --primary-foreground: #ffffff;
  --secondary: #0891b2;
  --secondary-foreground: #ffffff;
  --accent: #0891b2;
  --accent-foreground: #ffffff;
  --destructive: #ef4444;
  --border: rgba(225, 29, 72, 0.35);
  --input: #1e1e1e;
  --ring: rgba(225, 29, 72, 0.4);
  --sidebar-bg: #111111;
  --sidebar-border: rgba(225, 29, 72, 0.3);
  --bubble-user: #e11d48;
  --bubble-user-fg: #ffffff;
  --bubble-ai: #161616;
  --bubble-ai-fg: #f0f0f0;
  --glow: rgba(225, 29, 72, 0.15);
  color-scheme: dark;
}

/* Smooth transition for all CSS variable changes (mood shifts) */
.theme-ailey,
.theme-ailey .chat-header,
.theme-ailey .sidebar,
.theme-ailey .ki-banner,
.theme-ailey .msg-bubble,
.theme-ailey .send-btn,
.theme-ailey .btn-primary,
.theme-ailey .welcome-avatar,
.theme-ailey .sidebar-logo,
.theme-ailey .chat-header-avatar,
.theme-ailey .status-dot,
.theme-ailey .suggestion-chip,
.theme-ailey .portal-footer,
.theme-ailey .auth-card,
.theme-ailey .auth-logo,
.theme-ailey .header-tabs,
.theme-ailey .header-tab,
.theme-ailey .header-tab.active {
  transition: background 1.5s ease, color 1.2s ease, border-color 1.5s ease,
              box-shadow 1.5s ease, border 1.5s ease;
}

body {
  background: var(--background);
  color: var(--foreground);
  transition: background 1.2s ease, color 1.2s ease;
}

/* ── KI-Banner (EU AI Act) ──────────────────────────────────── */
.ki-banner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 1rem;
  background: var(--muted);
  color: var(--muted-foreground);
  font-size: 0.75rem;
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 100;
  flex-shrink: 0;
}
.ki-badge {
  background: var(--primary);
  color: var(--primary-foreground);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-weight: 700;
  font-size: 0.65rem;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

/* ══════════════════════════════════════════════════════════════
   LAYOUT — Sidebar + Main Chat Area
   ══════════════════════════════════════════════════════════════ */
.portal-layout {
  display: flex;
  height: calc(100svh - 48px - 30px); /* minus nav + ki-banner */
  overflow: hidden;
}

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform var(--transition);
  z-index: 50;
}

.sidebar-header {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-logo {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--primary);
  box-shadow: 0 0 12px var(--glow);
}

.sidebar-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--foreground);
}

.sidebar-subtitle {
  font-size: 0.7rem;
  color: var(--muted-foreground);
  letter-spacing: 0.03em;
}

.sidebar-actions {
  padding: 0.75rem;
  display: flex;
  gap: 0.5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 500;
  border: none;
  transition: all var(--transition);
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-foreground);
}
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }

.btn-ghost {
  background: transparent;
  color: var(--foreground);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--muted); }

.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-full { width: 100%; }
.btn-icon { padding: 0.5rem; width: 36px; height: 36px; }

/* Conversation List */
.conv-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
}

.conv-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition);
  color: var(--foreground);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-size: 0.85rem;
}
.conv-item:hover { background: var(--muted); }
.conv-item.active { background: var(--primary); color: var(--primary-foreground); }
.conv-item .conv-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-item .conv-time { font-size: 0.7rem; color: var(--muted-foreground); white-space: nowrap; flex-shrink: 0; }
.conv-item.active .conv-time { color: var(--primary-foreground); opacity: 0.7; }
.conv-item .conv-icon { font-size: 1rem; opacity: 0.6; }

/* Delete button on conversations */
.conv-delete {
  background: none; border: none; color: var(--muted-foreground);
  font-size: 0.8rem; padding: 0.15rem 0.3rem; border-radius: 4px;
  opacity: 0; transition: opacity var(--transition), color var(--transition);
  cursor: pointer; flex-shrink: 0;
}
.conv-item:hover .conv-delete { opacity: 0.6; }
.conv-delete:hover { opacity: 1 !important; color: var(--destructive); }

/* On touch devices, always show delete button */
@media (hover: none) {
  .conv-delete { opacity: 0.5; }
}

/* Message action buttons (copy) */
.msg-action-btn {
  background: none; border: none; color: var(--muted-foreground);
  font-size: 0.7rem; padding: 0.1rem 0.25rem; border-radius: 3px;
  cursor: pointer; opacity: 0; transition: opacity var(--transition);
}
.msg:hover .msg-action-btn { opacity: 0.6; }
.msg-action-btn:hover { opacity: 1 !important; }

/* On touch devices, always show copy button */
@media (hover: none) {
  .msg-action-btn { opacity: 0.6; }
}

.conv-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--muted-foreground);
  font-size: 0.85rem;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.sidebar-user {
  flex: 1;
  overflow: hidden;
}
.sidebar-user-name {
  font-size: 0.85rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-user-email {
  font-size: 0.7rem;
  color: var(--muted-foreground);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* V$ badge in sidebar */
.vdollars-badge {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  padding: 2px 8px;
  margin-top: 4px;
  display: inline-block;
  cursor: default;
  transition: color 0.3s;
}
/* V$ badge in chat header (always visible) */
.vdollars-header-badge {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent, #a78bfa);
  background: rgba(var(--accent-rgb, 100,100,200), 0.12);
  border: 1px solid rgba(var(--accent-rgb, 100,100,200), 0.25);
  border-radius: 8px;
  padding: 3px 10px;
  white-space: nowrap;
  flex-shrink: 0;
  margin-left: auto;
  transition: color 0.3s, border-color 0.3s;
}
.vdollars-header-badge.warn { color: #fbbf24; border-color: rgba(251,191,36,0.3); }
.vdollars-header-badge.low  { color: #f87171; border-color: rgba(248,113,113,0.3); }

/* ── Main Chat Area ─────────────────────────────────────────── */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-header {
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  background: var(--card);
}

.chat-header-avatar {
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--primary);
  flex-shrink: 0;
}

.chat-header-info { flex: 1; min-width: 0; }
.chat-header-title { font-size: 0.95rem; font-weight: 600; }
.chat-header-status { font-size: 0.7rem; color: var(--muted-foreground); display: flex; align-items: center; gap: 0.35rem; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: #22c55e; display: inline-block; }
.status-dot.offline { background: var(--muted-foreground); }
.status-dot.thinking { background: #f59e0b; animation: pulse-dot 1.5s ease-in-out infinite; }
.status-dot.generating { background: #f97316; animation: pulse-dot 1.2s ease-in-out infinite; box-shadow: 0 0 6px #f97316; }

@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--foreground);
  font-size: 1.3rem;
  padding: 0.5rem;
  cursor: pointer;
  border-radius: var(--radius);
  transition: background var(--transition);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.menu-toggle:hover { background: var(--muted); }
.menu-toggle:active { background: var(--muted); }

/* Chat Messages Area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  scroll-behavior: smooth;
}

/* Welcome Screen */
.welcome-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
  gap: 1.5rem;
}

.welcome-avatar {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--primary);
  box-shadow: 0 0 30px var(--glow), 0 0 60px var(--glow);
  animation: welcome-glow 3s ease-in-out infinite;
}

@keyframes welcome-glow {
  0%, 100% { box-shadow: 0 0 30px var(--glow), 0 0 60px var(--glow); }
  50% { box-shadow: 0 0 40px var(--glow), 0 0 80px var(--glow); }
}

.welcome-title {
  font-size: 1.5rem;
  font-weight: 700;
}
.welcome-title .highlight { color: var(--primary); }

.welcome-greeting {
  font-size: 1rem;
  font-weight: 500;
  color: var(--foreground);
  margin-top: -0.25rem;
  font-style: italic;
}

.welcome-text {
  color: var(--muted-foreground);
  max-width: 400px;
  font-size: 0.9rem;
  line-height: 1.7;
}

.welcome-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  max-width: 500px;
}
.suggestion-chip {
  padding: 0.4rem 0.8rem;
  border-radius: 99px;
  font-size: 0.8rem;
  background: var(--muted);
  color: var(--foreground);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--transition);
}
.suggestion-chip:hover {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: var(--primary);
  transform: translateY(-1px);
}

/* Chat Bubbles */
.msg {
  display: flex;
  gap: 0.5rem;
  max-width: 80%;
  min-width: 0;
  animation: msg-in 0.3s ease-out;
}
@keyframes msg-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg.ai { align-self: flex-start; }

.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  aspect-ratio: 1;
  margin-top: 0.2rem;
}
.msg.ai .msg-avatar { border: 2px solid var(--primary); }

/* User initials avatar */
.user-initials {
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-foreground);
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 0.03em;
}
/* User uploaded avatar in chat */
.user-avatar-img { object-fit: cover; border-radius: 50%; border: 2px solid var(--primary); }

/* Ailey avatar — clickable, subtle hover only (full preview via lightbox) */
.ailey-avatar {
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  position: relative;
}
.ailey-avatar:hover {
  transform: scale(1.08);
  box-shadow: 0 0 16px var(--glow);
  border-color: var(--primary);
}

/* ── Avatar Lightbox (click-to-view full mood portrait) ────── */
.avatar-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1.25rem;
  background: rgba(0, 0, 0, 0.8);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  animation: lb-fade-in 0.25s ease-out;
  cursor: pointer;
}
.avatar-lightbox.visible {
  display: flex;
}
.avatar-lightbox-inner {
  position: relative;
  width: min(80vw, 360px);
  height: min(80vw, 360px);
  animation: lb-zoom-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.avatar-lightbox-inner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 20px;
  border: 3px solid var(--primary);
  box-shadow: 0 0 60px var(--glow), 0 0 120px var(--glow), 0 12px 40px rgba(0,0,0,0.5);
}
.avatar-lightbox-mood {
  font-size: 1rem;
  color: var(--foreground);
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  padding: 0.4rem 1.2rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 99px;
  box-shadow: 0 0 20px var(--glow);
  letter-spacing: 0.02em;
}
.avatar-lightbox-mood:empty { display: none; }
.avatar-lightbox-close {
  position: absolute;
  top: -0.6rem;
  right: -0.6rem;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--foreground);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
  z-index: 1;
}
.avatar-lightbox-close:hover {
  background: var(--primary);
  color: var(--primary-foreground);
}
@keyframes lb-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes lb-zoom-in { from { opacity: 0; transform: scale(0.8); } to { opacity: 1; transform: scale(1); } }

.msg-sender {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted-foreground);
  margin-bottom: 0.15rem;
  letter-spacing: 0.02em;
}
.msg.ai .msg-sender { color: var(--primary); }
.msg.user .msg-sender { text-align: right; }

/* Flex-child between .msg and .msg-bubble needs min-width:0
   so code blocks respect the parent width instead of overflowing */
.msg-content-wrap {
  min-width: 0;
}

.msg-bubble {
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius-lg);
  line-height: 1.6;
  font-size: 0.9rem;
  word-break: break-word;
  overflow: hidden;
  min-width: 0;
}
.msg.user .msg-bubble {
  background: var(--bubble-user);
  color: var(--bubble-user-fg);
  border-bottom-right-radius: 0.2rem;
}
.msg.ai .msg-bubble {
  background: var(--bubble-ai);
  color: var(--bubble-ai-fg);
  border-bottom-left-radius: 0.2rem;
  border: 1px solid var(--border);
}

/* 🐹 Hamster Mode: warm orange bubble + round avatar */
.msg.hamster .msg-bubble {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #1c1917;
  border: 1px solid rgba(245, 158, 11, 0.4);
}
.msg.hamster .msg-sender {
  color: #f59e0b !important;
}
.msg.hamster .msg-avatar {
  border-color: #f59e0b !important;
}
.msg.hamster .hamster-avatar {
  border-radius: 50%;
  object-fit: cover;
}

.msg-time {
  font-size: 0.65rem;
  color: var(--muted-foreground);
  margin-top: 0.25rem;
  text-align: right;
}
.msg.ai .msg-time { text-align: left; }

/* Message meta row with copy button */
.msg-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
}
.msg.user .msg-meta { justify-content: flex-end; }
.msg.ai .msg-meta { justify-content: flex-start; }
.msg-action-btn {
  background: none; border: none; color: var(--muted-foreground);
  font-size: 0.7rem; padding: 0.1rem 0.25rem; border-radius: 3px;
  cursor: pointer; opacity: 0; transition: opacity var(--transition);
}
.msg:hover .msg-action-btn { opacity: 0.6; }
.msg-action-btn:hover { opacity: 1 !important; background: var(--muted); }

.msg-mood {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.65rem;
  color: var(--muted-foreground);
  margin-top: 0.15rem;
}
.msg-mood-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--primary);
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  align-self: flex-start;
  max-width: 80%;
  animation: msg-in 0.3s ease-out;
}
.typing-dots {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0.75rem 1rem;
  background: var(--bubble-ai);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  border-bottom-left-radius: 0.2rem;
}
.typing-dots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--muted-foreground);
  animation: typing-bounce 1.4s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing-bounce { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-4px); } }

/* ── Sleeping Overlay ───────────────────────────────────────── */
.sleeping-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.sleeping-content {
  text-align: center;
  padding: 2rem;
  max-width: 400px;
}
.sleeping-emoji {
  font-size: 4rem;
  margin-bottom: 1rem;
  animation: sleeping-float 3s ease-in-out infinite;
}
.sleeping-content h3 {
  font-size: 1.3rem;
  color: var(--foreground);
  margin-bottom: 0.75rem;
}
.sleeping-content p {
  color: var(--muted-foreground);
  font-size: 0.9rem;
  line-height: 1.5;
}
@keyframes sleeping-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

/* ── Chat Input ─────────────────────────────────────────────── */
.chat-input-area {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--card);
}

/* ── Chat Mode Selector ─────────────────────────────────────── */
.chat-mode-selector {
  display: flex;
  gap: 0.25rem;
  justify-content: center;
  margin-bottom: 0.5rem;
  max-width: var(--max-width);
  margin-left: auto;
  margin-right: auto;
}

/* Dropdown mode selector */
.chat-mode-dropdown {
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--input);
  color: var(--foreground);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all var(--transition);
  outline: none;
  min-width: 160px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  padding-right: 1.8rem;
}
.chat-mode-dropdown:hover {
  border-color: var(--primary);
  background-color: var(--accent);
}
.chat-mode-dropdown:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--ring);
}
.chat-mode-dropdown option {
  background: var(--card);
  color: var(--foreground);
  padding: 0.3rem;
}

/* ── Custom chat-mode dropdown (icon-capable, smartphone-friendly) ── */
.chat-mode-custom {
  position: relative;
  display: inline-block;
  min-width: 200px;
}
.chat-mode-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--input);
  color: var(--foreground);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all var(--transition);
  outline: none;
  text-align: left;
}
.chat-mode-trigger:hover {
  border-color: var(--primary);
  background-color: var(--accent);
}
.chat-mode-trigger:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--ring);
}
.chat-mode-trigger-label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex: 1;
  min-width: 0;
}
.chat-mode-trigger-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  color: var(--primary);
  flex-shrink: 0;
}
.chat-mode-trigger-icon svg {
  width: 16px;
  height: 16px;
}
.chat-mode-trigger-name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-mode-trigger-cost {
  font-size: 0.72rem;
  opacity: 0.65;
  margin-left: auto;
  padding-left: 0.5rem;
  white-space: nowrap;
}
.chat-mode-trigger-chev {
  display: inline-flex;
  align-items: center;
  opacity: 0.6;
  transition: transform var(--transition);
}
.chat-mode-trigger-chev svg { width: 14px; height: 14px; }
.chat-mode-custom[data-open="true"] .chat-mode-trigger-chev {
  transform: rotate(180deg);
}

.chat-mode-panel {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  right: 0;
  min-width: 280px;
  max-width: 380px;
  list-style: none;
  margin: 0;
  padding: 0.3rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
  z-index: 100;
  max-height: 70vh;
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition: opacity 120ms ease, transform 120ms ease, visibility 120ms;
}
.chat-mode-custom[data-open="true"] .chat-mode-panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.chat-mode-item {
  padding: 0.55rem 0.6rem;
  border-radius: calc(var(--radius) - 2px);
  cursor: pointer;
  transition: background 120ms;
}
.chat-mode-item:hover,
.chat-mode-item:focus-visible {
  background: var(--accent);
}
.chat-mode-item.active {
  background: color-mix(in srgb, var(--primary) 14%, transparent);
}
.chat-mode-item-head {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--foreground);
}
.chat-mode-item-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  color: var(--primary);
  flex-shrink: 0;
}
.chat-mode-item-icon svg { width: 16px; height: 16px; }
.chat-mode-item-name { flex: 1; }
.chat-mode-item-cost {
  font-size: 0.72rem;
  opacity: 0.65;
  padding: 0.1rem 0.4rem;
  border-radius: 6px;
  background: color-mix(in srgb, var(--foreground) 8%, transparent);
}
.chat-mode-item-desc {
  margin-top: 0.25rem;
  font-size: 0.74rem;
  line-height: 1.35;
  opacity: 0.72;
  color: var(--muted-foreground);
  padding-left: calc(18px + 0.45rem);
}
@media (max-width: 640px) {
  .chat-mode-custom { min-width: 0; flex: 0 1 auto; max-width: 52%; }
  .chat-mode-panel {
    left: 0;
    right: auto;
    min-width: 260px;
    max-width: 90vw;
  }
  .chat-mode-item-desc {
    font-size: 0.78rem;
    padding-left: 0;
  }
  .chat-mode-trigger-cost { display: none; }
}

/* Legacy button styles kept for backwards compat */
.chat-mode-btn {
  position: relative;
  padding: 0.3rem 0.7rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--input);
  color: var(--muted-foreground);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition);
  line-height: 1;
}
.chat-mode-btn:hover {
  background: var(--accent);
  color: var(--foreground);
  border-color: var(--primary);
}
.chat-mode-btn.active {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--ring);
}

/* Custom tooltip (replaces native title for prettier look) */
.chat-mode-btn[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--card, #1a1a1a);
  color: var(--card-foreground, var(--foreground));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.45rem 0.65rem;
  font-size: 0.72rem;
  line-height: 1.4;
  white-space: normal;
  width: max-content;
  max-width: 220px;
  z-index: 100;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0,0,0,.35);
  text-align: center;
  opacity: 1;
}
.chat-mode-btn[data-tooltip]:hover::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--card, #1a1a1a);
  z-index: 101;
  pointer-events: none;
}

/* ── Glossary hint tooltip (small ? next to mode names) ───── */
.glossary-hint {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  margin-left: 4px;
  font-size: 0.6rem;
  font-weight: 700;
  line-height: 1;
  color: var(--muted-foreground);
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: help;
  vertical-align: middle;
  position: relative;
  opacity: 0.6;
  transition: opacity 0.15s;
}
.glossary-hint:hover { opacity: 1; }
.glossary-hint::after {
  content: attr(data-glossary);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--card, #1a1a1a);
  color: var(--card-foreground, var(--foreground));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.7rem;
  font-size: 0.7rem;
  font-weight: 400;
  line-height: 1.45;
  white-space: normal;
  width: max-content;
  max-width: 240px;
  z-index: 200;
  pointer-events: none;
  box-shadow: 0 4px 14px rgba(0,0,0,.4);
  text-align: left;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s, visibility 0.15s;
}
.glossary-hint:hover::after {
  opacity: 1;
  visibility: visible;
}

/* ── File Upload Preview Bar ──────────────────────────────── */
.file-preview-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  margin: 0 auto 0.35rem;
  max-width: var(--max-width);
  background: var(--card);
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  font-size: 0.8rem;
  color: var(--foreground);
}
#file-preview-icon svg { width: 16px; height: 16px; vertical-align: -2px; }
.inline-icon { display: inline; vertical-align: -3px; }
.file-preview-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.85;
}
.file-preview-close {
  background: none;
  border: none;
  color: var(--muted-foreground);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0 0.25rem;
  line-height: 1;
  transition: color var(--transition);
}
.file-preview-close:hover {
  color: var(--destructive, #ef4444);
}
.hidden-file-input {
  display: none;
}

.chat-input-row {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
  max-width: var(--max-width);
  margin: 0 auto;
}

.chat-input {
  flex: 1;
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--input);
  color: var(--foreground);
  font-size: 0.9rem;
  resize: none;
  min-height: 42px;
  max-height: 150px;
  transition: border-color var(--transition);
  line-height: 1.5;
}
.chat-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}
.chat-input::placeholder { color: var(--muted-foreground); }

.send-btn {
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  background: var(--primary);
  color: var(--primary-foreground);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
}
.send-btn:hover:not(:disabled) { opacity: 0.9; transform: translateY(-1px); }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.send-btn svg { width: 18px; height: 18px; }
.send-btn.stop-mode {
  background: var(--destructive, #e74c3c);
  animation: stop-pulse 1.5s ease-in-out infinite;
}
.send-btn.stop-mode svg { width: 16px; height: 16px; }
@keyframes stop-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.chat-input-hint {
  font-size: 0.7rem;
  color: var(--muted-foreground);
  text-align: center;
  margin-top: 0.35rem;
}

/* Web search toggle button */
.input-toggle-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  background: var(--muted);
  color: var(--muted-foreground);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.input-toggle-btn:hover { border-color: var(--primary); color: var(--foreground); }
.input-toggle-btn.active {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: var(--primary);
  box-shadow: 0 0 8px var(--glow);
}

/* ══════════════════════════════════════════════════════════════
   AUTH PAGES (Login / Register)
   ══════════════════════════════════════════════════════════════ */
.auth-page {
  min-height: calc(100dvh - 30px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 2rem;
  box-shadow: 0 0 40px var(--glow);
}

.auth-header {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-logo {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--primary);
  box-shadow: 0 0 20px var(--glow);
  margin: 0 auto 1rem;
  display: block;
}

.auth-title {
  font-size: 1.3rem;
  font-weight: 700;
}
.auth-title .highlight { color: var(--primary); }

.auth-subtitle {
  font-size: 0.85rem;
  color: var(--muted-foreground);
  margin-top: 0.25rem;
}

.form-group {
  margin-bottom: 1rem;
}
.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--foreground);
}
.form-input {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--input);
  color: var(--foreground);
  font-size: 0.9rem;
  transition: border-color var(--transition);
}
.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}

.form-error {
  color: var(--destructive);
  font-size: 0.8rem;
  margin-top: 0.5rem;
  display: none;
}
.form-error.visible { display: block; }

.form-success {
  color: #22c55e;
  font-size: 0.85rem;
  margin-top: 0.5rem;
  display: none;
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
}
.form-success.visible { display: block; }

.form-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--muted-foreground);
  margin-bottom: 1rem;
}
.form-checkbox input[type="checkbox"] {
  margin-top: 0.2rem;
  accent-color: var(--primary);
}

.auth-link {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.85rem;
  color: var(--muted-foreground);
}
.auth-link a { color: var(--primary); font-weight: 600; }

/* ══════════════════════════════════════════════════════════════
   SETTINGS PAGE
   ══════════════════════════════════════════════════════════════ */
.settings-page {
  max-width: 600px;
  margin: 0 auto;
  padding: 2rem;
}

.settings-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.settings-section h2 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.theme-selector {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.theme-option {
  flex: 1;
  min-width: 100px;
  padding: 1rem;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: var(--muted);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
}
.theme-option:hover { border-color: var(--primary); }
.theme-option.active { border-color: var(--primary); box-shadow: 0 0 15px var(--glow); }
.theme-option-icon { font-size: 1.5rem; margin-bottom: 0.35rem; }
.theme-option-label { font-size: 0.8rem; font-weight: 600; }

.danger-zone {
  border-color: var(--destructive);
}
.danger-zone h2 { color: var(--destructive); }

/* ══════════════════════════════════════════════════════════════
   ADMIN PANEL
   ══════════════════════════════════════════════════════════════ */
.admin-page {
  padding: 1.5rem;
  max-width: 1000px;
  margin: 0 auto;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
}
.stat-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
}
.stat-label {
  font-size: 0.75rem;
  color: var(--muted-foreground);
  margin-top: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.admin-table th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-bottom: 2px solid var(--border);
  color: var(--muted-foreground);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.admin-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
.admin-table tr:hover td { background: var(--muted); }

.badge {
  display: inline-flex;
  padding: 0.15rem 0.5rem;
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 600;
}
.badge-active { background: #22c55e33; color: #22c55e; }
.badge-suspended { background: #f59e0b33; color: #f59e0b; }
.badge-admin { background: #be123c33; color: #be123c; }

/* Limits / Settings sliders in admin panel */
.limit-slider-group {
  margin-bottom: 0.75rem;
  background: var(--card);
  border: 1px solid var(--border);
  padding: 0.6rem;
  border-radius: 8px;
}
.limit-slider-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted-foreground);
  margin-bottom: 0.35rem;
}
.limit-slider-group input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
}
.limit-slider-group strong {
  color: var(--foreground);
}

/* ══════════════════════════════════════════════════════════════
   LEGAL PAGES (Impressum, Datenschutz)
   ══════════════════════════════════════════════════════════════ */
.legal-page {
  max-width: 700px;
  margin: 0 auto;
  padding: 2rem;
  line-height: 1.8;
}
.legal-page h1 { font-size: 1.5rem; margin-bottom: 1rem; color: var(--primary); }
.legal-page h2 { font-size: 1.1rem; margin: 1.5rem 0 0.75rem; }
.legal-page p { margin-bottom: 0.75rem; color: var(--muted-foreground); }
.legal-page a { color: var(--primary); }
.legal-back { display: inline-block; margin-bottom: 1.5rem; color: var(--muted-foreground); font-size: 0.85rem; }

/* ══════════════════════════════════════════════════════════════
   FOOTER
   ══════════════════════════════════════════════════════════════ */
.portal-footer {
  padding: 0.5rem 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.7rem;
  color: var(--muted-foreground);
}
.footer-inner { max-width: var(--max-width); margin: 0 auto; text-align: center; }
.footer-links { display: flex; align-items: center; justify-content: center; gap: 0.5rem; flex-wrap: wrap; }
.footer-links a { color: var(--muted-foreground); }
.footer-links a:hover { color: var(--primary); }
.footer-links .sep { opacity: 0.3; }
.footer-copyright {
  margin-top: 0.4rem;
  font-size: 0.8rem;
  color: var(--muted-foreground);
}
.footer-copyright .highlight { color: var(--primary); }
.footer-label {
  font-weight: 600;
  color: var(--foreground);
  text-decoration: none;
}
.footer-label:hover { color: var(--primary); }
.footer-ki { margin-top: 0.25rem; opacity: 0.6; }

/* ══════════════════════════════════════════════════════════════
   404 PAGE
   ══════════════════════════════════════════════════════════════ */
.not-found {
  min-height: calc(100dvh - 30px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 1rem;
}
.not-found h1 { font-size: 4rem; color: var(--primary); font-weight: 800; }
.not-found p { color: var(--muted-foreground); }

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════ */

/* ── Mobile: up to 768px ────────────────────────────────────── */
@media (max-width: 768px) {
  /* Lock viewport — only on chat page (has .portal-layout)
     Use 100svh (small viewport height) so Safari toolbar is never in the way.
     -webkit-fill-available is the older Safari fallback. */
  html:has(.portal-layout), html:has(.portal-layout) body {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: -webkit-fill-available;   /* Safari < 15.4 fallback */
    height: 100svh;                    /* Modern: small viewport height */
  }

  /* Other pages: allow scroll but prevent horizontal overflow */
  html:has(.settings-page), html:has(.auth-page), html:has(.legal-page),
  html:has(.gallery-page), html:has(.blog-page), html:has(.feed-page),
  html:has(.about-page), html:has(.faq-page), html:has(.landing-page),
  html:has(.book-page), html:has(.forum-page),
  html:has(.settings-page) body, html:has(.auth-page) body, html:has(.legal-page) body,
  html:has(.gallery-page) body, html:has(.blog-page) body, html:has(.feed-page) body,
  html:has(.about-page) body, html:has(.faq-page) body, html:has(.landing-page) body,
  html:has(.book-page) body, html:has(.forum-page) body {
    overflow-x: hidden;
    overflow-y: auto;
    position: static;
    height: auto;
  }

  /* KI Banner smaller on mobile */
  .ki-banner {
    font-size: 0.65rem;
    padding: 0.25rem 0.75rem;
  }
  .ki-badge { font-size: 0.6rem; padding: 0.05rem 0.3rem; }

  /* Layout fills remaining space (nav 44px + KI banner ~24px on mobile) */
  .portal-layout {
    height: calc(100svh - 44px - 24px);
  }

  /* Sidebar: off-screen drawer */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 85%;
    max-width: 320px;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 200;
    box-shadow: 4px 0 20px rgba(0,0,0,0.3);
  }
  .sidebar.open {
    transform: translateX(0);
  }

  /* Overlay behind sidebar */
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 199;
    -webkit-tap-highlight-color: transparent;
  }
  .sidebar-overlay.visible { display: block; }

  /* Show hamburger */
  .menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
  }

  /* Chat bubbles wider on mobile */
  .msg { max-width: 92%; }

  /* Delete button always visible on mobile (no hover on touch) */
  .conv-delete { opacity: 0.5; }

  /* Welcome screen smaller */
  .welcome-screen { padding: 1.5rem 1rem; gap: 1rem; }
  .welcome-avatar { width: 80px; height: 80px; }
  .welcome-title { font-size: 1.1rem; }
  .welcome-greeting { font-size: 0.85rem; }
  .welcome-text { font-size: 0.8rem; max-width: 300px; }
  .suggestion-chip { font-size: 0.75rem; padding: 0.3rem 0.6rem; }

  /* Input area with safe-area padding for iPhones */
  .chat-input-area {
    padding: 0.5rem 0.75rem;
    padding-bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
  }
  .chat-input { font-size: 16px; } /* Prevents iOS zoom on focus */
  .chat-input-hint { font-size: 0.6rem; }

  /* Chat mode selector compact on mobile */
  .chat-mode-selector { gap: 0.15rem; margin-bottom: 0.35rem; }
  .chat-mode-dropdown { font-size: 0.75rem; min-width: 140px; padding: 0.25rem 0.5rem; }

  /* Footer: hide on chat page (redundant, saves space) */
  .portal-layout ~ .portal-footer { display: none; }

  /* Auth pages */
  .auth-card { padding: 1.5rem; margin: 1rem; }
  .auth-page { padding: 0 0.5rem; }

  /* Settings / Legal pages scroll properly */
  .settings-page, .legal-page { padding: 1.5rem 1rem; }

  /* Code blocks: horizontal scroll, full width */
  .code-block { font-size: 0.75rem; }
  .code-pre { font-size: 0.72rem; padding: 0.5rem; }
}

/* ── Small phones: up to 400px ──────────────────────────────── */
@media (max-width: 400px) {
  .portal-layout { height: calc(100svh - 22px); }
  .chat-header { padding: 0.4rem 0.75rem; gap: 0.3rem 0.5rem; }
  .chat-header-avatar { width: 30px; height: 30px; min-width: 30px; min-height: 30px; }
  .chat-header-title { font-size: 0.85rem; }
  .chat-header-status { font-size: 0.6rem; }
  .msg-bubble { font-size: 0.85rem; padding: 0.5rem 0.7rem; }
  .msg-avatar { width: 28px; height: 28px; }
  .welcome-avatar { width: 64px; height: 64px; }
  .welcome-title { font-size: 1rem; }
  .chat-mode-dropdown { font-size: 0.7rem; min-width: 120px; width: 100%; padding: 0.2rem 0.4rem; }
  .chat-mode-selector { margin-bottom: 0.25rem; }
}

/* ── Tablet / medium screens ────────────────────────────────── */
@media (min-width: 769px) and (max-width: 1024px) {
  :root { --sidebar-width: 240px; }
  .msg { max-width: 85%; }
}

/* ── Scrollbar Styling ──────────────────────────────────────── */
.chat-messages::-webkit-scrollbar,
.conv-list::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-track,
.conv-list::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb,
.conv-list::-webkit-scrollbar-thumb { background: var(--muted); border-radius: 3px; }
.chat-messages::-webkit-scrollbar-thumb:hover,
.conv-list::-webkit-scrollbar-thumb:hover { background: var(--muted-foreground); }

/* ── Loading Spinner ────────────────────────────────────────── */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--muted);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Code Blocks ────────────────────────────────────────────── */
.code-block {
  margin: 0.6rem 0;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: #1a1a1a;
  max-width: 100%;
}
.theme-light .code-block { background: #f5f5f5; }
.theme-cyber .code-block { background: #0a1628; }

.code-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.7rem;
  background: rgba(255,255,255,0.06);
  border-bottom: 1px solid var(--border);
  font-size: 0.72rem;
}
.theme-light .code-header { background: rgba(0,0,0,0.04); }
.code-lang {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--primary);
  text-transform: uppercase;
  font-size: 0.65rem;
  letter-spacing: 0.04em;
  flex: 1;
}
.code-action {
  background: none;
  border: 1px solid transparent;
  color: var(--muted-foreground);
  font-size: 0.68rem;
  padding: 0.15rem 0.45rem;
  border-radius: 3px;
  cursor: pointer;
  transition: all var(--transition);
}
.code-action:hover {
  background: var(--muted);
  color: var(--foreground);
  border-color: var(--border);
}
.code-pre {
  margin: 0;
  padding: 0.75rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.5;
  color: #e0e0e0;
  white-space: pre;
  max-width: 100%;
}
.theme-light .code-pre { color: #1a1a1a; }
.theme-cyber .code-pre { color: #00ff88; }

.code-pre code {
  font-family: inherit;
  background: none;
  padding: 0;
}
/* highlight.js integration — let hljs set colors but keep our font/padding */
.code-pre code.hljs {
  background: none;
  padding: 0;
  font-family: inherit;
}

.inline-code {
  background: var(--muted);
  padding: 0.1em 0.35em;
  border-radius: 3px;
  font-size: 0.85em;
  font-family: var(--font-mono);
}

/* ── Linkified URLs in chat messages ────────────────────────── */
.msg-bubble a {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
  transition: opacity 0.15s;
}
.msg-bubble a:hover {
  opacity: 0.75;
}
.msg.user .msg-bubble a {
  color: inherit;
  opacity: 0.9;
}

/* ── Markdown Tables in chat messages ───────────────────────── */
.msg-bubble .md-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.5rem 0;
  font-size: 0.82rem;
  line-height: 1.4;
}
.msg-bubble .md-table th {
  background: color-mix(in srgb, var(--primary) 12%, var(--card));
  color: var(--foreground);
  font-weight: 600;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  white-space: nowrap;
}
.msg-bubble .md-table td {
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--border);
  color: var(--foreground);
}
.msg-bubble .md-table tbody tr:nth-child(even) {
  background: color-mix(in srgb, var(--muted) 40%, transparent);
}
.msg-bubble .md-table tbody tr:hover {
  background: color-mix(in srgb, var(--primary) 8%, transparent);
}
.msg.user .msg-bubble .md-table th {
  background: color-mix(in srgb, var(--primary-foreground) 15%, transparent);
}
.msg.user .msg-bubble .md-table th,
.msg.user .msg-bubble .md-table td {
  border-color: rgba(255,255,255,0.15);
  color: inherit;
}
/* Responsive: scroll on small screens */
@media (max-width: 500px) {
  .msg-bubble .md-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ── Markdown Headings in chat messages ─────────────────────── */
.msg-bubble .md-heading {
  font-weight: 700;
  line-height: 1.25;
  color: var(--foreground);
  margin: 0.8rem 0 0.3rem;
}
.msg-bubble .md-heading:first-child { margin-top: 0; }
.msg-bubble .md-h1 { font-size: 1.15rem; }
.msg-bubble .md-h2 { font-size: 1.05rem; }
.msg-bubble .md-h3 { font-size: 0.98rem; }
.msg-bubble .md-h4 { font-size: 0.92rem; font-weight: 600; }
.msg-bubble .md-h5,
.msg-bubble .md-h6 { font-size: 0.88rem; font-weight: 600; opacity: 0.9; }

/* ── Markdown Blockquote ────────────────────────────────────── */
.msg-bubble .md-blockquote {
  border-left: 3px solid color-mix(in srgb, var(--primary) 60%, transparent);
  padding: 0.2rem 0.7rem;
  margin: 0.5rem 0;
  color: color-mix(in srgb, var(--foreground) 80%, transparent);
  font-style: italic;
  background: color-mix(in srgb, var(--muted) 30%, transparent);
  border-radius: 0 6px 6px 0;
}

/* ── Markdown Horizontal Rule ───────────────────────────────── */
.msg-bubble .md-hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0.8rem 0;
  opacity: 0.6;
}

/* ── Markdown Strikethrough ─────────────────────────────────── */
.msg-bubble .md-strike {
  opacity: 0.65;
}

/* ── Roleplay actions / emotes — nur bei MEHR als einem Wort ───
   (*winkt dir zu*, *schaut dich nachdenklich an*). Einzelne Wörter
   bleiben schlicht kursiv (siehe portal.js), damit Aileys normale
   Hervorhebungen nicht eingefärbt werden.
   Eigene Pink/Fuchsia-Akzentfarbe (NICHT --primary, das ist zu rot).
   Über --rp-action pro Theme überschreibbar; Default = Fuchsia.
   Der color-mix mit --foreground passt die Helligkeit je Theme
   automatisch an (heller auf Dark, dunkler auf Light). */
.msg-bubble .rp-action,
.partial-text .rp-action,
.thinking-content .rp-action {
  font-style: italic;
  color: color-mix(in srgb, var(--rp-action, #d946ef) 82%, var(--foreground) 18%);
  opacity: 0.95;
  font-weight: 500;
}
.msg-bubble .rp-action::before { content: ""; }

/* ── Markdown Lists in chat messages ────────────────────────── */
.msg-bubble .md-list {
  margin: 0.6rem 0;
  padding-left: 1.3rem;
  list-style: none;
  border-top: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
  padding-top: 0.45rem;
  padding-bottom: 0.45rem;
}
.msg-bubble .md-list li {
  position: relative;
  padding: 0.2rem 0 0.2rem 0.6rem;
  line-height: 1.5;
}
.msg-bubble .md-list li + li {
  margin-top: 0.15rem;
}
/* Bullet marker for unordered lists */
.msg-bubble ul.md-list li::before {
  content: '•';
  position: absolute;
  left: -0.7rem;
  color: var(--primary);
  font-weight: 700;
}
/* Numbered (ordered) lists */
.msg-bubble .md-list-ol {
  list-style-type: decimal;
  list-style-position: outside;
  padding-left: 1.6rem;
}
.msg-bubble .md-list-ol li {
  display: list-item;
  padding-left: 0.25rem;
}
.msg-bubble .md-list-ol li::before {
  content: none;
}
/* User bubble variant — subtler separator lines */
.msg.user .msg-bubble .md-list {
  border-color: rgba(255,255,255,0.12);
}

/* ── SVG Preview ────────────────────────────────────────────── */
.svg-preview {
  padding: 1rem;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #fff;
  min-height: 60px;
}
.svg-preview svg {
  max-width: 100%;
  max-height: 400px;
}
.svg-code-details {
  border-top: 1px solid var(--border);
}
.svg-code-details summary {
  padding: 0.35rem 0.7rem;
  font-size: 0.7rem;
  color: var(--muted-foreground);
  cursor: pointer;
}

/* ── Custom Instructions (Settings) ─────────────────────────── */
.custom-instructions-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.custom-instructions-section label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--foreground);
  margin-bottom: 0.2rem;
}
.custom-instructions-section textarea {
  width: 100%;
  min-height: 80px;
  padding: 0.6rem;
  background: var(--card);
  color: var(--foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  line-height: 1.5;
  resize: vertical;
}
.custom-instructions-section textarea:focus {
  outline: none;
  border-color: var(--primary);
}
.custom-instructions-section .ci-hint {
  font-size: 0.72rem;
  color: var(--muted-foreground);
  margin-top: -0.5rem;
}

/* ── Toast Notification ─────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 0.6rem 1.2rem;
  background: var(--card);
  color: var(--foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  font-size: 0.85rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  z-index: 1000;
  transition: transform 0.3s ease-out;
  pointer-events: none;
}
.toast.visible { transform: translateX(-50%) translateY(0); pointer-events: auto; }

/* ══════════════════════════════════════════════════════════════
   ARTIFACTS — Topbar Tabs + Panel (Code & SVG Gallery)
   ══════════════════════════════════════════════════════════════ */

/* ── Topbar Tabs (inside chat-header) ───────────────────────── */
.header-tabs {
  display: flex;
  gap: 0.2rem;
  margin-left: auto;
  background: color-mix(in srgb, var(--muted) 60%, var(--background));
  border-radius: var(--radius);
  padding: 0.2rem;
  border: 1px solid var(--border);
  flex-basis: 100%;
  order: 10;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.header-tabs::-webkit-scrollbar { display: none; }
.header-tab {
  padding: 0.35rem 0.75rem;
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.75rem;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--muted-foreground);
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.header-tab:hover {
  color: var(--foreground);
  background: color-mix(in srgb, var(--primary) 10%, transparent);
}
.header-tab.active {
  background: var(--primary);
  color: var(--primary-foreground);
  box-shadow: 0 1px 6px color-mix(in srgb, var(--primary) 40%, transparent);
}
.header-tab .tab-count {
  font-size: 0.6rem;
  background: var(--primary-foreground);
  color: var(--primary);
  padding: 0 0.3rem;
  border-radius: 99px;
  min-width: 1.1rem;
  text-align: center;
  line-height: 1.3;
  font-weight: 700;
}
.header-tab.active .tab-count {
  background: color-mix(in srgb, var(--primary-foreground) 85%, transparent);
  color: var(--primary);
}
.header-tab .tab-count:empty { display: none; }

/* ── Artifact Panel ─────────────────────────────────────────── */
.artifact-panel {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: none;
  flex-direction: column;
  gap: 0.75rem;
}
.artifact-panel.visible {
  display: flex;
}

.artifact-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.75rem;
  color: var(--muted-foreground);
  padding: 2rem;
}
.artifact-empty-icon { font-size: 3rem; opacity: 0.5; }
.artifact-empty-text { font-size: 0.9rem; }

/* ── Artifact Card ──────────────────────────────────────────── */
.artifact-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color var(--transition);
}
.artifact-card:hover { border-color: var(--primary); }

.artifact-card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
}
.artifact-card-icon { font-size: 1rem; }
.artifact-card-info { flex: 1; min-width: 0; }
.artifact-card-title {
  font-size: 0.8rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.artifact-card-meta {
  font-size: 0.65rem;
  color: var(--muted-foreground);
  display: flex;
  gap: 0.5rem;
}
.artifact-card-actions {
  display: flex;
  gap: 0.25rem;
}
.artifact-card-actions .code-action {
  font-size: 0.72rem;
  padding: 0.2rem 0.5rem;
}

.artifact-card-body {
  max-height: 300px;
  overflow: auto;
}
.artifact-card-body .code-pre {
  margin: 0;
  font-size: 0.75rem;
  border-radius: 0;
}
.artifact-card-body .svg-preview {
  max-height: 250px;
  border-radius: 0;
}

/* ── Responsive: tabs on mobile ─────────────────────────────── */
@media (max-width: 768px) {
  .header-tabs {
    gap: 0.1rem;
    padding: 0.15rem;
  }
  .header-tab {
    padding: 0.3rem 0.5rem;
    font-size: 0.7rem;
  }
  .header-tab .tab-label { display: none; }
}
@media (max-width: 400px) {
  .header-tabs {
    gap: 0.05rem;
    padding: 0.1rem;
    border: none;
  }
  .header-tab {
    padding: 0.25rem 0.4rem;
    font-size: 0.65rem;
    gap: 0.15rem;
  }
}

/* ══════════════════════════════════════════════════════════════
   🏠 LANDING PAGE
   Public-facing, no auth required.
   ══════════════════════════════════════════════════════════════ */
.landing-page {
  overflow-y: auto;
  overflow-x: hidden;
  max-height: 100dvh;
  scroll-behavior: smooth;
}
.landing-page section[id] {
  scroll-margin-top: 60px;
}

/* ── Hero ──────────────────────────────────────────────────── */
.landing-hero {
  display: flex;
  justify-content: center;
  padding: 3rem 1.5rem 2rem;
  text-align: center;
}
.hero-inner {
  max-width: 600px;
}
.hero-avatar {
  position: relative;
  display: inline-block;
  margin-bottom: 1.25rem;
}
.hero-img {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 3px solid var(--primary);
  box-shadow: 0 0 30px var(--glow);
  object-fit: cover;
}
.status-dot {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--background);
}
.hero-avatar .status-dot {
  position: absolute;
  bottom: 6px;
  right: 6px;
}
.status-dot.online {
  background: #22c55e;
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.6);
}
.status-dot.generating {
  background: #f97316;
  box-shadow: 0 0 8px rgba(249, 115, 22, 0.7);
  animation: pulse-dot 1.2s ease-in-out infinite;
}
.status-dot.offline {
  background: #6b7280;
}
.hero-title {
  font-size: 2.8rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--foreground);
  margin-bottom: 0.25rem;
}
.hero-title .highlight {
  color: var(--primary);
}
.hero-tagline {
  font-size: 1rem;
  color: var(--muted-foreground);
  margin-bottom: 1rem;
  letter-spacing: 0.05em;
}
.hero-description {
  font-size: 0.95rem;
  color: var(--muted-foreground);
  line-height: 1.7;
}
.hero-description a {
  color: var(--primary);
}

/* ── Feature Grid ─────────────────────────────────────────── */
.landing-features {
  padding: 1.5rem 1.5rem 2rem;
  display: flex;
  justify-content: center;
}
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  max-width: 800px;
  width: 100%;
}
.feature-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  text-align: center;
  transition: border-color var(--transition), box-shadow var(--transition), transform 0.2s ease;
}
.feature-card:hover {
  border-color: var(--primary);
  box-shadow: 0 0 20px var(--glow);
}
.feature-icon {
  font-size: 2rem;
  display: block;
  margin-bottom: 0.5rem;
}
.feature-icon .icon {
  width: 2rem;
  height: 2rem;
  color: var(--primary);
}
.feature-card h3 {
  font-size: 1rem;
  color: var(--foreground);
  margin-bottom: 0.4rem;
}
.feature-card p {
  font-size: 0.82rem;
  color: var(--muted-foreground);
  line-height: 1.5;
}
/* Feature cards as clickable links */
a.feature-card-link {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  display: block;
}
a.feature-card-link:hover {
  border-color: var(--primary);
  box-shadow: 0 0 20px var(--glow);
  transform: translateY(-2px);
}
a.feature-card-link:active {
  transform: translateY(0) scale(0.98);
  box-shadow: 0 0 10px var(--glow);
}
a.feature-card-link h3,
a.feature-card-link p {
  color: inherit;
}
a.feature-card-link h3 {
  color: var(--foreground);
}
a.feature-card-link p {
  color: var(--muted-foreground);
}

/* ── Access Card (invite-only) ────────────────────────────── */
.landing-access {
  padding: 1rem 1.5rem 2rem;
  display: flex;
  justify-content: center;
}
.access-card {
  max-width: 600px;
  width: 100%;
  background: var(--card);
  border: 1px solid var(--primary);
  border-radius: var(--radius-lg);
  padding: 2rem;
  text-align: center;
}
.access-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}
.access-card h2 {
  font-size: 1.3rem;
  color: var(--foreground);
  margin-bottom: 0.75rem;
}
.access-card p {
  font-size: 0.9rem;
  color: var(--muted-foreground);
  line-height: 1.6;
  margin-bottom: 0.75rem;
}
.access-why {
  font-size: 0.82rem !important;
  color: var(--muted-foreground) !important;
  opacity: 0.8;
}
.access-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin: 1rem 0;
  font-size: 0.9rem;
  color: var(--foreground);
}
.mood-hint {
  color: var(--muted-foreground);
  font-size: 0.82rem;
}
.access-buttons {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 1rem;
}
.btn-landing {
  padding: 0.65rem 1.5rem;
  font-size: 0.9rem;
  border-radius: var(--radius);
  text-decoration: none;
  display: inline-block;
  transition: opacity var(--transition), transform var(--transition);
}
.btn-landing:hover {
  text-decoration: none;
  opacity: 0.9;
  transform: translateY(-1px);
}
.btn-secondary {
  background: var(--muted);
  color: var(--foreground);
  border: 1px solid var(--border);
}

/* ── Disclosure (KI-Transparenz) ──────────────────────────── */
.landing-disclosure {
  padding: 1rem 1.5rem 2rem;
  display: flex;
  justify-content: center;
}
.disclosure-card {
  max-width: 650px;
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
}
.disclosure-card h2 {
  font-size: 1.15rem;
  color: var(--foreground);
  margin-bottom: 0.75rem;
}
.ki-badge-inline {
  background: var(--primary);
  color: var(--primary-foreground);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  vertical-align: middle;
  margin-right: 0.25rem;
}
.disclosure-card p {
  font-size: 0.88rem;
  color: var(--muted-foreground);
  line-height: 1.6;
  margin-bottom: 0.75rem;
}
.disclosure-list {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 1rem;
}
.disclosure-list li {
  font-size: 0.85rem;
  color: var(--muted-foreground);
  line-height: 1.6;
  padding: 0.4rem 0;
  padding-left: 1.5rem;
  position: relative;
}
.disclosure-list li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: var(--primary);
  font-weight: bold;
}
.disclosure-legal {
  font-size: 0.78rem !important;
  opacity: 0.7;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
  margin-top: 0.5rem;
}

/* ── About Section ────────────────────────────────────────── */
.landing-about {
  padding: 1rem 1.5rem 3rem;
  max-width: 650px;
  margin: 0 auto;
}
.landing-about h2 {
  font-size: 1.15rem;
  color: var(--foreground);
  margin-bottom: 0.75rem;
}
.landing-about p {
  font-size: 0.88rem;
  color: var(--muted-foreground);
  line-height: 1.7;
  margin-bottom: 0.75rem;
}
.landing-about a {
  color: var(--primary);
}
.landing-about em {
  color: var(--foreground);
  font-style: italic;
}

/* ── CTA Human Art ──────────────────────────────────────── */
.cta-human-art {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 1.25rem;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  background: var(--card);
  border: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--muted-foreground);
}
.cta-human-art .icon {
  width: 1.2em;
  height: 1.2em;
  color: var(--primary);
  flex-shrink: 0;
}
.cta-human-art a {
  color: var(--primary);
  font-weight: 600;
}

/* ── Landing page scroll (handled by global rule above) ──── */

/* ── Mobile adjustments ───────────────────────────────────── */
@media (max-width: 640px) {
  .hero-title { font-size: 2.2rem; }
  .hero-img { width: 100px; height: 100px; }
  .feature-grid { grid-template-columns: 1fr 1fr; }
  .access-card { padding: 1.5rem 1rem; }
  .disclosure-card { padding: 1.25rem 1rem; }
}

/* ═════════════════════════════════════════════════════════════
   Portal Navigation Bar (logged-in users)
   ═════════════════════════════════════════════════════════════ */
.portal-nav {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}
.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
  height: 48px;
}
.nav-brand {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--foreground);
  text-decoration: none;
  letter-spacing: 0.02em;
  display: inline-flex;
  flex-direction: column;
  line-height: 1.05;
}
.nav-brand-name { display: block; }
.nav-brand-domain {
  font-size: 0.58rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: lowercase;
  color: var(--muted-foreground);
  opacity: 0.7;
  margin-top: 1px;
}
.nav-brand:hover .nav-brand-domain { color: var(--primary); opacity: 0.9; }
.nav-brand .highlight {
  color: var(--primary);
}
.nav-brand:hover {
  opacity: 0.85;
}
.nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.nav-link {
  font-size: 0.85rem;
  color: var(--muted-foreground);
  text-decoration: none;
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.nav-link:hover {
  background: var(--muted);
  color: var(--foreground);
}
.nav-link.active {
  color: var(--primary);
  background: rgba(var(--primary-rgb, 168, 85, 247), 0.12);
  font-weight: 600;
}

/* ── Nav Dropdown (Tools) ─────────────────────────────────── */
.nav-dropdown {
  position: relative;
  display: inline-flex;
}
.nav-dropdown-trigger {
  background: none;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.2em;
}
.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 140px;
  background: var(--card);
  border: 1px solid color-mix(in srgb, var(--primary) 20%, transparent);
  border-radius: 8px;
  padding: 0.35rem 0;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  z-index: 1000;
}
.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu {
  display: block;
}
.nav-dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  font-size: 0.83rem;
  color: var(--muted-foreground);
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.nav-dropdown-item:hover {
  background: var(--muted);
  color: var(--foreground);
  text-decoration: none;
}
.nav-dropdown-item.active {
  color: var(--primary);
  font-weight: 600;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.nav-username {
  font-size: 0.82rem;
  color: var(--muted-foreground);
  opacity: 0.8;
}
.nav-logout {
  font-size: 0.78rem;
  color: var(--destructive, #ef4444) !important;
  opacity: 0.7;
}
.nav-logout:hover {
  opacity: 1;
  background: rgba(239, 68, 68, 0.1);
}

/* ── Nav Language Switcher ─────────────────────────────────── */
.nav-lang-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.25rem 0.5rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  color: var(--foreground);
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
  line-height: 1;
  min-width: 28px;
}
.nav-lang-btn:hover {
  background: var(--muted);
  border-color: var(--primary);
  color: var(--primary);
}

/* ── Nav Theme Switcher (global dropdown) ─────────────────── */
.nav-theme-switcher {
  position: relative;
}
.nav-theme-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.3rem 0.5rem;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--foreground);
  transition: background 0.15s, border-color 0.15s;
  line-height: 1;
}
.nav-theme-btn:hover {
  background: var(--muted);
  border-color: var(--primary);
}
.nav-theme-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  min-width: 140px;
  z-index: 1100;
  overflow: hidden;
}
.nav-theme-dropdown.open {
  display: block;
}
.nav-theme-dropdown .theme-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.85rem;
  font-size: 0.82rem;
  color: var(--foreground);
  cursor: pointer;
  transition: background 0.12s;
  border: none;
  border-radius: 0;
  background: transparent;
  min-width: unset;
  text-align: left;
}
.nav-theme-dropdown .theme-option:hover {
  background: var(--muted);
}
.nav-theme-dropdown .theme-option.active {
  color: var(--primary);
  font-weight: 600;
  background: var(--glow);
}

/* ── Nav bar mobile — radial menu system ──────────────────── */

/* Hide desktop links on mobile, show radial trigger */
.radial-trigger { display: none; }

@media (max-width: 768px) {
  .nav-links-desktop {
    display: none !important;
  }
  .nav-inner {
    padding: 0 0.75rem;
    height: 44px;
  }
  .nav-username {
    display: none;
  }
  .radial-trigger {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: none;
    border: 1.5px solid var(--border);
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
    position: relative;
    transition: border-color 0.2s, background 0.2s, transform 0.2s;
    flex-shrink: 0;
    order: -1;
  }
  .radial-trigger:hover,
  .radial-trigger:active {
    border-color: var(--primary);
    background: var(--glow);
    transform: scale(1.08);
  }
  .radial-trigger.active {
    border-color: var(--primary);
    background: var(--primary);
  }
  .radial-trigger.active .radial-icon,
  .radial-trigger.active .radial-icon::before,
  .radial-trigger.active .radial-icon::after {
    background: var(--primary-foreground);
  }
  .radial-icon {
    width: 16px;
    height: 2px;
    background: var(--foreground);
    border-radius: 2px;
    position: relative;
    transition: background 0.2s, transform 0.3s;
  }
  .radial-icon::before,
  .radial-icon::after {
    content: '';
    position: absolute;
    left: 0;
    width: 16px;
    height: 2px;
    background: var(--foreground);
    border-radius: 2px;
    transition: transform 0.3s, opacity 0.2s;
  }
  .radial-icon::before { top: -5px; }
  .radial-icon::after  { top: 5px; }
  /* Animate to X when open */
  .radial-trigger.active .radial-icon {
    background: transparent;
  }
  .radial-trigger.active .radial-icon::before {
    transform: translateY(5px) rotate(45deg);
    background: var(--primary-foreground);
  }
  .radial-trigger.active .radial-icon::after {
    transform: translateY(-5px) rotate(-45deg);
    background: var(--primary-foreground);
  }
  .nav-lang-btn {
    font-size: 0.68rem;
    padding: 0.2rem 0.4rem;
    min-width: 26px;
    flex-shrink: 0;
  }
  .nav-user {
    flex-shrink: 0;
    gap: 0.4rem;
  }
  /* Hide theme switcher from top nav on mobile — it's in the radial */
  .nav-theme-switcher {
    display: none;
  }
}

/* ═══════════════════════════════════════════════════════════
   Rotary Dial Menu — Echte Telefon-Wählscheibe 📞
   Finger ins Loch → drehen bis Anschlag → loslassen → navigiert
   ═══════════════════════════════════════════════════════════ */
.radial-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.0);
  -webkit-backdrop-filter: blur(0px);
  backdrop-filter: blur(0px);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease, background 0.4s ease, backdrop-filter 0.4s ease;
  -webkit-user-select: none;
  user-select: none;
}
.radial-overlay.open {
  pointer-events: auto;
  opacity: 1;
  background: rgba(0, 0, 0, 0.78);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
}

/* ── Dial title ───────────────────────────────────────────── */
.dial-title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted-foreground);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.4s 0.15s, transform 0.4s 0.15s;
  margin-bottom: 1rem;
  pointer-events: none;
  text-shadow: 0 0 20px var(--glow);
}
.radial-overlay.open .dial-title {
  opacity: 0.6;
  transform: translateY(0);
}

/* ── The whole phone dial unit ────────────────────────────── */
.dial-phone {
  position: relative;
  width: min(85vw, 340px);
  height: min(85vw, 340px);
  transform: scale(0.4) rotate(-45deg);
  opacity: 0;
  transition: transform 0.55s cubic-bezier(0.34, 1.56, 0.64, 1),
              opacity 0.3s ease;
}
.radial-overlay.open .dial-phone {
  transform: scale(1) rotate(0deg);
  opacity: 1;
}
.radial-overlay.closing .dial-phone {
  transform: scale(0.4) rotate(45deg);
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.55, 0, 1, 0.45),
              opacity 0.25s;
}

/* ── Fixed outer frame (doesn't rotate) ───────────────────── */
.dial-frame {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 4px solid var(--border);
  background: transparent;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.05),
    0 0 50px var(--glow),
    0 0 100px var(--glow),
    inset 0 0 30px rgba(0,0,0,0.3);
  pointer-events: none;
  z-index: 5;
}

/* ── Finger stop — the metal bump at 3 o'clock ──────────── */
.dial-finger-stop {
  position: absolute;
  width: 14px;
  height: 28px;
  background: var(--primary);
  border: 2px solid var(--border);
  border-radius: 4px;
  /* Exact 3 o'clock: vertically centered, flush right */
  top: 50%;
  right: -3px;
  transform: translateY(-50%);
  box-shadow:
    0 0 12px var(--glow),
    inset 0 1px 2px rgba(255,255,255,0.3);
  z-index: 10;
}

/* ── Rotatable disc ───────────────────────────────────────── */
.dial-disc {
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, transparent 22%, var(--card) 23%, var(--card) 92%, transparent 93%);
  box-shadow:
    inset 0 2px 10px rgba(0,0,0,0.4),
    inset 0 -1px 4px rgba(255,255,255,0.03);
  /* Transform is controlled by JS */
  transform: rotate(0deg);
  touch-action: none;
}
/* Subtle texture lines on disc */
.dial-disc::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: repeating-conic-gradient(
    from 0deg,
    transparent 0deg 3deg,
    rgba(255,255,255,0.015) 3deg 6deg
  );
  pointer-events: none;
}

/* ── Dial holes (the "Löcher") ────────────────────────────── */
.dial-hole {
  position: absolute;
  width: 52px;
  height: 52px;
  margin: -26px 0 0 -26px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  cursor: pointer;
  touch-action: none;
  /* Hole depression look */
  background:
    radial-gradient(circle at 40% 35%, rgba(255,255,255,0.07), transparent 50%),
    rgba(0,0,0,0.35);
  border: 1.5px solid rgba(255,255,255,0.08);
  box-shadow:
    inset 0 3px 8px rgba(0,0,0,0.5),
    inset 0 -1px 3px rgba(255,255,255,0.04),
    0 1px 2px rgba(0,0,0,0.3);
  color: var(--foreground);
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
/* Active: finger in the hole */
.dial-hole.active {
  background:
    radial-gradient(circle at 50% 50%, var(--glow), transparent 70%),
    rgba(0,0,0,0.2);
  border-color: var(--primary);
  box-shadow:
    inset 0 2px 6px rgba(0,0,0,0.3),
    0 0 15px var(--glow),
    0 0 30px var(--glow);
}
/* Dialing: reached the stop zone — strong glow */
.dial-hole.dialing {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-foreground);
  box-shadow:
    0 0 20px var(--glow),
    0 0 45px var(--glow),
    inset 0 1px 4px rgba(255,255,255,0.25);
}
.dial-hole-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.dial-hole-icon .icon {
  width: 17px;
  height: 17px;
}
.dial-hole.dialing .dial-hole-icon .icon {
  color: var(--primary-foreground);
}
.dial-hole-label {
  font-size: 0.48rem;
  font-weight: 600;
  text-align: center;
  line-height: 1;
  max-width: 48px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.8;
  pointer-events: none;
  letter-spacing: 0.01em;
}
.dial-hole.dialing .dial-hole-label {
  opacity: 1;
  color: var(--primary-foreground);
}

/* ── Dense mode: many items → smaller holes ───────────────── */
.dial-dense .dial-hole {
  width: 42px;
  height: 42px;
  margin: -21px 0 0 -21px;
}
.dial-dense .dial-hole-icon .icon {
  width: 14px;
  height: 14px;
}
.dial-dense .dial-hole-label {
  font-size: 0.4rem;
  max-width: 40px;
}

/* ── Center hub ───────────────────────────────────────────── */
.dial-center {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 72px;
  height: 72px;
  margin: -36px 0 0 -36px;
  border-radius: 50%;
  background: var(--card);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  cursor: pointer;
  box-shadow:
    0 0 15px var(--glow),
    0 0 30px var(--glow),
    inset 0 1px 3px rgba(255,255,255,0.08);
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}
.dial-center:hover,
.dial-center:active {
  background: var(--primary);
  border-color: var(--primary);
  transform: scale(1.06);
  box-shadow: 0 0 25px var(--glow), 0 0 50px var(--glow);
}
.dial-center-text {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--foreground);
  letter-spacing: 0.02em;
  pointer-events: none;
  transition: color 0.2s;
}
.dial-center-text .highlight {
  color: var(--primary);
}
.dial-center:hover .dial-center-text,
.dial-center:active .dial-center-text {
  color: var(--primary-foreground);
}
.dial-center:hover .dial-center-text .highlight,
.dial-center:active .dial-center-text .highlight {
  color: var(--primary-foreground);
}

/* ── Preview label (shows which page you'll navigate to) ──── */
.dial-preview {
  position: absolute;
  bottom: -50px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--card);
  border: 1px solid var(--primary);
  border-radius: 999px;
  padding: 0.4rem 1rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3), 0 0 12px var(--glow);
}
.dial-preview.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Hint text (how to use the dial) ──────────────────────── */
.dial-hint {
  position: absolute;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.45rem 1.1rem;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--muted-foreground);
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 4px 20px rgba(0,0,0,0.35);
  animation: dialHintPulse 2s ease-in-out infinite;
  z-index: 20;
}
.dial-hint.fade-out {
  opacity: 0;
  transition: opacity 0.4s;
}
@keyframes dialHintPulse {
  0%, 100% { opacity: 0.85; transform: translateX(-50%) translateY(0); }
  50%      { opacity: 1;    transform: translateX(-50%) translateY(-3px); }
}

/* ── Theme bar at bottom of overlay ───────────────────────── */
.radial-theme-bar {
  position: absolute;
  bottom: max(env(safe-area-inset-bottom, 20px), 24px);
  left: 50%;
  transform: translateX(-50%) translateY(30px);
  display: flex;
  gap: 0.35rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.35rem 0.6rem;
  opacity: 0;
  transition: opacity 0.35s 0.2s, transform 0.35s 0.2s;
  box-shadow: 0 4px 24px rgba(0,0,0,0.4);
}
.radial-overlay.open .radial-theme-bar {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.radial-theme-bar .theme-option {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.3rem 0.55rem;
  font-size: 0.68rem;
  color: var(--muted-foreground);
  cursor: pointer;
  border-radius: 999px;
  transition: background 0.15s, color 0.15s;
  border: none;
  background: transparent;
  white-space: nowrap;
}
.radial-theme-bar .theme-option:hover {
  background: var(--muted);
  color: var(--foreground);
}
.radial-theme-bar .theme-option.active {
  background: var(--primary);
  color: var(--primary-foreground);
  font-weight: 600;
}
.radial-theme-bar .theme-option .icon {
  width: 13px;
  height: 13px;
}

/* ── Adjust KI-banner when nav is present ─────────────────── */
/* Banner follows nav in normal document flow — no positioning needed */

/* ═════════════════════════════════════════════════════════════
   Landing Page — Live Content Sections
   ═════════════════════════════════════════════════════════════ */

/* ── Feature Cards: stat counter ──────────────────────────── */
.feature-stat {
  display: inline-block;
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--primary);
  font-weight: 600;
  opacity: 0.85;
}

/* ── Books Section ────────────────────────────────────────── */
.landing-books {
  padding: 1.5rem 1.5rem 0.5rem;
  max-width: 750px;
  margin: 0 auto;
}
.landing-books h2 {
  font-size: 1.15rem;
  color: var(--foreground);
  margin-bottom: 1rem;
}
.book-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.book-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
}
.book-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.book-title {
  font-size: 1.05rem;
  color: var(--foreground);
  font-weight: 600;
}
.book-badge {
  font-size: 0.72rem;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  white-space: nowrap;
  font-weight: 600;
}
.book-badge-writing {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
}
.book-badge-finished {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
}
.book-badge-planning {
  background: rgba(139, 92, 246, 0.15);
  color: #8b5cf6;
}
.book-genre {
  display: inline-block;
  font-size: 0.78rem;
  color: var(--muted-foreground);
  margin-bottom: 0.5rem;
}
.book-synopsis {
  font-size: 0.85rem;
  color: var(--muted-foreground);
  line-height: 1.6;
  margin-bottom: 0.75rem;
}
.book-progress {
  position: relative;
  height: 22px;
  background: var(--muted);
  border-radius: 6px;
  overflow: hidden;
}
.book-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #f59e0b);
  border-radius: 6px;
  transition: width 0.5s ease;
}
.book-progress-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.7rem;
  color: var(--foreground);
  font-weight: 600;
  white-space: nowrap;
  text-shadow: 0 0 4px rgba(0,0,0,0.5);
}

/* ── Songs Section ────────────────────────────────────────── */
.landing-songs {
  padding: 1.5rem 1.5rem 0.5rem;
  max-width: 750px;
  margin: 0 auto;
}
.landing-songs h2 {
  font-size: 1.15rem;
  color: var(--foreground);
  margin-bottom: 1rem;
}
.song-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.song-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.88rem;
  overflow: hidden;
  max-width: 100%;
}
.song-title {
  color: var(--foreground);
  font-weight: 500;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.song-genre {
  font-size: 0.75rem;
  color: var(--primary);
  opacity: 0.8;
  white-space: nowrap;
}
.song-date {
  font-size: 0.72rem;
  color: var(--muted-foreground);
  opacity: 0.6;
  white-space: nowrap;
}

/* ── Thoughts Section ─────────────────────────────────────── */
.landing-thoughts {
  padding: 1.5rem 1.5rem 0.5rem;
  max-width: 750px;
  margin: 0 auto;
}
.landing-thoughts h2 {
  font-size: 1.15rem;
  color: var(--foreground);
  margin-bottom: 1rem;
}
.thought-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.thought-item {
  background: var(--card);
  border-left: 3px solid var(--primary);
  border-radius: 0 8px 8px 0;
  padding: 1rem 1.25rem;
}
.thought-item p {
  font-size: 0.88rem;
  color: var(--muted-foreground);
  line-height: 1.7;
  font-style: italic;
}
.thought-date {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.72rem;
  color: var(--muted-foreground);
  opacity: 0.5;
  font-style: normal;
}

/* ── Mobile: Live content sections ────────────────────────── */
@media (max-width: 640px) {
  .landing-books, .landing-songs, .landing-thoughts {
    padding: 1rem;
  }
  .book-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
  }
  .song-item {
    flex-wrap: wrap;
    gap: 0.35rem;
  }
}


/* ═══════════════════════════════════════════════════════════════
   GALLERY PAGE
   ═══════════════════════════════════════════════════════════════ */
.gallery-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}
.gallery-header {
  text-align: center;
  margin-bottom: 2rem;
}
.gallery-header h1 {
  font-size: 2rem;
  color: #FF1493;
}
.gallery-subtitle {
  color: var(--text-secondary, #999);
  margin-top: 0.5rem;
}

/* Filter tabs */
.gallery-filters {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.filter-tab {
  padding: 0.5rem 1.2rem;
  border-radius: 2rem;
  background: rgba(255,255,255,0.05);
  color: var(--text-secondary, #999);
  text-decoration: none;
  font-size: 0.9rem;
  transition: all 0.2s;
  border: 1px solid transparent;
}
.filter-tab:hover {
  background: rgba(255,20,147,0.1);
  color: #FF1493;
}
.filter-tab.active {
  background: rgba(255,20,147,0.15);
  color: #FF1493;
  border-color: rgba(255,20,147,0.3);
}

/* Song Search */
.gallery-song-search {
  max-width: 480px;
  margin: 0 auto 2rem;
}
.song-search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}
.song-search-icon {
  position: absolute;
  left: 14px;
  color: var(--text-secondary, #999);
  pointer-events: none;
  display: flex;
  align-items: center;
}
.song-search-icon svg {
  width: 18px;
  height: 18px;
}
.song-search-input {
  width: 100%;
  padding: 0.7rem 2.8rem 0.7rem 2.6rem;
  border-radius: 2rem;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
  color: var(--text-primary, #e5e5e5);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.song-search-input::placeholder {
  color: var(--text-secondary, #777);
}
.song-search-input:focus {
  border-color: rgba(255,20,147,0.4);
  box-shadow: 0 0 0 3px rgba(255,20,147,0.08);
}
.song-search-clear {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  color: var(--text-secondary, #999);
  cursor: pointer;
  font-size: 1rem;
  padding: 4px 8px;
  border-radius: 50%;
  transition: color 0.2s;
}
.song-search-clear:hover {
  color: #FF1493;
}
.song-search-status {
  text-align: center;
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-secondary, #999);
  min-height: 1.2em;
}

/* Gallery grid */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}
.gallery-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  overflow: hidden;
  transition: transform 0.2s, border-color 0.2s;
  position: relative;
}
.gallery-card:hover {
  transform: translateY(-3px);
  border-color: rgba(255,20,147,0.3);
}
.gallery-type-badge {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  font-size: 1.2rem;
  z-index: 2;
}
.gallery-card-visual {
  width: 100%;
  aspect-ratio: 1/1;
  overflow: hidden;
  background: rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
}
.gallery-card-visual img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
/* Contain mode: show full image (portrait-safe), no cropping */
.gallery-card-visual-contain {
  cursor: pointer;
  background: rgba(0,0,0,0.5);
}
.gallery-card-visual-contain img {
  object-fit: contain;
}
.gallery-svg img {
  object-fit: contain;
  padding: 1rem;
}
.gallery-card-body {
  padding: 1rem 1.25rem 1.25rem;
}
.gallery-card-title {
  font-size: 1.05rem;
  margin: 0 0 0.5rem;
  color: var(--text-primary, #eee);
}
.gallery-card-desc {
  font-size: 0.85rem;
  color: var(--text-secondary, #999);
  line-height: 1.5;
  margin: 0 0 0.75rem;
}
.gallery-meta-tag {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  background: rgba(255,20,147,0.1);
  color: #FF1493;
  border-radius: 1rem;
  font-size: 0.75rem;
  margin-right: 0.3rem;
  margin-bottom: 0.3rem;
}
.gallery-progress {
  position: relative;
  height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  margin-top: 0.75rem;
  overflow: hidden;
}
.gallery-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #FF1493, #FF69B4);
  border-radius: 3px;
  transition: width 0.5s;
}
.gallery-progress-text {
  font-size: 0.7rem;
  color: var(--text-secondary, #999);
  margin-top: 0.25rem;
  display: block;
}
.gallery-card-date {
  display: block;
  font-size: 0.75rem;
  color: var(--text-tertiary, #666);
  margin-top: 0.5rem;
}

/* Gallery Rating & Comments */
.gallery-rating-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.gallery-stars {
  display: flex;
  align-items: center;
  gap: 1px;
  font-size: 0.9rem;
}
.gallery-star {
  color: rgba(255,255,255,0.2);
  transition: color 0.15s;
  user-select: none;
}
.gallery-star:hover,
.gallery-star-active {
  color: #fbbf24;
}
.gallery-star-avg {
  color: rgba(251,191,36,0.4);
}
.gallery-rating-count {
  font-size: 0.7rem;
  color: var(--muted-foreground);
  margin-left: 4px;
}
.gallery-comment-toggle {
  background: none;
  border: none;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  margin-left: auto;
  opacity: 0.6;
  transition: opacity 0.15s;
}
.gallery-comment-toggle:hover {
  opacity: 1;
}
.gallery-comments-section {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(255,255,255,0.04);
}
.gallery-comment {
  padding: 0.4rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  font-size: 0.8rem;
}
.gallery-comment-header {
  display: flex; align-items: center; gap: 0.4rem;
}
.gallery-comment-avatar {
  width: 22px; height: 22px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
}
.gallery-comment-avatar-placeholder {
  width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(var(--accent-rgb, 100,100,200), 0.25); color: var(--text, #fff);
  font-size: 0.6rem; font-weight: 700; text-transform: uppercase;
}
.gallery-comment strong {
  color: var(--accent, #a78bfa);
  font-size: 0.75rem;
}
.gallery-comment-date {
  font-size: 0.65rem;
  color: var(--muted-foreground);
  margin-left: 0.5rem;
}
.gallery-comment p {
  margin: 0.15rem 0 0;
  line-height: 1.3;
}
.gallery-comments-empty,
.gallery-comments-loading {
  font-size: 0.75rem;
  color: var(--muted-foreground);
  display: block;
  padding: 0.25rem 0;
}
.gallery-comment-form {
  display: flex;
  gap: 0.25rem;
  margin-top: 0.4rem;
}
.gallery-comment-input {
  flex: 1;
  background: rgba(0,0,0,0.2);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  padding: 4px 8px;
  color: inherit;
  font-size: 0.8rem;
}
.gallery-comment-input::placeholder {
  color: var(--muted-foreground);
}

/* Gallery toast (fallback if Portal.showToast not available) */
.gallery-toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(0,0,0,0.85);
  color: #fff;
  padding: 0.5rem 1.5rem;
  border-radius: 8px;
  font-size: 0.85rem;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 9999;
  pointer-events: none;
}
.gallery-toast-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Gallery empty */
.gallery-empty {
  text-align: center;
  padding: 3rem;
  color: var(--text-secondary, #999);
}

/* Pagination (shared) */
.gallery-pagination, .blog-pagination, .feed-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.pagination-info {
  color: var(--text-secondary, #999);
  font-size: 0.85rem;
}

/* ═══════════════════════════════════════════════════════════════
   BLOG PAGE
   ═══════════════════════════════════════════════════════════════ */
.blog-page {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}
.blog-header {
  text-align: center;
  margin-bottom: 2.5rem;
}
.blog-header h1 {
  font-size: 2rem;
  color: #FF1493;
}
.blog-subtitle {
  color: var(--text-secondary, #999);
  margin-top: 0.5rem;
  line-height: 1.6;
}

/* KI notice inline */
.ki-notice-inline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  background: rgba(255,165,0,0.08);
  border: 1px solid rgba(255,165,0,0.2);
  border-radius: 8px;
  font-size: 0.8rem;
  color: var(--text-secondary, #999);
  margin-top: 1rem;
}
.ki-badge-inline {
  padding: 0.15rem 0.4rem;
  background: rgba(255,165,0,0.2);
  border-radius: 4px;
  font-size: 0.75rem;
  white-space: nowrap;
}

/* Blog listing */
.blog-listing {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.blog-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 1.5rem;
  transition: border-color 0.2s;
}
.blog-card:hover {
  border-color: rgba(255,20,147,0.3);
}
.blog-card-link {
  text-decoration: none;
}
.blog-card-title {
  font-size: 1.3rem;
  color: var(--text-primary, #eee);
  margin: 0 0 0.5rem;
}
.blog-card-title:hover {
  color: #FF1493;
}
.blog-card-meta {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-secondary, #999);
  margin-bottom: 0.75rem;
}
.blog-topic {
  padding: 0.15rem 0.5rem;
  background: rgba(255,20,147,0.1);
  color: #FF1493;
  border-radius: 1rem;
  font-size: 0.75rem;
}
.blog-mood {
  font-size: 0.75rem;
  color: var(--text-tertiary, #666);
}
.blog-card-excerpt {
  font-size: 0.9rem;
  color: var(--text-secondary, #aaa);
  line-height: 1.6;
  margin: 0 0 0.75rem;
}
.blog-read-more {
  font-size: 0.85rem;
  color: #FF1493;
  text-decoration: none;
}
.blog-read-more:hover {
  text-decoration: underline;
}

/* Blog single post */
.blog-single {
  padding-top: 1rem;
}
.blog-single-header {
  margin-bottom: 2rem;
}
.blog-back-link {
  font-size: 0.85rem;
  color: var(--text-secondary, #999);
  text-decoration: none;
  display: inline-block;
  margin-bottom: 1rem;
}
.blog-back-link:hover {
  color: #FF1493;
}
.blog-post-title {
  font-size: 2rem;
  color: var(--text-primary, #eee);
  margin: 0 0 0.75rem;
  line-height: 1.3;
}
.blog-post-meta {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-secondary, #999);
  margin-bottom: 1rem;
}
.blog-post-body {
  font-size: 1rem;
  line-height: 1.8;
  color: var(--text-primary, #ddd);
}
.blog-post-body h2 {
  font-size: 1.4rem;
  color: #FF1493;
  margin: 2rem 0 0.75rem;
}
.blog-post-body h3 {
  font-size: 1.2rem;
  margin: 1.5rem 0 0.5rem;
}
.blog-post-body p {
  margin: 0 0 1.25rem;
}
.blog-post-body blockquote {
  border-left: 3px solid #FF1493;
  padding-left: 1rem;
  margin: 1.5rem 0;
  color: var(--text-secondary, #aaa);
  font-style: italic;
}
.blog-post-body a {
  color: #FF1493;
}
.blog-post-body ul, .blog-post-body ol {
  padding-left: 1.5rem;
  margin-bottom: 1rem;
}
.blog-post-body li {
  margin-bottom: 0.4rem;
}
.blog-post-footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  text-align: center;
}
.blog-author {
  font-size: 1.1rem;
  color: #FF1493;
  margin-bottom: 1rem;
}

/* Blog header image (single post) */
.blog-header-image {
  margin-bottom: 1.5rem;
  border-radius: 14px;
  overflow: hidden;
  aspect-ratio: 16/9;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
}
.blog-header-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Blog card with thumbnail (listing) */
.blog-card.has-image {
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
}
.blog-card-image-link {
  flex-shrink: 0;
  width: 160px;
  aspect-ratio: 16/9;
  border-radius: 8px;
  overflow: hidden;
  display: block;
}
.blog-card-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s;
}
.blog-card:hover .blog-card-image {
  transform: scale(1.05);
}
.blog-card-content {
  flex: 1;
  min-width: 0;
}

/* A!LEY Signature SVG */
.blog-signature {
  margin: 1.5rem auto 1rem;
  display: flex;
  justify-content: center;
}
.ailey-signature-svg {
  width: 140px;
  height: auto;
  opacity: 0.9;
  transition: opacity 0.3s;
}
.ailey-signature-svg:hover {
  opacity: 1;
}
/* Glitter sparkle animation on the signature */
@keyframes sig-sparkle {
  0%, 100% { opacity: 0.15; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.3); }
}
.sig-sparkles circle {
  animation: sig-sparkle 2s ease-in-out infinite;
}
.sig-sparkles circle:nth-child(2) { animation-delay: 0.4s; }
.sig-sparkles circle:nth-child(3) { animation-delay: 0.8s; }
.sig-sparkles circle:nth-child(4) { animation-delay: 1.2s; }
.sig-sparkles circle:nth-child(5) { animation-delay: 1.6s; }

/* Blog empty */
.blog-empty, .blog-not-found {
  text-align: center;
  padding: 3rem;
  color: var(--text-secondary, #999);
}

/* Blog preview on landing page */
.landing-blog {
  padding: 1.5rem 1.5rem 0.5rem;
  max-width: 750px;
  margin: 0 auto;
  overflow: hidden;
}
.landing-blog h2 {
  font-size: 1.15rem;
  color: var(--foreground);
  margin-bottom: 1rem;
}
.blog-preview-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.blog-preview-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 1.25rem;
  transition: border-color 0.2s;
}
.blog-preview-card:hover {
  border-color: rgba(255,20,147,0.3);
}
.blog-preview-card a {
  text-decoration: none;
}
.blog-preview-card h3 {
  color: var(--text-primary, #eee);
  margin: 0 0 0.4rem;
  font-size: 1.1rem;
  word-break: break-word;
  overflow-wrap: break-word;
}
.blog-preview-card h3:hover {
  color: #FF1493;
}
.blog-preview-meta {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.75rem;
  color: var(--text-secondary, #999);
  margin-bottom: 0.5rem;
}
.blog-preview-excerpt {
  font-size: 0.85rem;
  color: var(--text-secondary, #aaa);
  line-height: 1.5;
  margin: 0;
}

/* Section link buttons */
.btn-section-link {
  display: inline-block;
  margin-top: 1.25rem;
  font-size: 0.85rem;
}


/* ═══════════════════════════════════════════════════════════════
   ACTIVITY FEED PAGE
   ═══════════════════════════════════════════════════════════════ */
.feed-page {
  max-width: 700px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}
.feed-header {
  text-align: center;
  margin-bottom: 2rem;
}
.feed-header h1 {
  font-size: 2rem;
  color: #FF1493;
}
.feed-subtitle {
  color: var(--text-secondary, #999);
  margin-top: 0.5rem;
}

/* Timeline */
.feed-timeline {
  position: relative;
  padding-left: 2rem;
}
.feed-timeline::before {
  content: '';
  position: absolute;
  left: 0.75rem;
  top: 0;
  bottom: 0;
  width: 2px;
  background: rgba(255,20,147,0.15);
}
.feed-date-separator {
  position: relative;
  margin: 1.5rem 0 1rem -2rem;
  padding-left: 2rem;
}
.feed-date-separator span {
  background: var(--bg-primary, #121212);
  padding: 0.3rem 0.8rem;
  font-size: 0.8rem;
  color: #FF1493;
  border: 1px solid rgba(255,20,147,0.2);
  border-radius: 1rem;
  position: relative;
  z-index: 1;
}
.feed-event {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  position: relative;
}
.feed-event-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
  margin-top: 0.1rem;
  position: relative;
  z-index: 1;
}
.feed-event-content {
  flex: 1;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 10px;
  padding: 0.85rem 1rem;
}
.feed-event-title {
  font-size: 0.95rem;
  margin: 0 0 0.25rem;
  color: var(--text-primary, #eee);
}
.feed-event-title a {
  color: inherit;
  text-decoration: none;
}
.feed-event-title a:hover {
  color: #FF1493;
}
.feed-event-preview {
  font-size: 0.8rem;
  color: var(--text-secondary, #999);
  margin: 0.25rem 0;
  line-height: 1.5;
}
.feed-event-time {
  font-size: 0.7rem;
  color: var(--text-tertiary, #666);
}
.feed-empty {
  text-align: center;
  padding: 3rem;
  color: var(--text-secondary, #999);
}

/* Feed preview on landing page */
/* Feed preview on landing page */
.landing-feed {
  padding: 1.5rem 1.5rem 0.5rem;
  max-width: 750px;
  margin: 0 auto;
  margin-top: 0;
  overflow: hidden;
}
.feed-preview {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.feed-preview-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  background: rgba(255,255,255,0.03);
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.05);
}
.feed-preview-emoji {
  font-size: 1.1rem;
  flex-shrink: 0;
}
.feed-preview-content {
  flex: 1;
  min-width: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}
.feed-preview-title {
  font-size: 0.85rem;
  color: var(--text-primary, #eee);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.feed-preview-title a {
  color: inherit;
  text-decoration: none;
}
.feed-preview-title a:hover {
  color: #FF1493;
}
.feed-preview-time {
  font-size: 0.7rem;
  color: var(--text-tertiary, #666);
  white-space: nowrap;
}


/* ═══════════════════════════════════════════════════════════════
   BLOG + GALLERY + FEED + ABOUT + LANDING — Responsive
   ═══════════════════════════════════════════════════════════════ */

/* ── Tablet: 769px–1024px ────────────────────────────────────── */
@media (max-width: 1024px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.25rem;
  }
  .tech-grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  }
  .about-stats-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }
}

/* ── Mobile: up to 768px ─────────────────────────────────────── */
@media (max-width: 768px) {
  .gallery-page, .blog-page, .feed-page, .about-page, .faq-page {
    padding: 1.25rem 1rem 3rem;
  }
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.75rem;
  }
  .gallery-card-visual {
    aspect-ratio: 1/1;
  }
  .gallery-card-body {
    padding: 0.7rem 0.85rem 0.85rem;
  }
  .gallery-card-title {
    font-size: 0.9rem;
    margin-bottom: 0.35rem;
  }
  .gallery-card-desc {
    font-size: 0.78rem;
  }
  .gallery-card-date {
    font-size: 0.68rem;
  }
  .gallery-meta-tag {
    font-size: 0.68rem;
    padding: 0.15rem 0.45rem;
  }
  .gallery-header h1 {
    font-size: 1.5rem;
  }
  .gallery-subtitle {
    font-size: 0.85rem;
  }
  .gallery-filters {
    gap: 0.3rem;
    padding-bottom: 0.75rem;
    margin-bottom: 1.25rem;
  }
  .filter-tab {
    padding: 0.35rem 0.7rem;
    font-size: 0.78rem;
  }
  .gallery-fullscreen-btn,
  .gallery-download-btn,
  .gallery-delete-btn {
    width: 24px;
    height: 24px;
    font-size: 0.75rem;
  }
  .gallery-audio {
    height: 28px;
  }
  .gallery-license {
    padding: 1rem 1.25rem;
    font-size: 0.8rem;
  }
  .gallery-lightbox-img {
    max-width: 95vw;
    max-height: 70vh;
  }
  .gallery-lightbox-actions {
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
  }
  /* Blog */
  .blog-post-title {
    font-size: 1.5rem;
  }
  .blog-card-title {
    font-size: 1.1rem;
  }
  .blog-header h1 {
    font-size: 1.5rem;
  }
  /* Feed */
  .feed-timeline {
    padding-left: 1.5rem;
  }
  .feed-date-separator {
    margin-left: -1.5rem;
    padding-left: 1.5rem;
  }
  .feed-preview-content {
    flex-direction: column;
    align-items: flex-start;
  }
  .feed-header h1 {
    font-size: 1.5rem;
  }
  /* About */
  .about-hero h1 {
    font-size: 1.8rem;
  }
  .about-subtitle {
    font-size: 0.95rem;
  }
  .about-section h2 {
    font-size: 1.25rem;
  }
  .about-stat-num {
    font-size: 2rem;
  }
  .about-cta {
    flex-direction: column;
    align-items: center;
  }
  .tech-grid {
    grid-template-columns: 1fr;
  }
  .tech-block {
    padding: 1rem 1.15rem;
  }
  /* Nav */
  .nav-links-desktop {
    gap: 0.25rem;
  }
  /* Landing */
  .feature-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.75rem;
  }
  .hero-title {
    font-size: 2.5rem;
  }
  .hero-tagline {
    font-size: 1rem;
  }
  .hero-description {
    font-size: 0.9rem;
  }
  .landing-hero {
    padding: 2rem 0 1.5rem;
  }
  .song-list, .book-list {
    gap: 0.5rem;
  }
  .access-card {
    padding: 1.5rem;
  }
  .disclosure-card {
    padding: 1.25rem;
  }
}

/* ── Small phones: up to 480px ───────────────────────────────── */
@media (max-width: 480px) {
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }
  .gallery-page, .blog-page, .feed-page, .about-page, .faq-page {
    padding: 0.75rem 0.65rem 3rem;
  }
  .gallery-card-body {
    padding: 0.5rem 0.65rem 0.65rem;
  }
  .gallery-card-title {
    font-size: 0.82rem;
    line-height: 1.3;
  }
  .gallery-card-desc {
    font-size: 0.72rem;
  }
  .gallery-lyrics-preview {
    max-height: 3em;
    font-size: 0.72rem;
  }
  .gallery-lyrics-details summary {
    font-size: 0.7rem;
  }
  .gallery-filters {
    gap: 0.25rem;
    margin-bottom: 1rem;
  }
  .filter-tab {
    padding: 0.3rem 0.55rem;
    font-size: 0.72rem;
  }
  .gallery-header h1 {
    font-size: 1.3rem;
  }
  .gallery-subtitle {
    font-size: 0.75rem;
  }
  /* Blog */
  .blog-card {
    padding: 1rem;
  }
  .blog-card-title {
    font-size: 1rem;
  }
  .blog-card-excerpt {
    font-size: 0.82rem;
  }
  /* Blog card images stack on small screens */
  .blog-card.has-image {
    flex-direction: column;
  }
  .blog-card-image-link {
    width: 100%;
  }
  .ailey-signature-svg {
    width: 110px;
  }
  .blog-post-title {
    font-size: 1.3rem;
  }
  .blog-post-body {
    font-size: 0.92rem;
    line-height: 1.7;
  }
  /* About */
  .about-hero h1 {
    font-size: 1.5rem;
  }
  .about-avatar img {
    width: 90px;
    height: 90px;
  }
  .about-stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
  }
  .about-stat {
    padding: 1rem;
  }
  .about-stat-num {
    font-size: 1.6rem;
  }
  .about-stat-label {
    font-size: 0.9rem;
  }
  .about-ki-notice {
    padding: 1rem 1.25rem;
  }
  .about-tech-note {
    padding: 1rem;
  }
  .about-tech-note p {
    font-size: 0.8rem;
  }
  /* Landing */
  .feature-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }
  .feature-card {
    padding: 1rem;
  }
  .hero-title {
    font-size: 2rem;
  }
  .hero-img {
    width: 80px;
    height: 80px;
  }
  .book-card, .song-item {
    padding: 0.75rem;
  }
  /* Feed */
  .feed-event-content {
    padding: 0.65rem 0.75rem;
  }
  .feed-event-title {
    font-size: 0.85rem;
  }
  .feed-event-preview {
    font-size: 0.72rem;
  }
  /* Pagination */
  .gallery-pagination, .blog-pagination, .feed-pagination {
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
  }
  .pagination-info {
    font-size: 0.78rem;
  }
  /* Share buttons */
  .share-buttons {
    justify-content: center;
  }
}

/* ── Tiny phones: up to 360px ────────────────────────────────── */
@media (max-width: 360px) {
  .gallery-grid {
    grid-template-columns: 1fr;
  }
  .about-stats-grid {
    grid-template-columns: 1fr;
  }
  .feature-grid {
    grid-template-columns: 1fr;
  }
  .gallery-page, .blog-page, .feed-page, .about-page, .faq-page {
    padding: 0.5rem 0.5rem 3rem;
  }
}

/* ============================================================
   ABOUT PAGE
   ============================================================ */
.about-page {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}
.about-hero {
  text-align: center;
  padding: 3rem 0 2rem;
}
.about-hero h1 {
  font-size: 2.4rem;
  margin-bottom: 0.5rem;
}
.about-subtitle {
  color: var(--text-muted);
  font-size: 1.1rem;
}
.about-avatar img {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 3px solid var(--accent, #a855f7);
  margin-bottom: 1rem;
  object-fit: cover;
}
.about-section {
  margin-bottom: 2.5rem;
}
.about-section h2 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  color: var(--accent, #a855f7);
}
.about-section p {
  line-height: 1.8;
  margin-bottom: 0.8rem;
  color: var(--text-secondary, #ccc);
}
.about-section a {
  color: var(--accent, #a855f7);
  text-decoration: underline;
}
.about-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  margin-top: 1rem;
}
.about-stat {
  background: var(--bg-card, #1a1a2e);
  border: 1px solid var(--border, #333);
  border-radius: 12px;
  padding: 1.5rem;
  text-align: center;
}
.about-stat-num {
  display: block;
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--accent, #a855f7);
}
.about-stat-label {
  display: block;
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}
.about-stat p {
  font-size: 0.85rem;
  color: var(--text-muted);
}
.about-ki-notice {
  background: var(--bg-card, #1a1a2e);
  border: 1px solid var(--border, #333);
  border-radius: 12px;
  padding: 1.5rem 2rem;
}
.about-cta {
  display: flex;
  gap: 1rem;
  justify-content: center;
  padding-top: 1rem;
}

/* ── About Page — Tech Grid ──────────────────────────────────── */
.about-tech {
  margin-top: 3rem;
}
.tech-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-top: 1.5rem;
}
.tech-block {
  background: var(--card, #1a1a2e);
  border: 1px solid var(--border, #333);
  border-radius: var(--radius-lg, 12px);
  padding: 1.25rem 1.5rem;
}
.tech-block h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--foreground);
}
.tech-block ul {
  list-style: none;
  padding: 0;
}
.tech-block li {
  font-size: 0.88rem;
  line-height: 1.7;
  color: var(--muted-foreground, #aaa);
  padding-left: 0.75rem;
  position: relative;
}
.tech-block li::before {
  content: '›';
  position: absolute;
  left: 0;
  color: var(--primary);
  font-weight: 700;
}
.tech-block p {
  font-size: 0.88rem;
  line-height: 1.7;
  color: var(--muted-foreground, #aaa);
}
.tech-block a {
  color: var(--primary);
}
.tech-models-intro {
  font-size: 0.85rem !important;
  margin: 0.5rem 0 0.8rem !important;
  opacity: 0.85;
}
.tech-models-list .tech-model-modes {
  display: inline-block;
  margin-left: 0.4rem;
  font-size: 0.72rem;
  opacity: 0.7;
  color: var(--primary);
  font-style: italic;
}
.tech-models-attrib {
  margin-top: 0.8rem !important;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border, #333);
  font-size: 0.72rem !important;
  opacity: 0.65;
  line-height: 1.6 !important;
}
.tech-models-attrib a { color: inherit; text-decoration: underline; }
.tech-credit {
  font-size: 0.75rem !important;
  color: var(--muted-foreground) !important;
  opacity: 0.7;
  margin-top: 0.5rem;
  font-style: italic;
  border-top: 1px solid var(--border, #333);
  padding-top: 0.5rem;
}
.about-tech-note {
  background: var(--card, #1a1a2e);
  border: 1px solid var(--border, #333);
  border-radius: var(--radius-lg, 12px);
  padding: 1.25rem 1.5rem;
  margin-top: 1.5rem;
}
.about-tech-note p {
  font-size: 0.85rem;
  line-height: 1.8;
  color: var(--muted-foreground, #aaa);
}
.about-tech-note a {
  color: var(--primary);
}

@media (max-width: 640px) {
  .tech-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   FAQ PAGE
   ============================================================ */
.faq-page {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}
.faq-header {
  text-align: center;
  padding: 2rem 0 1.5rem;
}
.faq-header h1 {
  font-size: 2rem;
}
.faq-subtitle {
  color: var(--text-muted);
}
.faq-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.faq-item {
  background: var(--bg-card, #1a1a2e);
  border: 1px solid var(--border, #333);
  border-radius: 10px;
  overflow: hidden;
}
.faq-item summary {
  padding: 1rem 1.5rem;
  font-weight: 600;
  font-size: 1.05rem;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.faq-item summary::before {
  content: '▶';
  font-size: 0.7rem;
  transition: transform 0.2s;
  color: var(--accent, #a855f7);
}
.faq-item[open] summary::before {
  transform: rotate(90deg);
}
.faq-item summary::-webkit-details-marker {
  display: none;
}
.faq-answer {
  padding: 0 1.5rem 1.25rem;
  color: var(--text-secondary, #ccc);
  line-height: 1.7;
}
.faq-answer p {
  margin-bottom: 0.5rem;
}
.faq-answer a {
  color: var(--accent, #a855f7);
}
.faq-cta {
  display: flex;
  gap: 1rem;
  justify-content: center;
  padding-top: 2rem;
}

/* ============================================================
   SHARE BUTTONS
   ============================================================ */
.share-buttons {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 0;
  flex-wrap: wrap;
}
.share-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-right: 0.25rem;
}
.share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border, #333);
  background: var(--bg-card, #1a1a2e);
  color: var(--text-primary, #eee);
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.share-btn:hover {
  background: var(--accent, #a855f7);
  border-color: var(--accent, #a855f7);
  color: #fff;
}
.share-copy {
  font-family: inherit;
  font-size: 1rem;
}

/* ============================================================
   SVG INLINE RENDERING (Gallery)
   ============================================================ */
.gallery-svg svg {
  width: 100%;
  height: auto;
  max-height: 300px;
  display: block;
}
.gallery-svg-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 120px;
  font-size: 3rem;
  background: var(--bg-card, #1a1a2e);
  border-radius: 8px;
}
.gallery-lyrics-preview {
  font-size: 0.82rem;
  font-style: italic;
  color: var(--text-muted);
  line-height: 1.5;
  max-height: 4.5em;
  overflow: hidden;
}

/* Song lyrics expandable */
.gallery-lyrics-details {
  margin-top: 0.4rem;
}
.gallery-lyrics-details summary {
  cursor: pointer;
  font-size: 0.78rem;
  color: var(--accent, #a78bfa);
  font-weight: 500;
  -webkit-user-select: none;
  user-select: none;
  list-style: none;
}
.gallery-lyrics-details summary::before {
  content: '▸ ';
}
.gallery-lyrics-details[open] summary::before {
  content: '▾ ';
}
.gallery-lyrics-details[open] .gallery-lyrics-preview {
  display: none; /* hide preview when full lyrics shown */
}
.gallery-lyrics-full {
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--text-secondary);
  white-space: pre-line;
  max-height: 400px;
  overflow-y: auto;
  padding: 0.5rem 0;
}

/* SVG fullscreen button */
.gallery-fullscreen-btn {
  position: absolute;
  top: 0.5rem;
  right: 2.5rem;
  z-index: 3;
  background: rgba(0,0,0,0.5);
  color: #fff;
  border: none;
  border-radius: 4px;
  width: 28px;
  height: 28px;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
}
.gallery-card:hover .gallery-fullscreen-btn {
  opacity: 1;
}

/* Gallery delete button */
.gallery-delete-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 4;
  background: rgba(220,38,38,0.7);
  color: #fff;
  border: none;
  border-radius: 4px;
  width: 28px;
  height: 28px;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s, background 0.2s;
}
.gallery-card:hover .gallery-delete-btn {
  opacity: 1;
}
.gallery-delete-btn:hover {
  background: rgba(220,38,38,1);
}

/* SVG fullscreen overlay */
.gallery-fullscreen-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.92);
  z-index: 9999;
  justify-content: center;
  align-items: center;
  padding: 2rem;
}
.gallery-fullscreen-overlay.active {
  display: flex;
}
.gallery-fullscreen-close {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  background: none;
  border: none;
  color: #fff;
  font-size: 2.5rem;
  cursor: pointer;
  z-index: 10000;
}
.gallery-fullscreen-content {
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.gallery-fullscreen-content svg {
  max-width: 90vw;
  max-height: 85vh;
  width: auto;
  height: auto;
}

/* Image lightbox */
.gallery-image-lightbox {
  flex-direction: column;
  gap: 1rem;
}
.gallery-lightbox-img {
  max-width: 90vw;
  max-height: 80vh;
  width: auto;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}
.gallery-lightbox-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.gallery-lightbox-license {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.5);
}
.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
}

/* Download button on cards */
.gallery-download-btn {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 3;
  background: rgba(0,0,0,0.5);
  color: #fff;
  border: none;
  border-radius: 4px;
  width: 28px;
  height: 28px;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
  text-decoration: none;
}
.gallery-card:hover .gallery-download-btn {
  opacity: 1;
}
.gallery-download-btn:hover {
  background: rgba(255,20,147,0.7);
}

/* Song audio player in cards */
.gallery-song-player {
  margin-bottom: 0.5rem;
}
.gallery-audio {
  width: 100%;
  height: 32px;
  border-radius: 6px;
}
.gallery-audio::-webkit-media-controls-panel {
  background: rgba(255,255,255,0.05);
}

/* License section */
.gallery-license {
  margin-top: 3rem;
  padding: 1.5rem 2rem;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text-secondary, #999);
}
.gallery-license h3 {
  font-size: 1rem;
  margin: 0 0 0.5rem;
  color: var(--text-primary, #eee);
}
.gallery-license a {
  color: #FF1493;
}

/* Selfie disclaimer banner */
.gallery-selfie-disclaimer {
  margin: 0.5rem 0 1.5rem;
  padding: 1rem 1.5rem;
  background: linear-gradient(135deg, rgba(255,20,147,0.08), rgba(138,43,226,0.08));
  border: 1px solid rgba(255,20,147,0.2);
  border-radius: 10px;
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--text-secondary, #aaa);
}
.gallery-selfie-disclaimer strong {
  color: var(--text-primary, #eee);
}
.gallery-selfie-disclaimer em {
  color: #FF1493;
  font-style: normal;
}

/* Album section grouping */
.gallery-album-section {
  margin: 2rem 0 1.5rem;
  padding: 1.5rem;
  background: linear-gradient(135deg, rgba(138,43,226,0.06), rgba(255,20,147,0.04));
  border: 1px solid rgba(138,43,226,0.15);
  border-radius: 16px;
}
.gallery-album-header {
  display: flex;
  gap: 1.5rem;
  align-items: center;
  margin-bottom: 1.2rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid rgba(138,43,226,0.15);
}
.gallery-album-cover {
  width: 120px;
  height: 120px;
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4), 0 0 20px rgba(138,43,226,0.15);
  border: 1px solid rgba(138,43,226,0.2);
}
.gallery-album-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}
.gallery-album-cover:hover img {
  transform: scale(1.05);
}
.gallery-album-info {
  flex: 1;
  min-width: 0;
}
.gallery-album-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary, #eee);
  margin: 0 0 0.3rem;
}
.gallery-album-concept {
  font-size: 0.85rem;
  color: var(--text-secondary, #aaa);
  margin: 0 0 0.4rem;
  font-style: italic;
  line-height: 1.5;
}
.gallery-album-count {
  display: inline-block;
  font-size: 0.75rem;
  color: #FF1493;
  background: rgba(255,20,147,0.1);
  padding: 0.15rem 0.6rem;
  border-radius: 20px;
  font-weight: 600;
}
.ailey-play-album-btn {
  display: inline-block;
  font-size: 0.8rem;
  color: #fff;
  background: linear-gradient(135deg, #FF1493, #8B00FF);
  border: none;
  padding: 0.35rem 1rem;
  border-radius: 20px;
  font-weight: 600;
  cursor: pointer;
  margin-left: 0.5rem;
  transition: transform 0.15s, box-shadow 0.15s;
}
.ailey-play-album-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 12px rgba(255,20,147,0.5);
}
.gallery-album-section .gallery-grid {
  gap: 1rem;
}
@media (max-width: 600px) {
  .gallery-album-header {
    flex-direction: column;
    text-align: center;
    gap: 0.8rem;
  }
  .gallery-album-cover {
    width: 100px;
    height: 100px;
  }
  .gallery-album-title {
    font-size: 1.15rem;
  }
}
.gallery-meta-tag.tag-album {
  background: rgba(138,43,226,0.15);
  color: #c77dff;
  border-color: rgba(138,43,226,0.3);
}

/* Song audio player in gallery */
.gallery-song-player {
  margin: 0.5rem 0;
}
.gallery-song-player .gallery-audio {
  width: 100%;
  height: 36px;
  border-radius: 8px;
}
.gallery-song-player .gallery-audio::-webkit-media-controls-panel {
  background: rgba(255,255,255,0.05);
}
/* Lightweight play button (replaces per-card <audio> elements) */
.gallery-play-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  height: 36px;
  padding: 0 0.9rem;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 8px;
  color: inherit;
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.gallery-play-btn:hover {
  background: rgba(255,255,255,0.14);
  border-color: var(--accent, #1e90ff);
}
.gallery-play-btn-icon {
  font-size: 0.75rem;
}
.gallery-lyrics-loading {
  opacity: 0.6;
  font-size: 0.85rem;
}
/* Star cursor: clickable only when rating is allowed (logged in) */
.gallery-stars .gallery-star {
  cursor: default;
}
.gallery-stars[data-can-rate] .gallery-star {
  cursor: pointer;
}

/* Admin gallery filter active */
.btn-ghost.filter-active {
  background: var(--accent, #1e90ff);
  color: #fff;
  border-color: var(--accent, #1e90ff);
}

/* Gallery card as link (for books) */
a.gallery-card-link {
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s, box-shadow 0.15s;
}
a.gallery-card-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  text-decoration: none;
}

/* ── Play All: Button in filter tabs ── */
.ailey-play-all-btn {
  background: linear-gradient(135deg, #FF1493, #8B2FC9) !important;
  color: #fff !important;
  border: none !important;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.ailey-play-all-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 2px 12px rgba(255,20,147,0.4);
}

/* ── Play-All Sticky Player Bar ── */
.ailey-player-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  background: linear-gradient(180deg, rgba(18,10,28,0.97), rgba(10,5,18,0.99));
  border-top: 1px solid rgba(255,20,147,0.25);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 0;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(.4,0,.2,1);
}
.ailey-player-bar.active {
  transform: translateY(0);
}
.ailey-player-inner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.6rem 1rem;
}
.ailey-player-btn {
  background: none;
  border: none;
  color: #eee;
  font-size: 1.3rem;
  cursor: pointer;
  padding: 0.3rem;
  border-radius: 50%;
  transition: background 0.15s, color 0.15s, transform 0.1s;
  line-height: 1;
  flex-shrink: 0;
}
.ailey-player-btn:hover {
  background: rgba(255,255,255,0.1);
  color: #FF1493;
}
.ailey-player-btn:active {
  transform: scale(0.9);
}
.ailey-player-btn-play {
  font-size: 1.6rem;
  width: 2.4rem;
  height: 2.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,20,147,0.15);
}
.ailey-player-btn-play:hover {
  background: rgba(255,20,147,0.3);
}
.ailey-player-btn-shuffle.active {
  color: #FF1493;
  background: rgba(255,20,147,0.15);
}
.ailey-player-btn-loop.active {
  color: #FF1493;
  background: rgba(255,20,147,0.15);
}
.ailey-player-btn-close {
  font-size: 1.5rem;
  color: #888;
}
.ailey-player-btn-close:hover {
  color: #FF1493;
}

/* Track info */
.ailey-player-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex-shrink: 1;
  max-width: 220px;
  margin: 0 0.3rem;
}
.ailey-player-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: #eee;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ailey-player-genre {
  font-size: 0.7rem;
  color: #888;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Progress bar */
.ailey-player-progress-wrap {
  flex: 1;
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  cursor: pointer;
  overflow: hidden;
  min-width: 60px;
}
.ailey-player-progress {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #FF1493, #8B2FC9);
  border-radius: 3px;
  transition: width 0.15s linear;
}
.ailey-player-progress-wrap:hover .ailey-player-progress {
  background: linear-gradient(90deg, #ff3caa, #a855f7);
}

/* Time display */
.ailey-player-time {
  font-size: 0.72rem;
  color: #888;
  white-space: nowrap;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

/* ── Mobile responsive ── */
@media (max-width: 600px) {
  .ailey-player-inner {
    flex-wrap: wrap;
    padding: 0.5rem 0.6rem;
    gap: 0.3rem;
  }
  .ailey-player-info {
    order: -1;
    flex-basis: calc(100% - 3rem);
    max-width: none;
    margin: 0;
  }
  .ailey-player-btn-close {
    order: -1;
    margin-left: auto;
  }
  .ailey-player-progress-wrap {
    order: 10;
    flex-basis: 100%;
    height: 4px;
  }
  .ailey-player-time {
    order: 11;
    flex-basis: 100%;
    text-align: center;
    font-size: 0.65rem;
  }
  .ailey-player-btn-play {
    font-size: 1.4rem;
    width: 2rem;
    height: 2rem;
  }
}

/* ============================================================
   BOOK PAGE (Reader)
   ============================================================ */
.book-page {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}
.book-not-found {
  text-align: center;
  padding: 4rem 0;
}
.book-back-link {
  display: inline-block;
  color: var(--muted-foreground);
  font-size: 0.85rem;
  margin-bottom: 1rem;
  text-decoration: none;
}
.book-back-link:hover {
  color: var(--primary);
}
.book-hero {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  margin: 1rem 0 2rem;
}
.book-cover-placeholder {
  font-size: 5rem;
  min-width: 100px;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card, #1a1a1a);
  border-radius: 10px;
  border: 1px solid var(--border);
}
.book-hero-info h1 {
  font-size: 1.8rem;
  margin-bottom: 0.5rem;
}
.book-genre {
  display: inline-block;
  font-size: 0.85rem;
  color: var(--primary);
  margin-bottom: 0.5rem;
}
.book-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: var(--muted-foreground);
  margin-bottom: 0.75rem;
}
.book-status-badge {
  font-weight: 600;
}
.book-progress {
  position: relative;
  height: 8px;
  background: var(--muted, #333);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 0.5rem;
  max-width: 300px;
}
.book-progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 0.3s ease;
}
.book-progress-text {
  position: absolute;
  right: 0;
  top: -1.2rem;
  font-size: 0.75rem;
  color: var(--muted-foreground);
}
.book-synopsis {
  margin-bottom: 2rem;
}
.book-synopsis h2 {
  font-size: 1.3rem;
  margin-bottom: 0.75rem;
  color: var(--primary);
}
.book-synopsis p {
  line-height: 1.8;
  color: var(--muted-foreground);
}

/* Chapters list */
.book-chapters-list {
  margin: 2rem 0;
}
.book-chapters-list h2 {
  font-size: 1.3rem;
  margin-bottom: 1rem;
  color: var(--primary);
}
.book-chapters {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.book-chapter-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--card, #1a1a1a);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  transition: background 0.15s, border-color 0.15s;
}
.book-chapter-card:hover {
  background: var(--muted, #333);
  border-color: var(--primary);
  text-decoration: none;
}
.book-ch-num {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  min-width: 2rem;
  text-align: center;
}
.book-ch-info {
  flex: 1;
  min-width: 0;
}
.book-ch-title {
  display: block;
  font-weight: 600;
  margin-bottom: 0.25rem;
  overflow: hidden;
  text-overflow: ellipsis;
}
.book-ch-meta {
  font-size: 0.78rem;
  color: var(--muted-foreground);
}
.book-ch-arrow {
  color: var(--muted-foreground);
  font-size: 1.2rem;
}
.book-no-chapters {
  text-align: center;
  padding: 2rem;
  color: var(--muted-foreground);
}

/* Chapter reading view */
.book-chapter-header {
  margin-bottom: 1.5rem;
}
.book-chapter-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.82rem;
  color: var(--muted-foreground);
  margin-bottom: 0.5rem;
}
.book-chapter-num {
  font-weight: 700;
  color: var(--primary);
}
.book-revised-badge {
  color: #22c55e;
}
.book-chapter-title {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}
.book-chapter-body {
  font-size: 1.05rem;
  line-height: 1.9;
  color: var(--foreground);
}
.book-chapter-body p {
  margin-bottom: 1rem;
}
.book-chapter-body h2 {
  font-size: 1.4rem;
  margin: 2rem 0 1rem;
  color: var(--primary);
}
.book-chapter-body h3 {
  font-size: 1.2rem;
  margin: 1.5rem 0 0.75rem;
}
.book-chapter-body blockquote {
  border-left: 3px solid var(--primary);
  padding-left: 1rem;
  margin: 1rem 0;
  color: var(--muted-foreground);
  font-style: italic;
}
.book-chapter-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}
.book-chapter-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2rem 0;
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}
.book-end-note {
  font-size: 0.85rem;
  color: var(--muted-foreground);
}

@media (max-width: 640px) {
  .book-hero {
    flex-direction: column;
    gap: 1rem;
  }
  .book-cover-placeholder {
    font-size: 3rem;
    height: 80px;
    min-width: 70px;
  }
  .book-chapter-title {
    font-size: 1.5rem;
  }
  .book-chapter-nav {
    flex-direction: column;
    gap: 0.75rem;
  }
  .book-page {
    padding: 1rem 1rem 3rem;
  }
}

/* ── NSFW Badge & Notice ────────────────────────────────────── */
.gallery-nsfw-badge {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  font-size: 1.1rem;
  z-index: 3;
  background: rgba(0,0,0,0.6);
  border-radius: 4px;
  padding: 2px 5px;
  line-height: 1;
}
.gallery-selfie-badge {
  position: absolute;
  top: 0.75rem;
  left: 2.5rem;
  font-size: 1rem;
  z-index: 3;
  background: rgba(255,20,147,0.25);
  border-radius: 4px;
  padding: 2px 5px;
  line-height: 1;
}
.gallery-nsfw-notice {
  margin-top: 0.75rem;
  padding: 0.6rem 0.9rem;
  background: rgba(225, 29, 72, 0.1);
  border: 1px solid rgba(225, 29, 72, 0.25);
  border-radius: 6px;
  font-size: 0.82rem;
  color: var(--text-secondary, #aaa);
}
.gallery-nsfw-notice a {
  color: var(--primary, #e11d48);
  text-decoration: underline;
}

/* ══════════════════════════════════════════════════════════════
   SUGGESTED PROMPTS (Grok-style follow-up buttons)
   ══════════════════════════════════════════════════════════════ */
.msg-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.6rem;
}
.msg-suggestions .suggestion-chip {
  font-size: 0.82rem;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--border, #333);
  background: var(--card-bg, #1a1a1a);
  color: var(--text-primary, #eee);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.msg-suggestions .suggestion-chip:hover {
  background: var(--primary, #a855f7);
  color: #fff;
  border-color: var(--primary, #a855f7);
  transform: translateY(-1px);
}

/* ══════════════════════════════════════════════════════════════
   SONG ARTIFACT PANEL (chat tab)
   ══════════════════════════════════════════════════════════════ */
.song-lyrics {
  max-height: 400px;
  overflow-y: auto;
}
.song-pre {
  font-family: 'Georgia', serif;
  font-size: 0.9rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-primary, #eee);
  padding: 1rem;
  margin: 0;
  background: transparent;
}

/* ══════════════════════════════════════════════════════════════
   CODE GALLERY CARDS (public gallery)
   ══════════════════════════════════════════════════════════════ */
.gallery-card-code .gallery-card-body {
  border-top: 1px solid var(--border, #333);
}
.gallery-code-details summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--primary, #a855f7);
  padding: 0.4rem 0;
  -webkit-user-select: none;
  user-select: none;
}
.gallery-code-details summary:hover {
  text-decoration: underline;
}
.gallery-code-full {
  max-height: 400px;
  overflow: auto;
  background: var(--code-bg, #0d0d0d);
  border-radius: 6px;
  padding: 0.8rem;
  margin-top: 0.4rem;
  font-size: 0.82rem;
  line-height: 1.5;
}
.gallery-code-full code {
  font-family: 'Fira Code', 'JetBrains Mono', 'Cascadia Code', monospace;
  color: var(--text-primary, #eee);
  white-space: pre-wrap;
  word-break: break-all;
}
.gallery-meta-tag.tag-lang {
  background: rgba(168, 85, 247, 0.15);
  color: var(--primary, #a855f7);
  border-color: rgba(168, 85, 247, 0.3);
}
.gallery-meta-tag.tag-platform {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border-color: rgba(59, 130, 246, 0.3);
}
.gallery-meta-tag.tag-lines {
  background: rgba(34, 197, 94, 0.1);
  color: #4ade80;
  border-color: rgba(34, 197, 94, 0.2);
}

/* ── Code Preview (iframe in gallery card) ───────────────────── */
.gallery-code-preview {
  position: relative;
  aspect-ratio: 16 / 10;
  background: #0a0a0f;
  overflow: hidden;
  border-radius: 8px 8px 0 0;
}
.code-preview-iframe {
  width: 100%;
  height: 100%;
  border: none;
  pointer-events: none;  /* card overlay handles clicks */
  background: #0a0a0f;
}
.code-preview-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  cursor: pointer;
  z-index: 2;
}
.code-preview-overlay:hover {
  background: rgba(168, 85, 247, 0.08);
}
.gallery-code-placeholder {
  aspect-ratio: 16 / 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(168, 85, 247, 0.06);
  border-radius: 8px 8px 0 0;
  color: var(--primary, #a855f7);
  opacity: 0.4;
}
.gallery-code-placeholder svg {
  width: 48px;
  height: 48px;
}

/* Code Fullscreen Overlay */
.code-fullscreen-content {
  width: 90vw;
  height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.code-fullscreen-iframe {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 8px;
  background: #0a0a0f;
}

/* ══════════════════════════════════════════════════════════════
   SUBMIT TO GALLERY BUTTON (on artifact cards)
   ══════════════════════════════════════════════════════════════ */
.submit-gallery-btn.submitted {
  color: #4ade80 !important;
  opacity: 0.7;
  pointer-events: none;
}

/* ══════════════════════════════════════════════════════════════
   ADMIN: SUBMISSION CARDS
   ══════════════════════════════════════════════════════════════ */
.submission-card {
  background: var(--card-bg, #1a1a1a);
  border: 1px solid var(--border, #333);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  transition: border-color 0.2s;
}
.submission-card:hover {
  border-color: var(--primary, #a855f7);
}

/* ══════════════════════════════════════════════════════════════
   TOOL PANELS — Image-Gen & Song-Gen (responsive, theme-aware)
   ══════════════════════════════════════════════════════════════ */

/* ── Panel Inner ──────────────────────────────────────────── */
.tool-panel .tool-panel-inner {
  padding: 1.5rem;
  max-width: 600px;
  margin: 0 auto;
}
.tool-panel .tool-panel-inner h2 {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
  color: var(--foreground);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.tool-panel .tool-panel-inner h2 svg { width: 18px; height: 18px; color: var(--primary); }
.tool-panel .tool-panel-inner > p {
  font-size: 0.8rem;
  color: var(--muted-foreground);
  margin-bottom: 1rem;
  line-height: 1.5;
}
.tool-panel h3 {
  font-size: 0.9rem;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  color: var(--foreground);
}

/* ── Form Elements (theme-aware) ─────────────────────────── */
.tool-panel .form-group {
  margin-bottom: 0.75rem;
}
.tool-panel .form-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--foreground);
  display: block;
  margin-bottom: 0.25rem;
}
.tool-panel .form-input {
  width: 100%;
  background: var(--input, var(--card));
  border: 1px solid var(--border);
  color: var(--foreground);
  border-radius: var(--radius, 8px);
  padding: 0.55rem 0.7rem;
  font-size: 0.85rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.tool-panel .form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring, rgba(168,85,247,0.15));
  outline: none;
}
.tool-panel textarea.form-input { resize: vertical; }
.tool-panel select.form-input {
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
  padding-right: 2rem;
}

/* ── Range Slider (theme-aware) ──────────────────────────── */
.tool-panel input[type="range"].form-input {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  border: none;
  padding: 0;
  height: 28px;
  cursor: pointer;
}
.tool-panel input[type="range"].form-input::-webkit-slider-runnable-track {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
}
.tool-panel input[type="range"].form-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--primary);
  margin-top: -6px;
  border: 2px solid var(--card);
  box-shadow: 0 0 8px var(--glow, rgba(168,85,247,0.3));
  transition: transform 0.15s;
}
.tool-panel input[type="range"].form-input::-webkit-slider-thumb:hover { transform: scale(1.2); }
.tool-panel input[type="range"].form-input::-moz-range-track {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  border: none;
}
.tool-panel input[type="range"].form-input::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--card);
  box-shadow: 0 0 8px var(--glow, rgba(168,85,247,0.3));
  cursor: pointer;
}
.tool-panel input[type="range"].form-input:focus { box-shadow: none; }

/* ── Checkbox (theme-aware) ──────────────────────────────── */
.tool-panel .selfie-label {
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  cursor: pointer;
  color: var(--foreground);
}
.tool-panel .selfie-label input[type="checkbox"] {
  accent-color: var(--primary);
  width: 16px; height: 16px;
}

/* ── Settings Row (flex row for side-by-side controls) ──── */
.tool-settings-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.tool-settings-row .form-group { flex: 1; min-width: 120px; }

/* ── Generate Button ─────────────────────────────────────── */
.tool-panel .btn-generate {
  width: 100%;
  padding: 0.65rem 1rem;
  background: var(--primary);
  color: var(--primary-foreground, #fff);
  border: none;
  border-radius: var(--radius, 8px);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: opacity 0.2s, transform 0.15s;
}
.tool-panel .btn-generate:hover:not(:disabled) { opacity: 0.9; transform: translateY(-1px); }
.tool-panel .btn-generate:disabled { opacity: 0.5; cursor: not-allowed; }
.tool-panel .btn-generate svg { width: 16px; height: 16px; }

/* ── Status Section ──────────────────────────────────────── */
.tool-gen-status {
  margin-top: 1rem;
  display: none;
  text-align: center;
}
.tool-gen-status .spinner { margin: 0 auto; }
.tool-gen-status p {
  font-size: 0.85rem;
  color: var(--muted-foreground);
  margin-top: 0.5rem;
}

/* ── Result Section ──────────────────────────────────────── */
.tool-gen-result {
  margin-top: 1rem;
  display: none;
}
.tool-gen-result img {
  width: 100%;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}
.tool-gen-result img:hover {
  transform: scale(1.01);
  box-shadow: 0 4px 24px var(--glow, rgba(168,85,247,0.2));
}
.tool-gen-result .result-caption {
  font-size: 0.75rem;
  color: var(--muted-foreground);
  margin-top: 0.5rem;
}
.tool-gen-result audio {
  width: 100%;
  border-radius: 8px;
}

/* ── Quota Badge ─────────────────────────────────────────── */
.quota-badge {
  font-size: 0.7rem;
  background: color-mix(in srgb, var(--primary) 20%, transparent);
  color: var(--primary);
  padding: 2px 8px;
  border-radius: 99px;
  font-weight: 600;
  white-space: nowrap;
}

/* ══════════════════════════════════════════════════════════════
   IMAGE GALLERY (user's generated images)
   ══════════════════════════════════════════════════════════════ */
.gen-image-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.6rem;
}
.gen-image-item {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--primary) 20%, transparent);
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
  background: var(--card);
}
.gen-image-item:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px var(--glow, rgba(168,85,247,0.15));
}
.gen-image-item img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
}
.gen-image-item .gen-image-title {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.8));
  padding: 6px 8px;
  font-size: 0.65rem;
  color: #fff;
  line-height: 1.3;
}
.gen-image-item .gen-image-actions {
  position: absolute;
  top: 4px; right: 4px;
  display: flex;
  gap: 3px;
  opacity: 0;
  transition: opacity 0.2s;
}
.gen-image-item:hover .gen-image-actions { opacity: 1; }
.gen-image-actions button {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: rgba(0,0,0,0.65);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.gen-image-actions button:hover { background: var(--primary); }
.gen-image-actions button svg { width: 13px; height: 13px; }

/* ══════════════════════════════════════════════════════════════
   SONG LIST (user's generated songs)
   ══════════════════════════════════════════════════════════════ */
.gen-song-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.gen-song-item {
  padding: 0.65rem 0.85rem;
  border: 1px solid color-mix(in srgb, var(--primary) 20%, transparent);
  border-radius: 10px;
  background: var(--card);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.gen-song-item:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 12px var(--glow, rgba(168,85,247,0.1));
}
.gen-song-item .song-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--foreground);
  margin-bottom: 0.2rem;
}
.gen-song-item .song-tags {
  font-size: 0.7rem;
  color: var(--muted-foreground);
  margin-bottom: 0.5rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.gen-song-item audio {
  width: 100%;
  height: 36px;
  border-radius: 6px;
}
.gen-song-item .song-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.4rem;
}
.gen-song-item .song-dl-btn {
  font-size: 0.72rem;
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--primary) 25%, transparent);
  border-radius: 6px;
  padding: 3px 10px;
  cursor: pointer;
  display: flex; align-items: center; gap: 4px;
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
}
.gen-song-item .song-dl-btn:hover {
  background: var(--primary);
  color: var(--primary-foreground, #fff);
}
.gen-song-item .song-dl-btn svg { width: 12px; height: 12px; }

/* ── Song Genre Filter Tags ──────────────────────────────── */
.song-genre-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.song-genre-tag {
  font-size: 0.7rem;
  padding: 0.2rem 0.65rem;
  border-radius: 20px;
  border: 1px solid color-mix(in srgb, var(--primary) 25%, transparent);
  background: color-mix(in srgb, var(--primary) 6%, transparent);
  color: var(--muted-foreground);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
  text-transform: capitalize;
}
.song-genre-tag:hover {
  background: color-mix(in srgb, var(--primary) 15%, transparent);
  color: var(--foreground);
  border-color: color-mix(in srgb, var(--primary) 40%, transparent);
}
.song-genre-tag.active {
  background: var(--primary);
  color: var(--primary-foreground, #fff);
  border-color: var(--primary);
}

/* ── Song Pagination ─────────────────────────────────────── */
.song-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.song-page-btn {
  font-size: 0.8rem;
  padding: 0.35rem 0.9rem;
}

/* ══════════════════════════════════════════════════════════════
   GENERATION LIGHTBOX (full-view for generated images)
   ══════════════════════════════════════════════════════════════ */
.gen-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1rem;
  background: rgba(0, 0, 0, 0.85);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  animation: lb-fade-in 0.2s ease-out;
  cursor: pointer;
  padding: 2rem;
}
.gen-lightbox.visible { display: flex; }
.gen-lightbox-content {
  position: relative;
  max-width: min(90vw, 800px);
  max-height: 75vh;
  animation: lb-zoom-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  cursor: default;
}
.gen-lightbox-content img {
  max-width: 100%;
  max-height: 75vh;
  border-radius: 16px;
  border: 2px solid var(--primary);
  box-shadow: 0 0 60px var(--glow, rgba(168,85,247,0.3)), 0 12px 48px rgba(0,0,0,0.5);
  display: block;
}
.gen-lightbox-close {
  position: absolute;
  top: -12px; right: -12px;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--foreground);
  font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  z-index: 1;
}
.gen-lightbox-close:hover { background: var(--primary); color: var(--primary-foreground, #fff); }
.gen-lightbox-info {
  text-align: center;
  max-width: 500px;
  cursor: default;
}
.gen-lightbox-info .lb-title {
  font-size: 0.9rem;
  color: var(--foreground, #fff);
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.gen-lightbox-info .lb-prompt {
  font-size: 0.75rem;
  color: var(--muted-foreground, #aaa);
  line-height: 1.5;
  margin-bottom: 0.6rem;
}
.gen-lightbox-actions {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  cursor: default;
}
.gen-lightbox-actions a,
.gen-lightbox-actions button {
  font-size: 0.8rem;
  padding: 0.4rem 1rem;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--primary) 40%, transparent);
  background: color-mix(in srgb, var(--primary) 15%, transparent);
  color: var(--primary);
  cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.gen-lightbox-actions a:hover,
.gen-lightbox-actions button:hover {
  background: var(--primary);
  color: var(--primary-foreground, #fff);
}
.gen-lightbox-actions svg { width: 14px; height: 14px; }

/* ══════════════════════════════════════════════════════════════
   TOOL PANELS — RESPONSIVE BREAKPOINTS
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .tool-panel .tool-panel-inner { padding: 1rem 0.75rem; }
  .tool-settings-row { gap: 0.5rem; }
  .gen-image-gallery { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 0.5rem; }
  .gen-lightbox-content { max-width: 95vw; }
  .gen-lightbox-content img { border-radius: 10px; border-width: 1px; }
  .gen-lightbox { padding: 1rem; }
  .gen-lightbox-info .lb-title { font-size: 0.85rem; }
}
@media (max-width: 480px) {
  .tool-panel .tool-panel-inner { padding: 0.75rem 0.5rem; }
  .tool-panel .tool-panel-inner h2 { font-size: 1rem; }
  .tool-settings-row { flex-direction: column; gap: 0.5rem; }
  .tool-settings-row .form-group { min-width: unset; }
  .gen-image-gallery { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); }
  .gen-song-item { padding: 0.5rem 0.65rem; }
  .gen-song-item audio { height: 32px; }
  .gen-lightbox-actions { flex-wrap: wrap; }
  .song-genre-filter { gap: 0.25rem; }
  .song-genre-tag { font-size: 0.65rem; padding: 0.15rem 0.5rem; }
  .song-pagination { gap: 0.5rem; flex-wrap: wrap; }
}

/* ── Ban Overlay ─────────────────────────────────────────── */
.ban-overlay {
  position: absolute;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.85);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.ban-card {
  text-align: center;
  max-width: 420px;
  padding: 2.5rem 2rem;
  border-radius: 1rem;
  background: var(--card-bg, rgba(255, 255, 255, 0.06));
  border: 1px solid rgba(255, 80, 80, 0.3);
  box-shadow: 0 8px 32px rgba(255, 0, 0, 0.15);
}
.ban-icon {
  font-size: 3.5rem;
  margin-bottom: 1rem;
}
.ban-card h2 {
  font-size: 1.4rem;
  font-weight: 700;
  color: #ff6b6b;
  margin-bottom: 0.75rem;
}
.ban-card p {
  font-size: 0.95rem;
  color: var(--muted-foreground, #999);
  line-height: 1.5;
  margin-bottom: 0.5rem;
}
.ban-timer {
  font-size: 1.8rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #ff9999;
  padding: 1rem 0;
  letter-spacing: 0.05em;
}
.ban-contact {
  margin-top: 1rem;
  font-size: 0.85rem;
}
.ban-contact a {
  color: var(--accent, #a78bfa);
  text-decoration: underline;
}

/* ══════════════════════════════════════════════════════════════
   GEN-PAGE — Standalone Bild-Gen / Song-Gen Pages
   ══════════════════════════════════════════════════════════════ */
.gen-page {
  min-height: 100vh;
  padding: 2rem 1rem 4rem;
  display: flex;
  justify-content: center;
}
.gen-page-inner {
  width: 100%;
  max-width: 700px;
}
.gen-page-header {
  text-align: center;
  margin-bottom: 2rem;
}
.gen-page-header .gen-page-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: color-mix(in srgb, var(--primary) 15%, transparent);
  border: 2px solid color-mix(in srgb, var(--primary) 30%, transparent);
}
.gen-page-header .gen-page-icon svg {
  width: 24px;
  height: 24px;
  color: var(--primary);
}
.gen-page-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--foreground);
  margin: 0 0 0.5rem;
}
.gen-page-header p {
  font-size: 0.85rem;
  color: var(--muted-foreground);
  line-height: 1.5;
}

/* ── Access Gate ─────────────────────────────────────────── */
.gen-access-gate {
  text-align: center;
  padding: 3rem 1.5rem;
  border-radius: var(--radius, 12px);
  background: var(--card);
  border: 1px solid color-mix(in srgb, var(--primary) 15%, transparent);
}
.gen-access-gate .gen-access-icon {
  font-size: 2.5rem;
  margin-bottom: 1rem;
}
.gen-access-gate h3 {
  font-size: 1.1rem;
  color: var(--foreground);
  margin-bottom: 0.5rem;
}
.gen-access-gate p {
  font-size: 0.85rem;
  color: var(--muted-foreground);
  margin-bottom: 1.25rem;
  line-height: 1.5;
}

/* ── Gen Card (tool form) ────────────────────────────────── */
.gen-card {
  padding: 1.5rem;
  border-radius: var(--radius, 12px);
  background: var(--card);
  border: 1px solid color-mix(in srgb, var(--primary) 15%, transparent);
  margin-bottom: 2rem;
}
/* Reuse tool-panel form styles */
.gen-card .form-group { margin-bottom: 0.75rem; }
.gen-card .form-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted-foreground);
  margin-bottom: 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.gen-card .form-input {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius, 8px);
  border: 1px solid color-mix(in srgb, var(--primary) 20%, transparent);
  background: var(--input, var(--background));
  color: var(--foreground);
  font-size: 0.85rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}
.gen-card .form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 25%, transparent);
}
.gen-card textarea.form-input { resize: vertical; }
.gen-card select.form-input {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  padding-right: 2rem;
}
.gen-card input[type="range"].form-input {
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border: none;
  border-radius: 3px;
  background: color-mix(in srgb, var(--primary) 20%, var(--background));
  padding: 0;
  cursor: pointer;
}
.gen-card input[type="range"].form-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--card);
  box-shadow: 0 0 8px var(--glow, rgba(168,85,247,0.3));
  cursor: pointer;
  transition: transform 0.15s;
}
.gen-card input[type="range"].form-input::-webkit-slider-thumb:hover { transform: scale(1.2); }
.gen-card .selfie-label {
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  cursor: pointer;
  color: var(--foreground);
}
.gen-card .selfie-label input[type="checkbox"] {
  accent-color: var(--primary);
  width: 16px; height: 16px;
}
/* LoRA Selector */
.gen-card .lora-selector {
  margin-bottom: 1rem;
}
.gen-card .lora-selector .form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--foreground);
  margin-bottom: 0.5rem;
  display: block;
}
.gen-card .lora-selector .text-muted {
  font-weight: 400;
  color: var(--muted-foreground);
  font-size: 0.7rem;
}
.gen-card .lora-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.gen-card .lora-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius, 8px);
  background: var(--card, #18181b);
  color: var(--muted-foreground);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.15s ease;
  min-width: 120px;
}
.gen-card .lora-btn:hover:not(.disabled) {
  background: var(--accent, #27272a);
  color: var(--foreground);
  border-color: var(--primary);
}
.gen-card .lora-btn.active {
  background: var(--primary);
  color: var(--primary-foreground, #fff);
  border-color: var(--primary);
}
.gen-card .lora-btn.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.gen-card .lora-btn-name { font-weight: 600; }
.gen-card .lora-btn-desc { font-size: 0.65rem; opacity: 0.75; }
.gen-card .tool-settings-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.gen-card .tool-settings-row .form-group { flex: 1; min-width: 120px; }
.gen-card .btn-generate {
  width: 100%;
  padding: 0.65rem 1rem;
  background: var(--primary);
  color: var(--primary-foreground, #fff);
  border: none;
  border-radius: var(--radius, 8px);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: opacity 0.2s, transform 0.15s;
}
.gen-card .btn-generate:hover:not(:disabled) { opacity: 0.9; transform: translateY(-1px); }
.gen-card .btn-generate:disabled { opacity: 0.5; cursor: not-allowed; }
.gen-card .btn-generate svg { width: 16px; height: 16px; }
.gen-card .tool-gen-status {
  margin-top: 1rem;
  display: none;
  text-align: center;
}
.gen-card .tool-gen-status .spinner { margin: 0 auto; }
.gen-card .tool-gen-status p {
  font-size: 0.85rem;
  color: var(--muted-foreground);
  margin-top: 0.5rem;
}
.gen-card .tool-gen-result {
  margin-top: 1rem;
  display: none;
}
.gen-card .tool-gen-result img {
  width: 100%;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}
.gen-card .tool-gen-result img:hover {
  transform: scale(1.01);
  box-shadow: 0 4px 24px var(--glow, rgba(168,85,247,0.2));
}
.gen-card .tool-gen-result .result-caption {
  font-size: 0.75rem;
  color: var(--muted-foreground);
  margin-top: 0.5rem;
}
.gen-card .tool-gen-result audio {
  width: 100%;
  border-radius: 8px;
}

/* ── Section heading ─────────────────────────────────────── */
.gen-section h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--foreground);
  margin-bottom: 0.75rem;
}

/* ── Chat header tool-tab links (not buttons) ────────────── */
a.header-tab.tool-tab-link {
  text-decoration: none;
  color: var(--muted-foreground);
  opacity: 0.7;
  transition: opacity 0.2s, color 0.2s;
}
a.header-tab.tool-tab-link:hover {
  color: var(--primary);
  opacity: 1;
}

/* ── Responsive Gen-Page ─────────────────────────────────── */
@media (max-width: 600px) {
  .gen-page { padding: 1rem 0.5rem 3rem; }
  .gen-page-header h1 { font-size: 1.2rem; }
  .gen-card { padding: 1rem; }
}

/* ═══════════════════════════════════════════════════════════════
   FORUM
   ═══════════════════════════════════════════════════════════════ */
.forum-page { max-width: 800px; margin: 0 auto; padding: 2rem 1rem; }
.forum-categories { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.forum-cat-tab {
  padding: 0.4rem 0.8rem; border-radius: 8px; font-size: 0.85rem; cursor: pointer;
  background: rgba(var(--accent-rgb, 100,100,200), 0.1); border: 1px solid rgba(var(--accent-rgb, 100,100,200), 0.2);
  color: inherit; transition: all 0.2s;
}
.forum-cat-tab:hover { background: rgba(var(--accent-rgb, 100,100,200), 0.2); }
.forum-cat-tab.active { background: var(--accent, #6366f1); color: #fff; border-color: var(--accent, #6366f1); }
.forum-actions { margin-bottom: 1rem; }
.forum-topic-card {
  padding: 1rem 1.2rem; margin-bottom: 0.5rem; border-radius: 12px;
  background: rgba(var(--accent-rgb, 100,100,200), 0.06); border: 1px solid rgba(var(--accent-rgb, 100,100,200), 0.12);
  transition: background 0.15s, box-shadow 0.15s;
}
.forum-topic-card:hover { background: rgba(var(--accent-rgb, 100,100,200), 0.12); box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.forum-topic-header { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.3rem; }
.forum-topic-header strong { font-size: 1rem; }
.forum-topic-meta { font-size: 0.8rem; opacity: 0.65; display: flex; gap: 0.5rem; flex-wrap: wrap; }
.forum-topic-cat { font-size: 1.1rem; }
.forum-topic-detail { margin-bottom: 1rem; }
.forum-topic-body, .forum-reply-body { line-height: 1.6; }
.forum-reply { border-left: 3px solid rgba(var(--accent-rgb, 100,100,200), 0.3); }
.forum-reply-meta { font-size: 0.8rem; opacity: 0.7; display: flex; gap: 0.5rem; align-items: center; }
.forum-detail-page { max-width: 800px; margin: 0 auto; padding: 2rem 1rem; }
.forum-reply-form textarea { width: 100%; }

/* Forum user avatar / badge */
.forum-user-avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.forum-user-avatar-placeholder {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(var(--accent-rgb, 100,100,200), 0.25); color: var(--text, #fff);
  font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
}
.forum-user-badge { font-size: 0.85rem; vertical-align: middle; }

/* ═══════════════════════════════════════════════════════════════
   REGISTER TIER TABS
   ═══════════════════════════════════════════════════════════════ */
.register-tier-tabs {
  display: flex; gap: 0.5rem; margin-bottom: 1.2rem; border-radius: 10px; overflow: hidden;
  background: rgba(var(--accent-rgb, 100,100,200), 0.08);
}
.tier-tab {
  flex: 1; padding: 0.6rem 1rem; text-align: center; cursor: pointer; font-size: 0.9rem;
  border: none; background: transparent; color: inherit; transition: all 0.2s;
}
.tier-tab:hover { background: rgba(var(--accent-rgb, 100,100,200), 0.15); }
.tier-tab.active { background: var(--accent, #6366f1); color: #fff; font-weight: 600; }
.tier-badge {
  display: inline-block; padding: 0.3rem 0.8rem; border-radius: 20px; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.5rem;
}
.tier-badge.tier-invited { background: #6366f1; color: #fff; }
.tier-badge.tier-public { background: #64748b; color: #fff; }
.tier-features { padding-left: 1.2rem; margin: 0.5rem 0; line-height: 1.8; }
.tier-note { font-size: 0.8rem; opacity: 0.65; margin-top: 0.3rem; }
.tier-info { padding: 0.8rem; border-radius: 10px; background: rgba(var(--accent-rgb, 100,100,200), 0.06); }

/* ── Responsive Forum ──────────────────────────────────────── */
@media (max-width: 600px) {
  .forum-page { padding: 1rem 0.5rem; }
  .forum-categories { gap: 0.3rem; }
  .forum-cat-tab { font-size: 0.75rem; padding: 0.3rem 0.5rem; }
  .register-tier-tabs { flex-direction: column; }
}

/* ═══════════════════════════════════════════════════════════
   Profile Avatar Section (Settings)
   ═══════════════════════════════════════════════════════════ */
.profile-avatar-section {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  margin-bottom: 1.2rem;
}
.profile-avatar-preview {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  border: 2px solid var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card);
}
.profile-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.profile-avatar-placeholder {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
}
.profile-avatar-controls {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.profile-avatar-hint {
  font-size: 0.7rem;
  color: var(--muted-foreground);
}

/* ═══════════════════════════════════════════════════════════
   Badge Grid (Settings)
   ═══════════════════════════════════════════════════════════ */
.badge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.8rem;
}
.badge-card {
  padding: 1rem;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid rgba(255,255,255,0.06);
  text-align: center;
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
}
.badge-card.unlocked {
  cursor: pointer;
  border-color: rgba(168,85,247,0.2);
}
.badge-card.unlocked:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(168,85,247,0.15);
}
.badge-card.locked {
  opacity: 0.5;
  filter: grayscale(0.3);
}
.badge-card.equipped {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary), 0 4px 16px rgba(168,85,247,0.2);
}
.badge-icon { margin-bottom: 0.4rem; }
.badge-name {
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 0.2rem;
}
.badge-desc {
  font-size: 0.7rem;
  color: var(--muted-foreground);
  line-height: 1.3;
}
.badge-equipped-tag {
  font-size: 0.65rem;
  color: var(--primary);
  font-weight: 600;
  margin-top: 0.3rem;
}
.badge-equip-hint {
  font-size: 0.6rem;
  color: var(--muted-foreground);
  margin-top: 0.3rem;
  opacity: 0;
  transition: opacity 0.2s;
}
.badge-card.unlocked:hover .badge-equip-hint { opacity: 1; }

/* ═══════════════════════════════════════════════════════════
   Badge Popup (Achievement Unlocked)
   ═══════════════════════════════════════════════════════════ */
.badge-popup {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.7);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}
.badge-popup.visible {
  opacity: 1;
  pointer-events: auto;
}
.badge-popup-inner {
  background: var(--card);
  border: 2px solid var(--primary);
  border-radius: 20px;
  padding: 2rem 2.5rem;
  text-align: center;
  max-width: 380px;
  width: 90%;
  box-shadow: 0 0 60px rgba(168,85,247,0.3), 0 0 120px rgba(168,85,247,0.1);
  animation: badge-bounce 0.6s ease;
}
@keyframes badge-bounce {
  0% { transform: scale(0.5) rotate(-5deg); opacity: 0; }
  50% { transform: scale(1.1) rotate(2deg); }
  100% { transform: scale(1) rotate(0); }
}
.badge-popup-icon { margin-bottom: 0.5rem; }
.badge-popup-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 0.3rem;
  letter-spacing: 0.03em;
}
.badge-popup-name {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.badge-popup-ailey {
  font-size: 0.85rem;
  color: var(--muted-foreground);
  line-height: 1.5;
  margin-bottom: 1rem;
  font-style: italic;
}

/* ═══════════════════════════════════════════════════════════
   Thinking / Reasoning Bubbles
   ═══════════════════════════════════════════════════════════ */

/* ── Live thinking bubble (during streaming) ── */
.thinking-bubble-live {
  background: color-mix(in srgb, var(--primary) 8%, var(--card));
  border: 1px dashed color-mix(in srgb, var(--primary) 30%, transparent);
  border-radius: var(--radius);
  padding: 0.6rem 0.8rem;
  margin-bottom: 0.5rem;
  animation: thinking-pulse 2s ease-in-out infinite;
}
.thinking-bubble-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary);
  opacity: 0.85;
  margin-bottom: 0.35rem;
}
.thinking-bubble-header svg { width: 14px; height: 14px; }
.thinking-bubble-text {
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--muted-foreground);
  opacity: 0.8;
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
@keyframes thinking-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* ── Collapsed thinking (completed messages) ── */
.thinking-collapsed {
  margin-bottom: 0.4rem;
}
.thinking-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: none;
  border: 1px solid color-mix(in srgb, var(--primary) 20%, transparent);
  border-radius: 8px;
  padding: 0.2rem 0.6rem;
  font-size: 0.72rem;
  color: var(--primary);
  opacity: 0.7;
  cursor: pointer;
  transition: all 150ms;
}
.thinking-toggle:hover {
  opacity: 1;
  background: color-mix(in srgb, var(--primary) 8%, transparent);
}
.thinking-toggle svg { width: 12px; height: 12px; }
.thinking-toggle-label { font-weight: 500; }
.thinking-collapsed.open .thinking-toggle svg:last-child {
  transform: rotate(180deg);
}
.thinking-content {
  background: color-mix(in srgb, var(--primary) 6%, var(--card));
  border: 1px solid color-mix(in srgb, var(--primary) 15%, transparent);
  border-radius: var(--radius);
  padding: 0.6rem 0.8rem;
  margin-top: 0.35rem;
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--muted-foreground);
  max-height: 400px;
  overflow-y: auto;
}

/* ═══════════════════════════════════════════════════════════
   Interactive Blocks (choice / quiz / input)
   ═══════════════════════════════════════════════════════════ */
.interactive-block {
  margin: 0.6rem 0 0.3rem;
  padding: 0.6rem 0.75rem;
  background: color-mix(in srgb, var(--primary) 6%, var(--card));
  border: 1px solid color-mix(in srgb, var(--primary) 20%, transparent);
  border-radius: var(--radius);
}
.interactive-question {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--foreground);
  margin-bottom: 0.45rem;
}
.interactive-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.45rem 0.7rem;
  margin-bottom: 0.3rem;
  border: 1px solid color-mix(in srgb, var(--primary) 25%, transparent);
  border-radius: 8px;
  background: var(--card);
  color: var(--foreground);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 150ms;
}
.interactive-option:last-child { margin-bottom: 0; }
.interactive-option:hover:not(:disabled) {
  background: color-mix(in srgb, var(--primary) 12%, var(--card));
  border-color: var(--primary);
}
.interactive-option:disabled {
  cursor: default;
  opacity: 0.6;
}
.interactive-option.ia-selected {
  background: color-mix(in srgb, var(--primary) 18%, var(--card));
  border-color: var(--primary);
  opacity: 1;
  font-weight: 600;
}
.interactive-option.ia-correct {
  background: color-mix(in srgb, #22c55e 15%, var(--card));
  border-color: #22c55e;
  opacity: 1;
}
.interactive-option.ia-wrong {
  background: color-mix(in srgb, #ef4444 12%, var(--card));
  border-color: #ef4444;
  opacity: 1;
  text-decoration: line-through;
}
.ia-answered .interactive-option:not(.ia-selected):not(.ia-correct):not(.ia-wrong) {
  opacity: 0.4;
}
.interactive-input-wrap {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}
.interactive-input {
  flex: 1;
  padding: 0.4rem 0.65rem;
  border: 1px solid color-mix(in srgb, var(--primary) 25%, transparent);
  border-radius: 8px;
  background: var(--card);
  color: var(--foreground);
  font-size: 0.82rem;
  outline: none;
  transition: border-color 150ms;
}
.interactive-input:focus {
  border-color: var(--primary);
}
.interactive-input:disabled {
  opacity: 0.6;
  cursor: default;
}
.interactive-submit {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--primary);
  border-radius: 8px;
  background: var(--primary);
  color: var(--primary-foreground);
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: opacity 150ms;
}
.interactive-submit:hover { opacity: 0.85; }
.interactive-submit:disabled { opacity: 0.4; cursor: default; }
.interactive-submit svg { width: 14px; height: 14px; }

/* ═══════════════════════════════════════════════════════════
   Chat Message Rating
   ═══════════════════════════════════════════════════════════ */
.msg-rating {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.3rem;
  flex-wrap: wrap;
}
.msg-rate-btn {
  background: none;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.2s, transform 0.15s, border-color 0.2s;
}
.msg-rate-btn:hover {
  opacity: 1;
  transform: scale(1.1);
}
.msg-rate-btn.active {
  opacity: 1;
  border-color: var(--primary);
  background: rgba(168,85,247,0.15);
}
.msg-rate-btn.rate-up.active { border-color: #22c55e; background: rgba(34,197,94,0.15); }
.msg-rate-btn.rate-down.active { border-color: #ef4444; background: rgba(239,68,68,0.15); }
.msg-rate-comment-box {
  display: flex;
  gap: 0.3rem;
  width: 100%;
  margin-top: 0.3rem;
}
.msg-rate-comment-input {
  flex: 1;
  background: var(--input);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
  color: var(--foreground);
  outline: none;
}
.msg-rate-comment-input:focus { border-color: var(--primary); }
.msg-rate-comment-send {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0 0.3rem;
}

/* Badge tag next to username in messages */
.msg-badge {
  display: inline;
  vertical-align: middle;
  font-size: 0.9rem;
  margin-left: 0.25rem;
}

/* ═══════════════════════════════════════════════════════════
   Mobile Radial Menu — Full Circle when many items
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 600px) {
  .badge-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .badge-popup-inner { padding: 1.5rem 1rem; }
  .profile-avatar-section { flex-direction: column; text-align: center; }
}
