/* RhoMesh – Prüfstand Stufe 0.
   Gestaltungsidee: Laborjournal auf einem Steckbrett. Papier mit Lochraster, Stromschienen (rot/blau)
   als Kopfkante, Karten als Karteikarten mit Lochreihe. Serifen für Inhalt, Mono für Messwerte/IDs.
   CSP-tauglich: keine externen Fonts/Bilder, nur Systemschriften und CSS-Verläufe. */

:root {
  --paper: #f2eee4;
  --paper-2: #fbf9f4;
  --paper-3: #e9e3d5;
  --ink: #16140f;
  --graphite: #4a463c;
  --rule: #cbc3b1;
  --hole: #d3cbb9;
  --rho: #b0271b;
  --rho-soft: #f6dfd6;
  --rail-red: #c42b1e;
  --rail-blue: #1d4c9c;
  --ok: #0c6a4e;
  --ok-soft: #dcefe5;
  --warn-soft: #fbeccf;
  --focus: #1d4c9c;
  --shadow: #16140f;

  --f-display: "Sitka Display", "Sitka Heading", "Iowan Old Style", "Palatino Linotype", "URW Palladio L", P052, Palatino, "Book Antiqua", serif;
  --f-text: "Sitka Text", "Iowan Old Style", Charter, "Bitstream Charter", "Palatino Linotype", Palatino, serif;
  --f-mono: "Cascadia Mono", "JetBrains Mono", "SF Mono", "IBM Plex Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --grid: 18px;
  --radius: 3px;
  --measure: 72rem;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #12110e;
    --paper-2: #1b1915;
    --paper-3: #26231d;
    --ink: #eee8da;
    --graphite: #b9b09d;
    --rule: #3b372e;
    --hole: #2b2821;
    --rho: #ff8166;
    --rho-soft: #3a1d16;
    --rail-red: #e2503e;
    --rail-blue: #6f9cff;
    --ok: #6fd6ad;
    --ok-soft: #13302a;
    --warn-soft: #33290f;
    --focus: #8fb4ff;
    --shadow: #000000;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--paper);
  background-image: radial-gradient(circle at 2px 2px, var(--hole) 1.25px, transparent 1.6px);
  background-size: var(--grid) var(--grid);
  color: var(--ink);
  font-family: var(--f-text);
  font-size: 1.0625rem;
  line-height: 1.55;
  font-kerning: normal;
}

main { flex: 1; width: 100%; max-width: var(--measure); margin: 0 auto; padding: 1.5rem 1.5rem 4rem; }
main:focus { outline: none; }

/* ---------- Stromschiene ---------- */
.rail {
  height: 14px;
  background:
    linear-gradient(var(--rail-red), var(--rail-red)) top / 100% 2px no-repeat,
    linear-gradient(var(--rail-blue), var(--rail-blue)) bottom / 100% 2px no-repeat,
    radial-gradient(circle at 50% 50%, var(--graphite) 1.3px, transparent 1.7px) center / 9px 6px repeat-x,
    var(--paper-3);
  border-bottom: 1px solid var(--rule);
}

/* ---------- Kopf ---------- */
.masthead {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .75rem 1.75rem;
  max-width: var(--measure);
  margin: 0 auto;
  padding: 1rem 1.5rem;
  border-bottom: 1.5px solid var(--ink);
  width: 100%;
}
.masthead-auth { border-bottom: 0; justify-content: center; padding-top: 2.5rem; }

.brand { display: inline-flex; align-items: baseline; gap: .35rem; color: var(--ink); text-decoration: none; }
.brand-rho { font-family: var(--f-display); font-style: italic; font-weight: 700; color: var(--rho); font-size: 1.9rem; line-height: 1; }
.brand-name { font-family: var(--f-display); font-weight: 700; font-size: 1.45rem; letter-spacing: -.01em; }
.stage {
  font-family: var(--f-mono); font-size: .72rem; letter-spacing: .14em; text-transform: uppercase;
  color: var(--graphite); border: 1px solid var(--rule); padding: .15rem .5rem; border-radius: 999px; background: var(--paper-2);
}

.mainnav ul { list-style: none; display: flex; gap: 1.25rem; margin: 0; padding: 0; }
.mainnav a {
  font-family: var(--f-mono); font-size: .82rem; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink); text-decoration: none; padding: .3rem 0; border-bottom: 2px solid transparent;
}
.mainnav a:hover { border-bottom-color: var(--rule); }
.mainnav a[aria-current="page"] { border-bottom-color: var(--rho); }

.who { margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; font-size: .92rem; }
.who-label { color: var(--graphite); font-size: .8rem; }
.who-name { font-family: var(--f-mono); font-size: .86rem; overflow-wrap: anywhere; }
.logout { margin: 0; }

/* ---------- Typografie ---------- */
h1, h2, h3 { font-family: var(--f-display); line-height: 1.12; letter-spacing: -.015em; margin: 0; overflow-wrap: anywhere; }
h1 { font-size: clamp(2.1rem, 1.4rem + 2.6vw, 3.4rem); font-weight: 600; }
h2 { font-size: 1.45rem; font-weight: 600; }
h3 { font-size: 1.2rem; font-weight: 600; }
p { margin: 0; }
a { color: var(--ink); text-decoration-color: var(--rho); text-decoration-thickness: 1.5px; text-underline-offset: .18em; }
a:hover { color: var(--rho); }
code, .id { font-family: var(--f-mono); font-size: .86em; overflow-wrap: anywhere; }

.eyebrow {
  font-family: var(--f-mono); font-size: .74rem; letter-spacing: .16em; text-transform: uppercase; color: var(--rho);
  margin-bottom: .5rem;
}
.lede { font-size: 1.12rem; color: var(--graphite); max-width: 44rem; margin-top: .75rem; }
.meta { margin-top: .75rem; font-size: .95rem; color: var(--graphite); }
.muted { color: var(--graphite); }
.fine { font-size: .86rem; color: var(--graphite); margin-top: 1.25rem; }
.sr-only { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

.skip {
  position: absolute; left: 1rem; top: -4rem; z-index: 10; background: var(--ink); color: var(--paper);
  padding: .6rem 1rem; font-family: var(--f-mono); font-size: .85rem; text-decoration: none;
}
.skip:focus { top: 1rem; }

/* ---------- Fokus (immer sichtbar, hoher Kontrast) ---------- */
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
input:focus-visible, textarea:focus-visible { outline-offset: 0; }

/* ---------- Abschnitte ---------- */
.intro, .project-head { padding: 2rem 0 1.75rem; border-bottom: 1px solid var(--rule); margin-bottom: 2rem; }
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: .4rem; margin: 0 0 .25rem; padding: 0; font-family: var(--f-mono); font-size: .8rem; color: var(--graphite); }
.crumbs li + li::before { content: "/"; margin-right: .4rem; color: var(--rule); }
.crumbs a { color: var(--graphite); }
.crumbs [aria-current] { color: var(--ink); overflow-wrap: anywhere; }

.facts { display: flex; flex-wrap: wrap; gap: .75rem 2rem; margin: 1.25rem 0 0; }
.facts > div { min-width: 0; }
.facts dt { font-family: var(--f-mono); font-size: .7rem; letter-spacing: .14em; text-transform: uppercase; color: var(--graphite); }
.facts dd { margin: .2rem 0 0; }
.idline { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .5rem; }

.badge, .tag, .ver {
  display: inline-block; font-family: var(--f-mono); font-size: .74rem; letter-spacing: .04em; line-height: 1.2;
  padding: .2rem .5rem; border: 1.5px solid currentColor; border-radius: 999px; white-space: nowrap; vertical-align: middle;
}
.badge-on { color: var(--ok); background: var(--ok-soft); }
.badge-off { color: var(--graphite); background: var(--paper-2); }
.badge-locked { color: var(--rho); background: var(--rho-soft); }
.tag-admin { color: var(--rail-blue); }
.tag-warn { color: var(--rho); background: var(--rho-soft); }
.ver { color: var(--ink); background: var(--paper-2); border-radius: var(--radius); }

/* ---------- Projektliste ---------- */
.projects { list-style: none; margin: 0; padding: 0; display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr)); }
.project {
  position: relative; background: var(--paper-2); border: 1.5px solid var(--ink); border-radius: var(--radius);
  padding: 1.25rem 1.25rem 1.25rem 2.25rem; box-shadow: 5px 5px 0 var(--shadow);
  animation: rise .45s cubic-bezier(.2, .7, .2, 1) both;
}
.project h2 a { text-decoration: none; }
.project h2 a:hover { text-decoration: underline; text-decoration-color: var(--rho); }
.project .facts { margin-top: 1rem; }

/* Lochreihe am linken Rand von Projekt- und Kartenkarten */
.project::before, .card > article::before {
  content: ""; position: absolute; left: .7rem; top: 1rem; bottom: 1rem; width: 6px;
  background: radial-gradient(circle at 50% 50%, var(--hole) 2px, transparent 2.6px) top / 6px 14px repeat-y;
}

/* ---------- Arbeitsfläche ---------- */
.workbench { display: grid; gap: 2.5rem; grid-template-columns: 1fr; align-items: start; }
@media (min-width: 64rem) {
  .workbench { grid-template-columns: minmax(19rem, 25rem) minmax(0, 1fr); }
  .composer { position: sticky; top: 1rem; }
}
.composer, .editor-wrap {
  background: var(--paper-2); border: 1.5px solid var(--ink); border-radius: var(--radius); padding: 1.25rem;
  box-shadow: 5px 5px 0 var(--rho);
}
.composer h2, .deck > h2 { margin-bottom: 1rem; display: flex; align-items: center; gap: .6rem; }
.deck > h2::after { content: ""; flex: 1; height: 1.5px; background: var(--ink); }

/* ---------- Formulare ---------- */
.stack { display: grid; gap: 1.1rem; }
.field { display: grid; gap: .35rem; }
label, legend { font-weight: 600; font-size: .98rem; }
.label-aside { font-weight: 400; font-size: .82rem; color: var(--graphite); margin-left: .35rem; }
input[type="text"], input[type="password"], textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--paper);
  border: 1.5px solid var(--ink); border-radius: var(--radius); padding: .6rem .7rem;
}
textarea { font-family: var(--f-mono); font-size: .9rem; line-height: 1.5; resize: vertical; min-height: 12rem; tab-size: 2; }
.field.has-error input, .field.has-error textarea { border-color: var(--rho); box-shadow: inset 4px 0 0 var(--rho); }
.hint { font-size: .85rem; color: var(--graphite); }
.field-error { font-size: .88rem; color: var(--rho); font-weight: 600; }
fieldset { border: 1.5px solid var(--rule); border-radius: var(--radius); padding: 1rem 1.1rem 1.1rem; margin: 0; min-width: 0; }
legend { padding: 0 .4rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; cursor: pointer;
  font-family: var(--f-mono); font-size: .82rem; letter-spacing: .08em; text-transform: uppercase; text-decoration: none;
  padding: .7rem 1.1rem; border-radius: var(--radius); border: 1.5px solid var(--ink); line-height: 1.1;
  transition: transform .12s ease, box-shadow .12s ease, background-color .12s ease;
}
.btn-primary { background: var(--ink); color: var(--paper); box-shadow: 3px 3px 0 var(--rho); }
.btn-primary:hover { color: var(--paper); transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--rho); }
.btn-primary:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--rho); }
.btn-secondary { background: var(--paper-2); color: var(--ink); box-shadow: 3px 3px 0 var(--shadow); }
.btn-secondary:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--shadow); color: var(--ink); }
.btn-ghost { background: transparent; color: var(--ink); border-color: transparent; text-decoration: underline; text-decoration-color: var(--rho); text-underline-offset: .25em; padding-inline: .4rem; }
.btn-ghost:hover { border-color: var(--rule); }
.btn-quiet { background: transparent; color: var(--ink); border-color: var(--rule); padding: .4rem .7rem; font-size: .74rem; }
.btn-quiet:hover { border-color: var(--ink); }
.btn-tiny { background: var(--paper); color: var(--ink); border-color: var(--rule); padding: .2rem .5rem; font-size: .68rem; }
.btn-tiny:hover { border-color: var(--ink); }
.btn-block { width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: .75rem; justify-content: flex-end; align-items: center; }

/* ---------- Karten ---------- */
.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 1.5rem; }
.card { animation: rise .45s cubic-bezier(.2, .7, .2, 1) both; }
.card > article {
  position: relative; background: var(--paper-2); border: 1.5px solid var(--ink); border-radius: var(--radius);
  padding: 1.1rem 1.25rem 1rem 2.25rem; box-shadow: 5px 5px 0 var(--shadow);
}
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.card-body, .pane-body, .doc {
  margin: .85rem 0 0; font-family: var(--f-mono); font-size: .88rem; line-height: 1.55;
  white-space: pre-wrap; overflow-wrap: anywhere; tab-size: 2;
  max-height: 22rem; overflow: auto; background: var(--paper); border: 1px dashed var(--rule); border-radius: var(--radius); padding: .75rem .85rem;
}
.card-empty { margin-top: .75rem; color: var(--graphite); font-style: italic; }
/* Herkunft: wer hat die Karte angelegt/zuletzt geändert, über welchen Weg. KI dezent in Blau abgesetzt. */
.prov-block { margin-top: .75rem; display: grid; gap: .2rem; }
.prov { margin: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: .15rem .45rem; font-size: .84rem; color: var(--graphite); }
.prov-by { font-family: var(--f-mono); font-size: .86em; font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.via { display: inline-block; font-family: var(--f-mono); font-size: .76rem; line-height: 1.3; padding: .05rem .45rem; border: 1px solid var(--rule); border-radius: 999px; background: var(--paper-2); overflow-wrap: anywhere; }
.via-web { color: var(--graphite); }
.via-ai { color: var(--rail-blue); border-color: var(--rail-blue); background: transparent; }
.via-unverified { border-style: dashed; }
.via-host { font-weight: 700; }
.card-foot { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin-top: .9rem; font-size: .82rem; color: var(--graphite); }
.card-foot .btn { margin-left: auto; }
.id-small { font-size: .74rem; color: var(--graphite); }

.pager { display: flex; justify-content: space-between; gap: 1rem; margin-top: 2rem; }
.pager .btn-secondary { margin-left: auto; }
.empty, .note {
  padding: 1.25rem; border: 1.5px dashed var(--rule); border-radius: var(--radius); color: var(--graphite); background: var(--paper-2);
}

/* ---------- Meldungen ---------- */
.flash { border: 1.5px solid var(--ink); border-left-width: 8px; border-radius: var(--radius); padding: .85rem 1rem; margin-bottom: 1.5rem; background: var(--paper-2); }
.flash-ok { border-color: var(--ok); background: var(--ok-soft); }
.flash-error, .flash-conflict { border-color: var(--rho); background: var(--rho-soft); }
.flash h2 { font-size: 1.2rem; margin-bottom: .35rem; }

/* ---------- Konflikt ---------- */
.conflict { margin-bottom: 2rem; }
.diff { display: grid; gap: 1.25rem; grid-template-columns: 1fr; }
@media (min-width: 56rem) { .diff { grid-template-columns: 1fr 1fr; } }
.pane { background: var(--paper-2); border: 1.5px solid var(--ink); border-radius: var(--radius); padding: 1rem 1.1rem; min-width: 0; }
.pane-server { box-shadow: inset 0 6px 0 var(--rail-blue); }
.pane-mine { box-shadow: inset 0 6px 0 var(--rho); }
.pane h3 { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-top: .35rem; }
.pane-meta { font-size: .82rem; color: var(--graphite); margin-top: .25rem; }
.pane-title { margin-top: .75rem; font-family: var(--f-display); font-size: 1.15rem; font-weight: 600; overflow-wrap: anywhere; }
.conflict-out { margin-top: 1rem; }

/* ---------- Anleitung ---------- */
.doc { max-height: none; font-size: .92rem; padding: 1.25rem 1.5rem; background: var(--paper-2); border: 1.5px solid var(--ink); border-style: solid; box-shadow: 5px 5px 0 var(--shadow); }

/* ---------- Fehler ---------- */
.fault { padding: 3rem 0; max-width: 40rem; display: grid; gap: 1rem; }
.fault-code { font-family: var(--f-display); font-style: italic; font-size: clamp(5rem, 3rem + 10vw, 9rem); line-height: .9; color: var(--rho); letter-spacing: -.04em; }

/* ---------- Anmeldung und Zustimmung ---------- */
.v-auth main { display: flex; justify-content: center; padding-top: 1rem; }
.v-auth::after {
  content: "ρ"; position: fixed; right: -2vw; bottom: -12vw; z-index: -1; pointer-events: none;
  font-family: var(--f-display); font-style: italic; font-weight: 700; font-size: 46vw; line-height: 1; color: var(--rho); opacity: .07;
}
.auth-card, .consent {
  width: 100%; max-width: 28rem; background: var(--paper-2); border: 1.5px solid var(--ink); border-radius: var(--radius);
  padding: 2rem 1.75rem; box-shadow: 6px 6px 0 var(--shadow); display: grid; gap: 1.1rem; align-content: start;
  animation: rise .5s cubic-bezier(.2, .7, .2, 1) both;
}
.consent { max-width: 40rem; }
.consent h1 { font-size: clamp(1.7rem, 1.3rem + 1.6vw, 2.4rem); }
.client-name { overflow-wrap: anywhere; }
h1 .client-name { color: var(--rho); }
.caution { border: 2px solid var(--rho); border-radius: var(--radius); padding: .85rem 1rem; background: var(--rho-soft); }
.ledger { margin: 0; display: grid; border-top: 1px solid var(--rule); }
.ledger > div { display: grid; grid-template-columns: 10rem minmax(0, 1fr); gap: .25rem 1rem; padding: .6rem 0; border-bottom: 1px solid var(--rule); }
@media (max-width: 34rem) { .ledger > div { grid-template-columns: 1fr; } }
.ledger dt { font-family: var(--f-mono); font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--graphite); padding-top: .2rem; }
.ledger dd { margin: 0; overflow-wrap: anywhere; }
.scopes, .checks { list-style: none; margin: .5rem 0 0; padding: 0; display: grid; gap: .6rem; }
.scopes li { display: grid; gap: .15rem; }
.scope { color: var(--rho); font-weight: 600; }
.checks li { display: flex; align-items: flex-start; gap: .6rem; padding: .55rem .7rem; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--paper); }
.checks input { width: 1.15rem; height: 1.15rem; margin-top: .2rem; accent-color: var(--rho); flex: none; }
.checks label { font-weight: 400; overflow-wrap: anywhere; }
.check-title { font-weight: 600; }
.check-role { font-family: var(--f-mono); font-size: .74rem; color: var(--graphite); }
.transfer {
  border: 2px solid var(--ink); border-radius: var(--radius); padding: 1rem 1.1rem;
  background: repeating-linear-gradient(-45deg, var(--warn-soft) 0 12px, var(--paper-2) 12px 24px);
}
.transfer-head { font-family: var(--f-display); font-size: 1.2rem; font-weight: 700; margin-bottom: .35rem; }

/* ---------- Fuß ---------- */
.colophon {
  max-width: var(--measure); width: 100%; margin: 0 auto; padding: 1.25rem 1.5rem 2rem;
  border-top: 1px solid var(--rule); font-size: .82rem; color: var(--graphite);
}
.colophon .brand-rho { font-size: 1rem; }

/* ---------- Bewegung ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.cards > li:nth-child(2), .projects > li:nth-child(2) { animation-delay: 50ms; }
.cards > li:nth-child(3), .projects > li:nth-child(3) { animation-delay: 100ms; }
.cards > li:nth-child(4), .projects > li:nth-child(4) { animation-delay: 150ms; }
.cards > li:nth-child(5), .projects > li:nth-child(5) { animation-delay: 200ms; }
.cards > li:nth-child(n+6), .projects > li:nth-child(n+6) { animation-delay: 250ms; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Hoher Kontrast (Windows) ---------- */
@media (forced-colors: active) {
  .btn, .badge, .tag, .ver, .via, .project, .card > article, .composer, .editor-wrap, .pane { border-color: CanvasText; }
  .project::before, .card > article::before, .rail { forced-color-adjust: auto; }
}

@media print {
  .rail, .masthead nav, .who, .composer, .btn, .colophon { display: none !important; }
  body { background: none; }
  .card > article, .project { box-shadow: none; }
}
