/* Xyntal Guard panel: Design nach docs/community/design.md (Tokens §1, Shell §2,
   Komponenten §3, Übersicht §4). Keine Inline-Styles, keine externen Quellen.
   Klassen aus dem Design bleiben: card, stack, grid2, row, field, notice, stat,
   badge, toast. Hell ist Standard; Dunkel folgt dem System, außer data-theme
   auf html sagt etwas anderes. */
@font-face { font-family: "Plex"; src: url("/fonts/plexsans-latin.woff2") format("woff2"); font-weight: 100 700; font-display: swap; }
@font-face { font-family: "Serif4"; src: url("/fonts/sourceserif4-latin.woff2") format("woff2"); font-weight: 400 700; font-display: swap; }

/* ---------- Tokens: hell (Standard) */
:root {
  color-scheme: light;
  --bg: #f5f4f0;
  --surface: #ffffff;
  --surface-2: #eeede8;
  --border: #d9d7cf;
  --border-strong: #8d8a82;
  --text: #1c1c1a;
  --muted: #62605a;
  --accent: #2563c7;
  --accent-text: #ffffff;
  --accent-soft: #e6eefb;
  --success: #1e7d4a;
  --success-soft: #e3f3ea;
  --warning: #8f5600;
  --warning-soft: #fbf0dc;
  --danger: #c4302b;
  --danger-soft: #fbe6e5;
  --danger-solid: #c4302b;
  --danger-solid-text: #ffffff;
  --high: #b24a00;
  --toggle-off: #7a776f;
  --overlay: rgba(20, 20, 18, .55);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .06);
  --shadow-2: 0 8px 24px rgba(0, 0, 0, .18);
  --shadow-3: 0 16px 40px rgba(0, 0, 0, .28);
  /* Discord-Vorschau: immer dunkel, unabhängig vom Theme */
  --dc-bg: #313338; --dc-embed: #2b2d31; --dc-text: #dbdee1; --dc-muted: #949ba4;
  --dc-link: #00a8fc; --dc-btn: #4e5058; --dc-btn-primary: #5865f2;
  /* Maße */
  --s1: 4px; --s2: 8px; --s3: 16px; --s4: 24px; --s5: 32px; --s6: 48px;
  --radius-sm: 6px; --radius-md: 10px; --radius-lg: 14px; --radius-pill: 999px;
  --fs-xs: 12px; --fs-sm: 13px; --fs-md: 14px; --fs-lg: 16px; --fs-xl: 20px; --fs-2xl: 28px; --fs-stat: 26px;
  --sidebar: 220px;
  --ease: 150ms ease;
}

/* ---------- Tokens: dunkel (System oder Wahl „Dunkel“) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #1c1c1c; --surface: #232323; --surface-2: #2a2a2a; --border: #353535; --border-strong: #6f6c65;
    --text: #eceae4; --muted: #a3a097; --accent: #8fb8ff; --accent-text: #1c1c1c; --accent-soft: #243145;
    --success: #6fcf97; --success-soft: #1f3328; --warning: #ffc53d; --warning-soft: #3a2f14;
    --danger: #ff7b7f; --danger-soft: #3d2224; --danger-solid: #d63a40; --danger-solid-text: #ffffff;
    --high: #ff9b52; --toggle-off: #7d7a73; --overlay: rgba(0, 0, 0, .65);
    --shadow-2: 0 8px 24px rgba(0, 0, 0, .4); --shadow-3: 0 16px 40px rgba(0, 0, 0, .4);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1c1c1c; --surface: #232323; --surface-2: #2a2a2a; --border: #353535; --border-strong: #6f6c65;
  --text: #eceae4; --muted: #a3a097; --accent: #8fb8ff; --accent-text: #1c1c1c; --accent-soft: #243145;
  --success: #6fcf97; --success-soft: #1f3328; --warning: #ffc53d; --warning-soft: #3a2f14;
  --danger: #ff7b7f; --danger-soft: #3d2224; --danger-solid: #d63a40; --danger-solid-text: #ffffff;
  --high: #ff9b52; --toggle-off: #7d7a73; --overlay: rgba(0, 0, 0, .65);
  --shadow-2: 0 8px 24px rgba(0, 0, 0, .4); --shadow-3: 0 16px 40px rgba(0, 0, 0, .4);
}

/* ---------- Grundlagen */
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 400 14px/1.5 "Plex", system-ui, sans-serif; min-height: 100vh; }
body.sheet-open { overflow: hidden; }
h1, h2, h3 { font-family: "Serif4", Georgia, serif; font-weight: 600; line-height: 1.2; margin: 0 0 var(--s3); color: var(--text); }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
p { margin: 0 0 var(--s3); }
a { color: var(--accent); }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: var(--fs-xs); }
.muted { color: var(--muted); }
.center { text-align: center; }
.ok { color: var(--success); }
.fail { color: var(--danger); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* Die Seitenüberschrift bekommt nach einem Seitenwechsel programmatisch den Fokus (für Screenreader).
   Der Rahmen bleibt dabei aus; Tastatur-Fokus auf Knöpfen, Links und Feldern bleibt sichtbar. */
h1[tabindex="-1"]:focus { outline: none; }

.icon { width: 16px; height: 16px; flex: none; display: inline-block; vertical-align: middle; }
.icon-lg { width: 32px; height: 32px; color: var(--muted); }

/* ---------- Kopfzeile (sticky, 56 px) */
.top { position: sticky; top: 0; z-index: 20; height: 56px; display: flex; align-items: center; gap: var(--s3); padding: 0 var(--s5); background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { font-family: "Serif4", Georgia, serif; font-size: var(--fs-xl); color: var(--text); text-decoration: none; white-space: nowrap; }
.brand em { color: var(--accent); font-style: italic; }
.top-center { flex: 1; min-width: 0; color: var(--muted); font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-right { display: flex; align-items: center; gap: var(--s3); margin-left: auto; }
.menu-btn { display: none; }
.who { display: flex; gap: var(--s2); align-items: center; }
.who-text { display: flex; gap: var(--s2); align-items: center; font-size: var(--fs-sm); }
.who-logout { font-size: var(--fs-sm); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--surface-2); color: var(--text); display: grid; place-items: center; font-family: "Serif4", Georgia, serif; overflow: hidden; flex: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* Theme-Umschalter: segmentiert, Auto/Hell/Dunkel */
.theme { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.theme button { font: inherit; font-size: var(--fs-sm); font-weight: 500; background: transparent; color: var(--muted); border: 0; padding: 0 var(--s2); min-height: 36px; display: inline-flex; align-items: center; gap: var(--s1); cursor: pointer; transition: background var(--ease), color var(--ease); }
.theme button + button { border-left: 1px solid var(--border); }
.theme button[aria-pressed="true"] { background: var(--accent-soft); color: var(--text); }
.theme button:hover { color: var(--text); }
.theme button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ---------- Knöpfe (40 px, mobil 44) */
button, .button {
  font: inherit; font-weight: 500; font-size: var(--fs-md); color: var(--accent-text); background: var(--accent); border: 1px solid transparent;
  border-radius: var(--radius-sm); min-height: 40px; padding: 0 var(--s3); cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); transition: background var(--ease), border-color var(--ease), opacity var(--ease);
}
button:hover, .button:hover { filter: brightness(1.06); }
button:disabled { opacity: .5; cursor: not-allowed; filter: none; }
button.ghost { background: transparent; color: var(--text); border-color: var(--border-strong); }
button.ghost:hover { background: var(--surface-2); filter: none; }
button.danger { background: var(--danger-solid); color: var(--danger-solid-text); }
button.link { background: none; color: var(--accent); padding: 0 var(--s1); min-height: 36px; }
button.link:hover { text-decoration: underline; filter: none; }
button.small { min-height: 32px; padding: 0 var(--s2); font-size: var(--fs-sm); }
button.icon { background: transparent; color: var(--muted); border-color: transparent; min-width: 36px; min-height: 36px; padding: 0; }
button.icon:hover { color: var(--text); border-color: var(--border); background: transparent; filter: none; }
button.icon-btn { min-width: 44px; min-height: 44px; padding: 0; }
button[aria-busy="true"] { cursor: progress; }
.spinner { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; flex: none; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
/* Gefahr in Zeilen: Textknopf statt Vollfläche */
tr button.danger, .row-actions button.danger { background: none; color: var(--danger); padding: 0 var(--s1); min-height: 32px; }
tr button.danger:hover, .row-actions button.danger:hover { text-decoration: underline; filter: none; }
tr button.ghost, .row-actions button.ghost { min-height: 32px; font-size: var(--fs-sm); }

/* ---------- Formfelder (40 px, mobil 44, 16 px Schrift) */
input, select, textarea {
  font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  min-height: 40px; padding: 0 var(--s2); min-width: 0; max-width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type="color"] { padding: 2px; width: 40px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); min-height: 0; width: 18px; height: 18px; margin: 0; }
textarea { width: 100%; min-height: 96px; padding: var(--s2); resize: vertical; }
select { padding-right: var(--s2); }
input:disabled, select:disabled, textarea:disabled { opacity: .5; cursor: not-allowed; }
[aria-invalid="true"] { border-color: var(--danger); }

/* Feld: Label oben, Hilfetext oder Fehler darunter */
.field { display: grid; gap: var(--s1); min-width: 0; }
.field > .field-label { font-size: var(--fs-sm); font-weight: 500; color: var(--text); }
.field > .field-label .optional { font-weight: 400; color: var(--muted); }
.field-help { font-size: var(--fs-xs); color: var(--muted); }
.field-error { display: none; align-items: center; gap: var(--s1); font-size: var(--fs-xs); color: var(--danger); }
.field.has-error .field-error { display: flex; }
.field.has-error .field-help { display: none; }
label.field > span { color: var(--text); font-size: var(--fs-sm); font-weight: 500; }
.input-wrap { display: grid; gap: var(--s1); min-width: 0; }
.input-wrap > input, .input-wrap > textarea { width: 100%; }
.counter { justify-self: end; font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; }
.counter.warn { color: var(--warning); }
.counter.bad { color: var(--danger); }
.chips-insert { display: flex; flex-wrap: wrap; gap: var(--s1); align-items: center; font-size: var(--fs-xs); color: var(--muted); }
.chips-insert button { font-size: var(--fs-xs); min-height: 28px; padding: 0 var(--s2); background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.chips-insert button:hover { background: var(--accent-soft); filter: none; }

/* ---------- Schalter: 44x24, Daumen 18 */
.switch-row { display: flex; align-items: center; gap: var(--s3); min-height: 44px; padding: var(--s1) 0; cursor: pointer; }
.switch-row:has(button:disabled) { cursor: not-allowed; opacity: .5; }
.switch-text { display: grid; gap: 2px; min-width: 0; }
.switch-label { font-weight: 500; color: var(--text); }
.switch-help { font-size: var(--fs-xs); color: var(--muted); }
.switch { position: relative; width: 44px; height: 24px; flex: none; border-radius: var(--radius-pill); border: 0; background: var(--toggle-off); padding: 0; min-height: 0; transition: background var(--ease); }
.switch:hover { filter: none; }
.switch .thumb { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #ffffff; transition: transform var(--ease); display: grid; place-items: center; color: var(--accent); }
.switch .thumb svg { width: 12px; height: 12px; opacity: 0; transition: opacity var(--ease); }
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"] .thumb { transform: translateX(20px); }
.switch[aria-checked="true"] .thumb svg { opacity: 1; }
.switch .thumb .spinner { width: 12px; height: 12px; border-width: 2px; color: var(--accent); opacity: 1; }
.switch:disabled { opacity: 1; }

/* ---------- Notizen, Badges, Kennzahlen */
.notice { display: flex; align-items: flex-start; gap: var(--s2); border: 1px solid var(--warning); background: var(--warning-soft); color: var(--text); border-radius: var(--radius-sm); padding: var(--s2) var(--s3); margin-bottom: var(--s3); font-size: var(--fs-sm); }
.notice .icon { color: var(--warning); margin-top: 2px; }
.notice > span:not(.icon) { flex: 1; min-width: 0; }
.notice.warn { border-color: var(--warning); background: var(--warning-soft); }
.notice.error { border-color: var(--danger); background: var(--danger-soft); }
.notice.error .icon { color: var(--danger); }
.notice.info { border-color: var(--border); background: var(--surface); color: var(--muted); }
.notice.info .icon { color: var(--muted); }
.notice.ok { border-color: var(--success); background: var(--success-soft); }
.notice.ok .icon { color: var(--success); }
.notice .notice-action { margin-left: auto; }

.badge { display: inline-flex; align-items: center; gap: var(--s1); font-size: var(--fs-xs); font-weight: 500; line-height: 1; padding: 4px var(--s2); border-radius: var(--radius-pill); border: 1px solid transparent; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.neutral { background: var(--surface-2); color: var(--muted); border-color: var(--border); }
.badge.ok { background: var(--success-soft); color: var(--success); border-color: var(--success); }
.badge.warn { background: var(--warning-soft); color: var(--warning); border-color: var(--warning); }
.badge.bad { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.badge.high { background: var(--danger-soft); color: var(--high); border-color: var(--high); }
.badge.info { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s3); margin-bottom: var(--s4); }
.stat { display: grid; gap: var(--s1); align-content: start; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--s3) var(--s4); min-width: 0; }
.stat-label { color: var(--muted); font-size: var(--fs-sm); }
.stat-value { font-family: "Serif4", Georgia, serif; font-size: var(--fs-stat); line-height: 1.2; color: var(--text); font-variant-numeric: lining-nums; }
.stat-note { color: var(--muted); font-size: var(--fs-xs); }
.tone-ok { color: var(--success); }
.tone-warn { color: var(--warning); }
.tone-bad { color: var(--danger); }

/* ---------- Karten */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--s4); margin-bottom: var(--s4); min-width: 0; }
.card.narrow { max-width: 520px; margin: var(--s5) auto; }
.card-head { display: grid; gap: var(--s1); margin-bottom: var(--s3); }
.card-head h2 { margin: 0; }
.card-head .muted { font-size: var(--fs-sm); margin: 0; }
.card-foot { display: flex; justify-content: flex-end; gap: var(--s2); flex-wrap: wrap; margin-top: var(--s4); }
.card.disabled { opacity: .6; }
.card.skeleton .skel-line { height: 14px; border-radius: var(--radius-sm); margin-bottom: var(--s2); background: linear-gradient(90deg, var(--surface-2), var(--border), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s ease-in-out infinite; }
.card.skeleton .skel-line.short { width: 40%; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.card.clickable { transition: border-color var(--ease), box-shadow var(--ease); }
.card.clickable:hover { border-color: var(--accent); box-shadow: var(--shadow-1); }
.card.clickable > a { color: inherit; text-decoration: none; display: grid; gap: var(--s1); }

.row { display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap; }
.row.tight { gap: var(--s2); }
.row.spread { justify-content: space-between; }
.stack > * + * { margin-top: var(--s3); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--s4); align-items: start; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s4); align-items: start; }
.split-right { position: sticky; top: calc(56px + var(--s4)); }
.split-preview > summary { display: none; list-style: none; cursor: pointer; font-weight: 500; color: var(--accent); margin-bottom: var(--s2); }
.split-preview > summary::-webkit-details-marker { display: none; }

/* ---------- Seitenkopf */
.page-head { display: grid; gap: var(--s2); margin-bottom: var(--s4); }
.page-title-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; }
.page-title-row h1 { margin: 0; }
.page-head .page-desc { color: var(--muted); margin: 0; max-width: 120ch; }
.page-toggle { display: inline-flex; align-items: center; gap: var(--s3); }
.page-toggle .switch-label { font-weight: 500; min-width: 3ch; }
.page-head .notice { margin: var(--s2) 0 0; }
.page-head .page-action { display: flex; gap: var(--s2); flex-wrap: wrap; }

/* ---------- Speichern-Leiste */
.savebar { position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: min(1080px, 100%); z-index: 30; min-height: 64px; display: flex; align-items: center; gap: var(--s3); padding: var(--s2) var(--s4); background: var(--surface); border: 1px solid var(--border); border-bottom: 0; border-radius: var(--radius-md) var(--radius-md) 0 0; box-shadow: var(--shadow-2); padding-bottom: calc(var(--s2) + env(safe-area-inset-bottom)); }
.savebar .savebar-msg { display: flex; align-items: center; gap: var(--s2); flex: 1; min-width: 0; font-size: var(--fs-sm); }
.savebar .dot-warn { width: 8px; height: 8px; border-radius: 50%; background: var(--warning); flex: none; }
.savebar.error .savebar-msg { color: var(--danger); }
.savebar.error .dot-warn { background: var(--danger); }
.savebar .savebar-actions { display: flex; gap: var(--s2); flex-wrap: wrap; justify-content: flex-end; }
body.has-savebar main { padding-bottom: 88px; }

/* ---------- Toast (unten mittig, über der Leiste auf dem Handy) */
.toast { position: fixed; bottom: var(--s4); left: 50%; transform: translateX(-50%); z-index: 60; display: flex; align-items: center; gap: var(--s2); background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: var(--s2) var(--s3); box-shadow: var(--shadow-2); max-width: min(420px, calc(100% - 32px)); font-size: var(--fs-sm); white-space: pre-line; transition: opacity var(--ease); }
.toast.error { border-color: var(--danger); }
.toast .icon { flex: none; }
.toast.error .icon { color: var(--danger); }
.toast .toast-close { min-height: 28px; padding: 0 var(--s2); }

/* ---------- Shell: Seitenleiste, Gruppen, Status */
main { max-width: 1080px; margin: 0 auto; padding: var(--s5) var(--s5) var(--s6); }
.back-link { margin: 0 0 var(--s3); font-size: var(--fs-sm); }
.guild-layout { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); gap: var(--s4); align-items: start; }
.sheet-nav { display: grid; gap: var(--s4); }
.top-page { display: none; }
.guild-content { min-width: 0; }
.sidenav { position: sticky; top: var(--s4); display: grid; gap: var(--s4); max-height: calc(100vh - 88px); overflow-y: auto; padding-right: var(--s1); }
.navgroup { display: grid; gap: var(--s1); }
.navgroup-title { color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; padding: 0 var(--s3); margin-bottom: 2px; }
.navlink { display: flex; align-items: center; gap: var(--s2); min-height: 36px; padding: 0 var(--s3); border-radius: var(--radius-sm); color: var(--text); text-decoration: none; font-size: var(--fs-md); border-left: 3px solid transparent; transition: background var(--ease); }
.navlink:hover { background: var(--surface-2); }
.navlink[aria-current="page"] { background: var(--surface); color: var(--accent); font-weight: 600; border-left-color: var(--accent); }
.navlink:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.navlink .navlink-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.navlink .icon { color: var(--muted); }
.navlink[aria-current="page"] .icon { color: var(--accent); }
/* Statuspunkt: 8 px rund, gefüllt = an, Ring = aus. Feste Maße, sonst wird er in der Zeile schmal und hoch. */
.navlink-status { display: inline-flex; align-items: center; flex: none; }
.navlink-status:empty { display: none; }
.status-dot { display: block; box-sizing: border-box; flex-shrink: 0; width: 8px; height: 8px; border-radius: 50%; align-self: center; border: 2px solid var(--toggle-off); }
.status-dot.on { background: var(--success); border-color: var(--success); }
.nav-badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--radius-pill); background: var(--warning-soft); color: var(--warning); font-size: var(--fs-xs); font-weight: 600; display: inline-grid; place-items: center; flex: none; }
.navgroup-empty { display: none; }

/* Mobile Kopfzeile und Sheet: nur unter 760 px */
.sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: var(--overlay); }
.sheet { position: fixed; top: 0; bottom: 0; left: 0; z-index: 41; width: min(340px, 100%); background: var(--surface); display: flex; flex-direction: column; box-shadow: var(--shadow-3); }
.sheet-head, .sheet-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); padding: var(--s2) var(--s3); min-height: 56px; border-bottom: 1px solid var(--border); }
.sheet-foot { border-bottom: 0; border-top: 1px solid var(--border); justify-content: flex-start; flex-wrap: wrap; padding-bottom: calc(var(--s2) + env(safe-area-inset-bottom)); }
.sheet-foot .button { min-height: 44px; }
.sheet-title { font-family: "Serif4", Georgia, serif; font-size: var(--fs-xl); }
.sheet-body { flex: 1; overflow-y: auto; padding: var(--s2) 0; display: grid; gap: var(--s3); align-content: start; }
.sheet-body .navgroup-title { padding: 0 var(--s4); }
.sheet-body .navlink { min-height: 48px; padding: 0 var(--s4); }
.sheet-body .navlink-status { margin-left: auto; }
/* Darstellung im Menü-Sheet (mobil; auf dem Desktop ist das Sheet ausgeblendet). */
.sheet-theme { display: grid; gap: var(--s2); padding: var(--s3) var(--s4); border-top: 1px solid var(--border); }
.sheet-section-title { color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.sheet-theme .theme { display: flex; }
.sheet-theme .theme button { flex: 1; min-height: 44px; justify-content: center; }

/* ---------- Übersicht */
.overview-head { margin-bottom: var(--s4); }
.need-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s1); }
.need-list li { display: flex; align-items: center; gap: var(--s2); }
.need-list li a { color: var(--text); text-decoration: none; display: inline-flex; align-items: center; gap: var(--s2); min-height: 36px; }
.need-list li a:hover { text-decoration: underline; }
.need-list li .icon { color: var(--warning); }
.area-group { margin-bottom: var(--s4); }
.area-group h2 { font-size: var(--fs-lg); margin-bottom: var(--s2); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--s3); }
.tile { display: grid; gap: var(--s1); align-content: start; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--s3); color: var(--text); text-decoration: none; min-width: 0; transition: border-color var(--ease), box-shadow var(--ease); }
.tile:hover { border-color: var(--accent); box-shadow: var(--shadow-1); }
.tile.problem-warn { border-color: var(--warning); }
.tile.problem-bad { border-color: var(--danger); }
.tile.not-set { border-style: dashed; }
.tile-head { display: flex; align-items: center; gap: var(--s2); min-width: 0; }
.tile-head .tile-name { flex: 1; min-width: 0; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-info { color: var(--muted); font-size: var(--fs-xs); }
.recent { list-style: none; margin: 0; padding: 0; }
.recent li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: var(--s3); align-items: center; padding: var(--s2) 0; border-bottom: 1px solid var(--border); }
.recent li:last-child { border-bottom: 0; }
.recent .muted { font-size: var(--fs-sm); }
.recent .who-line { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Tabelle und Liste */
.table-wrap { overflow: visible; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: var(--s2) var(--s3); border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: var(--fs-xs); }
tbody tr { min-height: 48px; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--surface-2); }
tbody tr.clickable:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.excerpt { white-space: pre-wrap; word-break: break-word; background: var(--bg); border-radius: var(--radius-sm); padding: var(--s2); margin-top: var(--s1); }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: var(--s2); min-height: 44px; padding: var(--s1) 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
.skel-row { height: 48px; border-bottom: 1px solid var(--border); background: linear-gradient(90deg, var(--surface), var(--surface-2), var(--surface)); background-size: 200% 100%; animation: shimmer 1.2s ease-in-out infinite; }
.table-more { display: flex; justify-content: center; padding-top: var(--s3); }

/* Leerer Zustand */
.empty { display: grid; justify-items: center; text-align: center; gap: var(--s2); padding: var(--s4) var(--s3); }
.empty h3 { margin: 0; }
.empty p { margin: 0; color: var(--muted); max-width: 52ch; }
.empty .empty-action { margin-top: var(--s1); }

/* ---------- Mehrfachwahl (Chips) und Menü */
.picker-wrap { display: grid; gap: var(--s2); min-width: 0; position: relative; }
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.chip { display: inline-flex; align-items: center; gap: var(--s1); min-height: 28px; max-width: 100%; padding: 0 var(--s1) 0 var(--s2); border-radius: var(--radius-pill); background: var(--accent-soft); border: 1px solid var(--accent); color: var(--text); font-size: var(--fs-sm); }
.chip.warn { background: var(--warning-soft); border-color: var(--warning); }
.chip.gone { background: var(--surface-2); border-color: var(--border-strong); border-style: dashed; }
.chip .chip-name { min-width: 0; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip .chip-note { font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; }
.chip button { min-width: 24px; min-height: 24px; width: 24px; height: 24px; padding: 0; border-radius: 50%; background: transparent; color: var(--text); border: 0; display: inline-grid; place-items: center; }
.chip button:hover { background: var(--surface-2); filter: none; }
.chip .dot, .menu-item .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; display: inline-block; border: 1px solid var(--border-strong); }
.chip .icon, .menu-item .icon { color: var(--muted); }
.chips-empty { color: var(--muted); font-size: var(--fs-sm); }
.picker-note { font-size: var(--fs-xs); color: var(--warning); display: flex; gap: var(--s1); align-items: flex-start; }
.picker-menu { position: absolute; z-index: 35; top: calc(100% + 4px); left: 0; min-width: 280px; max-width: min(360px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-2); padding: var(--s3); display: grid; gap: var(--s2); }
.picker-menu input[type="search"] { width: 100%; }
.menu-list { display: grid; gap: 0; max-height: 280px; overflow-y: auto; }
.menu-item { display: flex; align-items: center; gap: var(--s2); min-height: 40px; padding: 0 var(--s2); border-radius: var(--radius-sm); cursor: pointer; color: var(--text); }
.menu-item:hover { background: var(--surface-2); }
.menu-item .menu-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-item .menu-parent { color: var(--muted); font-size: var(--fs-xs); }
.menu-item input { width: 18px; height: 18px; min-height: 0; }
.menu-foot { display: flex; justify-content: flex-end; }
.menu-empty { color: var(--muted); padding: var(--s2); }

/* Klappmenü der Layout-Rollen (Namenliste) */
details.picker { position: relative; }
details.picker > summary { list-style: none; cursor: pointer; min-height: 32px; display: inline-flex; align-items: center; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 0 var(--s2); color: var(--muted); font-size: var(--fs-xs); white-space: nowrap; }
details.picker > summary::-webkit-details-marker { display: none; }
details.picker[open] > summary { border-color: var(--accent); color: var(--text); }
details.picker .menu { position: absolute; z-index: 35; top: calc(100% + 4px); left: 0; min-width: 240px; max-height: 280px; overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: var(--s2); display: grid; gap: var(--s1); box-shadow: var(--shadow-2); }
details.picker .menu .check { display: inline-flex; gap: var(--s2); align-items: center; cursor: pointer; min-height: 32px; }
details summary { cursor: pointer; color: var(--muted); }
details.more { margin: var(--s2) 0; }
details.more > summary { min-height: 36px; display: flex; align-items: center; color: var(--accent); font-weight: 500; }

/* ---------- Dialog (Bestätigung) */
.dialog-backdrop { position: fixed; inset: 0; z-index: 50; background: var(--overlay); display: grid; place-items: center; padding: var(--s3); }
.dialog { width: min(440px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-3); padding: var(--s4); display: grid; gap: var(--s3); max-height: calc(100vh - 32px); overflow-y: auto; }
.dialog h2 { margin: 0; font-size: var(--fs-xl); }
.dialog .dialog-text { margin: 0; color: var(--muted); white-space: pre-line; }
.dialog .dialog-foot { display: flex; justify-content: flex-end; gap: var(--s2); flex-wrap: wrap; }

/* ---------- Discord-Vorschau (immer dunkel) */
.dc { background: var(--dc-bg); color: var(--dc-text); border-radius: var(--radius-md); padding: var(--s3); font: 400 15px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; display: grid; gap: var(--s2); min-width: 0; }
.dc-empty { color: var(--dc-muted); text-align: center; padding: var(--s5) var(--s3); }
.dc-msg { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: var(--s3); align-items: start; }
.dc-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--dc-btn-primary); color: #ffffff; display: grid; place-items: center; font-weight: 600; }
.dc-head { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.dc-name { color: #ffffff; font-weight: 500; }
.dc-app { background: var(--dc-btn-primary); color: #ffffff; font-size: 10px; font-weight: 600; border-radius: 4px; padding: 1px 4px; }
.dc-time { color: var(--dc-muted); font-size: 12px; }
.dc-content { white-space: pre-wrap; word-break: break-word; margin: 2px 0 0; }
.dc-embed { position: relative; background: var(--dc-embed); border-left: 4px solid #4f8cff; border-radius: 4px; padding: var(--s3); max-width: 432px; display: grid; gap: var(--s2); margin-top: var(--s1); min-width: 0; }
.dc-embed-title { font-weight: 600; font-size: 16px; color: #ffffff; margin: 0; padding-right: 88px; word-break: break-word; }
.dc-embed-desc { font-size: 14px; word-break: break-word; }
.dc-embed-desc p { margin: 0 0 var(--s1); }
.dc-embed-desc ul, .dc-embed-desc ol { margin: 0 0 var(--s1); padding-left: 20px; }
.dc-embed-desc a { color: var(--dc-link); text-decoration: none; }
.dc-embed-desc a:hover { text-decoration: underline; }
.dc-fields { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s3); }
.dc-field { flex: 1 1 100%; min-width: 0; font-size: 14px; }
.dc-field.inline { flex: 1 1 calc(33% - 12px); }
.dc-field-name { font-weight: 600; color: #ffffff; word-break: break-word; }
.dc-field-value { word-break: break-word; }
.dc-thumb { position: absolute; top: var(--s3); right: var(--s3); width: 80px; height: 80px; border-radius: 4px; object-fit: cover; background: var(--dc-btn); }
.dc-image { width: 100%; max-height: 300px; border-radius: 4px; object-fit: cover; background: var(--dc-btn); display: block; }
.dc-placeholder { display: grid; place-items: center; min-height: 80px; color: var(--dc-muted); font-size: 12px; background: var(--dc-btn); border-radius: 4px; }
.dc-footer { font-size: 12px; color: var(--dc-muted); word-break: break-word; }
.dc-buttons { display: flex; flex-wrap: wrap; gap: var(--s2); }
.dc-btn { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 var(--s3); border-radius: 3px; font-size: 14px; font-weight: 500; color: #ffffff; background: var(--dc-btn); }
.dc-btn.primary { background: var(--dc-btn-primary); }
.dc-btn.secondary { background: var(--dc-btn); }
.dc-btn.success { background: #248046; }
.dc-btn.danger { background: #da373c; }
.dc-btn.link { background: var(--dc-btn); }
.dc-select { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); min-height: 40px; padding: 0 var(--s3); border-radius: 3px; background: var(--dc-btn); color: var(--dc-muted); font-size: 14px; }
.dc-too-long { color: #ff7b7f; font-size: 12px; font-weight: 600; }
.dc-caption { color: var(--muted); font-size: var(--fs-xs); margin-top: var(--s2); }

/* ---------- Skeleton-Zeilen und Fortschritt */
.progress { height: 6px; background: var(--surface-2); border-radius: var(--radius-pill); overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width var(--ease); }
.plan li { padding: var(--s1) 0; }
.plan .changes { color: var(--muted); font-size: var(--fs-xs); }
.plan li.ok { color: var(--success); }
.plan li.fail { color: var(--danger); }
.plan .muted { font-size: var(--fs-sm); }
.category { border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--s3); margin-bottom: var(--s3); background: var(--surface); }
.channels { margin-top: var(--s2); }
.editor-item { display: grid; gap: var(--s2); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: var(--s2) var(--s3); margin-bottom: var(--s2); }
.editor-line { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; }
.editor-line .grow { flex: 1 1 160px; }
.editor-line .check { display: inline-flex; gap: var(--s2); align-items: center; cursor: pointer; min-height: 32px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; border: 1px solid var(--border-strong); }
.check { display: inline-flex; gap: var(--s2); align-items: center; cursor: pointer; }
.definition { display: grid; gap: 2px; }
.definition > .muted { font-size: var(--fs-sm); }

/* ---------- Mobil (unter 760 px): Sheet statt Seitenleiste, Blöcke statt Tabellen */
@media (max-width: 759px) {
  /* Kopfzeile: Menü, Marke, Seitenname und rechts nur der Avatar. Umschalter und Abmelden
     stehen im Menü-Sheet; die Flex-Kinder schrumpfen nicht unter ihren Inhalt. */
  .top { padding: 0 var(--s3); gap: var(--s2); }
  .menu-btn { display: inline-flex; flex: none; min-width: 44px; min-height: 44px; padding: 0 var(--s2); background: transparent; color: var(--text); border-color: var(--border-strong); }
  .menu-btn span { font-size: var(--fs-sm); }
  .brand { flex: none; font-size: 18px; }
  .top-center { display: block; min-width: 0; font-size: var(--fs-sm); color: var(--text); font-weight: 500; text-align: right; }
  .top-center:empty { display: none; }
  .top-right { flex: none; min-width: 0; gap: var(--s2); }
  .top-right > .theme { display: none; }
  .who-text { display: none; }
  .who-logout { display: none; }
  .who .avatar { display: grid; }
  .sheet-theme .theme button { min-width: 0; padding: 0 var(--s1); }
  main { padding: var(--s3) var(--s3) var(--s6); }
  .guild-layout { grid-template-columns: minmax(0, 1fr); gap: var(--s3); }
  .top-server { display: none; }
  .top-page { display: block; }
  .sidenav { display: none; }
  .split { grid-template-columns: minmax(0, 1fr); gap: var(--s3); }
  .split-right { position: static; }
  .split-preview > summary { display: block; }
  .split-preview:not([open]) > :not(summary) { display: none; }
  .split-preview > summary { min-height: 44px; display: flex; align-items: center; }
  .savebar { width: 100%; left: 0; transform: none; border-radius: var(--radius-md) var(--radius-md) 0 0; padding: var(--s2) var(--s3); padding-bottom: calc(var(--s2) + env(safe-area-inset-bottom)); }
  .savebar .savebar-actions button { min-height: 44px; }
  .toast { bottom: calc(var(--s4) + 72px); }
  .dialog-backdrop { place-items: end center; padding: 0; }
  .dialog { width: 100%; border-radius: var(--radius-lg) var(--radius-lg) 0 0; padding-bottom: calc(var(--s4) + env(safe-area-inset-bottom)); }
  .field input, .field select, .field textarea, input, select { min-height: 44px; font-size: 16px; }
  /* Einspaltig: Felder und Steuerelemente nehmen die volle Breite (sonst nur ca. 265 px). */
  .field, .input-wrap, .picker-wrap { width: 100%; }
  .field select, .field textarea, .input-wrap select, .input-wrap textarea, .row > select,
  .field input:not([type="checkbox"]):not([type="radio"]),
  .input-wrap input:not([type="checkbox"]):not([type="radio"]),
  .row > input:not([type="checkbox"]):not([type="radio"]) { width: 100%; }
  button { min-height: 44px; }
  button.small, tr button.danger, .row-actions button.danger, tr button.ghost, .row-actions button.ghost, .chips-insert button, button.icon { min-height: 36px; }
  .stats { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s2); }
  .stat { padding: var(--s3); }
  .stat-value { font-size: 22px; }
  .card { padding: var(--s3); }
  .card.narrow { margin: var(--s3) auto; }
  .grid2 { grid-template-columns: minmax(0, 1fr); gap: var(--s3); }
  .tiles { grid-template-columns: minmax(0, 1fr); gap: var(--s2); }
  .tile { min-height: 64px; grid-template-columns: 1fr; }
  .page-title-row { align-items: flex-start; }
  .picker-menu { position: fixed; left: 0; right: 0; bottom: 0; top: auto; min-width: 0; max-width: none; border-radius: var(--radius-lg) var(--radius-lg) 0 0; max-height: 70vh; }
  .menu-list { max-height: 50vh; }
  details.picker .menu { position: static; box-shadow: none; }
  .table-wrap table, .table-wrap thead, .table-wrap tbody, .table-wrap tr, .table-wrap th, .table-wrap td { display: block; width: 100%; }
  .table-wrap thead { display: none; }
  .table-wrap tr { border-bottom: 1px solid var(--border); padding: var(--s2) 0; }
  .table-wrap td { border-bottom: 0; padding: var(--s1) 0; }
  .table-wrap td[data-label]::before { content: attr(data-label); display: block; color: var(--muted); font-size: var(--fs-xs); }
  .dc-embed-title { padding-right: 88px; }
  main { overflow-wrap: anywhere; }
}
@media (min-width: 760px) {
  .menu-btn, .sheet, .sheet-backdrop { display: none !important; }
  .top-center { display: block; }
  .top-center:empty { display: none; }
  .top-page { display: none; }
  .top-server { display: inline; }
  .split-preview > summary { display: none; }
  .split-preview > :not(summary) { display: block !important; }
}
@media (max-width: 640px) {
  .savebar .savebar-msg { font-size: var(--fs-xs); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0ms !important; animation-duration: 1ms !important; animation-iteration-count: 1 !important; }
}
