:root {
  color-scheme: light;
  --ink: #17243d;
  --muted: #495a73;
  --accent: #345bc0;
  --accent-hover: #244499;
  --error: #a3352f;
  --glass: rgba(250, 253, 255, .49);
  --glass-strong: rgba(248, 252, 255, .78);
  --glass-line: rgba(255, 255, 255, .78);
  --shadow: 0 24px 70px rgba(37, 58, 113, .15), 0 2px 8px rgba(37, 58, 113, .07);
  --radius: 22px;
  font-family: "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif;
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.6;
  background:
    radial-gradient(ellipse at 14% 12%, #f5fbff 0, transparent 43%),
    radial-gradient(ellipse at 80% 5%, #c8d7ff 0, transparent 54%),
    radial-gradient(ellipse at 95% 72%, #e1d3fb 0, transparent 52%),
    radial-gradient(ellipse at 10% 90%, #c4ebed 0, transparent 52%),
    #e3ebfa;
  background-attachment: fixed;
}
button, input, textarea, select { font: inherit; color: inherit; }
button, select, input, textarea {
  border: 1px solid rgba(24, 40, 32, .12);
  border-radius: 12px;
  background: rgba(255, 255, 255, .62);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .8);
}
button { padding: 8px 14px; cursor: pointer; font-weight: 500; transition: background .18s ease, box-shadow .18s ease, transform .12s ease; }
button:hover:not(:disabled) { background: rgba(255, 255, 255, .86); box-shadow: 0 8px 24px rgba(26, 46, 36, .10); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { cursor: not-allowed; opacity: .45; }
.primary {
  background: linear-gradient(165deg, #5279db, #2a4fac);
  border-color: rgba(49, 83, 166, .58);
  color: #fff;
  box-shadow: 0 10px 24px rgba(40, 73, 154, .28), inset 0 1px 0 rgba(255, 255, 255, .28);
}
.primary:hover:not(:disabled) { background: linear-gradient(165deg, #6387e5, #3156b8); box-shadow: 0 14px 30px rgba(40, 73, 154, .32); }
.pill { font-size: 11px; padding: 5px 10px; border-radius: 999px; }
.pill.on { background: rgba(52, 91, 192, .14); border-color: rgba(52, 91, 192, .35); color: #244499; }
a { color: var(--accent); text-underline-offset: 3px; overflow-wrap: anywhere; }
:focus-visible { outline: 3px solid rgba(49, 91, 195, .62); outline-offset: 3px; }
[hidden] { display: none !important; }
h1, h2, p { margin-top: 0; }
h1 { font-size: 22px; line-height: 1.3; letter-spacing: -.5px; }
h2 { font-size: 15px; }
.muted, .fine-print, .small { color: var(--muted); }
.small { font-size: 12px; }
.fine-print { font-size: 12px; line-height: 1.7; }
.eyebrow { margin: 0 0 7px; color: var(--muted); font-size: 11px; letter-spacing: 1px; }
.error { color: var(--error); min-height: 24px; margin: 12px 0 0; overflow-wrap: anywhere; }

.login-page { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(100%, 430px);
  padding: 36px 34px 30px;
  border: 1px solid var(--glass-line);
  border-radius: 28px;
  background: linear-gradient(145deg, rgba(255, 255, 255, .79), rgba(248, 252, 255, .54));
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, .9);
}
.login-card h1 { font-size: clamp(26px, 7vw, 34px); margin-bottom: 8px; }
.login-card form { margin-top: 30px; }
.login-card label { display: block; margin-bottom: 8px; font-weight: 600; }
.login-card input { display: block; padding: 12px 13px; width: 100%; }
.login-card button { width: 100%; padding: 12px; margin-top: 14px; }
.login-card > .fine-print { margin: 20px 0 0; }

.workspace { height: 100vh; height: 100dvh; display: grid; grid-template-columns: 268px minmax(0, 1fr); gap: 18px; padding: 18px; }
.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 22px 18px 16px;
  border: 1px solid var(--glass-line);
  border-radius: var(--radius);
  background: var(--glass);
  backdrop-filter: blur(26px) saturate(170%);
  -webkit-backdrop-filter: blur(26px) saturate(170%);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, .85);
}
.brand { display: flex; flex-direction: column; margin: 0 0 22px; }
.brand strong { font-size: 17px; letter-spacing: -.4px; }
.brand span { font-size: 11px; color: var(--muted); margin-top: 3px; }
.history-heading { display: flex; align-items: center; justify-content: space-between; margin-top: 24px; margin-bottom: 8px; }
.history-heading h2 { color: var(--muted); margin: 0; font-size: 12px; font-weight: 500; }
.quiet { border-color: transparent; background: transparent; font-size: 12px; padding: 3px 8px; box-shadow: none; }
.history { display: flex; flex-direction: column; gap: 4px; overflow-y: auto; min-height: 0; }
.history-item {
  flex-shrink: 0; text-align: left; background: transparent; border-color: transparent; box-shadow: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 9px 11px; border-radius: 12px;
}
.history-item:hover:not(:disabled) { background: rgba(255, 255, 255, .62); }
.history-item[aria-current] { background: rgba(255, 255, 255, .82); color: #244499; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .9), 0 6px 18px rgba(26, 46, 36, .08); }
.sidebar-footer { margin-top: auto; padding-top: 18px; }
.sidebar-footer button { width: 100%; background: rgba(255, 255, 255, .45); }

.usage { display: flex; align-items: flex-end; gap: 14px; margin: 0 0 14px; }
.usage-item { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.usage-ring-wrap { position: relative; width: 40px; height: 40px; }
.usage-ring { width: 40px; height: 40px; transform: rotate(-90deg); }
.usage-track { fill: none; stroke: rgba(24, 40, 32, .12); stroke-width: 3; }
.usage-arc { fill: none; stroke: var(--accent); stroke-width: 3; stroke-linecap: round; stroke-dasharray: 100; transition: stroke-dashoffset .35s ease, stroke .2s; }
.usage-arc.warn { stroke: #b7791f; }
.usage-arc.low { stroke: var(--error); }
.usage-pct { position: absolute; inset: 0; display: grid; place-items: center; font-size: 10px; font-weight: 600; font-variant-numeric: tabular-nums; }
.usage-label { font-size: 10px; color: var(--muted); }

.main-panel {
  display: flex; flex-direction: column; min-width: 0; min-height: 0;
  border: 1px solid var(--glass-line); border-radius: var(--radius);
  background: rgba(255, 255, 255, .42);
  backdrop-filter: blur(24px) saturate(165%);
  -webkit-backdrop-filter: blur(24px) saturate(165%);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, .85);
  overflow: hidden;
}
.auth-summary { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--muted); }
.auth-summary span { max-width: 300px; overflow-wrap: anywhere; }
.auth-summary button { flex-shrink: 0; font-size: 12px; }
.connected { color: var(--accent); }
.device-auth { margin: 16px 26px 0; padding: 16px 18px; background: rgba(233, 246, 238, .72); border: 1px solid rgba(52, 91, 192, .18); border-radius: 16px; backdrop-filter: blur(16px); }
.device-auth h2 { margin-bottom: 5px; }
.device-auth p { margin-bottom: 10px; }
.device-auth p:last-child { margin-bottom: 0; }
.device-actions { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; margin-bottom: 8px; }
.device-actions code { font-size: 16px; font-weight: 600; user-select: all; letter-spacing: 1px; }
.app-error { margin: 14px 26px 0; padding: 11px 15px; color: var(--error); border: 1px solid rgba(163, 53, 47, .25); background: rgba(255, 244, 241, .8); border-radius: 14px; overflow-wrap: anywhere; backdrop-filter: blur(14px); }
.messages { flex: 1; min-height: 0; overflow-y: auto; padding: 28px max(26px, calc((100% - 860px) / 2)); overscroll-behavior: contain; }
.welcome { max-width: 580px; margin: 7vh auto 0; }
.welcome h2 { font-size: 25px; margin-bottom: 12px; font-weight: 600; letter-spacing: -.6px; }
.welcome p { color: var(--muted); line-height: 1.9; }
.message { margin: 0 0 26px; min-width: 0; }
.message h2 { font-size: 11px; margin: 0 0 8px; color: var(--muted); letter-spacing: .6px; }
.message-content { white-space: pre-wrap; overflow-wrap: anywhere; tab-size: 4; }
.assistant-message .message-content { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-size: 13px; line-height: 1.9; }
.user-message .message-content {
  background: rgba(255, 255, 255, .66); border: 1px solid var(--glass-line); padding: 13px 16px; border-radius: 16px;
  box-shadow: 0 8px 22px rgba(26, 46, 36, .07), inset 0 1px 0 rgba(255, 255, 255, .9);
}
.composer-area { padding: 0 max(26px, calc((100% - 860px) / 2)) 16px; }
.activity {
  width: fit-content;
  max-width: 100%;
  margin: 0 auto 5px;
  padding: 1px 10px;
  border: 1px solid var(--glass-line);
  border-radius: 12px;
  background: var(--glass);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  overflow-wrap: anywhere;
  max-height: 62px;
  overflow-y: auto;
}
.activity:empty { display: none; }
.messages[aria-busy="true"] + .composer-area .activity:not(:empty)::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-inline-end: 6px;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: .12em;
}
#chat-form {
  background: rgba(255, 255, 255, .58);
  border: 1px solid rgba(255, 255, 255, .85);
  border-radius: 20px;
  padding: 12px 14px 10px;
  backdrop-filter: blur(24px) saturate(175%);
  -webkit-backdrop-filter: blur(24px) saturate(175%);
  box-shadow: 0 18px 46px rgba(26, 46, 36, .10), inset 0 1px 0 rgba(255, 255, 255, .95);
  transition: box-shadow .2s ease, border-color .2s ease;
}
#chat-form:focus-within { border-color: rgba(49, 91, 195, .62); box-shadow: 0 22px 54px rgba(26, 46, 36, .14), 0 0 0 4px rgba(49, 91, 195, .12); }
#prompt { width: 100%; display: block; border: 0; border-radius: 10px; resize: vertical; min-height: 72px; max-height: 30vh; padding: 4px 3px; line-height: 1.7; background: transparent; box-shadow: none; }
#prompt:focus { outline: none; }
.composer-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; }
.bar-side { display: flex; align-items: center; gap: 8px; min-width: 0; }
.chip-access { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px 4px 8px; border-radius: 999px; background: rgba(255, 255, 255, .55); border: 1px solid rgba(24, 40, 32, .10); }
.chip-icon { font-size: 11px; color: #b7791f; }
.chip-access select { appearance: none; -webkit-appearance: none; border: 0; background: transparent; box-shadow: none; padding: 0; font-size: 11px; color: var(--muted); cursor: pointer; backdrop-filter: none; }
.chip-access select:focus-visible { outline-offset: 2px; }
.chip-button { cursor: pointer; font-size: 11px; color: #33403a; gap: 5px; }
.chip-button:hover:not(:disabled) { background: rgba(255, 255, 255, .82); }
.segmented { display: inline-flex; gap: 4px; padding: 3px; border-radius: 999px; background: rgba(255, 255, 255, .5); border: 1px solid rgba(24, 40, 32, .10); }
.segmented button { padding: 4px 12px; border-radius: 999px; border: 0; background: transparent; box-shadow: none; font-size: 11px; color: var(--muted); }
.segmented button[aria-pressed="true"] { background: linear-gradient(165deg, #5279db, #2a4fac); color: #fff; box-shadow: 0 4px 12px rgba(40, 73, 154, .25); }
.model-button { display: inline-flex; align-items: center; gap: 7px; padding: 5px 10px; border-radius: 999px; background: rgba(255, 255, 255, .5); border: 1px solid rgba(24, 40, 32, .10); font-size: 11px; color: #33403a; max-width: 78%; }
.model-button #model-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.effort-tag { padding: 1px 7px; border-radius: 999px; background: rgba(52, 91, 192, .12); color: #244499; font-size: 10px; }
.chev { color: var(--muted); font-size: 11px; }
.send-circle { width: 34px; height: 34px; padding: 0; border-radius: 50%; display: grid; place-items: center; font-size: 16px; line-height: 1; background: linear-gradient(165deg, #5279db, #2a4fac); color: #fff; border-color: rgba(49, 83, 166, .5); box-shadow: 0 8px 20px rgba(40, 73, 154, .28); }
.send-circle:hover:not(:disabled) { background: linear-gradient(165deg, #6387e5, #3156b8); }
.stop-pill { font-size: 11px; padding: 5px 10px; border-radius: 999px; }
.picker { position: relative; margin-top: 10px; padding: 12px 14px 10px; border-radius: 18px; border: 1px solid var(--glass-line); background: rgba(255, 255, 255, .72); backdrop-filter: blur(26px) saturate(180%); box-shadow: 0 18px 44px rgba(26, 46, 36, .14), inset 0 1px 0 rgba(255, 255, 255, .9); }
.picker-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding-bottom: 8px; }
.picker-head > span:first-child { font-weight: 600; font-size: 13px; }
.picker-hint { font-size: 10px; color: var(--muted); }
.picker-group { display: flex; align-items: baseline; gap: 8px; padding: 8px 2px 4px; }
.picker-group span:first-child { font-size: 12px; font-weight: 600; }
.picker-group-sub { font-size: 10px; color: var(--muted); }
.model-list { display: flex; flex-direction: column; max-height: 232px; overflow-y: auto; }
.model-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 10px; background: transparent; border: 0; box-shadow: none; font-size: 12px; text-align: left; }
.model-item:hover:not(:disabled) { background: rgba(255, 255, 255, .8); box-shadow: none; }
.model-item[aria-selected="true"] { background: rgba(52, 91, 192, .10); color: #244499; font-weight: 600; }
.model-item[aria-selected="true"]::after { content: "✓"; font-size: 12px; color: var(--accent); }
.picker-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 2px 2px; border-top: 1px solid rgba(24, 40, 32, .07); margin-top: 6px; }
.picker-label { font-size: 11px; color: var(--muted); flex: 0 0 auto; }
.dots { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; flex: 1 1 auto; justify-content: flex-end; }
.dot { padding: 5px 10px; border-radius: 9px; }
.dot[aria-pressed="true"], .dot[aria-pressed="true"]:hover:not(:disabled) {
  color: white;
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
.composer-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 14px; margin-top: 10px; }
.mode-control { display: flex; align-items: center; gap: 6px; min-width: 0; }
.mode-control label { font-size: 11px; color: var(--muted); }
.mode-control select { padding: 6px 8px; font-size: 12px; max-width: 100%; }
.send-actions { display: flex; gap: 8px; flex-shrink: 0; margin-left: auto; }
#mode-note { margin: 9px 0 0; font-size: 11px; }
.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; }
@keyframes glass-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.message { animation: glass-rise .22s ease both; }

@media (min-width: 1450px) { .workspace { grid-template-columns: 296px minmax(0, 1fr); } }
@media (max-width: 760px) {
  .workspace { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); gap: 10px; padding: 10px; }
  .sidebar { padding: 12px 14px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; border-radius: 20px; }
  .brand { margin: 0; }
  .brand strong { font-size: 14px; }
  .brand span { font-size: 10px; margin: 0; }
  .sidebar > .primary { align-self: center; font-size: 12px; }
  .history-heading { margin: 0; grid-column: 1 / -1; }
  .history { grid-column: 1 / -1; flex-direction: row; gap: 5px; overflow-x: auto; max-height: 42px; }
  .history-item { max-width: 170px; font-size: 12px; padding: 6px 9px; }
  #history-empty { grid-column: 1; margin: 0; }
  .sidebar-footer { position: static; grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 0; margin: -2px 0 0; }
  .usage { margin: 0; gap: 10px; }
  .usage-ring-wrap, .usage-ring { width: 32px; height: 32px; }
  .usage-pct { font-size: 9px; }
  .sidebar-footer button { width: auto; font-size: 11px; padding: 3px 9px; }
  .main-panel { border-radius: 20px; }
  .auth-summary { gap: 7px; justify-content: flex-end; flex-wrap: wrap; font-size: 11px; max-width: 55%; }
  .auth-summary span { max-height: 42px; overflow: auto; }
  .auth-summary button { padding: 5px 9px; font-size: 11px; }
  .messages { padding: 18px 14px; }
  .composer-area { padding: 0 12px max(10px, env(safe-area-inset-bottom)); }
  .app-error, .device-auth { margin: 10px 12px 0; padding: 10px 12px; max-height: 25dvh; overflow-y: auto; }
  .device-auth { font-size: 12px; }
  .device-auth h2 { font-size: 13px; }
  .device-actions { gap: 5px 16px; }
  .welcome { margin-top: 3vh; }
  .welcome h2 { font-size: 21px; }
  .composer-bar { flex-wrap: wrap; gap: 8px; }
  .bar-side { gap: 6px; }
  .model-button { max-width: 100%; }
  .model-button #model-label { max-width: 44vw; }
  .chip-access { padding: 3px 8px; }
  .picker { padding: 10px 12px; }
  .model-item { padding: 9px 8px; font-size: 13px; }
  .composer-controls { gap: 8px; flex-direction: column; align-items: stretch; }
  .mode-control { gap: 6px; justify-content: space-between; }
  .mode-control select { flex: 1 1 auto; min-width: 0; }
  .mode-control .pill { flex: 0 0 auto; }
  .send-actions { justify-content: flex-end; margin-left: 0; }
  .mode-control label { display: none; }
  .mode-control select { font-size: 11px; padding: 6px; }
  .send-actions button { padding: 6px 10px; font-size: 12px; }
  #prompt { font-size: 16px; min-height: 58px; }
  .login-card { padding: 28px 22px; border-radius: 24px; }
  .login-card input { font-size: 16px; }
}

.login-card .brand { margin-bottom: 12px; color: var(--accent-hover); font-weight: 700; }
.login-card .description { color: var(--muted); }
.password-field { position: relative; }
.password-field input { padding-inline-end: 48px; }
.password-field #toggle-password {
  position: absolute;
  top: 50%;
  inset-inline-end: 6px;
  width: 36px;
  height: 36px;
  margin: 0;
  padding: 8px;
  transform: translateY(-50%);
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
  backdrop-filter: none;
}
.password-field #toggle-password:hover { background: rgba(52, 91, 192, .1); }
#toggle-password svg { display: block; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.password-field #password::-ms-reveal { display: none; }
#login-error:empty { display: none; }
#queue-status {
  min-width: 0;
  margin: 0 auto 0 0;
  color: var(--accent-hover);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-page {
  --chat-line: rgba(85, 110, 170, .19);
  --chat-column: 760px;
}
.chat-page .workspace { grid-template-columns: 238px minmax(0, 1fr); gap: 8px; padding: 8px; }
.chat-page .sidebar { background: var(--glass); }
.chat-page .main-panel {
  background: linear-gradient(160deg, rgba(255, 255, 255, .73), rgba(253, 254, 255, .46));
  box-shadow: 0 8px 30px rgba(37, 58, 113, .09), inset 0 1px 1px rgba(255, 255, 255, .95);
}
.chat-page .history-item[aria-current] { background: rgba(255, 255, 255, .66); box-shadow: inset 0 1px 1px white; }
.chat-page .messages { padding-inline: max(22px, calc((100% - var(--chat-column)) / 2)); }
.chat-page .composer-area { width: min(100%, 640px); align-self: center; padding-inline: 20px; }
.sidebar-footer .auth-summary { flex-wrap: wrap; margin: 0; }
.sidebar-footer .auth-summary button { width: auto; }
#codex-status:is(.connected, .disconnected) {
  margin-inline: auto;
  padding: 2px 9px;
  border-radius: 999px;
  text-align: center;
}
#codex-status.connected { background: #d9f1e3; color: #17603d; }
#codex-status.disconnected { background: #fbe0e0; color: #962c31; }
#codex-status.connected + #codex-login { display: none; }
.chat-page .welcome { text-align: center; margin-top: clamp(24px, 14vh, 150px); }
.chat-page .message { font-size: 15px; line-height: 1.75; }
.chat-page .user-message { display: flex; flex-direction: column; align-items: flex-end; }
.chat-page .user-message .message-content {
  max-width: min(86%, 620px);
  border: 0;
  border-radius: 20px 20px 4px 20px;
  background: linear-gradient(160deg, rgba(255, 255, 255, .88), rgba(212, 226, 252, .77));
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, .95), 0 3px 10px rgba(37, 58, 113, .07);
  padding: 10px 16px;
}
.chat-page .assistant-message .message-content { font: inherit; white-space: normal; }
.chat-page .assistant-message .streaming-response { white-space: pre-wrap; }
.chat-page .system-message .message-content {
  padding: 8px 12px;
  border-inline-start: 3px solid var(--accent);
  border-radius: 8px;
  background: rgba(52, 91, 192, .10);
  color: var(--accent-hover);
  font-size: 13px;
}
.assistant-message .message-content > :last-child { margin-bottom: 0; }
.message-content :is(h1, h2, h3, h4, h5, h6) { margin: 1.2em 0 .55em; color: var(--ink); line-height: 1.35; }
.message-content h2 { font-size: 1.25em; letter-spacing: normal; }
.message-content :is(ul, ol) { padding-inline-start: 1.5em; }
.message-content li + li { margin-top: .25em; }
.message-content blockquote { margin-inline: 0; padding-inline: 14px; border-inline-start: 3px solid #a5b9e8; color: var(--muted); }
.message-content :not(pre) > code { padding: .12em .32em; border-radius: 4px; background: #edf2fc; }
.code-block { margin-block: 14px; border: 1px solid var(--chat-line); border-radius: 12px; overflow: hidden; }
.code-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 12px; background: #e5edfb; font-size: 12px; }
.code-header button { padding: 3px 9px; font-size: 12px; }
.message-content pre { overflow-x: auto; margin: 0; padding: 14px; background: #f6f8fe; font-size: 13px; tab-size: 4; }
.table-scroll { overflow-x: auto; margin-block: 14px; }
.message-content table { border-collapse: collapse; width: max-content; min-width: 100%; }
.message-content :is(th, td) { padding: 7px 12px; border: 1px solid var(--chat-line); max-width: 340px; }
.message-content th { background: #edf2fc; }
.chat-page #chat-form { position: relative;
  background: var(--glass-strong);
  border-color: var(--glass-line);
  box-shadow: 0 6px 24px rgba(37, 58, 113, .13), inset 0 1px 1px #fff;
}
.chat-page #chat-form:focus-within { border-color: #a5b9e8; }
.chat-page #prompt {
  min-height: 36px;
  max-height: min(30dvh, 240px);
  overflow-y: auto;
  resize: none;
  font-size: 16px;
  backdrop-filter: none;
}
.chat-page .picker {
  position: absolute;
  z-index: 2;
  inset: auto 0 calc(100% + 8px);
  max-height: 48dvh;
  overflow-y: auto;
  background: rgba(249, 252, 255, .94);
  border-color: var(--glass-line);
}
#engine-row { flex-wrap: wrap; column-gap: 8px; }
#engine-row .segmented { margin-inline-start: auto; }
.effort-toolbar .dots { justify-content: flex-start; gap: 3px; }
.effort-toolbar .dot { padding: 2px 7px; min-height: 26px; font-size: 11px; white-space: nowrap; }
.composer-bar .bar-side { margin-inline-start: auto; }
.composer-bar .model-button { padding: 3px 8px; }
.composer-bar .send-circle { width: 30px; height: 30px; }

@media (max-width: 430px) {
  #engine-row .effort-toolbar { order: 1; flex-basis: 100%; }
}
.chat-page #mode-note { margin-bottom: 0; }

@media (max-width: 760px) {
  .chat-page .workspace { grid-template-columns: minmax(0, 1fr); gap: 5px; padding: 4px; }
  .chat-page .messages, .chat-page .composer-area { padding-inline: 12px; }
  .sidebar-footer .auth-summary { justify-content: flex-start; max-width: none; }
}

.chat-page .workspace.sidebar-collapsed { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
.chat-page #mode-note { margin: 6px 0 0; }
.chat-page .composer-area { padding-bottom: max(8px, env(safe-area-inset-bottom)); }
.chat-page #chat-form { padding-block: 8px; }
.chat-page .composer-bar { margin-top: 5px; }

@media (prefers-reduced-motion: reduce) {
  .message { animation: none; }
  button, #chat-form { transition: none; }
}

@media (prefers-reduced-transparency: reduce) {
  .login-card, .chat-page .sidebar, .chat-page .main-panel, .chat-page #chat-form, .chat-page .picker {
    background: #f6f8fe;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

.chat-page .main-panel { position: relative; }
.sidebar-toggle {
  position: absolute;
  z-index: 3;
  inset: 10px auto auto 10px;
}
.chat-page .messages { padding-top: 48px; }
.chat-page .app-error, .chat-page .device-auth { margin-top: 48px; }
.chat-page .app-error:not([hidden]) + .messages,
.chat-page .device-auth:not([hidden]) ~ .messages { padding-top: 14px; }
.chat-page .main-panel.new-conversation .messages {
  flex: 0 1 auto;
  margin-top: auto;
  padding-bottom: 16px;
}
.chat-page .new-conversation .welcome { margin: 0 auto; }
.chat-page .new-conversation .welcome h1 { font-size: clamp(24px, 5vw, 36px); margin: 0; }
.chat-page .new-conversation .composer-area { margin-bottom: auto; }
.attachment-preview { display: flex; gap: 8px; align-items: center; padding: 5px 0; }
.attachment-preview img { width: 58px; height: 58px; object-fit: contain; border-radius: 9px; background: var(--glass); }
.attachment-preview button { padding: 4px 8px; font-size: 12px; }
.message-image { display: block; max-width: min(100%, 340px); max-height: 300px; object-fit: contain; border-radius: 10px; }
.message-image:not(:first-child) { margin-top: 8px; }

.sidebar-header { display: flex; align-items: center; gap: 5px; margin-bottom: 12px; min-width: 0; }
.sidebar-header .brand { flex: 1; margin: 0; white-space: nowrap; }
.sidebar-header .brand strong { font-size: 14px; }
.sidebar-icon {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: rgba(255, 255, 255, .48);
  color: var(--muted);
  box-shadow: none;
  font-size: 19px;
  line-height: 1;
}
.panel-icon, .search-icon { position: relative; display: block; border: 1.4px solid currentColor; }
.panel-icon { width: 15px; height: 12px; border-radius: 3px; }
.panel-icon::before { content: ""; position: absolute; inset: 0 auto 0 4px; border-left: 1px solid currentColor; }
.search-icon { width: 11px; height: 11px; border-radius: 50%; transform: translate(-1px, -1px); }
.search-icon::after { content: ""; position: absolute; top: 8px; left: 7px; width: 6px; border-top: 1.4px solid currentColor; transform: rotate(45deg); }
.new-chat {
  align-self: stretch;
  text-align: left;
  padding: 5px 10px;
  border: 1px solid rgba(85, 110, 170, .16);
  border-radius: 9px;
  background: rgba(255, 255, 255, .64);
  font-size: 13px;
}
.new-chat span { margin-inline-end: 2px; color: var(--accent); }
:is(#history-search, #client-manager, #delete-history) {
  width: min(540px, calc(100% - 28px));
  max-height: min(640px, calc(100dvh - 36px));
  padding: 16px;
  color: var(--ink);
  border: 1px solid var(--glass-line);
  border-radius: 20px;
  background: #f4f8fe;
  box-shadow: var(--shadow);
}
:is(#history-search, #client-manager, #delete-history)::backdrop { background: rgba(25, 43, 79, .23); backdrop-filter: blur(3px); }
.search-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; gap: 10px; }
.search-heading h2 { margin: 0; }
#history-query { width: 100%; padding: 8px 11px; font-size: 16px; }
#history-search-status { margin: 10px 0 6px; }
#history-search-results { display: grid; gap: 4px; }
.search-result {
  display: grid;
  gap: 3px;
  width: 100%;
  padding: 8px 10px;
  text-align: left;
  border-color: transparent;
  border-radius: 9px;
  box-shadow: none;
}
.search-result > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-result span { color: var(--muted); font-size: 12px; }

@media (max-width: 760px) {
  .sidebar-header { margin-bottom: 0; }
  .new-chat { min-width: 92px; justify-self: end; font-size: 12px; }
}

.chat-page .composer-bar { flex-wrap: nowrap; justify-content: flex-start; gap: 6px; }
.composer-bar .bar-side { flex-shrink: 0; }
#attach-file {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 50%;
  line-height: 1;
}
#draft-filename { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#draft-filename:empty { display: none; }
.message-file { display: block; overflow-wrap: anywhere; }
@media (max-width: 430px) {
  .composer-bar .model-button #model-label { max-width: 24vw; }
  .composer-bar .bar-side { gap: 4px; }
}

.client-actions { display: grid; gap: 6px; }
.current-client {
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(52, 91, 192, .12);
  color: var(--accent-hover);
  font-size: 11px;
  white-space: nowrap;
}
#client-list { display: grid; gap: 6px; list-style: none; padding: 0; margin: 0 0 10px; }
#client-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 9px;
  background: rgba(255, 255, 255, .58);
}
#client-list small { display: block; color: var(--muted); }
#client-list button, #revoke-others { padding: 4px 9px; font-size: 12px; }
.password-settings { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--chat-line); }
.password-settings summary { cursor: pointer; font-weight: 600; }
#change-password { display: grid; gap: 6px; margin-top: 8px; }
#change-password p { margin: 0; }
#change-password input { width: 100%; padding: 6px 9px; font-size: 16px; }
#save-password { justify-self: start; margin-top: 4px; }
#client-status { margin: 8px 0 0; }
#client-status:empty { display: none; }

@media (max-width: 760px) {
  .client-actions { justify-items: end; }
}

.footer-metrics {
  --metric-gap: 20px;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: var(--metric-gap);
  margin-bottom: 12px;
}
.footer-metrics .usage { margin: 0; gap: var(--metric-gap); }
#open-clients,
#open-clients:hover:not(:disabled) {
  flex: 0 0 auto;
  width: auto;
  padding: 0;
  border: 0;
  background: transparent;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  box-shadow: none;
}
#open-clients .usage-arc { stroke-dasharray: none; }
@media (max-width: 760px) {
  .sidebar-footer { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); }
  .footer-metrics { --metric-gap: 10px; grid-column: 2; margin: 0; }
  .client-actions { grid-column: 3; justify-self: end; min-width: 0; }
}

/* Keep the conversation scrollbar draggable without separate end buttons. */
.chat-page .messages { scrollbar-width: thin; }
@supports selector(::-webkit-scrollbar) {
  .chat-page .messages { scrollbar-width: auto; }
  .chat-page .messages::-webkit-scrollbar { width: 8px; }
  .chat-page .messages::-webkit-scrollbar-button,
  .chat-page .messages::-webkit-scrollbar-button:single-button {
    display: none;
    width: 0;
    height: 0;
  }
  .chat-page .messages::-webkit-scrollbar-track { background: transparent; }
  .chat-page .messages::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: rgba(73, 90, 115, .45);
  }
}

.history-row { position: relative; flex-shrink: 0; min-width: 0; }
.history-row .history-item { width: 100%; padding-inline-end: 32px; }
.history-delete {
  position: absolute;
  inset: 50% 4px auto auto;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  box-shadow: none;
  color: #aa2935;
  transform: translateY(-50%);
  opacity: 0;
  pointer-events: none;
}
.history-row:hover .history-delete,
.history-row:focus-within .history-delete {
  opacity: 1;
  pointer-events: auto;
}
.history-delete:hover:not(:disabled) { background: #fbe0e0; box-shadow: none; }
.history-delete:active:not(:disabled) { transform: translateY(-50%); }
.trash-icon { position: relative; width: 9px; height: 10px; margin-top: 3px; border: 1.4px solid; border-top: 0; border-radius: 0 0 2px 2px; }
.trash-icon::before { content: ""; position: absolute; top: -3px; left: -3px; width: 12px; border-top: 1.4px solid; }
.trash-icon::after { content: ""; position: absolute; top: -6px; left: 1px; width: 5px; height: 3px; border: 1.4px solid; border-bottom: 0; border-radius: 2px 2px 0 0; }
#delete-history { width: min(410px, calc(100% - 28px)); }
#delete-history-title { margin: 0 0 8px; }
#delete-history-name { overflow-wrap: anywhere; font-weight: 650; margin-bottom: 6px; }
#delete-history-error { margin-top: 0; }
.delete-history-actions { display: flex; justify-content: flex-end; gap: 8px; }
.danger-button { background: #aa2935; border-color: #aa2935; color: #fff; box-shadow: none; }
.danger-button:hover:not(:disabled) { background: #8f1f2a; }
@media (hover: none) {
  .history-delete { opacity: 1; pointer-events: auto; }
}
