/* DeepSeek Playground — Self-contained modern UI */

:root {
  --bg: #0b0f19;
  --bg-elevated: #121826;
  --bg-sidebar: #0d1220;
  --bg-hover: #1a2236;
  --bg-input: #151c2c;
  --border: #1e2a44;
  --border-light: #2a3a5c;
  --text: #e8eef9;
  --text-muted: #8b9bb8;
  --text-dim: #5c6b8a;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-soft: rgba(59, 130, 246, 0.15);
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --user-bubble: #1e3a5f;
  --assistant-bubble: #151c2c;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --font: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", "Fira Code", ui-monospace, monospace;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
  --bg: #f5f7fb;
  --bg-elevated: #ffffff;
  --bg-sidebar: #eef1f8;
  --bg-hover: #e4e9f4;
  --bg-input: #ffffff;
  --border: #d8e0ef;
  --border-light: #c5d0e6;
  --text: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.12);
  --user-bubble: #dbeafe;
  --assistant-bubble: #ffffff;
  --shadow: 0 4px 24px rgba(15, 23, 42, 0.08);
}

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

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 280px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: transform var(--transition), width var(--transition);
  z-index: 40;
}

.sidebar-header {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  font-weight: 700;
  font-size: 1.15rem;
}

.logo-icon { font-size: 1.4rem; }

.sidebar-section {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
}

.section-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  padding: 0.5rem 0.5rem 0.35rem;
}

.chat-list { display: flex; flex-direction: column; gap: 2px; }

.chat-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.875rem;
  transition: background var(--transition), color var(--transition);
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}

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

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

.chat-item .delete {
  opacity: 0;
  padding: 2px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  border-radius: 4px;
}
.chat-item:hover .delete { opacity: 1; }
.chat-item .delete:hover { color: var(--danger); }

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

/* Main */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
}

.topbar {
  height: 56px;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}

.topbar-title {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 600;
  font-size: 0.95rem;
  overflow: hidden;
}

.topbar-title span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  font-size: 0.7rem;
  font-weight: 500;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  white-space: nowrap;
}

.topbar-actions { display: flex; gap: 0.25rem; }

/* Messages */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 1rem 2rem;
  scroll-behavior: smooth;
}

.welcome {
  max-width: 640px;
  margin: 4rem auto 0;
  text-align: center;
  animation: fadeUp 0.5s ease;
}

.welcome-icon { font-size: 3rem; margin-bottom: 0.75rem; }
.welcome h1 { font-size: 1.75rem; margin-bottom: 0.5rem; }
.welcome p { color: var(--text-muted); margin-bottom: 2rem; }

.welcome-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.welcome-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: left;
  cursor: pointer;
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
  color: var(--text);
}

.welcome-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.welcome-card strong { display: block; font-size: 0.9rem; margin-bottom: 0.25rem; }
.welcome-card span { font-size: 0.8rem; color: var(--text-muted); }

.message {
  max-width: 780px;
  margin: 0 auto 1.25rem;
  display: flex;
  gap: 0.85rem;
  animation: fadeUp 0.35s ease;
}

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

.message.user .avatar { background: var(--user-bubble); }
.message.assistant .avatar { background: linear-gradient(135deg, #3b82f6, #8b5cf6); }

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

.message-meta {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-bottom: 0.25rem;
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.bubble {
  padding: 0.85rem 1.1rem;
  border-radius: var(--radius);
  line-height: 1.65;
  font-size: 0.95rem;
  word-break: break-word;
}

.message.user .bubble {
  background: var(--user-bubble);
  border: 1px solid var(--border-light);
}

.message.assistant .bubble {
  background: var(--assistant-bubble);
  border: 1px solid var(--border);
}

/* Reasoning / Thinking block */
.reasoning {
  margin-bottom: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-input);
}

.reasoning-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.75rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  background: var(--bg-hover);
}

.reasoning-header:hover { color: var(--text); }

.reasoning-body {
  padding: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: pre-wrap;
  max-height: 240px;
  overflow-y: auto;
  border-top: 1px solid var(--border);
}

.reasoning.collapsed .reasoning-body { display: none; }

/* Markdown-ish styles inside bubble */
.bubble p { margin-bottom: 0.75rem; }
.bubble p:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { margin: 0.5rem 0 0.75rem 1.25rem; }
.bubble li { margin-bottom: 0.25rem; }
.bubble code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--bg-hover);
  padding: 0.15em 0.4em;
  border-radius: 4px;
}
.bubble pre {
  background: #0a0e17;
  color: #e2e8f0;
  padding: 0.9rem 1rem;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 0.75rem 0;
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.5;
}
[data-theme="light"] .bubble pre { background: #1e293b; }
.bubble pre code { background: none; padding: 0; }
.bubble a { color: var(--accent); text-decoration: none; }
.bubble a:hover { text-decoration: underline; }
.bubble blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 0.85rem;
  margin: 0.75rem 0;
  color: var(--text-muted);
}
.bubble img {
  max-width: 100%;
  border-radius: var(--radius-sm);
  margin: 0.5rem 0;
}

.attachments-in-msg {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.attachments-in-msg img {
  max-width: 160px;
  max-height: 120px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  border: 1px solid var(--border);
}

.tool-call {
  margin: 0.5rem 0;
  padding: 0.6rem 0.85rem;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}
.tool-call .name { font-weight: 600; color: var(--accent); }
.tool-call pre { margin: 0.4rem 0 0; font-size: 0.8rem; max-height: 120px; overflow: auto; }

.typing {
  display: inline-flex;
  gap: 4px;
  padding: 0.2rem 0;
}
.typing span {
  width: 6px;
  height: 6px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: bounce 1.2s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }

/* Composer */
.composer-wrap {
  padding: 0.75rem 1rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
}

.attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  max-width: 780px;
  margin-left: auto;
  margin-right: auto;
}
.attachments:empty { display: none; }

.attach-preview {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}
.attach-preview img { width: 100%; height: 100%; object-fit: cover; }
.attach-preview .remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0,0,0,0.7);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.composer {
  max-width: 780px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  padding: 0.5rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.composer:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.composer textarea {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  resize: none;
  max-height: 180px;
  padding: 0.5rem 0.25rem;
  outline: none;
  line-height: 1.5;
}

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

.composer-hint {
  max-width: 780px;
  margin: 0.4rem auto 0;
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-dim);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), opacity var(--transition), transform 0.1s;
  font-family: inherit;
  color: var(--text);
  background: transparent;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

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

.btn-ghost {
  color: var(--text-muted);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}
.btn-danger:hover { background: rgba(239, 68, 68, 0.1); }

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  color: var(--text-muted);
}
.btn-icon:hover { background: var(--bg-hover); color: var(--text); }

.btn-block { width: 100%; }

.btn-send {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
}
.btn-stop { color: var(--danger); }
.btn-stop:hover { background: rgba(239, 68, 68, 0.15); }

.hidden { display: none !important; }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal.hidden { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}

.modal-panel {
  position: relative;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  animation: scaleIn 0.25s ease;
}
.modal-wide { max-width: 640px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 1.1rem; }

.modal-body {
  padding: 1.25rem;
  overflow-y: auto;
}

.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  margin-bottom: 0.35rem;
  color: var(--text-muted);
}
.form-hint { font-size: 0.75rem; color: var(--text-dim); margin-top: 0.35rem; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="url"],
select,
textarea {
  width: 100%;
  padding: 0.55rem 0.75rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--transition);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.input-row {
  display: flex;
  gap: 0.5rem;
}
.input-row input { flex: 1; }

.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  color: var(--text) !important;
  font-size: 0.9rem !important;
}
.checkbox-label input { width: auto; }

.form-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.tab {
  padding: 0.55rem 0.9rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--transition), border-color var(--transition);
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn 0.2s ease; }

.panel-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}
.panel-desc code {
  font-family: var(--mono);
  font-size: 0.8em;
  background: var(--bg-hover);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}

.code-output {
  margin-top: 1rem;
  padding: 0.85rem;
  background: #0a0e17;
  color: #e2e8f0;
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 0.8rem;
  max-height: 280px;
  overflow: auto;
  white-space: pre-wrap;
  display: none;
}
.code-output:not(:empty) { display: block; }

.tools-list { margin-top: 1rem; display: flex; flex-direction: column; gap: 0.5rem; }
.tool-item {
  padding: 0.65rem 0.85rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}
.tool-item strong { display: block; color: var(--accent); margin-bottom: 0.15rem; }
.tool-item span { color: var(--text-muted); font-size: 0.8rem; }

/* Theme icons */
[data-theme="light"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon,
:root:not([data-theme="light"]) .icon-moon { display: none; }
[data-theme="light"] .icon-moon { display: block; }

/* Mobile */
.mobile-only { display: none; }

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }
  .mobile-only { display: flex; }
  .welcome-cards { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}

/* Animations */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }


/* Password gate */
.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 1.5rem;
}
.auth-gate.hidden { display: none; }

.auth-card {
  width: 100%;
  max-width: 360px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  padding: 2rem 1.75rem;
  box-shadow: var(--shadow);
  text-align: center;
  animation: scaleIn 0.3s ease;
}
.auth-logo { font-size: 2.5rem; margin-bottom: 0.5rem; }
.auth-card h1 { font-size: 1.35rem; margin-bottom: 0.35rem; }
.auth-sub { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1.5rem; }
.auth-card form { display: flex; flex-direction: column; gap: 0.75rem; }
.auth-card input[type="password"] {
  width: 100%;
  padding: 0.7rem 0.9rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  text-align: center;
  letter-spacing: 0.05em;
}
.auth-card input[type="password"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.auth-error {
  margin-top: 0.85rem;
  color: var(--danger);
  font-size: 0.85rem;
}


/* KaTeX */
.bubble .katex { font-size: 1.05em; }
.bubble .katex-display {
  margin: 0.75em 0;
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
}
.bubble .katex-display > .katex {
  text-align: center;
}

/* -------------------------------------------------------------------------
   Liquid Glass-inspired redesign
   Web adaptation: glass is reserved for navigation and floating controls;
   message content stays on solid, readable surfaces as Apple's HIG recommends.
   ------------------------------------------------------------------------- */
:root {
  color-scheme: dark;
  --bg: #090d18;
  --bg-elevated: rgba(18, 25, 42, 0.78);
  --bg-sidebar: rgba(13, 19, 34, 0.66);
  --bg-hover: rgba(255, 255, 255, 0.075);
  --bg-input: rgba(9, 15, 29, 0.68);
  --border: rgba(215, 229, 255, 0.12);
  --border-light: rgba(215, 229, 255, 0.22);
  --text: #f4f7ff;
  --text-muted: #b0bdd5;
  --text-dim: #8190ac;
  --accent: #8bb9ff;
  --accent-hover: #a8ccff;
  --accent-soft: rgba(116, 166, 255, 0.17);
  --success: #69ddb1;
  --danger: #ff8e9c;
  --warning: #ffd18a;
  --user-bubble: #263d68;
  --assistant-bubble: #141d30;
  --radius: 19px;
  --radius-sm: 13px;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
  --glass-fill: rgba(255, 255, 255, 0.075);
  --glass-edge: rgba(255, 255, 255, 0.20);
  --glass-blur: 26px;
  --transition: 0.24s cubic-bezier(0.2, 0.75, 0.25, 1);
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #edf2fb;
  --bg-elevated: rgba(255, 255, 255, 0.78);
  --bg-sidebar: rgba(246, 249, 255, 0.70);
  --bg-hover: rgba(38, 70, 125, 0.075);
  --bg-input: rgba(255, 255, 255, 0.78);
  --border: rgba(43, 63, 100, 0.12);
  --border-light: rgba(43, 63, 100, 0.20);
  --text: #18233a;
  --text-muted: #52627e;
  --text-dim: #7d8ca5;
  --accent: #2866c7;
  --accent-hover: #1d55ad;
  --accent-soft: rgba(50, 112, 210, 0.13);
  --user-bubble: #dce9ff;
  --assistant-bubble: #ffffff;
  --shadow: 0 24px 70px rgba(39, 62, 103, 0.12);
  --glass-fill: rgba(255, 255, 255, 0.58);
  --glass-edge: rgba(255, 255, 255, 0.82);
}

html, body {
  min-width: 320px;
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Inter, sans-serif;
  letter-spacing: -0.012em;
}
body { position: relative; isolation: isolate; }
body::before {
  content: "";
  position: fixed;
  inset: -18%;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 15% 12%, rgba(73, 119, 236, 0.25), transparent 31%),
    radial-gradient(ellipse at 80% 16%, rgba(93, 89, 205, 0.22), transparent 29%),
    radial-gradient(ellipse at 68% 86%, rgba(29, 151, 181, 0.13), transparent 30%),
    linear-gradient(145deg, #090d18, #10182a 56%, #0b1220);
  transform: translateZ(0);
}
[data-theme="light"] body::before {
  background:
    radial-gradient(ellipse at 15% 12%, rgba(119, 166, 255, 0.30), transparent 31%),
    radial-gradient(ellipse at 80% 16%, rgba(184, 156, 255, 0.24), transparent 29%),
    radial-gradient(ellipse at 68% 86%, rgba(103, 206, 218, 0.19), transparent 30%),
    linear-gradient(145deg, #f2f6ff, #e8effa 56%, #f4f7ff);
}
.app { height: 100dvh; min-height: 0; gap: 12px; padding: 12px; }

/* Floating navigation glass */
.sidebar {
  flex: 0 0 270px;
  width: 270px;
  border: 1px solid var(--glass-edge);
  border-radius: 26px;
  background: var(--glass-fill);
  -webkit-backdrop-filter: saturate(155%) blur(var(--glass-blur));
  backdrop-filter: saturate(155%) blur(var(--glass-blur));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.16), 0 16px 46px rgba(0,0,0,.13);
  overflow: hidden;
}
.sidebar-header { padding: 20px 16px 16px; border-bottom-color: var(--border); }
.logo { gap: 10px; margin-bottom: 18px; font-size: 1.08rem; letter-spacing: -.035em; }
.logo-icon { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 12px; font-size: 1.15rem; background: linear-gradient(145deg, rgba(126,177,255,.30), rgba(156,128,255,.16)); border: 1px solid rgba(255,255,255,.16); }
.sidebar-section { padding: 13px 10px; }
.section-label { padding: 9px 11px 7px; font-size: .66rem; letter-spacing: .12em; color: var(--text-dim); }
.chat-list { gap: 4px; }
.chat-item { min-height: 40px; border-radius: 12px; padding: 9px 11px; color: var(--text-muted); }
.chat-item:hover { background: rgba(255,255,255,.085); }
.chat-item.active { background: var(--accent-soft); color: var(--text); box-shadow: inset 0 0 0 1px rgba(130,174,255,.12); }
.chat-item .delete { opacity: .45; }
.chat-item:hover .delete, .chat-item:focus-within .delete { opacity: 1; }
.sidebar-footer { padding: 12px; border-top-color: var(--border); gap: 6px; }

/* Main content remains visually quiet; topbar/composer are glass controls. */
.main { min-height: 0; border-radius: 26px; overflow: hidden; background: transparent; }
.topbar {
  flex: 0 0 62px;
  height: 62px;
  margin-bottom: 10px;
  padding: 0 19px;
  border: 1px solid var(--glass-edge);
  border-radius: 20px;
  background: var(--glass-fill);
  -webkit-backdrop-filter: saturate(160%) blur(var(--glass-blur));
  backdrop-filter: saturate(160%) blur(var(--glass-blur));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.15);
}
.topbar-title { font-size: .96rem; gap: 11px; }
.badge { padding: 5px 10px; border: 1px solid rgba(130,174,255,.18); background: rgba(110,157,246,.13); color: var(--accent); font-size: .68rem; letter-spacing: .01em; }
.topbar-actions { gap: 5px; }
.messages { min-height: 0; padding: 1.5rem clamp(14px, 3vw, 36px) 2rem; }
.welcome { margin-top: clamp(2rem, 9vh, 6rem); max-width: 680px; }
.welcome-icon { display: grid; place-items: center; width: 76px; height: 76px; margin: 0 auto 18px; border-radius: 27px; font-size: 2.2rem; background: linear-gradient(145deg, rgba(130,180,255,.20), rgba(159,126,255,.12)); border: 1px solid rgba(255,255,255,.17); box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 16px 40px rgba(45,87,170,.16); }
.welcome h1 { font-size: clamp(1.7rem, 4vw, 2.35rem); font-weight: 680; letter-spacing: -.055em; }
.welcome p { max-width: 540px; margin: 0 auto 28px; color: var(--text-muted); font-size: .96rem; }
.welcome-cards { gap: 11px; }
.welcome-card { padding: 17px 18px; border-radius: 17px; border-color: var(--border); background: rgba(17,25,42,.54); color: var(--text); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); box-shadow: inset 0 1px 0 rgba(255,255,255,.045); }
[data-theme="light"] .welcome-card { background: rgba(255,255,255,.62); }
.welcome-card:hover { border-color: rgba(130,174,255,.52); transform: translateY(-3px); box-shadow: 0 12px 30px rgba(0,0,0,.12), inset 0 1px 0 rgba(255,255,255,.1); }
.welcome-card strong { font-size: .9rem; letter-spacing: -.02em; }
.welcome-card span { display: block; margin-top: 3px; line-height: 1.45; }

/* Message surfaces intentionally use solid material for reading contrast. */
.message { max-width: 860px; gap: 12px; margin-bottom: 1.45rem; }
.message .avatar { width: 34px; height: 34px; border-radius: 13px; border: 1px solid var(--border); }
.message.user .avatar { background: var(--user-bubble); }
.message.assistant .avatar { background: linear-gradient(145deg, #5c9eff, #9b83f6); color: white; }
.message-meta { margin-bottom: 6px; font-size: .72rem; letter-spacing: .025em; }
.bubble { padding: 14px 17px; border-radius: 17px; font-size: .94rem; line-height: 1.72; }
.message.user .bubble { background: linear-gradient(145deg, #2a426d, #203451); border: 1px solid rgba(156,190,255,.22); color: #f5f8ff; }
.message.assistant .bubble { background: var(--assistant-bubble); border: 1px solid var(--border); box-shadow: 0 5px 18px rgba(0,0,0,.045); }
[data-theme="light"] .message.user .bubble { background: linear-gradient(145deg, #dfeaff, #d4e3ff); color: #172743; border-color: rgba(55,105,190,.16); }
[data-theme="light"] .message.assistant .bubble { box-shadow: 0 5px 18px rgba(39,62,103,.045); }
.reasoning { background: rgba(120,145,185,.07); border-color: var(--border); border-radius: 13px; }
.reasoning-header { background: rgba(120,145,185,.09); padding: 9px 12px; }
.reasoning-body { border-top-color: var(--border); }
.bubble code { border: 1px solid rgba(140,160,200,.10); border-radius: 6px; }
.bubble pre { border: 1px solid rgba(255,255,255,.08); border-radius: 13px; }
.tool-call { border-radius: 12px; }

/* Composer is a floating, tactile glass panel. */
.composer-wrap { flex: 0 0 auto; padding: 13px 18px 11px; border: 1px solid var(--glass-edge); border-radius: 22px; background: var(--glass-fill); -webkit-backdrop-filter: saturate(160%) blur(var(--glass-blur)); backdrop-filter: saturate(160%) blur(var(--glass-blur)); box-shadow: inset 0 1px 0 rgba(255,255,255,.16), 0 12px 36px rgba(0,0,0,.10); }
.attachments { margin-bottom: 9px; }
.composer { border-radius: 18px; padding: 7px; gap: 7px; background: var(--bg-input); border: 1px solid var(--border-light); box-shadow: inset 0 1px 2px rgba(0,0,0,.06); }
.composer:focus-within { border-color: rgba(126,176,255,.6); box-shadow: 0 0 0 3px rgba(115,162,255,.13), inset 0 1px 2px rgba(0,0,0,.04); }
.composer textarea { min-height: 38px; padding: 9px 7px; font-size: .94rem; }
.composer-hint { margin-top: 7px; font-size: .68rem; }

/* Rounded glass controls with restrained, interactive highlights. */
.btn { border-radius: 12px; font-weight: 570; letter-spacing: -.01em; transition: background var(--transition), color var(--transition), opacity var(--transition), transform var(--transition), box-shadow var(--transition), border-color var(--transition); }
.btn:focus-visible, .welcome-card:focus-visible, .tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.btn-primary { background: linear-gradient(145deg, #77aaff, #5c8ce9); color: #07142b; box-shadow: inset 0 1px 0 rgba(255,255,255,.42), 0 5px 14px rgba(70,119,219,.18); }
.btn-primary:hover:not(:disabled) { background: linear-gradient(145deg, #9ac2ff, #79a5f6); box-shadow: inset 0 1px 0 rgba(255,255,255,.55), 0 7px 19px rgba(70,119,219,.25); }
.btn-primary:active:not(:disabled) { transform: scale(.97); }
.btn-ghost { color: var(--text-muted); }
.btn-ghost:hover { background: rgba(255,255,255,.09); color: var(--text); }
.btn-icon { border: 1px solid transparent; border-radius: 13px; color: var(--text-muted); }
.btn-icon:hover { background: var(--glass-fill); border-color: var(--border); color: var(--text); box-shadow: inset 0 1px 0 rgba(255,255,255,.12); }
.btn-send { width: 39px; height: 39px; border-radius: 14px; }
.btn-stop { color: var(--danger); }
.btn-danger { border-radius: 12px; }

/* Settings and tool dialogs use a thicker, legible glass treatment. */
.modal { padding: clamp(10px, 3vw, 28px); }
.modal-backdrop { background: rgba(4,8,17,.58); -webkit-backdrop-filter: blur(9px); backdrop-filter: blur(9px); }
.modal-panel { max-width: 510px; max-height: min(90dvh, 900px); border-radius: 24px; border: 1px solid var(--glass-edge); background: var(--bg-elevated); -webkit-backdrop-filter: blur(30px) saturate(150%); backdrop-filter: blur(30px) saturate(150%); box-shadow: 0 30px 100px rgba(0,0,0,.36), inset 0 1px 0 rgba(255,255,255,.17); }
.modal-wide { max-width: 700px; }
.modal-header { padding: 18px 22px; border-bottom-color: var(--border); }
.modal-header h2 { font-size: 1.15rem; letter-spacing: -.035em; }
.modal-body { padding: 21px 22px; }
.form-group label { color: var(--text-muted); }
input[type="text"], input[type="password"], input[type="number"], input[type="url"], select, textarea { border-radius: 12px; border-color: var(--border-light); background: var(--bg-input); padding: 10px 12px; }
input:focus, select:focus, textarea:focus { border-color: rgba(126,176,255,.65); box-shadow: 0 0 0 3px rgba(115,162,255,.11); }
.tabs { gap: 5px; padding: 4px; border: 1px solid var(--border); border-radius: 14px; background: rgba(120,145,185,.07); }
.tab { border: 0; border-radius: 10px; padding: 9px 12px; }
.tab.active { background: var(--glass-fill); color: var(--text); border: 1px solid var(--glass-edge); box-shadow: 0 2px 8px rgba(0,0,0,.07), inset 0 1px 0 rgba(255,255,255,.12); }
.code-output { border: 1px solid var(--border); border-radius: 13px; }
.tool-item { border-radius: 13px; background: rgba(120,145,185,.07); }

/* Password gate */
.auth-gate { background: transparent; padding: 20px; -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px); }
.auth-gate::before { content: ""; position: absolute; inset: 0; background: rgba(5,9,19,.30); }
.auth-card { position: relative; max-width: 390px; padding: 34px 30px; border-radius: 28px; border: 1px solid var(--glass-edge); background: var(--bg-elevated); -webkit-backdrop-filter: blur(32px) saturate(160%); backdrop-filter: blur(32px) saturate(160%); box-shadow: 0 30px 100px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.18); }
.auth-logo { display: grid; place-items: center; width: 68px; height: 68px; margin: 0 auto 17px; border-radius: 24px; background: linear-gradient(145deg, rgba(126,177,255,.30), rgba(156,128,255,.18)); border: 1px solid rgba(255,255,255,.19); }
.auth-card h1 { font-size: 1.45rem; letter-spacing: -.04em; }
.auth-card input[type="password"] { text-align: left; letter-spacing: .02em; }

/* Responsive: mobile navigation becomes a glass drawer, dialogs stay contained. */
.mobile-only { display: none; }
@media (max-width: 900px) {
  .app { gap: 8px; padding: 8px; }
  .sidebar { flex-basis: 245px; width: 245px; }
  .messages { padding-inline: 16px; }
}
@media (max-width: 768px) {
  .app { gap: 0; padding: 0; }
  .sidebar { position: fixed; left: 8px; top: 8px; bottom: 8px; z-index: 90; width: min(285px, calc(100vw - 28px)); flex-basis: auto; transform: translateX(calc(-100% - 18px)); box-shadow: 0 20px 65px rgba(0,0,0,.38); }
  .sidebar.open { transform: translateX(0); }
  .mobile-only { display: inline-flex; }
  .main { border-radius: 0; }
  .topbar { flex-basis: 56px; height: 56px; margin: 8px 8px 6px; padding: 0 11px; border-radius: 17px; }
  .topbar-title { min-width: 0; gap: 7px; font-size: .88rem; }
  .badge { max-width: 42vw; overflow: hidden; text-overflow: ellipsis; }
  .messages { padding: 1rem 12px 1.5rem; }
  .welcome { margin-top: clamp(1.5rem, 7vh, 4rem); }
  .welcome-cards { grid-template-columns: 1fr 1fr; gap: 8px; }
  .welcome-card { padding: 13px; }
  .composer-wrap { margin: 0 8px 8px; padding: 9px; border-radius: 18px; }
  .composer { gap: 4px; }
  .composer-hint .hint-right { display: none; }
  .message { gap: 8px; }
  .message .avatar { width: 29px; height: 29px; border-radius: 10px; }
  .bubble { padding: 12px 13px; font-size: .91rem; }
  .modal { align-items: center; padding: 9px; }
  .modal-panel { max-height: calc(100dvh - 18px); border-radius: 20px; }
  .modal-body { padding: 16px; }
  .modal-header { padding: 14px 16px; }
  .tabs { max-width: 100%; }
}
@media (max-width: 480px) {
  .topbar-title span:first-child { max-width: 38vw; }
  .welcome h1 { font-size: 1.65rem; }
  .welcome p { font-size: .88rem; margin-bottom: 20px; }
  .welcome-cards { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .composer-left .btn-icon { width: 33px; height: 33px; }
  .composer textarea { font-size: 16px; }
  .form-actions { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .sidebar, .topbar, .composer-wrap, .modal-panel, .auth-card { background: var(--bg-elevated); }
}
