* { box-sizing: border-box; }

:root {
  color-scheme: light;
  --bg: oklch(96.8% 0.006 205);
  --surface: oklch(99% 0.004 205);
  --panel: oklch(94.4% 0.012 205);
  --line: oklch(84.5% 0.012 205);
  --ink: oklch(21% 0.018 220);
  --muted: oklch(47% 0.02 220);
  --accent: oklch(44% 0.095 178);
  --accent-ink: oklch(99% 0.004 205);
  --accent-soft: oklch(93.5% 0.035 178);
  --ok: oklch(42% 0.09 155);
  --ok-soft: oklch(94% 0.04 155);
  --warn: oklch(44% 0.11 55);
  --warn-soft: oklch(95% 0.045 75);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

/* ── Topbar ── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  min-height: 54px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in oklch, var(--surface) 94%, transparent);
  backdrop-filter: blur(12px);
}

.nav {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.nav .brand {
  color: var(--ink);
  font-size: 16px;
  font-weight: 900;
  text-decoration: none;
}

.brand-sub {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.topbar-side {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar-link {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 11px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-decoration: none;
}

.topbar-link:hover {
  background: var(--panel);
  color: var(--ink);
}

.topbar-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.export-group {
  display: flex;
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--line);
}

.export-group button {
  min-height: 32px;
  border: 0;
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
  font-weight: 750;
}

.export-group button:hover {
  background: var(--panel);
}

.identity {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.topbar-toggle {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 11px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.topbar-toggle:hover {
  background: var(--panel);
  color: var(--ink);
  filter: none;
}

.topbar-toggle.is-active {
  border-color: color-mix(in oklch, var(--accent) 45%, var(--line));
  background: var(--accent-soft);
  color: var(--accent);
}

/* ── Shell + Masthead ── */

.shell {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 18px;
  display: grid;
  gap: 14px;
}

.masthead {
  display: grid;
  gap: 16px;
  align-items: end;
}

h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 850;
  letter-spacing: 0;
}

.lede {
  max-width: 62ch;
  margin: 6px 0 0;
  color: var(--muted);
}

.masthead-side {
  display: grid;
  gap: 8px;
  justify-items: start;
}

.funnel {
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.funnel-chip {
  min-height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 0;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 750;
  transition: background 150ms ease-out, color 150ms ease-out;
}

.funnel-chip strong {
  margin-left: 4px;
  font-weight: 900;
}

.funnel-chip:hover {
  background: var(--panel);
  color: var(--ink);
}

.funnel-chip.is-active {
  background: var(--accent);
  color: var(--accent-ink);
}

.pool-meta {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

/* ── View Tabs ── */

.view-tabs {
  display: flex;
  width: fit-content;
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.view-tab {
  min-height: 34px;
  border: 0;
  border-radius: 0;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
}

.view-tab:hover {
  background: var(--panel);
  color: var(--ink);
  filter: none;
}

.view-tab.is-active {
  background: var(--accent);
  color: var(--accent-ink);
}

/* ── Controls ── */

.controls {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

select,
input {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 9px;
  background: oklch(99.5% 0.004 205);
  color: var(--ink);
  font: inherit;
}

select:focus-visible,
input:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

button {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  padding: 0 13px;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  font: inherit;
  font-weight: 850;
  transition: filter 150ms ease-out;
}

button:hover {
  filter: brightness(1.08);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  filter: none;
}

button.secondary {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
}

button.secondary:hover {
  color: var(--ink);
  filter: none;
}

.statusline {
  min-height: 22px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.auth {
  display: grid;
  grid-template-columns: minmax(180px, 320px) auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.is-hidden {
  display: none !important;
}

/* ── Set-Karten ── */

.sets {
  display: grid;
  gap: 12px;
}

.set-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  transition: border-color 150ms ease-out;
}

.set-card.is-final {
  border: 1.5px solid var(--accent);
  background: color-mix(in oklch, var(--surface) 92%, var(--accent-soft));
}

.set-card.is-excluded {
  opacity: 0.62;
}

.set-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
}

.kicker {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.set-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 850;
  line-height: 1.25;
}

.selection-explainer {
  display: grid;
  gap: 6px;
  max-width: 92ch;
  margin-top: 8px;
}

.selection-summary {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.selection-explainer details {
  max-width: 92ch;
}

.selection-explainer summary {
  width: fit-content;
  cursor: pointer;
  color: var(--accent);
  font-size: 12px;
  font-weight: 850;
}

.selection-explainer summary:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.selection-grid {
  display: grid;
  gap: 8px;
  margin-top: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in oklch, var(--panel) 54%, var(--surface));
}

.selection-grid span {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.selection-grid p {
  margin: 0;
  color: var(--ink);
  font-size: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 0 9px;
  border-radius: 6px;
  background: var(--panel);
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  white-space: nowrap;
}

.pill-final {
  background: var(--accent);
  color: var(--accent-ink);
}

.collapsed-hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

/* ── Event-Rows ── */

.rows {
  display: grid;
  gap: 0;
}

.event-row {
  display: grid;
  grid-template-columns: 34px 64px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.event-row.is-hook {
  grid-template-columns: minmax(140px, 200px) minmax(0, 1fr);
  gap: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}

.index {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: var(--panel);
  color: var(--muted);
  font-weight: 900;
}

.thumb {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  background: var(--panel);
}

.thumb-sm {
  width: 64px;
  aspect-ratio: 1;
}

.thumb-lg {
  width: 100%;
  aspect-ratio: 4 / 3;
}

.event-row.is-hook .thumb {
  background: var(--surface);
}

.thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb.is-broken img {
  display: none;
}

.thumb.is-broken::after {
  content: "Kein Bild";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.thumb-sm.is-broken::after {
  content: "–";
  font-size: 16px;
}

.event-body {
  min-width: 0;
}

.event-row h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 750;
  line-height: 1.3;
}

.event-row.is-hook h3 {
  font-size: 17px;
}

.event-row h3 a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: color-mix(in oklch, var(--accent) 40%, transparent);
  text-underline-offset: 2px;
}

.event-row h3 a:hover {
  text-decoration-color: var(--accent);
}

.role-tag {
  display: inline-block;
  margin-right: 2px;
  padding: 1px 7px;
  border-radius: 5px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  vertical-align: 2px;
}

.event-meta {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.why {
  margin: 8px 0 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}

.desc {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  max-width: 72ch;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.item-reason {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
}

/* ── Badges ── */

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 800;
}

.badge-ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.badge-warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.badge-neutral {
  background: var(--panel);
  color: var(--muted);
}

.source-link {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.source-link:hover {
  color: var(--accent);
}

/* ── Set-Aktionen ── */

.set-actions {
  display: grid;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.empty {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface);
}

/* ── Monatsbestand ── */

.event-browser {
  display: grid;
  gap: 12px;
}

.event-browser.is-hidden {
  display: none;
}

.event-list {
  display: grid;
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.event-toolbar {
  display: grid;
  grid-template-columns: auto minmax(260px, 1fr) auto auto auto auto;
  gap: 8px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.compact-control {
  min-width: 142px;
}

.compact-control select {
  min-height: 34px;
}

.event-search {
  position: relative;
  display: block;
  min-width: 260px;
}

.event-search span {
  position: absolute;
  left: 11px;
  bottom: 7px;
  color: var(--muted);
  font-size: 16px;
  font-weight: 900;
  line-height: 1;
  pointer-events: none;
}

.event-search input {
  min-height: 34px;
  padding-left: 34px;
  font-weight: 650;
}

.quick-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: end;
}

.quick-filter,
.filter-toggle {
  min-height: 34px;
  white-space: nowrap;
}

.quick-filter {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
}

.quick-filter:hover {
  background: var(--surface);
  color: var(--ink);
  filter: none;
}

.quick-filter.is-active {
  border-color: color-mix(in oklch, var(--accent) 45%, var(--line));
  background: var(--accent-soft);
  color: var(--accent);
}

.event-filter-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)) auto;
  gap: 10px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in oklch, var(--panel) 50%, var(--surface));
}

.event-filter-panel button {
  min-height: 36px;
}

.pagination {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  align-items: center;
}

.pagination span {
  min-width: 190px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.pagination button {
  min-height: 32px;
}

.pool-row {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
}

.pool-row:first-child {
  border-top: 0;
}

.pool-row.is-highlight {
  background: color-mix(in oklch, var(--ok-soft) 42%, var(--surface));
}

.pool-row h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.25;
}

.pool-row h3 a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: color-mix(in oklch, var(--accent) 40%, transparent);
  text-underline-offset: 2px;
}

.event-subline {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.pool-actions {
  display: flex;
  gap: 7px;
  align-items: start;
  justify-content: flex-end;
}

.pool-actions button {
  min-height: 32px;
  white-space: nowrap;
}

/* ── Statistik ── */

.stats-view {
  display: grid;
  gap: 12px;
}

.stats-toolbar {
  display: flex;
  gap: 8px;
  align-items: end;
  width: fit-content;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.stats-dashboard {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}

.stats-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.stats-wide {
  grid-column: 1 / -1;
}

.stats-panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.stats-panel-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 850;
}

.stats-panel-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  text-align: right;
}

.metric-strip,
.curation-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.metric {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: color-mix(in oklch, var(--panel) 42%, var(--surface));
}

.metric span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.metric strong {
  color: var(--ink);
  font-size: 19px;
  font-weight: 850;
  line-height: 1.15;
}

.metric small {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-summary {
  display: grid;
  grid-template-columns: minmax(120px, 0.32fr) minmax(0, 1fr);
  gap: 10px;
}

.bar-list,
.bucket-list,
.source-quality,
.todo-list {
  display: grid;
  gap: 8px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(96px, 0.6fr) minmax(120px, 1fr) minmax(38px, auto);
  gap: 8px;
  align-items: center;
  min-height: 26px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.bar-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-row strong {
  color: var(--ink);
  text-align: right;
}

.bar-track {
  overflow: hidden;
  height: 8px;
  border-radius: 999px;
  background: var(--panel);
}

.bar-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.source-row {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) repeat(3, minmax(80px, auto));
  gap: 10px;
  align-items: center;
  min-height: 34px;
  padding: 7px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.source-row:first-child {
  border-top: 0;
}

.source-row strong {
  overflow: hidden;
  color: var(--ink);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.todo-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  text-align: left;
}

.todo-row:hover {
  background: var(--surface);
  filter: none;
}

.todo-row strong {
  color: var(--accent);
}

/* ── Edit-Modus ── */

.set-card.is-editing {
  border-color: var(--accent);
  border-style: dashed;
}

.pill-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.pill-locked {
  background: var(--warn-soft);
  color: var(--warn);
}

.sibling-hint {
  max-width: 72ch;
  margin: 8px 0 0;
  padding: 8px 10px;
  border: 1px solid var(--warn-soft);
  border-radius: 6px;
  background: color-mix(in oklch, var(--warn-soft) 55%, var(--surface));
  color: var(--warn);
  font-size: 12px;
  font-weight: 650;
}

.event-row.has-edit {
  grid-template-columns: 34px 64px minmax(0, 1fr) auto;
}

.event-row.is-hook.has-edit {
  grid-template-columns: minmax(140px, 200px) minmax(0, 1fr) auto;
}

.item-edit {
  display: flex;
  gap: 6px;
  align-items: start;
  padding-top: 2px;
}

.icon-btn {
  min-height: 30px;
  min-width: 30px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.icon-btn:hover {
  color: var(--ink);
  background: var(--panel);
  filter: none;
}

.icon-btn.is-danger:hover {
  border-color: var(--warn);
  color: var(--warn);
  background: var(--warn-soft);
}

.edit-hint {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

/* ── Detail-Aufklappen + Debug-Sicht ── */

/* Chevron in der Badge-Zeile — das einzige neue sichtbare Element der Liste. */
.detail-toggle {
  display: inline-grid;
  place-items: center;
  min-height: 26px;
  min-width: 30px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
}

.detail-toggle:hover {
  background: var(--panel);
  color: var(--ink);
  filter: none;
}

.detail-toggle .chev {
  font-size: 15px;
  font-weight: 900;
  line-height: 1;
  transition: transform 150ms ease-out;
}

.detail-toggle.is-open .chev {
  transform: rotate(90deg);
}

.event-details {
  display: grid;
  gap: 10px;
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in oklch, var(--panel) 45%, var(--surface));
}

/* display: grid würde das hidden-Attribut sonst überstimmen. */
.event-details[hidden] {
  display: none;
}

.detail-media {
  overflow: hidden;
  width: 100%;
  max-width: 420px;
  margin: 0;
  border-radius: 8px;
  background: var(--panel);
}

.detail-media img {
  display: block;
  width: 100%;
  height: auto;
}

.detail-media.is-broken {
  display: none;
}

.detail-desc {
  max-width: 78ch;
  margin: 0;
  color: var(--ink);
  font-size: 13px;
}

.detail-facts {
  display: grid;
  gap: 8px;
}

.detail-fact {
  display: grid;
  gap: 2px;
}

.detail-fact > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.detail-fact p {
  max-width: 78ch;
  margin: 0;
  color: var(--ink);
  font-size: 13px;
}

.detail-fact a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Debug-Sicht: nur mit globalem Schalter (Body-Klasse debug-on) sichtbar. */
.debug-block {
  display: none;
}

body.debug-on .debug-block {
  display: grid;
  gap: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}

.debug-title {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.debug-section {
  display: grid;
  gap: 6px;
}

.debug-section h4 {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.mini-bars {
  display: grid;
  gap: 4px;
  max-width: 460px;
}

.mini-bars .bar-row {
  min-height: 20px;
}

.kv-grid {
  display: grid;
  gap: 4px;
}

.kv-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.5fr) minmax(0, 1fr);
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.kv-row strong {
  overflow-wrap: anywhere;
  color: var(--ink);
  font-weight: 750;
}

.debug-note {
  max-width: 78ch;
  margin: 0;
  color: var(--ink);
  font-size: 12px;
}

.hash-row {
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.hash-row code {
  overflow: hidden;
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Kommentare (Rückkanal) ── */

.comment-section {
  display: grid;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}

.comment-section h4 {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.comment-list {
  display: grid;
  gap: 8px;
}

.comment-row {
  display: grid;
  gap: 2px;
  max-width: 78ch;
}

.comment-meta {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.comment-text {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  overflow-wrap: anywhere;
  white-space: pre-line;
}

/* Erledigte Kommentare bleiben sichtbar, treten aber zurück. */
.comment-row.is-resolved {
  opacity: 0.55;
}

.comment-row.is-resolved .comment-text {
  color: var(--muted);
}

.comment-empty {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.comment-form {
  display: grid;
  gap: 6px;
  max-width: 560px;
}

.comment-form textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  resize: vertical;
}

.comment-form-foot {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.comment-status {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

/* ── Such-Dialog ── */

dialog {
  width: min(720px, calc(100vw - 32px));
  max-height: min(80vh, 760px);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  background: var(--surface);
  color: var(--ink);
}

dialog::backdrop {
  background: oklch(21% 0.018 220 / 0.45);
  backdrop-filter: blur(2px);
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
  margin-bottom: 12px;
}

.dialog-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 850;
}

.dialog-sub {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.search-results {
  display: grid;
  gap: 0;
  overflow-y: auto;
  max-height: 52vh;
  margin-top: 6px;
}

.search-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.search-action {
  display: flex;
  align-items: center;
}

/* ── Handbuch ── */

.manual {
  width: min(860px, 100%);
  margin: 0 auto;
  padding: 28px 18px 56px;
}

.manual-hero {
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.manual-hero h1 {
  max-width: 18ch;
  font-size: 30px;
  line-height: 1.12;
}

.manual-section {
  padding: 22px 0;
  border-bottom: 1px solid var(--line);
}

.manual-section h2 {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 850;
}

.manual-section p,
.manual-section li,
.manual-section dd {
  max-width: 72ch;
  color: var(--ink);
}

.manual-section p {
  margin: 0 0 10px;
}

.manual-section ol {
  margin: 0;
  padding-left: 20px;
}

.manual-dl {
  display: grid;
  gap: 12px;
  margin: 0;
}

.manual-dl div {
  display: grid;
  gap: 2px;
}

.manual-dl dt {
  font-weight: 850;
}

.manual-dl dd {
  margin: 0;
  color: var(--muted);
}

/* ── Responsive ── */

@media (min-width: 860px) {
  .masthead {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .masthead-side {
    justify-items: end;
  }

  .controls {
    grid-template-columns: minmax(150px, 0.28fr) minmax(190px, 0.34fr) minmax(270px, 1fr) minmax(180px, 0.3fr);
    align-items: end;
  }

  .set-actions {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
  }

  .selection-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 1100px) {
  .rows.is-list {
    grid-template-columns: 1fr 1fr;
    column-gap: 28px;
  }
}

@media (max-width: 1080px) {
  .event-toolbar {
    grid-template-columns: minmax(140px, auto) minmax(240px, 1fr) minmax(150px, auto);
  }

  .quick-filters {
    grid-column: 1 / 3;
  }

  .stats-dashboard {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .event-toolbar {
    grid-template-columns: 1fr;
  }

  .event-search,
  .compact-control {
    min-width: 0;
  }

  .quick-filters {
    grid-column: auto;
  }

  .event-filter-panel {
    grid-template-columns: 1fr;
  }

  .pagination {
    justify-content: stretch;
  }

  .pagination span {
    min-width: 0;
    flex: 1;
  }

  .pool-row {
    grid-template-columns: 56px minmax(0, 1fr);
  }

  .pool-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .metric-strip,
  .curation-grid,
  .score-summary,
  .source-row {
    grid-template-columns: 1fr;
  }

  .stats-panel-head {
    align-items: start;
    flex-direction: column;
  }

  .event-row {
    grid-template-columns: 28px 56px minmax(0, 1fr);
    gap: 8px;
  }

  .event-row.is-hook {
    grid-template-columns: 1fr;
  }

  .thumb-lg {
    max-width: 320px;
  }

  .topbar {
    flex-wrap: wrap;
    padding: 8px 12px;
  }

  .topbar-side {
    flex-wrap: wrap;
  }

  .manual-hero h1 {
    max-width: none;
    font-size: 24px;
  }
}
