:root {
  --bg: #0f1216; --panel: #161b22; --panel2: #1c232c; --line: #2a333e; --text: #e6edf3; --muted: #8b97a6;
  --accent: #4fb3ff; --accent2: #2d7fd0; --ok: #3fb950; --warn: #d29922; --danger: #f85149;
  --radius: 10px; --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.hidden { display: none !important; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0 0 .6em; font-weight: 600; }
h2 { font-size: 1.25rem; } h3 { font-size: 1rem; }
.muted { color: var(--muted); } .error { color: var(--danger); min-height: 1.2em; }
code, pre, .mono { font-family: var(--mono); font-size: .85em; }
pre { white-space: pre-wrap; word-break: break-word; margin: 0; }

.layout { display: flex; min-height: 100vh; }
.sidebar { width: 210px; background: var(--panel); border-right: 1px solid var(--line); padding: 18px 12px;
  display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; }
.sidebar a { color: var(--text); text-decoration: none; padding: 8px 12px; border-radius: 8px; }
.sidebar a:hover { background: var(--panel2); }
.sidebar a.active { background: var(--accent2); color: #fff; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.15rem; padding: 4px 10px 16px; }
.spacer { flex: 1; }
.conn { font-size: .8rem; color: var(--muted); padding: 6px 10px; }
.conn.ok::before { content: "● "; color: var(--ok); } .conn.bad::before { content: "● "; color: var(--danger); }
main { flex: 1; padding: 24px 28px; max-width: 1200px; min-width: 0; }

.logo-dot { width: 46px; height: 46px; border-radius: 50%; margin: 0 auto 10px;
  background: radial-gradient(circle at 35% 35%, #9fd8ff, var(--accent2) 55%, #0b2a47); box-shadow: 0 0 24px #4fb3ff55; }
.logo-dot.small { width: 22px; height: 22px; margin: 0; }

.login { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { width: 320px; text-align: center; display: flex; flex-direction: column; gap: 10px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin-bottom: 18px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > input, .row > select { flex: 1; width: auto; min-width: 160px; }
.row > select { flex: 0 1 220px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: .9rem; }
.kv span:nth-child(odd) { color: var(--muted); }

.btn { background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 14px; cursor: pointer; font: inherit; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent2); border-color: var(--accent2); color: #fff; }
.btn.danger { background: #5a1d1d; border-color: var(--danger); }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 10px; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: default; }

input, select, textarea { width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; font: inherit; }
textarea { min-height: 80px; resize: vertical; }
input[type=checkbox] { width: auto; transform: scale(1.2); }
label.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
label.field.check { flex-direction: row; align-items: center; gap: 10px; }
.field .title { font-weight: 500; font-size: .9rem; }
.field .desc { color: var(--muted); font-size: .8rem; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px 4px; margin: 0 0 14px; }
legend { padding: 0 6px; color: var(--accent); font-weight: 600; font-size: .9rem; }
.array-item { position: relative; border-style: dashed; }
.array-item > .remove { position: absolute; top: -12px; right: 10px; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs button { background: var(--panel); border: 1px solid var(--line); color: var(--text); border-radius: 20px;
  padding: 6px 14px; cursor: pointer; }
.tabs button.active { background: var(--accent2); border-color: var(--accent2); color: #fff; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: .75rem; background: var(--panel2);
  border: 1px solid var(--line); }
.badge.ok { color: var(--ok); border-color: #2c5f34; } .badge.bad { color: var(--danger); border-color: #6b2a2a; }
.badge.warn { color: var(--warn); border-color: #6b5420; }
.badge.read { color: var(--ok); } .badge.write { color: var(--warn); } .badge.danger { color: var(--danger); }

table { width: 100%; border-collapse: collapse; font-size: .85rem; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; }
td.wrap { max-width: 420px; word-break: break-word; }

/* Chat */
.chat { display: flex; flex-direction: column; height: calc(100vh - 110px); }
.messages { flex: 1; overflow-y: auto; padding: 8px 4px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 80%; padding: 10px 14px; border-radius: 14px; white-space: pre-wrap; word-break: break-word; }
.msg.user { align-self: flex-end; background: var(--accent2); color: #fff; border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--panel2); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.system { align-self: center; color: var(--muted); font-size: .85rem; background: transparent; }
.msg .speaker { font-size: .75rem; opacity: .7; display: block; margin-bottom: 2px; }
.tool-chip { align-self: flex-start; font-size: .78rem; color: var(--muted); border: 1px dashed var(--line);
  border-radius: 8px; padding: 4px 10px; font-family: var(--mono); max-width: 80%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer { display: flex; gap: 8px; padding-top: 10px; align-items: flex-end; }
.composer textarea { min-height: 46px; max-height: 200px; }
.mic { width: 52px; height: 46px; border-radius: 12px; flex: none; font-size: 1.2rem; }
.mic.live { background: var(--danger); border-color: var(--danger); }

/* Bestätigungen */
.confirm { background: #3a2a0d; border: 1px solid var(--warn); border-radius: var(--radius); padding: 12px 16px;
  margin-bottom: 12px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.confirm pre { flex: 1; min-width: 200px; }

#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 10; }
.toast { background: var(--panel2); border: 1px solid var(--line); border-left: 4px solid var(--accent);
  padding: 10px 14px; border-radius: 8px; max-width: 380px; box-shadow: 0 6px 20px #0008; }
.toast.warn { border-left-color: var(--warn); }

.live-log { max-height: 320px; overflow-y: auto; font-size: .85rem; display: flex; flex-direction: column; gap: 4px; }
.live-log div { border-bottom: 1px solid var(--line); padding: 3px 0; }
.mem-item { border-bottom: 1px solid var(--line); padding: 10px 0; }
.mem-item .head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }

@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .sidebar { width: auto; height: auto; position: static; flex-direction: row; flex-wrap: wrap; padding: 8px; }
  .brand { padding: 4px 8px; } .spacer, .conn { display: none; }
  main { padding: 14px; }
  .msg { max-width: 92%; }
  .chat { height: calc(100vh - 150px); }
}
