:root { color-scheme: light; --bg: #fff; --surface: #f7f7f8; --surface-strong: #fff; --line: #e5e5e5; --text: #202123; --muted: #6b6d70; --accent: #10a37f; --accent-dark: #0d8c6d; --blue: #2f6fed; --danger: #b42318; --drawer: 280px; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif; }
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { min-height: 100dvh; overflow-x: hidden; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.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; }
.eyebrow { margin: 0 0 8px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.message { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.error { min-height: 20px; margin: 10px 0 0; color: var(--danger); font-size: 13px; }
.success { color: var(--accent-dark); }
.primary, .secondary-button, .send-button, .icon-button, .drawer-action, .drawer-nav-item, .session-card { border: 0; transition: background .15s ease, color .15s ease, transform .15s ease; }
.primary { background: var(--text); color: white; border-radius: 8px; padding: 12px 18px; font-weight: 600; }
.primary:hover { background: #000; }
.primary:disabled, .send-button:disabled { opacity: .5; cursor: not-allowed; }
.full-button { width: 100%; }
.compact-button { padding: 10px 18px; }
.secondary-button { background: transparent; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; }
.secondary-button:hover { background: var(--surface); }
.icon-button { width: 38px; height: 38px; padding: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 21px; line-height: 1; }
.icon-button:hover { background: var(--surface); color: var(--text); }

.login-screen { min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: #fff; }
.login-card { width: min(100%, 380px); padding: 44px 34px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface-strong); box-shadow: 0 8px 30px rgba(0,0,0,.06); }
.brand-mark { width: 48px; height: 48px; display: grid; place-items: center; margin-bottom: 25px; border-radius: 14px; background: var(--text); color: #fff; font-size: 25px; }
.brand-mark.small { width: 30px; height: 30px; margin: 0; border-radius: 9px; font-size: 16px; }
.login-card h1 { margin: 0 0 9px; font-size: 29px; letter-spacing: -.03em; }
.login-copy { margin: 0 0 24px; color: var(--muted); font-size: 14px; line-height: 1.55; }
input, textarea, select { width: 100%; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text); outline: none; }
input:focus, textarea:focus, select:focus { border-color: #8e8e8e; box-shadow: 0 0 0 2px rgba(0,0,0,.06); }
.login-card input { margin: 0 0 11px; padding: 13px 14px; }

.app-shell { min-height: 100dvh; display: flex; background: var(--bg); }
.drawer { width: var(--drawer); flex: 0 0 var(--drawer); display: flex; flex-direction: column; min-height: 100dvh; padding: 16px 12px; border-right: 1px solid var(--line); background: var(--surface); z-index: 20; }
.drawer-top { display: flex; align-items: center; justify-content: space-between; padding: 3px 8px 18px; }
.drawer-brand { display: flex; align-items: center; gap: 10px; font-size: 17px; }
.drawer-action { width: 100%; display: grid; grid-template-columns: 28px 1fr; grid-template-rows: auto auto; column-gap: 4px; padding: 12px 13px; margin-bottom: 8px; border-radius: 8px; text-align: left; background: transparent; color: var(--text); }
.drawer-action > span { grid-row: 1 / span 2; font-size: 20px; color: var(--muted); }
.drawer-action strong { font-size: 14px; font-weight: 600; }
.drawer-action small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.drawer-action:hover, .drawer-action:focus { background: #ececed; }
.admin-action { background: #ececed; }
.drawer-section { min-height: 0; margin-top: 10px; }
.drawer-section-title { display: flex; align-items: center; justify-content: space-between; padding: 10px 9px 8px; color: var(--muted); font-size: 12px; font-weight: 700; }
.drawer-label { display: block; margin: 0 8px 8px; color: var(--muted); font-size: 11px; }
.drawer-label select { display: block; margin-top: 5px; padding: 8px 10px; font-size: 13px; }
.search-input { margin: 0 8px 7px; width: calc(100% - 16px); padding: 9px 11px; border-color: #ddd; background: #fff; font-size: 13px; }
.drawer-section > .message { padding: 0 9px 8px; font-size: 11px; }
.session-list { max-height: min(42dvh, 430px); overflow-y: auto; padding: 0 3px; }
.session-card { width: 100%; display: block; padding: 10px 11px; border-radius: 7px; background: transparent; color: var(--text); text-align: left; }
.session-card:hover, .session-card.active { background: #e9e9ea; }
.session-card strong, .session-card small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-card strong { font-size: 13px; font-weight: 500; }
.session-card small { margin-top: 4px; color: var(--muted); font-size: 10px; }
.session-empty { padding: 18px 8px; text-align: center; }
.session-empty .secondary-button { margin-top: 10px; font-size: 12px; }
.drawer-nav { display: grid; gap: 2px; margin-top: auto; padding-top: 14px; }
.drawer-nav-item { width: 100%; display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 7px; background: transparent; color: var(--muted); text-align: left; font-size: 13px; }
.drawer-nav-item span { width: 18px; text-align: center; font-size: 17px; }
.drawer-nav-item:hover, .drawer-nav-item.active { background: #e9e9ea; color: var(--text); }
.drawer-bottom { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.drawer-backdrop { display: none; }

.content-shell { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-header { height: 64px; flex: 0 0 64px; display: flex; align-items: center; justify-content: space-between; padding: 0 25px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.92); }
.header-model-wrap { display: flex; align-items: center; gap: 10px; min-width: 0; }
.model-picker { width: auto; min-width: 150px; padding: 7px 28px 7px 10px; border: 0; background: transparent; font-size: 15px; font-weight: 600; }
.model-picker:focus { box-shadow: none; }
.connection-status { color: var(--muted); font-size: 11px; white-space: nowrap; }
.connection-status.online { color: var(--accent-dark); }.connection-status.offline { color: var(--danger); }
.header-actions { display: flex; align-items: center; gap: 2px; }
.view-stack { flex: 1; min-height: 0; }
.view { min-height: calc(100dvh - 64px); }
.chat-empty { min-height: calc(100dvh - 64px); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 30px; text-align: center; }
.welcome-icon { display: grid; place-items: center; width: 50px; height: 50px; margin-bottom: 20px; border-radius: 15px; background: var(--text); color: #fff; font-size: 26px; }
.chat-empty h1 { margin: 0 0 9px; font-size: 30px; letter-spacing: -.04em; }.chat-empty p { margin: 0 0 22px; color: var(--muted); font-size: 14px; }.chat-empty .secondary-button { margin-top: 9px; }
.session-detail { width: min(100%, 860px); min-height: calc(100dvh - 64px); display: flex; flex-direction: column; margin: 0 auto; }
.detail-heading { display: flex; align-items: center; gap: 15px; min-height: 72px; padding: 10px 24px; border-bottom: 1px solid var(--line); }
.back-button, .back-to-chat { padding: 4px 6px; border: 0; background: transparent; color: var(--muted); font-size: 15px; }.back-button:hover, .back-to-chat:hover { color: var(--text); }
.detail-title { min-width: 0; flex: 1; }.detail-title h2 { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; font-weight: 600; }.detail-title .message { margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.status { color: var(--muted); font-size: 11px; white-space: nowrap; }.status.online { color: var(--accent-dark); }
.codex-history { flex: 1; overflow-y: auto; padding: 28px 24px 150px; scroll-behavior: smooth; }
.history-empty { padding: 48px 0; color: var(--muted); text-align: center; font-size: 14px; }
.chat-message { display: flex; gap: 15px; max-width: 760px; margin: 0 auto 27px; line-height: 1.65; font-size: 15px; }.message-avatar { width: 30px; height: 30px; flex: 0 0 30px; display: grid; place-items: center; border-radius: 50%; background: var(--text); color: #fff; font-size: 12px; font-weight: 600; }.from-user .message-avatar { background: #e9e9ea; color: var(--text); }.message-body { min-width: 0; flex: 1; }.message-author { margin: 2px 0 5px; font-size: 12px; font-weight: 600; }.message-content { overflow-wrap: anywhere; }.from-user .message-content { display: inline-block; padding: 8px 13px; border-radius: 12px; background: #f1f1f1; }
.message-content code { padding: 2px 4px; border-radius: 4px; background: #f1f1f1; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; }.code-block { margin: 12px 0; overflow: hidden; border: 1px solid #ddd; border-radius: 8px; background: #f7f7f8; }.code-header { display: flex; align-items: center; justify-content: space-between; padding: 7px 10px; color: var(--muted); font-size: 11px; }.copy-code { border: 0; background: transparent; color: var(--muted); font-size: 11px; }.copy-code:hover { color: var(--text); }.code-block pre { margin: 0; padding: 12px; overflow-x: auto; border-top: 1px solid #e5e5e5; font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
.composer { position: sticky; bottom: 0; margin: -110px auto 0; width: min(calc(100% - 48px), 760px); padding: 16px 0 22px; background: linear-gradient(transparent, #fff 23%); }.composer textarea { min-height: 54px; max-height: 180px; resize: vertical; padding: 15px 48px 15px 15px; border-color: #cfcfcf; border-radius: 13px; box-shadow: 0 2px 12px rgba(0,0,0,.06); }.composer-row { display: flex; align-items: center; justify-content: space-between; margin-top: -45px; padding: 0 9px 7px 15px; pointer-events: none; }.composer-row .message { flex: 1; margin-right: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }.send-button { width: 32px; height: 32px; border-radius: 8px; background: var(--text); color: white; pointer-events: auto; font-size: 20px; }
.page-heading { display: flex; align-items: center; gap: 11px; padding: 27px max(24px, calc((100% - 860px)/2)); }.page-heading > div { flex: 1; }.page-heading h1 { margin: 0; font-size: 26px; letter-spacing: -.03em; }.device-list, #view-commands > .panel, #view-admin > .panel { width: min(calc(100% - 48px), 860px); margin: 0 auto 16px; }.device-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(245px, 1fr)); gap: 12px; }.panel { padding: 20px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }.device-card { padding: 18px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }.device-card-heading { display: flex; justify-content: space-between; gap: 12px; }.device-card h3 { margin: 0; font-size: 15px; }.device-card p, .device-platform { margin: 5px 0 15px; color: var(--muted); font-size: 12px; }.metric { display: flex; justify-content: space-between; padding: 7px 0; border-top: 1px solid #f0f0f0; color: var(--muted); font-size: 12px; }.metric span:last-child { color: var(--text); font-weight: 500; }.form-card { display: grid; gap: 13px; }.form-card h3 { margin: 0 0 4px; font-size: 16px; }.form-card label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; }.form-card input, .form-card select, .form-card textarea { padding: 10px 12px; }.panel-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }.panel-heading h3 { margin: 0; font-size: 16px; }.command-row, .admin-user-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 15px; padding: 12px 0; border-top: 1px solid #f0f0f0; font-size: 12px; }.command-row small, .admin-user-row small { color: var(--muted); }.command-output { flex-basis: 100%; max-height: 130px; overflow: auto; padding: 9px; border-radius: 6px; background: var(--surface); font-size: 11px; white-space: pre-wrap; }.admin-user-row > div:first-child { display: grid; flex: 1; gap: 4px; min-width: 150px; }.admin-user-actions { display: flex; flex-wrap: wrap; gap: 5px; }.admin-user-actions .secondary-button { padding: 6px 8px; font-size: 11px; }

.sheet { position: fixed; inset: 0; z-index: 50; display: grid; align-items: end; }.sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.35); }.sheet-panel { position: relative; width: min(100%, 560px); max-height: 90dvh; overflow: auto; margin: 0 auto; padding: 18px 23px calc(23px + env(safe-area-inset-bottom)); border-radius: 18px 18px 0 0; background: #fff; box-shadow: 0 -8px 30px rgba(0,0,0,.12); }.sheet-handle { width: 38px; height: 4px; margin: 0 auto 17px; border-radius: 99px; background: #d1d1d1; }.sheet-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }.sheet-heading h2 { margin: 0; font-size: 21px; letter-spacing: -.03em; }.sheet-panel > .message { margin-bottom: 20px; }.sheet-panel label { display: grid; gap: 7px; margin: 13px 0; color: var(--muted); font-size: 12px; }.sheet-panel textarea, .sheet-panel input, .sheet-panel select { padding: 11px 12px; }.sheet-panel .full-button { margin-top: 9px; }
.alert-stack { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: grid; gap: 8px; width: min(360px, calc(100% - 36px)); }.alert { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 10px; background: #fff; box-shadow: 0 7px 25px rgba(0,0,0,.12); }.alert div { display: grid; gap: 3px; }.alert span { color: var(--muted); font-size: 12px; }.alert button { border: 0; background: transparent; color: var(--muted); font-size: 18px; }

@media (min-width: 800px) { .mobile-only, #menu-button { display: none; } }
@media (max-width: 799px) { :root { --drawer: min(86vw, 320px); }.drawer { position: fixed; top: 0; bottom: 0; left: 0; transform: translateX(-101%); transition: transform .2s ease; box-shadow: 5px 0 20px rgba(0,0,0,.12); }.drawer-open .drawer { transform: translateX(0); }.drawer-backdrop { position: fixed; inset: 0; z-index: 15; display: block; pointer-events: none; background: rgba(0,0,0,.35); opacity: 0; transition: opacity .2s ease; }.drawer-open .drawer-backdrop { pointer-events: auto; opacity: 1; }.content-shell { width: 100%; }.app-header { padding: 0 12px; }.model-picker { min-width: 110px; max-width: 180px; }.codex-history { padding: 20px 15px 140px; }.detail-heading { padding: 8px 13px; }.composer { width: calc(100% - 26px); }.page-heading { padding: 22px 16px; }.device-list, #view-commands > .panel, #view-admin > .panel { width: calc(100% - 26px); }.chat-message { gap: 10px; margin-bottom: 23px; font-size: 14px; }.message-avatar { width: 27px; height: 27px; flex-basis: 27px; font-size: 11px; }.chat-empty { padding: 24px 16px; }.chat-empty h1 { font-size: 27px; } }
@media (max-width: 430px) { .connection-status { display: none; }.header-actions .icon-button { width: 33px; }.detail-heading .status { display: none; }.sheet-panel { padding-left: 17px; padding-right: 17px; } }

/* Mobile shell: keep the header reachable and give the drawer one scrollable region. */
html { min-height: 100%; }
.drawer { height: 100dvh; min-height: 0; overflow: hidden; padding-top: calc(16px + env(safe-area-inset-top)); padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
.drawer-main { display: flex; flex: 1 1 auto; min-height: 0; flex-direction: column; overflow: hidden; }
.drawer-section { display: flex; flex: 1 1 auto; min-height: 0; flex-direction: column; overflow: hidden; }
.session-list { flex: 1 1 auto; min-height: 0; max-height: none; overflow-y: auto; overscroll-behavior: contain; }
.drawer-footer { flex: 0 0 auto; margin-top: 10px; }
.drawer-settings-toggle { width: 100%; display: flex; align-items: center; gap: 11px; padding: 10px 12px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); text-align: left; font-size: 13px; }
.drawer-settings-toggle:hover, .drawer-settings-toggle:focus-visible { background: #e9e9ea; color: var(--text); }
.drawer-settings-toggle > span:first-child { width: 18px; text-align: center; font-size: 17px; }
.drawer-settings-toggle strong { flex: 1; font-weight: 500; }
.drawer-settings-chevron { width: 18px; text-align: center; font-size: 17px; transition: transform .15s ease; }
.drawer-settings-toggle[aria-expanded="true"] .drawer-settings-chevron { transform: rotate(180deg); }
.drawer-settings-panel { padding-top: 4px; }
.drawer-settings-panel .drawer-nav { margin-top: 0; padding-top: 0; }
.app-header { position: sticky; top: 0; z-index: 30; height: calc(64px + env(safe-area-inset-top)); flex-basis: calc(64px + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top); }
.header-model-wrap { flex: 1 1 auto; justify-content: center; }
.header-actions { flex: 0 0 auto; }
.model-picker { max-width: min(240px, 58vw); }
.view, .chat-empty { min-height: calc(100dvh - 64px - env(safe-area-inset-top)); }
.session-detail { min-height: calc(100dvh - 64px - env(safe-area-inset-top)); }

@media (max-width: 799px) {
  .drawer { top: 0; bottom: 0; height: 100dvh; }
  .app-header { padding: env(safe-area-inset-top) 12px 0; }
  .model-picker { min-width: 0; }
}
