:root {
  --up: #c62828;
  --imminent: #f9a825;
  --scheduled: #1565c0;
  --down: #2e7d32;
  --unknown: #546e7a;
  --nearby: #546e7a;
  --text: #1c2124;
  --muted: #5f6b70;
  --line: #dde3e6;
  --bg: #f4f6f7;
  --card: #ffffff;
  --selected: #e3ecf8;
  --radius: 14px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --text: #e6eaec;
    --muted: #a3afb4;
    --line: #34404a;
    --bg: #12171a;
    --card: #1b2226;
    --selected: #22344a;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 16px 16px 40px;
  display: grid;
  gap: 14px;
}

h1 { margin: 0; font-size: 1.45rem; }
h2 { margin: 0 0 8px; font-size: 1.1rem; display: inline; }
p { margin: 0; }
a { color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

/* Status card: colour by state */
.status {
  border-radius: var(--radius);
  padding: 22px 24px;
  color: #fff;
  background: var(--unknown);
  transition: background-color 0.3s;
}
.status[data-tone="up"] { background: var(--up); }
.status[data-tone="imminent"] { background: var(--imminent); color: #1c1c1c; }
.status[data-tone="scheduled"] { background: var(--scheduled); }
.status[data-tone="down"] { background: var(--down); }
.status-label { font-size: clamp(1.8rem, 7vw, 2.4rem); font-weight: 900; letter-spacing: 0.01em; line-height: 1.1; }
.status-detail { margin-top: 4px; opacity: 0.92; }

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

.map {
  height: min(60vh, 380px);
  border-radius: 10px;
  background: var(--line);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  list-style: none;
  margin: 10px 0 6px;
  padding: 0;
  font-size: 0.85rem;
}
.legend li::before,
.vessel-name::before {
  content: "";
  display: inline-block;
  width: 11px;
  height: 11px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--tone);
  vertical-align: -1px;
}
.tone-up { --tone: var(--up); }
.tone-imminent { --tone: var(--imminent); }
.tone-nearby { --tone: var(--nearby); }

.connection.live { color: var(--down); }
@media (prefers-color-scheme: dark) {
  .connection.live { color: #66bb6a; }
}

/* Vessel list */
.vessels {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.vessel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.vessel.selected {
  background: var(--selected);
  border-color: var(--scheduled);
  box-shadow: inset 0 0 0 1px var(--scheduled);
}
.vessel summary {
  list-style: none;
  cursor: pointer;
  padding: 10px 14px;
  display: grid;
  gap: 2px;
}
.vessel summary::-webkit-details-marker { display: none; }
.vessel-name { font-weight: 600; }
.vessel-line { font-size: 0.85rem; color: var(--muted); }
.vessel-details {
  display: grid;
  grid-template-columns: minmax(7em, 40%) 1fr;
  gap: 2px 12px;
  margin: 0;
  padding: 0 14px 12px;
  font-size: 0.85rem;
}
.vessel-details dt { color: var(--muted); }
.vessel-details dd { margin: 0; overflow-wrap: anywhere; }

/* Lift history */
#lifts-section summary { cursor: pointer; }
.lifts { margin: 8px 0 0; padding-left: 18px; display: grid; gap: 4px; }

footer { display: grid; gap: 6px; margin-top: 8px; }
