* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  display: grid;
  grid-template-rows: auto 1fr;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* Scrollbars: thin, rounded, in the theme's colours (both engines) */

* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { border-radius: 999px; border: 3px solid transparent; background: var(--border-strong) padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--muted) padding-box; }
::-webkit-scrollbar-corner { background: transparent; }

/* App bar: brand on the left, station search in the middle */

.appbar {
  position: relative;
  z-index: 20;
  display: grid;
  grid-template-columns: 400px 1fr auto;
  align-items: center;
  gap: 16px;
  height: 60px;
  padding: 0 16px 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-1);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand .logo { width: 34px; height: 34px; flex: none; }
.brand strong { display: block; font-size: 17px; font-weight: 600; letter-spacing: 0.005em; line-height: 1.15; color: var(--text); }
.brand span { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar-right { display: flex; align-items: center; gap: 10px; }

.meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 12px;
  color: var(--text-2);
  white-space: nowrap;
}
.meta .live { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 22%, transparent); }
.meta .live.off { background: var(--stale); box-shadow: none; }
.meta .err { color: var(--critical); }

/* Main: docked panel on the left, map fills the rest */

.layout { display: grid; grid-template-columns: 400px 1fr; min-height: 0; }
.map-wrap { position: relative; min-height: 0; }

.panel {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  box-shadow: 4px 0 16px rgba(16, 24, 40, 0.06);
}

/* Underline tabs */

.tabs {
  display: flex;
  flex: none;
  padding: 0 8px;
  border-bottom: 1px solid var(--border);
}
.tabs button {
  position: relative;
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 46px;
  border: none;
  background: none;
  color: var(--muted);
  font-weight: 500;
  cursor: pointer;
}
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { color: var(--brand-strong); }
.tabs button[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: 18%; right: 18%; bottom: -1px;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--brand);
}
.tab-body { flex: 1; overflow-y: auto; scrollbar-gutter: stable; }
.tab-body[hidden] { display: none; }

.panel-foot {
  flex: none;
  padding: 10px 20px 12px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted);
}

/* Phones and narrow windows: map on top, panel below */

@media (max-width: 900px) {
  html, body { height: auto; }
  body { grid-template-rows: auto auto; }
  .appbar { grid-template-columns: 1fr auto; height: auto; padding: 10px 14px; row-gap: 10px; }
  .appbar .search { grid-column: 1 / -1; grid-row: 2; }
  .brand span { display: none; }
  .layout { grid-template-columns: 1fr; }
  .map-wrap { height: 56vh; order: -1; }
  .panel { border-right: none; box-shadow: none; }
  .tab-body { overflow: visible; }
}
