/* Qcmology Support Studio · agent playground.
   Theme tokens mirror dashboard.css so the playground follows the inbox appearance
   (cobalt/graphite, light/dark) chosen through appearance.js. Keep them in sync. */

:root {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-synthesis: none; -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
  --page-safe-top: env(safe-area-inset-top); --page-safe-right: env(safe-area-inset-right);
  --page-safe-bottom: env(safe-area-inset-bottom); --page-safe-left: env(safe-area-inset-left);
  --radius: 12px; --radius-l: 18px; --bubble: 20px; --pill: 999px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}
:root[data-design="cobalt"][data-mode="light"] {
  --canvas: #f2f4f8; --surface: #ffffff; --soft: #eef1f6; --rail: #f7f8fb; --ink: #0f172a; --muted: #566074;
  --line: #e2e6ee; --border: #c8cfdb; --accent: #2458e0; --accent-hover: #1b47bd; --on-accent: #ffffff; --accent-soft: #e7eeff;
  --outgoing: #2458e0; --outgoing-ink: #ffffff; --ai-bg: #e3eafb; --ai-ink: #14224a;
  --ms-bg: #e3ecff; --ms-ink: #1d4ed8; --ig-bg: #fde6ef; --ig-ink: #a3214f; --success: #147a3d;
  --amber: #93460a; --amber-soft: #fff3e3; --danger: #b8233b; --danger-soft: #fdedf0;
  --shadow: rgba(15, 23, 42, .10); --shadow-strong: rgba(15, 23, 42, .18); --overlay: rgba(15, 23, 42, .38);
  --toast: #0f172a; --contrast-ink: #ffffff; --focus: #2458e0; --skeleton: #e6eaf1;
}
:root[data-design="cobalt"][data-mode="dark"] {
  --canvas: #0a0f1c; --surface: #111827; --soft: #1a2334; --rail: #0d1422; --ink: #e9eef8; --muted: #9ba6ba;
  --line: #222c3f; --border: #3a4760; --accent: #82a7ff; --accent-hover: #a1bdff; --on-accent: #0a1633; --accent-soft: #1b2a4d;
  --outgoing: #2f5fe0; --outgoing-ink: #ffffff; --ai-bg: #1c2742; --ai-ink: #e6ecfa;
  --ms-bg: #1b2a4d; --ms-ink: #9dbbff; --ig-bg: #3a1a2a; --ig-ink: #ff9ec3; --success: #4ade80;
  --amber: #f4b860; --amber-soft: #33240f; --danger: #ff8d9e; --danger-soft: #3a1820;
  --shadow: rgba(0, 0, 0, .35); --shadow-strong: rgba(0, 0, 0, .55); --overlay: rgba(2, 6, 16, .62);
  --toast: #e9eef8; --contrast-ink: #0a0f1c; --focus: #82a7ff; --skeleton: #1d2638;
}
:root[data-design="graphite"][data-mode="light"] {
  --canvas: #f4f4f5; --surface: #ffffff; --soft: #f0f0f2; --rail: #fafafa; --ink: #18181b; --muted: #5c5c66;
  --line: #e4e4e7; --border: #c9c9cf; --accent: #18181b; --accent-hover: #000000; --on-accent: #ffffff; --accent-soft: #ececef;
  --outgoing: #27272a; --outgoing-ink: #fafafa; --ai-bg: #e8e8eb; --ai-ink: #18181b;
  --ms-bg: #ececef; --ms-ink: #1d4ed8; --ig-bg: #fbe8ef; --ig-ink: #a3214f; --success: #147a3d;
  --amber: #93460a; --amber-soft: #fff3e3; --danger: #b8233b; --danger-soft: #fdedf0;
  --shadow: rgba(0, 0, 0, .08); --shadow-strong: rgba(0, 0, 0, .16); --overlay: rgba(0, 0, 0, .36);
  --toast: #18181b; --contrast-ink: #ffffff; --focus: #18181b; --skeleton: #e9e9ec;
}
:root[data-design="graphite"][data-mode="dark"] {
  --canvas: #0c0c0e; --surface: #18181b; --soft: #222226; --rail: #111113; --ink: #f4f4f5; --muted: #a1a1aa;
  --line: #2b2b30; --border: #45454d; --accent: #f4f4f5; --accent-hover: #ffffff; --on-accent: #18181b; --accent-soft: #2b2b30;
  --outgoing: #3f3f46; --outgoing-ink: #fafafa; --ai-bg: #26262b; --ai-ink: #f4f4f5;
  --ms-bg: #26262b; --ms-ink: #9dbbff; --ig-bg: #33202a; --ig-ink: #ff9ec3; --success: #4ade80;
  --amber: #f4b860; --amber-soft: #33240f; --danger: #ff8d9e; --danger-soft: #3a1820;
  --shadow: rgba(0, 0, 0, .4); --shadow-strong: rgba(0, 0, 0, .6); --overlay: rgba(0, 0, 0, .62);
  --toast: #f4f4f5; --contrast-ink: #0c0c0e; --focus: #f4f4f5; --skeleton: #232327;
}
html[data-design="graphite"] { --radius: 8px; --radius-l: 12px; --bubble: 14px; }
html.support-android-viewport { --page-safe-top: 0px; }
html.support-android-webview { --page-safe-right: 0px; --page-safe-bottom: 0px; --page-safe-left: 0px; }
:root { --header-h: 64px; --sidebar-w: 268px; --inspector-w: 340px; }

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; }
html { color: var(--ink); background: var(--canvas); }
html.support-android-webview, html.support-android-webview body { touch-action: pan-x pan-y; }
body { margin: 0; overflow: hidden; background: var(--canvas); color: var(--ink); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
p { margin: 0; }
[hidden] { display: none !important; }
:is(button, a, input, select, textarea, summary, label):focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
kbd { font: inherit; font-size: 11px; padding: 0 5px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; background: var(--surface); }

/* ---------- Controls ---------- */
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--ink); font-size: 14px; font-weight: 600; white-space: nowrap; transition: background .15s, border-color .15s, transform .1s; }
.button .icon { width: 18px; height: 18px; }
.button:hover:not(:disabled) { background: var(--soft); }
.button:active:not(:disabled) { transform: translateY(1px); }
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.button.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.button.ghost:hover:not(:disabled), .button.ghost[aria-expanded="true"] { background: var(--soft); color: var(--ink); }
.button.block { width: 100%; }
.button.is-busy { position: relative; color: transparent !important; pointer-events: none; }
.button.is-busy::after { content: ""; position: absolute; width: 16px; height: 16px; border: 2px solid currentColor; border-color: var(--muted) transparent var(--muted) transparent; border-radius: 50%; animation: spin .8s linear infinite; }
.button.primary.is-busy::after { border-color: var(--on-accent) transparent var(--on-accent) transparent; }
.icon-button { display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none; padding: 0; border: 0; border-radius: var(--radius); background: transparent; color: var(--muted); cursor: pointer; }
.icon-button:hover { background: var(--soft); color: var(--ink); }
.section-label, .eyebrow, .field-label { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .35; } }
@keyframes bounce { 0%, 80%, 100% { transform: translateY(0); opacity: .45; } 40% { transform: translateY(-4px); opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Layout ---------- */
.pg { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--inspector-w); height: 100dvh; padding: var(--page-safe-top) var(--page-safe-right) 0 var(--page-safe-left); }
.compact-only { display: none !important; }
.scrim { position: fixed; inset: 0; z-index: 20; background: var(--overlay); animation: rise .15s var(--ease); }

/* ---------- Sidebar ---------- */
.pg-sidebar { display: flex; flex-direction: column; gap: 12px; min-height: 0; padding: 20px 14px 16px; background: var(--rail); border-right: 1px solid var(--line); }
.sidebar-head { display: flex; align-items: flex-start; justify-content: space-between; padding: 0 6px; }
.brand { color: var(--ink); font-size: 28px; font-weight: 800; letter-spacing: -.06em; line-height: 1; }
.brand span { font-size: 20px; letter-spacing: -.04em; }
.brand small { display: block; margin-top: 6px; font-size: 10px; font-weight: 700; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); }
.back-link { display: inline-flex; align-items: center; gap: 8px; padding: 6px; border-radius: var(--radius); color: var(--muted); font-size: 13px; font-weight: 600; }
.back-link .icon { width: 16px; height: 16px; }
.back-link:hover { color: var(--ink); background: var(--soft); }
.search-field { position: relative; display: block; }
.search-field .icon { position: absolute; left: 11px; top: 50%; width: 16px; height: 16px; color: var(--muted); transform: translateY(-50%); pointer-events: none; }
.search-field input { width: 100%; height: 38px; padding: 0 12px 0 34px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); font-size: 13px; }
.pg-sidebar .section-label { padding: 4px 6px 0; }
.conversation-list { flex: 1; min-height: 0; overflow-y: auto; margin: 0 -4px; padding: 0 4px; scrollbar-width: thin; }
.conversation-list button { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 8px; width: 100%; margin: 0 0 2px; padding: 9px 10px; border: 0; border-radius: var(--radius); background: transparent; color: var(--ink); text-align: left; }
.conversation-list button:hover { background: var(--soft); }
.conversation-list button.active { background: var(--accent-soft); }
.conversation-list .conv-label { overflow: hidden; font-size: 14px; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; }
.conversation-list .conv-time { font-size: 12px; color: var(--muted); }
.conversation-list .conv-meta { grid-column: 1 / -1; display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); }
.conv-flag { padding: 0 6px; border-radius: var(--pill); background: var(--amber-soft); color: var(--amber); font-size: 11px; font-weight: 600; }
.sidebar-empty { padding: 4px 8px; font-size: 13px; color: var(--muted); }
.sidebar-foot { padding: 12px 8px 0; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); line-height: 1.5; }
.env-row { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; color: var(--ink); font-weight: 600; font-size: 13px; }
.env-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 20%, transparent); }

/* ---------- Main ---------- */
.pg-main { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--canvas); }
.pg-header { position: relative; z-index: 25; display: flex; align-items: center; gap: 10px; height: var(--header-h); padding: 0 20px; border-bottom: 1px solid var(--line); background: var(--surface); }
.title-block { flex: 1; min-width: 0; }
.eyebrow { display: flex; align-items: center; gap: 5px; font-size: 10px; }
.eyebrow .icon { width: 13px; height: 13px; }
.pg-header h1 { margin-top: 2px; overflow: hidden; font-size: 17px; font-weight: 700; white-space: nowrap; text-overflow: ellipsis; }
.header-actions { display: flex; flex: none; align-items: center; gap: 6px; }
.model-chip, .status-chip, .status-pill, .batching-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 260px; min-height: 28px; padding: 3px 10px; border: 1px solid var(--line); border-radius: var(--pill); background: var(--soft); color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.model-chip { cursor: pointer; }
.model-chip:hover { color: var(--ink); border-color: var(--border); }
.status-chip::before, .status-pill::before { content: ""; width: 7px; height: 7px; flex: none; border-radius: 50%; background: currentColor; }
.state-ai { background: color-mix(in srgb, var(--success) 12%, var(--surface)); border-color: color-mix(in srgb, var(--success) 30%, var(--surface)); color: var(--success); }
.state-paused, .state-hold { background: var(--amber-soft); border-color: color-mix(in srgb, var(--amber) 30%, var(--surface)); color: var(--amber); }
.state-none::before { display: none; }

/* ---------- Thread ---------- */
.thread { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 24px max(20px, calc((100% - 760px) / 2)) 16px; scrollbar-width: thin; }
.welcome { max-width: 640px; margin: 4vh auto 0; text-align: center; animation: rise .3s var(--ease); }
.welcome-mark { display: grid; place-items: center; width: 56px; height: 56px; margin: 0 auto 18px; border-radius: 18px; background: var(--accent-soft); color: var(--accent); }
.welcome-mark .icon { width: 28px; height: 28px; }
.welcome h2 { font-size: 24px; font-weight: 750; letter-spacing: -.02em; }
.welcome > p { max-width: 460px; margin: 10px auto 28px; color: var(--muted); font-size: 15px; line-height: 1.55; }
.welcome .section-label { margin-bottom: 10px; text-align: left; }
.presets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; text-align: left; }
.presets button { display: flex; flex-direction: column; gap: 6px; min-width: 0; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius-l); background: var(--surface); color: var(--ink); text-align: left; transition: border-color .15s, box-shadow .15s, transform .15s; }
.presets button:hover { border-color: var(--accent); box-shadow: 0 6px 20px var(--shadow); transform: translateY(-1px); }
.presets small { color: var(--accent); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.presets span { display: -webkit-box; overflow: hidden; font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; -webkit-line-clamp: 3; -webkit-box-orient: vertical; unicode-bidi: plaintext; }

.messages { display: flex; flex-direction: column; gap: 18px; }
.messages:empty { display: none; }
.message { display: flex; flex-direction: column; min-width: 0; max-width: min(620px, 88%); animation: rise .2s var(--ease); }
.message .who { margin: 0 4px 5px; color: var(--muted); font-size: 12px; font-weight: 600; }
.bubble { padding: 11px 15px; border-radius: var(--bubble); font-size: 15px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; unicode-bidi: plaintext; }
.message.customer { align-self: flex-end; align-items: flex-end; }
.message.customer .bubble { border-bottom-right-radius: 6px; background: var(--outgoing); color: var(--outgoing-ink); }
.message.assistant, .message.draft, .message.agent-turn { align-self: flex-start; padding-left: 40px; position: relative; }
.message .avatar, .working .avatar { position: absolute; left: 0; top: 18px; }
.avatar { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: var(--on-accent); font-size: 16px; font-weight: 800; line-height: 1; }
.message.assistant .bubble { border-bottom-left-radius: 6px; background: var(--ai-bg); color: var(--ai-ink); }
.message.draft .bubble { border: 1.5px dashed var(--border); border-bottom-left-radius: 6px; background: var(--surface); }
.message.draft .who { color: var(--amber); }
.message.agent-turn { max-width: min(620px, 100%); }
.message.agent-turn .avatar { background: var(--soft); color: var(--muted); }
.turn-state { display: inline-flex; align-items: center; gap: 8px; width: fit-content; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--muted); font-size: 13px; }
.turn-state .icon { width: 16px; height: 16px; }
.turn-state.failed { border-color: color-mix(in srgb, var(--danger) 35%, var(--surface)); background: var(--danger-soft); color: var(--danger); }
.turn-state.live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1s infinite; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 10px; margin: 5px 4px 0; color: var(--muted); font-size: 12px; }
.meta .sep { opacity: .5; }
.meta .cost { font-variant-numeric: tabular-nums; }
.media-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.message.customer .media-row { justify-content: flex-end; }
.media-thumb { display: block; overflow: hidden; width: 132px; height: 100px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--soft); }
.media-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.media-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--pill); background: var(--surface); color: var(--muted); font-size: 12px; }
.media-chip .icon { width: 15px; height: 15px; }
.media-row audio { max-width: 100%; height: 36px; }

/* ---------- Activity ---------- */
.turn-activity { margin: 4px 0 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); font-size: 13px; }
.turn-activity > summary { display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 8px 12px; list-style: none; cursor: pointer; color: var(--muted); font-weight: 600; user-select: none; }
.turn-activity > summary::-webkit-details-marker { display: none; }
.turn-activity > summary::before { content: ""; width: 6px; height: 6px; flex: none; border-right: 1.8px solid currentColor; border-bottom: 1.8px solid currentColor; transform: rotate(-45deg); transition: transform .15s; }
.turn-activity[open] > summary::before { transform: rotate(45deg); }
.turn-activity > summary:hover { color: var(--ink); }
.activity-title { color: var(--ink); white-space: nowrap; }
.activity-count { min-width: 0; overflow: hidden; font-weight: 500; white-space: nowrap; text-overflow: ellipsis; }
.activity-state { margin-left: auto; padding: 1px 8px; border-radius: var(--pill); background: var(--soft); font-size: 11px; font-weight: 700; text-transform: capitalize; }
.activity-state.is-completed { background: color-mix(in srgb, var(--success) 12%, var(--surface)); color: var(--success); }
.activity-state.is-failed, .activity-state.is-cancelled, .activity-state.is-discarded { background: var(--danger-soft); color: var(--danger); }
.activity-state.is-working { background: var(--accent-soft); color: var(--accent); }
.activity-events { max-height: 300px; overflow-y: auto; padding: 2px 12px 10px; border-top: 1px solid var(--line); scrollbar-width: thin; }
.activity-empty { padding: 8px 0 2px; color: var(--muted); font-size: 12px; }
.activity-event { position: relative; padding: 7px 0 7px 22px; color: var(--ink); white-space: normal; }
.activity-event::before { content: ""; position: absolute; left: 3px; top: 13px; width: 8px; height: 8px; border-radius: 50%; background: var(--border); }
.activity-event::after { content: ""; position: absolute; left: 6.5px; top: 25px; bottom: -9px; width: 1px; background: var(--line); }
.activity-event:last-child::after { display: none; }
.activity-event time { margin-right: 8px; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.activity-event.tool_start::before, .activity-event.tool_end::before { background: var(--accent); }
.activity-event.completed::before, .activity-event.model_complete::before { background: var(--success); }
.activity-event.retry, .activity-event.attempt_failed { color: var(--amber); }
.activity-event.retry::before, .activity-event.attempt_failed::before { background: var(--amber); }
.activity-event.failed, .activity-event.cancelled { color: var(--danger); }
.activity-event.failed::before, .activity-event.cancelled::before { background: var(--danger); }
.activity-event details { margin-top: 4px; }
.activity-event details summary { width: fit-content; color: var(--accent); font-size: 12px; font-weight: 600; cursor: pointer; }
.activity-event pre { max-height: 200px; overflow: auto; margin: 6px 0 0; padding: 8px 10px; border-radius: 8px; background: var(--soft); font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- Working indicator ---------- */
.working { position: relative; margin-top: 18px; padding-left: 40px; animation: rise .2s var(--ease); }
.working .avatar { top: 4px; }
.working-bubble { display: inline-flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--bubble); border-bottom-left-radius: 6px; background: var(--ai-bg); color: var(--ai-ink); font-size: 13px; }
.typing { display: inline-flex; gap: 3px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: bounce 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
.jump-latest { position: absolute; left: 50%; top: -44px; z-index: 5; display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border: 1px solid var(--line); border-radius: var(--pill); background: var(--surface); color: var(--ink); font-size: 13px; font-weight: 600; box-shadow: 0 6px 20px var(--shadow); transform: translateX(-50%); }
.jump-latest .icon { width: 15px; height: 15px; }

/* ---------- Composer ---------- */
.composer-wrap { position: relative; padding: 8px max(20px, calc((100% - 760px) / 2)) calc(14px + var(--page-safe-bottom)); background: linear-gradient(transparent, var(--canvas) 24px); }
.composer { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 10px 10px 8px 14px; border: 1px solid var(--border); border-radius: var(--radius-l); background: var(--surface); box-shadow: 0 8px 28px var(--shadow); transition: border-color .15s, box-shadow .15s; }
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), 0 8px 28px var(--shadow); }
.composer.dragging { border-style: dashed; border-color: var(--accent); background: var(--accent-soft); }
.composer textarea { width: 100%; min-height: 26px; max-height: 220px; padding: 4px 0; border: 0; outline: 0; background: transparent; resize: none; font-size: 15px; line-height: 1.5; unicode-bidi: plaintext; }
.composer-bar { display: flex; align-items: center; gap: 8px; }
.attach { margin-left: -6px; width: 36px; height: 36px; }
.attach .icon { width: 19px; height: 19px; }
.attach.disabled { opacity: .4; cursor: not-allowed; }
.composer-hint { flex: 1; min-width: 0; overflow: hidden; color: var(--muted); font-size: 12px; white-space: nowrap; text-overflow: ellipsis; }
.batching-chip { cursor: pointer; background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.send { min-height: 36px; padding: 6px 14px; }
.send .icon { width: 16px; height: 16px; }
.staged { display: flex; flex-wrap: wrap; gap: 6px; }
.staged-item { position: relative; display: inline-flex; align-items: center; gap: 8px; max-width: 220px; padding: 4px 30px 4px 4px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--soft); font-size: 12px; }
.staged-item .thumb { display: grid; place-items: center; width: 40px; height: 40px; flex: none; overflow: hidden; border-radius: 8px; background: var(--surface); color: var(--muted); }
.staged-item .thumb img { width: 100%; height: 100%; object-fit: cover; }
.staged-item .thumb .icon { width: 18px; height: 18px; }
.staged-item .name { overflow: hidden; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; }
.staged-item small { display: block; color: var(--muted); font-weight: 400; }
.staged-item .remove { position: absolute; right: 2px; top: 50%; width: 26px; height: 26px; transform: translateY(-50%); }
.staged-item .remove .icon { width: 14px; height: 14px; }
.staged-item.uploading .thumb::after { content: ""; width: 16px; height: 16px; border: 2px solid var(--muted); border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
.footnote { margin-top: 8px; color: var(--muted); font-size: 11px; text-align: center; }

/* ---------- Inspector ---------- */
.pg-inspector { display: flex; flex-direction: column; gap: 12px; min-height: 0; overflow-y: auto; padding: 16px 16px 24px; border-left: 1px solid var(--line); background: var(--rail); scrollbar-width: thin; }
.inspector-head { display: none; align-items: center; justify-content: space-between; }
.inspector-head h2 { font-size: 17px; }
.card { display: flex; flex-direction: column; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-l); background: var(--surface); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-head h3 { font-size: 14px; font-weight: 700; }
.field { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 600; }
.field .optional { font-weight: 400; }
.field input, .field select, .field textarea { width: 100%; min-height: 38px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--ink); font-size: 14px; font-weight: 400; }
.field textarea { resize: vertical; line-height: 1.45; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); outline: 0; box-shadow: 0 0 0 3px var(--accent-soft); }
.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.unit-input { position: relative; display: block; }
.unit-input input { padding-right: 26px; }
.unit-input span { position: absolute; right: 10px; top: 50%; color: var(--muted); font-weight: 400; transform: translateY(-50%); pointer-events: none; }
.kv { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--muted); }
.kv strong { overflow: hidden; color: var(--ink); font-weight: 600; text-align: right; white-space: nowrap; text-overflow: ellipsis; }
.kv strong.warn { color: var(--amber); }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); padding: 3px; border-radius: var(--radius); background: var(--soft); }
.segmented button { display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-height: 34px; padding: 4px 6px; border: 0; border-radius: calc(var(--radius) - 3px); background: transparent; color: var(--muted); font-size: 13px; font-weight: 600; }
.segmented button .icon { width: 15px; height: 15px; }
.segmented button:hover:not(:disabled) { color: var(--ink); }
.segmented button.current { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px var(--shadow); }
.action-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.action-row .button { min-width: 0; padding: 8px 10px; font-size: 13px; line-height: 1.2; white-space: normal; }
.help { color: var(--muted); font-size: 12px; line-height: 1.5; }
.dirty-hint { padding: 1px 8px; border-radius: var(--pill); background: var(--amber-soft); color: var(--amber); font-size: 11px; font-weight: 700; }
.toggle-chips { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.toggle-chips label { position: relative; }
.toggle-chips input { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.toggle-chips span { display: flex; align-items: center; gap: 7px; min-height: 36px; padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius); color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer; transition: .15s; }
.toggle-chips span .icon { width: 16px; height: 16px; }
.toggle-chips input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.toggle-chips input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.switch { display: flex; align-items: center; gap: 10px; min-height: 40px; color: var(--ink); font-size: 14px; font-weight: 600; cursor: pointer; }
.switch { position: relative; }
.switch input { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.switch-track { position: relative; width: 38px; height: 22px; flex: none; border-radius: var(--pill); background: var(--border); transition: background .15s; }
.switch-track::after { content: ""; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .15s var(--ease); }
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--focus); outline-offset: 2px; }
.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.metric { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: 9px 10px; border-radius: var(--radius); background: var(--soft); }
.metric span { overflow: hidden; color: var(--muted); font-size: 11px; white-space: nowrap; text-overflow: ellipsis; }
.metric strong { overflow-wrap: anywhere; font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.metric.span { grid-column: 1 / -1; }
.metric.span strong { font-size: 13px; font-weight: 600; }
.health { display: flex; flex-direction: column; gap: 4px; }
.cases { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--radius); background: var(--amber-soft); color: var(--amber); font-size: 13px; font-weight: 600; }
.cases .icon { width: 16px; height: 16px; }

/* ---------- Dialog and toasts ---------- */
#globalDialog { width: min(760px, calc(100vw - 24px)); max-height: 85dvh; padding: 0; border: 1px solid var(--line); border-radius: var(--radius-l); background: var(--surface); color: var(--ink); box-shadow: 0 24px 60px var(--shadow-strong); }
#globalDialog::backdrop { background: var(--overlay); }
#globalDialog header { position: sticky; top: 0; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 18px 18px 12px 20px; background: var(--surface); }
#globalDialog h2 { font-size: 18px; }
#globalDialog p { margin-top: 3px; color: var(--muted); font-size: 13px; }
.metric-grid.wide { grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 0 20px 20px; }
.toasts { position: fixed; left: 50%; bottom: calc(24px + var(--page-safe-bottom)); z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 8px; width: min(440px, calc(100vw - 24px)); transform: translateX(-50%); pointer-events: none; }
.toast { display: flex; align-items: flex-start; gap: 10px; width: 100%; padding: 12px 14px; border-radius: var(--radius); background: var(--toast); color: var(--contrast-ink); font-size: 14px; box-shadow: 0 10px 30px var(--shadow-strong); pointer-events: auto; animation: rise .2s var(--ease); }
.toast.error { background: var(--danger); color: #fff; }
.toast span { flex: 1; }
.toast button { padding: 0 2px; border: 0; background: transparent; color: inherit; font-size: 18px; line-height: 1; opacity: .75; }

/* ---------- Responsive ---------- */
@media (max-width: 1179px) {
  .pg { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .inspector-head { display: flex; }
  .pg-inspector { position: fixed; top: calc(var(--header-h) + var(--page-safe-top)); right: 0; bottom: 0; z-index: 30; width: min(var(--inspector-w), 100vw); border-left: 1px solid var(--line); box-shadow: -16px 0 40px var(--shadow); transform: translateX(105%); visibility: hidden; transition: transform .22s var(--ease), visibility 0s .22s; }
  .controls-open .pg-inspector { transform: none; visibility: visible; transition: transform .22s var(--ease); }
}
@media (min-width: 1180px) {
  .controls-toggle { display: none !important; }
}
@media (max-width: 799px) {
  :root { --header-h: 58px; }
  .pg { grid-template-columns: minmax(0, 1fr); }
  .compact-only { display: inline-grid !important; }
  .pg-sidebar { position: fixed; top: 0; bottom: 0; left: 0; z-index: 40; width: min(300px, 86vw); padding-top: calc(20px + var(--page-safe-top)); box-shadow: 16px 0 40px var(--shadow); transform: translateX(-105%); visibility: hidden; transition: transform .22s var(--ease), visibility 0s .22s; }
  .menu-open .pg-sidebar { transform: none; visibility: visible; transition: transform .22s var(--ease); }
  .menu-open .scrim { z-index: 35; }
  .pg-header { gap: 4px; padding: 0 8px; }
  .pg-header h1 { font-size: 16px; }
  .model-chip, .status-chip { display: none; }
  .controls-toggle span { display: none; }
  .controls-toggle { width: 40px; padding: 0; }
  .pg-inspector { width: 100vw; border-left: 0; }
  .thread { padding: 16px 12px 12px; }
  .message { max-width: 92%; }
  .message.assistant, .message.draft, .message.agent-turn { padding-left: 0; }
  .message .avatar { display: none; }
  .working { padding-left: 0; }
  .working .avatar { display: none; }
  .composer-wrap { position: relative; padding: 6px 10px calc(10px + var(--page-safe-bottom)); }
  .footnote { display: none; }
  .presets { grid-template-columns: minmax(0, 1fr); }
  .welcome { margin-top: 2vh; }
  .welcome h2 { font-size: 21px; }
  .metric-grid.wide { grid-template-columns: 1fr 1fr; padding: 0 14px 16px; }
}
@media (max-width: 380px) {
  .composer-hint { display: none; }
  .composer-bar { justify-content: space-between; }
  .send span { display: none; }
  .send { width: 40px; padding: 0; }
  .field-pair, .action-row { grid-template-columns: minmax(0, 1fr); }
  .metric-grid.wide { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
.media-transcript { max-width: 100%; min-width: 0; }
.media-transcript summary { cursor: pointer; }
.transcript-body { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 18rem; overflow: auto; }
