:root {
  --bg: #0b0c0f;
  --surface: #121318;
  --surface-2: #181a20;
  --text: #e7e9ee;
  --text-dim: #a6acb9;
  --brand: #00a67d;
  --brand-2: #22c6a0;
  --border: #2a2f3a;
  --accent: #4a9eff;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f7fb;
    --surface: #ffffff;
    --surface-2: #f3f4f8;
    --text: #101216;
    --text-dim: #616776;
    --border: #e9eaf0;
  }
}

/* Optional manual theme override via html[data-theme="light"|"dark"] */
html[data-theme="light"] {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f3f4f8;
  --text: #101216;
  --text-dim: #616776;
  --border: #e9eaf0;
}
html[data-theme="dark"] {
  --bg: #0b0c0f;
  --surface: #121318;
  --surface-2: #181a20;
  --text: #e7e9ee;
  --text-dim: #a6acb9;
  --border: #2a2f3a;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 14px/1.4 system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--bg);
  color: var(--text);
}

.app-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--border);
  background: var(--surface);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: white; font-weight: 700;
}
.brand .name { font-weight: 600; letter-spacing: .2px; }

.sidebar-section { margin-top: 8px; }
.sidebar-title { color: var(--text-dim); text-transform: uppercase; font-size: 11px; letter-spacing: .12em; margin-bottom: 6px; }
.session-id { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace; color: var(--text-dim); word-break: break-all; }
.sidebar-footer { margin-top: auto; display: flex; gap: 8px; }

.chat {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100vh;
}

.chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--surface);
}
.chat-header .title { font-weight: 600; }

.messages {
  padding: 16px; overflow-y: auto; background: var(--surface-2);
}

.message {
  display: grid; grid-template-columns: 40px 1fr; gap: 12px; padding: 14px 12px; border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.message + .message { margin-top: 12px; }
.message .avatar {
  width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font-weight: 700;
}
.message.user .avatar { background: #2a6cff; color: white; }
.message.assistant .avatar { background: var(--brand); color: white; }

.message .bubble { white-space: pre-wrap; word-wrap: break-word; }
.message .bubble a { color: var(--accent); text-decoration: none; }
.message .bubble a:hover { text-decoration: underline; }
.message .bubble code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  background: var(--surface-2); border: 1px solid var(--border); padding: .1rem .3rem; border-radius: 6px;
}
.message .bubble pre {
  background: var(--surface-2); border: 1px solid var(--border); padding: 12px; border-radius: 10px;
  overflow: auto; max-width: 100%;
}
.message .bubble img {
  max-width: 100%; border: 1px solid var(--border); border-radius: 12px; margin-top: 8px;
}

.composer {
  border-top: 1px solid var(--border); background: var(--surface);
}
.composer-form {
  display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 12px; align-items: end;
}
.composer textarea {
  resize: none; width: 100%; max-height: 200px; min-height: 42px;
  padding: 12px 14px; border-radius: 12px; border: none; background: transparent; color: var(--text);
  outline: none;
}
.composer .hint { color: var(--text-dim); font-size: 12px; padding: 0 12px 12px; }

.btn { border: 1px solid var(--border); background: var(--surface-2); color: var(--text); border-radius: 10px; padding: 10px 12px; cursor: pointer; }
.btn:hover { filter: brightness(1.05); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn.full { width: 100%; }
.btn.small { padding: 6px 10px; border-radius: 8px; }
.btn-primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: white; border: none; }
.btn-ghost { background: transparent; }

@media (max-width: 880px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}

