:root {
  --bg: #f3f4f8; --card: #ffffff; --card-2: #f8f8fc; --text: #1b1c24; --muted: #6a6c80; --line: #e2e3ec;
  --accent: #7c4dff; --accent-hover: #6a3df0; --accent-soft: #efeaff; --on: #1f9d55; --off: #8b8d9c; --warn: #c2410c;
  --input: #ffffff; --err: #c81e1e; --shadow: 0 1px 2px rgba(20, 20, 40, .06), 0 2px 8px rgba(20, 20, 40, .04);
  /* Seitenleiste ist immer dunkel (wie bei Fossabot) */
  --side-bg: #15161c; --side-text: #a9abbd; --side-hover: #22232d; --side-active: #2a2540; --side-line: #262733;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1015; --card: #181920; --card-2: #1e1f28; --text: #e9e9f2; --muted: #9496aa; --line: #2a2b37;
          --accent: #9b7bff; --accent-hover: #ab8fff; --accent-soft: #272143; --on: #34c77b; --off: #6c6e80; --warn: #fb923c;
          --input: #13141a; --err: #f87171; --shadow: 0 1px 2px rgba(0, 0, 0, .3);
          --side-bg: #0b0c10; --side-hover: #181920; --side-active: #241f3b; --side-line: #1d1e27; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
       font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1 { font-size: 19px; margin: 0; font-weight: 650; }
h2 { font-size: 20px; margin: 0 0 2px; font-weight: 650; }
h3 { font-size: 15px; margin: 0; font-weight: 650; }
h4 { font-size: 12px; margin: 0 0 8px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 650; }
a { color: var(--accent); }
.hidden { display: none !important; }
.hint { color: var(--muted); font-size: 13.5px; margin: 2px 0 10px; }
.muted { color: var(--muted); }
.small-text { font-size: 13px; }
.error { color: var(--err); font-size: 14px; }
code { background: var(--card-2); padding: 1px 6px; border-radius: 5px; font-size: 12.5px; border: 1px solid var(--line);
       font-family: ui-monospace, Menlo, Consolas, monospace; word-break: break-all; }

/* Formulare */
label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 5px; }
input[type=text], input[type=number], input[type=password], input[type=search], textarea, select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--input); color: var(--text); font: inherit; }
textarea { resize: vertical; min-height: 44px; }
input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible, .item:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); flex: 0 0 auto; margin: 0; }
button, a.btn { font: inherit; font-size: 14px; cursor: pointer; border-radius: 8px; border: 1px solid var(--line);
         background: var(--card); color: var(--text); padding: 8px 14px; text-decoration: none; display: inline-flex;
         align-items: center; gap: 6px; line-height: 1.3; }
button:hover, a.btn:hover { border-color: var(--accent); }
button:disabled { opacity: .45; cursor: default; }
button:disabled:hover { border-color: var(--line); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.small, a.btn.small { padding: 5px 11px; font-size: 13px; }
button.icon { padding: 5px 9px; }
button.danger:hover { border-color: var(--err); color: var(--err); }
button.danger-solid { background: transparent; border-color: var(--err); color: var(--err); }
button.danger-solid:hover { background: var(--err); color: #fff; }
button.link { border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline; font-size: inherit; }
button.twitch { background: #9146ff; border-color: #9146ff; }
.icon-btn { border: 0; background: none; font-size: 18px; padding: 4px 9px; color: var(--muted); }
.icon-btn:hover { color: var(--text); background: var(--card-2); }
.check { display: flex; align-items: center; gap: 10px; font-weight: 400; margin: 10px 0; font-size: 14.5px; cursor: pointer; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.nowrap { flex-wrap: nowrap; justify-content: flex-end; }
.grow { flex: 1 1 200px; min-width: 0; }
.spacer { flex: 1 1 auto; }
.w90 { width: 90px; }
.field { min-width: 0; }
.field .hint { margin-bottom: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 16px; }
.grid4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0 14px; }
.grid2 > .card { margin-bottom: 16px; }

/* Schiebeschalter */
.switch { position: relative; display: inline-block; width: 38px; height: 22px; flex: 0 0 auto; margin: 0; cursor: pointer; }
.switch input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch .slider { position: absolute; inset: 0; background: var(--off); border-radius: 22px; transition: background .15s; }
.switch .slider::before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff;
  border-radius: 50%; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.switch input:checked + .slider { background: var(--on); }
.switch input:checked + .slider::before { transform: translateX(16px); }
.switch input:focus-visible + .slider { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch-label { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-size: 14px; cursor: pointer; }
.switch-label.live .switch-text { color: var(--err); }
.switch-label.live .switch input:not(:checked) + .slider { background: var(--err); }

/* Login */
body.login { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-box { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 26px; width: 100%; max-width: 380px; box-shadow: var(--shadow); }
.login-box h1 { margin-bottom: 12px; }
.login-box button { margin-top: 14px; width: 100%; padding: 11px; justify-content: center; }

/* Grundgerüst: Seitenleiste + Inhalt */
.sidebar { position: fixed; top: 0; bottom: 0; left: 0; width: 236px; background: var(--side-bg); color: var(--side-text);
  display: flex; flex-direction: column; z-index: 30; border-right: 1px solid var(--side-line); }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 20px; font-weight: 700; font-size: 17px; color: #fff; }
.brand-logo { width: 32px; height: 32px; display: grid; place-items: center; background: var(--accent); border-radius: 9px; font-size: 17px; }
.nav { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; flex: 1 1 auto; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: 12px; width: 100%; border: 0; background: none; color: var(--side-text);
  padding: 10px 12px; border-radius: 8px; font-size: 14.5px; text-align: left; }
.nav-item:hover { background: var(--side-hover); color: #fff; border: 0; }
.nav-item.active { background: var(--side-active); color: #fff; font-weight: 600; }
.nav-item.active .ico { stroke: var(--accent); }
.ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
.sidebar-foot { padding: 10px; border-top: 1px solid var(--side-line); }
.nav-item.logout { justify-content: center; }
.nav-backdrop { display: none; }

.main-col { margin-left: 236px; min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 20; background: var(--card); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px; padding: 10px 24px; min-height: 60px; flex-wrap: wrap; }
.topbar h1 { flex: 1 1 auto; visibility: hidden; } /* Titel steht groß auf der Seite */
.top-actions { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.menu-btn { display: none; }
.pill { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted);
  background: var(--card-2); border: 1px solid var(--line); padding: 4px 11px; border-radius: 999px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--off); }
.dot.online { background: var(--on); box-shadow: 0 0 0 3px rgba(52, 199, 123, .2); }
.dot.connecting, .dot.reconnecting { background: #e0a800; }
.dot.error { background: var(--err); }
#toggle { min-width: 104px; padding: 8px 16px; font-weight: 700; font-size: 14px; border: 0; border-radius: 8px; background: var(--off); color: #fff; justify-content: center; }
#toggle.on { background: var(--on); }

main { max-width: 1080px; margin: 0 auto; padding: 24px 24px 80px; }
.page-head { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .hint { margin-bottom: 0; max-width: 640px; }

/* Karten */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card.flush { padding: 0; overflow: hidden; }
.card.dim .items { opacity: .6; }
.card-head { display: flex; align-items: center; gap: 12px; justify-content: space-between; margin-bottom: 10px; flex-wrap: wrap; }
.card-head .search { max-width: 340px; }
.pad { padding-left: 20px; padding-right: 20px; }
.card-head.pad { padding-top: 16px; padding-bottom: 12px; margin: 0; border-bottom: 1px solid var(--line); }
p.hint.pad { margin: 12px 0; }
.banner { border-left: 4px solid var(--warn); background: var(--card); border-radius: 8px; padding: 11px 14px; margin-bottom: 12px; font-size: 14px;
  border-top: 1px solid var(--line); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.banner.ok { border-left-color: var(--on); }
.banner.bad { border-left-color: var(--err); }

/* Übersicht */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 16px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
  display: block; text-align: left; border-top: 3px solid var(--line); font-size: inherit; }
.tile.clickable:hover { border-color: var(--accent); }
.tile.good { border-top-color: var(--on); }
.tile.bad { border-top-color: var(--err); }
.tile.warn { border-top-color: var(--warn); }
.tile-label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.tile-value { font-size: 21px; font-weight: 700; margin: 4px 0 2px; overflow-wrap: anywhere; }
.tile-sub { font-size: 13px; color: var(--muted); }
.big-num { font-size: 30px; font-weight: 700; margin: 6px 0 12px; }
.big-num span { font-size: 14px; font-weight: 400; color: var(--muted); }
.steps { list-style: none; padding: 0; margin: 10px 0 0; }
.steps li { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.steps li.done { color: var(--muted); text-decoration: line-through; }
.step-mark { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-size: 12px; flex: 0 0 auto; }
.steps li.done .step-mark { background: var(--on); border-color: var(--on); color: #fff; text-decoration: none; }

/* Einstellungen */
.conn { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: #9146ff; color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 18px; }
.props { display: grid; grid-template-columns: minmax(140px, 240px) 1fr; gap: 0; margin: 0; }
.props dt, .props dd { padding: 10px 0; border-top: 1px solid var(--line); margin: 0; }
.props dt { color: var(--muted); font-size: 14px; padding-right: 12px; }
.props dd { overflow-wrap: anywhere; }

/* Listen (Danke-Nachrichten) */
.items { display: flex; flex-direction: column; }
.item { display: flex; align-items: center; gap: 14px; padding: 13px 20px; border-top: 1px solid var(--line); cursor: pointer; }
.items .item:first-child { border-top: 0; }
.item:hover { background: var(--card-2); }
.item.off .item-main { opacity: .55; }
.item-main { flex: 1 1 200px; min-width: 0; }
.item-title { font-weight: 600; }
.item-preview { color: var(--muted); font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.item-actions { display: flex; gap: 6px; }
.tag { font-size: 12px; background: var(--card-2); border: 1px solid var(--line); color: var(--muted); padding: 1px 8px; border-radius: 999px; white-space: nowrap; }
.count-badge { display: inline-block; min-width: 30px; text-align: center; background: var(--accent-soft); color: var(--accent); border-radius: 6px; padding: 0 6px; font-weight: 700; }

/* Tabelle (Auto-Antworten) */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600;
  padding: 10px 12px; background: var(--card-2); border-bottom: 1px solid var(--line); }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover { background: var(--card-2); }
.table tr.off td:not(.c-on):not(.c-act) { opacity: .5; }
.table th:first-child, .table td:first-child { padding-left: 20px; }
.table th:last-child, .table td:last-child { padding-right: 20px; }
.c-on { width: 70px; }
.c-name { font-weight: 600; }
.c-act { width: 1%; white-space: nowrap; }

/* Chips für Platzhalter */
.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: 8px 0 4px; }
.chips-label { font-size: 12.5px; color: var(--muted); margin-right: 2px; }
.chip { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; padding: 3px 9px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); border: 1px solid transparent; }
.chip:hover { border-color: var(--accent); }

/* Popup-Fenster */
dialog#modal { border: 1px solid var(--line); border-radius: 16px; padding: 0; background: var(--card); color: var(--text);
  width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 40px); box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
  flex-direction: column; overflow: hidden; }
dialog#modal[open] { display: flex; }
dialog#modal.lg { width: min(820px, calc(100vw - 24px)); }
dialog#modal::backdrop { background: rgba(8, 8, 14, .6); backdrop-filter: blur(2px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 22px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 18px; margin: 0; }
.modal-body { padding: 8px 22px 20px; overflow-y: auto; flex: 1 1 auto; }
.modal-errors { margin: 0; padding: 10px 22px 10px 40px; color: var(--err); font-size: 14px; background: var(--card-2); border-top: 1px solid var(--line); }
.modal-foot { display: flex; gap: 10px; align-items: center; padding: 14px 22px; border-top: 1px solid var(--line); background: var(--card-2); flex-wrap: wrap; }
.form-section { padding: 14px 0 6px; border-top: 1px solid var(--line); }
.form-section:first-child { border-top: 0; }
.form-section h4 { margin-top: 4px; }
.form-section label:first-child { margin-top: 0; }
.tester { margin-top: 6px; padding: 10px 12px 8px; border-radius: 10px; background: var(--card-2); border: 1px dashed var(--line); }
.tester label { margin-top: 0; }
.tester-out { font-size: 14px; margin-top: 6px; min-height: 20px; }
.tester-out.ok { color: var(--on); }
.tester-out.no { color: var(--muted); }
.pattern-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.pattern-row { display: flex; gap: 6px; align-items: center; }
.pattern-row input { flex: 1 1 auto; min-width: 0; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.pattern-mark { flex: 0 0 18px; text-align: center; font-weight: 600; }
.pattern-mark.ok { color: var(--on); }
.pattern-mark.no { color: var(--muted); }
.pattern-mark.err { color: var(--err); }
.help ul { padding-left: 20px; }
.help li { margin: 6px 0; }

/* Ausprobieren */
.try-layout { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.try-cards .card h3 { margin-bottom: 6px; }
.try-cards .card > button { margin-top: 12px; }
.sim-card { position: sticky; top: 84px; }
.sim-out { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.bubble { background: var(--card-2); border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px; overflow-wrap: anywhere; }
.bubble.blocked { border-color: var(--err); }
.bubble-meta { font-size: 12px; color: var(--muted); margin-bottom: 2px; }

/* Protokoll */
.log { background: #0e0d15; color: #d8d4ea; font: 12.5px/1.55 ui-monospace, Menlo, Consolas, monospace; border-radius: 10px; padding: 10px 12px;
  height: 60vh; min-height: 280px; overflow-y: auto; }
.log.mini { height: auto; min-height: 0; max-height: 260px; }
.log div { white-space: pre-wrap; word-break: break-word; }
.log .t { color: #7b7694; }
.log .k-sent { color: #7be0a6; }
.log .k-dry, .log .k-sim { color: #f3c969; }
.log .k-error { color: #ff8b8b; }
.log .k-event { color: #8fc2ff; }
.log .k-rule { color: #c9a7ff; }
.log .k-chat { color: #9a96b0; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filter { border-radius: 999px; padding: 4px 12px; font-size: 13px; color: var(--muted); }
.filter.on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

/* Meldungen */
#toasts { position: fixed; right: 20px; bottom: 20px; z-index: 50; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast { background: #1f2029; color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.25); font-size: 14px;
  border-left: 4px solid var(--on); max-width: min(420px, calc(100vw - 40px)); transition: opacity .3s, transform .3s; }
.toast.bad { border-left-color: var(--err); }
.toast.out { opacity: 0; transform: translateY(6px); }

/* Handy & kleine Fenster */
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .nav-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 25; }
  .main-col { margin-left: 0; }
  .menu-btn { display: inline-flex; }
  .topbar h1 { visibility: visible; }
  .page-head h2 { display: none; }
  .topbar { padding: 8px 16px; gap: 8px 12px; }
  .top-actions { gap: 10px; width: 100%; justify-content: space-between; }
  main { padding: 16px 16px 60px; }
  .try-layout { grid-template-columns: 1fr; }
  .sim-card { position: static; }
}
@media (max-width: 640px) {
  .item { flex-wrap: wrap; padding: 12px 16px; }
  .item-main { flex-basis: calc(100% - 60px); }
  .item-chips { order: 3; }
  .item-actions { order: 4; margin-left: auto; }
  .pad { padding-left: 16px; padding-right: 16px; }
  .props { grid-template-columns: 1fr; }
  .props dd { border-top: 0; padding-top: 0; }
  /* Tabelle wird zu Karten */
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: auto; }
  .table tr { position: relative; padding: 12px 16px 12px 70px; border-bottom: 1px solid var(--line); }
  .table td { border: 0; padding: 2px 0 !important; }
  .table td.c-on { position: absolute; left: 16px; top: 14px; }
  .table td[data-label]:not(.c-name)::before { content: attr(data-label) ": "; color: var(--muted); font-size: 12.5px; }
  .table td.c-act { width: auto; margin-top: 6px; }
  .row.nowrap { justify-content: flex-start; }
  .modal-head, .modal-foot { padding-left: 16px; padding-right: 16px; }
  .modal-body { padding: 6px 16px 16px; }
  dialog#modal, dialog#modal.lg { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; border-radius: 0; margin: 0; }
}
