html, body { height: 100%; margin: 0; }
body {
  overflow: hidden;
  background: #c98e58;
  font-family: "Barlow", system-ui, -apple-system, sans-serif;
  color: #1d1f22;
}

/* ---------- The wall ---------- */
#viewport {
  --a: 46px;
  position: fixed;
  inset: 0;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  background-color: #c98e58;
  /* Seamless cork photo, 1024px file shown at 768px at zoom 1 (--a is 46px at zoom 1) */
  background-image: url("img/cork-tile.jpg");
  background-size: calc(var(--a) * 16.6957) calc(var(--a) * 16.6957);
}
#viewport.grabbing { cursor: grabbing; }
#world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }

.layer { position: absolute; overflow: visible; pointer-events: none; }
.layer .entity { pointer-events: auto; }


.line { fill: none; stroke-width: 11; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 3px 2px rgba(0, 0, 0, .35)); }
.st-dot { fill: #fff; stroke-width: 6; }
.st-interchange { fill: #fff; stroke: #1d1f22; stroke-width: 6; }
.st-label {
  font: 700 17px "Barlow", sans-serif;
  fill: #1d1f22;
  paint-order: stroke;
  stroke: #fbf7ee;
  stroke-width: 7px;
  stroke-linejoin: round;
}
.logo-mark { fill: #1d1f22; filter: drop-shadow(0 5px 4px rgba(0, 0, 0, .4)); }
.station.logo.clickable:hover .logo-mark, .station.logo:focus-visible .logo-mark { fill: #1f4e79; }
.station.clickable { cursor: pointer; }
.station.clickable:hover .st-label, .station:focus-visible .st-label { fill: #1f4e79; text-decoration: underline; }
.station:focus { outline: none; }
.sel-ring { fill: none; stroke: #1f6feb; stroke-width: 3; stroke-dasharray: 6 5; }

.string { fill: none; stroke: #b3121b; stroke-width: 2.4; stroke-linecap: round; filter: drop-shadow(0 2px 1.5px rgba(0, 0, 0, .35)); }

/* Pinned items */
.item {
  position: absolute;
  box-sizing: border-box;
  box-shadow: 0 8px 16px rgba(0, 0, 0, .35);
  transition: box-shadow .15s;
}
.item.clickable { cursor: pointer; }
.item.clickable:hover, .item:focus-visible { box-shadow: 0 14px 26px rgba(0, 0, 0, .45); outline: none; }
.item .pin {
  position: absolute;
  top: -5px;
  left: 50%;
  width: 16px;
  height: 16px;
  margin-left: -8px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ff6b6b, #c0272d 55%, #7a1015);
  box-shadow: 0 3px 4px rgba(0, 0, 0, .45);
}
.item.photo { width: 170px; height: 205px; padding: 10px 10px 0; background: #fbfaf6; }
.item.photo .ph { display: block; width: 150px; height: 150px; object-fit: cover; background: #77736b; }
.item.photo .ph.empty {
  display: flex; align-items: center; justify-content: center;
  color: #d3d1c7; font: 500 22px "Caveat", cursive;
}
.item.photo .cap {
  font: 700 21px/1.1 "Caveat", cursive;
  text-align: center;
  padding-top: 8px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.item.note {
  width: 170px; height: 150px; padding: 18px 14px 12px;
  background: var(--note, #fdf1a8);
  font-family: "Caveat", cursive;
  overflow: hidden;
}
.item.note .note-title { font-weight: 700; font-size: 24px; line-height: 1.05; margin-bottom: 4px; }
.item.note .note-text { font-weight: 500; font-size: 20px; line-height: 1.1; }
.item.selected { outline: 3px dashed #1f6feb; outline-offset: 5px; }

/* ---------- Interface ---------- */
.brand, .legend, .controls button, .list {
  background: rgba(252, 251, 248, .95);
  border-radius: 10px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .25);
}
.brand {
  position: fixed; top: 16px; left: 16px;
  display: flex; align-items: center;
  padding: 8px 12px;
}
.brand img { display: block; height: 30px; width: auto; }

.legend {
  position: fixed; left: 16px; bottom: 16px;
  padding: 10px 12px;
  display: flex; flex-direction: column; gap: 2px;
  max-width: calc(100vw - 32px);
}
.legend button {
  display: flex; align-items: center; gap: 10px;
  background: none; border: 0; padding: 4px 4px; border-radius: 6px;
  font: 700 15px "Barlow", sans-serif; color: #1d1f22; cursor: pointer; text-align: left;
}
.legend button:hover { background: rgba(0, 0, 0, .06); }
.legend .swatch { width: 28px; height: 7px; border-radius: 4px; flex: none; }

.controls { position: fixed; right: 16px; bottom: 16px; display: flex; gap: 8px; }
.controls button {
  min-width: 40px; height: 40px; padding: 0 12px; border: 0;
  font: 700 16px "Barlow", sans-serif; color: #1d1f22; cursor: pointer;
}
.controls button:hover { background: #fff; }

.list {
  position: fixed; top: 16px; right: 16px; bottom: 72px;
  width: min(320px, calc(100vw - 32px));
  overflow-y: auto; padding: 16px 20px; box-sizing: border-box;
}
.list h2 { margin: 0 0 8px; font-size: 20px; }
.list h3 { display: flex; align-items: center; gap: 8px; margin: 16px 0 4px; font-size: 15px; }
.list ul { margin: 0; padding-left: 20px; }
.list li { margin: 3px 0; }
.list a { color: #1f4e79; }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; box-shadow: none;
}
.noscript { position: fixed; inset: auto 16px 16px; background: #fff; padding: 12px 16px; border-radius: 10px; }

@media (max-width: 600px) {
  .brand img { height: 24px; }
  .legend { padding: 6px 8px; }
  .legend button { font-size: 13px; padding: 2px; }
  .controls { bottom: auto; top: 16px; }
}

/* ---------- Edit mode (only on your Mac, via tools/edit.py) ---------- */
body.editing .brand { display: none; }
.edit-bar {
  position: fixed; top: 0; left: 0; right: 0;
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  padding: 8px 12px; background: #1d1f22; color: #fff; z-index: 10;
  font: 500 14px system-ui, sans-serif;
}
.edit-bar button, .edit-panel button {
  font: 500 14px system-ui, sans-serif; padding: 6px 10px; border-radius: 6px;
  border: 1px solid #5f646b; background: #2b2e33; color: #fff; cursor: pointer;
}
.edit-bar button:hover, .edit-panel button:hover { background: #3a3e44; }
.edit-bar button.on { background: #b3121b; border-color: #b3121b; }
.edit-bar .primary { background: #1f6feb; border-color: #1f6feb; }
.edit-badge { background: #fdf1a8; color: #1d1f22; padding: 3px 8px; border-radius: 6px; font-weight: 600; margin-right: 6px; }
.edit-bar .sep { flex: 1; }
.edit-status { color: #d3d1c7; margin-left: 8px; }
.edit-status.warn { color: #ffb4a8; }
.edit-panel {
  position: fixed; top: 60px; right: 16px; bottom: 72px; width: 300px; overflow-y: auto;
  background: #1d1f22; color: #fff; border-radius: 10px; padding: 14px 16px; z-index: 10;
  font: 400 14px system-ui, sans-serif; box-sizing: border-box;
}
.edit-panel[hidden] { display: none; }
.edit-panel h2 { margin: 0 0 10px; font-size: 17px; display: flex; justify-content: space-between; align-items: center; }
.edit-panel .f { display: block; margin: 0 0 10px; }
.edit-panel .f > span { display: block; color: #a3a9b0; font-size: 12px; margin-bottom: 3px; }
.edit-panel input[type=text], .edit-panel textarea, .edit-panel select {
  width: 100%; box-sizing: border-box; padding: 6px 8px; border-radius: 6px;
  border: 1px solid #5f646b; background: #121417; color: #fff; font: inherit;
}
.edit-panel textarea { min-height: 70px; resize: vertical; }
.edit-panel input[type=range] { width: 100%; }
.edit-panel .row { display: flex; gap: 6px; align-items: center; }
.edit-panel .row > input[type=text] { flex: 1; }
.edit-panel .checks label { display: flex; gap: 8px; align-items: center; margin: 4px 0; }
.edit-panel .danger { border-color: #b3121b; color: #ffb4a8; margin-top: 8px; }
.edit-panel .hint { color: #a3a9b0; font-size: 12px; line-height: 1.4; }
.edit-panel .line-box { border: 1px solid #3a3e44; border-radius: 8px; padding: 10px; margin-bottom: 12px; }
.edit-panel .stops { list-style: none; padding: 0; margin: 6px 0; }
.edit-panel .stops li { display: flex; gap: 4px; align-items: center; margin: 3px 0; }
.edit-panel .stops li span { flex: 1; }
.edit-panel .stops button { padding: 2px 7px; }
