:root {
  --bg: #0f1117;
  --bg-elevated: #171923;
  --sidebar: #12141c;
  --border: rgba(255,255,255,0.08);
  --text: #ececf1;
  --muted: #9ca3af;
  --accent: #3b82f6;
  --user-bubble: #2563eb;
  --assistant-bubble: #2a2d3a;
  --radius: 12px;
  --font: "Inter", system-ui, -apple-system, sans-serif;
}
[data-theme="light"] {
  --bg: #f7f7f8;
  --bg-elevated: #fff;
  --sidebar: #ececf1;
  --border: rgba(0,0,0,0.08);
  --text: #0d0d0d;
  --muted: #6b7280;
  --assistant-bubble: #f0f0f0;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; font-family: var(--font); background: var(--bg); color: var(--text); }
.auth-screen { min-height: 100%; display: grid; place-items: center; padding: 1rem; }
.auth-card { width: min(420px, 100%); background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); padding: 2rem; }
.auth-card h1 { margin: 0.5rem 0 0; font-size: 1.5rem; }
.auth-tabs { display: flex; gap: 0.5rem; margin: 1.25rem 0; }
.auth-tabs button { flex: 1; padding: 0.5rem; border: 1px solid var(--border); background: transparent; color: var(--text); border-radius: 8px; cursor: pointer; }
.auth-tabs button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.auth-card label { display: block; margin-bottom: 0.75rem; font-size: 0.85rem; }
.auth-card input { width: 100%; margin-top: 0.25rem; padding: 0.65rem; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); }
.auth-card .primary, .sidebar-btn.primary, .composer-actions .primary { background: var(--accent); color: #fff; border: none; padding: 0.65rem 1rem; border-radius: 8px; cursor: pointer; }
.oauth-row { display: flex; gap: 0.5rem; margin-top: 1rem; }
.oauth { flex: 1; padding: 0.5rem; border-radius: 8px; border: 1px solid var(--border); background: transparent; color: var(--muted); }
.oauth.disabled { opacity: 0.5; cursor: not-allowed; }
.error { color: #f87171; font-size: 0.9rem; }
.muted { color: var(--muted); font-size: 0.9rem; }

.app-shell { display: grid; grid-template-columns: 280px 1fr; height: 100vh; }
.sidebar { background: var(--sidebar); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 0.75rem; gap: 0.5rem; }
.sidebar-head { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem; }
.sidebar-btn { width: 100%; text-align: left; padding: 0.5rem 0.75rem; border: none; background: transparent; color: var(--text); border-radius: 8px; cursor: pointer; }
.sidebar-btn:hover { background: rgba(255,255,255,0.06); }
.sidebar-search { padding: 0.5rem; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); }
.conv-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 0.25rem; }
.conv-item { padding: 0.5rem 0.75rem; border-radius: 8px; cursor: pointer; font-size: 0.9rem; border: none; background: transparent; color: var(--text); text-align: left; }
.conv-item.active, .conv-item:hover { background: rgba(59,130,246,0.15); }
.sidebar-foot { border-top: 1px solid var(--border); padding-top: 0.5rem; }

.main { display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
.main-head { display: flex; justify-content: space-between; align-items: center; padding: 0.75rem 1.25rem; border-bottom: 1px solid var(--border); }
.main-head h2 { margin: 0; font-size: 1rem; font-weight: 500; }
.dev-toggle { font-size: 0.8rem; color: var(--muted); }
.welcome { flex: 1; display: grid; place-items: center; }
.welcome h1 { font-size: clamp(1.5rem, 4vw, 2rem); font-weight: 500; color: var(--muted); }
.thread { flex: 1; overflow-y: auto; padding: 1.25rem; display: flex; flex-direction: column; gap: 1rem; max-width: 820px; width: 100%; margin: 0 auto; }
.bubble { max-width: 85%; padding: 0.85rem 1rem; border-radius: var(--radius); line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.bubble.user { align-self: flex-end; background: var(--user-bubble); color: #fff; border-bottom-right-radius: 4px; }
.bubble.assistant { align-self: flex-start; background: var(--assistant-bubble); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.bubble.error { align-self: center; border: 1px solid #f87171; color: #fecaca; }
.typing { opacity: 0.7; font-style: italic; }
.tech { margin-top: 0.5rem; font-size: 0.75rem; }
.composer { border-top: 1px solid var(--border); padding: 0.75rem 1.25rem 1.25rem; max-width: 820px; width: 100%; margin: 0 auto; }
.composer-tools { display: flex; gap: 0.35rem; margin-bottom: 0.35rem; }
.icon-btn { background: transparent; border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 0.35rem 0.5rem; cursor: pointer; }
.composer textarea { width: 100%; min-height: 52px; max-height: 200px; resize: vertical; padding: 0.75rem; border-radius: var(--radius); border: 1px solid var(--border); background: var(--bg-elevated); color: var(--text); font-family: inherit; font-size: 1rem; }
.composer-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 0.5rem; }

@media (max-width: 768px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 10; left: -100%; width: 85%; height: 100%; transition: left 0.2s; }
  .sidebar.open { left: 0; }
}
