:root {
  color-scheme: dark;
  --bg: #0e1716;
  --rail: #111e1b;
  --panel: #172623;
  --panel-hover: #20332d;
  --line: #2a4139;
  --text: #eff7f1;
  --muted: #a7bab1;
  --accent: #aaf0ce;
  --accent-deep: #152e24;
  --error: #ffc0a5;
  --content-width: 760px;
  font: 16px/1.55 "Avenir Next", "Segoe UI", system-ui, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
button, textarea { font: inherit; }
button { cursor: pointer; color: inherit; }
button:disabled { cursor: default; }
button:focus-visible, textarea:focus-visible, [tabindex]:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
[hidden] { display: none !important; }
.sr-only, .skip-link:not(:focus) {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.skip-link { position: fixed; top: 12px; left: 12px; padding: 8px 12px; color: var(--accent); background: var(--bg); z-index: 5; }
.workspace {
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}
.rail {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 25px 17px 17px;
  background: var(--rail);
  border-right: 1px solid var(--line);
}
.wordmark { display: flex; align-items: center; gap: 11px; padding-left: 8px; font-size: 22px; letter-spacing: -.045em; }
.wordmark strong { font-weight: 720; }
.wordmark strong span { color: var(--muted); font-weight: 560; }
.emblem {
  display: inline-grid;
  place-items: center;
  position: relative;
  flex: 0 0 auto;
  width: 32px;
  aspect-ratio: 1;
  background: var(--accent-deep);
  color: var(--accent);
  border: 1px solid #456f5a;
  border-radius: 10px;
}
.emblem::before {
  content: "";
  width: 53%;
  height: 53%;
  background: currentColor;
  clip-path: polygon(50% 0, 63% 37%, 100% 50%, 63% 63%, 50% 100%, 37% 63%, 0 50%, 37% 37%);
}
.emblem::after { content: ""; width: 8%; aspect-ratio: 1; position: absolute; right: 20%; top: 20%; background: currentColor; border-radius: 50%; }
.new-chat {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 45px;
  margin-top: 34px;
  padding: 8px 12px;
  border: 1px solid #496d5c;
  border-radius: 12px;
  background: var(--accent-deep);
  font-size: 14px;
  font-weight: 650;
  color: var(--accent);
}
.new-chat:hover { background: #254536; }
.history { flex: 1; min-height: 0; overflow: auto; margin: 29px -5px 0; padding: 0 5px; }
.history h2 { margin: 0 0 6px 8px; font-size: 13px; color: var(--muted); font-weight: 600; }
.history ul { display: grid; gap: 3px; margin: 0; padding: 0; list-style: none; }
.history li { display: grid; grid-template-columns: minmax(0, 1fr) 44px; align-items: center; }
.history li button {
  width: 100%;
  min-height: 44px;
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 5px 8px;
  font-size: 14px;
}
.history li button:hover, .history li button[aria-current="true"] { background: var(--panel-hover); border-color: var(--line); }
.history li .delete-chat { display: grid; place-items: center; width: 44px; padding: 0; color: var(--muted); }
.history li .delete-chat:hover:not(:disabled) { color: var(--error); }
.history li .delete-chat:disabled { opacity: .5; }
.trash::before, .trash::after { content: ""; position: absolute; }
.trash::before { inset: 5px 4px 2px; border: 1px solid currentColor; border-radius: 0 0 2px 2px; }
.trash::after { top: 4px; inset-inline: 2px; border-top: 1px solid currentColor; box-shadow: 0 -3px 0 -0.25px currentColor; }
.history-empty { margin: 10px 8px; color: var(--muted); font-size: 13px; }
.history-feedback { margin-top: 8px; padding: 6px 8px 0; border-top: 1px solid var(--line); }
.history-feedback p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.history-feedback button { min-height: 44px; padding: 4px 6px; margin-left: -6px; color: var(--accent); background: transparent; border: 0; border-radius: 8px; font-size: 13px; }
.history-feedback button:hover { background: var(--panel-hover); }
.rail-note { display: flex; align-items: center; gap: 8px; margin: 14px 4px 0; padding-top: 15px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.chat { display: grid; min-width: 0; min-height: 0; grid-template-rows: auto minmax(0, 1fr) auto; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 69px; padding: 8px clamp(16px, 3.6vw, 44px); border-bottom: 1px solid var(--line); }
.topbar-title { display: flex; align-items: center; min-width: 0; gap: 7px; font-size: 15px; font-weight: 650; }
#chat-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.model-status {
  display: flex;
  align-items: center;
  min-height: 44px;
  gap: 10px;
  flex: 0 0 auto;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  font-size: 12px;
}
.model-status:hover { background: var(--panel-hover); }
.model-name { font-weight: 650; }
.status-label { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
[data-state="ready"] .status-label { color: var(--accent); }
[data-state="offline"] .status-label { color: var(--error); }
.icon-button { display: grid; place-items: center; width: 44px; min-width: 44px; height: 44px; border-radius: 11px; border: 0; background: transparent; }
.menu-button, .scrim { display: none; }
.icon { display: inline-block; width: 17px; height: 17px; position: relative; flex: 0 0 auto; }
.plus::before, .plus::after, .menu-icon::before, .menu-icon::after, .arrow::before, .arrow::after, .square::before, .laptop::before, .laptop::after { content: ""; position: absolute; }
.plus::before, .plus::after { background: currentColor; border-radius: 1px; top: 50%; left: 50%; transform: translate(-50%, -50%); }
.plus::before { width: 12px; height: 2px; }
.plus::after { width: 2px; height: 12px; }
.menu-icon::before, .menu-icon::after { left: 0; right: 0; height: 2px; background: currentColor; border-radius: 1px; }
.menu-icon::before { top: 5px; }
.menu-icon::after { bottom: 5px; }
.laptop::before { inset: 2px 3px 5px; border: 1px solid currentColor; border-radius: 2px; }
.laptop::after { bottom: 2px; left: 1px; right: 1px; border-bottom: 1px solid currentColor; }
.arrow::before { top: 3px; left: 7px; width: 2px; height: 12px; border-radius: 1px; background: currentColor; }
.arrow::after { top: 3px; left: 3px; width: 10px; height: 10px; border-top: 2px solid; border-left: 2px solid; transform: rotate(45deg); }
.square::before { inset: 4px; background: currentColor; border-radius: 2px; }
.viewport { display: flex; flex-direction: column; overflow: auto; padding: 0 24px; scroll-padding: 24px; }
.viewport:focus-visible { outline-offset: -2px; }
.welcome { width: 100%; max-width: var(--content-width); margin: auto; padding: 28px 0 37px; text-align: center; }
.signal { position: relative; width: min(100%, 340px); height: 136px; display: grid; place-items: center; margin: 0 auto 1px; isolation: isolate; }
.signal::before { content: ""; position: absolute; inset: 0; z-index: -1; background: radial-gradient(ellipse, #315c4859 0%, transparent 67%); }
.orbit { position: absolute; border: 1px solid #55826c55; border-radius: 50%; transform: rotate(-12deg); }
.orbit-wide { width: 78%; height: 68%; }
.orbit-mid { width: 66%; height: 51%; }
.orbit-close { width: 49%; height: 36%; }
.orbit-mid::after, .orbit-wide::after { content: ""; position: absolute; width: 5px; height: 5px; border-radius: 50%; background: #8acaab; }
.orbit-wide::after { top: 16%; right: 10%; }
.orbit-mid::after { bottom: 14%; left: 10%; opacity: .65; }
.emblem-large { width: 67px; border-radius: 19px; background: #1d382d; box-shadow: 0 9px 35px #07110e99, inset 0 0 16px #91cfa416; transform: rotate(-7deg); }
.welcome h1 { margin: 0; line-height: 1.03; font-size: clamp(41px, 6.4vw, 76px); font-weight: 650; letter-spacing: -.075em; }
.welcome-copy p { margin: 17px auto 0; max-width: 410px; color: var(--muted); text-wrap: balance; }
.suggestions { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin-top: 28px; }
.suggestions button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  font-size: 13px;
}
.suggestions button:hover { background: var(--panel-hover); }
.suggestions span { color: var(--accent); }
.messages { display: flex; flex-direction: column; width: 100%; max-width: var(--content-width); margin: 0 auto; gap: 26px; padding: 30px 0; }
.message { max-width: 100%; min-width: 0; }
.message[data-role="user"] { align-self: flex-end; max-width: min(88%, 620px); padding: 11px 16px; background: var(--panel-hover); border: 1px solid var(--line); border-radius: 15px 15px 4px 15px; }
.message[data-role="assistant"] { padding: 0 0 0 14px; border-left: 2px solid #4e8269; }
.message h2 { margin: 0 0 5px; color: var(--accent); font-size: 13px; font-weight: 670; }
.message[data-role="user"] h2 { color: var(--muted); }
.message-body { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.message-actions { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.message-actions button { min-height: 44px; color: var(--muted); background: transparent; padding: 4px 7px; border: 0; border-radius: 7px; font-size: 13px; }
.message-actions button:hover { background: var(--panel); color: var(--text); }
.reply-sources { margin: 12px 0 0; font-size: 13px; color: var(--muted); }
.reply-sources ul { margin: 4px 0 0; padding-inline-start: 19px; }
.reply-sources a { color: var(--accent); overflow-wrap: anywhere; }
.reply-note { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.search-options { display: flex; align-items: center; gap: 3px 12px; flex-wrap: wrap; margin-bottom: 5px; }
.search-options label { display: flex; align-items: center; min-height: 44px; padding-inline: 7px; gap: 6px; font-size: 14px; cursor: pointer; }
.search-options input { width: 16px; height: 16px; accent-color: var(--accent); }
.search-options span { color: var(--muted); font-size: 12px; }
.correction-dialog { width: min(520px, calc(100% - 32px)); max-height: 90dvh; padding: 22px; border: 1px solid var(--line); border-radius: 16px; background: var(--rail); color: var(--text); }
.correction-dialog::backdrop { background: #030a08b3; }
.correction-dialog h2 { margin: 0; font-size: 23px; }
#correction-question { max-height: 95px; overflow: auto; margin: 8px 0 18px; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.correction-dialog label { display: block; margin-bottom: 6px; }
.correction-dialog textarea { width: 100%; min-height: 110px; padding: 10px; border: 1px solid var(--line); border-radius: 9px; color: var(--text); background: var(--bg); resize: vertical; }
.correction-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 13px; }
.correction-actions button { min-height: 44px; padding: 6px 13px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
#correction-save { background: var(--accent); color: var(--accent-deep); font-weight: 650; }
.composer-area { width: min(100% - 48px, var(--content-width)); margin: 0 auto; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
.activity { min-height: 23px; padding: 0 3px; color: var(--muted); font-size: 13px; }
.notice { margin: 0; padding: 5px 3px; color: var(--error); font-size: 14px; }
#composer { display: flex; align-items: flex-end; gap: 10px; border: 1px solid #496456; border-radius: 17px; padding: 9px; background: var(--panel); }
#composer:focus-within { border-color: var(--accent); }
#prompt {
  display: block;
  flex: 1;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  max-height: min(30dvh, 180px);
  padding: 10px 7px;
  color: var(--text);
  background: transparent;
  border: 0;
  resize: none;
  line-height: 24px;
}
#prompt::placeholder { color: var(--muted); opacity: 1; }
#prompt:focus-visible { outline: 0; }
.send { color: #0e251a; background: var(--accent); }
.send:hover:not(:disabled) { background: #dcfbe9; }
.send:disabled { color: #9ab5a6; background: #284137; }
.composer-note { min-height: 25px; display: flex; justify-content: space-between; align-items: flex-end; gap: 8px; padding: 3px; font-size: 12px; color: var(--muted); }
@media (max-width: 760px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .rail { display: none; position: fixed; inset: 0 auto 0 0; z-index: 3; width: min(82vw, 275px); box-shadow: 12px 0 36px #040b08a6; }
  .rail.open { display: flex; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 2; background: #030a08b3; border: 0; }
  .menu-button { display: grid; margin-left: -8px; }
  .topbar { min-height: 61px; gap: 8px; }
  .viewport { padding: 0 16px; }
  .composer-area { width: calc(100% - 32px); }
}
@media (max-width: 480px) {
  .model-name, .keyboard-hint { display: none; }
  .welcome { padding: 17px 0 22px; }
  .signal { height: 112px; }
  .welcome-copy p { max-width: 272px; font-size: 14px; }
  .suggestions { margin-top: 17px; }
  .suggestions button { font-size: 12px; padding-inline: 9px; }
}
@media (max-height: 520px) {
  .signal { display: none; }
  .welcome { padding-block: 15px; }
}

.logout-form { margin-top: 10px; }
.logout-form button {
  width: 100%;
  min-height: 44px;
  padding: 6px 8px;
  text-align: left;
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: 9px;
  font-size: 14px;
}
.logout-form button:hover { background: var(--panel-hover); color: var(--text); }
[data-state="expired"] .status-label { color: var(--error); }
.account-link {
  display: flex;
  align-items: center;
  min-height: 44px;
  margin-top: 10px;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: 9px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
}
.account-link:hover { background: var(--panel-hover); color: var(--text); }
.account-link + .logout-form { margin-top: 0; }
.saved-corrections { min-height: 44px; padding: 6px 8px; margin-top: 8px; text-align: left; background: transparent; color: var(--muted); border: 1px solid transparent; border-radius: 9px; font-size: 14px; }
.saved-corrections:hover { background: var(--panel-hover); color: var(--text); }
.saved-corrections + .account-link { margin-top: 0; }
.corrections-list { list-style: none; margin: 14px 0 0; padding: 0; max-height: min(48vh, 340px); overflow: auto; }
.corrections-list li { border-top: 1px solid var(--line); padding: 8px 0; overflow-wrap: anywhere; }
.corrections-list p { margin: 4px 0; color: var(--muted); white-space: pre-wrap; }
.corrections-list button { min-height: 44px; background: transparent; color: var(--error); border: 0; padding: 4px 6px; border-radius: 8px; }
.corrections-list button:hover { background: var(--panel-hover); }
