/* Cortina App. Token aus DESIGN.md. Sidebar und Kopfzeile sind in jedem Modul pixelgleich. */
:root {
  --bg: #ffffff;
  --panel: #faf8f8;
  --line: rgba(45, 45, 45, 0.12);
  --ink: #2d2d2d;
  --muted: #6b6b6b;
  --primary: #6c1428;
  --primary-hover: #4a0e1c;
  --primary-soft: #f1e8ea;
  --primary-text: #6c1428;
  --good: #1f7a3f;
  --bad: #b3261e;
  --warn: #8a6100;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s6: 24px; --s8: 32px; --s12: 48px;
  --r-sm: 4px; --r-md: 6px;
  --control: 32px;
  --row: 40px;
  --sidebar: 240px;
  --header: 48px;
  --t-fast: 100ms; --t-mid: 200ms;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1a1b;
    --panel: #242122;
    --line: rgba(255, 255, 255, 0.12);
    --ink: #ece7e8;
    --muted: #a69da0;
    --primary-soft: #3a2229;
    --primary-text: #d4a5b0;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  }
}
@media (prefers-reduced-motion: reduce) {
  :root { --t-fast: 0ms; --t-mid: 0ms; }
}

*, *::before, *::after { box-sizing: border-box; }
html { font: 400 14px/1.5 Helvetica, Arial, sans-serif; color: var(--ink); background: var(--bg); -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; }
a { color: var(--primary-text); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--primary-text); outline-offset: 2px; }
h1, h2, h3, p, ul, ol { margin: 0; }
button, input, select { font: inherit; color: inherit; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); }   /* sonst Browser-Blau als zweite Akzentfarbe */
.oben-4 { margin-top: var(--s4); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg.icon { width: 16px; height: 16px; stroke: currentColor; stroke-width: 1.75; fill: none; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Schale: umgekehrtes L */
.app { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); grid-template-rows: var(--header) minmax(0, 1fr); min-height: 100vh; }
.kopf { grid-column: 1 / -1; display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr) auto; align-items: center; height: var(--header); border-bottom: 1px solid var(--line); background: var(--bg); }
.logo { display: flex; align-items: center; gap: var(--s2); height: 100%; padding: 0 var(--s4); color: var(--ink); font-weight: 700; }
.logo:hover { text-decoration: none; }
.logo .marke { width: 24px; height: 24px; border-radius: var(--r-sm); background: var(--primary); color: #fff; display: grid; place-items: center; font-size: 12px; }
.suche { height: var(--control); max-width: 480px; width: 100%; text-align: left; cursor: pointer; display: flex; align-items: center; gap: var(--s2); padding: 0 var(--s3); border: 1px solid var(--line); border-radius: var(--r-sm); color: var(--muted); background: var(--panel); }
.suche kbd { margin-left: auto; font: 400 12px/1 Helvetica, Arial, sans-serif; color: var(--muted); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 2px 5px; }
.kopf-rechts { display: flex; align-items: center; gap: var(--s2); padding: 0 var(--s4); }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-text); display: grid; place-items: center; font-size: 12px; font-weight: 700; }

.seite { grid-row: 2; display: flex; flex-direction: column; background: var(--panel); border-right: 1px solid var(--line); padding: var(--s3) var(--s2); gap: var(--s4); }
.seite .block-titel { font-size: 12px; color: var(--muted); padding: 0 var(--s2); margin-bottom: var(--s1); }
.nav a { display: flex; align-items: center; gap: var(--s2); height: var(--control); padding: 0 var(--s2); border-radius: var(--r-sm); color: var(--muted); }
.nav a:hover { background: var(--primary-soft); text-decoration: none; color: var(--ink); }
.nav a[aria-current="page"] { background: var(--primary-soft); color: var(--primary-text); }
.nav a .zahl { margin-left: auto; font-variant-numeric: tabular-nums; font-size: 12px; }
.seite .fuss { margin-top: auto; }

main { grid-row: 2; padding: var(--s6) var(--s8); min-width: 0; }
.ansicht-kopf { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s4); margin-bottom: var(--s6); }
.pfad { font-size: 13px; color: var(--muted); }
.pfad a { color: var(--muted); }
h1 { font-size: 20px; line-height: 1.2; margin-top: var(--s1); }
h2 { font-size: 16px; line-height: 1.25; }
.unter { color: var(--muted); margin-top: var(--s1); }
.aktionen { display: flex; gap: var(--s2); align-items: center; flex: none; }

/* Bedienelemente */
.knopf { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); height: var(--control); padding: 0 var(--s3); border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--bg); color: var(--ink); cursor: pointer; white-space: nowrap; transition: background var(--t-fast) ease-out; }
.knopf:hover { background: var(--panel); text-decoration: none; }
.knopf.primaer { background: var(--primary); border-color: var(--primary); color: #fff; }
.knopf.primaer:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.knopf.leise { border-color: transparent; background: transparent; color: var(--muted); }
.knopf.leise:hover { background: var(--primary-soft); color: var(--ink); }
.knopf:disabled { opacity: .5; cursor: not-allowed; }
.feld { height: var(--control); padding: 0 var(--s3); border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--bg); width: 100%; }
.badge { display: inline-flex; align-items: center; height: 20px; padding: 0 var(--s2); border-radius: var(--r-sm); font-size: 12px; background: var(--panel); color: var(--muted); border: 1px solid var(--line); }
.badge.bad { color: var(--bad); border-color: currentColor; background: transparent; }
.badge.warn { color: var(--warn); border-color: currentColor; background: transparent; }
.badge.good { color: var(--good); border-color: currentColor; background: transparent; }
.zaehler { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); font-size: 12px; color: var(--muted); text-align: center; font-variant-numeric: tabular-nums; margin-left: var(--s2); vertical-align: 2px; }

/* Liste */
.abschnitt + .abschnitt { margin-top: var(--s8); }
.abschnitt h2 { margin-bottom: var(--s2); }
.liste { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.zeile { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--s4); min-height: var(--row); padding: var(--s2) var(--s2); border-bottom: 1px solid var(--line); transition: background var(--t-fast) ease-out; }
.zeile:hover { background: var(--primary-soft); }
.zeile > span:first-child { min-width: 0; }   /* sonst darf der Text die Spalte sprengen, Ellipsis greift nicht */
.zeile .titel { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.zeile .meta { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.zeile .rechts { display: flex; align-items: center; gap: var(--s3); font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.zeile .spaet { color: var(--bad); }
.zeile-aktionen { display: flex; gap: var(--s1); opacity: 0; transition: opacity var(--t-fast) ease-out; }
.zeile-aktionen form { margin: 0; }
.zeile:hover .zeile-aktionen, .zeile:focus-within .zeile-aktionen { opacity: 1; }
@media (hover: none) { .zeile-aktionen { opacity: 1; } }
.hinweis.good { border-color: var(--good); color: var(--good); }
.knopf.gefahr { color: var(--bad); }
.knopf.gefahr:hover { background: transparent; text-decoration: underline; }

/* Aufklapp-Menü ohne JavaScript: <details class="menue"> */
.menue { position: relative; }
.menue > summary { list-style: none; }
.menue > summary::-webkit-details-marker { display: none; }
.menue-inhalt { position: absolute; right: 0; top: calc(100% + 4px); z-index: 10; min-width: 260px; padding: var(--s3); display: flex; flex-direction: column; gap: var(--s3); background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow); text-align: left; font-variant-numeric: normal; white-space: normal; }
.menue-inhalt form { display: flex; flex-direction: column; gap: var(--s2); margin: 0; }
.menue-inhalt label { font-size: 13px; color: var(--muted); }
.menue[open] { z-index: 10; }
.zeile:has(.menue[open]) .zeile-aktionen { opacity: 1; }
.zeile:has(.menue[open]) { z-index: 10; position: relative; }
details.klapp summary { cursor: pointer; font-weight: 700; font-size: 16px; padding: var(--s2) 0; list-style: none; display: flex; align-items: center; }
details.klapp summary::-webkit-details-marker { display: none; }
details.klapp summary::before { content: ""; width: 6px; height: 6px; border-right: 1.75px solid var(--muted); border-bottom: 1.75px solid var(--muted); transform: rotate(-45deg); margin: 0 var(--s3) 0 var(--s1); transition: transform var(--t-fast) ease-out; }
details.klapp[open] summary::before { transform: rotate(45deg); }

/* Leerzustand und Meldungen */
.leer { padding: var(--s8) var(--s4); border: 1px dashed var(--line); border-radius: var(--r-md); text-align: center; color: var(--muted); max-width: 65ch; }
.leer b { display: block; color: var(--ink); margin-bottom: var(--s1); }
.leer .aktionen { justify-content: center; margin-top: var(--s4); }
.fehler { color: var(--bad); }

/* Meldungsseiten (Anmelden, Kein Zugang, Fehler): zentrierte schmale Karte */
.karte-seite { min-height: 100vh; display: grid; place-items: center; padding: var(--s6); background: var(--panel); }
.karte { width: 100%; max-width: 400px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s8); display: flex; flex-direction: column; gap: var(--s4); }
.karte .logo { padding: 0; }
.karte h1 { font-size: 20px; }
.karte p { color: var(--muted); }
.karte form { display: flex; flex-direction: column; gap: var(--s3); }
.karte .knopf { width: 100%; }
.hinweis { padding: var(--s3); border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--panel); color: var(--ink); }
.hinweis.bad { border-color: var(--bad); color: var(--bad); }
.haken { display: flex; gap: var(--s2); align-items: center; min-height: var(--control); }
fieldset { border: 0; margin: 0; padding: 0; }
legend { padding: 0; margin-bottom: var(--s1); }
label { display: block; }
.ms-logo { width: 16px; height: 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 1px; }
.ms-logo i { display: block; background: currentColor; }

/* Palette (Cmd+K): <dialog>, Inhalt kommt per HTMX aus /suche */
.palette { width: min(640px, calc(100vw - 32px)); margin: 10vh auto 0; padding: 0; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--bg); color: var(--ink); box-shadow: var(--shadow); }
.palette::backdrop { background: rgba(0, 0, 0, 0.3); }
.palette-kopf { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); margin: 0; }
.palette-kopf input { flex: 1; border: 0; background: transparent; font-size: 16px; padding: 0; outline: none; -webkit-appearance: none; appearance: none; }
.palette-kopf input::-webkit-search-cancel-button { display: none; }   /* das blaue X des Browsers wäre eine zweite Akzentfarbe */
.palette-kopf kbd, .palette-treffer kbd { font: 400 12px/1 Helvetica, Arial, sans-serif; color: var(--muted); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 3px 5px; white-space: nowrap; }
.palette-ergebnisse { max-height: 60vh; overflow-y: auto; padding: var(--s2); }
.palette-gruppe + .palette-gruppe { margin-top: var(--s2); }
.palette-titel { font-size: 12px; color: var(--muted); padding: var(--s2) var(--s2) var(--s1); }
.palette-treffer { display: flex; align-items: center; gap: var(--s3); min-height: 36px; padding: 0 var(--s2); border-radius: var(--r-sm); color: var(--ink); }
.palette-treffer:hover, .palette-treffer[aria-selected="true"] { background: var(--primary-soft); text-decoration: none; }
.palette-treffer .titel { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-treffer .meta { font-size: 13px; color: var(--muted); white-space: nowrap; }
.palette-leer { padding: var(--s4); color: var(--muted); text-align: center; }

/* Filterleiste: alles, was dort steht, steht auch in der URL */
.filterleiste { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; margin-bottom: var(--s4); }
.filterleiste .feld { width: auto; min-width: 140px; }
.filterleiste .feld[name="q"] { flex: 1 1 220px; }

/* Liste und Panel: Liste bleibt links (mindestens 320 px), Panel rechts 480 px, unter 1024 px wird das Panel zur Vollseite */
.geteilt { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s6); align-items: start; }
.geteilt.mit-panel { grid-template-columns: minmax(320px, 1fr) 480px; }
.panel { position: sticky; top: calc(var(--header) + var(--s4)); max-height: calc(100vh - var(--header) - var(--s8)); overflow-y: auto; border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s4); background: var(--bg); }
.panel-kopf { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s3); margin-bottom: var(--s3); }
.panel-meta { color: var(--muted); font-size: 13px; margin-bottom: var(--s3); }
.transkript { white-space: pre-wrap; max-width: 65ch; line-height: 1.6; }
a.zeile { color: inherit; }
a.zeile:hover { text-decoration: none; }
.zeile.aktiv { background: var(--primary-soft); }
@media (max-width: 1023px) {
  .geteilt.mit-panel { grid-template-columns: minmax(0, 1fr); }
  .geteilt.mit-panel .geteilt-liste { display: none; }
  .panel { position: static; max-height: none; }
}

/* Tabellen (für später, hier definiert, damit kein Modul eine zweite baut) */
table.tabelle { width: 100%; border-collapse: collapse; }
.tabelle th, .tabelle td { height: var(--row); padding: 0 var(--s3); border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.tabelle th { position: sticky; top: 0; background: var(--bg); font-weight: 400; color: var(--muted); font-size: 13px; }
.tabelle td.num, .tabelle th.num { text-align: right; font-variant-numeric: tabular-nums; }
.scroll-x { overflow-x: auto; }

/* Mobil: Sidebar wird zur unteren Leiste */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; grid-template-rows: var(--header) minmax(0, 1fr) auto; }
  .kopf { grid-template-columns: auto minmax(0, 1fr) auto; }
  .suche kbd { display: none; }
  main { grid-row: 2; padding: var(--s4) var(--s4) 72px; }   /* Platz für die untere Leiste */
  .seite { grid-row: 3; flex-direction: row; border-right: 0; border-top: 1px solid var(--line); padding: var(--s1) var(--s2); gap: 0; position: sticky; bottom: 0; }
  .seite .block-titel, .seite .fuss, .seite .nur-breit { display: none; }
  .nav { display: flex; flex: 1; justify-content: space-around; }
  .nav a { flex-direction: column; height: 48px; gap: 2px; font-size: 11px; padding: 0 var(--s1); min-width: 56px; }
  .nav a .zahl { display: none; }
  .ansicht-kopf { flex-direction: column; }
  .zeile { grid-template-columns: minmax(0, 1fr); }
  .zeile .rechts { font-size: 12px; }
}
