/* ═══════════════════════════════════════════
   DevIgniter AI Studio — Design System CSS
   Font: Syne (headings) + DM Sans (body)
   Aesthetic: Refined dark futurism
═══════════════════════════════════════════ */

/* ── 1. Design Tokens ─────────────────────────────── */
:root {
  /* Core palette — dark */
  --bg-base:        #0A0B0F;
  --bg-surface:     #111318;
  --bg-elevated:    #17191F;
  --bg-hover:       #1E2028;
  --bg-active:      #22252F;
  --border:         rgba(255,255,255,0.07);
  --border-strong:  rgba(255,255,255,0.13);

  /* Text */
  --text-primary:   #F0F1F5;
  --text-secondary: #9396A3;
  --text-muted:     #5C5F6D;
  --text-inverse:   #0A0B0F;

  /* Brand / accent */
  --accent-start:   #FF6B35;
  --accent-end:     #FFBE0B;
  --accent-mid:     #FF9A1F;
  --accent-glow:    rgba(255, 107, 53, 0.25);
  --accent-glow2:   rgba(255, 190, 11, 0.15);

  /* AI message */
  --ai-bg:          #15171D;
  --user-bg:        #1C2035;
  --user-border:    rgba(100, 130, 255, 0.2);

  /* States */
  --danger:         #FF4D6D;
  --success:        #2DD4BF;
  --warning:        #FBBF24;

  /* Sizing */
  --sidebar-width:  260px;
  --tab-height:     48px;
  --input-height:   52px;
  --radius-sm:      8px;
  --radius:         12px;
  --radius-lg:      18px;
  --radius-xl:      24px;

  /* Shadows */
  --shadow-sm:      0 2px 8px rgba(0,0,0,0.3);
  --shadow-md:      0 8px 24px rgba(0,0,0,0.4);
  --shadow-lg:      0 16px 48px rgba(0,0,0,0.5);
  --shadow-accent:  0 8px 32px rgba(255,107,53,0.2);

  /* Transitions */
  --t-fast:    0.12s ease;
  --t-base:    0.22s ease;
  --t-slow:    0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
  --bg-base:        #F4F5F7;
  --bg-surface:     #FFFFFF;
  --bg-elevated:    #FAFAFA;
  --bg-hover:       #F0F1F4;
  --bg-active:      #E8EAEF;
  --border:         rgba(0,0,0,0.07);
  --border-strong:  rgba(0,0,0,0.13);
  --text-primary:   #111318;
  --text-secondary: #5A5D6A;
  --text-muted:     #9396A3;
  --text-inverse:   #FFFFFF;
  --ai-bg:          #FFFFFF;
  --user-bg:        #EEF2FF;
  --user-border:    rgba(90, 120, 255, 0.25);
  --shadow-sm:      0 2px 8px rgba(0,0,0,0.08);
  --shadow-md:      0 8px 24px rgba(0,0,0,0.12);
  --shadow-lg:      0 16px 48px rgba(0,0,0,0.16);
}

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

html { font-size: 15px; -webkit-font-smoothing: antialiased; scroll-behavior: smooth; }

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  overflow: hidden;
  height: 100dvh;
  transition: background var(--t-slow), color var(--t-slow);
}

h1,h2,h3,h4 { font-family: 'Syne', sans-serif; font-weight: 700; }

input, textarea, select, button { font-family: inherit; }

:focus-visible { outline: 2px solid var(--accent-start); outline-offset: 2px; border-radius: var(--radius-sm); }

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── 3. Utilities ─────────────────────────────────── */
.hidden { display: none !important; }
[hidden] { display: none !important; }
.icon-btn {
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: none; cursor: pointer;
  color: var(--text-secondary); border-radius: var(--radius-sm);
  padding: 6px; transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); transform: scale(1.05); }
.icon-btn:active { transform: scale(0.95); }

.btn-primary {
  display: inline-flex; align-items: center; gap: 8px;
  background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
  color: var(--text-inverse); border: none; cursor: pointer;
  padding: 10px 20px; border-radius: var(--radius);
  font-weight: 600; font-size: 0.9rem; letter-spacing: 0.01em;
  transition: filter var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
  box-shadow: var(--shadow-accent);
}
.btn-primary:hover { filter: brightness(1.1); transform: translateY(-1px); box-shadow: 0 10px 36px rgba(255,107,53,0.35); }
.btn-primary:active { transform: translateY(0) scale(0.97); }

.btn-ghost {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; border: 1px solid var(--border-strong);
  color: var(--text-secondary); cursor: pointer;
  padding: 9px 18px; border-radius: var(--radius);
  font-size: 0.875rem; font-weight: 500;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-strong); transform: translateY(-1px); }
.btn-ghost:active { transform: translateY(0); }

/* ── 4. Modal ─────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(16px);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  animation: fadeIn var(--t-base);
}

.modal-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  padding: 40px 36px;
  max-width: 420px; width: 100%;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  text-align: center;
}

.modal-logo {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  margin-bottom: 24px;
  font-family: 'Syne', sans-serif; font-weight: 800; font-size: 1.2rem;
  color: var(--text-primary);
}

.modal-card h2 { font-size: 1.5rem; margin-bottom: 8px; }
.modal-card > p { color: var(--text-secondary); font-size: 0.875rem; margin-bottom: 24px; }

.modal-input-wrap {
  position: relative; margin-bottom: 14px;
}
.modal-input-wrap input {
  width: 100%; padding: 12px 44px 12px 16px;
  background: var(--bg-surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius); color: var(--text-primary);
  font-size: 0.875rem; font-family: monospace; letter-spacing: 0.05em;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.modal-input-wrap input:focus { outline: none; border-color: var(--accent-start); box-shadow: 0 0 0 3px var(--accent-glow); }
.modal-input-wrap input::placeholder { letter-spacing: 0; font-family: 'DM Sans', sans-serif; }
.modal-input-wrap .icon-btn { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); }

.modal-card .btn-primary { width: 100%; justify-content: center; padding: 13px; font-size: 1rem; }

.modal-note { font-size: 0.78rem; color: var(--text-muted); margin-top: 14px; }

/* ── 5. App Shell ─────────────────────────────────── */
.app-shell {
  display: flex; height: 100dvh; overflow: hidden;
  animation: fadeIn 0.3s ease;
}

/* ── 6. Sidebar ───────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width); min-width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
  transition: width var(--t-slow), min-width var(--t-slow), opacity var(--t-slow);
  position: relative; z-index: 10;
}
.sidebar.collapsed { width: 0; min-width: 0; opacity: 0; pointer-events: none; }

.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 14px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.brand { display: flex; align-items: center; gap: 9px; }
.brand-name { font-family: 'Syne', sans-serif; font-weight: 800; font-size: 1rem; letter-spacing: -0.01em; white-space: nowrap; }

.sidebar-collapse-btn { padding: 5px; }

.new-chat-btn {
  display: flex; align-items: center; gap: 9px;
  margin: 12px 12px 4px;
  padding: 10px 14px;
  background: linear-gradient(135deg, rgba(255,107,53,0.12), rgba(255,190,11,0.08));
  border: 1px solid rgba(255,107,53,0.25);
  border-radius: var(--radius); cursor: pointer;
  font-size: 0.875rem; font-weight: 600; color: var(--accent-start);
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
  white-space: nowrap;
}
.new-chat-btn:hover { background: linear-gradient(135deg, rgba(255,107,53,0.2), rgba(255,190,11,0.14)); border-color: rgba(255,107,53,0.5); transform: translateY(-1px); box-shadow: 0 4px 16px rgba(255,107,53,0.15); }
.new-chat-btn:active { transform: translateY(0); }

.sidebar-section-label { font-size: 0.7rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); padding: 12px 14px 4px; white-space: nowrap; }

.conversations-list { flex: 1; overflow-y: auto; padding: 4px 8px 8px; display: flex; flex-direction: column; gap: 2px; }

.conv-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm); cursor: pointer;
  transition: background var(--t-fast); position: relative;
  border: 1px solid transparent;
  animation: fadeSlideIn 0.2s ease;
}
.conv-item:hover { background: var(--bg-hover); }
.conv-item.active { background: var(--bg-active); border-color: var(--border); }

.conv-icon { width: 28px; height: 28px; border-radius: 7px; background: var(--bg-active); display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 13px; }
.conv-item.active .conv-icon { background: linear-gradient(135deg, var(--accent-start), var(--accent-end)); }

.conv-meta { flex: 1; min-width: 0; }
.conv-title { font-size: 0.82rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-primary); }
.conv-time { font-size: 0.7rem; color: var(--text-muted); margin-top: 1px; }

.conv-more-btn { opacity: 0; display: flex; align-items: center; justify-content: center; padding: 3px; border-radius: 5px; background: transparent; border: none; cursor: pointer; color: var(--text-secondary); transition: opacity var(--t-fast), background var(--t-fast); flex-shrink: 0; }
.conv-item:hover .conv-more-btn { opacity: 1; }
.conv-more-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

.conv-item input.rename-input {
  background: var(--bg-hover); border: 1px solid var(--accent-start); border-radius: 5px; padding: 2px 6px; color: var(--text-primary); font-size: 0.82rem; width: 100%;
}

.sidebar-footer { border-top: 1px solid var(--border); padding: 8px; display: flex; flex-direction: column; gap: 2px; flex-shrink: 0; }

.sidebar-footer-btn {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 10px; background: transparent; border: none; cursor: pointer;
  color: var(--text-secondary); border-radius: var(--radius-sm); font-size: 0.82rem;
  transition: background var(--t-fast), color var(--t-fast);
  white-space: nowrap;
}
.sidebar-footer-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

/* Sidebar open button (when collapsed) */
.sidebar-open-btn {
  position: fixed; top: 16px; left: 16px; z-index: 100;
  background: var(--bg-elevated); border: 1px solid var(--border-strong);
  border-radius: var(--radius); padding: 8px;
  cursor: pointer; box-shadow: var(--shadow-sm);
  display: flex; align-items: center; justify-content: center;
  transition: background var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
}
.sidebar-open-btn:hover { background: var(--bg-hover); transform: scale(1.05); box-shadow: var(--shadow-md); }

/* ── 7. Main Area ─────────────────────────────────── */
.main-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; position: relative; }

/* ── 8. Tab Bar ───────────────────────────────────── */
.tab-bar {
  display: flex; gap: 4px; padding: 8px 12px;
  background: var(--bg-surface); border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.tab-btn {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 14px; border-radius: var(--radius-sm); border: none; cursor: pointer;
  font-size: 0.82rem; font-weight: 500; color: var(--text-secondary);
  background: transparent;
  transition: background var(--t-fast), color var(--t-fast);
}
.tab-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.tab-btn.active { background: var(--bg-active); color: var(--text-primary); font-weight: 600; }
.tab-btn.active svg { color: var(--accent-start); }

/* ── 9. Tab Panels ───────────────────────────────── */
.tab-panel { display: none; flex: 1; flex-direction: column; overflow: hidden; }
.tab-panel.active { display: flex; }

/* ── 10. Welcome Screen ───────────────────────────── */
.welcome-screen {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 32px 20px; gap: 16px; overflow-y: auto; text-align: center;
  animation: fadeIn 0.5s ease;
}

.welcome-logo { animation: floatBob 3s ease-in-out infinite; margin-bottom: 8px; }

.welcome-title { font-size: clamp(1.5rem, 4vw, 2.5rem); font-weight: 800; letter-spacing: -0.03em; background: linear-gradient(135deg, var(--text-primary) 40%, var(--accent-mid)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }

.welcome-tagline { color: var(--text-secondary); font-size: clamp(0.875rem, 2vw, 1rem); max-width: 480px; margin-bottom: 8px; }

.suggested-prompts {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 640px;
  margin-top: 8px;
}

.prompt-chip {
  padding: 8px 16px; border-radius: 99px; font-size: 0.82rem; font-weight: 500;
  background: var(--bg-elevated); border: 1px solid var(--border-strong);
  cursor: pointer; color: var(--text-secondary);
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
}
.prompt-chip:hover { background: var(--bg-hover); color: var(--text-primary); border-color: rgba(255,107,53,0.3); transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,0.2); }
.prompt-chip:active { transform: translateY(0); }

/* ── 11. Chat Messages ────────────────────────────── */
.chat-messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 8px; }

.msg-row {
  display: flex; gap: 12px; align-items: flex-end; max-width: 820px;
  animation: fadeSlideIn 0.3s ease;
}
.msg-row.user { align-self: flex-end; flex-direction: row-reverse; }
.msg-row.assistant { align-self: flex-start; }

.msg-avatar {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 14px;
  overflow: hidden;
}
.msg-row.assistant .msg-avatar { background: linear-gradient(135deg, var(--accent-start), var(--accent-end)); color: #000; }
.msg-row.user .msg-avatar { background: var(--user-bg); border: 1px solid var(--user-border); color: var(--text-primary); }

.msg-content { max-width: min(600px, 78%); display: flex; flex-direction: column; gap: 4px; }

.msg-bubble {
  padding: 12px 16px; border-radius: var(--radius-lg);
  font-size: 0.875rem; line-height: 1.65; word-wrap: break-word;
  position: relative;
}
.msg-row.assistant .msg-bubble {
  background: var(--ai-bg); border: 1px solid var(--border);
  border-bottom-left-radius: 4px; color: var(--text-primary);
}
.msg-row.user .msg-bubble {
  background: var(--user-bg); border: 1px solid var(--user-border);
  border-bottom-right-radius: 4px; color: var(--text-primary);
}

.msg-bubble img { max-width: 100%; border-radius: 8px; margin: 8px 0; }

/* Markdown styles inside bubble */
.msg-bubble h1,.msg-bubble h2,.msg-bubble h3 { margin: 12px 0 6px; font-size: 1em; }
.msg-bubble p { margin: 4px 0; }
.msg-bubble pre { background: var(--bg-base); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; overflow-x: auto; margin: 8px 0; font-size: 0.82em; }
.msg-bubble code { background: var(--bg-base); padding: 2px 5px; border-radius: 4px; font-size: 0.82em; }
.msg-bubble pre code { background: none; padding: 0; }
.msg-bubble ul,.msg-bubble ol { padding-left: 20px; margin: 4px 0; }
.msg-bubble li { margin: 2px 0; }
.msg-bubble a { color: var(--accent-mid); text-decoration: none; }
.msg-bubble a:hover { text-decoration: underline; }
.msg-bubble blockquote { border-left: 3px solid var(--accent-start); padding-left: 12px; color: var(--text-secondary); margin: 8px 0; }
.msg-bubble strong { color: var(--text-primary); font-weight: 600; }
.msg-bubble table { border-collapse: collapse; width: 100%; margin: 8px 0; font-size: 0.82em; }
.msg-bubble th,.msg-bubble td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.msg-bubble th { background: var(--bg-hover); }
.msg-bubble hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }

.msg-actions {
  display: flex; gap: 4px; opacity: 0;
  transition: opacity var(--t-fast);
}
.msg-row:hover .msg-actions { opacity: 1; }
.msg-action-btn {
  padding: 4px 6px; border-radius: 5px; border: 1px solid var(--border); background: var(--bg-elevated); cursor: pointer; color: var(--text-muted); font-size: 0.72rem; display: flex; align-items: center; gap: 4px;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.msg-action-btn:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-strong); }
.msg-row.user .msg-actions { justify-content: flex-end; }

/* Typing indicator */
.typing-indicator {
  display: flex; gap: 5px; padding: 12px 16px; align-items: center;
  background: var(--ai-bg); border: 1px solid var(--border);
  border-radius: var(--radius-lg); border-bottom-left-radius: 4px;
  width: fit-content; animation: fadeSlideIn 0.3s ease;
}
.typing-dot { width: 7px; height: 7px; background: var(--text-muted); border-radius: 50%; animation: typingBounce 1.2s ease-in-out infinite; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

/* ── 12. Voice Wave ───────────────────────────────── */
.voice-wave {
  display: flex; align-items: center; gap: 8px; justify-content: center;
  padding: 12px 20px; background: var(--bg-elevated); border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.wave-bar {
  width: 3px; background: linear-gradient(var(--accent-start), var(--accent-end));
  border-radius: 99px; animation: waveAnim 0.8s ease-in-out infinite alternate;
  height: 16px;
}
.wave-bar:nth-child(1) { animation-delay: 0s; height: 8px; }
.wave-bar:nth-child(2) { animation-delay: 0.1s; height: 14px; }
.wave-bar:nth-child(3) { animation-delay: 0.2s; height: 20px; }
.wave-bar:nth-child(4) { animation-delay: 0.15s; height: 24px; }
.wave-bar:nth-child(5) { animation-delay: 0.25s; height: 20px; }
.wave-bar:nth-child(6) { animation-delay: 0.1s; height: 14px; }
.wave-bar:nth-child(7) { animation-delay: 0.05s; height: 8px; }
.voice-wave span { font-size: 0.78rem; color: var(--text-secondary); margin-left: 4px; }

/* ── 13. Input Area ───────────────────────────────── */
.input-area { padding: 12px 16px 10px; background: var(--bg-surface); border-top: 1px solid var(--border); flex-shrink: 0; }

.image-preview-strip {
  display: flex; gap: 8px; padding-bottom: 10px; overflow-x: auto; flex-wrap: nowrap;
}
.preview-thumb {
  position: relative; flex-shrink: 0;
  width: 72px; height: 72px; border-radius: 10px; overflow: hidden;
  border: 1px solid var(--border-strong);
}
.preview-thumb img { width: 100%; height: 100%; object-fit: cover; }
.preview-thumb-remove {
  position: absolute; top: 3px; right: 3px; width: 18px; height: 18px;
  background: rgba(0,0,0,0.7); border: none; border-radius: 99px; cursor: pointer;
  color: #fff; font-size: 11px; display: flex; align-items: center; justify-content: center;
  transition: background var(--t-fast);
}
.preview-thumb-remove:hover { background: var(--danger); }

.input-box {
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--bg-elevated); border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg); padding: 6px 8px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.input-box:focus-within { border-color: rgba(255,107,53,0.4); box-shadow: 0 0 0 3px var(--accent-glow); }

.input-icon-btn {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 8px; border: none; cursor: pointer;
  background: transparent; color: var(--text-muted);
  transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast);
  flex-shrink: 0;
}
.input-icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); transform: scale(1.05); }
.input-icon-btn:active { transform: scale(0.95); }
.input-icon-btn.recording { color: var(--danger); animation: pulseDot 1s ease-in-out infinite; }

.chat-textarea {
  flex: 1; background: transparent; border: none; resize: none; outline: none;
  color: var(--text-primary); font-size: 0.9rem; line-height: 1.5; padding: 6px 4px;
  min-height: 36px; max-height: 180px; overflow-y: auto;
}
.chat-textarea::placeholder { color: var(--text-muted); }

.send-btn {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 8px; border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
  color: #000; flex-shrink: 0;
  transition: filter var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
}
.send-btn:hover { filter: brightness(1.1); transform: scale(1.08); box-shadow: 0 4px 14px rgba(255,107,53,0.4); }
.send-btn:active { transform: scale(0.95); }
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

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

/* ── 14. Tool Panels ──────────────────────────────── */
.tool-panel { flex: 1; overflow-y: auto; padding: 24px 24px 32px; max-width: 800px; width: 100%; margin: 0 auto; }

.tool-header { margin-bottom: 28px; }
.tool-header h2 { font-size: 1.5rem; margin-bottom: 6px; }
.tool-header p { color: var(--text-secondary); font-size: 0.875rem; }

/* Image Gen Form */
.image-gen-form { display: flex; flex-direction: column; gap: 14px; margin-bottom: 32px; }

.gen-input-wrap { position: relative; }
.gen-textarea {
  width: 100%; background: var(--bg-elevated); border: 1px solid var(--border-strong); border-radius: var(--radius); color: var(--text-primary); padding: 14px 16px; font-size: 0.9rem; resize: vertical; line-height: 1.5; outline: none; transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.gen-textarea:focus { border-color: rgba(255,107,53,0.4); box-shadow: 0 0 0 3px var(--accent-glow); }
.gen-textarea::placeholder { color: var(--text-muted); }

.gen-options { display: flex; gap: 14px; flex-wrap: wrap; }

.gen-option-group { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 140px; }
.gen-option-group label { font-size: 0.78rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-muted); }

.gen-select {
  background: var(--bg-elevated); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); color: var(--text-primary); padding: 9px 12px; font-size: 0.875rem; outline: none; cursor: pointer; transition: border-color var(--t-fast);
}
.gen-select:focus { border-color: rgba(255,107,53,0.4); }

.gen-btn { align-self: flex-start; padding: 11px 24px; }

/* Image results */
.image-gen-results { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }

.image-card {
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden;
  animation: fadeSlideIn 0.4s ease;
  transition: transform var(--t-fast), box-shadow var(--t-fast);
}
.image-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }

.image-card img { width: 100%; display: block; cursor: zoom-in; }

.image-card-actions { display: flex; gap: 8px; padding: 10px 12px; }
.image-card-actions button { flex: 1; padding: 8px; font-size: 0.8rem; }

/* Vision */
.vision-drop-zone {
  border: 2px dashed var(--border-strong); border-radius: var(--radius-lg); padding: 48px 24px;
  text-align: center; cursor: pointer; background: var(--bg-elevated); margin-bottom: 24px;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.vision-drop-zone:hover, .vision-drop-zone.dragover { border-color: var(--accent-start); background: rgba(255,107,53,0.04); }
.vision-drop-zone svg { color: var(--text-muted); margin-bottom: 14px; display: block; margin-inline: auto; }
.vision-drop-zone p { color: var(--text-secondary); font-size: 0.9rem; }
.vision-drop-zone p + p { margin-top: 4px; }
.drop-hint { font-size: 0.78rem; color: var(--text-muted) !important; margin-top: 8px !important; }
.link-text { color: var(--accent-start); }

.vision-preview-area { display: flex; flex-direction: column; gap: 16px; margin-bottom: 24px; animation: fadeIn 0.3s ease; }
.vision-preview-img { width: 100%; max-height: 360px; object-fit: contain; border-radius: var(--radius-lg); border: 1px solid var(--border); background: var(--bg-base); }
.vision-controls { display: flex; flex-direction: column; gap: 12px; }
.vision-btn-row { display: flex; gap: 10px; justify-content: flex-end; }

.vision-result {
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px 24px; font-size: 0.9rem; line-height: 1.7; color: var(--text-primary); animation: fadeSlideIn 0.4s ease;
}
.vision-result h3 { font-size: 0.82rem; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--accent-start); margin-bottom: 12px; }
.vision-result pre { background: var(--bg-base); border-radius: var(--radius-sm); padding: 12px; overflow-x: auto; font-size: 0.82em; }
.vision-result code { background: var(--bg-base); padding: 2px 5px; border-radius: 4px; font-size: 0.82em; }

/* ── 15. Context Menu ─────────────────────────────── */
.ctx-menu {
  position: fixed; z-index: 9998; background: var(--bg-elevated); border: 1px solid var(--border-strong);
  border-radius: var(--radius); padding: 6px; box-shadow: var(--shadow-lg); min-width: 160px;
  animation: fadeIn 0.12s ease;
}
.ctx-menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 12px; background: transparent; border: none; cursor: pointer; color: var(--text-secondary); font-size: 0.84rem; border-radius: 6px; transition: background var(--t-fast), color var(--t-fast); }
.ctx-menu button:hover { background: var(--bg-hover); color: var(--text-primary); }
.ctx-danger { color: var(--danger) !important; }
.ctx-danger:hover { background: rgba(255,77,109,0.1) !important; color: var(--danger) !important; }

/* ── 16. Toast ────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 99999;
  background: var(--bg-elevated); border: 1px solid var(--border-strong);
  padding: 12px 20px; border-radius: var(--radius); font-size: 0.875rem;
  box-shadow: var(--shadow-lg); color: var(--text-primary);
  animation: toastIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.toast.toast-error { border-color: rgba(255,77,109,0.4); background: rgba(255,77,109,0.1); color: var(--danger); }
.toast.toast-success { border-color: rgba(45,212,191,0.4); background: rgba(45,212,191,0.08); color: var(--success); }

/* ── 17. Loading Overlay ──────────────────────────── */
.loading-overlay { position: fixed; inset: 0; z-index: 999; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; }
.loading-spinner { width: 44px; height: 44px; border: 3px solid var(--border); border-top-color: var(--accent-start); border-radius: 50%; animation: spin 0.7s linear infinite; }

/* Skeleton */
.skeleton { background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-hover) 50%, var(--bg-elevated) 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: var(--radius-sm); }

/* Image fullscreen viewer */
.fullscreen-overlay { position: fixed; inset: 0; z-index: 9997; background: rgba(0,0,0,0.93); display: flex; align-items: center; justify-content: center; padding: 16px; animation: fadeIn 0.2s ease; cursor: zoom-out; }
.fullscreen-overlay img { max-width: 100%; max-height: 100%; border-radius: var(--radius); object-fit: contain; }

/* ── 18. Animations ───────────────────────────────── */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeSlideIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes typingBounce { 0%,80%,100% { transform: translateY(0); opacity: 0.4; } 40% { transform: translateY(-6px); opacity: 1; } }
@keyframes waveAnim { from { transform: scaleY(0.4); } to { transform: scaleY(1); } }
@keyframes floatBob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes pulseDot { 0%,100% { transform: scale(1); box-shadow: none; } 50% { transform: scale(1.05); box-shadow: 0 0 0 3px rgba(255,77,109,0.2); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px) scale(0.96); } to { opacity: 1; transform: translateX(0) scale(1); } }

/* ── 19. Responsive ───────────────────────────────── */
@media (max-width: 640px) {
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 50;
    transform: translateX(0); box-shadow: var(--shadow-lg);
  }
  .sidebar.collapsed { transform: translateX(-100%); width: var(--sidebar-width); min-width: var(--sidebar-width); opacity: 1; pointer-events: none; }
  .sidebar-open-btn { display: flex !important; }
  .tool-panel { padding: 16px 16px 24px; }
  .gen-options { flex-direction: column; }
  .input-area { padding: 8px 10px 8px; }
  .chat-messages { padding: 12px; }
  .msg-bubble { font-size: 0.84rem; }
}

@media (max-width: 480px) {
  .welcome-title { font-size: 1.4rem; }
  .tab-btn span { display: none; }
  .tab-btn { padding: 8px 12px; }
}
