:root {
  --bg: #030a05;
  --panel: #06130a;
  --green: #22e07a;
  --green-dim: #14803f;
  --text: #d9f7e6;
  --muted: #7fa890;
  --border: #0f3d24;
  --danger: #ffb4a8;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: radial-gradient(ellipse at 50% -10%, #0a2a16 0%, var(--bg) 55%);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.hidden { display: none !important; }
.brand { letter-spacing: 0.5em; font-weight: 500; margin: 8px 0; text-align: center; color: var(--text); }
.brand-small { font-size: 1.1rem; margin: 0; text-align: left; letter-spacing: 0.4em; }
.error, .notice { color: var(--danger); min-height: 1.4em; margin: 4px 0; font-size: 0.9rem; text-align: center; }

.login { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; }
.login-form { width: min(360px, 100%); display: flex; flex-direction: column; gap: 14px; }
.login-form label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 0.9rem; }
input, textarea {
  background: #040f08; color: var(--text); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; font: inherit; width: 100%;
}
input:focus, textarea:focus { outline: 2px solid var(--green-dim); border-color: var(--green); }
.btn {
  background: linear-gradient(180deg, #1fcf72, #138a47); color: #02150a; border: 0; border-radius: 10px;
  padding: 12px 20px; font: inherit; font-weight: 700; cursor: pointer;
}
.btn:hover { filter: brightness(1.1); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-full { width: 100%; }
.link-btn { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 8px; font: inherit; text-decoration: underline; }
.icon-btn { background: none; border: 1px solid var(--border); color: var(--green); border-radius: 8px; padding: 6px 10px; font-size: 1.1rem; cursor: pointer; display: none; }

.sphere-big { width: 180px; height: 180px; }
.sphere-small { width: 56px; height: 56px; flex: none; }

.app { display: grid; grid-template-columns: 280px 1fr; height: 100%; }
.sidebar { background: var(--panel); border-right: 1px solid var(--border); padding: 14px; display: flex; flex-direction: column; gap: 12px; overflow: hidden; }
.conv-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.conv-item { display: flex; align-items: center; gap: 4px; border-radius: 8px; border: 1px solid transparent; }
.conv-item.active { background: #0a2214; border-color: var(--border); }
.conv-item button.open { flex: 1; text-align: left; background: none; border: 0; color: var(--text); padding: 10px; cursor: pointer; font: inherit; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-item button.mini { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 6px; font-size: 0.9rem; }
.conv-item button.mini:hover { color: var(--green); }

.chat { display: flex; flex-direction: column; min-width: 0; height: 100%; padding: 0 16px 10px; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 12px 0; }
.status { color: var(--green); font-size: 0.75rem; letter-spacing: 0.3em; text-transform: uppercase; }
.messages { flex: 1; overflow-y: auto; padding: 8px 0; display: flex; flex-direction: column; gap: 14px; }
.empty { color: var(--muted); text-align: center; margin-top: 12vh; }
.msg { max-width: min(760px, 92%); padding: 12px 16px; border-radius: 14px; border: 1px solid var(--border); overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: #0b2a18; white-space: pre-wrap; }
.msg.assistant { align-self: flex-start; background: var(--panel); }
.msg.assistant p, .msg.assistant ul { margin: 0 0 0.6em; }
.msg.assistant p:last-child, .msg.assistant ul:last-child { margin-bottom: 0; }
.msg pre { background: #020805; border: 1px solid var(--border); border-radius: 8px; padding: 10px; overflow-x: auto; margin: 0 0 0.6em; }
.msg code { font-family: ui-monospace, Consolas, monospace; font-size: 0.92em; color: var(--green); }
.msg pre code { color: var(--text); }
.msg .more { background: none; border: 0; color: var(--green); text-decoration: underline; cursor: pointer; padding: 0; font: inherit; }
.composer { display: flex; gap: 10px; align-items: flex-end; }
.composer textarea { resize: none; max-height: 200px; }
.footnote { color: var(--muted); font-size: 0.75rem; text-align: center; margin: 6px 0 0; }

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .icon-btn { display: inline-block; }
  .sidebar { position: fixed; inset: 0 25% 0 0; z-index: 5; transform: translateX(-102%); transition: transform 0.2s; }
  .sidebar.open { transform: translateX(0); }
}
@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }
