:root {
  color-scheme: dark;
  font-family: "Segoe UI", system-ui, sans-serif;
  color: #e7eced;
  background: #11171b;
  --base: #11171b;
  --panel: #151c20;
  --layer: #1d282d;
  --line: #304149;
  --muted: #a6b7bd;
  --accent: #a8efc5;
  --dark-accent: #153b2b;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; color: inherit; border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 9px 12px; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:disabled { opacity: .55; cursor: default; }
.primary { color: #13241b; background: var(--accent); border-color: var(--accent); font-weight: 650; }
.quiet { background: transparent; }
.shell { display: grid; grid-template-columns: minmax(240px, 300px) minmax(0, 1fr); height: var(--tg-viewport-stable-height, 100dvh); }
.shell:has(+ .gate:not([hidden])) { visibility: hidden; }
.sidebar { display: flex; flex-direction: column; min-height: 0; background: var(--panel); border-right: 1px solid var(--line); padding: 24px 17px; }
.sidebar-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 8px; margin-bottom: 22px; }
.device { color: var(--accent); font-size: .875rem; }
h1, h2, p { margin: 0; }
h1 { font-size: 2rem; font-weight: 650; letter-spacing: -.04em; }
h2 { font-size: 1.15rem; }
.create { white-space: nowrap; font-size: .875rem; }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tabs button { flex: 1; white-space: nowrap; font-size: .875rem; }
.tabs button[aria-pressed="true"] { color: var(--accent); background: var(--dark-accent); border-color: #385b4b; }
.search { display: flex; gap: 10px; align-items: center; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); }
.search input { background: transparent; border: 0; color: #e7eced; width: 100%; min-width: 0; }
.chat-list { display: grid; align-content: start; gap: 4px; overflow: auto; margin-top: 12px; }
.chat-choice { padding: 11px; text-align: left; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; border-color: transparent; }
.chat-choice:hover, .chat-choice[aria-current="true"] { background: var(--dark-accent); color: var(--accent); }
.panel { display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto; min-width: 0; min-height: 0; }
.top { padding: 18px 24px 0; border-bottom: 1px solid var(--line); background: var(--panel); }
.headline { display: flex; gap: 12px; align-items: center; justify-content: space-between; min-height: 36px; }
.headline h2 { text-overflow: ellipsis; overflow: hidden; white-space: nowrap; flex: 1; }
.back { display: none; }
.settings { display: flex; gap: 10px; margin: 10px 0; flex-wrap: wrap; }
.settings label { display: flex; gap: 6px; align-items: center; min-width: 0; color: var(--muted); font-size: .875rem; }
select { border: 1px solid var(--line); border-radius: 7px; padding: 5px; background: var(--base); color: #e7eced; max-width: min(35vw, 230px); }
.status { border-top: 1px solid var(--line); color: var(--muted); font-size: .875rem; }
.status summary { cursor: pointer; min-height: 41px; padding: 10px 0; display: flex; gap: 18px; flex-wrap: wrap; list-style: none; }
.status summary span:last-child { text-decoration: underline; text-underline-offset: 3px; }
.indicator { color: var(--accent); }
#status-details { padding: 7px 0 12px; line-height: 1.55; }
.messages { overflow: auto; display: grid; align-content: start; gap: 22px; padding: 24px max(24px, calc((100% - 840px) / 2)); }
.message { max-width: 100%; min-width: 0; line-height: 1.6; overflow-wrap: anywhere; }
.message.user { justify-self: end; max-width: min(88%, 700px); border: 1px solid var(--line); background: var(--layer); padding: 10px 14px; border-radius: 12px 12px 2px 12px; }
.message .role { color: var(--muted); font-size: .875rem; margin-bottom: 5px; }
.message .text { white-space: pre-wrap; }
pre { margin: 10px 0; padding: 12px; background: #0d1317; border: 1px solid var(--line); border-radius: 7px; overflow: auto; }
.notice { padding: 8px 24px; color: #f8cb97; background: #28221b; }
.archive-footer { padding: 14px 24px max(14px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); color: var(--muted); }
.composer { display: flex; align-items: flex-end; gap: 8px; padding: 12px 24px max(12px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--panel); }
.composer textarea, dialog input { color: inherit; background: var(--base); border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.composer textarea { flex: 1; min-width: 0; resize: vertical; min-height: 44px; max-height: 35vh; }
.gate { position: fixed; inset: 0; display: grid; place-content: center; gap: 8px; padding: 28px; text-align: center; }
.gate p:last-child { color: var(--muted); }
dialog { color: inherit; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; width: min(94%, 400px); }
dialog input { width: 100%; margin: 14px 0; }
dialog::backdrop { background: #090d11c7; }
.dialog-buttons { display: flex; justify-content: flex-end; gap: 8px; }
@media (max-width: 640px) {
  .shell { display: block; }
  .sidebar, .panel { height: 100%; }
  .shell[data-view="chats"] .panel, .shell[data-view="chat"] .sidebar { display: none; }
  .back { display: inline-block; }
  .top { padding: 12px 13px 0; }
  .messages, .composer, .notice { padding-left: 13px; padding-right: 13px; }
  .settings { flex-wrap: nowrap; }
  .status summary { gap: 11px; }
}
