:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --panel-soft: #edf2ff;
  --text: #111827;
  --muted: #6b7280;
  --border: #d9dfeb;
  --accent: #111827;
  --accent-2: #2563eb;
  --accent-3: #4f46e5;
  --bubble-me: #111827;
  --bubble-them: #ffffff;
  --danger: #b91c1c;
  --notice: #eef4ff;
  --shadow: 0 18px 50px rgba(15, 23, 42, 0.12);
}
body[data-theme="dark"] {
  --bg: #080d18;
  --panel: #12192d;
  --panel-soft: #18213b;
  --text: #f8fafc;
  --muted: #93a4bd;
  --border: #273450;
  --accent: #f8fafc;
  --accent-2: #60a5fa;
  --accent-3: #818cf8;
  --bubble-me: #2563eb;
  --bubble-them: #18213b;
  --notice: #0f1d3d;
  --shadow: 0 18px 50px rgba(0,0,0,0.38);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; font-family: Inter, Arial, sans-serif; background: var(--bg); color: var(--text); }
body { min-height: 100vh; }
button, input, textarea { font: inherit; }
button { border: none; background: var(--accent); color: #fff; border-radius: 14px; padding: 12px 16px; cursor: pointer; transition: 0.2s ease; }
button:hover { transform: translateY(-1px); opacity: 0.96; }
button.secondary { background: var(--accent-2); }
button.secondary-2 { background: var(--accent-3); }
.ghost-button { background: transparent; color: var(--text); border: 1px solid var(--border); }
input, textarea { width: 100%; background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; }
label { display: grid; gap: 8px; font-size: 14px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { background: rgba(185,28,28,0.12); color: var(--danger); border-radius: 14px; padding: 12px 14px; margin-top: 12px; }
.view { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: min(480px, 100%); background: var(--panel); border: 1px solid var(--border); border-radius: 28px; padding: 28px; box-shadow: var(--shadow); }
.brand, .sidebar-brand { display: flex; gap: 16px; align-items: center; }
.brand-logo { width: 96px; height: 96px; object-fit: contain; border-radius: 20px; }
.sidebar-logo, .empty-logo { width: 44px; height: 44px; object-fit: contain; border-radius: 12px; }
.brand h1 { margin: 0 0 6px; font-size: 2rem; }
.brand p { margin: 0; color: var(--muted); }
.version-pill { display: inline-block; margin-top: 10px; border: 1px solid var(--border); color: var(--muted); border-radius: 999px; padding: 6px 10px; font-size: 12px; }
.theme-row { display: flex; justify-content: flex-end; margin: 12px 0 18px; }
.tabs, .filter-tabs { display: flex; gap: 10px; }
.tabs { margin-bottom: 14px; }
.tab, .filter-tab { flex: 1; background: transparent; color: var(--text); border: 1px solid var(--border); }
.tab.active, .filter-tab.active { background: var(--panel-soft); }
.auth-form { display: grid; gap: 14px; }
.disclaimer { margin-top: 16px; font-size: 13px; color: var(--muted); line-height: 1.45; }
#chatView { display: grid; grid-template-columns: 355px 1fr; width: min(1320px, 100%); min-height: calc(100vh - 40px); border: 1px solid var(--border); border-radius: 30px; overflow: hidden; background: var(--panel); box-shadow: var(--shadow); }
.sidebar { border-right: 1px solid var(--border); background: linear-gradient(180deg, var(--panel), var(--panel-soft)); padding: 18px; display: flex; flex-direction: column; gap: 16px; }
.sidebar-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sidebar-actions { display: grid; gap: 10px; }
.sidebar-actions.three-col { grid-template-columns: 1fr 1fr 1fr; }
.sidebar-actions .span-all { grid-column: 1 / -1; }
.filter-tabs { margin-top: -4px; }
.chats-list { display: grid; gap: 10px; overflow: auto; padding-right: 4px; }
.chat-item { background: transparent; border: 1px solid var(--border); color: var(--text); border-radius: 20px; text-align: left; padding: 14px; }
.chat-item.active { background: var(--panel); box-shadow: var(--shadow); }
.chat-item-row { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.chat-item-name { font-weight: 700; }
.chat-item-meta { font-size: 13px; color: var(--muted); margin-top: 8px; }
.type-pill { display: inline-block; margin-top: 10px; border-radius: 999px; padding: 5px 10px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; border: 1px solid var(--border); }
.main { display: grid; grid-template-rows: auto 1fr; min-height: 0; background: radial-gradient(circle at top right, rgba(37,99,235,0.10), transparent 32%), linear-gradient(180deg, var(--bg), var(--panel-soft)); }
.chat-header { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.chat-header h2 { margin: 0; }
.chat-header-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.empty-state, .chat-panel { min-height: 0; display: grid; }
.empty-state { place-items: center; text-align: center; padding: 30px; gap: 8px; }
.chat-panel { grid-template-rows: auto 1fr auto; }
.notice { margin: 14px 18px 0; background: var(--notice); color: var(--text); border: 1px solid var(--border); border-radius: 16px; padding: 12px 14px; font-size: 14px; }
.messages { overflow: auto; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.message { max-width: min(80%, 780px); border-radius: 22px; padding: 12px 14px; line-height: 1.42; box-shadow: var(--shadow); }
.message.them { align-self: flex-start; background: var(--bubble-them); border: 1px solid var(--border); }
.message.me { align-self: flex-end; background: var(--bubble-me); color: #fff; }
.message-top { display: flex; gap: 10px; justify-content: space-between; margin-bottom: 6px; font-size: 12px; }
.message-body { white-space: pre-wrap; word-break: break-word; }
.composer { padding: 16px 18px 20px; border-top: 1px solid var(--border); display: grid; grid-template-columns: 1fr auto; gap: 12px; }
.composer textarea { min-height: 52px; max-height: 180px; resize: vertical; }
dialog { border: none; background: transparent; }
dialog::backdrop { background: rgba(0,0,0,0.45); }
.dialog-card { width: min(430px, calc(100vw - 32px)); background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 24px; padding: 22px; box-shadow: var(--shadow); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 0; margin-top: 16px; }
.info-body { white-space: pre-wrap; line-height: 1.5; }
@media (max-width: 960px) {
  #chatView { grid-template-columns: 1fr; min-height: 100vh; border-radius: 0; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--border); }
}
