/* Finsternis — dunkel, mobil zuerst, große Tippflächen.
   Nachts steht man im Dunkeln und will nichts suchen. */

:root {
  --bg: #0d1117;
  --card: #151b24;
  --card-2: #1b2330;
  --line: #232b36;
  --text: #e8eef6;
  --muted: #8b98a8;
  --accent: #7fd0ff;
  --warm: #ffcc55;
  --danger: #ff8a6b;
  --good: #7ee2a8;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, 'Segoe UI', sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-text-size-adjust: 100%;
}

/* Rotlichtmodus: das Auge behält seine Dunkeladaption */
body.night {
  --bg: #0a0000;
  --card: #170606;
  --card-2: #1e0808;
  --line: #3a1010;
  --text: #ff9a9a;
  --muted: #b06060;
  --accent: #ff8080;
  --warm: #ff7a5a;
  filter: saturate(0.6);
}

/* ---------- Kopf ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  padding: max(10px, env(safe-area-inset-top)) 14px 6px;
}

.topbar-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

h1 {
  font-size: 17px;
  font-weight: 650;
  margin: 0;
  letter-spacing: 0.2px;
}

h2 {
  font-size: 14px;
  font-weight: 600;
  margin: 0;
  color: var(--text);
}

.site-chip {
  background: var(--card-2);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 12px;
  font: inherit;
  font-size: 12px;
  max-width: 55%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-chip::before {
  content: '📍 ';
}

.status {
  font-size: 11.5px;
  color: var(--muted);
  min-height: 16px;
}

.status.error {
  color: var(--danger);
}

/* ---------- Reiter ---------- */

.tabs {
  position: sticky;
  top: 52px;
  z-index: 19;
  display: flex;
  gap: 4px;
  padding: 4px 10px 8px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.tab {
  flex: 1;
  background: transparent;
  border: none;
  border-radius: 10px;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 550;
  padding: 9px 2px;
  white-space: nowrap;
}

.tab.active {
  background: var(--card-2);
  color: var(--text);
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

main {
  padding: 12px 12px 40px;
  max-width: 720px;
  margin: 0 auto;
}

/* ---------- Bausteine ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  margin: 12px 0;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.lead {
  color: var(--muted);
  margin: 0 0 12px;
}

.note {
  font-size: 12.5px;
  margin: 8px 0 0;
}

.small-note {
  font-size: 11.5px;
}

.muted {
  color: var(--muted);
}

canvas {
  width: 100%;
  display: block;
  border-radius: 10px;
  background: #0a0e14;
}

/* ---------- Hinweiskarte oben ---------- */

.hint {
  background: var(--card-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  padding: 11px 13px;
  font-size: 13.5px;
  line-height: 1.5;
  margin-bottom: 12px;
  color: var(--text);
}

.hint.good {
  border-left-color: var(--good);
}

.hint.danger {
  border-left-color: var(--danger);
}

.notice {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 138, 107, 0.09);
  border: 1px solid rgba(255, 138, 107, 0.3);
  font-size: 13px;
}

/* ---------- Sonnenbild und Schieber ---------- */

/* Die Höhe muss im CSS festliegen. Sonst nimmt das Layout die Attributhöhe der
   Leinwand, die resize() gerade eben aus der Layouthöhe berechnet hat — und bei
   einem Gerät mit dpr 2 schaukelt sich das bei jedem Neuzeichnen auf. */
#sunview {
  height: 300px;
}

#horizonview {
  height: 180px;
}

#chart {
  height: 260px;
}

.scrubber {
  margin: 10px 0 4px;
}

.scrubber input[type='range'] {
  width: 100%;
  accent-color: var(--warm);
  height: 28px;
}

.scrub-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
}

.accent {
  color: var(--warm);
}

/* ---------- Zahlenraster ---------- */

.statgrid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.statgrid > div {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  min-width: 0;
}

.statgrid .k {
  display: block;
  font-size: 10.5px;
  color: var(--muted);
}

.statgrid .v {
  display: block;
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
}

.statgrid .full {
  grid-column: 1 / -1;
}

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

/* ---------- Beschreibungszeilen ---------- */

.info .row {
  display: flex;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
}

.info .row:last-child {
  border-bottom: none;
}

.info .k {
  color: var(--muted);
  flex: 0 0 38%;
}

.info .v {
  flex: 1;
}

/* ---------- Bedienelemente ---------- */

button {
  cursor: pointer;
  font: inherit;
}

.primary {
  background: var(--accent);
  color: #06222f;
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  font-weight: 650;
}

.primary.big {
  width: 100%;
  font-size: 16px;
  padding: 15px;
}

.primary.active {
  background: var(--danger);
  color: #2a0d05;
}

.ghost {
  background: var(--card-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
}

.ghost.active {
  border-color: var(--warm);
  color: var(--warm);
}

.small {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--text);
}

.wide {
  width: 100%;
  margin: 6px 0;
}

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

.control-row label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--muted);
  flex: 1 1 auto;
}

select,
input[type='number'],
input[type='search'] {
  background: var(--card-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 9px;
  font: inherit;
  font-size: 13px;
  min-width: 0;
  flex: 1 1 60px;
}

input[type='search'] {
  flex: 1 1 160px;
}

.legend {
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
}

.dot {
  display: inline-block;
  width: 10px;
  height: 3px;
  vertical-align: middle;
  margin-right: 4px;
  border-radius: 2px;
}

.dot.measured {
  background: var(--warm);
}

.dot.model {
  background: #3f6ea8;
  margin-left: 12px;
}

.meter-status {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 8px;
}

.meter-status.warn,
.warn {
  color: var(--danger);
}

.resume {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  font-size: 12.5px;
  margin-bottom: 10px;
}

/* ---------- Tabelle für den Fotografen ---------- */

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

th {
  text-align: left;
  color: var(--muted);
  font-weight: 500;
  font-size: 11px;
  padding: 4px 6px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

td {
  padding: 5px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  white-space: nowrap;
}

tr.event td {
  color: var(--warm);
  font-weight: 600;
}

tr.below td {
  opacity: 0.45;
}

td.ev {
  font-size: 11px;
  white-space: normal;
}

/* ---------- Listen in der Hilfe ---------- */

.steps,
.howto ul,
.howto ol {
  margin: 0;
  padding-left: 20px;
  font-size: 13.5px;
  color: var(--muted);
}

.steps li,
.howto li {
  margin: 6px 0;
}

.steps strong,
.howto strong {
  color: var(--text);
}

.howto summary {
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  margin: -2px 0 8px;
}

footer {
  margin-top: 16px;
  font-size: 11.5px;
  line-height: 1.5;
}

/* ---------- Standort-Blatt ---------- */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(4, 7, 12, 0.7);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(3px);
}

.sheet[hidden] {
  display: none;
}

.sheet-inner {
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px 18px 0 0;
  padding: 16px 14px calc(20px + env(safe-area-inset-bottom));
}

.results {
  margin: 8px 0;
}

.results-head {
  font-size: 11px;
  color: var(--muted);
  margin: 10px 0 4px;
}

.result {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--card-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 11px;
  margin-bottom: 6px;
  font-size: 13px;
}
