:root {
  --bg: #0f1117; --panel: #161a23; --panel2: #1d2230; --border: #2a3040;
  --text: #e6e9f0; --muted: #8b93a7; --accent: #6c8cff; --good: #4ade80;
  --bad: #f87171; --warn: #fbbf24;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 system-ui, sans-serif; background: var(--bg); color: var(--text); }
header { display: flex; align-items: center; gap: 24px; padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--border); }
header h1 { font-size: 18px; margin: 0; } header h1 span { color: var(--accent); }
header h1 em { font-size: 11px; color: var(--warn); font-style: normal; vertical-align: super; }
nav { display: flex; gap: 4px; flex: 1; }
.tab { background: none; border: none; color: var(--muted); padding: 8px 14px; cursor: pointer; border-radius: 6px; font-size: 14px; }
.tab.active, .tab:hover { background: var(--panel2); color: var(--text); }
#gpu-badge { font-size: 12px; color: var(--muted); background: var(--panel2); padding: 4px 10px; border-radius: 12px; }
#user-badge { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
#user-badge button { font-size: 11px; padding: 3px 8px; }
main { padding: 16px 20px; }
.panel { display: none; } .panel.active { display: block; }
#tab-chat.active { display: flex; gap: 16px; height: calc(100vh - 90px); }
.cols { display: flex; gap: 24px; align-items: flex-start; }
.col { flex: 1; min-width: 0; }
h2 { font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 18px 0 8px; }
h2:first-child { margin-top: 0; }

button, input, select, textarea { font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; }
button { cursor: pointer; } button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
label { display: block; color: var(--muted); font-size: 13px; }
label input, label select { display: block; width: 100%; margin-top: 2px; }
.stack > * { margin-bottom: 10px; }
.row { display: flex; gap: 10px; } .row > label { flex: 1; }
.chk { display: flex; align-items: center; gap: 6px; }
.chk input { display: inline; width: auto; margin: 0; }
.hint { color: var(--muted); font-size: 13px; }
code { background: var(--panel2); padding: 2px 6px; border-radius: 4px; font-size: 12px; }
pre { background: var(--panel2); border: 1px solid var(--border); border-radius: 6px; padding: 10px; overflow: auto; max-height: 240px; font-size: 12px; white-space: pre-wrap; }

/* chat */
#chat-list-pane { width: 220px; flex-shrink: 0; }
#new-chat { width: 100%; }
#chat-list { list-style: none; padding: 0; margin: 10px 0; }
#chat-list li { padding: 7px 10px; border-radius: 6px; cursor: pointer; color: var(--muted); display: flex; justify-content: space-between; gap: 6px; }
#chat-list li.active, #chat-list li:hover { background: var(--panel2); color: var(--text); }
#chat-list li .del { visibility: hidden; color: var(--bad); }
#chat-list li:hover .del { visibility: visible; }
#chat-pane { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.chat-toolbar select { max-width: 420px; }
#chat-messages { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 4px; }
.msg { max-width: 76%; padding: 10px 14px; border-radius: 12px; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--accent); color: #fff; }
.msg.assistant { align-self: flex-start; background: var(--panel2); }
.msg.tool { align-self: flex-start; background: var(--panel); border: 1px dashed var(--border); color: var(--muted); font-size: 12px; max-width: 90%; }
.msg .att { font-size: 11px; opacity: .8; }
#chat-form { display: flex; gap: 8px; margin-top: 10px; align-items: flex-end; }
#chat-input { flex: 1; resize: vertical; }
.attach-btn { cursor: pointer; font-size: 18px; padding: 6px; }
#chat-attachments { display: flex; gap: 6px; flex-wrap: wrap; }
#chat-attachments .pill { background: var(--panel2); border: 1px solid var(--border); border-radius: 12px; padding: 2px 10px; font-size: 12px; }

/* cards */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; }
.card .title { font-weight: 600; word-break: break-all; }
.card .meta { color: var(--muted); font-size: 12px; margin: 2px 0 6px; }
.card .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.card .actions button, .card .actions select { font-size: 12px; padding: 3px 8px; }
.badge { font-size: 11px; padding: 1px 8px; border-radius: 10px; background: var(--panel2); color: var(--muted); }
.badge.green { background: #14351f; color: var(--good); }
.badge.red { background: #3a1a1a; color: var(--bad); }
.badge.yellow { background: #3a2f12; color: var(--warn); }
progress { width: 100%; height: 8px; }
canvas { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; display: block; max-width: 100%; }
#recipe-canvas { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; }
#recipe-json { width: 100%; font-family: monospace; font-size: 12px; }

#toast { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 10; }
#toast .t { background: var(--panel2); border: 1px solid var(--border); border-left: 3px solid var(--accent); padding: 10px 14px; border-radius: 6px; max-width: 420px; white-space: pre-wrap; }
#toast .t.err { border-left-color: var(--bad); }
