:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-soft: #f8fafb;
  --text: #17212b;
  --muted: #6b7782;
  --line: #dce2e7;
  --line-strong: #c8d0d6;
  --teal: #087f73;
  --teal-dark: #06665d;
  --blue: #315fbd;
  --danger: #bd3c32;
  --warn: #b7791f;
  --code-bg: #17212b;
  --code-text: #dbe7ef;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; min-height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); overflow: hidden; }
button, input, select, textarea { font: inherit; }
button, select, textarea { outline: none; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }

.shell { height: 100vh; height: 100dvh; display: grid; grid-template-columns: 248px minmax(500px, 1fr) 300px; }
.sidebar, .inspector { background: var(--panel); min-width: 0; min-height: 0; }
.sidebar { padding: 20px 16px 16px; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; overflow: auto; }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 4px 21px; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 7px; background: #132f35; color: #b8f4e8; font-weight: 800; font-size: 20px; }
.brand strong, .brand span { display: block; }
.brand strong { font-size: 15px; letter-spacing: .01em; }
.brand span { margin-top: 3px; color: var(--muted); font-size: 11px; }
.side-section { border-top: 1px solid var(--line); padding: 15px 4px 8px; }
.side-section > label { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; margin-bottom: 8px; }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.icon-button, .text-button { border: 0; background: transparent; color: var(--muted); min-height: 26px; padding: 0 5px; }
.icon-button { font-size: 20px; line-height: 1; }
.icon-button:hover, .text-button:hover { color: var(--teal); }
.node-card { margin-top: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel-soft); }
.node-title { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 700; }
.node-model { margin: 10px 0 7px; font-size: 13px; font-weight: 650; overflow-wrap: anywhere; }
.node-card code { display: block; color: var(--muted); font-size: 10px; line-height: 1.45; overflow-wrap: anywhere; }
.node-latency { color: var(--muted); font-size: 10px; margin-top: 8px; }
.status-dot { display: inline-block; width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 4px rgba(8, 127, 115, .12); }
.status-dot.muted { background: #99a5ad; box-shadow: none; }
.status-dot.warn { background: var(--warn); box-shadow: 0 0 0 4px rgba(183, 121, 31, .12); }
.status-dot.error { background: var(--danger); box-shadow: 0 0 0 4px rgba(189, 60, 50, .12); }
select, textarea, input[type="range"], input[type="text"] { width: 100%; }
select, input[type="text"] { height: 36px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--text); padding: 0 9px; }
select:focus, input[type="text"]:focus, textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(8, 127, 115, .11); }
input[type="range"] { accent-color: var(--teal); }
.side-actions { display: grid; gap: 8px; }
.side-actions button { min-height: 35px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--text); text-align: left; padding: 0 10px; }
.side-actions button:hover { border-color: var(--teal); color: var(--teal-dark); }
.sidebar-footer { margin-top: auto; display: flex; align-items: center; gap: 7px; padding: 16px 4px 0; color: var(--muted); font-size: 11px; }
.local-indicator { width: 7px; height: 7px; border-radius: 50%; background: var(--blue); }

.workspace { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; background: var(--bg); overflow: hidden; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 18px; min-height: 78px; padding: 17px 26px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.9); }
.eyebrow { color: var(--teal); font-size: 10px; font-weight: 750; letter-spacing: .12em; }
.topbar h1, .inspector h2 { margin: 5px 0 0; font-size: 19px; line-height: 1.15; }
.topbar-meta { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 12px; }
.danger-button { min-height: 34px; border: 1px solid rgba(189,60,50,.35); border-radius: 6px; background: #fff; color: var(--danger); padding: 0 11px; }
.danger-button:hover { background: #fff7f6; }
.chat { min-height: 0; overflow: auto; padding: 24px max(26px, 5vw); display: flex; flex-direction: column; gap: 16px; }
.empty-state { margin: auto; text-align: center; color: var(--muted); }
.empty-state strong, .empty-state span { display: block; }
.empty-state strong { color: var(--text); font-size: 19px; font-weight: 650; }
.empty-state span { margin-top: 8px; font-size: 13px; }
.message { flex: 0 0 auto; width: min(900px, 100%); border: 1px solid var(--line); border-radius: 7px; background: var(--panel); overflow: hidden; box-shadow: 0 3px 14px rgba(23,33,43,.04); }
.message.user { align-self: flex-end; width: min(780px, 92%); border-color: rgba(8,127,115,.25); }
.message.error { border-color: rgba(189,60,50,.35); }
.message-meta { display: flex; justify-content: space-between; gap: 12px; padding: 8px 11px; background: var(--panel-soft); color: var(--muted); font-size: 11px; }
.message.user .message-meta { color: var(--teal-dark); }
.message-content { margin: 0; padding: 13px 14px 15px; color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; font: 13px/1.65 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }
.message.user .message-content { font-family: inherit; }
.message.error .message-content { color: var(--danger); }
.composer-wrap { padding: 0 max(26px, 5vw) 22px; }
.quick-prompts { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 9px; }
.prompt-chip { min-height: 28px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--muted); padding: 0 10px; font-size: 11px; }
.prompt-chip:hover { border-color: var(--teal); color: var(--teal-dark); background: #fff; }
.composer { border: 1px solid var(--line-strong); border-radius: 8px; background: var(--panel); box-shadow: 0 8px 22px rgba(23,33,43,.06); overflow: hidden; }
.composer textarea { display: block; min-height: 106px; resize: vertical; border: 0; border-radius: 0; padding: 13px 14px; color: var(--text); line-height: 1.55; }
.composer textarea::placeholder { color: #9aa5ad; }
.composer-bottom { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 9px 8px 13px; border-top: 1px solid var(--line); }
.composer-hint { color: var(--muted); font-size: 10px; }
.send-button { min-height: 34px; display: inline-flex; align-items: center; gap: 9px; border: 1px solid var(--teal); border-radius: 6px; background: var(--teal); color: #fff; padding: 0 12px; }
.send-button:hover { background: var(--teal-dark); }
.send-button b { font-size: 16px; line-height: 1; }

.inspector { border-left: 1px solid var(--line); display: grid; grid-template-rows: auto auto minmax(0, 1fr); min-width: 0; }
.inspector-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 78px; padding: 17px 17px; border-bottom: 1px solid var(--line); }
.inspector h2 { font-size: 16px; }
.run-state { color: var(--muted); font-size: 11px; }
.run-state.running { color: var(--warn); }
.inspector-section { padding: 16px 17px; border-bottom: 1px solid var(--line); }
.metrics { display: grid; gap: 13px; }
.metrics div { display: flex; justify-content: space-between; align-items: baseline; gap: 9px; }
.metrics span { color: var(--muted); font-size: 11px; }
.metrics strong { font-size: 11px; text-align: right; }
.log-section { min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr); border-bottom: 0; }
.log-section pre { min-height: 0; margin: 12px -5px -5px; padding: 10px; overflow: auto; background: var(--code-bg); color: var(--code-text); border-radius: 5px; white-space: pre-wrap; overflow-wrap: anywhere; font: 10px/1.5 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }

@media (max-width: 1050px) {
  .shell { grid-template-columns: 220px minmax(420px, 1fr); }
  .inspector { display: none; }
}
@media (max-width: 720px) {
  body { overflow: auto; }
  .shell { height: auto; min-height: 100%; grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar-footer { margin-top: 8px; }
  .workspace { min-height: 760px; }
  .topbar { padding: 15px 17px; }
  .chat, .composer-wrap { padding-left: 17px; padding-right: 17px; }
  .topbar-meta { gap: 8px; }
  .topbar-meta > span { display: none; }
  .message.user { width: 96%; }
}
