:root {
  color-scheme: dark;
  --bg: #212121;
  --side: #171717;
  --panel: #2f2f2f;
  --line: #3d3d3d;
  --text: #ececec;
  --muted: #afafaf;
  --acc: #10a37f;
  --acc-text: #04150f;
  --user: #2f2f2f;
  --danger: #ef4444;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: ui-sans-serif, system-ui, Segoe UI, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
.hidden { display: none !important; }
.login-wrap {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(800px 400px at 50% -10%, #2a3d34 0%, var(--bg) 55%);
}
.login-card {
  width: min(420px, 100%);
  background: var(--side);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px;
}
.mark {
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--acc); color: var(--acc-text);
  display: grid; place-items: center; font-weight: 800; margin-bottom: 14px;
}
.mark.sm { width: 32px; height: 32px; font-size: 13px; margin: 0; }
h1 { margin: 0 0 8px; font-size: 1.4rem; }
h2 { margin: 0; font-size: 1.1rem; }
p, .hint { color: var(--muted); line-height: 1.45; }
label { display: block; margin: 14px 0 6px; font-size: 13px; color: var(--muted); }
input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #111;
  color: var(--text);
  border-radius: 10px;
  padding: 11px 12px;
  font: inherit;
}
.login-actions { display: flex; gap: 10px; margin-top: 18px; }
.google-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin: 18px 0 0; padding: 11px 12px; border-radius: 10px;
  background: #fff; color: #1f1f1f; font-weight: 600; font-size: 14px;
  text-decoration: none; border: 1px solid #dadce0;
}
.google-btn:hover { background: #f5f5f5; }
.or {
  display: flex; align-items: center; gap: 10px;
  margin: 16px 0 4px; color: var(--muted); font-size: 12px;
}
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.btn {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
}
.btn.primary { background: var(--acc); color: var(--acc-text); border: 0; }
.btn.ghost { background: transparent; }
.btn.full { width: 100%; }
.btn.danger { color: var(--danger); }
.err { color: #ff8aa0; min-height: 1.2em; margin-top: 12px; font-size: 14px; }
.app { display: grid; grid-template-columns: 280px 1fr; height: 100%; }
aside {
  background: var(--side);
  border-right: 1px solid #000;
  display: flex; flex-direction: column; min-width: 0;
}
.aside-top, .aside-bottom { padding: 14px; }
.brand { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; }
.brand-name { font-weight: 700; }
.brand-sub { color: var(--muted); font-size: 12px; }
.chat-list { flex: 1; overflow: auto; padding: 0 8px 8px; }
.chat-item {
  display: flex; align-items: center; gap: 6px;
  padding: 9px 10px; border-radius: 10px; cursor: pointer; color: var(--muted);
}
.chat-item:hover, .chat-item.active { background: #262626; color: var(--text); }
.chat-item span { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 14px; }
.chat-item .x { opacity: 0; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.chat-item:hover .x { opacity: 1; }
.gpu { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.gpu.warm { color: #86efac; }
.user-row { display: flex; gap: 10px; align-items: center; margin-top: 10px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: #444; display: grid; place-items: center; font-size: 12px; font-weight: 700;
}
.user-meta { min-width: 0; }
.user-meta div { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0; font: inherit; font-size: 12px; }
main { display: grid; grid-template-rows: auto 1fr auto; min-width: 0; }
header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 20px; border-bottom: 1px solid #2a2a2a;
}
.thread { overflow: auto; padding: 24px 16px 8px; }
.empty { max-width: 640px; margin: 12vh auto 0; text-align: center; }
.empty h2 { margin: 12px 0 8px; font-size: 28px; }
.msg { max-width: 760px; margin: 0 auto 22px; display: flex; gap: 14px; }
.msg .who {
  width: 28px; height: 28px; border-radius: 8px; flex: none;
  display: grid; place-items: center; font-size: 11px; font-weight: 800;
}
.msg.user .who { background: #4b5563; }
.msg.assistant .who { background: var(--acc); color: var(--acc-text); }
.bubble { min-width: 0; flex: 1; line-height: 1.65; }
.bubble p { margin: 0 0 10px; }
.bubble pre {
  overflow: auto; background: #0d0d0d; padding: 12px; border-radius: 10px; font-size: 13px;
}
.think {
  background: #191919; border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 10px; margin-bottom: 10px; color: var(--muted); font-size: 13px;
}
.think summary { cursor: pointer; }
.status-line { max-width: 760px; margin: 0 auto 16px; color: var(--muted); font-size: 14px; }
.composer {
  display: flex; flex-direction: column; gap: 6px;
  max-width: 760px; width: calc(100% - 32px); margin: 0 auto 18px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 26px; padding: 8px 8px 10px 16px;
}
.composer-row { display: flex; gap: 10px; align-items: flex-end; }
.composer textarea {
  border: 0; background: transparent; resize: none; max-height: 180px; padding: 10px 0;
  field-sizing: content;
}
.composer-tools {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 0 4px; font-size: 12px; color: var(--muted);
}
.tool { display: flex; align-items: center; gap: 6px; }
.tool select {
  width: auto; padding: 3px 6px; border-radius: 8px; font-size: 12px;
  border: 1px solid var(--line); background: #111; color: var(--text); cursor: pointer;
}
.tool.checkbox { cursor: pointer; }
.tool.checkbox input { width: auto; cursor: pointer; }
.tool-hint { margin-left: auto; opacity: .75; }
.send {
  border: 0; background: var(--text); color: #111; border-radius: 50%;
  width: 36px; height: 36px; font-weight: 700; cursor: pointer; font-size: 12px;
}
.send:disabled { opacity: .4; cursor: default; }
.icon-btn { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 16px; }
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  display: grid; place-items: center; padding: 20px;
}
.modal-card {
  width: min(520px, 100%); background: var(--side); border: 1px solid var(--line);
  border-radius: 16px; padding: 18px;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.key-create { display: flex; gap: 8px; margin: 12px 0; }
.key-row {
  display: flex; justify-content: space-between; gap: 8px; align-items: center;
  border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-top: 8px; font-size: 13px;
}
.newkey { color: #86efac; font-size: 13px; word-break: break-all; }
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  aside { display: none; }
}
