/*
 * Outreach-OS · Redaktionsschreibtisch
 * Warmes Papier, Tinte, ein Akzent (Zinnober) für "hier ist Arbeit".
 * Serif für Überschriften, Grotesk für Text, Mono für IDs und Metadaten.
 */
:root {
  --paper: #f4efe6;
  --paper-2: #ebe4d6;
  --card: #fbf8f2;
  --ink: #1d1a16;
  --ink-2: #4a443b;
  --ink-3: #8a8174;
  --rule: #d8cfbf;
  --accent: #d2461b;
  --accent-soft: #f6dccf;
  --ok: #2f6b3f;
  --ok-soft: #dcead9;
  --warn: #9a6a00;
  --warn-soft: #f3e6c4;
  --bad: #9b2c2c;
  --bad-soft: #f2d6d3;
  --blue: #2c4f7c;
  --blue-soft: #dbe3ee;
  --display: 'Instrument Serif', 'Iowan Old Style', Georgia, serif;
  --sans: 'Hanken Grotesk', 'Avenir Next', 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', 'SF Mono', Menlo, monospace;
  --radius: 3px;
  --shadow: 0 1px 0 rgba(29, 26, 22, 0.06), 0 8px 24px -16px rgba(29, 26, 22, 0.35);
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 110% -10%, rgba(210, 70, 27, 0.06), transparent 60%),
    repeating-linear-gradient(0deg, transparent 0 31px, rgba(29, 26, 22, 0.025) 31px 32px),
    var(--paper);
  color: var(--ink);
  font: 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration-color: var(--rule); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--accent); }

/* ---------- Gerüst ---------- */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  padding: 28px 18px; border-right: 1px solid var(--rule);
  background: linear-gradient(180deg, var(--paper-2), var(--paper));
  display: flex; flex-direction: column; gap: 22px;
}
.brand { font-family: var(--display); font-size: 28px; line-height: 1; letter-spacing: -0.01em; text-decoration: none; }
.brand em { color: var(--accent); font-style: italic; }
.brand small { display: block; font: 500 10px/1 var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); margin-top: 8px; }
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-group { font: 500 10px/1 var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); margin: 14px 10px 6px; }
.nav a {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 10px; border-radius: var(--radius); text-decoration: none; color: var(--ink-2);
  border-left: 2px solid transparent;
}
.nav a:hover { background: rgba(29, 26, 22, 0.05); color: var(--ink); }
.nav a.on { background: var(--card); color: var(--ink); border-left-color: var(--accent); box-shadow: var(--shadow); }
.count { font: 600 11px/1 var(--mono); padding: 3px 6px; border-radius: 99px; background: var(--paper-2); color: var(--ink-2); }
.count.hot { background: var(--accent); color: #fff; }
.side-foot { margin-top: auto; font: 11px/1.5 var(--mono); color: var(--ink-3); }

.main { padding: 36px clamp(20px, 4vw, 56px) 80px; max-width: 1180px; width: 100%; }
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 26px; flex-wrap: wrap; }
h1 { font: 400 44px/1.02 var(--display); letter-spacing: -0.015em; margin: 0; }
h1 em { color: var(--accent); }
h2 { font: 400 26px/1.1 var(--display); margin: 34px 0 12px; }
h3 { font: 600 13px/1.3 var(--sans); letter-spacing: 0.02em; margin: 0 0 8px; }
.kicker { font: 500 11px/1 var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 10px; }
.lede { color: var(--ink-2); max-width: 62ch; margin: 8px 0 0; }
.muted { color: var(--ink-3); }
.mono { font-family: var(--mono); font-size: 12px; }

/* ---------- Banner ---------- */
.banner { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 18px; border: 1px solid; font-size: 14px; }
.banner.err { background: var(--bad-soft); border-color: #e2b2ad; color: var(--bad); }
.banner.ok { background: var(--ok-soft); border-color: #b9d3b4; color: var(--ok); }
.banner.stop { background: var(--ink); border-color: var(--ink); color: var(--paper); display: flex; justify-content: space-between; align-items: center; }

/* ---------- Karten & Raster ---------- */
.card { background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.card + .card { margin-top: 14px; }
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, 1fr); gap: 22px; align-items: start; }
@media (max-width: 980px) {
  .split, .shell { grid-template-columns: 1fr; }
  .context { position: static; }
  /* Mobil: Navigation als schmale, horizontal scrollbare Leiste oben */
  .side {
    position: sticky; top: 0; z-index: 10; height: auto; padding: 12px 16px 0; gap: 8px;
    flex-direction: column; border-right: 0; border-bottom: 1px solid var(--rule); background: var(--paper-2);
  }
  .brand { font-size: 22px; } .brand small { display: none; }
  .nav { flex-direction: row; overflow-x: auto; gap: 4px; padding-bottom: 10px; scrollbar-width: none; }
  .nav-group, .side-foot { display: none; }
  .nav a { flex: 0 0 auto; gap: 6px; border-left: 0; border-bottom: 2px solid transparent; border-radius: 0; padding: 6px 8px; }
  .nav a.on { border-bottom-color: var(--accent); box-shadow: none; background: transparent; }
  .main { padding-top: 22px; }
  h1 { font-size: 34px; }
}

/* Arbeitsplatz: Aufgabenstapel */
.stack { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.pile {
  position: relative; display: block; text-decoration: none; padding: 18px 18px 16px;
  background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  animation: rise 0.45s ease both;
}
.pile:nth-child(2) { animation-delay: 0.04s; } .pile:nth-child(3) { animation-delay: 0.08s; }
.pile:nth-child(4) { animation-delay: 0.12s; } .pile:nth-child(5) { animation-delay: 0.16s; } .pile:nth-child(6) { animation-delay: 0.2s; }
.pile::before, .pile::after {
  content: ''; position: absolute; inset: 0; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--card); z-index: -1;
}
.pile::before { transform: translate(4px, 4px); }
.pile::after { transform: translate(8px, 8px); opacity: 0.6; }
.pile.empty::before, .pile.empty::after { display: none; }
.pile:hover { transform: translate(-2px, -2px); }
.pile .n { font: 400 52px/1 var(--display); }
.pile.hot .n { color: var(--accent); }
.pile .t { font-weight: 600; margin-top: 6px; }
.pile .d { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.stats { display: flex; gap: 28px; flex-wrap: wrap; }
.stat .v { font: 400 30px/1 var(--display); }
.stat .l { font: 500 10px/1.4 var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); }

/* ---------- Tabellen ---------- */
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font: 500 10px/1 var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); padding: 12px 14px; border-bottom: 1px solid var(--rule); background: var(--paper-2); white-space: nowrap; }
td { padding: 10px 14px; border-bottom: 1px solid #ece5d8; vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #f7f2e9; }
td .sub { font-size: 12px; color: var(--ink-3); }

/* ---------- Plaketten ---------- */
.tag { display: inline-flex; align-items: center; gap: 5px; font: 600 10.5px/1 var(--mono); letter-spacing: 0.04em; padding: 4px 7px; border-radius: 2px; background: var(--paper-2); color: var(--ink-2); white-space: nowrap; }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.blue { background: var(--blue-soft); color: var(--blue); }
.tag.hot { background: var(--accent-soft); color: var(--accent); }
.grade { display: inline-grid; place-items: center; width: 24px; height: 24px; font: 400 18px/1 var(--display); border: 1px solid var(--ink); border-radius: 50%; }
.grade.A { background: var(--ink); color: var(--paper); }
.grade.SKIP { width: auto; padding: 0 6px; border-radius: 12px; font: 600 9px/1 var(--mono); }

/* ---------- Formulare ---------- */
form { margin: 0; }
label { display: block; font: 600 12px/1.3 var(--sans); color: var(--ink-2); margin: 14px 0 6px; }
label .hint { font-weight: 400; color: var(--ink-3); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=search], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: #fffdf8; border: 1px solid var(--rule); border-radius: var(--radius); padding: 9px 11px;
}
textarea { min-height: 96px; resize: vertical; }
textarea.letter { min-height: 360px; field-sizing: content; font: 15px/1.65 var(--sans); padding: 18px 20px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row > * { flex: 1 1 160px; }
.row > :where(.tag, .grade, span, strong, a, button) { flex: 0 1 auto; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; align-items: center; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: 600 13.5px/1 var(--sans);
  padding: 10px 15px; border-radius: var(--radius); border: 1px solid var(--ink); background: var(--card); color: var(--ink);
  cursor: pointer; text-decoration: none; transition: background 0.12s, transform 0.05s;
}
.btn:hover { background: var(--paper-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--ink); color: var(--paper); }
.btn.primary:hover { background: #000; }
.btn.go { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.hot { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--bad); border-color: #d9a39d; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.small { padding: 6px 10px; font-size: 12.5px; }

/* Auswahl als große Schalter (Urteil, Grade) */
.choices { display: flex; gap: 8px; flex-wrap: wrap; }
.choice { position: relative; flex: 1 1 120px; }
.choice input { position: absolute; opacity: 0; inset: 0; }
.choice span {
  display: block; text-align: center; padding: 12px 10px; border: 1px solid var(--rule); border-radius: var(--radius);
  background: #fffdf8; cursor: pointer; font-weight: 600; transition: all 0.12s;
}
.choice span small { display: block; font-weight: 400; font-size: 11.5px; color: var(--ink-3); margin-top: 3px; }
.choice input:checked + span { border-color: var(--ink); background: var(--ink); color: var(--paper); }
.choice input:checked + span small { color: #cfc6b6; }
.choice input:focus-visible + span { outline: 2px solid var(--accent); }

/* Regeln als Checkliste */
.rules { display: flex; flex-direction: column; gap: 6px; max-height: 520px; overflow-y: auto; padding-right: 4px; }
.rule { display: grid; grid-template-columns: 18px 44px 1fr; gap: 8px; align-items: start; padding: 8px 10px; border: 1px solid transparent; border-radius: var(--radius); cursor: pointer; }
.rule:hover { background: #f6f0e6; }
.rule input { margin-top: 3px; accent-color: var(--accent); }
.rule:has(input:checked) { border-color: var(--accent-soft); background: #fbf1ea; }
.rule .code { font: 600 11px/1.6 var(--mono); color: var(--accent); }
.rule .title { font-weight: 600; font-size: 13px; line-height: 1.35; }
.rule .body { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; }
.rule.observe .code::after { content: ' ·beob.'; color: var(--ink-3); font-weight: 400; }

/* Brief / Mailvorschau */
.letter-card {
  background: #fffdf9; border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.letter-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); }
.letter-head { display: grid; grid-template-columns: 70px 1fr; gap: 4px 12px; padding: 14px 20px; border-bottom: 1px dashed var(--rule); font-size: 13px; }
.letter-head dt { font: 500 10px/1.9 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); }
.letter-head dd { margin: 0; }
.letter-body { padding: 18px 22px; white-space: pre-wrap; font-size: 15px; line-height: 1.65; }
.letter-card input.subject { border: 0; background: transparent; padding: 0; font-weight: 600; }
.letter-card textarea.letter { border: 0; border-radius: 0; background: transparent; }

/* Kontext-Seitenleiste */
.context { position: sticky; top: 20px; display: flex; flex-direction: column; gap: 14px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13.5px; margin: 0; }
.facts dt { color: var(--ink-3); font: 500 11px/1.7 var(--mono); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.prose { font-size: 14px; color: var(--ink-2); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 420px; overflow-y: auto; }
.prose.tall { max-height: none; }
details { border-top: 1px solid var(--rule); padding-top: 10px; margin-top: 10px; }
details summary { cursor: pointer; font-weight: 600; font-size: 13px; }
details[open] summary { margin-bottom: 8px; }

/* Zeitleiste */
.timeline { list-style: none; margin: 0; padding: 0 0 0 16px; border-left: 1px solid var(--rule); }
.timeline li { position: relative; padding: 0 0 14px 14px; }
.timeline li::before { content: ''; position: absolute; left: -21px; top: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--paper); border: 2px solid var(--ink-3); }
.timeline li.human::before { border-color: var(--accent); background: var(--accent); }
.timeline li.agent::before { border-color: var(--blue); }
.timeline .when { font: 11px/1.4 var(--mono); color: var(--ink-3); }
.timeline .what { font-weight: 600; font-size: 13.5px; }
.timeline .why { font-size: 13px; color: var(--ink-2); }

.empty-state { text-align: center; padding: 56px 20px; color: var(--ink-3); }
.empty-state .big { font: 400 36px/1.1 var(--display); color: var(--ink); margin-bottom: 8px; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: min(380px, 100%); padding: 32px; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filters input, .filters select { width: auto; flex: 0 1 220px; }
.inline-form { display: inline; }
hr { border: 0; border-top: 1px solid var(--rule); margin: 18px 0; }
