:root {
    --bg: #111214;
    --bg-raised: #1b1c1f;
    --bg-input: #232428;
    --border: #2e3035;
    --text: #e8e9ec;
    --muted: #9a9ca4;
    --accent: #5865f2;
    --accent-hover: #4752c4;
    --accent-soft: rgba(88, 101, 242, .16);
    --danger: #e5484d;
    --ok: #3fb950;
    --warning: #f0b232;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(0, 0, 0, .25);
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
}

/* Hell: Systemeinstellung (außer manuell auf dunkel gestellt) oder manuell gewählt */
@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) {
        --bg: #f6f7f9;
        --bg-raised: #ffffff;
        --bg-input: #f0f1f4;
        --border: #dfe1e6;
        --text: #1c1d21;
        --muted: #5f636d;
        --accent-soft: rgba(88, 101, 242, .1);
        --shadow: 0 1px 3px rgba(16, 24, 40, .08);
        color-scheme: light;
    }
}

:root[data-theme="light"] {
    --bg: #f6f7f9;
    --bg-raised: #ffffff;
    --bg-input: #f0f1f4;
    --border: #dfe1e6;
    --text: #1c1d21;
    --muted: #5f636d;
    --accent-soft: rgba(88, 101, 242, .1);
    --shadow: 0 1px 3px rgba(16, 24, 40, .08);
    color-scheme: light;
}

:root[data-theme="dark"] { color-scheme: dark; }

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

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.55 var(--font);
}

main { flex: 1; padding-bottom: 48px; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .6em; }
h1 { font-size: clamp(1.6rem, 4vw, 2.4rem); }
h2 { font-size: 1.35rem; margin-top: 2.2em; }
p { margin: 0 0 1em; }
img { max-width: 100%; }

.container { width: 100%; max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 680px; padding-top: 32px; }
.muted { color: var(--muted); }
.error { color: var(--danger); }
.warning { background: rgba(240, 178, 50, .12); border: 1px solid var(--warning); border-radius: var(--radius); padding: 10px 14px; }

.skip-link { position: absolute; left: -9999px; }
.skip-link:focus { left: 16px; top: 8px; z-index: 100; background: var(--bg-raised); padding: 8px 12px; border-radius: 8px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Header / Footer ── */

.site-header {
    position: sticky; top: 0; z-index: 10;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: 16px; min-height: 60px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.1rem; color: var(--text); }
.brand-mark {
    display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px;
    background: var(--accent); color: #fff; font-weight: 800;
}
.nav { display: flex; gap: 4px; }
.nav a { color: var(--muted); padding: 6px 10px; border-radius: 8px; }
.nav a:hover { color: var(--text); background: var(--bg-input); text-decoration: none; }
.header-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.lang-switch { width: auto; padding: 6px 8px; }
.theme-toggle {
    display: grid; place-items: center; width: 38px; height: 38px; padding: 0;
    border: 1px solid var(--border); border-radius: 10px; background: var(--bg-input); color: var(--text); cursor: pointer; font-size: 1.1rem;
}

.account { position: relative; }
.account-button {
    display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px;
    background: var(--bg-input); border: 1px solid var(--border); border-radius: 999px; color: var(--text); cursor: pointer;
}
.avatar { width: 28px; height: 28px; border-radius: 50%; }
.menu {
    position: absolute; right: 0; top: calc(100% + 6px); min-width: 200px; z-index: 20;
    display: flex; flex-direction: column; padding: 6px;
    background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
}
.menu[hidden] { display: none; }
.menu a, .menu button {
    padding: 8px 10px; border-radius: 8px; text-align: left; color: var(--text);
    background: none; border: 0; font: inherit; cursor: pointer;
}
.menu a:hover, .menu button:hover { background: var(--bg-input); text-decoration: none; }

.site-footer { border-top: 1px solid var(--border); padding: 20px 0; color: var(--muted); font-size: .9rem; }
.footer-inner { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.footer-inner nav { display: flex; gap: 16px; }

/* ── Buttons & Formulare ── */

.button, .actions > a {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 40px; padding: 8px 16px; border-radius: 10px;
    border: 1px solid var(--border); background: var(--bg-input); color: var(--text);
    font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.button:hover, .actions > a:hover { text-decoration: none; border-color: var(--muted); }
.button-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.button-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.button-ghost { background: transparent; }
.button-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

input, select, textarea {
    width: 100%; padding: 9px 11px; border-radius: 9px;
    border: 1px solid var(--border); background: var(--bg-input); color: var(--text); font: inherit;
}
textarea { resize: vertical; }
input[type="color"] { width: 64px; height: 40px; padding: 3px; }
input[type="checkbox"] { width: auto; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
.field-label { font-weight: 600; }
.group { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px 0; margin: 0 0 18px; }
.group legend { padding: 0 6px; font-weight: 700; }
.inline-group { display: flex; gap: 10px; }
.inline-group label { display: flex; flex-direction: column; gap: 4px; flex: 1; }

.switch { position: relative; display: inline-block; width: 46px; height: 26px; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--border); border-radius: 999px; transition: background .15s; cursor: pointer; }
.switch span::before {
    content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px;
    background: #fff; border-radius: 50%; transition: transform .15s;
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::before { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.multi { display: flex; flex-direction: column; gap: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 4px 3px 10px; border-radius: 999px; background: var(--accent-soft); }
.chip button { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 1.1rem; line-height: 1; padding: 2px 6px; }

.card { background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.sticky-actions { position: sticky; bottom: 0; padding: 12px 0 0; background: linear-gradient(transparent, var(--bg-raised) 30%); }

.grid-form { display: grid; grid-template-columns: 1fr; gap: 12px; }
.grid-form label { display: flex; flex-direction: column; gap: 4px; }
@media (min-width: 720px) {
    .grid-form { grid-template-columns: 1fr 1fr; }
    .span-2 { grid-column: span 2; }
}

/* ── Startseite ── */

.hero { padding: 56px 0 24px; background: radial-gradient(ellipse at top, var(--accent-soft), transparent 70%); }
.hero-inner { display: flex; gap: 28px; align-items: center; flex-wrap: wrap; }
.hero-avatar { width: 120px; height: 120px; border-radius: 28px; box-shadow: 0 10px 30px rgba(88, 101, 242, .35); }
.lead { font-size: 1.15rem; color: var(--muted); max-width: 560px; }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 720px) { .stats { grid-template-columns: repeat(3, 1fr); } }
.stat { background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.stat-value { font-size: 1.7rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: .9rem; }

.features { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 720px) { .features { grid-template-columns: repeat(2, 1fr); } }
.feature p { color: var(--muted); margin: 0; }

.reviews { display: grid; grid-template-columns: 1fr; gap: 12px; margin-bottom: 16px; }
@media (min-width: 720px) { .reviews { grid-template-columns: repeat(2, 1fr); } }
.review p { margin: 8px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.review-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.stars { color: var(--warning); letter-spacing: 1px; }
.feedback-forms { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 720px) { .feedback-forms { grid-template-columns: 1fr 1fr; } }
.feedback-forms form { display: flex; flex-direction: column; gap: 10px; }
.star-input { display: flex; gap: 2px; }
.star-input button { background: none; border: 0; font-size: 1.8rem; color: var(--border); cursor: pointer; padding: 0 2px; min-width: 40px; min-height: 40px; }
.star-input button.on { color: var(--warning); }

/* ── Dashboard ── */

.guilds { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.guild { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.guild > a:last-child { margin-top: auto; }
.guild > a[data-link] {
    display: inline-flex; padding: 8px 16px; border-radius: 10px; background: var(--accent); color: #fff; font-weight: 600;
}
.guild-inactive { opacity: .75; }
.guild-name { overflow-wrap: anywhere; }
.guild-icon { width: 64px; height: 64px; border-radius: 18px; object-fit: cover; }
.guild-icon-fallback { display: grid; place-items: center; background: var(--bg-input); font-weight: 700; color: var(--muted); }

.dashboard { padding-top: 28px; }
.guild-header { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.guild-header h1 { margin: 0; }
.dashboard-layout { display: grid; grid-template-columns: 1fr; gap: 18px; }
@media (min-width: 900px) { .dashboard-layout { grid-template-columns: 220px 1fr; align-items: start; } }

.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: thin; padding-bottom: 4px; }
@media (min-width: 900px) { .tabs { flex-direction: column; position: sticky; top: 76px; } }
.tabs a { padding: 9px 12px; border-radius: 9px; color: var(--muted); white-space: nowrap; }
.tabs a:hover { background: var(--bg-input); color: var(--text); text-decoration: none; }
.tabs a[aria-current="page"] { background: var(--accent-soft); color: var(--text); font-weight: 600; }

.rows { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.row label { display: flex; flex-direction: column; gap: 4px; }
.row label:first-child { width: 96px; }
.grow { flex: 1; min-width: 160px; }

.entries { list-style: none; padding: 0; margin: 0 0 16px; display: flex; flex-direction: column; gap: 6px; }
.entries li { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 9px; background: var(--bg-input); flex-wrap: wrap; }
.entry-emoji { font-size: 1.4rem; min-width: 32px; text-align: center; }
.emoji { width: 24px; height: 24px; vertical-align: middle; }
.role-tag { padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); font-size: .9rem; }
.emoji-picker { display: flex; flex-wrap: wrap; gap: 4px; }
.emoji-picker button { background: var(--bg-input); border: 1px solid var(--border); border-radius: 8px; padding: 4px; cursor: pointer; width: 40px; height: 40px; }
.emoji-picker img { width: 28px; height: 28px; }
.panel h4 { margin-top: 18px; }

.preview { margin-top: 10px; border-radius: var(--radius); border: 1px solid var(--border); }

/* ── Sonstiges ── */

.loading { height: 3px; width: 100%; background: linear-gradient(90deg, transparent, var(--accent), transparent); background-size: 200% 100%; animation: loading 1s linear infinite; }
@keyframes loading { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.toasts { position: fixed; bottom: 16px; left: 16px; right: 16px; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 50; pointer-events: none; }
.toast { background: var(--bg-raised); border: 1px solid var(--border); border-left: 4px solid var(--ok); border-radius: 10px; padding: 10px 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, .3); max-width: 480px; pointer-events: auto; }
.toast-error { border-left-color: var(--danger); }

@media (max-width: 560px) {
    .account-name { display: none; }
    .nav a { padding: 6px 8px; }
    .hero { padding-top: 32px; }
    .hero-avatar { width: 88px; height: 88px; border-radius: 22px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ── Reaction-Role-Editor ── */

.stack-sm { display: flex; flex-direction: column; gap: 12px; }
.small { font-size: .9rem; }
.note { background: var(--accent-soft); border-radius: 10px; padding: 10px 14px; margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.actions-end { justify-content: flex-end; }
.field .field-label + .segmented { align-self: flex-start; }

.segmented { display: inline-flex; padding: 3px; gap: 3px; border-radius: 10px; background: var(--bg-input); border: 1px solid var(--border); flex-wrap: wrap; }
.segmented button { border: 0; background: none; color: var(--muted); padding: 7px 12px; border-radius: 8px; font: inherit; cursor: pointer; min-height: 36px; }
.segmented button.active { background: var(--bg-raised); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }

.editor { display: grid; grid-template-columns: 1fr; gap: 20px; margin-top: 12px; }
@media (min-width: 1000px) {
    .editor { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); }
    .editor-preview { position: sticky; top: 76px; align-self: start; }
}
.editor-preview { display: flex; flex-direction: column; gap: 8px; min-width: 0; }

.panel { padding: 0; overflow: hidden; }
.panel.open { padding-bottom: 18px; }
.panel.open > .editor { padding: 0 18px; }
.panel-head {
    display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 18px;
    background: none; border: 0; color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.panel-head:hover { background: var(--bg-input); }
.panel-head .grow { display: flex; flex-direction: column; min-width: 0; }
.panel-head strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel-emojis { display: flex; gap: 2px; font-size: 1.2rem; min-width: 40px; }
.chevron { color: var(--muted); }

.entry-add { display: flex; flex-direction: column; gap: 10px; padding: 12px; border: 1px dashed var(--border); border-radius: var(--radius); }
.entries li .grow { min-width: 140px; }

.message-list { display: flex; flex-direction: column; gap: 6px; max-height: 420px; overflow-y: auto; padding: 2px; }
.message-item {
    display: grid; grid-template-columns: 32px 1fr; grid-template-rows: auto auto; column-gap: 10px; text-align: left;
    padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-input); color: var(--text); font: inherit; cursor: pointer;
}
.message-item .avatar { grid-row: span 2; width: 32px; height: 32px; }
.message-item.selected { border-color: var(--accent); background: var(--accent-soft); }
.message-item:disabled { opacity: .5; cursor: not-allowed; }
.message-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: .9rem; }
.message-snippet { color: var(--muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }

/* Vorschau im Discord-Look (bewusst immer dunkel wie der Discord-Standard) */
.dc-preview {
    display: flex; gap: 14px; padding: 14px 16px; border-radius: var(--radius);
    background: #313338; color: #dbdee1; font: 15px/1.4 "gg sans", "Noto Sans", system-ui, sans-serif;
}
.dc-avatar { width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; }
.dc-body { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.dc-head { display: flex; align-items: center; gap: 6px; }
.dc-head strong { color: #f2f3f5; }
.dc-head .muted { color: #949ba4; font-size: .75rem; }
.dc-bot { background: #5865f2; color: #fff; font-size: .62rem; font-weight: 700; padding: 1px 5px; border-radius: 4px; }
.dc-text { white-space: normal; overflow-wrap: anywhere; }
.dc-text code, .dc-embed code { background: #2b2d31; padding: 1px 4px; border-radius: 4px; font-size: .85em; }
.mention { --mention: #5865f2; color: color-mix(in srgb, var(--mention) 75%, #fff); background: color-mix(in srgb, var(--mention) 22%, transparent); padding: 0 3px; border-radius: 4px; font-weight: 500; }
.dc-embed {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; max-width: 520px; margin-top: 2px;
    background: #2b2d31; border-left: 4px solid var(--embed-color); border-radius: 4px; padding: 10px 14px 12px 12px;
}
.dc-embed-main { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.dc-embed-title { font-weight: 700; color: #f2f3f5; }
.dc-embed-desc { font-size: .9rem; overflow-wrap: anywhere; }
.dc-embed-image { border-radius: 4px; max-height: 300px; object-fit: contain; align-self: flex-start; }
.dc-embed-thumb { width: 80px; height: 80px; object-fit: cover; border-radius: 4px; }
.dc-embed-footer { font-size: .75rem; color: #b5bac1; }
.dc-reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.dc-reaction { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 8px; background: #2b2d31; border: 1px solid #3f4147; font-size: .85rem; }
.dc-reaction .emoji { width: 18px; height: 18px; }
