/* Klanglabor - Industrial Look: Stahl, Schwarz, Signalrot (aus dem Logo abgeleitet) */
:root {
  --red: #e0202a;
  --red-dark: #9e1118;
  --radius: 6px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
}
[data-theme="dark"] {
  --bg: #0b0b0d;
  --bg-2: #141418;
  --panel: #1a1a1f;
  --panel-2: #222228;
  --line: #34343c;
  --text: #e6e6ea;
  --muted: #9a9aa4;
  --steel: linear-gradient(180deg, #d8d8dc 0%, #8e8e96 100%);
  --accent: var(--red);
  --accent-text: #ff4a52;
  --shadow: 0 6px 24px rgba(0, 0, 0, .5);
}
[data-theme="light"] {
  --bg: #eeeef1;
  --bg-2: #e4e4e8;
  --panel: #ffffff;
  --panel-2: #f5f5f7;
  --line: #d2d2d8;
  --text: #17171c;
  --muted: #5d5d66;
  --steel: linear-gradient(180deg, #3a3a42 0%, #17171c 100%);
  --accent: #c4121b;
  --accent-text: #b00f18;
  --shadow: 0 4px 16px rgba(0, 0, 0, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  background-image: radial-gradient(ellipse at top, rgba(224, 32, 42, .08), transparent 60%);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
}
a { color: var(--accent-text); }
a:hover { text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--accent); color: #fff; padding: .5rem 1rem; z-index: 100; }
.skip-link:focus { left: 0; }
[hidden] { display: none !important; }

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 1rem;
  padding: .5rem 1.25rem;
  background: rgba(11, 11, 13, .92);
  border-bottom: 2px solid var(--red-dark);
  backdrop-filter: blur(6px);
}
[data-theme="light"] .topbar { background: rgba(255, 255, 255, .95); }
.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--text); }
.brand img { border-radius: 6px; box-shadow: 0 0 12px rgba(224, 32, 42, .5); }
.brand span { font-weight: 900; letter-spacing: .18em; font-size: 1.05rem; background: var(--steel); -webkit-background-clip: text; background-clip: text; color: transparent; }
nav { display: flex; align-items: center; gap: .25rem; flex-wrap: wrap; margin-left: auto; }
nav a, nav button.linklike {
  color: var(--text); text-decoration: none; padding: .45rem .7rem; border-radius: var(--radius);
  font-size: .92rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 600;
}
nav a:hover, nav button.linklike:hover { background: var(--panel-2); }
nav a.active { color: var(--accent-text); box-shadow: inset 0 -2px 0 var(--accent); }
.menu-toggle { display: none; margin-left: auto; }

main { max-width: 1180px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
main:focus { outline: none; }

h1, h2, h3 { line-height: 1.2; margin: 0 0 .75rem; }
h1 { font-size: 1.7rem; text-transform: uppercase; letter-spacing: .06em; }
h2 { font-size: 1.2rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); border-bottom: 1px solid var(--line); padding-bottom: .4rem; margin-top: 2rem; }
h2::before { content: ""; display: inline-block; width: .5rem; height: .5rem; background: var(--accent); margin-right: .6rem; vertical-align: middle; box-shadow: 0 0 8px var(--accent); }
h3 { font-size: 1.05rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* Panels & cards */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.panel + .panel { margin-top: 1rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--red-dark);
  border-radius: var(--radius); padding: 1rem; display: flex; flex-direction: column; gap: .4rem;
  transition: border-color .15s, transform .15s;
}
.card:hover { border-left-color: var(--accent); transform: translateY(-1px); }
.card h3 a { color: var(--text); text-decoration: none; }
.card h3 a:hover { color: var(--accent-text); }
.card .meta { margin-top: auto; }
.meta { display: flex; flex-wrap: wrap; gap: .4rem .9rem; font-size: .82rem; color: var(--muted); align-items: center; }
.badge { display: inline-block; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; padding: .12rem .45rem; border-radius: 3px; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); }
.badge.red { border-color: var(--red-dark); color: var(--accent-text); }
.badge.warn { border-color: #a86b00; color: #e3a12a; }
.badge.ok { border-color: #2f7d4a; color: #6cc58b; }
.tag { display: inline-block; font-size: .78rem; padding: .1rem .5rem; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); color: var(--text); text-decoration: none; margin: 0 .25rem .25rem 0; }
.tag:hover { border-color: var(--accent); }

/* Buttons & forms */
button, .btn {
  font: inherit; font-size: .92rem; font-weight: 600; cursor: pointer;
  padding: .5rem 1rem; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  text-decoration: none; display: inline-flex; align-items: center; gap: .4rem;
}
button:hover, .btn:hover { border-color: var(--muted); }
button.primary, .btn.primary { background: linear-gradient(180deg, var(--red), var(--red-dark)); border-color: var(--red-dark); color: #fff; text-transform: uppercase; letter-spacing: .05em; }
button.primary:hover, .btn.primary:hover { box-shadow: 0 0 14px rgba(224, 32, 42, .45); }
button.danger { color: var(--accent-text); border-color: var(--red-dark); }
button.linklike { background: none; border: none; padding: 0; color: var(--accent-text); font-weight: 500; }
button:disabled { opacity: .5; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: 1rem; }
.field label { font-weight: 600; font-size: .9rem; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--bg-2);
  border: 1px solid var(--line); border-radius: var(--radius); padding: .55rem .7rem; width: 100%;
}
textarea { min-height: 7rem; resize: vertical; }
textarea.code, .code { font-family: var(--mono); font-size: .9rem; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 2px rgba(224, 32, 42, .25); }
.hint { color: var(--muted); }
.error { color: var(--accent-text); }
.has-error input, .has-error select, .has-error textarea { border-color: var(--accent); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 1rem; }
.alert { padding: .75rem 1rem; border-radius: var(--radius); border: 1px solid var(--red-dark); background: rgba(224, 32, 42, .08); margin-bottom: 1rem; }
.alert.ok { border-color: #2a7a3b; background: rgba(42, 122, 59, .1); }

/* Filters */
.filters { display: grid; grid-template-columns: 2fr repeat(4, 1fr); gap: .6rem; margin-bottom: 1rem; }
.filters .search { grid-column: span 1; }

/* Prompt detail */
.detail-head { display: flex; gap: 1rem; justify-content: space-between; flex-wrap: wrap; align-items: flex-start; }
.prompt-box {
  font-family: var(--mono); white-space: pre-wrap; word-break: break-word;
  background: #070708; color: #f1f1f3; border: 1px solid var(--line); border-left: 3px solid var(--accent);
  padding: 1rem; border-radius: var(--radius); position: relative;
}
[data-theme="light"] .prompt-box { background: #1b1b20; }
.explain { border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; background: var(--panel-2); }
.prose p { margin: 0 0 .7rem; }
.prose p:last-child { margin-bottom: 0; }
.stars { display: inline-flex; gap: .15rem; }
.stars button { background: none; border: none; padding: .1rem; font-size: 1.5rem; line-height: 1; color: var(--line); }
.stars button.on { color: var(--accent); text-shadow: 0 0 8px rgba(224, 32, 42, .6); }
.stars button:hover { color: var(--accent-text); }

.comment, .post { border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; background: var(--panel); margin-bottom: .75rem; }
.post.helpful { border-color: #2a7a3b; box-shadow: inset 3px 0 0 #2a7a3b; }
.post.hidden-item, .comment.hidden-item, .card.hidden-item { opacity: .6; border-style: dashed; }
.post header, .comment header { display: flex; justify-content: space-between; gap: .5rem; flex-wrap: wrap; margin-bottom: .4rem; }

/* Tables (admin) */
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; text-transform: uppercase; font-size: .75rem; letter-spacing: .06em; }
.table-wrap { overflow-x: auto; }

/* Topic list */
.topic-row { display: flex; gap: 1rem; justify-content: space-between; align-items: center; padding: .75rem 1rem; border-bottom: 1px solid var(--line); }
.topic-row:last-child { border-bottom: none; }
.topic-row a { color: var(--text); font-weight: 600; text-decoration: none; }
.topic-row a:hover { color: var(--accent-text); }

/* Hero / auth */
.hero { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; align-items: center; margin-bottom: 1rem; }
.hero img { width: 100%; height: auto; aspect-ratio: 1; max-width: 420px; justify-self: center; border-radius: var(--radius); box-shadow: 0 0 60px rgba(224, 32, 42, .35); }
.hero h1 { font-size: 2.2rem; }
.auth-wrap {
  min-height: calc(100vh - 3rem); display: grid; grid-template-columns: auto minmax(340px, 440px);
  justify-content: center; gap: clamp(2rem, 5vw, 4.5rem); align-items: center;
}
/* Unscharfe Buehne als Seitenhintergrund (nur Login/Antrag) */
.auth-bg {
  position: fixed; inset: -40px; z-index: -1; pointer-events: none;
  background: url("/assets/img/stage-720.jpg") center / cover no-repeat;
  filter: blur(28px) brightness(.35) saturate(1.3);
}
.auth-bg::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(ellipse at 30% 50%, transparent 0%, rgba(11, 11, 13, .85) 75%);
}
[data-theme="light"] .auth-bg { filter: blur(28px) brightness(1.1) saturate(.6); opacity: .35; }
[data-theme="light"] .auth-bg::after { display: none; }
.auth-art {
  height: min(84vh, 860px); aspect-ratio: 720 / 1279; border-radius: 10px; overflow: hidden;
  box-shadow: 0 0 0 1px rgba(224, 32, 42, .35), 0 0 90px rgba(224, 32, 42, .28), 0 20px 50px rgba(0, 0, 0, .6);
}
.auth-art img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 42%; display: block; }
.auth-card {
  padding: 2rem 2rem 1.5rem; border-top: 3px solid var(--accent);
  background: rgba(26, 26, 31, .82); backdrop-filter: blur(12px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .55);
}
[data-theme="light"] .auth-card { background: rgba(255, 255, 255, .9); }
.auth-card h1 {
  text-align: center; font-size: 2.1rem; font-weight: 900; letter-spacing: .2em; margin-bottom: .4rem;
  background: var(--steel); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.auth-eyebrow { text-align: center; margin: 0 0 .3rem; font-size: .75rem; letter-spacing: .3em; text-transform: uppercase; color: var(--accent-text); font-weight: 700; }
.auth-features { list-style: none; margin: 1.1rem 0 1.4rem; padding: .9rem 1rem; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(0, 0, 0, .18); }
[data-theme="light"] .auth-features { background: var(--panel-2); }
.auth-features li { position: relative; padding-left: 1.3rem; font-size: .92rem; }
.auth-features li + li { margin-top: .35rem; }
.auth-features li::before {
  content: ""; position: absolute; left: .1rem; top: .5em; width: .5rem; height: .5rem;
  background: var(--accent); transform: rotate(45deg); box-shadow: 0 0 8px rgba(224, 32, 42, .7);
}
.auth-note { margin: 1rem 0 0; text-align: center; font-size: .8rem; color: var(--muted); }
.tabs { display: flex; gap: .25rem; margin-bottom: 1rem; border-bottom: 1px solid var(--line); }
.tabs button { border: none; background: none; border-bottom: 2px solid transparent; border-radius: 0; text-transform: uppercase; letter-spacing: .05em; }
.tabs button[aria-selected="true"] { border-bottom-color: var(--accent); color: var(--accent-text); }

.pager { display: flex; gap: .5rem; justify-content: center; align-items: center; margin-top: 1.25rem; }
.empty { padding: 2rem; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }
.loading { color: var(--muted); padding: 2rem; text-align: center; }

.toast {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 50; max-width: 360px;
  padding: .8rem 1rem; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow);
  opacity: 0; transform: translateY(10px); transition: all .2s; pointer-events: none;
}
.toast.show { opacity: 1; transform: none; }
.toast.error { border-color: var(--accent); }
.toast.ok { border-color: #2a7a3b; }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); max-width: 520px; width: 92vw; }
dialog::backdrop { background: rgba(0, 0, 0, .6); }

@media (max-width: 860px) {
  .menu-toggle { display: inline-flex; }
  nav { display: none; position: absolute; top: 100%; left: 0; right: 0; flex-direction: column; align-items: stretch; background: var(--panel); border-bottom: 2px solid var(--red-dark); padding: .5rem; }
  nav.open { display: flex; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters .search { grid-column: span 2; }
  .hero, .auth-wrap { grid-template-columns: 1fr; }
  /* Mobil: Ausschnitt genau auf das Zahnrad-Logo, nichts abgeschnitten */
  .auth-wrap { min-height: 0; gap: 1.25rem; }
  .auth-art { height: auto; width: 100%; max-width: 420px; justify-self: center; aspect-ratio: 720 / 700; }
  .auth-card { padding: 1.5rem 1.25rem 1.25rem; }
  .auth-features { display: none; }
  .hero img { max-width: 220px; }
}

.center { text-align: center; }
button.block { width: 100%; justify-content: center; }

/* Ankuendigung / Wartungshinweis unter der Kopfleiste */
.announcement { max-width: 1180px; margin: .75rem auto 0; padding: 0 1.25rem; display: grid; gap: .5rem; }
.banner { padding: .6rem 1rem; border-radius: var(--radius); border: 1px solid var(--line); border-left: 4px solid #3b82c4; background: var(--panel); }
.banner.warning { border-left-color: #e3a12a; background: rgba(227, 161, 42, .08); }

/* Administration */
.admin-tabs { display: flex; flex-wrap: wrap; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1.25rem; }
.admin-tabs a { padding: .55rem .9rem; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; text-transform: uppercase; letter-spacing: .05em; font-size: .85rem; font-weight: 600; }
.admin-tabs a:hover { color: var(--text); }
.admin-tabs a.active { color: var(--accent-text); border-bottom-color: var(--accent); }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .75rem; margin-bottom: 1.5rem; }
.stat { display: flex; flex-direction: column; gap: .15rem; padding: .9rem 1rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--text); }
.stat strong { font-size: 1.6rem; line-height: 1.1; }
.stat span { font-size: .82rem; color: var(--muted); }
a.stat:hover { border-color: var(--muted); }
.stat.hot { border-color: var(--red-dark); box-shadow: inset 3px 0 0 var(--accent); }
.stat.hot strong { color: var(--accent-text); }
.kv { display: grid; gap: .35rem; }
.kv-row { display: flex; justify-content: space-between; gap: 1rem; border-bottom: 1px dashed var(--line); padding-bottom: .3rem; }
.kv-row:last-child { border-bottom: none; }
.settings fieldset { margin: 0 0 1rem; }
.settings legend { font-weight: 800; text-transform: uppercase; letter-spacing: .08em; font-size: .85rem; color: var(--accent-text); padding: 0 .4rem; }
label.check { display: flex; align-items: center; gap: .5rem; font-weight: 600; cursor: pointer; }
label.check input { width: auto; }
.sticky-actions { position: sticky; bottom: 0; padding: .75rem 0; background: linear-gradient(transparent, var(--bg) 35%); }
.toolbar { margin-bottom: .75rem; }
.toolbar input, .toolbar select { width: auto; min-width: 200px; }
button.small { padding: .3rem .6rem; font-size: .8rem; }
.cat-row { display: grid; grid-template-columns: minmax(140px, 1fr) minmax(160px, 2fr) 90px 110px auto auto; gap: .5rem; align-items: center; padding: .4rem 0; border-bottom: 1px solid var(--line); }
.cat-row.head { border-bottom: 1px solid var(--line); padding-bottom: .3rem; }
.cat-row.new { border-bottom: none; }
.cat-row .field { margin: 0; }
.details { max-width: 380px; word-break: break-word; }
.code.secret { display: inline-block; font-size: 1.3rem; letter-spacing: .08em; padding: .4rem .7rem; border: 1px dashed var(--accent); border-radius: var(--radius); user-select: all; }
.auth-wrap.single { grid-template-columns: minmax(300px, 460px); }
@media (max-width: 860px) {
  .cat-row { grid-template-columns: 1fr 1fr; }
  .cat-row.head { display: none; }
  .toolbar input, .toolbar select { min-width: 0; flex: 1; }
}

/* ---- Avatare ---- */
.avatar-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.avatar-frame { display: block; aspect-ratio: 1 / 1; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line);
  background: repeating-conic-gradient(var(--panel-2) 0% 25%, var(--bg-2) 0% 50%) 50% / 20px 20px; }
.avatar-thumb { display: block; width: 100%; height: 100%; object-fit: contain; }
.avatar-card h3 { margin: .5rem 0 0; font-size: 1.05rem; }
.avatar-filters { grid-template-columns: 2fr 1.5fr 1fr auto; }
.avatar-detail { display: grid; grid-template-columns: minmax(0, 480px) 1fr; gap: 1.5rem; align-items: start; }
.avatar-detail h1 { margin-top: 0; }
.upload-grid { display: grid; grid-template-columns: 1fr 220px; gap: 1.25rem; align-items: start; }
.upload-preview { width: 220px; }
@media (max-width: 860px) {
  .avatar-filters, .avatar-detail, .upload-grid { grid-template-columns: 1fr; }
  .upload-preview { width: 100%; max-width: 320px; }
}

/* KI-Werkstatt */
.ai-info { margin-bottom: 1rem; }
.ai-form textarea[name="idea"] { min-height: 5rem; }
.chips { margin: -.6rem 0 1rem; display: flex; flex-wrap: wrap; align-items: center; gap: .25rem; }
.chips .tag { cursor: pointer; font: inherit; }
.ai-result { margin-top: 1rem; }
.ai-result .banner { margin-bottom: .75rem; }
.ai-prompt { width: 100%; min-height: 6rem; }
.ai-actions { margin-top: .5rem; }
.counter { color: var(--muted); margin-right: auto; }
.counter.over { color: var(--accent-text); font-weight: 700; }
.conflicts li { margin-bottom: .3rem; }
.source-list { padding-left: 1.2rem; }
.source-list li { margin-bottom: .6rem; }

/* Tutorials */
.cat-nav { display: flex; flex-wrap: wrap; gap: .25rem; margin: 0 0 1rem; }
.tag.active { border-color: var(--accent); color: var(--accent-text); }
.markdown { line-height: 1.6; overflow-wrap: anywhere; margin: 1.25rem 0; }
.markdown h2, .markdown h3, .markdown h4 { margin: 1.4rem 0 .5rem; }
.markdown p, .markdown ul, .markdown ol, .markdown blockquote { margin: 0 0 .8rem; }
.markdown ul, .markdown ol { padding-left: 1.4rem; }
.markdown li { margin-bottom: .25rem; }
.markdown blockquote { border-left: 3px solid var(--line); padding: .3rem 0 .3rem 1rem; color: var(--muted); }
.markdown hr { border: none; border-top: 1px solid var(--line); margin: 1.4rem 0; }
.markdown code { font-family: var(--mono); font-size: .9em; background: var(--panel-2); border: 1px solid var(--line); border-radius: 3px; padding: 0 .3rem; }
.code-block { position: relative; margin: 0 0 .9rem; }
.code-block pre { margin: 0; font-family: var(--mono); white-space: pre-wrap; word-break: break-word; background: #070708; color: #f1f1f3; border: 1px solid var(--line); border-left: 3px solid var(--accent); padding: 1rem 5.5rem 1rem 1rem; border-radius: var(--radius); }
[data-theme="light"] .code-block pre { background: #1b1b20; }
.code-block pre code { background: none; border: none; padding: 0; font-size: .9rem; }
.code-block .copy { position: absolute; top: .5rem; right: .5rem; }
.preview { border: 1px dashed var(--line); border-radius: var(--radius); padding: .5rem 1rem; min-height: 12rem; background: var(--panel-2); }
.md-help td { padding: .15rem .8rem .15rem 0; }
.md-image { display: block; max-width: 100%; height: auto; margin: .5rem 0 1rem; border: 1px solid var(--line); border-radius: var(--radius); }
.image-panel { border-top: 1px solid var(--line); margin: 1rem 0; padding-top: .75rem; }
.small-heading { font-size: 1rem; margin: 0; }
.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .75rem; }
.image-item { margin: 0; border: 1px solid var(--line); border-radius: var(--radius); padding: .5rem; background: var(--panel-2); display: flex; flex-direction: column; gap: .35rem; }
.image-item img { width: 100%; height: 110px; object-fit: contain; background: var(--bg); border-radius: 3px; }
.image-item figcaption { display: flex; flex-wrap: wrap; gap: .25rem; align-items: center; }
