/* ==========================================================================
   GLAMOUR AI — Premium Design System
   Palette: charcoal black / warm ivory / muted gold accent
   Type: Fraunces (display) + Inter (body/UI) + JetBrains Mono (code)
   ========================================================================== */

:root {
  --gold: #C9A961;
  --gold-soft: #E8D9AF;
  --gold-dim: rgba(201, 169, 97, 0.16);

  --bg-0: #08080a;
  --bg-1: #0f0f12;
  --bg-2: #16161a;
  --bg-3: #1e1e23;
  --panel: rgba(24, 24, 28, 0.72);
  --panel-solid: #17171b;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);

  --text-0: #f3f1eb;
  --text-1: #cfccc4;
  --text-2: #8d8a83;
  --text-3: #5c5a56;

  --danger: #d97a6a;
  --success: #7cae87;

  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 9px;
  --shadow-soft: 0 20px 60px rgba(0,0,0,0.45);
  --shadow-tight: 0 8px 24px rgba(0,0,0,0.35);

  --font-display: 'Fraunces', serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --sidebar-w: 280px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

[data-theme="light"] {
  --bg-0: #f7f5f0;
  --bg-1: #efece5;
  --bg-2: #e7e3da;
  --bg-3: #ddd8cc;
  --panel: rgba(255, 255, 255, 0.72);
  --panel-solid: #fdfcf9;
  --border: rgba(20, 18, 12, 0.08);
  --border-strong: rgba(20, 18, 12, 0.14);

  --text-0: #1c1a15;
  --text-1: #4a473e;
  --text-2: #837f73;
  --text-3: #a8a397;

  --gold: #a9822f;
  --gold-soft: #c9a961;
  --gold-dim: rgba(169, 130, 47, 0.12);
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-body);
  background: var(--bg-0);
  color: var(--text-0);
  -webkit-font-smoothing: antialiased;
  transition: background 0.4s var(--ease), color 0.4s var(--ease);
}

.hidden { display: none !important; }

::selection { background: var(--gold-dim); color: var(--gold-soft); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold-dim); }

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea { font-family: inherit; color: inherit; background: none; border: none; outline: none; }
a { color: inherit; }

/* Background ambient texture */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 900px 500px at 15% -10%, rgba(201,169,97,0.06), transparent 60%),
    radial-gradient(ellipse 700px 500px at 110% 10%, rgba(201,169,97,0.04), transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ==========================================================================
   LOADER
   ========================================================================== */
.app-loader {
  position: fixed; inset: 0; z-index: 999;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-0);
  transition: opacity 0.5s var(--ease), visibility 0.5s var(--ease);
}
.app-loader.fade-out { opacity: 0; visibility: hidden; }
.loader-mark { animation: pulse-mark 1.6s ease-in-out infinite; }
@keyframes pulse-mark {
  0%, 100% { transform: scale(1); opacity: 0.7; }
  50% { transform: scale(1.08); opacity: 1; }
}

/* ==========================================================================
   AUTH SCREEN
   ========================================================================== */
.auth-screen {
  position: fixed; inset: 0; z-index: 500;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  animation: fadeIn 0.6s var(--ease);
}
.auth-ambient {
  position: absolute; inset: 0;
  background:
    radial-gradient(circle 500px at 20% 20%, rgba(201,169,97,0.09), transparent 70%),
    radial-gradient(circle 600px at 85% 85%, rgba(201,169,97,0.06), transparent 70%),
    var(--bg-0);
  z-index: -1;
}
.auth-card {
  width: 100%; max-width: 408px;
  background: var(--panel);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 44px 38px 34px;
  box-shadow: var(--shadow-soft);
  animation: riseIn 0.7s var(--ease);
}
@keyframes riseIn { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.auth-brand { text-align: center; margin-bottom: 30px; }
.brand-mark {
  width: 56px; height: 56px; margin: 0 auto 16px;
  border-radius: 50%;
  border: 1px solid var(--gold-dim);
  background: linear-gradient(160deg, var(--gold-dim), transparent);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 26px; font-weight: 600; color: var(--gold-soft);
}
.brand-mark.small { width: 34px; height: 34px; font-size: 17px; margin: 0; }
.auth-brand h1 {
  font-family: var(--font-display);
  font-size: 28px; font-weight: 500;
  letter-spacing: 0.2px;
}
.auth-tagline {
  color: var(--text-2); font-size: 13px; margin-top: 6px;
  letter-spacing: 0.4px; text-transform: uppercase;
}

.auth-form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field label { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.field input {
  padding: 12px 14px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14.5px;
  transition: border-color 0.25s, box-shadow 0.25s;
}
.field input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-dim);
}
.field-row { display: flex; justify-content: space-between; align-items: center; }
.remember { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-2); cursor: pointer; }
.remember input { accent-color: var(--gold); }

.link-btn {
  color: var(--gold-soft); font-size: 12.5px; font-weight: 500;
  text-decoration: none; transition: opacity 0.2s;
}
.link-btn:hover { opacity: 0.75; }

.btn-primary {
  position: relative; overflow: hidden;
  padding: 13px; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--gold-soft), var(--gold));
  color: #1a1509; font-weight: 700; font-size: 14.5px;
  letter-spacing: 0.2px;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
  box-shadow: 0 8px 20px rgba(201,169,97,0.18);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 10px 26px rgba(201,169,97,0.28); }
.btn-primary:active { transform: translateY(0); }
.btn-primary.small { padding: 9px 18px; font-size: 13px; width: auto; }
.btn-primary.danger { background: linear-gradient(135deg, #e08a7c, var(--danger)); color: #2a0e09; }

.auth-divider {
  display: flex; align-items: center; gap: 12px;
  color: var(--text-3); font-size: 12px; margin: 2px 0;
}
.auth-divider::before, .auth-divider::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}

.btn-google {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 12px; border-radius: var(--radius-sm);
  background: var(--bg-1); border: 1px solid var(--border);
  font-size: 14px; font-weight: 600;
  transition: border-color 0.2s, background 0.2s;
}
.btn-google:hover { border-color: var(--border-strong); background: var(--bg-2); }

.auth-switch { text-align: center; font-size: 13px; color: var(--text-2); margin-top: 4px; }
.auth-help { font-size: 13px; color: var(--text-2); line-height: 1.5; margin-bottom: 4px; }

.auth-message {
  margin-top: 16px; padding: 11px 14px; border-radius: var(--radius-sm);
  font-size: 12.5px; text-align: center;
  background: rgba(217, 122, 106, 0.12); color: #e69c8f;
  border: 1px solid rgba(217, 122, 106, 0.25);
}
.auth-message.success { background: rgba(124, 174, 135, 0.12); color: var(--success); border-color: rgba(124,174,135,0.25); }

/* ==========================================================================
   APP SHELL
   ========================================================================== */
.app-shell {
  position: relative; z-index: 1;
  display: flex; height: 100vh; width: 100vw;
  animation: fadeIn 0.5s var(--ease);
}

/* ---------------- SIDEBAR ---------------- */
.sidebar {
  width: var(--sidebar-w); min-width: var(--sidebar-w);
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 16px 12px;
  transition: margin-left 0.35s var(--ease), width 0.35s var(--ease);
  position: relative; z-index: 20;
}
.sidebar.collapsed { margin-left: calc(-1 * var(--sidebar-w)); }

.sidebar-top { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 18px; }
.sidebar-brand { display: flex; align-items: center; gap: 10px; }
.brand-name { font-family: var(--font-display); font-size: 16.5px; font-weight: 500; }

.icon-btn {
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: var(--text-2);
  transition: background 0.2s, color 0.2s;
}
.icon-btn.ghost:hover { background: var(--bg-2); color: var(--text-0); }

.btn-new-chat {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; margin: 4px 4px 16px;
  border: 1px solid var(--gold-dim);
  background: linear-gradient(160deg, var(--gold-dim), transparent);
  border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 600; color: var(--gold-soft);
  transition: border-color 0.2s, transform 0.15s;
}
.btn-new-chat:hover { border-color: var(--gold); transform: translateY(-1px); }

.sidebar-search {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 12px; margin: 0 4px 14px;
  background: var(--bg-2); border-radius: var(--radius-sm);
  border: 1px solid transparent;
}
.sidebar-search:focus-within { border-color: var(--border-strong); }
.sidebar-search i { color: var(--text-3); font-size: 12px; }
.sidebar-search input { flex: 1; font-size: 13px; color: var(--text-0); }
.sidebar-search input::placeholder { color: var(--text-3); }

.sidebar-section-label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.6px; text-transform: uppercase;
  color: var(--text-3); padding: 0 10px 8px;
}

.chat-history-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; padding: 0 2px; }

.chat-history-item {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  font-size: 13.2px; color: var(--text-1);
  cursor: pointer; position: relative;
  transition: background 0.18s;
}
.chat-history-item:hover { background: var(--bg-2); }
.chat-history-item.active { background: var(--gold-dim); color: var(--gold-soft); }
.chat-history-item .chat-item-title {
  flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-history-item .chat-item-actions {
  display: none; gap: 2px; flex-shrink: 0;
}
.chat-history-item:hover .chat-item-actions { display: flex; }
.chat-history-item .chat-item-actions button {
  width: 24px; height: 24px; border-radius: 6px; font-size: 11px; color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
}
.chat-history-item .chat-item-actions button:hover { background: var(--bg-3); color: var(--text-0); }
.chat-history-empty { color: var(--text-3); font-size: 12.5px; padding: 10px; text-align: center; }

.sidebar-bottom { border-top: 1px solid var(--border); padding-top: 10px; margin-top: 10px; display: flex; flex-direction: column; gap: 2px; }
.sidebar-action {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  font-size: 13.2px; color: var(--text-1);
  transition: background 0.18s;
}
.sidebar-action i { width: 16px; color: var(--text-2); font-size: 13px; }
.sidebar-action:hover { background: var(--bg-2); }

.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  margin-top: 8px; padding: 9px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-2);
}
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(160deg, var(--gold-soft), var(--gold));
  color: #1a1509; font-weight: 700; font-size: 13px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.user-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.user-name { font-size: 12.8px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-email { font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 15;
}
.sidebar-overlay.show { display: block; animation: fadeIn 0.25s; }

/* ---------------- CHAT MAIN ---------------- */
.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }

.chat-topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 24px; border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}
.chat-topbar h2 { font-family: var(--font-display); font-weight: 500; font-size: 16px; color: var(--text-1); flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mobile-only { display: none; }

.messages-container { flex: 1; overflow-y: auto; padding: 8px 0 4px; }

.empty-state { max-width: 640px; margin: 6vh auto 0; text-align: center; padding: 20px; animation: riseIn 0.6s var(--ease); }
.empty-mark {
  width: 64px; height: 64px; margin: 0 auto 20px;
  border-radius: 50%; border: 1px solid var(--gold-dim);
  background: linear-gradient(160deg, var(--gold-dim), transparent);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 30px; color: var(--gold-soft);
}
.empty-state h1 { font-family: var(--font-display); font-size: 26px; font-weight: 500; margin-bottom: 8px; }
.empty-state p { color: var(--text-2); font-size: 14px; margin-bottom: 28px; }

.suggestion-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.suggestion-card {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; text-align: left;
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--radius-md); font-size: 13px; color: var(--text-1);
  transition: border-color 0.2s, transform 0.2s;
}
.suggestion-card:hover { border-color: var(--gold-dim); transform: translateY(-2px); }
.suggestion-card i { color: var(--gold-soft); font-size: 14px; }

.messages-list { max-width: 760px; margin: 0 auto; padding: 8px 24px 24px; display: flex; flex-direction: column; gap: 22px; }

.message-row { display: flex; gap: 14px; animation: msgIn 0.35s var(--ease); }
@keyframes msgIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.message-row.user { flex-direction: row-reverse; }

.msg-avatar {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700;
  margin-top: 2px;
}
.message-row.assistant .msg-avatar {
  background: linear-gradient(160deg, var(--gold-soft), var(--gold)); color: #1a1509;
}
.message-row.user .msg-avatar { background: var(--bg-3); color: var(--text-1); }

.msg-col { display: flex; flex-direction: column; gap: 6px; max-width: 78%; }
.message-row.user .msg-col { align-items: flex-end; }

.msg-bubble {
  padding: 12px 16px; border-radius: var(--radius-md);
  font-size: 14.5px; line-height: 1.65; color: var(--text-0);
}
.message-row.assistant .msg-bubble { background: transparent; padding-left: 0; }
.message-row.user .msg-bubble { background: var(--bg-2); border: 1px solid var(--border); }

.msg-files { display: flex; flex-wrap: wrap; gap: 8px; }
.msg-file-chip {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 11px; background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 10px; font-size: 12px; color: var(--text-2);
}
.msg-file-chip img { width: 22px; height: 22px; border-radius: 4px; object-fit: cover; }

.msg-meta { display: flex; align-items: center; gap: 10px; font-size: 11px; color: var(--text-3); padding: 0 2px; }

.msg-actions { display: flex; gap: 4px; opacity: 0; transition: opacity 0.2s; }
.message-row:hover .msg-actions { opacity: 1; }
.msg-actions button {
  width: 24px; height: 24px; border-radius: 6px; font-size: 11px; color: var(--text-3);
  display: flex; align-items: center; justify-content: center;
}
.msg-actions button:hover { background: var(--bg-2); color: var(--gold-soft); }

/* Typing / thinking animation */
.thinking-dots { display: flex; gap: 5px; padding: 8px 0; }
.thinking-dots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--gold-soft);
  animation: dotPulse 1.2s ease-in-out infinite;
}
.thinking-dots span:nth-child(2) { animation-delay: 0.15s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes dotPulse { 0%, 60%, 100% { opacity: 0.25; transform: scale(0.85); } 30% { opacity: 1; transform: scale(1.1); } }

.typing-cursor::after {
  content: "▍"; color: var(--gold-soft); animation: blink 0.9s step-start infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* Markdown content styling */
.msg-bubble h1, .msg-bubble h2, .msg-bubble h3 { font-family: var(--font-display); margin: 14px 0 8px; font-weight: 600; line-height: 1.3; }
.msg-bubble h1 { font-size: 20px; } .msg-bubble h2 { font-size: 17px; } .msg-bubble h3 { font-size: 15px; }
.msg-bubble p { margin: 8px 0; }
.msg-bubble ul, .msg-bubble ol { margin: 8px 0 8px 22px; }
.msg-bubble li { margin: 4px 0; }
.msg-bubble a { color: var(--gold-soft); text-decoration: underline; }
.msg-bubble strong { color: var(--text-0); font-weight: 700; }
.msg-bubble blockquote {
  border-left: 2px solid var(--gold-dim); padding: 4px 14px; margin: 10px 0; color: var(--text-2);
}
.msg-bubble table { border-collapse: collapse; width: 100%; margin: 12px 0; font-size: 13px; }
.msg-bubble th, .msg-bubble td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; }
.msg-bubble th { background: var(--bg-2); font-weight: 600; }
.msg-bubble code:not(pre code) {
  background: var(--gold-dim); color: var(--gold-soft); padding: 2px 6px; border-radius: 5px;
  font-family: var(--font-mono); font-size: 0.88em;
}

.code-block-wrap { margin: 12px 0; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border); }
.code-block-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px; background: var(--bg-3); font-size: 11.5px; color: var(--text-2);
  font-family: var(--font-mono);
}
.code-copy-btn { display: flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 11.5px; }
.code-copy-btn:hover { color: var(--gold-soft); }
.msg-bubble pre {
  background: var(--bg-3) !important; padding: 14px 16px; overflow-x: auto;
  font-family: var(--font-mono); font-size: 13px; line-height: 1.6;
}
.msg-bubble pre code { background: transparent !important; padding: 0; }

.scroll-bottom-btn {
  position: absolute; bottom: 130px; left: 50%; transform: translateX(-50%);
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--panel-solid); border: 1px solid var(--border-strong);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-tight); color: var(--text-1); z-index: 5;
  transition: transform 0.2s;
}
.scroll-bottom-btn:hover { transform: translateX(-50%) translateY(-2px); }

/* ---------------- COMPOSER ---------------- */
.composer-wrap { max-width: 760px; margin: 0 auto; width: 100%; padding: 0 24px 18px; }

.file-preview-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.file-preview-chip {
  position: relative; display: flex; align-items: center; gap: 8px;
  padding: 7px 10px 7px 7px; background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 10px; font-size: 12px; color: var(--text-1);
}
.file-preview-chip img { width: 30px; height: 30px; border-radius: 6px; object-fit: cover; }
.file-preview-chip .file-icon-box {
  width: 30px; height: 30px; border-radius: 6px; background: var(--bg-3);
  display: flex; align-items: center; justify-content: center; color: var(--gold-soft); font-size: 13px;
}
.file-preview-chip .remove-file {
  width: 16px; height: 16px; border-radius: 50%; background: var(--bg-3);
  display: flex; align-items: center; justify-content: center; font-size: 9px; color: var(--text-2);
  margin-left: 4px;
}
.file-preview-chip .remove-file:hover { background: var(--danger); color: #fff; }

.composer {
  position: relative;
  display: flex; align-items: flex-end; gap: 6px;
  background: var(--panel-solid); border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg); padding: 8px 10px;
  box-shadow: var(--shadow-tight);
  transition: border-color 0.25s;
}
.composer:focus-within { border-color: var(--gold-dim); }
.composer.drag-active { border-color: var(--gold); }

.composer-icon { width: 36px; height: 36px; flex-shrink: 0; font-size: 15px; }
.composer-icon.active { color: var(--gold-soft); }

.chat-input {
  flex: 1; resize: none; max-height: 200px; min-height: 36px;
  padding: 8px 4px; font-size: 14.5px; line-height: 1.5; color: var(--text-0);
}
.chat-input::placeholder { color: var(--text-3); }

.send-btn {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(160deg, var(--gold-soft), var(--gold));
  color: #1a1509; display: flex; align-items: center; justify-content: center;
  font-size: 14px; transition: transform 0.15s, opacity 0.2s;
}
.send-btn:hover { transform: scale(1.06); }
.send-btn:disabled { opacity: 0.35; pointer-events: none; }
.send-btn.stop { background: var(--bg-3); color: var(--text-0); }

.drop-overlay {
  display: none; position: absolute; inset: 0; border-radius: var(--radius-lg);
  background: var(--gold-dim); border: 2px dashed var(--gold);
  align-items: center; justify-content: center; gap: 10px; flex-direction: column;
  color: var(--gold-soft); font-size: 13px; font-weight: 600;
  backdrop-filter: blur(4px);
}
.composer.drag-active .drop-overlay { display: flex; }

.composer-footer { display: flex; justify-content: space-between; padding: 8px 6px 0; font-size: 11px; color: var(--text-3); }

/* ==========================================================================
   MODALS
   ========================================================================== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(5,5,6,0.6); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fadeIn 0.25s var(--ease);
}
.modal-panel {
  width: 100%; max-width: 440px; max-height: 86vh; overflow: hidden;
  display: flex; flex-direction: column;
  background: var(--panel-solid); border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-soft);
  animation: riseIn 0.35s var(--ease);
}
.modal-panel.small { max-width: 360px; }
.modal-panel.large { max-width: 620px; }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-family: var(--font-display); font-size: 16.5px; font-weight: 500; display: flex; align-items: center; gap: 9px; }
.modal-header h3 i { color: var(--gold-soft); font-size: 14px; }

.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-hint { font-size: 12.5px; color: var(--text-2); line-height: 1.6; margin-bottom: 14px; }
.modal-status { font-size: 12px; color: var(--text-3); }

.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--border); }

.knowledge-textarea {
  width: 100%; min-height: 280px; padding: 14px; resize: vertical;
  background: var(--bg-1); border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 13.5px; line-height: 1.6; font-family: var(--font-mono); color: var(--text-0);
}
.knowledge-textarea:focus { border-color: var(--gold-dim); }

.rename-input {
  width: 100%; padding: 11px 14px; background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 14px;
}
.rename-input:focus { border-color: var(--gold); }

.settings-group { margin-bottom: 22px; }
.settings-group:last-child { margin-bottom: 0; }
.settings-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px; }

.theme-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.theme-option {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 14px 8px; background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 12px; color: var(--text-2);
  transition: border-color 0.2s, color 0.2s;
}
.theme-option i { font-size: 16px; }
.theme-option.active { border-color: var(--gold); color: var(--gold-soft); background: var(--gold-dim); }

.settings-actions-row { display: flex; gap: 8px; margin-bottom: 8px; }
.btn-secondary {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px; background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; color: var(--text-1);
  transition: border-color 0.2s, background 0.2s;
}
.btn-secondary:hover { border-color: var(--border-strong); background: var(--bg-2); }
.btn-secondary.full { width: 100%; }
.btn-secondary.danger { color: var(--danger); }
.btn-secondary.danger:hover { border-color: var(--danger); background: rgba(217,122,106,0.08); }
.file-label { position: relative; overflow: hidden; }

/* ==========================================================================
   TOASTS
   ========================================================================== */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 999; display: flex; flex-direction: column; gap: 10px; }
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; min-width: 240px; max-width: 340px;
  background: var(--panel-solid); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-soft);
  font-size: 13px; color: var(--text-0);
  animation: toastIn 0.3s var(--ease);
}
@keyframes toastIn { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: translateX(0); } }
.toast.exit { animation: toastOut 0.25s var(--ease) forwards; }
@keyframes toastOut { to { opacity: 0; transform: translateX(24px); } }
.toast i { font-size: 14px; }
.toast.success i { color: var(--success); }
.toast.error i { color: var(--danger); }
.toast.info i { color: var(--gold-soft); }

/* ==========================================================================
   RIPPLE EFFECT
   ========================================================================== */
.ripple { position: relative; overflow: hidden; }
.ripple-circle {
  position: absolute; border-radius: 50%; background: rgba(255,255,255,0.35);
  transform: scale(0); animation: rippleAnim 0.6s ease-out;
  pointer-events: none;
}
[data-theme="light"] .ripple-circle { background: rgba(0,0,0,0.12); }
@keyframes rippleAnim { to { transform: scale(2.5); opacity: 0; } }

/* ==========================================================================
   SHIMMER (loading skeleton)
   ========================================================================== */
.shimmer {
  background: linear-gradient(90deg, var(--bg-2) 25%, var(--bg-3) 37%, var(--bg-2) 63%);
  background-size: 400% 100%; animation: shimmerAnim 1.4s ease infinite;
  border-radius: 8px;
}
@keyframes shimmerAnim { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 860px) {
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 25;
    box-shadow: var(--shadow-soft);
  }
  .sidebar.collapsed { margin-left: calc(-1 * var(--sidebar-w)); }
  .sidebar:not(.collapsed) { margin-left: 0; }
  .mobile-only { display: flex; }
  .suggestion-grid { grid-template-columns: 1fr; }
  .msg-col { max-width: 88%; }
  .composer-wrap { padding: 0 12px 14px; }
  .messages-list { padding: 8px 12px 24px; }
  .chat-topbar { padding: 12px 14px; }
}

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

/* Focus visibility for accessibility */
button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
