:root {
  --bg: #002746;
  --surface: #1a1d24;
  --text: #ededed;
  --text-dim: #777;
  --green: #27ae60;
  --amber: #e67e22;
  --red: #c0392b;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Hammersmith One', 'Helvetica Neue', Arial, sans-serif;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

header {
  padding: 20px 20px;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  border-bottom: 2px solid var(--text);
  flex-shrink: 0;
}

.line-selector {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 36px;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}

.line-selector::-webkit-scrollbar {
  display: none;
}

.line-pill {
  flex-shrink: 0;
  background: transparent;
  border: none;
  height: 36px;
  display: grid;
  grid-template-columns: 0fr;
  align-items: center;
  overflow: hidden;
  cursor: pointer;
  border-radius: 6px;
  padding: 0 6px;
  transition: grid-template-columns 400ms cubic-bezier(.4, 0, .2, 1),
              padding 400ms cubic-bezier(.4, 0, .2, 1);
  background-color: var(--pill-colour, #888);
  font-family: 'Hammersmith One', sans-serif;
}

.line-pill.active {
  grid-template-columns: max-content;
  padding: 0 16px;
}

.line-pill .label {
  color: #ffffff;
  font-size: clamp(14px, 5vw, 22px);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  min-width: 0;
  opacity: 0;
  transition: opacity 200ms ease 200ms;
}

.line-pill.active .label {
  opacity: 1;
}

.status {
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  min-height: 0;
}

#schematic-container {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: #333 transparent;
}

#trains-table-section {
  flex-shrink: 0;
  border-top: 2px solid rgba(255, 255, 255, 0.12);
}

#trains-table-toggle {
  width: 100%;
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: 'Hammersmith One', sans-serif;
  font-size: 11px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 8px 16px;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

#trains-table-toggle::before {
  content: '▾';
  font-size: 13px;
  transition: transform 200ms ease;
}

#trains-table-section.collapsed #trains-table-toggle::before {
  transform: rotate(-90deg);
}

#trains-table-toggle:hover {
  color: var(--text);
}

#trains-table-content {
  max-height: 40vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #333 transparent;
}

#trains-table-section.collapsed #trains-table-content {
  display: none;
}

#trains-table {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  border-collapse: collapse;
  font-size: 13px;
}

#trains-table th,
#trains-table td {
  padding: 8px 16px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

#trains-table thead th {
  position: sticky;
  top: 0;
  background: var(--bg);
  color: var(--text-dim);
  font-size: 11px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  padding-top: 12px;
  padding-bottom: 12px;
}

#trains-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.04);
}

#trains-table .raw-location {
  color: var(--text-dim);
  font-size: 11px;
}

#unresolved-locations {
  font-size: 11px;
  color: var(--amber);
  padding: 8px 16px;
  word-break: break-word;
}

.rag-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

#schematic-container.detail-zoom {
  -webkit-mask-image: linear-gradient(
    to bottom,
    transparent 0%,
    black 7%,
    black 93%,
    transparent 100%
  );
  mask-image: linear-gradient(
    to bottom,
    transparent 0%,
    black 7%,
    black 93%,
    transparent 100%
  );
}

#schematic {
  display: block;
  margin: 0 auto;
  width: 100%;
  max-width: 720px;
  height: auto;
  overflow: visible;
}

.station-name {
  font-family: 'Hammersmith One', sans-serif;
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0.04em;
  fill: var(--text);
}

.train {
  transition: opacity 300ms ease;
}
.train.entering,
.train.exiting {
  opacity: 0;
}
.interchange-pill:hover {
  opacity: 0.82;
}
.overlay-dim {
  opacity: 0.25;
}

.train-label {
  font-size: 12px;
  font-weight: 700;
  dominant-baseline: middle;
  text-anchor: middle;
  pointer-events: none;
  fill: #fff;
}

.train-tap-tooltip {
  position: fixed;
  z-index: 100;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--text-dim);
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 600;
  pointer-events: none;
  white-space: nowrap;
}
