/* ─── Brand tokens (self-contained) ─────────────────────────────────────── */
/* TODO: duplicated brand tokens to be extracted into a shared stylesheet in the fast-follow */
:root {
  /* Brand-Teal */
  --brand-50:  #f0fdfa;
  --brand-100: #ccfbf1;
  --brand-300: #5eead4;
  --brand-500: #14b8a6;
  --brand-600: #0d9488;
  --brand-700: #0f766e;
  --brand-900: #134e4a;

  /* Neutral-Slate */
  --slate-50:  #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;

  /* Ampel — AA-compliant (≥4.5:1 contrast on their respective backgrounds) */
  /* green: #065f55 on #ecfdf5 = 7.18:1 ✓ */
  --ampel-green-fg:  #065f55;
  --ampel-green-bg:  #ecfdf5;
  --ampel-green-bd:  #a7f3d0;
  --ampel-yellow-fg: #b45309;
  --ampel-yellow-bg: #fffbeb;
  --ampel-yellow-bd: #fde68a;
  --ampel-red-fg:    #be123c;
  --ampel-red-bg:    #fff1f2;
  --ampel-red-bd:    #fecdd3;

  /* Layout */
  --sidebar-width: 320px;
  --header-height: 56px;
}

/* ─── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--slate-800);
  background: var(--slate-50);
}

/* ─── Focus visible ──────────────────────────────────────────────────────── */
:focus-visible {
  outline: 3px solid var(--brand-500);
  outline-offset: 2px;
}

/* ─── Layout ─────────────────────────────────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: auto 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ─── App bar ────────────────────────────────────────────────────────────── */
.app-bar {
  grid-column: 1 / -1;
  height: var(--header-height);
  background: var(--slate-900);
  color: white;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  z-index: 10;
}

.app-bar .logo {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--brand-300);
  text-decoration: none;
}

.app-bar .verfahren-name {
  font-size: 13px;
  color: var(--slate-400);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-bar .spacer { flex: 1; }

/* ─── Verfahren switcher ─────────────────────────────────────────────────── */
.verfahren-switcher-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.verfahren-switcher-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--slate-400);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.verfahren-switcher-select {
  background: var(--slate-800);
  border: 1px solid var(--slate-600);
  color: white;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  max-width: 200px;
}

.verfahren-switcher-select:hover {
  border-color: var(--brand-300);
}

.verfahren-switcher-select:focus-visible {
  outline: 3px solid var(--brand-500);
  outline-offset: 2px;
}

.btn-help {
  background: none;
  border: 1px solid var(--slate-600);
  color: var(--slate-400);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}
.btn-help:hover { border-color: var(--slate-400); color: white; }

.sidebar-toggle-btn {
  display: none;
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 6px;
  border-radius: 4px;
  font-size: 18px;
  line-height: 1;
}

/* ─── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar {
  background: var(--slate-50);
  border-right: 1px solid var(--slate-100);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.sidebar-head {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--slate-200);
  flex-shrink: 0;
}

.sidebar-head .verfahren-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--slate-800);
  margin-bottom: 8px;
  line-height: 1.3;
}

/* Progress bar */
.progress-wrap {
  margin-bottom: 2px;
}
.progress-label {
  font-size: 12px;
  color: var(--slate-600);
  margin-bottom: 4px;
}
.progress-bar-outer {
  height: 6px;
  background: var(--slate-200);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar-inner {
  height: 100%;
  background: var(--brand-500);
  border-radius: 999px;
  transition: width 0.3s ease;
  min-width: 0;
}

/* Filter chips */
.filter-chips {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  padding: 10px 16px 0;
  flex-shrink: 0;
}

.chip {
  border: 1px solid var(--slate-200);
  background: white;
  color: var(--slate-600);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}
.chip:hover {
  border-color: var(--brand-300);
  color: var(--brand-700);
}
.chip[aria-pressed="true"],
.chip.active {
  background: var(--brand-700);
  border-color: var(--brand-700);
  color: white;
}

/* Search */
.search-wrap {
  padding: 8px 16px;
  flex-shrink: 0;
}
.search-input {
  width: 100%;
  border: 1px solid var(--slate-200);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
  font-family: inherit;
  background: white;
  color: var(--slate-800);
}
.search-input:focus-visible {
  outline: 2px solid var(--brand-500);
  outline-offset: 0;
  border-color: var(--brand-500);
}
.search-input::placeholder { color: var(--slate-400); }

/* Entry list */
.entry-list {
  flex: 1;
  overflow-y: auto;
  list-style: none;
  padding: 4px 0;
}

/* Theme group */
.theme-group {
  margin-bottom: 2px;
}
.theme-toggle {
  width: 100%;
  background: none;
  border: none;
  padding: 6px 16px;
  text-align: left;
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--slate-600);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}
.theme-toggle:hover { color: var(--slate-800); }
.theme-toggle::after {
  content: '▾';
  margin-left: auto;
  font-size: 10px;
  transition: transform 0.2s;
}
.theme-toggle[aria-expanded="false"]::after {
  transform: rotate(-90deg);
}
.theme-entries {
  list-style: none;
}
.theme-entries.collapsed { display: none; }

/* Entry item */
.entry-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 16px;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background 0.1s;
}
.entry-item:hover { background: white; }
.entry-item[data-active="true"] {
  background: white;
  border-left-color: var(--brand-500);
}
.entry-item:focus-visible {
  outline: 2px solid var(--brand-500);
  outline-offset: -2px;
}

/* Status dot */
.status-dot {
  flex-shrink: 0;
  margin-top: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
}
.status-dot[data-status="offen"] {
  border: 2px solid var(--slate-300);
  background: white;
  color: var(--slate-600);
}
.status-dot[data-status="in_arbeit"] {
  border: 2px solid var(--ampel-yellow-fg);
  background: var(--ampel-yellow-bg);
  color: var(--ampel-yellow-fg);
}
.status-dot[data-status="abgewogen"] {
  border: 2px solid var(--ampel-green-fg);
  background: var(--ampel-green-bg);
  color: var(--ampel-green-fg);
}

.entry-meta {
  flex: 1;
  min-width: 0;
}
.entry-absender {
  font-size: 13px;
  font-weight: 600;
  color: var(--slate-800);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.entry-status-label {
  font-size: 11px;
  color: var(--slate-600);
  margin-top: 1px;
}
.entry-item[data-active="true"] .entry-absender { color: var(--brand-700); }

/* Sidebar footer */
.sidebar-foot {
  padding: 12px 16px;
  border-top: 1px solid var(--slate-200);
  flex-shrink: 0;
}
.btn-export {
  width: 100%;
  background: white;
  border: 1px solid var(--slate-200);
  color: var(--slate-700, var(--slate-800));
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: border-color 0.15s;
}
.btn-export:hover { border-color: var(--brand-300); color: var(--brand-700); }
.btn-beschlussvorlage {
  width: 100%;
  box-sizing: border-box;
  background: var(--brand-700);
  border: 1px solid var(--brand-700);
  color: white;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  margin-bottom: 8px;
  transition: background-color 0.15s;
}
.btn-beschlussvorlage:hover { background: var(--brand-900); border-color: var(--brand-900); }
.btn-beschlussvorlage:focus-visible { outline: 3px solid var(--brand-500); outline-offset: 2px; }
.pseudonym-note {
  margin: 8px 0 0;
  font-size: 11px;
  color: var(--slate-400); /* #94a3b8 on white = 3.0:1, meets WCAG AA for 11px/bold? use slate-600 for safety */
  color: var(--slate-600); /* #475569 on white = 4.73:1 ✓ WCAG AA */
  font-style: italic;
  line-height: 1.4;
}

/* ─── Detail pane ─────────────────────────────────────────────────────────── */
.detail-pane {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background: white;
}

.detail-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--slate-600);
  gap: 8px;
  font-size: 14px;
  padding: 32px;
  text-align: center;
}
.detail-empty .empty-icon { font-size: 40px; }

.detail-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Detail header */
.detail-header {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.detail-absender {
  font-size: 18px;
  font-weight: 700;
  color: var(--slate-900);
  line-height: 1.3;
}
.detail-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.detail-datum {
  font-size: 13px;
  color: var(--slate-600);
}
.detail-thema-chip {
  display: inline-block;
  background: var(--brand-50);
  border: 1px solid var(--brand-100);
  color: var(--brand-700);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 600;
}
.detail-cluster-chip {
  display: inline-block;
  background: #fef3c7; /* amber-100 */
  border: 1px solid #fcd34d;
  color: #92400e; /* amber-800 on amber-100 ✓ */
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 600;
}

/* §35a banner */
.s35a-banner {
  background: var(--ampel-yellow-bg);
  border: 1px solid var(--ampel-yellow-bd);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--ampel-yellow-fg);
  display: flex;
  gap: 6px;
  align-items: flex-start;
}
.s35a-banner .s35a-icon { flex-shrink: 0; margin-top: 1px; }

/* Section card */
.section-card {
  border-radius: 18px;
  padding: 18px 20px;
}
.section-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  margin-bottom: 10px;
  color: var(--slate-600);
}
.section-card.card-a {
  background: var(--slate-50);
  border: 1px solid var(--slate-100);
}
.section-card.card-b {
  background: var(--brand-50);
  border: 1px solid var(--brand-100);
}
.stellungnahme-text {
  font-size: 14.5px;
  line-height: 1.7;
  color: var(--slate-800);
  white-space: pre-wrap;
}
.ki-hint {
  font-size: 12px;
  color: var(--brand-700);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.abwaegung-textarea {
  width: 100%;
  border: 1px solid var(--brand-300);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14.5px;
  line-height: 1.7;
  font-family: inherit;
  color: var(--slate-800);
  background: white;
  resize: none;
  overflow: hidden;
  min-height: 80px;
  transition: border-color 0.15s;
}
.abwaegung-textarea:focus-visible {
  outline: 2px solid var(--brand-500);
  outline-offset: 0;
  border-color: var(--brand-500);
}
.abwaegung-textarea[readonly] {
  background: var(--slate-50);
  border-color: var(--slate-200);
  color: var(--slate-600);
  cursor: default;
}

/* Abgewogen state: show "bearbeiten" */
.abgewogen-bar {
  background: var(--ampel-green-bg);
  border: 1px solid var(--ampel-green-bd);
  border-radius: 10px;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: -8px;
}
.abgewogen-bar .abgewogen-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ampel-green-fg);
  display: flex;
  align-items: center;
  gap: 6px;
}
.btn-bearbeiten {
  background: none;
  border: 1px solid var(--ampel-green-fg);
  color: var(--ampel-green-fg);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.btn-bearbeiten:hover { background: var(--ampel-green-bg); }

/* Decision control */
.decision-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.decision-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--slate-700, var(--slate-800));
}
.decision-control {
  display: flex;
  gap: 0;
  border: 1px solid var(--slate-200);
  border-radius: 999px;
  overflow: hidden;
  width: fit-content;
}
.decision-btn {
  background: white;
  border: none;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  color: var(--slate-600);
  border-right: 1px solid var(--slate-200);
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.decision-btn:last-child { border-right: none; }
.decision-btn:hover { background: var(--slate-50); }
.decision-btn[aria-pressed="true"] {
  background: var(--brand-700);
  color: white;
}
.decision-btn:focus-visible {
  outline: 2px solid var(--brand-500);
  outline-offset: -2px;
  z-index: 1;
  position: relative;
}

/* Sticky actions */
.sticky-actions {
  border-top: 1px solid var(--slate-100);
  padding: 12px 28px;
  background: white;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.btn-primary {
  background: var(--brand-700);
  color: white;
  border: none;
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.btn-primary:hover { background: var(--brand-900); }
.btn-primary:disabled {
  background: var(--slate-200);
  color: var(--slate-400);
  cursor: not-allowed;
}
.btn-ghost {
  background: none;
  border: none;
  color: var(--slate-600);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 999px;
  transition: color 0.15s;
}
.btn-ghost:hover { color: var(--slate-800); background: var(--slate-50); }

.autosave-indicator {
  margin-left: auto;
  font-size: 12px;
  color: var(--slate-400);
  white-space: nowrap;
}
.autosave-indicator.saved { color: var(--ampel-green-fg); }

/* ─── Help modal ──────────────────────────────────────────────────────────── */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 100;
  align-items: center;
  justify-content: center;
}
.modal-backdrop.open { display: flex; }

.modal {
  background: white;
  border-radius: 18px;
  padding: 28px;
  max-width: 480px;
  width: calc(100% - 32px);
  max-height: 80vh;
  overflow-y: auto;
}
.modal-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--slate-800);
  margin-bottom: 16px;
}
.kbd-table { width: 100%; border-collapse: collapse; }
.kbd-table tr { border-bottom: 1px solid var(--slate-100); }
.kbd-table td { padding: 8px 0; font-size: 13px; }
.kbd-table td:first-child { width: 80px; }
kbd {
  background: var(--slate-100);
  border: 1px solid var(--slate-200);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  color: var(--slate-700);
}
.modal-close {
  display: block;
  margin-top: 16px;
  margin-left: auto;
  background: var(--slate-100);
  border: none;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.modal-close:hover { background: var(--slate-200); }
.modal-wide { max-width: 640px; }

/* ─── Prüfung (KI-Review) ─────────────────────────────────────────────────── */
.btn-pruefung {
  background: none;
  border: 1px solid var(--slate-600);
  color: var(--slate-400);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 8px;
}
.btn-pruefung:hover { border-color: var(--slate-400); color: white; }
.pruefung-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--slate-600);
  color: white;
  font-size: 11px;
  font-weight: 700;
}
.pruefung-badge.has-findings { background: #b45309; } /* amber-700 on white text ✓ */
.pruefung-intro { font-size: 13px; color: var(--slate-600); margin: 0 0 16px; }
.pruefung-list { display: flex; flex-direction: column; gap: 10px; }
.pruefung-empty { color: #166534; font-weight: 600; font-size: 14px; margin: 8px 0; }
.pruefung-finding {
  border: 1px solid var(--slate-200);
  border-left: 4px solid #b45309;
  border-radius: 8px;
  padding: 10px 12px;
}
.pruefung-finding[data-typ="leer"],
.pruefung-finding[data-typ="widerspruch"] { border-left-color: #be123c; }
.pruefung-finding[data-typ="build_hinweis"] { border-left-color: var(--brand-600); }
.pruefung-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--slate-600);
  margin-bottom: 4px;
}
.pruefung-text { margin: 0 0 8px; font-size: 13.5px; color: var(--slate-800); }
.pruefung-jump {
  background: var(--brand-700);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}
.pruefung-jump:hover { background: var(--brand-900); }
.pruefung-jump:focus-visible { outline: 3px solid var(--brand-500); outline-offset: 2px; }

/* ─── Empty list state ────────────────────────────────────────────────────── */
.list-empty-msg {
  padding: 24px 16px;
  font-size: 13px;
  color: var(--slate-400);
  text-align: center;
}

/* ─── Responsive <1024px ──────────────────────────────────────────────────── */
@media (max-width: 1023px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: var(--sidebar-width);
    max-width: calc(100vw - 40px);
    height: calc(100vh - var(--header-height));
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,0.12);
  }
  .sidebar.open {
    transform: translateX(0);
  }

  .detail-pane {
    height: calc(100vh - var(--header-height));
  }

  .detail-content {
    padding: 16px 20px;
  }

  .sticky-actions {
    padding: 10px 20px;
  }
}

/* ─── Utilities ───────────────────────────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

.hidden { display: none !important; }
