:root {
  color-scheme: light;
  font: 16px/1.55 "Inter", system-ui, sans-serif;
  --canvas: #f1f1f1;
  --surface: #fff;
  --soft: #f5f5f5;
  --text: #161616;
  --muted: #565656;
  --line: #d5d5d5;
  --control: #858585;
  --action: #202020;
  --on-action: #fff;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #111;
  --surface: #181818;
  --soft: #222;
  --text: #f3f3f3;
  --muted: #bbb;
  --line: #414141;
  --control: #777;
  --action: #f1f1f1;
  --on-action: #191919;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--text); background: var(--canvas); }
main { margin: 0 auto; max-width: 1520px; padding: 0 clamp(12px, 2.7vw, 40px) 16px; }
.topbar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; min-height: 78px; padding-block: 12px; }
h1 { display: flex; align-items: center; gap: 13px; font-size: clamp(24px, 4vw, 32px); margin: 0 auto 0 0; line-height: 1.1; }
h1 small { padding-right: 12px; border-right: 1px solid var(--line); color: var(--muted); font-size: 11px; letter-spacing: .09em; }
h2, h3 { margin-block: 12px 6px; font-size: 16px; }
button, select, input, textarea { font: inherit; color: var(--text); border: 1px solid var(--control); border-radius: 8px; background: var(--surface); }
button { min-height: 42px; padding: 7px 12px; cursor: pointer; font-size: 14px; font-weight: 600; }
button:hover:not(:disabled) { background: var(--soft); }
button:disabled { opacity: .53; cursor: default; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
.primary { background: var(--action); color: var(--on-action); border-color: var(--action); }
.primary:hover:not(:disabled) { background: var(--action); opacity: .86; }
.themes, .views { display: flex; gap: 4px; }
.themes button, .views button { background: transparent; border-color: transparent; }
.themes button[aria-pressed="true"], .views button[aria-pressed="true"] { background: var(--surface); border-color: var(--line); }
.status { margin: 0 0 9px; color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.layout { display: grid; grid-template-columns: 225px minmax(0,1fr); min-height: calc(100dvh - 130px); border: 1px solid var(--line); border-radius: 15px; background: var(--soft); }
.sidebar { padding: 18px 14px; min-width: 0; }
.sidebar summary { font-weight: 700; }
.sidebar button { width: 100%; margin-top: 8px; }
label { display: block; color: var(--muted); font-size: 14px; margin: 12px 0 4px; }
select, input, textarea { display: block; width: 100%; min-width: 0; padding: 8px 10px; }
textarea { resize: vertical; }
summary { cursor: pointer; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px; min-width: 0; }
.codex { display: flex; flex-direction: column; margin: -1px; padding: clamp(12px, 2.5vw, 26px); }
.views { margin-bottom: 12px; }
#codex-chat-view { display: flex; flex: 1; flex-direction: column; }
#messages { display: flex; flex-direction: column; gap: 12px; flex: 1; min-height: 120px; max-height: 63dvh; overflow: auto; scrollbar-gutter: stable; }
#messages > p { margin: auto; color: var(--muted); text-align: center; padding: 12px; }
article, #editor { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
article.user-message { background: var(--soft); border-color: transparent; }
.message-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px 12px; }
pre { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; margin: 4px 0; }
#chat { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 9px; margin-top: 14px; }
#chat textarea { max-height: 38dvh; }
#codex-code-view button, .login button { margin-top: 10px; }
#codex-code-view #proposals { margin-top: 12px; }
#proposals button + button { margin-left: 6px; }
.hint { color: var(--muted); font-size: 14px; }
.login { max-width: 420px; margin: 32px auto; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 720px) {
  .layout { grid-template-columns: minmax(0,1fr); min-height: auto; }
  .sidebar { padding: 12px; }
  .codex { min-height: min(70dvh, 680px); }
  #messages { max-height: 53dvh; }
}
@media (max-width: 400px) {
  h1 { width: 100%; }
  #logout { margin-left: auto; }
  #chat { grid-template-columns: minmax(0,1fr); }
  #send { justify-self: end; }
}
