@import './theme.css';
@import './code.css';

:root {
  color-scheme: light dark;
  --bg: #f4f6f5; --surface: #fff; --soft: #f8faf9; --code-bg: var(--lm-code-bg);
  --ink: #1d2924; --muted: #607168; --line: #e0e7e3; --strong-line: #c6d2cc;
  --accent: var(--lm-accent); --accent-soft: var(--lm-accent-soft);
  --danger: #b73a36; --danger-soft: #fff0ef;
  --code-ink: var(--lm-code-ink); --code-muted: var(--lm-code-muted);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1210; --surface: #151c18; --soft: #19221d;
    --ink: #e0ebe4; --muted: #a2b3a8; --line: #2a3830; --strong-line: #465b4d;
    --danger: #ffaca5; --danger-soft: #381e1d;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
button, input, textarea, select { font: inherit; color: inherit; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
button { cursor: pointer; min-height: 32px; padding: 5px 10px; }
button:hover:not(:disabled) { background: var(--soft); border-color: var(--strong-line); }
button:disabled { opacity: .45; cursor: default; }
input, textarea, select { padding: 8px 10px; min-width: 0; }
input, textarea { caret-color: var(--accent); }
input[type="checkbox"] { accent-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--muted); }
textarea { display: block; width: 100%; resize: vertical; }
select { width: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline-offset: 1px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
h1, h2, p { margin: 0; }
h2 { font-size: 13px; font-weight: 500; }
.primary { background: var(--lm-brand); border-color: var(--lm-brand); color: var(--lm-on-brand); }
.primary:hover:not(:disabled) { background: var(--lm-brand-hover); border-color: var(--lm-brand-hover); }
.quiet, .text-button { border-color: transparent; background: transparent; }
.text-button { min-height: 28px; padding: 3px 0; color: var(--muted); font-size: 12px; }
.text-button:hover:not(:disabled) { color: var(--accent); background: transparent; border-color: transparent; }
/* Undoing something you set up (a key, a relay, results) is warm, the brand's complement — not the red kept for errors. */
.warm, .warm:hover:not(:disabled) { color: var(--lm-code-api); }
.warm:hover:not(:disabled) { text-decoration: underline; }
.workspace-toolbar { display: flex; align-items: center; gap: 20px; min-height: 64px; padding: 10px 24px; }
.brand { font-size: 19px; font-weight: 700; letter-spacing: -.7px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.connection, .toolbar-actions { display: flex; align-items: center; gap: 6px; min-width: 0; }
.toolbar-actions { margin-left: auto; }
.connection { flex: 1; }
.chip { display: inline-flex; align-items: center; justify-content: space-between; gap: 6px; min-width: 0; padding: 5px 8px; font-size: 12px; }
.chip > span:last-child { color: var(--muted); }
.provider-chip { max-width: 42%; }
.model-chip { flex: 1; }
#provider-name, #model-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.linking { color: var(--muted); font-size: 13px; margin-right: 6px; }
.reset-button { color: var(--muted); font-size: 13px; }
.reset-button:hover:not(:disabled) { color: var(--lm-code-api); background: transparent; border-color: transparent; text-decoration: underline; }
.more-menu { position: relative; }
.more-menu > summary { list-style: none; padding: 5px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); min-height: 32px; }
.more-menu > summary::-webkit-details-marker { display: none; }
summary { cursor: pointer; }
summary:hover { border-color: var(--strong-line); }
.more-content { position: absolute; z-index: 5; right: 0; top: calc(100% + 8px); width: min(330px, calc(100vw - 24px)); max-height: calc(100dvh - 100px); overflow: auto; padding: 18px; background: var(--surface); border: 1px solid var(--strong-line); border-radius: 8px; box-shadow: 0 8px 24px #0002; }
.more-section { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 14px; }
.more-links { display: flex; flex-direction: column; gap: 12px; font-size: 13px; }
.view-switch { display: none; }
.split { display: grid; grid-template-columns: minmax(340px, 1fr) minmax(380px, 1.02fr); height: calc(100dvh - 80px); min-height: 500px; margin: 0 24px 16px; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: var(--surface); }
.settings-panel, .chat-panel, .code-panel { min-height: 0; min-width: 0; display: flex; flex-direction: column; }
.settings-panel { background: var(--soft); border-right: 1px solid var(--line); }
/* The code panel folded: the conversation takes the room, a narrow strip keeps the way back. */
body[data-code="collapsed"] .split { grid-template-columns: minmax(340px, 1fr) 44px; }
body[data-code="collapsed"] .split .code-panel > :not(.code-toolbar) { display: none; }
body[data-code="collapsed"] .split .code-toolbar { flex-direction: column; justify-content: flex-start; padding: 8px 0; border-bottom: 0; }
body[data-code="collapsed"] .split .code-toolbar > .code-tabs, body[data-code="collapsed"] .split .code-tools > :not(.toggle-code) { display: none; }
body[data-code="collapsed"] .split .toggle-code { writing-mode: vertical-rl; min-height: 0; padding: 10px 6px; }
.toggle-code { font-size: 12px; color: var(--muted); white-space: nowrap; }
.settings-scroll { flex: 1; min-height: 0; overflow: auto; padding: 20px 16px; scrollbar-width: thin; scrollbar-color: var(--strong-line) transparent; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.section-heading a { font-size: 12px; }
.checkbox { display: flex; align-items: center; gap: 7px; font-size: 12px; cursor: pointer; min-height: 24px; }
.checkbox input { margin: 0; width: 14px; height: 14px; flex-shrink: 0; }
.setting-help { color: var(--muted); font-size: 12px; line-height: 1.6; margin-top: 6px; }
.setting-section { margin-top: 24px; }
.settings-panel label:not(.checkbox) { font-size: 13px; font-weight: 500; }
.setting-section select { margin-top: 8px; font-size: 13px; }
.field-error { margin-top: 8px; color: var(--danger); font-size: 12px; }
/* The system prompt opens the conversation: same voice as a turn's heading, the text growing with what is typed. */
.system-block { margin-bottom: 28px; }
.system-label { display: block; font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 8px; }
#system { padding: 12px 15px; border: 1px dashed var(--strong-line); border-radius: 7px; background: transparent; resize: none; overflow: auto; min-height: 44px; max-height: 260px; font-size: 14px; line-height: 1.8; }
#system:focus { border-style: solid; }
/* Sampling sits in the composer, under the message: three small fields, the code follows every keystroke. */
.composer-settings { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 4px 12px 0; }
.composer-settings .setting { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.composer-settings input, .composer-settings select { width: 84px; padding: 3px 6px; min-height: 26px; font-size: 12px; color: var(--ink); }
.composer-settings select { width: auto; }
.composer #settings-error { margin: 6px 12px 0; }
[aria-invalid="true"] { border-color: var(--danger); }
#loaded { overflow-wrap: anywhere; }
.note { font-size: 12px; color: var(--muted); }
.chat-scroll { flex: 1; min-height: 0; overflow: auto; padding: 18px 24px; scrollbar-width: thin; scrollbar-color: var(--strong-line) transparent; }
article { margin-bottom: 28px; }
.message-heading { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; }
article b { font-size: 12px; font-weight: 500; color: var(--muted); }
/* Every turn is a textarea that reads as text: no border on a reply, the usual box on a message; a focus shows it can be rewritten. */
.turn-text { padding: 0; border: 1px solid transparent; border-radius: 7px; background: transparent; resize: none; overflow: hidden; font-size: 14px; line-height: 1.8; color: var(--ink); }
article[data-role="user"] .turn-text { padding: 12px 15px; border-color: var(--line); background: var(--soft); }
article[data-role="assistant"] .turn-text { margin: 0 -8px; padding: 0 8px; }
.turn-text:hover:not(:read-only) { border-color: var(--strong-line); }
.turn-text:focus { outline: none; border-color: var(--accent); }
article[data-invalid] .turn-text { border-color: var(--danger); }
article[data-incomplete] { opacity: .65; }
article.streaming .turn-text::placeholder { color: var(--muted); font-size: 12px; }
.composer-area { padding: 12px 20px; }
.composer { position: relative; border: 1px solid var(--strong-line); border-radius: 8px; background: var(--surface); }
.composer:focus-within { border-color: var(--accent); }
#prompt { padding: 14px 14px 4px; border: 0; background: transparent; resize: none; overflow: auto; min-height: 70px; max-height: 220px; font-size: 14px; outline: none; }
.composer-actions { display: flex; align-items: center; gap: 6px; padding: 8px 10px 10px; }
.composer-actions > button { flex-shrink: 0; }
.composer-actions:has(.stop-button:not(:disabled)) #send { display: none; }
.stop-button:disabled { display: none; }
#alert { white-space: pre-wrap; max-height: 110px; overflow: auto; padding: 10px 12px; margin-bottom: 12px; border-radius: 6px; background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger); font-size: 12px; }
.usage { color: var(--muted); font-size: 12px; margin-bottom: 7px; overflow-wrap: anywhere; }
.usage:empty { display: none; }
.fidelity { color: var(--accent); }
.code-panel { background: var(--code-bg); border-left: 1px solid var(--line); }
.code-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 14px; border-bottom: 1px solid var(--line); }
.code-tools { display: flex; align-items: center; gap: 10px; }
.request-note { padding: 8px 16px 0; }
.request-note:empty { display: none; }
.code-panel pre[data-view="request"] { font-size: 14px; }
#copy-code { font-size: 12px; color: var(--muted); white-space: nowrap; }
.code-tabs { display: flex; gap: 14px; flex-wrap: wrap; }
.code-tabs button { min-height: 48px; padding: 8px 0; border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: transparent; color: var(--muted); font-size: 12px; }
.code-tabs button:hover:not(:disabled) { background: transparent; }
.code-tabs button[aria-pressed="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.code-body { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
/* While a runtime loads, the code stays visible but steps back; the card says what is happening. */
.code-body[data-loading] pre { opacity: 0.35; transition: opacity 200ms; }
.code-panel pre { flex: 1; min-height: 0; overflow: auto; margin: 0; padding: 16px; font-size: 16px; background: transparent; scrollbar-width: thin; scrollbar-color: var(--strong-line) transparent; }
/* What the generator marked (marks.ts) is coloured by the shared code.css; here, only the playground's own behaviour. */
.tok-value { border-radius: 3px; transition: background-color 120ms; }
/* The control on the left whose value is under the pointer on the right (or under the caret). */
#chat-panel .lit { border-color: var(--accent) !important; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent); }
#prompt.lit { box-shadow: none; background: color-mix(in srgb, var(--accent) 6%, transparent); }
/* The value whose control is under the pointer or the caret on the left. */
#code .lit { background: color-mix(in srgb, var(--accent) 14%, transparent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 14%, transparent); color: var(--lm-accent-strong); }
/* An opaque payload: read as "some blob", opened only on purpose. The hidden middle stays in the DOM, so Copy is exact. */
.tok-opaque.folded { cursor: pointer; }
.tok-opaque.folded .fold { display: none; }
.tok-opaque .fold-note { display: none; }
.tok-opaque.folded .fold-note::before { content: attr(data-hidden); }
.tok-opaque.folded .fold-note { display: inline; margin: 0 2px; padding: 0 6px; border: 1px dashed var(--strong-line); border-radius: 4px; font-size: 12px; color: var(--muted); font-style: italic; }
.tok-opaque.folded:hover .fold-note { border-color: var(--accent); color: var(--accent); }
.tok-opaque:not(.folded) { cursor: pointer; }
/* The loading card: centred over the code, one message at a time, a bar only when the bytes are being counted. */
.runtime-card { position: absolute; inset: 0; margin: auto; width: min(340px, calc(100% - 32px)); height: fit-content; padding: 22px 24px 20px; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px color-mix(in srgb, var(--ink) 12%, transparent); }
.runtime-card[hidden] { display: none; }
.runtime-title { margin: 6px 0 0; font-weight: 600; font-size: 15px; }
.runtime-phase { margin: 0; font-size: 13px; color: var(--muted); min-height: 1.4em; overflow-wrap: anywhere; }
.runtime-note { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.runtime-note:empty { display: none; }
.runtime-card button { margin-top: 10px; }
.runtime-bar { width: 100%; height: 6px; margin-top: 8px; border-radius: 3px; background: var(--accent-soft); overflow: hidden; }
.runtime-bar[hidden] { display: none; }
.runtime-bar-fill { height: 100%; width: var(--fraction, 0%); background: var(--accent); border-radius: 3px; transition: width 160ms linear; }
/* Not yet measurable: a short segment sweeps instead of a filling bar. */
.runtime-bar[data-indeterminate] .runtime-bar-fill { width: 35%; animation: runtime-sweep 1.4s ease-in-out infinite; }
@keyframes runtime-sweep { from { transform: translateX(-100%); } to { transform: translateX(290%); } }
/* A transform animation with will-change runs on the compositor, so it keeps turning while the main thread compiles a module. */
.runtime-spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--accent-soft); border-top-color: var(--accent); animation: runtime-spin 0.9s linear infinite; will-change: transform; }
.runtime-card[data-state="error"] .runtime-spinner { display: none; }
.runtime-card[data-state="error"] .runtime-title { color: var(--danger); }
@keyframes runtime-spin { to { transform: rotate(360deg); } }
/* The loading tab carries a small pulsing dot: the other tabs stay quiet. */
.code-tabs[data-state="loading"] button[aria-pressed="true"]::after { content: ""; display: inline-block; width: 6px; height: 6px; margin-left: 6px; vertical-align: 2px; border-radius: 50%; background: var(--accent); animation: runtime-pulse 1.2s ease-in-out infinite; }
@keyframes runtime-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
@media (prefers-reduced-motion: reduce) {
  .runtime-spinner, .runtime-bar[data-indeterminate] .runtime-bar-fill, .code-tabs[data-state="loading"] button[aria-pressed="true"]::after { animation: none; }
  .runtime-bar[data-indeterminate] .runtime-bar-fill { width: 100%; opacity: 0.4; }
}
dialog { width: min(94vw, 500px); max-height: 80dvh; padding: 20px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; }
dialog::backdrop { background: #10241c55; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 15px; }
.dialog-text p { margin: 0 0 12px; font-size: 14px; line-height: 1.5; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 16px; }
#picker-search { width: 100%; padding: 12px; }
.picker-status { color: var(--muted); font-size: 12px; margin: 12px 0; }
.picker-status:empty { display: none; }
.picker-status.is-error { color: var(--danger); }
#picker[data-kind="provider"] { width: min(94vw, 600px); }
#picker[data-kind="provider"] #picker-search { margin-bottom: 12px; }
/* A provider's row: the name, and at its right the key — masked with Forget, or a field to paste one. */
[role="option"] { display: flex; align-items: center; gap: 12px; min-height: 48px; }
#picker[data-kind="provider"] [role="listbox"] { max-height: min(60dvh, 560px); }
.pick-main { flex: 1; min-width: 0; }
.pick-trailing { flex-shrink: 0; }
.key-slot { display: flex; align-items: center; gap: 8px; }
.key-slot input { width: 200px; padding: 5px 8px; min-height: 28px; font-size: 12px; }
.key-slot input[type="url"] { width: 240px; font-family: ui-monospace, Consolas, monospace; }
.key-mask { font-family: ui-monospace, Consolas, monospace; letter-spacing: 2px; color: var(--muted); }
.key-local { font-size: 12px; color: var(--muted); }
.key-forget { min-height: 0; padding: 0; }
.key-page { font-size: 12px; white-space: nowrap; }
.picker-remember { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); }
[role="listbox"] { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow: auto; }
[role="option"] { padding: 10px 12px; border-radius: 6px; cursor: pointer; }
.pick-main span, .pick-main small { display: block; }
[role="option"] small { color: var(--muted); font-size: 12px; margin-top: 2px; }
[role="option"][aria-selected="true"], [role="option"]:hover { background: var(--accent-soft); }
.slash-picker { position: absolute; z-index: 3; bottom: calc(100% + 8px); left: 0; right: 0; padding: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px #0002; }
.slash-picker .picker-status { margin: 3px 4px 8px; }
.about-page { max-width: 740px; margin: 40px auto; padding: 0 24px; font-size: 16px; }
.about-page h1 { font-size: 28px; margin: 24px 0; }
.about-page h2 { font-size: 20px; margin: 30px 0 12px; }
.about-page p, .about-page li { margin: 12px 0; }

/* ─── Mode switch ─── */
.mode-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; padding: 2px; background: var(--surface); }
.mode-switch button { border: 0; background: transparent; color: var(--muted); min-height: 28px; padding: 2px 14px; border-radius: 5px; font-size: 13px; }
.mode-switch button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.mode-switch button:disabled { opacity: .55; cursor: not-allowed; }
.mode-switch button:hover:not(:disabled) { background: var(--soft); border-color: transparent; }
.mode-switch button[aria-pressed="true"]:hover:not(:disabled) { background: var(--accent-soft); }

/* ─── Judge mode ─── */
.judge-code-slot { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.judge-code-slot .code-panel { flex: 1; min-height: 0; }
/* Judge's left column: the state, the questions, then the result, in the conversation's own voice. */
.judge-block { margin-bottom: 28px; }
.judge-block > .section-heading { margin-bottom: 8px; }
.judge-block .system-label { margin-bottom: 0; }
.state-text, .state-json { width: 100%; padding: 12px 15px; border: 1px dashed var(--strong-line); border-radius: 7px; background: transparent; resize: none; overflow: auto; min-height: 44px; max-height: 320px; font-size: 14px; line-height: 1.8; }
.state-json { font: 13px/1.65 ui-monospace, Consolas, monospace; }
.state-text:focus, .state-json:focus { border-style: solid; }
.judge-state .convo { padding: 8px 4px; border: 1px dashed var(--strong-line); border-radius: 7px; }
.judge-state .msg textarea { font-size: 14px; line-height: 1.7; }
#judge-result.stale #judge-answers { opacity: .55; }
#judge-answers pre { margin: 0; font: 12.5px/1.55 ui-monospace, Consolas, monospace; color: var(--code-ink); white-space: pre-wrap; overflow-wrap: anywhere; }
.run-composer { padding: 0; }
.run-composer .composer-actions { padding: 10px; }
.method-line { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 55%; }
.paths-hint { margin: 10px 0 12px; padding: 8px 10px; border: 1px dashed var(--strong-line); border-radius: 6px; font-size: 12px; color: var(--muted); line-height: 1.6; }
.paths-hint code { color: var(--accent); font: 12px ui-monospace, Consolas, monospace; }
.muted { color: var(--muted); }
/* question cards */
.question-list { margin-top: 10px; }
.question { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); margin-bottom: 10px; }
.question > summary { list-style: none; display: flex; align-items: center; gap: 8px; padding: 10px 12px; cursor: pointer; }
.question > summary::-webkit-details-marker { display: none; }
.question > summary::before { content: "▸"; color: var(--muted); font-size: 11px; width: 10px; }
.question[open] > summary::before { content: "▾"; }
.question .qname { font-weight: 600; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.question .qkind { margin-left: auto; font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; white-space: nowrap; }
.question .qbody { padding: 0 12px 12px; border-top: 1px solid var(--line); }
.question .field { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 0; }
.question .field input { display: block; width: 100%; margin-top: 4px; font-size: 13px; padding: 6px 8px; color: var(--ink); }
.question input.mono { font-family: ui-monospace, Consolas, monospace; }
.levels { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.levels li { display: grid; grid-template-columns: 16px minmax(60px, 2fr) minmax(60px, 3fr) auto; gap: 6px; align-items: center; font-size: 12px; }
.levels li .n { color: var(--muted); font-family: ui-monospace, monospace; text-align: right; }
.levels li input { padding: 3px 6px; font-size: 12px; min-width: 0; }
.levels li input.key { font-family: ui-monospace, Consolas, monospace; }
.levels li .x, .msg .x { border: 0; background: none; color: var(--muted); min-height: 0; padding: 0 4px; font-size: 14px; line-height: 1; }
.levels li .x:hover, .msg .x:hover { color: var(--danger); background: none; border-color: transparent; }
.remove-question { margin-top: 10px; }
.add-question { width: 100%; margin-top: 4px; font-size: 13px; }
/* raw JSON editor */
.raw-editor { display: flex; flex-direction: column; min-height: 240px; height: 360px; margin-top: 10px; border: 1px solid var(--strong-line); border-radius: 8px; background: var(--code-bg); overflow: hidden; }
.raw-editor:focus-within { border-color: var(--accent); }
#judge-raw-json { flex: 1; border: 0; border-radius: 0; background: transparent; resize: none; width: 100%; padding: 14px; font: 13px/1.65 ui-monospace, Consolas, monospace; color: var(--code-ink); outline: none; white-space: pre-wrap; overflow: auto; tab-size: 2; }
.raw-status { display: flex; align-items: center; gap: 10px; padding: 6px 12px; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--muted); }
.raw-status .ok { color: var(--accent); }
.raw-status .bad { color: var(--danger); overflow-wrap: anywhere; }
.raw-status .spacer, .section-heading .spacer { flex: 1; }
.judge-connection { flex: 1; }
#judge-alert { white-space: pre-wrap; max-height: 110px; overflow: auto; padding: 10px 12px; margin-bottom: 12px; border-radius: 6px; background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger); font-size: 12px; }
.method-line { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60%; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; padding: 2px; background: var(--surface); }
.seg button { border: 0; background: transparent; color: var(--muted); min-height: 22px; padding: 0 9px; border-radius: 4px; font-size: 12px; }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.seg button:hover:not(:disabled) { border-color: transparent; }
.convo { display: flex; flex-direction: column; gap: 4px; }
.msg { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 8px; align-items: start; }
.msg .role { font: 11px ui-monospace, Consolas, monospace; color: var(--muted); padding: 5px 0 0 4px; }
.msg .role.assistant { color: var(--accent); }
.msg .x { padding: 4px; visibility: hidden; }
.msg:hover .x, .msg:focus-within .x { visibility: visible; }
.add-msg { font-size: 11.5px; color: var(--muted); padding: 2px 0 0 72px; }
.add-msg .text-button { min-height: 0; padding: 0 2px; font-size: 11.5px; }
.answers { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; }
.ans { min-width: 0; }
.ans .q { display: block; font: 11px ui-monospace, Consolas, monospace; color: var(--muted); margin-bottom: 1px; }
.ans .line { display: flex; align-items: flex-end; gap: 9px; }
.ans .pick { font-weight: 600; font-size: 13px; line-height: 1.25; display: block; overflow-wrap: anywhere; }
.ans .p { display: block; margin-top: 1px; font-weight: 400; color: var(--muted); font-size: 12px; }
.spark { display: inline-flex; align-items: flex-end; gap: 2px; height: 26px; flex-shrink: 0; padding-bottom: 1px; border-bottom: 1px solid var(--line); cursor: default; border-radius: 2px; }
.spark i { display: block; width: 7px; min-height: 2px; border-radius: 1px 1px 0 0; background: color-mix(in srgb, var(--accent) 38%, transparent); }
.spark i.top { background: var(--accent); }
.spark.boolean i { width: 10px; }
.spark:hover i, .spark:focus-visible i { background: color-mix(in srgb, var(--accent) 28%, transparent); }
.spark:hover i.top, .spark:focus-visible i.top { background: color-mix(in srgb, var(--accent) 60%, transparent); }
.spark i.hover, .spark i.hover.top { background: var(--accent) !important; }
.out-meta { font-size: 11px; color: var(--muted); margin-top: 6px; }
.out-meta .bad { color: var(--danger); font-weight: 500; }
.out-row pre { margin: 0; font: 12.5px/1.55 ui-monospace, Consolas, monospace; color: var(--code-ink); white-space: pre-wrap; overflow-wrap: anywhere; }
.pop { position: fixed; z-index: 20; pointer-events: none; min-width: 190px; max-width: 320px; padding: 8px 10px; background: var(--surface); color: var(--ink); border: 1px solid var(--strong-line); border-radius: 7px; box-shadow: 0 6px 20px #0003; font-size: 12px; }
.pop .ph { font: 11px ui-monospace, Consolas, monospace; color: var(--muted); margin-bottom: 5px; }
.pop .pr { display: grid; grid-template-columns: minmax(70px, auto) 90px 38px; gap: 8px; align-items: center; padding: 1px 0; }
.pop .pr .k { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pop .pr .n { color: var(--muted); font-family: ui-monospace, monospace; font-size: 11px; margin-right: 7px; }
.pop .pr i { display: block; height: 5px; border-radius: 2px; background: color-mix(in srgb, var(--accent) 35%, transparent); }
.pop .pr.top .k { font-weight: 600; } .pop .pr.top i { background: var(--accent); }
.pop .pr.hover { background: var(--accent-soft); margin: 0 -6px; padding: 1px 6px; border-radius: 4px; }
.pop .pr b { font-weight: 400; text-align: right; font-family: ui-monospace, monospace; color: var(--muted); }
.pop .pf { margin-top: 6px; padding-top: 5px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }

@media (min-width: 1700px) { .split { grid-template-columns: minmax(400px, 1fr) minmax(500px, 1.05fr); } .settings-scroll { padding: 24px; } .chat-scroll { padding: 24px 40px; } }
@media (max-width: 1100px) {
  .workspace-toolbar { padding: 10px 16px; }
  .split { grid-template-columns: minmax(0, 1fr); margin: 0 16px 12px; height: calc(100dvh - 116px); }
  /* One panel at a time here: the Chat / Code switch does the folding, so the desktop toggle steps aside. */
  body[data-code="collapsed"] .split { grid-template-columns: minmax(0, 1fr); }
  body[data-code="collapsed"] .split .code-panel > :not(.code-toolbar), body[data-code="collapsed"] .split .code-toolbar > .code-tabs, body[data-code="collapsed"] .split .code-tools > :not(.toggle-code) { display: revert; }
  body[data-code="collapsed"] .split .code-toolbar { flex-direction: row; justify-content: space-between; padding: 0 14px; border-bottom: 1px solid var(--line); }
  .toggle-code { display: none; }
  .view-switch { display: flex; gap: 4px; height: 40px; margin: 0 16px; align-items: start; }
  .view-switch button { border: 0; background: transparent; color: var(--muted); font-size: 13px; padding: 4px 15px; }
  .view-switch button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
  .view-switch [data-view-target="settings"] { display: none; }
  body:not([data-view="code"]) .code-panel { display: none; }
  body[data-view="code"] .chat-panel { display: none; }
  .code-panel { border-left: 0; }
}
@media (max-width: 700px) {
  .workspace-toolbar { min-height: 52px; padding: 8px 12px; gap: 10px; }
  .linking { display: none; } /* hover has no meaning on a touch screen */
  .chip { padding: 5px 6px; }
  .split { display: flex; margin: 0 10px 10px; height: calc(100dvh - 102px); min-height: 380px; }
  .view-switch { margin: 0 12px; }
  .view-switch button { flex: 1; }
  .settings-panel, .chat-panel, .code-panel, .judge-code-slot { flex: 1; width: 100%; }
  .mode-switch button { padding: 2px 10px; }
  .answers { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px 12px; }
  .ans .pick { overflow-wrap: normal; }
  body:not([data-view="chat"]) .chat-panel { display: none; }
  body:not([data-view="code"]) .code-panel { display: none; }
  .settings-panel { border-right: 0; }
  .settings-scroll { padding: 20px; }
  input:not([type="checkbox"]), textarea, select, #system, #prompt { font-size: 16px; }
  /* Three small cells, label above field: the phone keeps the sampling controls without a second scroll. */
  .composer-settings { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 4px 10px 0; }
  .composer-settings .setting { flex-direction: column; align-items: stretch; gap: 2px; font-size: 11px; }
  .composer-settings input, .composer-settings select { width: 100%; font-size: 16px; }
  [role="option"] { flex-wrap: wrap; }
  .key-slot input { width: 100%; }
  .chat-scroll { padding: 12px 20px; }
  .composer-area { padding: 10px 12px; }
  .code-toolbar { gap: 6px; padding: 0 10px; flex-wrap: wrap; }
  .code-tabs { gap: 12px; }
  #copy-code { margin-left: auto; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; } }

/* The sign-in lab (login-lab.ts). */
.login-lab { width: min(96vw, 820px); max-height: 90dvh; }
.login-lab h3 { font-size: 13px; margin: 20px 0 8px; }
.lab-consent { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px 4px; margin: 14px 0 0; }
.lab-consent legend { font-size: 12px; font-weight: 600; padding: 0 4px; }
.lab-check { align-items: flex-start; line-height: 1.5; margin: 8px 0; }
.lab-check input { margin-top: 3px; }
.lab-method { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 13px; }
.lab-method-main { flex: 1; min-width: 0; }
.lab-method[data-availability="unavailable"] .lab-method-main { color: var(--muted); }
.lab-start { padding: 5px 12px; font-size: 12px; }
.lab-attempt { margin-top: 16px; padding: 12px 14px; border: 1px solid var(--strong-line); border-radius: 8px; background: var(--soft); font-size: 13px; }
.lab-attempt-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.lab-notice { margin: 10px 0; }
.lab-notice p { margin: 0 0 8px; line-height: 1.5; }
.lab-code code { font-size: 22px; letter-spacing: 2px; font-weight: 600; }
.lab-prompt { margin: 10px 0; display: grid; gap: 6px; }
.lab-prompt label { font-size: 12px; font-weight: 500; }
.lab-prompt-row { display: flex; gap: 8px; }
.lab-prompt-row input { flex: 1; min-width: 0; padding: 6px 8px; }
.lab-ok { color: var(--accent); margin: 8px 0 0; }
.lab-info { color: var(--lm-code-api); }
.lab-session { padding: 8px 0; border-top: 1px solid var(--line); font-size: 13px; }
.lab-session-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 6px; }
.lab-session-actions input { width: 220px; padding: 4px 8px; font-size: 12px; }
.lab-result { overflow-wrap: anywhere; }
.lab-log-heading { display: flex; justify-content: space-between; align-items: baseline; }
.lab-log { overflow-x: auto; }
.lab-log table { width: 100%; border-collapse: collapse; font-size: 12px; }
.lab-log th, .lab-log td { text-align: left; padding: 4px 8px 4px 0; border-top: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
.lab-log th { color: var(--muted); font-weight: 500; }
.lab-log td:nth-child(1), .lab-log td:nth-child(2), .lab-log td:nth-child(4), .lab-log td:nth-child(6) { white-space: nowrap; overflow-wrap: normal; }
.lab-log tr[data-ok="false"] td { color: var(--danger); }
.lab-log tr.lab-outcome td { font-weight: 500; }
.lab-return-banner { margin: 0; padding: 10px 24px; background: var(--accent-soft); color: var(--ink); font-size: 13px; }
.lab-relay-address { display: grid; gap: 4px; font-size: 12px; color: var(--muted); margin: 0 0 10px; }
.lab-relay-url { padding: 4px 8px; font-size: 12px; }
.lab-mode { display: grid; gap: 2px; margin: 4px 0 8px; }
