:root {
  --bg: #ffffff;
  --bg-subtle: #f7f7f8;
  --bg-sidebar: #f4f5f7;
  --bg-hover: #eceef2;
  --bg-active: #e4e8f0;
  --bg-user-bubble: #eff3fa;
  --bg-composer: #f4f5f8;
  --surface: #ffffff;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #111827;
  --text-secondary: #4b5563;
  --text-muted: #6b7280;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.1);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.1);
  --success: #16a34a;
  --warning: #d97706;
  --warning-soft: rgba(217, 119, 6, 0.12);
  --code-bg: #1e2430;
  --code-text: #e5e7eb;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, 0.18);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --sidebar-w: 276px;
}

[data-theme="dark"] {
  --bg: #18191d;
  --bg-subtle: #212329;
  --bg-sidebar: #131417;
  --bg-hover: #24262e;
  --bg-active: #2b2f3a;
  --bg-user-bubble: #252b3b;
  --bg-composer: #23252c;
  --surface: #1e2026;
  --border: #2c2f38;
  --border-strong: #3b404d;
  --text: #f3f4f6;
  --text-secondary: #d1d5db;
  --text-muted: #9ca3af;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-soft: rgba(59, 130, 246, 0.16);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.15);
  --success: #22c55e;
  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.15);
  --code-bg: #101217;
  --code-text: #e5e7eb;
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.55);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: "Vazirmatn", -apple-system, BlinkMacSystemFont, "Segoe UI", Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

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

.hidden {
  display: none !important;
}

/* ---- Buttons & Inputs ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

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

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-hover);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--bg-active);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--bg-hover);
}

.btn-danger-soft {
  background: var(--danger-soft);
  color: var(--danger);
}
.btn-danger-soft:hover:not(:disabled) {
  background: var(--danger);
  color: #fff;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 8px;
}

.btn-full {
  width: 100%;
  padding: 11px 16px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.icon-btn svg {
  width: 18px;
  height: 18px;
}
.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.icon-btn.danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.form-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-error {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 12px;
}

.form-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ---- Login View ---- */
.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at top right, var(--accent-soft), transparent 45%), var(--bg-subtle);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px 28px;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  text-align: center;
  margin-bottom: 24px;
}

.brand-badge {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, #2563eb, #6366f1);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.brand-badge svg {
  width: 18px;
  height: 18px;
}
.brand-badge.lg {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  margin-bottom: 10px;
}
.brand-badge.lg svg {
  width: 28px;
  height: 28px;
}

.login-logo h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
}

.login-subtitle {
  margin: 6px 0 0;
  font-size: 13.5px;
  color: var(--text-muted);
}

.login-footer {
  margin-top: 16px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}

.login-notice-box {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  font-size: 12.2px;
  line-height: 1.7;
  color: var(--text-secondary);
}

/* ---- Audit Log ---- */
.audit-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.audit-toolbar select {
  padding: 8px 10px;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  background: var(--bg);
  font-size: 13px;
  min-width: 150px;
}
.audit-toolbar input {
  flex: 1;
  min-width: 180px;
  padding: 8px 12px;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  background: var(--bg);
  font-size: 13px;
}
.audit-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.audit-detail-meta {
  font-size: 13px;
  color: var(--text-secondary);
}
.audit-detail-messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.audit-msg-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--bg-subtle);
}
.audit-msg-card.user {
  background: var(--bg-user-bubble);
}
.audit-msg-head {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

/* ---- App Shell ---- */
.app-shell {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 12px;
  gap: 10px;
  z-index: 30;
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 4px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-title {
  font-weight: 700;
  font-size: 16px;
}

.btn-new-chat {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.15s ease;
}
.btn-new-chat svg {
  width: 18px;
  height: 18px;
  color: var(--accent);
}
.btn-new-chat:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
}

.sidebar-search {
  position: relative;
  display: flex;
  align-items: center;
}
.sidebar-search svg {
  position: absolute;
  right: 10px;
  width: 15px;
  height: 15px;
  color: var(--text-muted);
  pointer-events: none;
}
.sidebar-search input {
  width: 100%;
  padding: 8px 32px 8px 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--bg-hover);
  font-size: 13px;
  outline: none;
}
.sidebar-search input:focus {
  border-color: var(--border-strong);
  background: var(--surface);
}

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

.chat-group-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 10px 8px 4px;
}

.chat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 9px 10px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--text-secondary);
  transition: background 0.12s ease;
}
.chat-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.chat-item.active {
  background: var(--bg-active);
  color: var(--text);
  font-weight: 500;
}

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

.chat-item-actions {
  display: none;
  align-items: center;
  gap: 2px;
}
.chat-item:hover .chat-item-actions,
.chat-item.active .chat-item-actions {
  display: flex;
}

.chat-item-btn {
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.chat-item-btn svg {
  width: 14px;
  height: 14px;
}
.chat-item-btn:hover {
  background: var(--surface);
  color: var(--text);
}
.chat-item-btn.del:hover {
  color: var(--danger);
}

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

.budget-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
}
.budget-row {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.progress-track {
  height: 5px;
  border-radius: 99px;
  background: var(--bg-hover);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--accent);
  transition: width 0.3s ease;
}
.progress-fill.warn {
  background: var(--warning);
}
.progress-fill.danger {
  background: var(--danger);
}

.user-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 4px;
}
.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.user-meta {
  min-width: 0;
}
.user-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role {
  font-size: 11px;
  color: var(--text-muted);
}
.user-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

/* ---- Main Area ---- */
.main-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}

.topbar {
  height: 58px;
  flex-shrink: 0;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.topbar-right, .topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.model-picker {
  position: relative;
}

.model-picker-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.model-picker-btn:hover {
  background: var(--bg-hover);
}
.model-picker-btn svg {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

.model-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 300px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 40;
}

.model-option {
  width: 100%;
  text-align: right;
  padding: 10px 12px;
  border: none;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.model-option:hover {
  background: var(--bg-hover);
}
.model-option.active {
  background: var(--accent-soft);
}
.model-option-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13.5px;
  font-weight: 600;
}
.model-option-id {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
}
.model-option-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

.warning-pill {
  border: 1px solid var(--warning);
  background: var(--warning-soft);
  color: var(--warning);
  border-radius: 99px;
  padding: 5px 12px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
}

/* ---- Messages Viewport ---- */
.messages-viewport {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px 24px;
}

.welcome-screen {
  max-width: 720px;
  margin: 6vh auto 0;
  text-align: center;
  padding: 0 10px;
}

.welcome-icon {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  background: linear-gradient(135deg, #2563eb, #6366f1);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  box-shadow: 0 10px 25px rgba(37, 99, 235, 0.25);
}
.welcome-icon svg {
  width: 28px;
  height: 28px;
}

.welcome-screen h2 {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 700;
}

.welcome-sub {
  margin: 0 0 28px;
  color: var(--text-muted);
  font-size: 14.5px;
}

.prompt-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  text-align: right;
}

.prompt-card {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 15px 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: right;
}
.prompt-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.prompt-emoji {
  font-size: 20px;
}
.prompt-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.prompt-desc {
  font-size: 12.5px;
  color: var(--text-muted);
}

/* ---- Message Bubbles ---- */
.messages-list {
  max-width: 780px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.msg-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.msg-row.user {
  justify-content: flex-start;
  flex-direction: row-reverse;
}

.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  margin-top: 2px;
}

.msg-row.model .msg-avatar {
  background: linear-gradient(135deg, #2563eb, #6366f1);
  color: #fff;
}
.msg-row.model .msg-avatar svg {
  width: 16px;
  height: 16px;
}

.msg-content-wrap {
  max-width: 85%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.msg-row.model .msg-content-wrap {
  max-width: calc(100% - 44px);
  flex: 1;
}

.msg-bubble {
  border-radius: 18px;
  line-height: 1.85;
  font-size: 14.8px;
  word-wrap: break-word;
}

.msg-row.user .msg-bubble {
  background: var(--bg-user-bubble);
  padding: 12px 16px;
  border-top-left-radius: 18px;
  border-top-right-radius: 6px;
  white-space: pre-wrap;
}

.msg-row.model .msg-bubble {
  padding: 2px 4px;
}

.msg-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 6px;
}

.att-image {
  max-width: 240px;
  max-height: 220px;
  border-radius: 12px;
  border: 1px solid var(--border);
  cursor: zoom-in;
  object-fit: cover;
}

.att-audio-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 10px;
  min-width: 250px;
}
.att-audio-card audio {
  height: 34px;
  width: 100%;
}
.att-audio-label {
  font-size: 11.5px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
}

.att-file-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-secondary);
}

.msg-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.source-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
}
.source-chip:hover {
  background: var(--accent-soft);
}

.msg-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
  opacity: 0.75;
}
.msg-row:hover .msg-actions {
  opacity: 1;
}
.msg-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 7px;
  cursor: pointer;
}
.msg-action-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.msg-action-btn svg {
  width: 14px;
  height: 14px;
}

/* Markdown Styling inside Assistant Bubble */
.md-body p {
  margin: 0 0 10px;
}
.md-body p:last-child {
  margin-bottom: 0;
}
.md-body h1, .md-body h2, .md-body h3, .md-body h4 {
  margin: 16px 0 8px;
  line-height: 1.45;
  font-weight: 700;
}
.md-body h1 { font-size: 19px; }
.md-body h2 { font-size: 17px; }
.md-body h3 { font-size: 15.5px; }
.md-body ul, .md-body ol {
  margin: 6px 0 12px;
  padding-right: 22px;
  padding-left: 0;
}
.md-body li {
  margin-bottom: 4px;
}
.md-body blockquote {
  margin: 10px 0;
  padding: 8px 14px;
  border-right: 3px solid var(--accent);
  background: var(--bg-subtle);
  border-radius: 6px;
  color: var(--text-secondary);
}
.md-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--bg-hover);
  direction: ltr;
  unicode-bidi: embed;
}
.md-body .code-block {
  margin: 12px 0;
  border-radius: 12px;
  overflow: hidden;
  background: var(--code-bg);
  color: var(--code-text);
  direction: ltr;
  text-align: left;
}
.md-body .code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 12px;
  color: #9ca3af;
}
.md-body .code-copy-btn {
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: #e5e7eb;
  border-radius: 6px;
  padding: 3px 9px;
  font-size: 11.5px;
  cursor: pointer;
}
.md-body .code-copy-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}
.md-body .code-block pre {
  margin: 0;
  padding: 12px 14px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.6;
}
.md-body .code-block pre code {
  background: transparent;
  padding: 0;
  color: inherit;
}
.md-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 13.5px;
}
.md-body th, .md-body td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: right;
}
.md-body th {
  background: var(--bg-subtle);
  font-weight: 600;
}
.md-body a {
  color: var(--accent);
}
.md-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 14px 0;
}

.typing-dots {
  display: inline-flex;
  gap: 5px;
  padding: 10px 4px;
}
.typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: pulseDot 1.2s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes pulseDot {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1.1); }
}

/* ---- Composer ---- */
.composer-wrap {
  padding: 8px 16px 14px;
  background: var(--bg);
}

.composer-inner {
  max-width: 780px;
  margin: 0 auto;
}

.pending-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.pending-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border-radius: 10px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  font-size: 12.5px;
}
.pending-chip button {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 0 2px;
}
.pending-chip button:hover {
  color: var(--danger);
}

.composer-box {
  background: var(--bg-composer);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 10px 14px 8px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.composer-box:focus-within {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.composer-box textarea {
  width: 100%;
  border: none;
  background: transparent;
  resize: none;
  outline: none;
  font-size: 14.8px;
  line-height: 1.65;
  max-height: 180px;
  padding: 2px 2px 6px;
}

.composer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.composer-tools-right, .composer-tools-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 99px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.tool-btn svg {
  width: 16px;
  height: 16px;
}
.tool-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.tool-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(37, 99, 235, 0.25);
}

.mic-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}
.mic-btn svg {
  width: 19px;
  height: 19px;
}
.mic-btn:hover {
  background: var(--bg-hover);
  color: var(--accent);
}

.send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}
.send-btn svg {
  width: 18px;
  height: 18px;
}
.send-btn:hover:not(:disabled) {
  background: var(--accent-hover);
}
.send-btn.streaming {
  background: var(--danger);
}

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

/* ---- Voice Bar ---- */
.voice-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg-composer);
  border: 1.5px solid var(--danger);
  border-radius: 20px;
  padding: 12px 16px;
  flex-wrap: wrap;
}
.voice-bar-status {
  display: flex;
  align-items: center;
  gap: 10px;
}
.rec-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--danger);
  animation: recBlink 1s infinite;
}
@keyframes recBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}
.voice-timer {
  font-weight: 600;
  font-size: 14px;
  min-width: 44px;
}
.voice-waves {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 22px;
}
.voice-waves span {
  width: 3px;
  height: 6px;
  border-radius: 99px;
  background: var(--danger);
  transition: height 0.1s ease;
}
.voice-bar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---- Drop Overlay ---- */
.drop-overlay {
  position: absolute;
  inset: 10px;
  z-index: 50;
  border: 2px dashed var(--accent);
  border-radius: 20px;
  background: rgba(37, 99, 235, 0.08);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.drop-overlay-box {
  background: var(--surface);
  padding: 24px 36px;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  color: var(--accent);
  font-weight: 600;
}
.drop-overlay-box svg {
  width: 36px;
  height: 36px;
  margin-bottom: 8px;
}

/* ---- Modals ---- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(3px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-sm { max-width: 440px; }
.modal-lg { max-width: 820px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 {
  margin: 0;
  font-size: 16.5px;
}

.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 10px 20px 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
}
.tab-btn {
  border: none;
  background: transparent;
  padding: 9px 14px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
}
.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.tab-pane { display: none; }
.tab-pane.active { display: block; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
}
.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.stat-value {
  font-size: 20px;
  font-weight: 700;
}
.stat-value.sm {
  font-size: 14px;
}

.section-heading {
  margin: 0 0 10px;
  font-size: 14.5px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th, .data-table td {
  padding: 10px 12px;
  text-align: right;
  border-bottom: 1px solid var(--border);
}
.data-table th {
  background: var(--bg-subtle);
  font-weight: 600;
  color: var(--text-secondary);
}
.data-table tr:last-child td {
  border-bottom: none;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 500;
}
.badge-green { background: rgba(22, 163, 74, 0.14); color: var(--success); }
.badge-red { background: var(--danger-soft); color: var(--danger); }
.badge-blue { background: var(--accent-soft); color: var(--accent); }
.badge-gray { background: var(--bg-hover); color: var(--text-secondary); }

.inline-form-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 16px;
}
.inline-form-card h4 {
  margin: 0 0 12px;
  font-size: 14px;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.form-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.form-group-end {
  justify-content: flex-end;
}
.input-with-btn {
  display: flex;
  gap: 8px;
}
.input-with-btn input {
  flex: 1;
}
.checkbox-row {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}
.checkbox-row input {
  width: auto;
}

.models-chip-box {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 120px;
  overflow-y: auto;
  padding: 8px;
  border-radius: 10px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
}
.model-chip {
  padding: 4px 9px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 12px;
  direction: ltr;
  cursor: pointer;
}
.model-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---- Lightbox & Toasts ---- */
.lightbox-wrap img {
  max-width: 92vw;
  max-height: 88vh;
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
}

.toast-container {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-right: 4px solid var(--accent);
  border-radius: 12px;
  padding: 11px 16px;
  font-size: 13.5px;
  box-shadow: var(--shadow-lg);
  max-width: 340px;
  animation: toastIn 0.2s ease;
}
.toast.error { border-right-color: var(--danger); }
.toast.success { border-right-color: var(--success); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- Responsive ---- */
.mobile-only { display: none; }
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 25;
}

@media (max-width: 820px) {
  .mobile-only { display: inline-flex; }
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    right: 0;
    transform: translateX(100%);
    transition: transform 0.22s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .prompt-grid {
    grid-template-columns: 1fr;
  }
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .form-grid, .form-grid-3 {
    grid-template-columns: 1fr;
  }
  .tool-label {
    display: none;
  }
}
