:root {
  --bg: #0f1419;
  --card: #1a2332;
  --text: #e7ecf3;
  --muted: #8b98a8;
  --ok: #3dd68c;
  --warn: #f5c542;
  --bad: #f07178;
  --accent: #6cb6ff;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  max-width: 480px;
  margin-inline: auto;
  padding: 1rem;
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
header h1 { margin: 0; font-size: 1.25rem; }
.token-btn {
  border: none;
  background: var(--card);
  color: var(--accent);
  font-size: 1.25rem;
  padding: 0.35rem 0.6rem;
  border-radius: 8px;
  cursor: pointer;
}
.token-panel {
  background: var(--card);
  padding: 0.75rem;
  border-radius: 8px;
  margin: 0.5rem 0;
}
.token-panel label { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 0.35rem; }
.token-panel input {
  width: 100%;
  padding: 0.5rem;
  border-radius: 6px;
  border: 1px solid #2a3544;
  background: var(--bg);
  color: var(--text);
  margin-bottom: 0.5rem;
}
.token-panel button {
  width: 100%;
  padding: 0.55rem;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #0f1419;
  font-weight: 600;
  cursor: pointer;
}
.summary { color: var(--muted); font-size: 0.9rem; margin: 0.25rem 0 1rem; }

.halt {
  background: var(--bad);
  color: #fff;
  padding: 0.75rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-weight: 600;
}
.hidden { display: none !important; }

.tabs { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.tabs button {
  flex: 1;
  padding: 0.6rem;
  border: none;
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
}
.tabs button.active { background: var(--accent); color: #0f1419; font-weight: 600; }

.tab { display: none; }
.tab.active { display: block; }

.ampel { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.ampel .dot {
  flex: 1;
  text-align: center;
  padding: 0.5rem;
  border-radius: 8px;
  background: var(--card);
  font-size: 0.75rem;
}
.dot.ok { border-bottom: 3px solid var(--ok); }
.dot.warn { border-bottom: 3px solid var(--warn); }
.dot.bad { border-bottom: 3px solid var(--bad); }

.section-title { font-size: 1rem; margin: 0 0 0.5rem; }
.chart-label { font-size: 0.75rem; color: var(--muted); margin: 0.5rem 0 0.25rem; }

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.stat-card {
  background: var(--card);
  border-radius: 8px;
  padding: 0.6rem 0.4rem;
  text-align: center;
}
.stat-card .num { font-size: 1.35rem; font-weight: 700; color: var(--accent); }
.stat-card .lbl { font-size: 0.65rem; color: var(--muted); margin-top: 0.2rem; }
.stats-sub {
  background: var(--card);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 1rem;
  text-align: center;
}

.mode, .positions, .funnel, .blockers {
  background: var(--card);
  padding: 0.75rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.chart-wrap-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}
.chart-wrap-head .section-title { margin: 0; }
.landscape-hint {
  margin: 0;
  font-size: 0.7rem;
  color: var(--accent);
}

.chart-dashboard {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.chart-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.chart-canvas {
  width: 100%;
  background: var(--card);
  border-radius: 8px;
  display: block;
}
.chart-live-canvas { height: 150px; }
.chart-edge-canvas { height: 90px; }

/* Querformat: zwei Charts nebeneinander, volle Breite */
@media (orientation: landscape) {
  body {
    max-width: none;
    padding: 0.4rem 0.75rem;
    padding-left: max(0.75rem, env(safe-area-inset-left));
    padding-right: max(0.75rem, env(safe-area-inset-right));
  }

  header h1 { font-size: 1rem; }
  .summary { margin-bottom: 0.35rem; font-size: 0.8rem; }
  .tabs { margin-bottom: 0.5rem; }
  .tabs button { padding: 0.45rem; font-size: 0.85rem; }

  .portrait-only { display: none !important; }
  .home-portrait-block { display: none; }

  .home-top-strip .ampel { margin-bottom: 0.35rem; }
  .home-top-strip .dot { font-size: 0.65rem; padding: 0.35rem; }

  .signal-banner-wrap { margin-bottom: 0.35rem; }
  .signal-banner { padding: 0.4rem 0.6rem; font-size: 0.75rem; }
  .banner-sub { font-size: 0.72rem; }
  .banner-note { font-size: 0.65rem; margin-top: 0.2rem; }

  .filter-legend { margin-bottom: 0.35rem; }

  .chart-dashboard {
    flex-direction: row;
    align-items: stretch;
    gap: 0.6rem;
    min-height: calc(100vh - 11rem);
    min-height: calc(100dvh - 11rem);
  }

  .chart-panel {
    flex: 1;
    min-height: 0;
  }

  .chart-live-canvas,
  .chart-edge-canvas {
    flex: 1;
    height: calc(100vh - 12rem) !important;
    height: calc(100dvh - 12rem) !important;
    min-height: 160px;
    max-height: 420px;
  }

  .readiness { font-size: 0.75rem; margin-top: 0.25rem; }
}

@media (orientation: portrait) {
  .landscape-only { display: none !important; }
}

.chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
.chart-head h2 { margin: 0; font-size: 1rem; }
.go-line-hint { color: var(--warn); font-size: 0.75rem; font-weight: 600; }
.warn-line { color: var(--warn); font-size: 0.85rem; margin: 0 0 0.5rem; }
.markers { font-size: 0.75rem; margin: 0.25rem 0 0.5rem; }

.filter-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}
.filter-chip {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  background: var(--card);
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  border: 1px solid transparent;
}
.filter-chip.go { border-color: var(--ok); }
.filter-chip .swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}
.filter-chip strong { color: var(--text); font-size: 0.8rem; }
.filter-chip.edge-hist { opacity: 0.92; border-style: dashed; }
.chip-hint { color: var(--muted); font-size: 0.65rem; }

.signal-banner-wrap { margin-bottom: 0.6rem; }
.signal-banner {
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  font-size: 0.85rem;
}
.signal-banner.banner-ok {
  background: rgba(61, 214, 140, 0.12);
  border: 1px solid var(--ok);
}
.signal-banner.banner-wait {
  background: var(--card);
  border: 1px solid #2a3544;
}
.signal-banner strong { display: block; margin-bottom: 0.25rem; }
.banner-sub { margin: 0; color: var(--text); font-size: 0.8rem; }
.banner-note { margin: 0.35rem 0 0; color: var(--muted); font-size: 0.7rem; }
.badge-go {
  display: inline-block;
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  background: var(--ok);
  color: #0f1419;
}
.badge-wait {
  display: inline-block;
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 600;
  background: #2a3544;
  color: var(--muted);
}

.readiness { font-size: 0.85rem; color: var(--muted); margin-top: 0.35rem; }

.progress { margin: 0.75rem 0; }
.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
}
.progress-track {
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
}
.progress-fill { height: 100%; border-radius: 4px; }
.progress-hint { font-size: 0.75rem; color: var(--muted); margin-top: 0.25rem; }
.countdown { color: var(--accent); font-size: 0.9rem; margin-top: 0.5rem; }

.events { list-style: none; padding: 0; margin: 0; }
.events li {
  background: var(--card);
  margin-bottom: 0.5rem;
  padding: 0.6rem;
  border-radius: 8px;
  font-size: 0.8rem;
}

.muted { color: var(--muted); }
.badge {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
}
.badge.SOLID { background: var(--ok); color: #0f1419; }
.badge.OK { background: var(--warn); color: #0f1419; }
.badge.DUENN { background: var(--muted); color: #0f1419; }
