/* Warm light theme by default, matching the chat dashboard; dark follows the system. */
:root {
  color-scheme: light dark;
  --bg: #faf9f6;
  --panel: #ffffff;
  --raised: #f5f3ee;
  --line: #e8e5de;
  --line-strong: #d8d3c8;
  --text: #1c1b19;
  --muted: #6f6b63;
  --accent: #127a4f;
  --accent-strong: #0d6540;
  --accent-ink: #ffffff;
  --accent-soft: rgba(18, 122, 79, .09);
  --danger: #b4432f;
  --brand-bg: #10261b;
  --brand-text: #f1efea;
  --brand-muted: #b7c7bc;
  --shadow: 0 24px 60px rgba(40, 33, 20, .10), 0 2px 6px rgba(40, 33, 20, .05);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font: 16px/1.45 var(--font);
  color: var(--text);
  background: var(--bg);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141517;
    --panel: #1a1b1e;
    --raised: #222327;
    --line: #2b2c30;
    --line-strong: #3a3b40;
    --text: #f1efea;
    --muted: #a29e96;
    --accent: #6cf5b4;
    --accent-strong: #8ff8c6;
    --accent-ink: #0b1f15;
    --accent-soft: rgba(108, 245, 180, .10);
    --danger: #ff9b87;
    --brand-bg: #0d1d15;
    --shadow: 0 24px 60px rgba(0, 0, 0, .45);
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
[hidden] { display: none !important; }
a { color: var(--accent); font-weight: 600; text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea {
  font: inherit; color: inherit; border: 1px solid var(--line-strong); border-radius: 8px;
  padding: 10px 12px; background: var(--panel);
}
button { cursor: pointer; font-weight: 500; }
button:hover { background: var(--raised); }
button:disabled { opacity: .55; cursor: default; }
input, select, textarea { display: block; width: 100%; margin: 6px 0 16px; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 3px solid var(--accent-soft); outline-offset: 0; border-color: var(--accent);
}
input[aria-invalid=true] { border-color: var(--danger); }
label { display: block; font-size: 14px; font-weight: 600; }
.primary { width: 100%; background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; padding: 11px 14px; }
.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.hint, .switch, .optional, .note { color: var(--muted); font-size: 14px; font-weight: 400; }
.error { color: var(--danger); font-size: 14px; min-height: 20px; margin: 0 0 12px; }
.error:empty { min-height: 0; margin: 0; }
#status { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 10; margin: 0; max-width: calc(100% - 32px);
  padding: 10px 16px; border-radius: 999px; background: var(--text); color: var(--bg); font-size: 14px; box-shadow: var(--shadow); }
#status:empty { display: none; }

/* Sign-in and signup */
.brand-mark { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; letter-spacing: -.01em; }
.brand-mark img { border-radius: 10px; }
.brand-mark.compact { font-size: 16px; }
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.auth-brand {
  background: radial-gradient(120% 80% at 0% 0%, #1d4a33 0%, var(--brand-bg) 60%); color: var(--brand-text);
  padding: 48px clamp(32px, 6vw, 80px); display: flex; flex-direction: column; justify-content: center; gap: 28px;
}
.auth-brand h1 { font-size: clamp(28px, 3.2vw, 40px); line-height: 1.15; letter-spacing: -.02em; margin: 0; max-width: 17ch; }
.benefits { list-style: none; margin: 0; padding: 0; display: grid; gap: 18px; max-width: 420px; }
.benefits li { display: flex; gap: 14px; align-items: flex-start; }
.benefits strong { display: block; color: var(--brand-text); }
.benefits li > span:last-child { color: var(--brand-muted); font-size: 15px; }
.benefit-icon { flex: none; width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: rgba(108, 245, 180, .12); color: #6cf5b4; font-size: 14px; }
.pill-preview { display: flex; align-items: center; gap: 10px; max-width: 420px; padding: 10px 16px; border-radius: 999px; background: #000; border: 1px solid rgba(255,255,255,.14); font-size: 14px; color: #f5f5f7; }
.pill-preview > span:nth-child(2) { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill-dot { width: 8px; height: 8px; border-radius: 50%; background: #ff453a; box-shadow: 0 0 0 3px rgba(255,69,58,.2); flex: none; }
.pill-answer { color: #32d74b; font-size: 12px; flex: none; }
.auth-card { display: flex; flex-direction: column; justify-content: center; padding: 48px clamp(24px, 6vw, 72px); }
.auth-card form { width: 100%; max-width: 400px; margin: 0 auto; }
.auth-card .brand-mark.compact { display: none; }
.auth-card h2 { font-size: 28px; letter-spacing: -.02em; margin: 0 0 6px; }
.lede { color: var(--muted); margin: 0 0 24px; }
.google {
  display: flex; align-items: center; justify-content: center; gap: 12px; width: 100%; height: 44px; padding: 0 16px;
  border: 1px solid #747775; border-radius: 8px; background: #fff; color: #1f1f1f;
  font: 500 15px/1 Roboto, var(--font); text-decoration: none;
}
.google:hover { background: #f8f9fa; text-decoration: none; box-shadow: 0 1px 3px rgba(60,64,67,.2); }
@media (prefers-color-scheme: dark) { .google { background: #131314; color: #e3e3e3; border-color: #8e918f; } .google:hover { background: #1f1f20; } }
.divider { display: flex; align-items: center; gap: 12px; margin: 20px 0; color: var(--muted); font-size: 13px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.hint { margin: -10px 0 16px; }
.switch { text-align: center; margin: 20px 0 0; }
.handoff { min-height: 100vh; align-items: center; text-align: center; gap: 4px; }
.handoff h1 { font-size: 24px; margin: 12px 0 4px; }
.handoff p { color: var(--muted); margin: 0 0 20px; max-width: 360px; }
.handoff img { border-radius: 12px; }
.button-link { display: inline-block; width: auto; border-radius: 8px; padding: 11px 20px; text-decoration: none; }
.button-link:hover { text-decoration: none; }
@media (max-width: 860px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .auth-card { padding: 32px 16px; justify-content: flex-start; }
  .auth-card .brand-mark.compact { display: flex; justify-content: center; margin: 8px 0 28px; }
  .auth-card h2 { text-align: center; }
  .lede { text-align: center; }
}

/* Signed-in workspace */
.workspace { max-width: 1100px; margin: auto; padding: 24px 32px 48px; }
.toolbar { display: flex; align-items: center; gap: 16px; margin: 0 0 24px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.toolbar #identity { flex: 1; font-weight: 500; color: var(--muted); overflow-wrap: anywhere; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.keys { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 20px; margin-bottom: 20px; }
.keys h2 { margin: 0 0 4px; font-size: 18px; }
.keys .hint { margin: 0 0 16px; }
.key-row { padding: 14px 0; border-top: 1px solid var(--line); }
.key-heading { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.key-saved { color: var(--accent); font-family: var(--mono); font-size: 14px; }
.key-missing { color: var(--muted); font-size: 14px; }
.key-row form { display: flex; gap: 8px; flex-wrap: wrap; }
.key-row input { flex: 1; min-width: 220px; margin: 0; }
.key-row .error:empty { display: none; }
.key-row .error { margin: 8px 0 0; }
#keys-done { width: auto; margin-top: 8px; }
details { margin-bottom: 20px; }
summary { cursor: pointer; font-weight: 600; }
#settings { max-width: 460px; margin-top: 12px; }
.columns { display: grid; grid-template-columns: 260px 1fr; gap: 24px; }
aside button { display: block; width: 100%; margin-bottom: 8px; text-align: left; overflow-wrap: anywhere; }
.selected { border-color: var(--accent); background: var(--accent-soft); }
#detail { min-width: 0; padding: 20px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.message { white-space: pre-wrap; overflow-wrap: anywhere; border-bottom: 1px solid var(--line); padding: 14px 0; }
.message strong { display: block; color: var(--accent); font-size: 12px; margin-bottom: 6px; }
textarea { min-height: 100px; }
@media (max-width: 650px) {
  .workspace { padding: 16px; }
  .toolbar { flex-wrap: wrap; }
  .columns { grid-template-columns: 1fr; }
  #chats { max-height: 230px; overflow: auto; }
}
