*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #0f0f13;
    --bg2: #1a1a22;
    --bg3: #22222e;
    --border: #2e2e3e;
    --text: #e8e8f0;
    --text2: #9090a8;
    --purple: #9147ff;
    --purple-dark: #7b2fff;
    --teal: #1d9e75;
    --red: #e24b4a;
    --green: #4caf7d;
    --amber: #f0a500;
    --radius: 8px;
    --radius-lg: 12px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.6;
    min-height: 100vh;
}

/* ─── Header ─────────────────────────────────────────────────── */

header {
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    padding: 0 1.5rem;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 1100px;
    margin: 0 auto;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.site-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
}

nav {
    display: flex;
    align-items: center;
    gap: 10px;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--border);
}

.username { font-size: 14px; color: var(--text2); }

/* ─── Main ───────────────────────────────────────────────────── */

main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

h2 { font-size: 18px; font-weight: 600; margin-bottom: 1rem; margin-top: 1.5rem; color: var(--text); }
h3 { font-size: 15px; font-weight: 600; margin-bottom: 0.75rem; color: var(--text); }

/* ─── Buttons ────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg3);
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.btn:hover { background: var(--bg2); border-color: #444; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { display: block; width: 100%; text-align: center; margin-top: 6px; }

.btn-primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn-primary:hover { background: #179965; border-color: #179965; }

.btn-twitch { background: var(--purple); border-color: var(--purple); color: #fff; }
.btn-twitch:hover { background: var(--purple-dark); border-color: var(--purple-dark); }

.btn-danger { background: transparent; border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: var(--red); color: #fff; }

.btn-teal { background: transparent; border-color: var(--teal); color: var(--teal); }
.btn-teal:hover { background: var(--teal); color: #fff; }

.btn-lg { padding: 12px 24px; font-size: 15px; margin-top: 1rem; }

/* ─── Cards ──────────────────────────────────────────────────── */

.card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1rem;
}

.card.center { text-align: center; max-width: 480px; margin: 3rem auto; }
.card.center p { color: var(--text2); margin: 0.5rem 0; }

/* ─── Badges ─────────────────────────────────────────────────── */

.role-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.role-owner  { background: #3c2a6e; color: #b48fff; }
.role-mod    { background: #1a3a2a; color: #4caf7d; }
.role-viewer { background: var(--bg3); color: var(--text2); }

/* ─── Status Bar ─────────────────────────────────────────────── */

.status-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text2);
    margin-bottom: 1.5rem;
    padding: 8px 12px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.status-dot.green { background: var(--green); }
.status-dot.red   { background: var(--red); }

/* ─── Command Grid ───────────────────────────────────────────── */

.command-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.command-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
}

.command-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
    text-transform: capitalize;
}

/* ─── Alerts ─────────────────────────────────────────────────── */

.alert {
    padding: 10px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 1rem;
    border: 1px solid transparent;
}

.alert-success { background: #1a3a2a; border-color: var(--green); color: var(--green); }
.alert-error   { background: #2a1a1a; border-color: var(--red); color: var(--red); }

/* ─── Editor ─────────────────────────────────────────────────── */

.page-header { margin-bottom: 1rem; }

.editor-layout {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 1.5rem;
    align-items: start;
}

@media (max-width: 768px) { .editor-layout { grid-template-columns: 1fr; } }

.editor-main { display: flex; flex-direction: column; gap: 8px; }

.editor-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius) var(--radius) 0 0;
}

.editor-hint { font-size: 12px; color: var(--text2); }

.json-editor {
    width: 100%;
    min-height: 480px;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    color: var(--text);
    font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.7;
    padding: 1rem;
    resize: vertical;
    outline: none;
    transition: border-color 0.15s;
}

.json-editor:focus { border-color: var(--teal); }
.json-editor.invalid { border-color: var(--red); }

.json-error {
    font-size: 12px;
    color: var(--red);
    padding: 6px 12px;
    background: #2a1a1a;
    border: 1px solid var(--red);
    border-radius: var(--radius);
}

/* ─── Sidebar / Backups ──────────────────────────────────────── */

.editor-sidebar {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
}

.backup-list { display: flex; flex-direction: column; gap: 8px; }

.backup-item {
    padding: 8px 10px;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.backup-meta { display: flex; flex-direction: column; }
.backup-time { font-size: 12px; color: var(--text); font-weight: 500; }
.backup-user { font-size: 11px; color: var(--text2); }

/* ─── Log Table ──────────────────────────────────────────────── */

.log-table { width: 100%; border-collapse: collapse; font-size: 13px; }

.log-table th {
    text-align: left;
    padding: 8px 12px;
    color: var(--text2);
    font-weight: 500;
    border-bottom: 1px solid var(--border);
}

.log-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); color: var(--text); }
.log-table tr:last-child td { border-bottom: none; }
.log-table tr:hover td { background: var(--bg3); }

/* ─── Formular Editor ───────────────────────────────────────── */

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.view-toggle { display: flex; gap: 6px; }

.form-editor {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.form-group-root {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    background: var(--bg3);
}

.form-group-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.form-field { display: flex; flex-direction: column; gap: 6px; }

.form-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.placeholder-hints {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 2px;
}

.placeholder-badge {
    font-size: 11px;
    font-family: var(--font-mono, monospace);
    padding: 2px 7px;
    border-radius: 20px;
    background: #1a2a3a;
    color: #5ba4cf;
    border: 1px solid #2a4a6a;
}

.owner-only-badge {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 20px;
    background: #3c2a6e;
    color: #b48fff;
    font-weight: 600;
    text-transform: uppercase;
}

.form-input {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
    padding: 8px 12px;
    outline: none;
    transition: border-color 0.15s;
    font-family: inherit;
}

.form-input:focus { border-color: var(--teal); }

.form-textarea {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
    padding: 8px 12px;
    outline: none;
    transition: border-color 0.15s;
    resize: vertical;
    font-family: inherit;
    line-height: 1.6;
}

.form-textarea:focus { border-color: var(--teal); }

.form-actions {
    margin-top: 1rem;
    display: flex;
    justify-content: flex-end;
}

/* ─── LAB ────────────────────────────────────────────────────── */

.lab-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
    background: #3a2a00;
    color: var(--amber);
    border: 1px solid var(--amber);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.lab-banner {
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    padding: 3px 12px;
    border-radius: 20px;
    background: #3a2a00;
    color: var(--amber);
    border: 1px solid var(--amber);
    letter-spacing: 2px;
}

/* ─── User Verwaltung ────────────────────────────────────────── */

.user-section { margin-bottom: 2rem; }

.user-section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 0.75rem;
    font-size: 13px;
    color: var(--text2);
}

.user-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.user-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.user-info { display: flex; flex-direction: column; }
.user-name { font-size: 14px; font-weight: 500; color: var(--text); }
.user-meta { font-size: 12px; color: var(--text2); }
