:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --ok: #047857;
  --warn: #b45309;
  --bad: #b91c1c;
  --side: #0f172a;
  --side-text: #cbd5e1;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1120;
    --panel: #111827;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --line: #1f2937;
    --accent: #60a5fa;
    --accent-soft: #172554;
    --ok: #34d399;
    --warn: #fbbf24;
    --bad: #f87171;
    --side: #020617;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 16px 0 8px; }
.layout { display: flex; min-height: 100vh; }
.side { width: 230px; background: var(--side); color: var(--side-text); padding: 18px 12px; flex-shrink: 0; display: flex; flex-direction: column; gap: 4px; }
.side .brand { color: #fff; font-weight: 700; font-size: 17px; padding: 0 8px 12px; }
.side .brand span { color: #60a5fa; }
.side select { width: 100%; margin: 6px 0 10px; padding: 7px; border-radius: 8px; border: 1px solid #334155; background: #1e293b; color: #fff; }
.side a { color: var(--side-text); text-decoration: none; padding: 7px 10px; border-radius: 8px; display: block; }
.side a:hover { background: #1e293b; color: #fff; }
.side a.on { background: #1d4ed8; color: #fff; }
.side .label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #64748b; padding: 12px 10px 4px; }
.side .foot { margin-top: auto; font-size: 12px; color: #64748b; padding: 8px 10px; }
.side .foot button { background: none; border: 0; color: #93c5fd; cursor: pointer; padding: 0; }
.main { flex: 1; padding: 24px 28px; min-width: 0; }
.sub { color: var(--muted); margin: 0 0 18px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 16px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.stats { display: flex; gap: 18px; flex-wrap: wrap; }
.stat b { display: block; font-size: 22px; }
.stat span { color: var(--muted); font-size: 12px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--accent-soft); }
label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--text); font: inherit; }
textarea { min-height: 90px; }
input[type=checkbox] { width: auto; margin-right: 6px; }
input[type=color] { height: 38px; padding: 2px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 160px; }
button, .btn { background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 8px 14px; font: inherit; cursor: pointer; text-decoration: none; display: inline-block; }
button.ghost, .btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); }
button.danger { background: var(--bad); }
button:disabled { opacity: .6; cursor: default; }
.actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; align-items: center; }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); margin: 1px 2px 1px 0; white-space: nowrap; }
.tag.ok { background: #d1fae5; color: #065f46; }
.tag.warn { background: #fef3c7; color: #92400e; }
.tag.bad { background: #fee2e2; color: #991b1b; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
pre, code { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
pre { background: var(--bg); border: 1px solid var(--line); padding: 10px; border-radius: 8px; overflow-x: auto; white-space: pre-wrap; word-break: break-word; }
.banner { padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; background: #fef3c7; color: #92400e; }
.banner.info { background: var(--accent-soft); color: var(--accent); }
.screens { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.screen img { width: 100%; height: 130px; object-fit: cover; object-position: top; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); }
.chat { display: flex; flex-direction: column; gap: 10px; }
.bubble { padding: 10px 12px; border-radius: 10px; max-width: 85%; border: 1px solid var(--line); white-space: pre-wrap; }
.bubble.user { align-self: flex-end; background: var(--accent-soft); }
.bubble.assistant { background: var(--panel); }
.bubble.agent { background: #ecfdf5; color: #064e3b; }
.bubble.system { align-self: center; font-size: 12px; color: var(--muted); border: 0; }
.bubble img { max-width: 100%; border-radius: 8px; margin-top: 6px; display: block; }
.shot { position: relative; display: inline-block; max-width: 100%; }
.shot img { display: block; max-width: 100%; }
.shot svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.login { max-width: 380px; margin: 12vh auto; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #111827; color: #fff; padding: 10px 16px; border-radius: 10px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 10; max-width: 90vw; }
#toast.show { opacity: 1; }
.cluster { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 10px; }
.cluster ul { margin: 6px 0 0; padding-left: 18px; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .side { width: 100%; }
  .main { padding: 16px; }
  .split { grid-template-columns: 1fr; }
}
