:root {
  color-scheme: light;
  --surface: #fbfbfd;
  --panel: #eef0f7;
  --ink: #23283b;
  --muted: #626b80;
  --border: #dbe0eb;
  --accent: #3449a5;
  --active: #e0e5fa;
  font: 16px/1.5 system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--ink);
  background: var(--surface);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { display: grid; grid-template-columns: 245px minmax(0, 1fr); margin: 0; height: 100vh; height: 100dvh; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
button:focus-visible, a:focus-visible, textarea:focus-visible, select:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.sidebar { padding: 25px 15px; background: var(--panel); border-right: 1px solid var(--border); min-height: 0; display: flex; flex-direction: column; gap: 14px; }
.brand { padding: 0 10px; font-size: 22px; font-weight: 720; letter-spacing: -.055em; }
.new-chat, .quiet-button, select { border: 1px solid var(--border); border-radius: 9px; padding: 8px 12px; background: var(--surface); }
.new-chat { text-align: left; color: var(--accent); font-weight: 650; min-height: 44px; }
.new-chat span { margin-right: 7px; }
.sidebar nav { overflow: auto; display: grid; align-content: start; gap: 4px; }
.chat-link { border: 0; background: transparent; text-align: left; padding: 8px 10px; border-radius: 8px; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.chat-link:hover, .icon-button:hover { background: var(--panel); }
.chat-link[aria-current="true"], .chat-link:hover { background: var(--active); }
.chat-link[aria-current="true"] { color: var(--accent); }
main { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-height: 0; min-width: 0; }
.topbar { display: flex; gap: 12px; align-items: center; padding: 14px 23px; border-bottom: 1px solid var(--border); }
.heading { flex: 1; min-width: 0; }
.heading h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 17px; margin: 0; }
#connection { color: var(--muted); font-size: 12px; }
.quiet-button { white-space: nowrap; font-size: 14px; }
.icon-button { border: 0; border-radius: 8px; width: 40px; height: 40px; display: inline-grid; place-items: center; background: transparent; flex: 0 0 auto; }
.sidebar-toggle, .scrim { display: none; }
.scroll { overflow: auto; }
.messages { max-width: 800px; margin: auto; min-height: 100%; padding: clamp(18px, 5vw, 42px); display: flex; flex-direction: column; gap: 22px; }
.empty { margin: auto; color: var(--muted); text-align: center; }
.message { min-width: 0; }
.message.assistant { padding: 0 0 16px; border-bottom: 1px solid var(--border); }
.message.user { align-self: end; max-width: min(90%, 610px); background: #e9edfb; padding: 11px 15px; border-radius: 14px 14px 4px 14px; }
.message.user .text { white-space: pre-wrap; }
.message-header { display: flex; justify-content: space-between; align-items: center; min-height: 32px; font-size: 13px; font-weight: 630; color: var(--accent); }
.message-header .icon-button { width: 34px; height: 34px; }
.text { overflow-wrap: anywhere; }
.text > :first-child { margin-top: 0; }
.text > :last-child { margin-bottom: 0; }
.text pre { padding: 12px; overflow: auto; border: 1px solid var(--border); background: #f1f3f9; border-radius: 9px; }
.text code, #file-text { font-family: ui-monospace, SFMono-Regular, monospace; font-size: .88em; }
.text code { overflow-wrap: normal; }
.text a { color: var(--accent); }
.text blockquote { margin: 12px 0; padding-left: 12px; border-left: 3px solid var(--border); color: var(--muted); }
.message-file { margin: 0 0 4px; font-size: 12px; color: var(--muted); }
.waiting { color: var(--muted); font-size: 14px; }
.composer-area { width: min(100%, 800px); margin: auto; padding: 0 clamp(15px, 4vw, 34px) calc(14px + env(safe-area-inset-bottom)); }
.composer { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 8px; padding: 8px; border: 1px solid var(--border); border-radius: 15px; background: white; }
.composer textarea { min-width: 0; border: 0; padding: 8px; resize: vertical; max-height: 180px; background: transparent; }
#send, #save { background: var(--accent); border: 1px solid var(--accent); color: white; font-weight: 650; padding: 8px 14px; min-height: 42px; border-radius: 8px; }
#notice, #file-notice { margin: 5px 0 7px; font-size: 13px; color: #8a3044; }
.attachment { grid-column: 1 / -1; display: flex; align-items: center; gap: 5px; padding-left: 8px; color: var(--muted); font-size: 13px; }
.attachment span { min-width: 0; overflow-wrap: anywhere; }
.attachment .icon-button { height: 30px; width: 32px; }
dialog { width: min(calc(100% - 20px), 720px); border: 1px solid var(--border); border-radius: 17px; padding: 0; background: var(--surface); color: var(--ink); }
dialog::backdrop { background: #1b223677; }
.files-panel { display: grid; gap: 12px; padding: clamp(14px, 4vw, 24px); }
.files-panel header, .file-toolbar, .file-actions { display: flex; align-items: center; gap: 8px; }
.files-panel h2 { margin: 0; flex: 1; font-size: 18px; }
.file-toolbar select { min-width: 0; flex: 1; }
#editor { display: grid; gap: 8px; }
#editor input, #editor textarea { width: 100%; min-width: 0; border: 1px solid var(--border); background: white; border-radius: 8px; padding: 8px 10px; }
#editor textarea { resize: vertical; }
.file-actions { justify-content: end; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.temporary { display: block; }
.temporary main { height: 100%; }
.temporary .composer { grid-template-columns: auto minmax(0, 1fr) auto; }
#conversation-picker { width: min(calc(100% - 24px), 460px); }
#conversation-list { display: grid; gap: 4px; max-height: min(56dvh, 420px); overflow-y: auto; }
#conversation-list .chat-link { display: grid; min-width: 0; }
#conversation-list .chat-link span { overflow: hidden; text-overflow: ellipsis; }
#conversation-list small, #conversation-status { color: var(--muted); font-size: 13px; }
#conversation-status { margin: 0; }
.composer-settings {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 2px 2px 0;
  border-top: 1px solid #eceef4;
}
.model-options { display: flex; min-width: 0; gap: 2px; align-items: center; }
.composer-select { position: relative; min-width: 0; color: var(--muted); }
.composer-select:first-child { max-width: 11rem; }
.composer-select::after {
  content: "";
  position: absolute;
  right: 9px;
  top: calc(50% - 4px);
  width: 5px;
  height: 5px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  pointer-events: none;
}
.composer-select:has(select:disabled)::after { opacity: .4; }
.composer-select select, .composer-action {
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 550;
  line-height: 1.3;
  min-height: 32px;
}
.composer-select select {
  appearance: none;
  display: block;
  max-width: 100%;
  field-sizing: content;
  padding: 5px 22px 5px 8px;
  text-overflow: ellipsis;
  cursor: pointer;
}
.composer-select select:disabled { cursor: default; opacity: .58; }
.composer-select select:enabled:hover, .composer-action:enabled:hover { background: var(--panel); color: var(--ink); }
.composer-actions { display: flex; flex: none; margin-left: auto; gap: 2px; }
.composer-action { padding: 5px 8px; display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.composer-action[aria-pressed="true"], .composer-action[aria-pressed="true"]:enabled:hover {
  background: var(--active);
  color: var(--accent);
}
.search-icon { position: relative; flex: 0 0 13px; height: 13px; }
.search-icon::before, .search-icon::after { content: ""; position: absolute; }
.search-icon::before { width: 7px; height: 7px; top: 1px; left: 1px; border: 1.5px solid currentColor; border-radius: 50%; }
.search-icon::after { width: 5px; height: 1.5px; top: 9px; left: 8px; background: currentColor; transform: rotate(45deg); }
.quota-icon {
  flex: 0 0 13px;
  height: 13px;
  background:
    linear-gradient(currentColor, currentColor) 1px 11px / 2px 2px no-repeat,
    linear-gradient(currentColor, currentColor) 5px 7px / 2px 6px no-repeat,
    linear-gradient(currentColor, currentColor) 9px 3px / 2px 10px no-repeat;
}
@media (pointer: coarse) {
  .composer-select select, .composer-action { min-height: 42px; }
}
@media (max-width: 400px) {
  .composer-settings { gap: 3px; }
  .composer-select select { padding-inline: 5px 16px; }
  .composer-select::after { right: 6px; }
  .composer-action { padding-inline: 5px; }
  .search-icon, .quota-icon { display: none; }
}
#quota-picker { width: min(calc(100% - 32px), 390px); box-shadow: 0 15px 60px #1b223626; }
#quota-picker::backdrop { background: #1b22364a; }
#quota-picker .files-panel { padding: 14px 18px 16px; }
#quota-title { font-size: 16px; }
#close-quota { width: 34px; height: 34px; }
#quota-windows, .quota-group, .quota-window { display: grid; gap: 8px; min-width: 0; }
#quota-windows { max-height: min(52dvh, 400px); overflow-y: auto; }
.quota-group h3 { font-size: 14px; margin: 4px 0 0; overflow-wrap: anywhere; }
.quota-window { padding: 12px; background: #f0f2f9; border-radius: 10px; gap: 6px; font-size: 14px; }
.quota-line, .quota-footer { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.quota-line strong { color: var(--accent); white-space: nowrap; font-variant-numeric: tabular-nums; }
.quota-window progress { appearance: none; width: 100%; height: 5px; border: 0; border-radius: 5px; background: #dce2f1; }
.quota-window progress::-webkit-progress-bar { background: #dce2f1; border-radius: 5px; }
.quota-window progress::-webkit-progress-value { background: var(--accent); border-radius: 5px; }
.quota-window progress::-moz-progress-bar { background: var(--accent); border-radius: 5px; }
.quota-window small, #quota-updated, #quota-status { color: var(--muted); font-size: 13px; }
#quota-status { margin: 0; }
#refresh-quota { padding: 4px 9px; }
.temporary-login { display: grid; place-items: center; padding: 20px; background: var(--panel); }
.temporary-login form { display: grid; gap: 12px; width: min(100%, 420px); padding: 25px; border: 1px solid var(--border); border-radius: 17px; background: var(--surface); }
.temporary-login h1 { font-size: 23px; margin: 0 0 5px; }
.temporary-login input, .access-panel input { width: 100%; min-width: 0; border: 1px solid var(--border); border-radius: 8px; background: white; padding: 8px 10px; }
.temporary-login p, #access-notice { color: var(--muted); font-size: 13px; margin: 0; }
.primary-button { padding: 9px 14px; border: 1px solid var(--accent); border-radius: 8px; background: var(--accent); color: white; }
#expires { color: var(--muted); font-size: 12px; }
.access-panel a { color: var(--accent); justify-self: start; overflow-wrap: anywhere; }
.access-panel form, .access-panel label { display: grid; gap: 6px; min-width: 0; }
.access-expiries { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.access-expiries > div { display: grid; gap: 6px; }
.access-duration { display: flex; align-items: stretch; gap: 6px; }
.access-duration input { width: 6em; }
.access-panel form button { justify-self: start; }
.access-code { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 6px; padding: 9px; background: var(--panel); border-radius: 8px; }
.access-code label { grid-column: 1 / -1; font-size: 13px; }
.access-code input { font: 14px ui-monospace, monospace; }
.access-list { display: grid; max-height: 245px; overflow: auto; list-style: none; margin: 0; padding: 0; }
.access-list li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--border); }
.access-list li span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.access-list li small { display: block; color: var(--muted); }
@media (max-width: 680px) {
  body { display: block; }
  main { height: 100%; }
  .topbar { padding: 9px 12px; gap: 9px; }
  .sidebar-toggle { display: inline-grid; }
  .sidebar { visibility: hidden; position: fixed; inset: 0 auto 0 0; width: min(290px, 85vw); z-index: 3; padding-top: max(22px, env(safe-area-inset-top)); }
  .sidebar.open { visibility: visible; }
  .scrim { display: block; position: fixed; inset: 0; width: 100%; border: 0; background: #1b223666; z-index: 2; }
  .messages { padding: 20px 16px; }
}
