:root {
  color-scheme: dark;
  --bg: #050505;
  --panel: #050505;
  --panel-2: #111111;
  --panel-3: #181818;
  --panel-4: #2a2a2a;
  --ink: #f7f7f7;
  --muted: #8f8f8f;
  --line: #202020;
  --border: #2d2d2d;
  --field: #050505;
  --field-active: #111111;
  --blue: #8ad4ff;
  --pink: #f7c7db;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Helvetica, Arial, sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
  letter-spacing: 0;
}

.viewer-shell {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  min-height: 100vh;
  background: var(--bg);
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 340px;
  min-height: 100vh;
  max-height: 100vh;
  padding: 16px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto;
}

.map-stage {
  position: relative;
  min-height: 100vh;
  background: var(--bg);
  overflow: hidden;
}

#metroCanvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 100vh;
  cursor: grab;
  touch-action: none;
}

#metroCanvas.dragging {
  cursor: grabbing;
}

h1,
h2,
p,
pre {
  margin: 0;
}

h1 {
  font-size: 20px;
  line-height: 1.2;
}

h2 {
  font-size: 24px;
  line-height: 1.15;
}

.control-section {
  display: grid;
  gap: 8px;
}

.section-heading,
.collapsible-section > summary {
  color: var(--ink);
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
}

.collapsible-section {
  display: grid;
  gap: 8px;
}

.collapsible-section > summary {
  cursor: pointer;
  list-style: none;
}

.collapsible-section > summary::-webkit-details-marker {
  display: none;
}

.collapsible-section > summary::before {
  content: "- ";
}

.collapsible-section[open] > summary::before {
  content: "+ ";
}

.collapsible-section > .control-section,
.collapsible-section > .summary,
.collapsible-section > .text-panel {
  margin-top: 8px;
}

.summary,
.hint,
.text-panel,
.info-popup p {
  color: var(--ink);
  font-size: 12px;
  line-height: 1.35;
  white-space: pre-line;
}

.hint {
  color: var(--muted);
  font-size: 11px;
}

.field-label {
  display: block;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.field-label.spaced {
  margin-top: 4px;
}

.input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.sidebar-input {
  width: 100%;
  min-height: 28px;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--field);
  color: var(--ink);
  outline: none;
}

.sidebar-input:focus {
  background: var(--field-active);
  border-color: var(--border);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

button {
  min-height: 28px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 0;
  background: var(--panel-3);
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

button:hover,
button:focus-visible {
  background: var(--panel-4);
  outline: none;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 24px;
  color: var(--ink);
  font-size: 12px;
  cursor: pointer;
}

.check-row input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--panel-3);
}

.text-panel {
  padding: 10px 12px;
  border: 1px solid var(--border);
  background: var(--panel-2);
}

#routeSummary {
  font-weight: 700;
  margin-bottom: 8px;
}

#routeSteps {
  overflow: visible;
  white-space: pre-wrap;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.35;
  font-family: Helvetica, Arial, sans-serif;
}

.tooltip {
  position: absolute;
  z-index: 3;
  max-width: min(280px, calc(100vw - 40px));
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 0;
  background: var(--panel-2);
  color: var(--ink);
  pointer-events: none;
}

.tooltip strong {
  display: block;
  margin-bottom: 2px;
  font-size: 12px;
}

.tooltip span {
  color: var(--muted);
  font-size: 12px;
}

.info-popup {
  position: absolute;
  z-index: 2;
  width: max-content;
  max-width: min(320px, calc(100vw - 40px));
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 0;
  background: var(--panel-2);
  color: var(--ink);
}

.info-popup h2 {
  margin-bottom: 5px;
}

.info-popup .readonly-checks {
  display: grid;
  gap: 2px;
  margin-top: 7px;
}

.readonly-checks label {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--ink);
  font-size: 12px;
}

.readonly-checks input {
  width: 13px;
  height: 13px;
  margin: 0;
  pointer-events: none;
  accent-color: var(--panel-3);
}

.info-popup .section-label {
  margin-top: 7px;
  font-weight: 700;
}

@media (max-width: 860px) {
  .viewer-shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(58vh, 1fr) auto;
  }

  .side-panel {
    grid-row: 2;
    width: auto;
    max-height: none;
    min-height: auto;
    border-top: 1px solid var(--line);
    border-right: 0;
  }

  .map-stage {
    grid-row: 1;
  }

  .map-stage,
  #metroCanvas {
    min-height: 58vh;
  }
}
