/* ==========================================================================
   EntchenChat - Modern ChatGPT-like Design System
   ========================================================================== */

:root {
  --bg-primary: #171717;
  --bg-secondary: #212121;
  --bg-tertiary: #2f2f2f;
  --bg-sidebar: #171717;
  --bg-card: #212121;
  --bg-input: #2f2f2f;
  --bg-hover: #383838;
  --bg-active: #444444;
  --bg-user-bubble: #2f2f2f;
  
  --text-main: #ececec;
  --text-muted: #b4b4b4;
  --text-dim: #737373;
  
  --border-color: rgba(255, 255, 255, 0.1);
  --border-focus: rgba(255, 255, 255, 0.25);
  
  --primary: #10a37f;
  --primary-hover: #1a7f64;
  --primary-light: rgba(16, 163, 127, 0.15);
  --primary-text: #ffffff;
  
  --accent-duck: #f59e0b;
  --accent-duck-light: rgba(245, 158, 11, 0.15);
  
  --purple: #818cf8;
  --purple-light: rgba(129, 140, 248, 0.15);
  --pink: #ec4899;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.25);
  
  --sidebar-width: 260px;
  --header-height: 56px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Fira Code", "Cascadia Code", Consolas, Monaco, "Courier New", monospace;
}

[data-theme="light"] {
  --bg-primary: #ffffff;
  --bg-secondary: #f9f9f9;
  --bg-tertiary: #f0f0f0;
  --bg-sidebar: #f7f7f8;
  --bg-card: #ffffff;
  --bg-input: #f4f4f4;
  --bg-hover: #ececec;
  --bg-active: #e3e3e3;
  --bg-user-bubble: #f4f4f4;
  
  --text-main: #0d0d0d;
  --text-muted: #5d5d5d;
  --text-dim: #8f8f8f;
  
  --border-color: rgba(0, 0, 0, 0.08);
  --border-focus: rgba(0, 0, 0, 0.2);
  
  --primary: #10a37f;
  --primary-hover: #0e8e6e;
  --primary-light: rgba(16, 163, 127, 0.1);
  --primary-text: #ffffff;
}

[data-theme="oled"] {
  --bg-primary: #000000;
  --bg-secondary: #0a0a0a;
  --bg-tertiary: #141414;
  --bg-sidebar: #050505;
  --bg-card: #0d0d0d;
  --bg-input: #121212;
  --border-color: rgba(255, 255, 255, 0.12);
}

[data-theme="cyber"] {
  --bg-primary: #0b0f19;
  --bg-secondary: #111827;
  --bg-tertiary: #1f2937;
  --bg-sidebar: #090d16;
  --bg-card: #131d31;
  --bg-input: #1e293b;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: rgba(99, 102, 241, 0.2);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-main);
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  display: flex;
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 999px;
}
[data-theme="light"] ::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* App Container */
#app-container {
  display: flex;
  width: 100%;
  height: 100%;
  position: relative;
}

/* ==========================================================================
   Sidebar Layout
   ========================================================================== */
#sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100%;
  flex-shrink: 0;
  transition: transform 0.25s ease, width 0.25s ease;
  z-index: 50;
}

#sidebar.collapsed {
  transform: translateX(-100%);
  position: absolute;
  height: 100%;
}

.sidebar-header {
  padding: 0.85rem 0.85rem 0.5rem 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text-main);
  text-decoration: none;
  cursor: pointer;
}

.brand-icon {
  font-size: 1.35rem;
}

.brand-badge {
  font-size: 0.65rem;
  background: var(--accent-duck-light);
  color: var(--accent-duck);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.4rem;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
  text-decoration: none;
}

.btn-icon:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}

.sidebar-actions {
  padding: 0 0.85rem 0.5rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.btn-new-chat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.65rem 0.85rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-new-chat:hover {
  background: var(--bg-hover);
  border-color: var(--border-focus);
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box input {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.75rem 0.45rem 2rem;
  color: var(--text-main);
  font-size: 0.82rem;
  outline: none;
  transition: border-color 0.15s ease;
}

.search-box input:focus {
  border-color: var(--primary);
}

.search-box .search-icon {
  position: absolute;
  left: 0.6rem;
  color: var(--text-dim);
  pointer-events: none;
}

/* Nav Menu in Sidebar */
.sidebar-nav {
  padding: 0.35rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  border-bottom: 1px solid var(--border-color);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.45rem 0.65rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}

.nav-item.active {
  background: var(--bg-hover);
  color: var(--text-main);
  font-weight: 600;
}

.nav-item .nav-icon {
  font-size: 1rem;
  display: flex;
  align-items: center;
}

/* Chat History List */
.sidebar-history {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.history-group-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.35rem 0.4rem;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.chat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.48rem 0.65rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.84rem;
  cursor: pointer;
  position: relative;
  transition: all 0.12s ease;
  user-select: none;
  text-decoration: none;
}

.chat-item:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}

.chat-item.active {
  background: var(--bg-hover);
  color: var(--text-main);
  font-weight: 500;
}

.chat-item-title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-right: 0.5rem;
}

.chat-item-actions {
  display: none;
  align-items: center;
  gap: 0.2rem;
}

.chat-item:hover .chat-item-actions,
.chat-item.active .chat-item-actions {
  display: flex;
}

.chat-item-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0.2rem;
  border-radius: 4px;
}

.chat-item-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.1);
}

/* Sidebar Footer / User Profile */
.sidebar-footer {
  padding: 0.75rem 0.85rem;
  border-top: 1px solid var(--border-color);
  background: var(--bg-sidebar);
}

.user-profile-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.45rem 0.6rem;
  border-radius: var(--radius-md);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

.user-profile-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-color);
}

.user-avatar-wrap {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
}

.user-info {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.user-name {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.2;
}

.user-sub {
  font-size: 0.72rem;
  color: var(--text-dim);
}

/* ==========================================================================
   Main Content Area
   ========================================================================== */
#main-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
  background-color: var(--bg-primary);
  overflow: hidden;
}

/* Top App Header */
.top-header {
  height: var(--header-height);
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-primary);
  z-index: 10;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

/* Model Selector */
.model-dropdown-wrap {
  position: relative;
}

.btn-model-selector {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.75rem;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-model-selector:hover {
  background: var(--bg-hover);
  border-color: var(--border-focus);
}

.model-badge {
  font-size: 0.7rem;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  background: var(--primary-light);
  color: var(--primary);
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  width: 280px;
  padding: 0.35rem;
  display: none;
  flex-direction: column;
  gap: 0.2rem;
  z-index: 100;
}

.dropdown-menu.open {
  display: flex;
}

.dropdown-item {
  display: flex;
  flex-direction: column;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-main);
  cursor: pointer;
  transition: background 0.12s ease;
  text-decoration: none;
  border: none;
  background: transparent;
  text-align: left;
}

.dropdown-item:hover {
  background: var(--bg-hover);
}

.dropdown-item.active {
  background: var(--primary-light);
}

.dropdown-item-title {
  font-weight: 600;
  font-size: 0.86rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dropdown-item-desc {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* ==========================================================================
   Chat View & Messages
   ========================================================================== */
.view-container {
  display: none;
  flex: 1;
  height: calc(100% - var(--header-height));
  position: relative;
  overflow: hidden;
}

.view-container.active {
  display: flex;
  flex-direction: column;
}

#view-chat {
  display: none;
  flex-direction: column;
  height: calc(100% - var(--header-height));
}

#view-chat.active {
  display: flex;
}

.chat-scroll-area {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 1rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.chat-content-width {
  width: 100%;
  max-width: 800px;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Empty State / Welcome Screen */
.welcome-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  margin: auto 0;
  padding: 2rem 1rem;
  max-width: 720px;
}

.welcome-logo {
  font-size: 3.5rem;
  margin-bottom: 0.75rem;
  animation: floatDuck 3s ease-in-out infinite;
}

@keyframes floatDuck {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.welcome-title {
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, #10b981 0%, #818cf8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.welcome-desc {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
  max-width: 540px;
}

.welcome-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.85rem;
  width: 100%;
}

.prompt-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.9rem 1rem;
  text-align: left;
  cursor: pointer;
  transition: all 0.18s ease;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.prompt-card:hover {
  background: var(--bg-hover);
  border-color: var(--border-focus);
  transform: translateY(-2px);
}

.prompt-card-icon {
  font-size: 1.25rem;
}

.prompt-card-title {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-main);
}

.prompt-card-sub {
  font-size: 0.76rem;
  color: var(--text-dim);
}

/* Chat Messages */
.message-row {
  display: flex;
  width: 100%;
  gap: 1rem;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.message-row.user {
  justify-content: flex-end;
}

.message-bubble {
  position: relative;
  max-width: 85%;
  line-height: 1.6;
}

.message-row.user .message-bubble {
  background: var(--bg-user-bubble);
  border-radius: var(--radius-lg);
  padding: 0.75rem 1.1rem;
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.message-row.assistant .message-bubble {
  width: 100%;
  max-width: 100%;
  color: var(--text-main);
}

.assistant-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #10a37f, #6366f1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.assistant-body {
  flex: 1;
  min-width: 0;
}

/* Extended Thinking Box */
.thinking-box {
  background: rgba(129, 140, 248, 0.08);
  border: 1px solid rgba(129, 140, 248, 0.25);
  border-radius: var(--radius-md);
  margin-bottom: 0.85rem;
  overflow: hidden;
  font-size: 0.84rem;
}

.thinking-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.85rem;
  cursor: pointer;
  color: var(--purple);
  font-weight: 600;
  user-select: none;
}

.thinking-header:hover {
  background: rgba(129, 140, 248, 0.12);
}

.thinking-content {
  padding: 0.65rem 0.85rem;
  color: var(--text-muted);
  border-top: 1px solid rgba(129, 140, 248, 0.15);
  white-space: pre-wrap;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  max-height: 260px;
  overflow-y: auto;
}

.thinking-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid var(--purple);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 0.4rem;
}

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

/* Message Markdown Output */
.markdown-body {
  font-size: 0.94rem;
  line-height: 1.68;
}

.markdown-body p {
  margin-bottom: 0.85rem;
}

.markdown-body p:last-child {
  margin-bottom: 0;
}

.markdown-body h1, .markdown-body h2, .markdown-body h3 {
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
  font-weight: 700;
  color: var(--text-main);
}

.markdown-body ul, .markdown-body ol {
  margin-left: 1.5rem;
  margin-bottom: 0.85rem;
}

.markdown-body li {
  margin-bottom: 0.25rem;
}

.markdown-body blockquote {
  border-left: 3px solid var(--primary);
  padding-left: 0.85rem;
  color: var(--text-muted);
  margin: 0.85rem 0;
  font-style: italic;
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.86rem;
}

.markdown-body th, .markdown-body td {
  border: 1px solid var(--border-color);
  padding: 0.5rem 0.75rem;
  text-align: left;
}

.markdown-body th {
  background: var(--bg-secondary);
  font-weight: 600;
}

.markdown-body code:not(pre code) {
  background: rgba(255, 255, 255, 0.1);
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.85em;
  color: #fca5a5;
}

[data-theme="light"] .markdown-body code:not(pre code) {
  background: rgba(0, 0, 0, 0.06);
  color: #dc2626;
}

/* Code Blocks with Header & Copy */
.code-block-wrapper {
  position: relative;
  margin: 1rem 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-color);
  background: #0d1117;
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 0.85rem;
  background: #161b22;
  color: var(--text-muted);
  font-size: 0.76rem;
  font-family: var(--font-mono);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.btn-copy-code {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.74rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
}

.btn-copy-code:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.code-block-wrapper pre {
  margin: 0;
  padding: 1rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.86rem;
  line-height: 1.45;
}

/* Message Actions Bar */
.message-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.btn-msg-action {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0.3rem 0.45rem;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  transition: all 0.12s ease;
}

.btn-msg-action:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}

/* Images inside Messages */
.message-images-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.msg-thumb {
  width: 140px;
  height: 140px;
  object-fit: cover;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: transform 0.15s ease;
}

.msg-thumb:hover {
  transform: scale(1.02);
}

/* ==========================================================================
   Chat Input Area
   ========================================================================== */
.chat-input-wrapper {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 1rem 1.25rem 1rem;
  flex-shrink: 0;
}

.input-container {
  width: 100%;
  max-width: 800px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  box-shadow: var(--shadow-md);
  transition: border-color 0.15s ease;
}

.input-container:focus-within {
  border-color: var(--border-focus);
}

/* Attachment Previews in Input */
.attachment-preview-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.5rem;
  font-size: 0.78rem;
  color: var(--text-main);
}

.attachment-chip img {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  object-fit: cover;
}

.btn-remove-attachment {
  background: transparent;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
}

.input-textarea-row {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  width: 100%;
}

#chat-input-field {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  line-height: 1.5;
  resize: none;
  max-height: 200px;
  min-height: 24px;
}

#chat-input-field::placeholder {
  color: var(--text-dim);
}

.input-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding-top: 0.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.toolbar-left, .toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.btn-input-tool {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.35rem 0.55rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: all 0.15s ease;
}

.btn-input-tool:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}

.btn-input-tool.active {
  background: var(--purple-light);
  color: var(--purple);
  font-weight: 600;
}

.btn-send {
  background: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-send:hover:not(:disabled) {
  background: var(--primary-hover);
  transform: scale(1.05);
}

.btn-send:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.btn-stop {
  background: var(--danger);
  color: #ffffff;
  border: none;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.input-disclaimer {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 0.4rem;
  text-align: center;
}

/* ==========================================================================
   Image Studio View
   ========================================================================== */
#view-images {
  overflow-y: auto;
  padding: 1.5rem;
}

.studio-grid {
  max-width: 1000px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.card-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.form-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

.form-input, .form-textarea, .form-select {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.85rem;
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s ease;
}

.form-input:focus, .form-textarea:focus, .form-select:focus {
  border-color: var(--primary);
}

.aspect-ratio-selector {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.ar-pill {
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.12s ease;
}

.ar-pill:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}

.ar-pill.active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  padding: 0.65rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: all 0.15s ease;
  text-decoration: none;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.65rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: all 0.15s ease;
  text-decoration: none;
}

.btn-secondary:hover {
  background: var(--bg-hover);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-md);
  padding: 0.65rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

.btn-danger:hover {
  background: var(--danger);
  color: #ffffff;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.gallery-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.gallery-card img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.gallery-card img:hover {
  transform: scale(1.03);
}

.gallery-card-body {
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.gallery-card-prompt {
  font-size: 0.8rem;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gallery-card-meta {
  font-size: 0.72rem;
  color: var(--text-dim);
}

/* ==========================================================================
   Deep Research View
   ========================================================================== */
#view-research {
  overflow-y: auto;
  padding: 1.5rem;
}

.research-plan-card {
  background: var(--bg-secondary);
  border: 1px solid rgba(129, 140, 248, 0.3);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-top: 1rem;
}

.steps-list {
  margin: 1rem 0 1rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

/* ==========================================================================
   Gems View
   ========================================================================== */
#view-gems {
  overflow-y: auto;
  padding: 1.5rem;
}

.gems-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.gem-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  transition: all 0.15s ease;
}

.gem-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.gem-card-icon {
  font-size: 2rem;
}

.gem-card-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
}

.gem-card-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  flex: 1;
}

/* ==========================================================================
   Settings View
   ========================================================================== */
#view-settings {
  overflow-y: auto;
  padding: 1.5rem;
}

/* ==========================================================================
   Modals & Lightbox
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal-overlay.open {
  display: flex;
}

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  padding: 1.5rem;
  position: relative;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
}

/* Auth Modal Specifics */
.auth-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 1.25rem;
}

.auth-tab-btn {
  flex: 1;
  padding: 0.65rem;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
}

.auth-tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.auth-user-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 1rem;
  border-top: 1px solid var(--border-color);
  padding-top: 1rem;
}

.auth-user-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
}

.auth-user-chip:hover {
  background: var(--bg-hover);
}

/* Lightbox */
.lightbox-img {
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  border-radius: var(--radius-md);
}

/* Print Styles for Chat Export to PDF */
@media print {
  #sidebar, .top-header, .chat-input-wrapper, .message-actions, .btn-msg-action, .modal-overlay {
    display: none !important;
  }
  body, #app-container, #main-view, .chat-scroll-area {
    background: #ffffff !important;
    color: #000000 !important;
    height: auto !important;
    overflow: visible !important;
  }
  .message-row.user .message-bubble {
    background: #f0f0f0 !important;
    color: #000000 !important;
    border: 1px solid #ccc !important;
  }
  .markdown-body {
    color: #000000 !important;
  }
}

/* Responsive Rules */
@media (max-width: 768px) {
  #sidebar {
    position: absolute;
    height: 100%;
    left: 0;
    transform: translateX(-100%);
  }
  #sidebar.open {
    transform: translateX(0);
  }
  .welcome-cards {
    grid-template-columns: 1fr;
  }
}
