/* SPDX-FileCopyrightText: 2026 The UCNG authors (see NOTICE)
   SPDX-License-Identifier: AGPL-3.0-or-later */
[hidden] { display: none !important; }
:root {
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --bg: #f3f2f8;
  --surface: #ffffff;
  --text: #171927;
  --muted: #6b6f86;
  --line: #e3e3ee;
  --accent: #5848f4;
  --accent-soft: #ecebfe;
  --on-accent: #fff;
  --ink: #15172e;
  --ok: #0d7a52;
  --official: #4a3be0; --official-soft: #e9e7ff;
  --rec: #0a7d55; --rec-soft: #dcf5ea;
  --warn: #9a5b00; --warn-soft: #fff1d6;
  --std: #2f6690; --std-soft: #e3eef7;
  --danger: #d93f4c;
  --shadow: 0 1px 2px rgba(21, 23, 46, .05), 0 10px 30px -14px rgba(21, 23, 46, .22);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1020; --surface: #1a1c30; --text: #ecebf7; --muted: #9a9cb6; --line: #2b2e48;
    --accent: #8b80ff; --accent-soft: #2a2752; --on-accent: #0f1020; --ink: #0b0c18; --ok: #3fd39b; --danger: #ff6b78;
    --official: #a9a0ff; --official-soft: #2b2856; --rec: #4fd8a2; --rec-soft: #133a2d; --warn: #ffc266; --warn-soft: #3a2c12; --std: #8ec5f0; --std-soft: #1b2d40;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 30px -14px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.5 var(--font); background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wrap { width: min(1120px, 100% - 32px); margin: 0 auto; }

/* Kopf */
.top { background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 5; }
.top-row { display: flex; align-items: center; gap: 24px; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 700; font-size: 18px; letter-spacing: -.02em; }
.brand svg, .brand img { width: 28px; height: 28px; color: #8b80ff; flex: none; }
.tabs { display: flex; gap: 4px; margin-left: auto; }
.tabs a { color: #b9bbd2; text-decoration: none; padding: 7px 14px; border-radius: 10px; font-weight: 550; font-size: 14.5px; }
.tabs a:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.tabs a[aria-current="page"] { color: #fff; background: rgba(139, 128, 255, .28); }

/* Einleitung */
.hero { padding: 36px 0 20px; }
.hero h1 { margin: 0 0 6px; font-size: clamp(26px, 4vw, 36px); letter-spacing: -.03em; line-height: 1.15; }
.hero p { margin: 0; color: var(--muted); max-width: 720px; }
.stats { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0 0; }
.stats div { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 8px 14px; }
.stats dt { font-size: 12px; color: var(--muted); }
.stats dd { margin: 0; font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; }

/* Filter */
.filters { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; gap: 8px; }
.filters input, .filters select, .gif-head input, .card input, .card select {
  height: 42px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); outline: none; min-width: 0;
}
.filters input:focus, .filters select:focus, .gif-head input:focus, .card input:focus, .card select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.count { color: var(--muted); font-size: 13.5px; margin: 12px 2px; }

/* Instanzen */
.instances { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.inst { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 16px 18px; box-shadow: var(--shadow); display: grid; gap: 8px; }
.inst-head { display: flex; align-items: center; gap: 12px; }
.inst-mark { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: #fff; font-weight: 700; flex-shrink: 0; }
.inst-name { font-weight: 700; font-size: 16px; line-height: 1.2; overflow-wrap: anywhere; }
.inst-name a { color: inherit; text-decoration: none; }
.inst-name a:hover { color: var(--accent); }
.inst-domain { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.inst-desc { margin: 0; color: var(--text); font-size: 14px; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: var(--bg); color: var(--muted); white-space: nowrap; }
.badge.users { background: var(--accent-soft); color: var(--accent); }
.badge.ok { color: var(--ok); }
.inst-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.btn {
  height: 36px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
  font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; color: var(--text);
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { filter: brightness(1.08); color: var(--on-accent); }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); }
.empty { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 40px 10px; }
.howto { margin: 24px 0 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px 18px; }
.howto summary { cursor: pointer; font-weight: 650; }
.howto ol { margin: 10px 0 2px; padding-left: 20px; color: var(--muted); }
.howto code, .subscribe code { background: var(--bg); padding: 2px 6px; border-radius: 6px; font-size: 13px; overflow-wrap: anywhere; color: var(--text); }

/* GIFs */
.gif-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.gif-head input { width: min(320px, 100%); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { height: 34px; padding: 0 14px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: 13.5px; }
.chip[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.chip .n { opacity: .65; font-weight: 500; margin-left: 4px; }
.subscribe { margin: 14px 0 0; display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; justify-content: space-between; background: var(--accent-soft); border-radius: 16px; padding: 14px 18px; }
.subscribe p { margin: 2px 0 0; color: var(--muted); font-size: 13.5px; max-width: 560px; }
.sub-copy { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.gif-grid { columns: 4 200px; column-gap: 10px; }
.gif-grid.small { columns: 6 130px; }
.gif-tile { display: block; width: 100%; margin: 0 0 10px; break-inside: avoid; border: 0; padding: 0; border-radius: 12px; overflow: hidden; background: var(--surface); position: relative; }
.gif-tile img { display: block; width: 100%; height: auto; }
.gif-tile .t { position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 8px 6px; font-size: 12px; color: #fff; text-align: left;
  background: linear-gradient(transparent, rgba(0, 0, 0, .65)); opacity: 0; transition: opacity .15s; }
.gif-tile:hover .t, .gif-tile:focus-visible .t { opacity: 1; }
.gif-tile.add::after { content: "+ übernehmen"; position: absolute; top: 6px; right: 6px; background: var(--accent); color: var(--on-accent); font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 99px; }
.more { text-align: center; margin: 10px 0 30px; }

dialog { border: 0; border-radius: 20px; padding: 0; background: var(--surface); color: var(--text); width: min(720px, 100vw - 32px); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(10, 12, 28, .55); }
.gif-detail { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; padding: 20px; position: relative; }
.gif-detail img { width: 100%; height: auto; border-radius: 12px; background: var(--bg); }
.gif-detail h3 { margin: 0 0 6px; }
.gif-detail p { margin: 0 0 8px; color: var(--muted); font-size: 14px; }
.x { position: absolute; top: 8px; right: 10px; border: 0; background: none; font-size: 26px; line-height: 1; color: var(--muted); }

/* Verwaltung */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 20px 22px; margin: 0 0 16px; box-shadow: var(--shadow); }
.card h2 { margin: 0 0 6px; font-size: 18px; }
.card .hint, .card > p { color: var(--muted); margin: 0 0 12px; font-size: 14px; }
.login { max-width: 420px; margin: 10px auto 40px; display: grid; gap: 10px; }
.field { display: grid; gap: 5px; margin: 0 0 12px; }
.field > span { font-size: 13.5px; font-weight: 600; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.row-end { display: flex; justify-content: flex-end; align-items: center; gap: 10px; }
.saved { color: var(--ok); font-size: 13.5px; }
.error { color: var(--danger); font-size: 14px; margin: 6px 0 0; }
.error:empty { display: none; }
.inline { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 12px; }
.inline input { flex: 1 1 200px; }
.coll-list, .admin-inst { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.coll-list li, .admin-inst li { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; }
.coll-list li .grow, .admin-inst li .grow { flex: 1; min-width: 0; }
.coll-list small, .admin-inst small { color: var(--muted); display: block; overflow-wrap: anywhere; }
.admin-inst li.hidden { opacity: .55; }
.add-coll { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 0 0 12px; font-size: 14px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px; }
.checks label { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 99px; font-size: 13px; cursor: pointer; }
.checks label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.add-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 0 0 14px; }
.add-box { display: grid; gap: 8px; border: 1px dashed var(--line); border-radius: 14px; padding: 12px; }
.admin-bar { display: flex; justify-content: space-between; align-items: center; margin: 0 0 12px; color: var(--muted); }
.foot { color: var(--muted); font-size: 13px; padding: 30px 0; }

@media (max-width: 720px) {
  .top-row { gap: 10px; }
  .brand span { display: none; }
  .tabs { margin-left: auto; }
  .tabs a { padding: 6px 10px; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters input { grid-column: 1 / -1; }
  .grid2, .add-grid, .gif-detail { grid-template-columns: 1fr; }
  .instances { grid-template-columns: 1fr; }
}

/* Vertrauensstufen */
.trust { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; padding: 3px 9px 3px 7px; border-radius: 99px; white-space: nowrap; line-height: 1.3; }
.trust svg { width: 13px; height: 13px; flex-shrink: 0; }
.trust.official { background: var(--official-soft); color: var(--official); }
.trust.recommended { background: var(--rec-soft); color: var(--rec); }
.trust.community { background: var(--warn-soft); color: var(--warn); }
.inst-head .trust { margin-left: auto; align-self: flex-start; }
.inst.trust-official { border-color: color-mix(in srgb, var(--official) 45%, var(--line)); box-shadow: var(--shadow), inset 0 3px 0 var(--official); }
.inst.trust-recommended { box-shadow: var(--shadow), inset 0 3px 0 var(--rec); }
.inst-note { margin: -2px 0 0; font-size: 13px; color: var(--muted); font-style: italic; }
.trust-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 12px; }
.chip.t-official[aria-selected="true"] { background: var(--official); border-color: var(--official); color: var(--on-accent); }
.chip.t-recommended[aria-selected="true"] { background: var(--rec); border-color: var(--rec); color: var(--on-accent); }
.chip.t-community[aria-selected="true"] { background: var(--warn); border-color: var(--warn); color: var(--on-accent); }
.trust-help { font-size: 13.5px; color: var(--muted); }
.trust-help summary { cursor: pointer; font-weight: 600; color: var(--text); }
.trust-help[open] { flex-basis: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px; }
.trust-help dl { display: grid; gap: 8px; margin: 10px 0; }
.trust-help dl div { display: grid; grid-template-columns: 120px 1fr; gap: 10px; align-items: start; }
.trust-help dd { margin: 0; color: var(--text); }
.trust-help p { margin: 0; }
.inst-row { align-items: flex-start !important; }
.inst-row-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.trust-edit { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.trust-edit select, .trust-edit input { height: 32px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 0 8px; font-size: 13px; }
.trust-edit input { flex: 1; min-width: 140px; }
.inst-acts { display: flex; gap: 6px; flex-wrap: wrap; }
.admin-inst small.warn { color: var(--warn); font-weight: 600; }
.sub-h { font-size: 15px; margin: 18px 0 4px; }
#trustPending { margin-top: 10px; }
@media (max-width: 640px) {
  .trust-help dl div { grid-template-columns: 1fr; gap: 2px; }
  .inst-row { flex-wrap: wrap; }
}

.badge.warn { background: var(--warn-soft); color: var(--warn); }

.badge.country { display: inline-flex; align-items: center; gap: 5px; }
.flag { width: 16px; height: 12px; border-radius: 2px; object-fit: cover; box-shadow: 0 0 0 1px rgba(0,0,0,.1); flex-shrink: 0; }
.trust.standard { background: var(--std-soft); color: var(--std); }
.chip.t-standard[aria-selected="true"] { background: var(--std); border-color: var(--std); color: var(--on-accent); }

/* Sprachauswahl im Kopf */
.top-lang { display: inline-flex; align-items: center; gap: 6px; color: #b9bbd2; font-size: 13.5px; }
.top-lang[hidden] { display: none; }
.top-lang svg { width: 16px; height: 16px; flex: none; }
.top-lang select {
  appearance: none; -webkit-appearance: none; border: 0; background: transparent; color: inherit; font: inherit; cursor: pointer;
  padding: 4px 16px 4px 0; border-radius: 6px;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: right 5px center, right 1px center; background-size: 4px 4px, 4px 4px; background-repeat: no-repeat;
}
.top-lang select:hover { color: #fff; }
.top-lang option { color: var(--text); background: var(--surface); }
@media (max-width: 640px) { .top-lang { font-size: 12.5px; } .top-lang svg { display: none; } }

/* Sprachen in der Verwaltung */
.i18n-card { margin-bottom: 0; }
#i18nRoot { margin-top: 16px; }

/* Hinweise */
.toast { position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; box-shadow: var(--shadow); max-width: calc(100vw - 32px); z-index: 50; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); }

/* Sprachpakete für Chat-Server */
.lp-head { margin: 28px 0 18px; }
.lp-head h1 { margin: 0 0 8px; font-size: clamp(24px, 4vw, 32px); letter-spacing: -.02em; }
.lp-head p { margin: 0; color: var(--muted); max-width: 760px; }
.lp-list { list-style: none; padding: 0; margin: 0 0 22px; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); }
.lp-list .empty { grid-column: 1 / -1; }
.lp { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 16px 18px; box-shadow: var(--shadow); display: grid; gap: 8px; align-content: start; }
.lp-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lp-top b { font-size: 16.5px; }
.lp-code { font: 700 11px/1 ui-monospace, Menlo, Consolas, monospace; color: var(--accent); background: var(--accent-soft); padding: 4px 6px; border-radius: 6px; }
.lp-bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.lp-bar span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.lp-meta { margin: 0; color: var(--muted); font-size: 13px; }
.lp-note { margin: 0; font-size: 13.5px; }
.lp-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.lp-actions .btn { text-decoration: none; }
.lp-new-form { flex-wrap: wrap; }
.lp-new-form input { flex: 1 1 150px; min-width: 0; }
.lp-up .grid2 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.lp-up-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.lp-up-hint { margin-top: 6px !important; font-size: 13px !important; }
#lpAdmin { margin-top: 10px; }

/* Schmale Bildschirme: Reiter rollen innerhalb der Kopfzeile statt die Seite zu verbreitern */
@media (max-width: 520px) {
  .top-row { gap: 8px; }
  .brand svg, .brand img { width: 24px; height: 24px; }
  .tabs { min-width: 0; flex: 1 1 auto; overflow-x: auto; scrollbar-width: none; gap: 2px; }
  .tabs a:first-child { margin-left: auto; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs a { padding: 6px 8px; font-size: 13.5px; white-space: nowrap; flex: none; }
  .top-lang { flex: none; }
  .top-lang select { max-width: 76px; text-overflow: ellipsis; }
}

.inst-foot .src-link { color: var(--muted); font-size: 13px; margin-left: auto; margin-right: 10px; }
.inst-foot .src-link:hover { color: var(--accent); }
