﻿:root {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, 'Helvetica Neue',
    Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background-color: #0f172a;
  background-image: radial-gradient(circle at top left, rgba(99, 102, 241, 0.15), transparent 65%),
    var(--bg-gradient);
  background-size: cover;
  background-attachment: fixed;
  color: var(--text-color);
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, 'Helvetica Neue',
    Arial, sans-serif;
  font-weight: 400;
  line-height: 1.5;
  transition: background-color 0.3s ease, color 0.3s ease;
  color-scheme: dark;
  --bg-body: #0f172a;
  --bg-gradient: radial-gradient(circle at 60% -20%, rgba(99, 102, 241, 0.12), transparent 70%);
  --card-bg: rgba(18, 22, 38, 0.92);
  --header-bg: linear-gradient(135deg, #6366f1, #22d3ee);
  --header-text: #f8fafc;
  --text-color: #e7ecff;
  --chat-bg: rgba(10, 14, 29, 0.88);
  --user-bubble-bg: linear-gradient(135deg, #7c6cff, #4f46e5);
  --user-bubble-text: #f8f9ff;
  --bot-bubble-bg: rgba(22, 30, 48, 0.92);
  --bot-bubble-border: rgba(88, 106, 197, 0.35);
  --bot-bubble-text: #e9eeff;
  --input-bg: rgba(14, 18, 34, 0.95);
  --input-border: rgba(100, 116, 204, 0.35);
  --input-focus-border: #60a5fa;
  --input-focus-shadow: rgba(96, 165, 250, 0.35);
  --button-bg: linear-gradient(135deg, #38bdf8, #6366f1);
  --button-text: #041126;
  --button-hover-shadow: rgba(56, 189, 248, 0.35);
  --toggle-bg: rgba(35, 45, 78, 0.55);
  --toggle-border: rgba(99, 102, 241, 0.45);
  --toggle-text: #e7ecff;
  --select-bg: rgba(14, 18, 34, 0.95);
  --select-border: rgba(102, 114, 199, 0.35);
  --select-text: #f0f4ff;
  --select-muted: rgba(203, 213, 225, 0.7);
  --select-focus-border: #60a5fa;
  --select-focus-shadow: rgba(96, 165, 250, 0.3);
  --file-button-bg: rgba(18, 24, 44, 0.9);
  --file-button-border: rgba(99, 102, 241, 0.35);
  --file-button-text: #e7ecff;
  --file-button-hover: rgba(99, 102, 241, 0.18);
  --attachment-bg: rgba(18, 24, 44, 0.85);
  --attachment-border: rgba(99, 102, 241, 0.35);
  --attachment-text: #eef2ff;
  --form-label-color: #f6f7ff;
  --form-muted-color: rgba(231, 236, 255, 0.86);
}

body[data-theme='light'] {
  color-scheme: light;
  --bg-body: #f4f6fb;
  --bg-gradient: radial-gradient(circle at top, #fefefe 0%, #e6ecff 100%);
  --card-bg: rgba(255, 255, 255, 0.9);
  --header-bg: linear-gradient(135deg, #274f9c, #6c8be8);
  --header-text: #ffffff;
  --text-color: #1a1a1a;
  --chat-bg: rgba(246, 248, 255, 0.85);
  --user-bubble-bg: linear-gradient(135deg, #4b6cd9, #1e3c92);
  --user-bubble-text: #ffffff;
  --bot-bubble-bg: #ffffff;
  --bot-bubble-border: #dde3f7;
  --bot-bubble-text: #1a1a1a;
  --input-bg: #ffffff;
  --input-border: #ccd6f6;
  --input-focus-border: #5a76da;
  --input-focus-shadow: rgba(90, 118, 218, 0.2);
  --button-bg: linear-gradient(135deg, #5a76da, #2c48a2);
  --button-text: #ffffff;
  --button-hover-shadow: rgba(44, 72, 162, 0.25);
  --toggle-bg: rgba(255, 255, 255, 0.18);
  --toggle-border: rgba(255, 255, 255, 0.35);
  --toggle-text: #ffffff;
  --select-bg: #ffffff;
  --select-border: #ccd6f6;
  --select-text: #1a1a1a;
  --select-muted: rgba(71, 85, 105, 0.7);
  --select-focus-border: #5a76da;
  --select-focus-shadow: rgba(90, 118, 218, 0.2);
  --file-button-bg: rgba(255, 255, 255, 0.9);
  --file-button-border: #ccd6f6;
  --file-button-text: #1e3c92;
  --file-button-hover: rgba(44, 72, 162, 0.12);
  --attachment-bg: rgba(255, 255, 255, 0.85);
  --attachment-border: #dbe1f4;
  --attachment-text: #212121;
  --form-label-color: #1f2937;
  --form-muted-color: rgba(30, 41, 59, 0.75);
}

.hidden {
  display: none !important;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: transparent;
  z-index: 1000;
}

.auth-panel {
  width: 100%;
  max-width: 480px;
  margin: auto;
  padding: 2rem 2rem 2.5rem;
  background-color: #1e253a;
  border: 1px solid #2a345a;
  border-radius: 1rem;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.auth-logo {
  margin: 0;
  font-size: 2rem;
  font-weight: 600;
  text-align: center;
  color: #ffffff;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.auth-form h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 500;
  text-align: center;
  color: #94a3b8;
}

.auth-error {
  min-height: 20px;
  margin: 0;
  text-align: center;
  color: #f87171;
  font-size: 0.95rem;
}

.auth-description {
  margin: 0 0 1rem 0;
  text-align: center;
  font-size: 1rem;
  font-weight: 500;
  color: #94a3b8;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.auth-field label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: #cbd5e1;
}

.auth-field input {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  border: 1px solid #334155;
  background-color: #0f172a;
  color: #f8fafc;
  font-size: 1rem;
  line-height: 1.5rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.auth-field input::placeholder {
  color: #64748b;
}

.auth-field input:focus {
  outline: none;
  border-color: #4f46e5;
  box-shadow: 0 0 8px rgba(79, 70, 229, 0.6);
}

.auth-form button[type='submit'] {
  width: 100%;
  padding: 0.9rem 1rem;
  border: none;
  border-radius: 0.5rem;
  background: linear-gradient(90deg, #3b4ddc 0%, #4f46e5 50%, #6366f1 100%);
  color: #ffffff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.auth-form button[type='submit']:hover,
.auth-form button[type='submit']:focus-visible {
  box-shadow: 0 12px 30px rgba(99, 102, 241, 0.5);
  transform: translateY(-1px);
  outline: none;
}

.auth-form button[type='submit']:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.chat-app {
  width: min(1100px, 100%);
  background-color: var(--card-bg);
  border-radius: 22px;
  box-shadow: 0 34px 64px rgba(15, 25, 65, 0.35), 0 0 0 1px rgba(99, 102, 241, 0.12);
  display: flex;
  min-height: 620px;
  height: 85vh;
  max-height: 900px;
  overflow: hidden;
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.chat-sidebar {
  width: min(280px, 35%);
  background: var(--chat-bg);
  border-right: 1px solid var(--bot-bubble-border);
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px;
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sidebar-header h2 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--text-color);
}

.sidebar-new {
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--select-border);
  background: var(--select-bg);
  color: var(--select-text);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, border 0.2s ease;
}

.sidebar-new:hover {
  border-color: var(--select-focus-border);
}

.conversation-list {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: max(240px, calc(85vh - 220px));
  overflow-y: auto;
  padding-right: 6px;
}

.conversation-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.conversation-item {
  flex: 1 1 auto;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-color);
  text-align: left;
  cursor: pointer;
  transition: background 0.2s ease, border 0.2s ease;
}

.conversation-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.conversation-item:focus-visible {
  outline: 3px solid var(--select-focus-border);
  outline-offset: 2px;
}

.conversation-item.active {
  border-color: var(--select-focus-border);
  background: rgba(255, 255, 255, 0.12);
}

.conversation-delete {
  flex: 0 0 auto;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--file-button-border);
  background: transparent;
  color: var(--form-muted-color);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, border 0.2s ease, color 0.2s ease, transform 0.15s ease;
}

.conversation-delete:hover {
  background: var(--file-button-hover);
  color: var(--file-button-text);
  transform: translateY(-1px);
}

.conversation-delete:focus-visible {
  outline: 3px solid var(--select-focus-border);
  outline-offset: 2px;
}

.conversation-empty {
  margin: 0;
  color: rgba(230, 233, 255, 0.7);
  font-size: 0.9rem;
}

.chat-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--card-bg);
}

.chat-header {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 24px;
  background: var(--header-bg);
  color: var(--header-text);
}

.header-left h1 {
  margin: 0;
  font-size: 1.7rem;
  line-height: 1.1;
}

.header-left p {
  margin: 4px 0 12px 0;
  opacity: 0.85;
}

.tool-switch {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.tool-switch-btn {
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(15, 23, 42, 0.4);
  color: #e2e8f0;
  border-radius: 999px;
  padding: 6px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.tool-switch-btn:hover:not(:disabled),
.tool-switch-btn:focus-visible {
  border-color: rgba(99, 102, 241, 0.65);
  color: #ffffff;
  outline: none;
}

.tool-switch-btn.active {
  background: rgba(99, 102, 241, 0.18);
  border-color: rgba(99, 102, 241, 0.85);
  color: #ffffff;
}

.tool-switch-btn.hidden {
  display: none;
}

.header-controls {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.header-floating-actions {
  position: absolute;
  top: 18px;
  right: 24px;
  display: flex;
  gap: 12px;
}

.topbar-btn,
.topbar-logout-btn {
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border-radius: 9999px;
  margin: 0;
}

.topbar-logout-btn {
  background: #0f172a;
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  transition: opacity 0.2s ease;
}

.topbar-logout-btn:hover {
  opacity: 0.9;
}

.web-search-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(99, 102, 241, 0.35);
  background: rgba(15, 23, 42, 0.4);
  color: #e2e8f0;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.web-search-toggle:hover {
  background: rgba(99, 102, 241, 0.18);
  border-color: rgba(99, 102, 241, 0.45);
}

.web-search-toggle input[type='checkbox'] {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: rgba(15, 23, 42, 0.75);
  accent-color: #6366f1;
  cursor: pointer;
}

.theme-toggle {
  height: 34px;
  padding: 0 14px;
  border-radius: 9999px;
  border: 1px solid var(--toggle-border);
  background: var(--toggle-bg);
  color: var(--toggle-text);
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: transform 0.15s ease, border 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.theme-toggle:hover {
  transform: translateY(-1px);
}


.chat-log {
  flex: 1;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  background: var(--chat-bg);
  transition: background 0.3s ease;
}

.message {
  max-width: 80%;
  padding: 14px 18px;
  border-radius: 14px;
  line-height: 1.5;
  position: relative;
  animation: fadeIn 0.25s ease-in;
  transition: background 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.message-meta {
  font-size: 0.75rem;
  opacity: 0.75;
  margin-bottom: 4px;
}

.message.user {
  align-self: flex-end;
  background: var(--user-bubble-bg);
  color: var(--user-bubble-text);
  border-bottom-right-radius: 4px;
}

.message.bot {
  align-self: flex-start;
  background: var(--bot-bubble-bg);
  border: 1px solid var(--bot-bubble-border);
  color: var(--bot-bubble-text);
  border-bottom-left-radius: 4px;
}

.message-text p {
  margin: 0 0 0.75rem 0;
}

.message-text p:last-child {
  margin-bottom: 0;
}

.message-text ul {
  margin: 0 0 0.75rem 0;
  padding-left: 1.25rem;
  list-style: disc;
}

.message-text ul:last-child {
  margin-bottom: 0;
}

.message-text li {
  margin-bottom: 0.35rem;
}

.message-text li:last-child {
  margin-bottom: 0;
}

.message-text a {
  color: #60a5fa;
  text-decoration: underline;
  cursor: pointer;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.message-text a:hover {
  text-decoration-thickness: 2px;
}

.message-text sup {
  font-size: 0.75em;
}

.message-text sup a {
  color: #60a5fa;
}

.assistant-image {
  margin: 0.75rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.assistant-image img {
  width: 100%;
  border-radius: 14px;
  border: 1px solid rgba(99, 102, 241, 0.35);
  box-shadow: 0 16px 35px rgba(8, 10, 25, 0.45);
  cursor: zoom-in;
}

.assistant-image figcaption {
  font-size: 0.85rem;
  color: var(--form-muted-color);
}

.message-attachments {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message-attachment {
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--attachment-border);
  background: var(--attachment-bg);
  color: var(--attachment-text);
  font-size: 0.9rem;
}

.message-attachment-name {
  font-weight: 600;
  margin-bottom: 4px;
}

.message-attachment-preview {
  font-size: 0.82rem;
  opacity: 0.8;
  white-space: pre-wrap;
}

.message-attachment-image {
  margin-top: 8px;
  width: 100%;
  max-height: 260px;
  border-radius: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #0b1120;
  object-fit: contain;
  cursor: pointer;
}

.attachment-list {
  padding: 0 24px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--chat-bg);
  max-height: 260px;
  overflow-y: auto;
}

.attachment-warning {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: #fcd34d;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.92rem;
  line-height: 1.35;
  margin-bottom: 10px;
}

body[data-theme='light'] .attachment-warning {
  background: rgba(249, 250, 251, 0.92);
  border-color: rgba(245, 158, 11, 0.35);
  color: #92400e;
}

.attachment {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 12px 46px 12px 12px;
  border-radius: 12px;
  border: 1px solid var(--attachment-border);
  background: var(--attachment-bg);
  color: var(--attachment-text);
  font-size: 0.9rem;
}

.attachment-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.attachment-preview {
  font-size: 0.82rem;
  opacity: 0.8;
  white-space: pre-wrap;
}

.attachment-image {
  width: 100%;
  max-height: 200px;
  border-radius: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #0b1120;
  object-fit: contain;
  cursor: pointer;
}

.image-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 11, 24, 0.88);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 2000;
}

.image-modal-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.image-modal-container {
  position: relative;
  max-width: min(90vw, 1100px);
  max-height: min(90vh, 720px);
  border-radius: 1rem;
  overflow: hidden;
  background: #0b1120;
  border: 1px solid rgba(148, 163, 184, 0.25);
  box-shadow: 0 40px 90px rgba(0, 0, 0, 0.85);
  display: flex;
}

.image-modal-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #0b1120;
}

.image-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.85);
  color: #e2e8f0;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease, transform 0.15s ease;
}

.image-modal-close:hover,
.image-modal-close:focus-visible {
  background: rgba(99, 102, 241, 0.85);
  transform: translateY(-1px);
  outline: none;
}

.attachment-remove {
  border: none;
  background: transparent;
  color: inherit;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  align-self: flex-end;
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease, transform 0.15s ease;
}

.attachment-remove:hover {
  background-color: rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
}

.chat-form {
  padding: 16px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background-color: var(--card-bg);
  border-top: 1px solid var(--bot-bubble-border);
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.chat-form.chat-form-disabled {
  opacity: 0.55;
  pointer-events: none;
}

.chat-form textarea {
  width: 100%;
  padding: 14px 16px;
  font-size: 1rem;
  border: 1px solid var(--input-border);
  border-radius: 12px;
  outline: none;
  background: var(--input-bg);
  color: var(--text-color);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.3s ease;
  min-height: 56px;
  resize: vertical;
  font-family: inherit;
  line-height: 1.4;
}

.chat-form textarea:focus {
  border-color: var(--input-focus-border);
  box-shadow: 0 0 0 3px var(--input-focus-shadow);
}

.model-mode-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
  margin-bottom: 2px;
}

.model-mode-info {
  margin: 0;
  font-size: 0.85rem;
  color: rgba(148, 163, 184, 0.95);
}

.model-mode-warning {
  margin: 0;
  font-size: 0.8rem;
  color: #fbbf24;
}

.model-mode-warning.hidden {
  display: none;
}

.chat-form-actions {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.chat-upload-controls {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1 1 auto;
}

.chat-upload-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.chat-upload-hint {
  margin: 0;
  font-size: 0.85rem;
  color: rgba(148, 163, 184, 0.85);
}

.chat-send-btn {
  padding: 14px 22px;
  border: none;
  border-radius: 12px;
  font-weight: 600;
  background: var(--button-bg);
  color: var(--button-text);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.3s ease, color 0.3s ease;
}

.chat-send-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px var(--button-hover-shadow);
}

.chat-send-btn:disabled {
  opacity: 0.6;
  cursor: default;
  transform: none;
  box-shadow: none;
}

.chat-form.drag-over {
  outline: 2px dashed rgba(99, 102, 241, 0.65);
  outline-offset: 8px;
}

body[data-theme='light'] .chat-form.drag-over {
  outline-color: rgba(79, 70, 229, 0.6);
}

.file-button {
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--file-button-border);
  background: var(--file-button-bg);
  color: var(--file-button-text);
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.file-button:hover {
  transform: translateY(-1px);
  background: var(--file-button-bg);
  box-shadow: 0 8px 16px var(--button-hover-shadow);
}

.file-button:focus-visible {
  outline: 3px solid var(--select-focus-border);
  outline-offset: 2px;
}

.file-button.file-button-secondary {
  margin-left: 0;
  border-style: dashed;
  background: transparent;
  color: var(--file-button-text);
}

.file-button.file-button-secondary:hover {
  background: var(--file-button-hover);
}

.model-select {
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--select-border);
  background: var(--select-bg);
  color: var(--select-text);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.3s ease, color 0.3s ease;
}

.model-select:focus {
  border-color: var(--select-focus-border);
  box-shadow: 0 0 0 3px var(--select-focus-shadow);
}

.model-select option {
  background: var(--card-bg);
  color: var(--text-color);
}

.model-select optgroup {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--select-muted);
  padding: 4px 0;
}

.model-select optgroup option {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-color);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 820px) {
  body {
    padding: 16px;
  }

  .chat-app {
    flex-direction: column;
    border-radius: 16px;
  }

  .chat-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--bot-bubble-border);
    max-height: 220px;
    overflow-y: auto;
  }

  .conversation-item {
    padding: 10px 12px;
  }

  .chat-log {
    padding: 20px;
  }

  .chatkit-wrapper {
    padding: 20px;
  }

  .attachment-list {
    padding: 0 20px 10px;
  }

  .chat-form {
    padding: 16px 20px 20px;
  }

  .file-button,
  .chat-send-btn,
  .sidebar-new {
    width: 100%;
  }

  .chat-form-actions {
    flex-direction: column;
  }

  .chat-upload-buttons {
    width: 100%;
  }

  .tool-switch {
    width: 100%;
    justify-content: flex-start;
  }

  .header-controls .model-select,
  .header-controls .web-search-toggle {
    flex: 1 1 150px;
  }

  .conversation-list {
    max-height: none;
  }
}
.message-actions {
  margin-top: 12px;
  display: flex;
  gap: 10px;
}

.download-button {
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid var(--file-button-border);
  background: transparent;
  color: var(--attachment-text);
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.download-button:hover {
  transform: translateY(-1px);
  background-color: var(--file-button-hover);
}

.assistant-thought {
  margin: 12px 0;
  padding: 12px 14px;
  border-left: 3px solid rgba(148, 163, 184, 0.5);
  background: rgba(15, 23, 42, 0.35);
  border-radius: 10px;
  font-size: 0.85rem;
  color: rgba(226, 232, 240, 0.85);
}

.assistant-thought-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(148, 163, 184, 0.75);
  margin-bottom: 6px;
}

.assistant-thought-body p {
  margin: 0 0 4px 0;
}

.assistant-thought-body ul {
  margin: 4px 0 0 16px;
}

.message-footnotes {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(148, 163, 184, 0.2);
  font-size: 0.85rem;
  color: rgba(226, 232, 240, 0.8);
}

.message-footnotes-title {
  margin: 0 0 6px 0;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: rgba(148, 163, 184, 0.8);
}

.message-footnotes ol {
  margin: 0;
  padding-left: 20px;
}

.message-footnotes a {
  color: #60a5fa;
  text-decoration: underline;
}

body[data-theme='light'] .assistant-thought {
  background: rgba(226, 232, 240, 0.6);
  color: rgba(30, 41, 59, 0.78);
  border-left-color: rgba(148, 163, 184, 0.6);
}

body[data-theme='light'] .assistant-thought-label {
  color: rgba(71, 85, 105, 0.7);
}

body[data-theme='light'] .message-footnotes {
  border-top-color: rgba(148, 163, 184, 0.35);
  color: rgba(51, 65, 85, 0.85);
}

body[data-theme='light'] .message-footnotes-title {
  color: rgba(71, 85, 105, 0.75);
}

body[data-theme='light'] .message-footnotes a {
  color: #2563eb;
}

body[data-theme='light'] .message-text a,
body[data-theme='light'] .message-text sup a {
  color: #2563eb;
}

.gpt5-loading {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  margin: 10px 24px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.3);
  color: rgba(226, 232, 240, 0.85);
  font-size: 0.9rem;
}

.gpt5-spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 3px solid rgba(148, 163, 184, 0.2);
  border-top-color: #60a5fa;
  animation: gpt5-spin 0.8s linear infinite;
}

@keyframes gpt5-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

body[data-theme='light'] .gpt5-loading {
  background: rgba(226, 232, 240, 0.7);
  border-color: rgba(148, 163, 184, 0.4);
  color: rgba(30, 41, 59, 0.75);
}

.chatkit-wrapper {
  padding: 24px;
  background: var(--chat-bg);
  border-top: 1px solid var(--bot-bubble-border);
  border-bottom: 1px solid var(--bot-bubble-border);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chatkit-heading h2 {
  margin: 0 0 6px 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.chatkit-heading p {
  margin: 0;
  font-size: 0.9rem;
  color: rgba(226, 232, 240, 0.75);
}

.chatkit-widget {
  display: block;
  min-height: 460px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.4);
}

.chatkit-fallback {
  padding: 32px;
  text-align: center;
  font-size: 0.95rem;
  color: rgba(226, 232, 240, 0.7);
}

body[data-theme='light'] .chatkit-heading p {
  color: rgba(71, 85, 105, 0.7);
}

body[data-theme='light'] .chatkit-widget {
  border-color: rgba(148, 163, 184, 0.35);
  background: rgba(226, 232, 240, 0.65);
}

body[data-theme='light'] .chatkit-fallback {
  color: rgba(51, 65, 85, 0.75);
}

body.modal-open {
  overflow: hidden;
}

.settings-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
}

.settings-modal.hidden {
  display: none;
}

.settings-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(4px);
}

.settings-modal-panel {
  position: relative;
  width: min(640px, 94vw);
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  background: #0f172a;
  border: 1px solid #1f2a44;
  border-radius: 1.25rem;
  padding: 1.5rem;
  color: #f8fafc;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.85);
}

.settings-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.settings-header-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.settings-secondary-btn {
  padding: 0.6rem 1rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: transparent;
  color: #e2e8f0;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.settings-secondary-btn:hover,
.settings-secondary-btn:focus-visible {
  border-color: rgba(99, 102, 241, 0.65);
  color: #ffffff;
  outline: none;
}

.settings-subtitle {
  margin: 0.35rem 0 0;
  color: #94a3b8;
  font-size: 0.9rem;
}

.settings-close-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.2s ease;
}

.settings-close-btn:hover {
  color: #f8fafc;
}

.settings-tabs {
  display: flex;
  gap: 0.75rem;
}

.settings-tab {
  flex: 1;
  border-radius: 0.9rem;
  border: 1px solid #1f2a44;
  background: transparent;
  color: #94a3b8;
  font-weight: 600;
  padding: 0.65rem 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.settings-tab.active {
  background: #1c2542;
  color: #f8fafc;
  border-color: #4f46e5;
  box-shadow: 0 12px 28px rgba(79, 70, 229, 0.25);
}

.settings-section.hidden {
  display: none;
}

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.settings-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #cbd5e1;
  margin-bottom: 0.35rem;
}

.settings-input,
.settings-select,
.settings-textarea {
  width: 100%;
  border-radius: 0.9rem;
  border: 1px solid #1f2a44;
  background: #0b1120;
  color: #e2e8f0;
  padding: 0.85rem 1rem;
  font-size: 1rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.settings-textarea {
  resize: vertical;
  min-height: 120px;
}

.settings-input:focus,
.settings-select:focus,
.settings-textarea:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.4);
}

.settings-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: flex-start;
}

.settings-primary-btn {
  border: none;
  border-radius: 0.9rem;
  background: linear-gradient(90deg, #4f46e5, #7c3aed);
  color: #fff;
  font-weight: 600;
  padding: 0.75rem 1.5rem;
  cursor: pointer;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.settings-primary-btn:hover {
  opacity: 0.95;
  transform: translateY(-1px);
}

.settings-status {
  font-size: 0.85rem;
  min-height: 1.25rem;
  color: #94a3b8;
}

.settings-status[data-variant='error'] {
  color: #f87171;
}

.settings-status[data-variant='success'] {
  color: #34d399;
}

.report-panel {
  border-top: 1px solid rgba(148, 163, 184, 0.1);
  padding-top: 1rem;
}

.report-panel.hidden {
  display: none;
}

.report-form h3 {
  margin: 0 0 0.35rem 0;
}

.report-hint {
  margin: 0 0 1rem 0;
  color: #94a3b8;
  font-size: 0.9rem;
}

.report-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.settings-status[data-variant='warning'] {
  color: #fbbf24;
}

.settings-documents-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.settings-documents-actions {
  display: flex;
  gap: 0.5rem;
}

.settings-doc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  max-height: 40vh;
  overflow-y: auto;
}

.settings-doc-item {
  border: 1px solid #1f2a44;
  border-radius: 0.9rem;
  padding: 0.85rem 1rem;
  background: #111a31;
}

.settings-doc-name {
  margin: 0 0 0.35rem 0;
  font-weight: 600;
  color: #f8fafc;
}

.settings-doc-meta {
  margin: 0 0 0.35rem 0;
  font-size: 0.8rem;
  color: #94a3b8;
}

.settings-doc-summary {
  margin: 0;
  font-size: 0.9rem;
  color: #cbd5e1;
  line-height: 1.4;
}

.settings-doc-empty {
  margin: 0;
  color: #94a3b8;
}

.settings-dropzone {
  border: 1px dashed #2f3f66;
  border-radius: 1rem;
  padding: 1rem;
  margin-top: 1rem;
  text-align: center;
  color: #94a3b8;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.settings-dropzone p {
  margin: 0;
}

.settings-dropzone.settings-dropzone--active {
  border-color: #6366f1;
  background: rgba(99, 102, 241, 0.08);
  color: #e2e8f0;
}

@media (max-width: 640px) {
  .settings-modal-panel {
    width: 95vw;
    padding: 1.25rem;
  }

  .settings-documents-header {
    flex-direction: column;
  }
}











