:root {
  --bg: #000000;
  --panel: #0b0b0b;
  --panel-2: #101010;
  --text: #ffffff;
  --muted: rgba(255,255,255,0.72);
  --muted-2: rgba(255,255,255,0.58);
  --line: rgba(255,255,255,0.10);
  --line-2: rgba(255,255,255,0.14);
  --gold: #d4af37;
  --gold-soft: #e6c75a;
  --danger: #ff4d4d;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 10px;
  --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.45);
  --shadow-card: 0 10px 26px rgba(0,0,0,0.55);
  --shadow-btn: 0 6px 16px rgba(0,0,0,0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

a { color: inherit; }

.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 14px 24px 14px;
}

.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;
}

/* ===== Header (identisch Tool-Basis) ===== */
.r4x-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 16px 6px 16px;
  border-bottom: 3px solid var(--gold);
}

.r4x-header--dark {
  background: #000000;
}

.r4x-logo-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.r4x-logo {
  width: 2cm;
  height: 2cm;
  object-fit: contain;
}

.r4x-header-main-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.r4x-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1.5px solid var(--gold);
  background: radial-gradient(circle at 30% 30%, #444 0, #000 40%, #000 100%);
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.04),
    0 3px 8px rgba(0, 0, 0, 0.35);
  transition:
    transform 0.08s ease,
    box-shadow 0.12s ease,
    filter 0.12s ease;
  white-space: nowrap;
}

.nav-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.45);
  filter: brightness(1.05);
}

.nav-btn:active {
  transform: translateY(0);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.45);
  filter: brightness(0.97);
}

.r4x-header-right {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.hamburger-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 9px;
  border-radius: 999px;
  border: 1px solid var(--gold-soft);
  background: #ffffff;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  transition:
    transform 0.08s ease,
    box-shadow 0.12s ease,
    background 0.12s ease;
}

.hamburger-btn span {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: #000000;
}

.hamburger-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.18);
}

.hamburger-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: #000000;
  border-radius: var(--radius-md);
  border: 1px solid var(--gold-soft);
  box-shadow: var(--shadow-soft);
  padding: 8px 0;
  min-width: 240px;
  max-height: 70vh;
  overflow-y: auto;
  display: none;
  z-index: 20;
}

.hamburger-menu.open {
  display: block;
}

.hamburger-menu a {
  display: block;
  padding: 6px 16px;
  font-size: 0.85rem;
  text-decoration: none;
  color: #ffffff;
  white-space: nowrap;
}

.hamburger-menu a:hover {
  background: #202020;
}

@media (max-width: 768px) {
  .r4x-header {
    padding: 8px 10px 6px 10px;
    gap: 10px;
  }

  .r4x-nav {
    gap: 4px;
  }

  .nav-btn {
    padding: 3px 8px;
    font-size: 0.7rem;
  }

  .r4x-logo {
    width: 1.6cm;
    height: 1.6cm;
  }
}

/* ===== Tool UI ===== */
.toolbar {
  background: linear-gradient(180deg, rgba(212,175,55,0.10) 0%, rgba(0,0,0,0) 65%);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 14px 14px 10px 14px;
}

.toolbar-top {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.tool-name {
  font-weight: 800;
  letter-spacing: 0.2px;
  font-size: 1.1rem;
  line-height: 1.2;
}

.tool-sub {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.92rem;
  max-width: 70ch;
}

.controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.search {
  flex: 1 1 260px;
  min-width: 220px;
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: rgba(0,0,0,0.55);
  color: var(--text);
  outline: none;
}

.search:focus {
  border-color: rgba(212,175,55,0.55);
  box-shadow: 0 0 0 4px rgba(212,175,55,0.12);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: rgba(0,0,0,0.45);
  color: var(--text);
  font-weight: 700;
  font-size: 0.86rem;
  cursor: pointer;
  box-shadow: var(--shadow-btn);
  user-select: none;
}

.btn:hover { border-color: rgba(212,175,55,0.35); }

.btn:active { transform: translateY(1px); }

.btn--gold {
  border-color: rgba(212,175,55,0.6);
  background: radial-gradient(circle at 30% 30%, rgba(212,175,55,0.22), rgba(0,0,0,0.60) 55%, rgba(0,0,0,0.70) 100%);
}

.btn--ghost {
  background: transparent;
  box-shadow: none;
}

.btn[aria-pressed="true"] {
  border-color: rgba(212,175,55,0.9);
  box-shadow: 0 0 0 4px rgba(212,175,55,0.12);
}

.status-row {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.count {
  color: var(--muted);
  font-size: 0.85rem;
}

.legend {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(0,0,0,0.25);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  color: var(--muted-2);
  font-size: 0.82rem;
}

.legend b { color: var(--text); font-weight: 800; }

.chips-row {
  margin-top: 12px;
}

.row-label {
  font-size: 0.82rem;
  color: var(--muted-2);
  margin-bottom: 6px;
}

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 6px;
}

.chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  border-radius: 999px;
  border: 1px solid rgba(212,175,55,0.35);
  background: rgba(0,0,0,0.45);
  color: var(--text);
  font-weight: 700;
  font-size: 0.84rem;
  cursor: pointer;
  white-space: nowrap;
}

.chip:hover { border-color: rgba(212,175,55,0.60); }

.chip[aria-pressed="true"] {
  border-color: rgba(212,175,55,0.95);
  background: rgba(212,175,55,0.14);
}

.chip--all {
  border-color: var(--line-2);
}

.active-filters {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: rgba(0,0,0,0.35);
  color: var(--muted);
  font-size: 0.82rem;
}

.pill button {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.card {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,0.03) 0%, rgba(0,0,0,0.15) 100%), var(--panel);
  border-radius: var(--radius-lg);
  padding: 12px;
  box-shadow: var(--shadow-card);
  min-height: 160px;
  display: flex;
  flex-direction: column;
}

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

.card-title {
  font-weight: 800;
  font-size: 1.02rem;
  line-height: 1.2;
}

.card-sub {
  margin-top: 4px;
  color: var(--muted-2);
  font-size: 0.84rem;
}

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

.tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: rgba(0,0,0,0.35);
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  white-space: nowrap;
}

.tag--gold {
  border-color: rgba(212,175,55,0.45);
  color: rgba(255,255,255,0.92);
}

.tag--risk {
  border-color: rgba(255,77,77,0.55);
  color: rgba(255,255,255,0.92);
}

.card-body {
  margin-top: 10px;
  flex: 1 1 auto;
}

.fit {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-tags {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.tag-row {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 8px;
  align-items: start;
}

.tag-row .lbl {
  color: var(--muted-2);
  font-size: 0.78rem;
  padding-top: 2px;
}

.tag-row .vals {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.card-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.link-btns {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: rgba(0,0,0,0.25);
  color: var(--text);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 700;
}

.link:hover { border-color: rgba(212,175,55,0.35); }

.empty {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
  color: var(--muted);
  background: var(--panel);
}

.ftr {
  max-width: 1200px;
  margin: 18px auto 10px auto;
  padding: 0 14px;
  color: var(--muted-2);
  font-size: 0.84rem;
}

.ftr a {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid rgba(255,255,255,0.22);
}

.ftr a:hover { border-bottom-color: rgba(212,175,55,0.6); }

/* ===== Dialogs ===== */
.dialog {
  width: min(900px, calc(100vw - 24px));
  border: 1px solid rgba(212,175,55,0.30);
  border-radius: var(--radius-lg);
  background: #050505;
  color: var(--text);
  box-shadow: var(--shadow-soft);
  padding: 0;
}

.dialog::backdrop {
  background: rgba(0,0,0,0.72);
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 14px 10px 14px;
  border-bottom: 1px solid var(--line);
}

.dialog-title {
  font-weight: 900;
  font-size: 1.1rem;
}

.dialog-meta {
  margin-top: 4px;
  color: var(--muted-2);
  font-size: 0.86rem;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.18);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  line-height: 1;
}

.icon-btn:hover { border-color: rgba(212,175,55,0.45); }

.dialog-body {
  padding: 12px 14px 14px 14px;
}

.section {
  margin-top: 12px;
}

.section h3 {
  margin: 0 0 6px 0;
  font-size: 0.92rem;
  letter-spacing: 0.2px;
  color: rgba(255,255,255,0.92);
}

.section p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.risk-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

.risk-list li { margin: 6px 0; }

.steps {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

.dialog-links {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.dialog-links a {
  text-decoration: none;
}

.filters-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.filter-box {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 10px;
  background: rgba(255,255,255,0.02);
}

.filter-box .t {
  font-weight: 800;
  font-size: 0.86rem;
  color: rgba(255,255,255,0.9);
  margin-bottom: 8px;
}

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pills button {
  border: 1px solid var(--line-2);
  background: rgba(0,0,0,0.35);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 9px;
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
}

.pills button[aria-pressed="true"] {
  border-color: rgba(212,175,55,0.85);
  color: rgba(255,255,255,0.95);
  background: rgba(212,175,55,0.10);
}

.dialog-actions {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.toast {
  position: fixed;
  left: 14px;
  right: 14px;
  bottom: 14px;
  margin: 0 auto;
  max-width: 780px;
  border: 1px solid rgba(255,77,77,0.55);
  background: #0b0505;
  color: rgba(255,255,255,0.92);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: none;
  z-index: 50;
}

.toast strong { display: block; }

.toast .small { color: var(--muted-2); font-size: 0.84rem; margin-top: 2px; }

.toast.show { display: block; }

@media (max-width: 980px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .wrap { padding: 10px 10px 18px 10px; }
  .tool-sub { display: none; }
  .grid { grid-template-columns: 1fr; }
  .tag-row { grid-template-columns: 78px 1fr; }
  .filters-grid { grid-template-columns: 1fr; }

  /* Mobile: Content zuerst, Controls kompakt */
  .controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    align-items: stretch;
  }

  .search {
    grid-column: 1 / -1;
    width: 100%;
    min-width: 0;
  }

  .controls .btn {
    width: 100%;
    padding: 8px 10px;
    font-size: 0.82rem;
  }

  .controls .count {
    grid-column: 1 / -1;
    text-align: right;
    font-size: 0.78rem;
    padding-right: 2px;
  }

  .legend {
    font-size: 0.74rem;
    gap: 8px;
  }

  .legend-dot { width: 8px; height: 8px; }

  /* Lange Chips dürfen umbrechen, sonst sprengen sie Mobile */
  .tag {
    white-space: normal;
    max-width: 100%;
    line-height: 1.15;
  }

  .card-actions { justify-content: flex-start; }
  .card-actions .btn { flex: 1 1 calc(50% - 8px); }
}
}

/* ===== Aliases für v3 HTML Klassen ===== */
.ver {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(212,175,55,0.35);
  color: rgba(255,255,255,0.92);
  font-size: 0.74rem;
  font-weight: 800;
  background: rgba(0,0,0,0.45);
}

.chip-strip { margin-top: 12px; padding: 10px 10px 6px 10px; border: 1px solid rgba(212,175,55,0.18); border-radius: var(--radius-md); background: rgba(255,255,255,0.02); }
.chip-label { font-size: 0.82rem; color: rgba(255,255,255,0.78); margin-bottom: 6px; font-weight: 800; letter-spacing: 0.2px; }

/* Backwards: allow older class names too */
.chips-row { margin-top: 12px; }
.row-label { font-size: 0.82rem; color: var(--muted-2); margin-bottom: 6px; }

.active { margin-top: 10px; }
.active-filters { margin-top: 10px; }

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
  border: 1px solid var(--line-2);
}

.legend-dot--gold { background: rgba(212,175,55,0.9); }
.legend-dot--red { background: rgba(255,77,77,0.9); }

/* ===== Dialog Aliases für v3 HTML ===== */
.dialog-sub { margin-top: 4px; color: var(--muted-2); font-size: 0.86rem; }

.filter-group {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 10px;
  background: rgba(255,255,255,0.02);
}

.filter-title {
  font-weight: 800;
  font-size: 0.86rem;
  color: rgba(255,255,255,0.9);
  margin-bottom: 8px;
}

.dialog--detail { width: min(980px, calc(100vw - 24px)); }

.detail { }
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.detail-box {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 10px;
  background: rgba(255,255,255,0.02);
}

.detail-k {
  font-weight: 800;
  font-size: 0.9rem;
  color: rgba(255,255,255,0.92);
  margin-bottom: 6px;
}

.detail-v { color: var(--muted); line-height: 1.5; }

.link-row { display: flex; flex-wrap: wrap; gap: 8px; }

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

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

/* ===== Card Aliases für v3 JS Klassen ===== */
.card-meta { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-start; margin-top: 6px; }
.card-right { display: flex; align-items: center; gap: 8px; }

.tag--meta { color: var(--muted-2); }
.tag--muted { color: var(--muted-2); border-color: rgba(255,255,255,0.12); }

.card-fit {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tag-wrap { margin-top: 10px; display: grid; gap: 8px; }
.tag-k { color: var(--muted-2); font-size: 0.78rem; padding-top: 2px; }
.tag-v { display: flex; flex-wrap: wrap; gap: 6px; }

.card-links { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.link-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: rgba(0,0,0,0.25);
  color: var(--text);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 700;
}
.link-pill:hover { border-color: rgba(212,175,55,0.35); }
.link-pill[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }

.fav {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.18);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  line-height: 1;
}
.fav:hover { border-color: rgba(212,175,55,0.45); }
.fav[aria-pressed="true"] { border-color: rgba(212,175,55,0.75); }

/* Backwards support */
.meta { justify-content: flex-end; }
.fit { }


/* ===== Active filter tokens ===== */
.active-none { color: var(--muted-2); font-size: 0.84rem; }
.token {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(0,0,0,0.30);
  color: rgba(255,255,255,0.86);
  font-size: 0.78rem;
  font-weight: 700;
  margin-right: 6px;
  margin-top: 6px;
}
.active { display: flex; flex-wrap: wrap; align-items: center; }
.empty-box { display: flex; flex-direction: column; gap: 6px; }
.empty .small { color: var(--muted-2); font-size: 0.86rem; }
