/* RT-DETR-Demo – ruhiges, gut lesbares Layout für Beamer und Laptop. */

:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #eef1f6;
  --border: #dde3ec;
  --text: #0f172a;
  --text-2: #475569;
  --muted: #94a3b8;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --accent-soft: #dbe7fe;
  --hit: #15803d;
  --stage-bg: #0b1220;
  --red: #dc2626;
  --green: #16a34a;
  --blue: #2563eb;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 4px 16px rgba(15, 23, 42, 0.06);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1020;
    --surface: #131a2b;
    --surface-2: #1b2438;
    --border: #273248;
    --text: #e6eaf2;
    --text-2: #a5b0c4;
    --muted: #64748b;
    --accent: #5b8cff;
    --accent-ink: #0b1020;
    --accent-soft: #1e2b4d;
    --hit: #4ade80;
    --stage-bg: #05080f;
    --red: #f87171;
    --green: #4ade80;
    --blue: #7aa2ff;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h2 { font-size: 1.3rem; margin-bottom: 0.5rem; }
h3 { font-size: 0.95rem; margin: 1.25rem 0 0.5rem; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.04em; }
h4 { font-size: 1rem; display: flex; align-items: center; gap: 0.5rem; }
p { margin: 0 0 0.75rem; }
.muted { color: var(--muted); }
.c-r { color: var(--red); font-weight: 600; }
.c-g { color: var(--green); font-weight: 600; }
.c-b { color: var(--blue); font-weight: 600; }

/* ---------- Kopfzeile ---------- */

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand h1 { font-size: 1.4rem; }
.brand p { margin: 0.15rem 0 0; color: var(--text-2); font-size: 0.9rem; }

.modes {
  display: flex;
  gap: 0.25rem;
  padding: 0.25rem;
  background: var(--surface-2);
  border-radius: 999px;
}
.modes button {
  border: 0;
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.modes button:hover { color: var(--text); }
.modes button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }
.modes .short { display: none; }
.modes .num {
  display: inline-grid;
  place-items: center;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  font-size: 0.8rem;
  background: rgba(127, 127, 127, 0.18);
}

/* ---------- Hauptbereich ---------- */

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 1.25rem;
  padding: 1.25rem 1.5rem;
  align-items: start;
}

.stage-wrap { display: flex; flex-direction: column; gap: 0.75rem; min-width: 0; }

.stage {
  position: relative;
  background: var(--stage-bg);
  border-radius: var(--radius);
  overflow: hidden;
  height: min(72vh, 60vw);
  min-height: 280px;
}
.stage canvas { display: block; width: 100%; height: 100%; }
body[data-mode="pixels"] .stage canvas { cursor: crosshair; }
body[data-mode="queries"] .stage canvas { cursor: pointer; }

.badge {
  position: absolute;
  bottom: 0.75rem;
  left: 0.75rem;
  background: rgba(15, 23, 42, 0.75);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  pointer-events: none;
}

.loader {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1.5rem;
  background: rgba(11, 18, 32, 0.88);
  color: #e2e8f0;
  text-align: center;
  transition: opacity 0.3s;
}
.loader.hidden { opacity: 0; pointer-events: none; }
.loader-text { font-size: 1.15rem; font-weight: 600; }
.loader-sub { font-size: 0.9rem; color: #94a3b8; max-width: 32rem; }
.loader.error .spinner { display: none; }
.loader.error .loader-text { color: #fca5a5; }

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(255, 255, 255, 0.15);
  border-top-color: #60a5fa;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.progress { width: min(320px, 80%); height: 8px; background: rgba(255, 255, 255, 0.12); border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: #60a5fa; transition: width 0.15s; }

/* ---------- Werkzeugleiste ---------- */

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; }

.btn, .select {
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); min-width: 9rem; }
.btn-ghost { background: transparent; }
.select { font-weight: 500; max-width: 16rem; }

.check { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.95rem; cursor: pointer; }
.check input { width: 1.05rem; height: 1.05rem; accent-color: var(--accent); }

.stats { margin-left: auto; color: var(--text-2); font-size: 0.85rem; font-variant-numeric: tabular-nums; }

/* ---------- Seitenleiste ---------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  max-height: calc(72vh + 3.5rem);
  overflow-y: auto;
}
.panel-section p { color: var(--text-2); }
.panel-section p strong, .panel-section p em { color: var(--text); }

.facts { margin: 0 0 1rem; padding-left: 1.1rem; color: var(--text-2); font-size: 0.95rem; }
.facts li { margin-bottom: 0.3rem; }

.control { margin: 1rem 0 0.5rem; }
.control label, .control-label { display: block; font-size: 0.95rem; font-weight: 600; margin-bottom: 0.4rem; }
.control output { color: var(--accent); font-variant-numeric: tabular-nums; }
input[type="range"] { width: 100%; accent-color: var(--accent); }

.tip {
  margin-top: 1.25rem;
  padding: 0.75rem 0.9rem;
  background: var(--accent-soft);
  border-radius: 8px;
  font-size: 0.92rem;
}

.dot { display: inline-block; width: 0.7rem; height: 0.7rem; border-radius: 50%; flex: none; }
.pct { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--text-2); font-size: 0.9rem; }

.hit-list { list-style: none; margin: 0; padding: 0; }
.hit-list li { display: flex; align-items: center; gap: 0.5rem; padding: 0.35rem 0; border-bottom: 1px solid var(--border); font-weight: 600; }
.hit-list li.muted { font-weight: 400; border: 0; }

/* Pixel-Ansicht */
.bignum {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.9rem;
  margin: 0.5rem 0 0.75rem;
  background: var(--surface-2);
  border-radius: 8px;
  text-align: center;
}
.bignum span { color: var(--text-2); font-size: 0.95rem; }
.bignum strong { font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.bignum small { color: var(--text-2); }

.segmented { display: inline-flex; background: var(--surface-2); border-radius: 8px; padding: 0.2rem; gap: 0.2rem; }
.segmented button { font: inherit; font-size: 0.9rem; font-weight: 600; border: 0; background: transparent; color: var(--text-2); padding: 0.35rem 0.8rem; border-radius: 6px; cursor: pointer; }
.segmented button[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.magnifier { display: block; width: 100%; max-width: 308px; aspect-ratio: 1; border-radius: 8px; image-rendering: pixelated; }
.readout { margin-top: 0.5rem; font-variant-numeric: tabular-nums; font-size: 0.95rem; }

/* Suchtrupps */
.counters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; margin: 0.75rem 0; }
.counters div { background: var(--surface-2); border-radius: 8px; padding: 0.6rem 0.4rem; text-align: center; }
.counters strong { display: block; font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.counters span { font-size: 0.78rem; color: var(--text-2); line-height: 1.25; display: block; }
.counters .sure strong { color: var(--hit); }

.detail { margin: 1rem 0 0; padding: 0.8rem 0.9rem; border: 1px solid var(--border); border-radius: 8px; min-height: 5.5rem; }
.detail p { margin: 0.4rem 0; font-size: 0.9rem; }
.tag { font-size: 0.75rem; font-weight: 600; padding: 0.1rem 0.5rem; border-radius: 999px; background: var(--surface-2); color: var(--text-2); }
.tag-hit { background: color-mix(in srgb, var(--hit) 18%, transparent); color: var(--hit); }

.probs, .rank-list { list-style: none; margin: 0; padding: 0; }
.probs li, .rank-list li { display: grid; align-items: center; gap: 0.5rem; padding: 0.25rem 0; font-size: 0.9rem; }
.probs li { grid-template-columns: 7.5rem 1fr 3rem; }
.rank-list li { grid-template-columns: 3.6rem 7rem 1fr 3rem; border-radius: 6px; padding: 0.25rem 0.35rem; cursor: default; }
.rank-list li.active { background: #fef9c3; color: #0f172a; }
.rank-list li.hit .rank-label { font-weight: 700; }
.rank-id { color: var(--text-2); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.rank-label, .prob-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 999px; }
.probs .pct, .rank-list .pct { text-align: right; }

/* Vom Raten zur Box */
.stepper { margin: 1rem 0 0.75rem; }
.stepper-buttons { display: flex; gap: 0.5rem; margin-bottom: 0.6rem; }
.stepper-buttons .btn-primary { flex: 1; }
.stepper-buttons .btn:not(.btn-primary) { font-size: 1.2rem; line-height: 1; padding: 0.4rem 0.9rem; }
.step-ticks {
  list-style: none;
  margin: 0.2rem 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  font-size: 0.72rem;
  line-height: 1.2;
  color: var(--text-2);
  text-align: center;
}
.step-ticks li { cursor: pointer; padding: 0.2rem 0.1rem; border-radius: 4px; hyphens: manual; }
.step-ticks li:first-child { text-align: left; }
.step-ticks li:last-child { text-align: right; }
.step-ticks li.active { color: var(--accent); font-weight: 700; }

.step-info {
  padding: 0.75rem 0.9rem;
  background: var(--surface-2);
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  min-height: 7.5rem;
}
.step-info h4 { margin-bottom: 0.35rem; }
.step-info p { margin: 0; font-size: 0.92rem; }

.evo-wrap { overflow-x: auto; }
.evo { width: 100%; border-collapse: collapse; font-size: 0.8rem; font-variant-numeric: tabular-nums; table-layout: fixed; }
.evo col.name, .evo thead th:first-child { width: 34%; }
.evo th, .evo td { padding: 0.3rem 0.25rem; text-align: right; border-bottom: 1px solid var(--border); }
.evo thead th { font-size: 0.72rem; font-weight: 600; color: var(--text-2); vertical-align: bottom; line-height: 1.2; }
.evo tbody th, .evo tfoot th { text-align: left; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.evo tbody th .dot { margin-right: 0.35rem; vertical-align: 0.05rem; }
.evo td { color: var(--muted); }
.evo td.sure { color: var(--hit); font-weight: 700; }
.evo td small { display: block; font-size: 0.68rem; font-weight: 400; color: var(--text-2); }
.evo .current { background: var(--accent-soft); }
.evo tbody tr.active th, .evo tbody tr.active td { background: #fef9c3; color: #0f172a; }
.evo tfoot th, .evo tfoot td { border-bottom: 0; font-weight: 700; color: var(--text); padding-top: 0.5rem; }

/* Klassenliste */
.classes { margin-top: 1.5rem; border-top: 1px solid var(--border); padding-top: 1rem; }
.classes summary { cursor: pointer; font-weight: 600; }
.classes p { margin-top: 0.5rem; font-size: 0.9rem; }
.class-list { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0.35rem; }
.class-list li { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.82rem; padding: 0.15rem 0.55rem; background: var(--surface-2); border-radius: 999px; }
.class-list .dot { width: 0.55rem; height: 0.55rem; }

/* ---------- Fußzeile ---------- */

.footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  padding: 0.75rem 1.5rem 1rem;
  color: var(--muted);
  font-size: 0.8rem;
}
kbd {
  font: 600 0.75rem ui-monospace, Menlo, monospace;
  padding: 0.05rem 0.35rem;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--surface);
  color: var(--text-2);
}

/* ---------- Kleine Bildschirme ---------- */

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; padding: 1rem; }
  .topbar { padding: 0.9rem 1rem; }
  .stage { height: auto; aspect-ratio: 4 / 3; }
  .panel { max-height: none; }
  .stats { margin-left: 0; width: 100%; }
  .modes { width: 100%; }
  .modes button { flex: 1; justify-content: center; padding: 0.45rem 0.5rem; white-space: nowrap; font-size: 0.95rem; }
  .footer { padding: 0.75rem 1rem 1rem; }
  .footer .keys { display: none; }
}

@media (max-width: 820px) {
  .modes .long { display: none; }
  .modes .short { display: inline; }
}

@media (max-width: 560px) {
  .modes .num { display: none; }
  .modes button { padding: 0.45rem 0.3rem; font-size: 0.85rem; }
  .brand h1 { font-size: 1.2rem; }
}
