/* Bot-Panel – dunkles Design, angelehnt an Twitch */
:root {
  --bg: #0e0e10;
  --surface: #18181b;
  --surface-2: #1f1f23;
  --surface-3: #2a2a30;
  --border: #2f2f35;
  --text: #efeff1;
  --muted: #adadb8;
  --faint: #7d7d88;
  --accent: #9147ff;
  --accent-2: #772ce8;
  --accent-soft: rgba(145, 71, 255, .16);
  --ok: #00d26a;
  --ok-soft: rgba(0, 210, 106, .12);
  --warn: #f5a623;
  --warn-soft: rgba(245, 166, 35, .12);
  --bad: #ff4f4d;
  --bad-soft: rgba(255, 79, 77, .13);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 12px 40px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h2 { font-size: 16px; }
h3 { font-size: 15px; }
p { margin: 0; }
button { font: inherit; color: inherit; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 13px; }
.link { color: #bf94ff; text-decoration: none; }
.link:hover { text-decoration: underline; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.inline { display: flex; align-items: center; gap: 8px; }

/* ---------- Layout */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--border); padding: 16px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px; background: var(--accent); color: #fff;
  display: grid; place-items: center; flex: none;
}
.brand strong { display: block; font-size: 15px; }
.brand span { display: block; font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--muted); text-decoration: none; font-weight: 500;
}
nav a:hover { background: var(--surface-2); color: var(--text); }
nav a.active { background: var(--accent-soft); color: #fff; }
nav a.active svg { color: #bf94ff; }
.me { display: flex; align-items: center; gap: 10px; padding: 12px 6px 0; border-top: 1px solid var(--border); margin-top: 12px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--surface-3); flex: none; object-fit: cover; }
.avatar.letter { display: grid; place-items: center; font-weight: 700; color: #bf94ff; }
.me-text { flex: 1; min-width: 0; }
.me-text strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-text span { display: block; font-size: 12px; color: var(--muted); }

.main-wrap { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 5; height: 60px; display: flex; align-items: center; gap: 12px;
  padding: 0 28px; background: rgba(14, 14, 16, .88); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 18px; flex: 1; }
.menu-btn { display: none; }
main { padding: 24px 28px 96px; width: 100%; max-width: 1240px; display: flex; flex-direction: column; gap: 18px; }

.pill {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border); font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.pill.live { background: var(--bad-soft); border-color: rgba(255, 79, 77, .4); color: #ff8a88; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; flex: none; }
.live .dot { animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* ---------- Boxen & Karten */
.box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.box.flush { padding: 0; gap: 0; overflow: hidden; }
.box-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.box-head.pad { padding: 16px 20px; border-bottom: 1px solid var(--border); }
.box.help { flex-direction: row; display: block; color: var(--muted); }
.box.help strong { color: var(--text); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.card.wide { grid-column: span 2; }
.card-label { color: var(--muted); font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.card-value { font-size: 26px; font-weight: 700; display: flex; align-items: center; gap: 9px; }
.card-value .dot { width: 10px; height: 10px; }
.card-value.live { color: #ff6b69; }
.card-value.ok { color: var(--ok); }
.card-value.bad { color: var(--bad); }
.card-value.muted { color: var(--muted); }
.card-text { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-sub { color: var(--muted); font-size: 12.5px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.empty { color: var(--muted); padding: 28px; text-align: center; }

.alert { padding: 11px 14px; border-radius: var(--radius-sm); border: 1px solid; font-weight: 500; }
.alert.bad { background: var(--bad-soft); border-color: rgba(255, 79, 77, .35); color: #ffb3b2; }
.alert.warn { background: var(--warn-soft); border-color: rgba(245, 166, 35, .35); color: #ffd28a; }
.alert.ok { background: var(--ok-soft); border-color: rgba(0, 210, 106, .35); color: #8af0bd; }

/* ---------- Formulare */
.form { display: flex; flex-direction: column; gap: 14px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; align-items: start; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-weight: 600; font-size: 13px; color: var(--muted); }
.hint { color: var(--faint); font-size: 12.5px; }
.input {
  width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 11px; font: inherit; outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.invalid { border-color: var(--bad); }
textarea.input { resize: vertical; min-height: 42px; line-height: 1.45; }
select.input { cursor: pointer; padding-right: 30px; }
.input.num { max-width: 120px; }
.input.dur { max-width: 96px; }
.input.search { max-width: 360px; }
.prefix-input { display: flex; }
.prefix-input span {
  display: grid; place-items: center; padding: 0 12px; background: var(--surface-3); border: 1px solid var(--border);
  border-right: 0; border-radius: var(--radius-sm) 0 0 var(--radius-sm); font-weight: 700; color: var(--muted);
}
.prefix-input .input { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.title-input { font-weight: 600; max-width: 260px; background: transparent; border-color: transparent; padding-left: 4px; }
.title-input:hover { border-color: var(--border); }
.action-picker { display: flex; gap: 8px; }

.switch-row { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; font-weight: 500; }
.switch { position: relative; width: 40px; height: 22px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.slider { position: absolute; inset: 0; background: var(--surface-3); border-radius: 999px; transition: background .15s; }
.slider::after {
  content: ""; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; transition: transform .15s;
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::after { transform: translateX(18px); }
.switch input:focus-visible + .slider { box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2);
  font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-3); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn-danger { background: var(--bad-soft); border-color: rgba(255, 79, 77, .45); color: #ff8a88; }
.btn-danger:hover { background: rgba(255, 79, 77, .25); }
.btn-ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: var(--radius-sm);
  border: 0; background: transparent; color: var(--muted); cursor: pointer; flex: none;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.danger:hover { color: var(--bad); }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.toolbar p { flex: 1; min-width: 220px; }

.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--surface-3); font-size: 12px; font-weight: 600; white-space: nowrap; }
.tag.t-bad { background: var(--bad-soft); color: #ff8a88; }
.tag.t-warn { background: var(--warn-soft); color: #ffc65c; }
.tag.t-ok { background: var(--ok-soft); color: #5ce3a0; }
.chip { display: inline-block; padding: 1px 8px; border-radius: 6px; background: var(--surface-3); font-size: 12px; color: var(--muted); font-weight: 500; }
.chip.clickable { border: 1px solid var(--border); cursor: pointer; font-family: ui-monospace, Consolas, monospace; }
.chip.clickable:hover { border-color: var(--accent); color: var(--text); }
.var-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: -6px; }

/* ---------- Tabellen */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--faint); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: rgba(255, 255, 255, .02); }
.msg-cell { color: var(--muted); max-width: 380px; overflow-wrap: anywhere; }
.box > .table-wrap { margin: 0 -20px -18px; }

/* ---------- Befehle */
.cmd-list { display: flex; flex-direction: column; }
.cmd-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 16px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); }
.cmd-row:last-child { border-bottom: 0; }
.cmd-name { font-weight: 700; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; color: #bf94ff; }
.cmd-resp { color: var(--muted); overflow-wrap: anywhere; margin-top: 2px; }
.cmd-meta { display: flex; align-items: center; gap: 10px; font-size: 12.5px; }
.cmd-actions { display: flex; gap: 2px; }

/* ---------- Auto-Mod */
.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 14px; }
.filter-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; gap: 14px; transition: opacity .15s; }
.filter-card.off .filter-body { opacity: .45; }
.filter-head { display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; }
.filter-head p { margin-top: 3px; }
.filter-body { display: flex; flex-direction: column; gap: 12px; }
.steps { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.step { display: flex; align-items: center; gap: 10px; }
.step-no { width: 22px; color: var(--muted); font-weight: 700; }
.test-form { display: flex; gap: 8px; }
.timer-list { display: flex; flex-direction: column; gap: 14px; }
.timer.off { opacity: .7; }

/* ---------- Live-Chat */
main.main-chat { max-width: none; height: calc(100vh - 60px); padding-bottom: 20px; }
.chat-wrap { display: flex; flex-direction: column; gap: 10px; flex: 1; min-height: 0; }
.chat-box { position: relative; flex: 1; min-height: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.chat-list { position: absolute; inset: 0; overflow-y: auto; padding: 10px 0; overscroll-behavior: contain; }
.msg, .sys { position: relative; padding: 4px 16px; line-height: 1.55; overflow-wrap: anywhere; }
.msg:hover { background: rgba(255, 255, 255, .035); }
.msg .t, .sys .t, .user-msgs .t { color: var(--faint); font-size: 12px; margin-right: 8px; font-variant-numeric: tabular-nums; }
.msg .name { background: none; border: 0; padding: 0; font-weight: 700; cursor: pointer; color: #bf94ff; }
.msg .name:hover { text-decoration: underline; }
.msg.bot { background: rgba(145, 71, 255, .07); }
.msg.bot .name { cursor: default; text-decoration: none; }
.msg.first { box-shadow: inset 3px 0 0 var(--ok); }
.msg.me .text { font-style: italic; }
.msg.removed .text { color: var(--faint); text-decoration: line-through; }
.badge { display: inline-block; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; padding: 1px 5px; border-radius: 4px; margin-right: 5px; vertical-align: 1px; }
.b-streamer { background: #e91916; color: #fff; }
.b-mod { background: #00ad03; color: #fff; }
.b-vip { background: #e005b9; color: #fff; }
.b-sub { background: var(--accent); color: #fff; }
.b-bot { background: #4b4b56; color: #fff; }
.b-first { background: var(--ok-soft); color: var(--ok); }
.emote { height: 26px; vertical-align: middle; margin: -4px 1px; }
.msg-tools { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); display: none; gap: 2px; background: var(--surface-3); border: 1px solid var(--border); border-radius: 8px; padding: 2px; }
.msg:hover .msg-tools, .msg.show-tools .msg-tools { display: flex !important; }
.tool { width: 28px; height: 26px; border: 0; background: transparent; color: var(--muted); border-radius: 6px; cursor: pointer; display: grid; place-items: center; }
.tool:hover { background: var(--surface-2); color: var(--text); }
.tool.danger:hover { color: var(--bad); }
.sys { display: flex; align-items: center; gap: 7px; font-size: 13px; }
.sys svg { flex: none; }
.sys.action { color: #ffa3a2; background: rgba(255, 79, 77, .06); }
.sys.event { color: #d2b4ff; background: rgba(145, 71, 255, .08); }
.chat-jump { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); padding: 7px 14px; border-radius: 999px; border: 0; background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; box-shadow: var(--shadow); }
.chat-form { display: flex; gap: 8px; }
.user-card { display: flex; flex-direction: column; gap: 14px; }
.user-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.user-name { font-size: 17px; }
.btn-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.user-msgs { max-height: 180px; overflow-y: auto; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; display: flex; flex-direction: column; gap: 3px; overflow-wrap: anywhere; }

/* ---------- Modal, Toasts, Speicherleiste */
.modal-back { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .6); display: grid; place-items: center; padding: 16px; animation: fade .12s ease-out; }
.modal { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px 0; }
.modal-head h2 { font-size: 17px; }
.modal-body { padding: 16px 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 0 18px 18px; }
@keyframes fade { from { opacity: 0; } }
#toasts { position: fixed; right: 18px; bottom: 18px; z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast { padding: 10px 14px; border-radius: 10px; background: var(--surface-3); border: 1px solid var(--border); box-shadow: var(--shadow); font-weight: 500; max-width: 380px; transition: opacity .3s, transform .3s; }
.toast.ok { border-color: rgba(0, 210, 106, .45); }
.toast.bad { border-color: rgba(255, 79, 77, .55); color: #ffb3b2; }
.toast.hide { opacity: 0; transform: translateY(8px); }
.savebar {
  position: fixed; left: 50%; bottom: 18px; z-index: 40; transform: translate(-50%, 140%);
  display: flex; align-items: center; gap: 18px; padding: 10px 12px 10px 18px; border-radius: 12px;
  background: var(--surface-3); border: 1px solid var(--border); box-shadow: var(--shadow); transition: transform .2s; font-weight: 600;
}
.savebar.show { transform: translate(-50%, 0); }

/* ---------- Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(900px 500px at 50% -10%, rgba(145, 71, 255, .25), transparent 70%), var(--bg); }
.login-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 32px 28px; display: flex; flex-direction: column; gap: 14px; text-align: center; box-shadow: var(--shadow); }
.login-card .brand-mark { width: 52px; height: 52px; border-radius: 14px; margin: 0 auto 4px; }
.login-card h1 { font-size: 22px; }
.btn-twitch { background: var(--accent); border-color: var(--accent); color: #fff; padding: 11px 16px; font-size: 15px; }
.btn-twitch:hover { background: var(--accent-2); }
.login-card .alert { text-align: left; }

/* ---------- Handy & Tablet */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 30; left: 0; top: 0; width: 264px; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .menu-btn { display: inline-grid; }
  .topbar { padding: 0 16px; }
  main { padding: 16px 16px 96px; }
  main.main-chat { padding-bottom: 12px; }
  .card.wide { grid-column: span 1; }
  .grid-2 { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr; }
  .cmd-row { grid-template-columns: minmax(0, 1fr) auto; }
  .cmd-meta { grid-column: 1 / -1; grid-row: 2; }
  .savebar { width: calc(100% - 32px); justify-content: space-between; }
}
@media (max-width: 520px) {
  .action-picker { flex-wrap: wrap; }
  .btn-grid { grid-template-columns: 1fr; }
  .pill { display: none; }
}
