/* ============================================================
   SOKRATES — Intelligenter Philosoph
   Design: Dark Gold Matte · Futuristisch · Kreisförmig
   ============================================================ */

/* ── Design Tokens ── */
:root {
  --bg-void:        #07070e;
  --bg-deep:        #0c0c18;
  --bg-surface:     #101020;
  --bg-elevated:    #151528;
  --bg-glass:       rgba(18, 18, 34, 0.75);
  --bg-glass-light: rgba(28, 28, 52, 0.55);

  --gold-bright:    #eacb6e;
  --gold-mid:       #c9a84c;
  --gold-dim:       #8a6e2e;
  --gold-glow:      rgba(201, 168, 76, 0.18);
  --gold-glow-soft: rgba(201, 168, 76, 0.07);

  --text-primary:   #ede8d8;
  --text-secondary: #a89e82;
  --text-muted:     #524e40;
  --text-gold:      #c9a84c;

  --border-subtle:  rgba(201, 168, 76, 0.10);
  --border-mid:     rgba(201, 168, 76, 0.22);
  --border-bright:  rgba(201, 168, 76, 0.45);

  --radius-circle: 50%;
  --radius-pill:   100px;
  --radius-lg:     20px;
  --radius-md:     14px;
  --radius-sm:     8px;

  --sidebar-w: 272px;
  --header-h:  58px;

  --transition-fast: 140ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-mid:  260ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 420ms cubic-bezier(0.4, 0, 0.2, 1);

  --font-title: 'Cinzel', serif;
  --font-ui:    'Inter', sans-serif;
}

:root[data-theme="light"] {
  --bg-void:        #fcfaf6;
  --bg-deep:        #f3f0e8;
  --bg-surface:     #eae5d8;
  --bg-elevated:    #e0d9c8;
  --bg-glass:       rgba(252, 250, 246, 0.88);
  --bg-glass-light: rgba(243, 240, 232, 0.65);

  --gold-bright:    #c9a84c;
  --gold-mid:       #a3802e;
  --gold-dim:       #7a6021;
  --gold-glow:      rgba(163, 128, 46, 0.18);
  --gold-glow-soft: rgba(163, 128, 46, 0.07);

  --text-primary:   #2b271d;
  --text-secondary: #4f4838;
  --text-muted:     #827860;
  --text-gold:      #8a6e2e;

  --border-subtle:  rgba(163, 128, 46, 0.15);
  --border-mid:     rgba(163, 128, 46, 0.30);
  --border-bright:  rgba(163, 128, 46, 0.55);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font-ui);
  background: var(--bg-void);
  color: var(--text-primary);
  min-height: 100vh;
  overflow: hidden;
  direction: ltr;
}
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, textarea { font-family: inherit; }

/* ── Cursor Glow ── */
.cursor-glow {
  position: fixed;
  top: 0; left: 0;
  width: 300px; height: 300px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 9999;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(201,168,76,0.13) 0%, rgba(201,168,76,0.05) 35%, transparent 70%);
  mix-blend-mode: screen;
  transition: opacity 0.4s ease;
  opacity: 0;
  will-change: left, top;
}
body:hover .cursor-glow { opacity: 1; }
[data-theme="light"] .cursor-glow {
  background: radial-gradient(circle, rgba(160,110,20,0.20) 0%, rgba(160,110,20,0.08) 35%, transparent 68%);
  mix-blend-mode: multiply;
}

/* ── Ambient Background ── */
.ambient-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.22;
  animation: orb-drift 22s ease-in-out infinite alternate;
}
.orb-1 {
  width: 520px; height: 520px;
  background: radial-gradient(circle, #c9a84c 0%, transparent 70%);
  top: -160px; left: -80px;
  animation-duration: 24s;
}
.orb-2 {
  width: 420px; height: 420px;
  background: radial-gradient(circle, #2e2080 0%, transparent 70%);
  bottom: -100px; right: -80px;
  animation-duration: 19s;
  animation-delay: -9s;
}
.orb-3 {
  width: 280px; height: 280px;
  background: radial-gradient(circle, #c9a84c 0%, transparent 70%);
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  opacity: 0.07;
  animation-duration: 32s;
  animation-delay: -16s;
}
@keyframes orb-drift {
  0%   { transform: translate(0, 0) scale(1); }
  33%  { transform: translate(28px, -18px) scale(1.04); }
  66%  { transform: translate(-18px, 28px) scale(0.96); }
  100% { transform: translate(14px, 8px) scale(1.02); }
}
#particles-canvas { position: absolute; inset: 0; opacity: 0.35; }

/* ── App Shell ── */
.app-shell {
  position: relative;
  z-index: 1;
  display: flex;
  height: 100vh;
  height: 100dvh; /* Dynamic viewport height for mobile */
  overflow: hidden;
}

/* ── Chat Main ── */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%; /* Changed from 100vh to follow app-shell */
  overflow: hidden;
  min-width: 0;
  position: relative;
}

/* ── Header ── */
.chat-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  background: var(--bg-glass);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  position: relative;
  z-index: 20;
}

.header-emblem { flex-shrink: 0; }
.header-circle-outer {
  width: 34px; height: 34px;
  border-radius: var(--radius-circle);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: ring-rotate 20s linear infinite;
}
.header-circle-inner {
  width: 24px; height: 24px;
  border-radius: var(--radius-circle);
  background: var(--gold-glow-soft);
  border: 1px solid var(--border-mid);
  display: flex;
  align-items: center;
  justify-content: center;
}
@keyframes ring-rotate {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.chat-title-area { flex: 1; min-width: 0; overflow: hidden; }
.chat-title {
  font-family: var(--font-title);
  font-size: 1rem;
  font-weight: 600;
  color: var(--gold-mid);
  letter-spacing: 0.1em;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-subtitle {
  font-size: 0.62rem;
  color: var(--text-muted);
  display: block;
  margin-top: 2px;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Desktop Header Actions ── */
.header-actions { display: flex; align-items: center; gap: 7px; flex-shrink: 0; }

.header-action-btn {
  width: 32px; height: 32px;
  border-radius: var(--radius-circle);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all var(--transition-fast);
}
.header-action-btn:hover { color: var(--gold-mid); background: var(--gold-glow-soft); }

.clear-chat-btn {
  width: 32px; height: 32px;
  border-radius: var(--radius-circle);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all var(--transition-fast);
}
.clear-chat-btn:hover { color: #e05555; background: rgba(224, 85, 85, 0.1); }

/* Language & Theme Toggles */
.lang-toggle-btn, .theme-toggle-btn {
  height: 28px;
  width: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
  background: var(--bg-glass-light);
  cursor: pointer;
  transition: all var(--transition-fast);
  backdrop-filter: blur(12px);
  padding: 2px;
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
}
.lang-switch-wrap, .theme-switch-wrap {
  display: flex;
  align-items: center;
  width: 50px;
  height: 24px;
  position: relative;
}
.toggle-indicator {
  position: absolute;
  top: 1px;
  left: 1px;
  width: 22px;
  height: 22px;
  background: var(--gold-glow);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-circle);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 2px 8px rgba(201, 168, 76, 0.15);
  z-index: 0;
}
.lang-toggle-btn[data-active="de"] .toggle-indicator,
.theme-toggle-btn[data-active="light"] .toggle-indicator { transform: translateX(0); }
.lang-toggle-btn[data-active="en"] .toggle-indicator,
.theme-toggle-btn[data-active="dark"] .toggle-indicator { transform: translateX(25px); }

.lang-label, .sun-icon, .moon-icon {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.58rem;
  font-weight: 800;
  transition: all 0.3s ease;
  color: var(--text-muted);
  opacity: 0.5;
  position: relative;
  z-index: 1;
}
.sun-icon, .moon-icon { width: 12px; height: 12px; }

.lang-toggle-btn[data-active="de"] .lang-label.de,
.lang-toggle-btn[data-active="en"] .lang-label.en,
.theme-toggle-btn[data-active="light"] .sun-icon,
.theme-toggle-btn[data-active="dark"] .moon-icon { color: var(--gold-mid); opacity: 1; }

/* ── RAG Status Dot ── */
.rag-dot-wrap { width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.rag-dot { width: 8px; height: 8px; border-radius: 50%; }
.rag-dot--loading { background: #c9a84c; animation: rag-pulse 1.8s ease-in-out infinite; }
.rag-dot--ready   { background: #4ade80; animation: rag-pulse-g 2.5s ease-in-out infinite; }
.rag-dot--error   { background: #e05555; }
@keyframes rag-pulse   { 0%,100%{transform:scale(1);opacity:1} 50%{transform:scale(1.4);opacity:.5} }
@keyframes rag-pulse-g { 0%,100%{transform:scale(1);opacity:1} 50%{transform:scale(1.5);opacity:.6} }

/* ── Mobile Hamburger Menu Button ── */
.mobile-menu-btn {
  display: none;
  width: 36px; height: 36px;
  border-radius: var(--radius-circle);
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  background: var(--bg-glass-light);
  border: 1px solid var(--border-subtle);
  flex-shrink: 0;
  transition: all var(--transition-fast);
}
.mobile-menu-btn:hover { color: var(--gold-mid); border-color: var(--border-mid); }

/* ── Mobile Drawer (slides from right) ── */
.mobile-drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity var(--transition-mid);
}
.mobile-drawer-overlay.open {
  display: flex;
  justify-content: flex-start; /* Slide from left */
}
.mobile-drawer-overlay.visible { opacity: 1; }

.mobile-drawer {
  width: 260px;
  height: 100%;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border-mid); /* Right border instead of left */
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 20px 16px;
  transform: translateX(-100%); /* Start from left */
  transition: transform var(--transition-mid);
  box-shadow: 20px 0 60px rgba(0,0,0,0.5);
}
.mobile-drawer-overlay.visible .mobile-drawer { transform: translateX(0); }

.mobile-drawer-title {
  font-family: var(--font-title);
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0 4px 12px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 6px;
}
.mobile-drawer-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  transition: all var(--transition-fast);
}
.mobile-drawer-item:hover { background: var(--bg-surface); color: var(--text-primary); }
.mobile-drawer-item.danger:hover { background: rgba(224,85,85,0.1); color: #e05555; }
.mobile-drawer-item svg { flex-shrink: 0; }
.mobile-drawer-item span { flex: 1; }

/* Toggle items inside drawer */
.mobile-drawer-item .toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

/* ── Messages Area ── */
.messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 32px 20px 20px;
  display: flex;
  flex-direction: column;
  scroll-behavior: smooth;
  position: relative;
}
.messages-area::-webkit-scrollbar { width: 4px; }
.messages-area::-webkit-scrollbar-thumb { background: var(--border-subtle); border-radius: 2px; }

.messages-list {
  display: flex;
  flex-direction: column;
  gap: 22px;
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  z-index: 1;
}

/* ── Message Bubble ── */
.message {
  display: flex;
  gap: 14px;
  animation: msg-in 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes msg-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.message.user { flex-direction: row-reverse; }

.msg-avatar {
  width: 38px; height: 38px;
  border-radius: var(--radius-circle);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.message.ai .msg-avatar { background: var(--gold-glow); border: 1.5px solid var(--border-mid); }
.message.user .msg-avatar { background: rgba(70, 70, 150, 0.28); border: 1.5px solid rgba(110, 110, 190, 0.28); }

.msg-content { flex: 1; min-width: 0; }
.message.user .msg-content { align-items: flex-end; display: flex; flex-direction: column; }

.msg-bubble {
  padding: 14px 18px;
  line-height: 1.75;
  font-size: 0.88rem;
  position: relative;
  word-break: break-word;
  overflow-wrap: break-word;
}
.message.ai .msg-bubble {
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: 4px 18px 18px 18px;
  backdrop-filter: blur(12px);
  color: var(--text-primary);
}
.message.user .msg-bubble {
  background: rgba(201, 168, 76, 0.07);
  border: 1px solid var(--border-mid);
  border-radius: 18px 4px 18px 18px;
  backdrop-filter: blur(12px);
  color: var(--text-primary);
  max-width: 85%;
}

/* Markdown */
.msg-bubble h1, .msg-bubble h2, .msg-bubble h3 { color: var(--gold-mid); margin: 10px 0 5px; font-family: var(--font-title); font-weight: 600; }
.msg-bubble h1 { font-size: 1.05rem; }
.msg-bubble h2 { font-size: 0.95rem; }
.msg-bubble h3 { font-size: 0.88rem; }
.msg-bubble p { margin-bottom: 8px; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble ul, .msg-bubble ol { padding-left: 20px; margin: 8px 0; }
.msg-bubble li { margin-bottom: 4px; }
.msg-bubble strong { color: var(--gold-bright); font-weight: 600; }
.msg-bubble em { color: var(--text-secondary); font-style: italic; }
.msg-bubble code { background: rgba(201,168,76,0.1); border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); padding: 1px 6px; font-size: 0.82em; color: var(--gold-bright); }
.msg-bubble blockquote { border-left: 3px solid var(--gold-dim); padding-left: 12px; margin: 8px 0; color: var(--text-secondary); font-style: italic; }
.msg-bubble a { color: var(--gold-mid); text-decoration: underline; }
.msg-bubble hr { border: none; border-top: 1px solid var(--border-subtle); margin: 12px 0; }

/* Source & Meta */
.msg-source { margin-top: 10px; padding: 5px 12px; background: rgba(201,168,76,0.06); border: 1px solid var(--border-subtle); border-radius: var(--radius-pill); font-size: 0.7rem; color: var(--text-muted); display: inline-flex; align-items: center; gap: 6px; }
.msg-source-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--gold-dim); flex-shrink: 0; }
.msg-meta { display: flex; align-items: center; gap: 8px; margin-top: 6px; padding: 0 4px; }
.msg-time { font-size: 0.62rem; color: var(--text-muted); }
.msg-copy { display: flex; align-items: center; gap: 4px; color: var(--text-muted); padding: 3px 10px; border-radius: var(--radius-pill); font-size: 0.62rem; transition: all var(--transition-fast); }
.msg-copy:hover { color: var(--gold-mid); background: var(--gold-glow-soft); }

/* Typing Indicator */
.typing-indicator { display: flex; gap: 12px; }
.typing-bubble { background: var(--bg-glass); border: 1px solid var(--border-subtle); border-radius: 4px 18px 18px 18px; padding: 12px 18px; display: flex; gap: 5px; align-items: center; }
.typing-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--gold-mid); animation: typing-bounce 1.2s infinite; opacity: 0.4; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing-bounce { 0%,100%{transform:translateY(0);opacity:.4} 50%{transform:translateY(-6px);opacity:1} }

/* ── Welcome Screen ── */
.welcome-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 10px 20px 20px;
}
.welcome-emblem { 
  width: 240px; height: 240px; /* Even more compact */
  margin-bottom: 8px;
  flex-shrink: 0; 
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible; 
}
.welcome-emblem canvas {
  width: 100%;
  height: 100%;
  display: block;
}
.welcome-title {
  font-family: var(--font-title);
  font-size: clamp(1.8rem, 5vw, 3rem);
  font-weight: 700;
  color: var(--gold-mid);
  letter-spacing: 0.15em;
  margin-bottom: 8px;
  text-shadow: 0 0 40px rgba(201, 168, 76, 0.25);
}
.welcome-subtitle { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 18px; letter-spacing: 0.06em; }
.welcome-desc { padding: 0 20px; } /* side padding */
.welcome-desc {
  font-size: 0.85rem; /* slightly smaller */
  color: var(--text-secondary);
  line-height: 1.5;
  max-width: 480px;
  margin-bottom: 16px;
  font-weight: 300;
}
.welcome-suggestions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 580px; margin-bottom: 24px; }

/* ── Welcome Footer ── */
.welcome-footer {
  margin-top: auto;
  padding-top: 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  animation: fade-in 1s ease 2s forwards;
  opacity: 0;
}
.demo-note { font-size: 0.72rem; color: var(--text-muted); opacity: 0.7; }
.footer-links { display: flex; align-items: center; gap: 12px; font-size: 0.75rem; }
.footer-links a { color: var(--text-muted); text-decoration: none; transition: color var(--transition-fast); }
.footer-links a:hover { color: var(--gold-mid); }
.footer-links .dot { color: var(--border-mid); opacity: 0.5; }

/* ── Legal Modal ── */
.legal-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(7,7,12,0.85);
  backdrop-filter: blur(16px);
  display: none; align-items: center; justify-content: center;
  padding: 20px;
}
.legal-overlay.open { display: flex; }
.legal-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 800px;
  max-height: 85vh;
  display: flex; flex-direction: column;
  box-shadow: 0 40px 120px rgba(0,0,0,0.7);
  animation: modal-enter 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
.legal-header {
  padding: 24px 32px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex; align-items: center; justify-content: space-between;
}
.legal-title { font-family: var(--font-title); font-size: 1.1rem; color: var(--gold-mid); letter-spacing: 0.08em; }
.legal-close { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--text-muted); transition: all 0.2s; }
.legal-close:hover { background: var(--bg-surface); color: var(--text-primary); }

.legal-content {
  padding: 32px;
  overflow-y: auto;
  flex: 1;
  font-size: 0.92rem;
  line-height: 1.7;
  color: var(--text-secondary);
  scrollbar-width: thin;
}
.legal-content h4 { color: var(--text-primary); margin: 24px 0 12px; font-size: 1rem; }
.legal-content p { margin-bottom: 16px; }
.legal-content section { margin-bottom: 24px; }

@keyframes modal-enter {
  from { opacity: 0; transform: translateY(20px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.suggestion-chip {
  padding: 8px 18px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
  background: var(--bg-glass-light);
  color: var(--text-secondary);
  font-size: 0.78rem;
  transition: all var(--transition-mid);
  cursor: pointer;
}
.suggestion-chip:hover { border-color: var(--gold-mid); color: var(--gold-mid); background: var(--gold-glow); transform: translateY(-2px); }

/* ── Input Area (Floating) ── */
.input-area {
  position: relative; /* Changed from absolute */
  padding: 12px 20px 24px;
  background: var(--bg-void); /* Solid background to cover any overlapped content */
  z-index: 10;
  flex-shrink: 0;
}
@media (max-width: 600px) {
  .input-area {
    padding: 10px 12px 30px; /* Stronger bottom padding for iOS area */
  }
}

[data-theme="light"] .input-area {
  background: var(--bg-void); /* Solid on mobile, more reliable */
  border-top: 1px solid var(--border-subtle);
}

.input-container { max-width: 860px; margin: 0 auto; }

.input-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-elevated);
  border: 1.5px solid var(--border-mid);
  border-radius: 28px;
  padding: 8px 8px 8px 22px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
  transition: all var(--transition-mid);
}
.input-wrapper:focus-within { border-color: var(--gold-mid); box-shadow: 0 0 0 3px rgba(201,168,76,0.1), 0 10px 50px rgba(0,0,0,0.6); }

.chat-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 0.92rem;
  line-height: 1.5;
  resize: none;
  max-height: 140px;
  overflow-y: auto;
  padding: 6px 0;
}
.chat-input::placeholder { color: var(--text-muted); }

.input-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.char-count { font-size: 0.58rem; color: var(--text-muted); min-width: 20px; text-align: center; }

.send-btn {
  width: 42px; height: 42px;
  border-radius: var(--radius-circle);
  background: var(--gold-mid);
  color: var(--bg-void);
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition-mid);
  flex-shrink: 0;
}
.send-btn:disabled { background: var(--bg-surface); color: var(--text-muted); cursor: not-allowed; }
.send-btn:not(:disabled):hover { transform: scale(1.05); box-shadow: 0 0 20px rgba(201,168,76,0.4); }
.send-btn:not(:disabled):active { transform: scale(0.94); }

.input-footer { margin-top: 8px; display: flex; justify-content: center; }
.input-hint { font-size: 0.58rem; color: var(--text-muted); opacity: 0.6; }

/* ── Background Solar Canvas ── */
.bg-solar-canvas {
  position: absolute;
  top: var(--header-h);
  left: 0; right: 0; bottom: 0;
  width: 100%;
  height: calc(100% - var(--header-h));
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.8s ease;
  z-index: 0;
}

/* ── PDF Loading Overlay ── */
.pdf-loading-overlay { position: fixed; inset: 0; z-index: 100; background: rgba(7,7,14,0.88); backdrop-filter: blur(10px); display: flex; align-items: center; justify-content: center; }
.pdf-loading-box { background: var(--bg-elevated); border: 1px solid var(--border-mid); border-radius: 50%; width: 180px; height: 180px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; animation: scale-in 0.3s cubic-bezier(0.34,1.56,0.64,1); }
@keyframes scale-in { from{opacity:0;transform:scale(0.8)} to{opacity:1;transform:scale(1)} }
.pdf-loading-ring { width: 48px; height: 48px; border-radius: 50%; border: 2px solid var(--border-subtle); border-top-color: var(--gold-mid); animation: spin 0.75s linear infinite; }
@keyframes spin { to{transform:rotate(360deg)} }
.pdf-loading-text { font-size: 0.78rem; color: var(--text-primary); font-weight: 500; text-align: center; }
.pdf-loading-sub  { font-size: 0.65rem; color: var(--text-muted); text-align: center; }

/* ── Toast ── */
.toast { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%) translateY(16px); background: var(--bg-elevated); border: 1px solid var(--border-mid); border-radius: var(--radius-pill); padding: 9px 22px; font-size: 0.82rem; color: var(--text-primary); opacity: 0; pointer-events: none; transition: all var(--transition-mid); z-index: 600; white-space: nowrap; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { border-color: rgba(76,175,122,0.5); color: #4caf7a; }
.toast.error   { border-color: rgba(224,85,85,0.5); color: #e05555; }

/* ── Animations ── */
@keyframes fade-in { from{opacity:0;transform:translateY(10px)} to{opacity:1;transform:translateY(0)} }

/* ── Confirm Modal ── */
.confirm-overlay { position: fixed; inset: 0; z-index: 700; background: rgba(7,7,14,0.75); backdrop-filter: blur(10px); display: flex; align-items: center; justify-content: center; animation: fade-in 0.18s ease; }
.confirm-box { background: var(--bg-elevated); border: 1px solid var(--border-mid); border-radius: var(--radius-lg); padding: 30px 26px 22px; width: 300px; display: flex; flex-direction: column; align-items: center; gap: 16px; animation: scale-in 0.22s cubic-bezier(0.34,1.56,0.64,1); box-shadow: 0 24px 80px rgba(0,0,0,0.6); }
.confirm-icon { width: 52px; height: 52px; border-radius: 50%; background: var(--gold-glow); border: 1px solid var(--border-mid); display: flex; align-items: center; justify-content: center; }
.confirm-text { font-size: 0.9rem; color: var(--text-primary); text-align: center; line-height: 1.6; }
.confirm-actions { display: flex; gap: 10px; width: 100%; }
.confirm-cancel, .confirm-ok { flex: 1; padding: 10px; border-radius: var(--radius-pill); font-size: 0.82rem; font-family: var(--font-ui); font-weight: 500; cursor: pointer; transition: all var(--transition-mid); }
.confirm-cancel { background: var(--bg-surface); border: 1px solid var(--border-subtle); color: var(--text-secondary); }
.confirm-cancel:hover { border-color: var(--border-mid); color: var(--text-primary); }
.confirm-ok { background: linear-gradient(135deg, rgba(224,85,85,0.85), rgba(180,55,55,0.85)); border: 1px solid rgba(224,85,85,0.4); color: #fff; }
.confirm-ok:hover { background: linear-gradient(135deg, #e05555, #c03030); box-shadow: 0 4px 20px rgba(224,85,85,0.4); }

/* ── Chat History Popup ── */
.history-popup-overlay { position: fixed; inset: 0; z-index: 400; background: rgba(7,7,14,0.65); backdrop-filter: blur(8px); display: flex; align-items: flex-start; justify-content: flex-end; padding-top: calc(var(--header-h) + 8px); padding-right: 16px; opacity: 0; pointer-events: none; transition: opacity var(--transition-mid); }
.history-popup-overlay.open { opacity: 1; pointer-events: all; }
.history-popup { background: var(--bg-elevated); border: 1px solid var(--border-mid); border-radius: var(--radius-lg); width: 300px; max-height: 70vh; display: flex; flex-direction: column; box-shadow: 0 24px 80px rgba(0,0,0,0.55); transform: translateY(-10px) scale(0.97); transition: transform var(--transition-mid); overflow: hidden; }
.history-popup-overlay.open .history-popup { transform: translateY(0) scale(1); }
.history-popup-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 12px; border-bottom: 1px solid var(--border-subtle); flex-shrink: 0; }
.history-popup-title { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; font-weight: 600; color: var(--gold-mid); letter-spacing: 0.06em; font-family: var(--font-title); }
.history-popup-close { width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--text-muted); transition: all var(--transition-fast); }
.history-popup-close:hover { color: var(--text-primary); background: var(--bg-surface); }
.history-popup-list { flex: 1; overflow-y: auto; padding: 8px; }
.history-popup-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 12px; border-radius: var(--radius-pill); cursor: pointer; transition: background var(--transition-fast); color: var(--text-secondary); font-size: 0.8rem; }
.history-popup-item:hover { background: var(--bg-surface); color: var(--text-primary); }
.history-popup-item.active { background: var(--gold-glow); color: var(--gold-mid); }
.history-popup-item-content { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0; }
.history-popup-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.5; flex-shrink: 0; }
.history-popup-text { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-popup-del { opacity: 0; display: flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; color: var(--text-muted); transition: all var(--transition-fast); flex-shrink: 0; }
.history-popup-item:hover .history-popup-del { opacity: 1; }
@media (max-width: 650px) {
  .history-popup-del { opacity: 1; } /* Always visible on touch */
}
.history-popup-del:hover { color: #e05555; background: rgba(224,85,85,0.18); }
.history-popup-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 36px 20px; color: var(--text-muted); font-size: 0.78rem; text-align: center; }

/* ── Scrollbar ── */
* { scrollbar-width: thin; scrollbar-color: var(--border-subtle) transparent; }

/* ═══════════════════════════════════════════
   RESPONSIVE — MOBILE (≤ 600px)
   ═══════════════════════════════════════════ */
@media (max-width: 600px) {

  /* Header */
  .chat-header {
    padding: 0 14px;
    gap: 8px;
    height: 56px;
  }

  /* Hide desktop action icons — show only hamburger */
  .header-actions { display: none; }
  .mobile-menu-btn { display: flex; }

  /* Logo / Title: compact */
  .header-circle-outer { width: 30px; height: 30px; }
  .header-circle-inner { width: 22px; height: 22px; }

  .chat-title { font-size: 0.88rem; letter-spacing: 0.06em; }
  .chat-subtitle { display: none; } /* hide subtitle on mobile — no space */

  /* Welcome Screen: compact */
  .welcome-screen { padding: 10px 16px 60px; } /* Even tighter top padding to respect DVH */
  .welcome-emblem { width: 320px; height: 320px; margin-bottom: 20px; }
  .welcome-emblem canvas { width: 100%; height: 100%; }
  .welcome-title  { font-size: 1.6rem; letter-spacing: 0.08em; }
  .welcome-subtitle { font-size: 0.7rem; margin-bottom: 10px; }
  .welcome-desc { font-size: 0.78rem; max-width: 100%; margin-bottom: 18px; line-height: 1.6; }
  .welcome-suggestions { gap: 6px; }
  .suggestion-chip { padding: 6px 12px; font-size: 0.72rem; }

  /* Input Area */
  .input-area { padding: 8px 10px 32px; } /* Increased bottom padding for iOS bar */
  .input-wrapper { padding: 4px 4px 4px 16px; border-radius: 20px; gap: 6px; min-height: 44px; }
  .chat-input { font-size: 0.85rem; max-height: 90px; }
  .send-btn { width: 38px; height: 38px; }
  .input-footer { display: none; } /* hide kb hints on mobile */

  /* Messages: tighter */
  .messages-area { padding: 16px 12px 20px; }
  .msg-bubble { padding: 12px 14px; font-size: 0.85rem; }
  .msg-avatar { width: 32px; height: 32px; }
  .message { gap: 10px; }
  .message.user .msg-bubble { max-width: 90%; }

  /* History Popup: full width on mobile */
  .history-popup { width: calc(100vw - 24px); }
  .history-popup-overlay { justify-content: center; padding-right: 0; }
}

@media (min-width: 601px) and (max-width: 900px) {
  .messages-list, .input-container { max-width: 96%; }
}
