:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --border: #d9dde3;
  --text: #1c2128;
  --muted: #69717d;
  --accent: #2f8f46;
  --accent-text: #ffffff;
  --danger: #c0392b;
  --warn: #b7791f;
  --console-bg: #11151a;
  --console-text: #d6dde6;
  --radius: 8px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161b;
    --surface: #1a1f26;
    --surface-2: #232a33;
    --border: #2f3843;
    --text: #e3e8ee;
    --muted: #8b95a3;
    --accent: #3fae5a;
    --accent-text: #0b130d;
    --danger: #e0574a;
    --warn: #d9a23a;
    --console-bg: #0b0e12;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
h1, h2, h3 { margin: 0 0 12px; line-height: 1.25; }
h2 { font-size: 20px; }
h3 { font-size: 15px; }
code, .mono { font-family: ui-monospace, "Cascadia Code", Menlo, Consolas, monospace; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--danger); min-height: 1.5em; margin: 0; }
.spacer { flex: 1; }
.grow { flex: 1; min-width: 0; }

input, select, textarea, button, .button {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
button, .button { cursor: pointer; background: var(--surface-2); display: inline-block; text-decoration: none; white-space: nowrap; }
button:hover, .button:hover { border-color: var(--muted); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.danger { color: var(--danger); }
button.small, .button.small { padding: 3px 8px; font-size: 12px; }
label { display: flex; flex-direction: column; gap: 4px; }
label.inline { flex-direction: row; align-items: center; gap: 6px; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 14px; }
.login-card h1 { font-size: 20px; }

/* Layout */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-size: 15px; }
.menu-btn { display: none; }
#app { display: grid; grid-template-columns: 200px 1fr; grid-template-rows: auto 1fr; min-height: 100vh; }
#app.hidden { display: none; }
.topbar { grid-column: 1 / -1; }
.nav { display: flex; flex-direction: column; padding: 12px 8px; gap: 2px; border-right: 1px solid var(--border); background: var(--surface); }
.nav a { padding: 8px 12px; border-radius: 6px; cursor: pointer; color: var(--text); }
.nav a:hover { background: var(--surface-2); }
.nav a.active { background: var(--accent); color: var(--accent-text); }
.main { padding: 20px; min-width: 0; }
.view { display: none; flex-direction: column; gap: 16px; max-width: 1200px; }
.view.active { display: flex; }
.row { display: flex; align-items: center; gap: 8px; }
.row h2, .row h3 { margin: 0; }
.wrap { flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.btn-group { display: flex; flex-wrap: wrap; gap: 6px; }
.notice { background: color-mix(in srgb, var(--warn) 15%, var(--surface)); border: 1px solid var(--warn); border-radius: var(--radius); padding: 12px 16px; }

/* Status */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; }
.stat .label { color: var(--muted); font-size: 12px; }
.stat .value { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.pill { padding: 2px 10px; border-radius: 999px; background: var(--surface-2); font-size: 12px; font-weight: 600; }
.pill.ok { background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent); }
.pill.warn { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--warn); }
.pill.bad { background: color-mix(in srgb, var(--danger) 20%, transparent); color: var(--danger); }
.pill.small { font-size: 11px; padding: 1px 8px; vertical-align: middle; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px; border-radius: 999px; background: var(--surface-2); }
.avatar { width: 24px; height: 24px; border-radius: 4px; image-rendering: pixelated; flex: none; }

/* Konsole */
.console {
  margin: 0; height: 60vh; overflow: auto; padding: 12px;
  background: var(--console-bg); color: var(--console-text);
  border-radius: var(--radius); font: 12.5px/1.45 ui-monospace, Menlo, Consolas, monospace;
  white-space: pre-wrap; word-break: break-word;
}
.l-err { color: #ff7b72; }
.l-warn { color: #e3b341; }
.l-panel { color: #79c0ff; }
.l-join { color: #7ee787; }
.l-chat { color: #ffffff; }

/* Listen & Tabellen */
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow: auto; }
.list li { display: flex; align-items: center; gap: 8px; }
.list.cols { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { background: var(--surface-2); font-weight: 600; font-size: 12px; color: var(--muted); }
.table tr:last-child td { border-bottom: none; }
.table td.actions { text-align: right; white-space: nowrap; }
.table td.actions > * { margin-left: 4px; }
.table td { word-break: break-word; }

/* Welt */
.rules { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px 20px; }
.rule { flex-direction: row; align-items: center; justify-content: space-between; padding: 4px 0; border-bottom: 1px dashed var(--border); }
.rule .num { width: 90px; }

/* Konfiguration */
.tabs { display: flex; gap: 4px; }
.tabs button.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
#cfg-props, #cfg-files { display: flex; flex-direction: column; gap: 12px; }
#cfg-props.hidden, #cfg-files.hidden { display: none; }
.props { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px 20px; margin-bottom: 12px; }
.prop span { font-size: 12px; color: var(--muted); }
.editor { width: 100%; min-height: 55vh; resize: vertical; font-size: 12.5px; line-height: 1.45; }

/* Toast */
.toast {
  position: fixed; right: 16px; bottom: 16px; max-width: min(480px, calc(100vw - 32px));
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: var(--radius);
  opacity: 0; transform: translateY(10px); transition: .2s; pointer-events: none; white-space: pre-wrap; z-index: 100;
}
.toast.show { opacity: 1; transform: none; }
.toast.error { background: var(--danger); color: #fff; }

/* Mobil */
@media (max-width: 760px) {
  #app { grid-template-columns: 1fr; }
  .menu-btn { display: inline-block; }
  #whoami { display: none; }
  .nav { display: none; position: fixed; top: 53px; left: 0; right: 0; z-index: 9; border-bottom: 1px solid var(--border); }
  .nav.open { display: flex; }
  .main { padding: 16px; }
  .row { flex-wrap: wrap; }
  .table { display: block; overflow-x: auto; }
  .console { height: 55vh; }
}
