:root {
  color-scheme: dark;
  --ink: #e9ece8;
  --muted: #8d9796;
  --panel: #111516;
  --panel-2: #171c1e;
  --line: #303839;
  --acid: #d7ff31;
  --green: #35f06f;
  --blue: #50a6ff;
  --orange: #ff7c35;
  --black: #090b0c;
  --arrival-train-duration: 60s;
  --live-train-duration: 30s;
  --font-condensed: "Arial Narrow", "Roboto Condensed", Impact, sans-serif;
  --font-ui: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body[data-train-speed="slow"] { --arrival-train-duration: 86s; --live-train-duration: 44s; }
body[data-train-speed="fast"] { --arrival-train-duration: 38s; --live-train-duration: 19s; }

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; background: var(--black); color: var(--ink); }

body {
  font-family: var(--font-ui);
  background:
    radial-gradient(circle at 67% 12%, rgba(57, 106, 95, .13), transparent 23rem),
    linear-gradient(#0c1011 1px, transparent 1px),
    #090b0c;
  background-size: auto, 100% 34px, auto;
  overflow-x: hidden;
}

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

.arrival-screen[hidden], .editor-app[hidden] { display: none !important; }
body.arrival-active { overflow: hidden; }

.arrival-screen {
  min-height: 100svh;
  display: grid;
  grid-template-rows: 72px auto minmax(0, 1fr) 42px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(4,7,9,.48) 0%, rgba(4,7,9,.08) 42%, rgba(4,6,7,.52) 100%),
    url("./midnight-rail-yard.png") center center / cover no-repeat;
}

.arrival-header {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 34px;
  border-bottom: 1px solid #303839;
  background: rgba(7, 9, 10, .82);
}

.arrival-live { color: #aab2b1; font: 800 .72rem/1 var(--font-ui); letter-spacing: .11em; }
.arrival-live.offline { color: #ff806d; }
.arrival-actions { display: flex; align-items: center; gap: 22px; }
.train-speed-control { display: flex; align-items: center; gap: 4px; }
.train-speed-control > span { margin-right: 5px; color: #697374; font: 850 .68rem/1 var(--font-ui); letter-spacing: .12em; }
.train-speed-control button { min-height: 32px; padding: 0 10px; border: 1px solid #343c3d; background: rgba(17,21,22,.86); color: #7f8988; font: 900 .72rem/1 var(--font-ui); letter-spacing: .06em; cursor: pointer; }
.train-speed-control button:hover { border-color: #687372; color: #d7dcda; }
.train-speed-control button[aria-pressed="true"] { border-color: var(--acid); background: rgba(215,255,49,.09); color: var(--acid); box-shadow: inset 0 -2px var(--acid); }
.arrival-copy { position: relative; z-index: 4; padding: clamp(28px, 5vh, 64px) 30px 16px; text-align: center; }
.arrival-copy > span { color: #717c7c; font: 900 .68rem/1 var(--font-ui); letter-spacing: .2em; }
.arrival-copy h1 { margin: 9px 0 3px; font: 900 clamp(2.2rem, 5.5vw, 5rem)/.95 var(--font-condensed); letter-spacing: .035em; text-shadow: 0 3px 18px #030506; }
.arrival-copy p { margin: 10px 0 0; color: #bdc5c3; font-size: .92rem; text-shadow: 0 2px 10px #030506; }
.arrival-copy .arrival-subtitle { margin-top: 8px; color: #d7ff31; font: 900 clamp(.82rem, 1.4vw, 1.05rem)/1 var(--font-ui); letter-spacing: .18em; }
.arrival-copy #arrivalMessage { margin-top: 8px; color: #9fa9a7; font-size: .82rem; }

.arrival-stage { position: relative; min-height: 0; overflow: hidden; display: flex; align-items: center; }
.arrival-glow { position: absolute; inset: 0; background: radial-gradient(ellipse at center, transparent 42%, rgba(2,4,5,.34) 100%), linear-gradient(0deg, rgba(3,5,6,.56), transparent 36%); }
.arrival-train-viewport { position: absolute; inset: 0 0 30px; display: flex; align-items: center; overflow: hidden; }
.arrival-train-line { position: relative; z-index: 2; display: flex; align-items: center; gap: 20px; width: max-content; animation: arrivalRolling var(--arrival-train-duration) linear infinite; will-change: transform; }
body.train-hover-ready .arrival-train-line:hover { animation-play-state: paused; }
@keyframes arrivalRolling { from { transform: translateX(0); } to { transform: translateX(-50%); } }

.arrival-car-wrap { position: relative; width: clamp(540px, 55vw, 760px); aspect-ratio: 1200 / 500; flex: none; }
.arrival-car { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; border: 0; background: transparent; cursor: pointer; color: #151918; }
.arrival-car-body { position: absolute; inset: 0 0 14%; overflow: hidden; border: 3px solid #111515; border-top-color: #4e5554; border-bottom-width: 6px; border-radius: 11px 11px 3px 3px; background: linear-gradient(180deg, rgba(255,255,255,.28) 0 1.5%, transparent 2% 49%, rgba(33,38,37,.22) 50% 51%, transparent 52%), repeating-linear-gradient(90deg, rgba(255,255,255,.09) 0 1px, rgba(0,0,0,.045) 1px 5px), linear-gradient(180deg, #bfc4c1 0%, #858c8a 52%, #d0d3cf 54%, #717977 100%); box-shadow: inset 0 3px rgba(255,255,255,.18), inset 0 -18px 28px rgba(25,28,27,.3), 0 28px 42px rgba(0,0,0,.7); transition: filter .2s, transform .25s, box-shadow .25s; }
.arrival-car-body::after { content: ""; position: absolute; inset: 0; z-index: 3; pointer-events: none; background: radial-gradient(ellipse at 11% 105%, rgba(72,45,26,.2), transparent 19%), radial-gradient(ellipse at 43% 108%, rgba(48,35,25,.17), transparent 17%), radial-gradient(ellipse at 78% 106%, rgba(75,45,25,.15), transparent 20%), repeating-linear-gradient(172deg, transparent 0 31px, rgba(255,255,255,.055) 32px, transparent 33px), linear-gradient(180deg, transparent 58%, rgba(24,22,19,.13) 100%); }
.arrival-car:hover .arrival-car-body, .arrival-car:focus-visible .arrival-car-body { filter: brightness(1.08); transform: translateY(-8px); box-shadow: 0 0 0 3px var(--acid), 0 30px 55px rgba(0,0,0,.8); }
.arrival-car:disabled { cursor: not-allowed; }
.arrival-car[data-status="claimed"]:disabled .arrival-car-body,
.arrival-car[data-status="loading"]:disabled .arrival-car-body { filter: brightness(.58) saturate(.72); }
.arrival-car:disabled:hover .arrival-car-body { transform: none; box-shadow: 0 28px 42px rgba(0,0,0,.7); }
.arrival-car[data-status="painted"]:disabled .arrival-car-body,
.arrival-car[data-status="painted"]:disabled:hover .arrival-car-body { filter: none; }
.arrival-windows { position: absolute; z-index: 1; left: 7%; right: 7%; top: 9%; height: 29%; display: grid; grid-template-columns: repeat(8, 1fr); gap: 10px; }
.arrival-windows i { border-radius: 2px; background: linear-gradient(145deg, #0b171c 0%, #293d43 54%, #516268 100%); border: clamp(3px, .4vw, 6px) solid #555e5d; box-shadow: inset 0 0 18px rgba(0,0,0,.95), inset 2px 2px rgba(167,184,186,.12), 0 1px rgba(255,255,255,.18); }
.arrival-doors { position: absolute; z-index: 1; inset: 39% 0 7%; }
.arrival-doors i { position: absolute; top: 0; bottom: 0; width: 2px; background: rgba(29,32,32,.38); box-shadow: 2px 0 rgba(255,255,255,.13); }
.arrival-doors i:nth-child(1) { left: 25%; }.arrival-doors i:nth-child(2) { left: 50%; }.arrival-doors i:nth-child(3) { left: 75%; }
.arrival-art { position: absolute; z-index: 2; inset: 0; width: 100%; height: 100%; object-fit: fill; pointer-events: none; }
.arrival-code { position: absolute; z-index: 4; right: 2%; bottom: 6%; padding: 3px 5px; border: 1px solid rgba(20,23,22,.35); color: #222827; font: 950 .78rem/1 var(--font-ui); letter-spacing: .1em; }
.arrival-status { position: absolute; z-index: 5; left: 18px; bottom: 15px; padding: 7px 10px; background: var(--acid); color: #101313; font: 950 .66rem/1 var(--font-ui); letter-spacing: .12em; box-shadow: 3px 3px 0 rgba(0,0,0,.34); }
.arrival-car.has-art .arrival-status { background: #1c2223; color: #c0c8c6; border: 1px solid #65706f; }
.arrival-car[data-status="claimed"] .arrival-status { background: #ff7c35; color: #121313; border: 0; }
.arrival-car[data-status="mine"] .arrival-status { background: #50a6ff; color: #09121a; border: 0; }
.arrival-car[data-status="loading"] .arrival-status { background: #252b2c; color: #7e8786; border: 1px solid #3c4445; }
.arrival-wheelset { position: absolute; z-index: 3; left: 9%; right: 9%; bottom: 3%; display: flex; justify-content: space-between; pointer-events: none; }
.arrival-wheelset i { width: clamp(48px, 5vw, 72px); aspect-ratio: 1.65 / 1; border-radius: 50%; background: radial-gradient(ellipse at center, #626a69 0 9%, #171a1a 10% 25%, #050606 26% 58%, #343938 59% 71%, #090b0b 72%); border: clamp(5px, .55vw, 8px) solid #242929; box-shadow: inset 0 0 0 2px #090b0b, 0 6px 8px rgba(0,0,0,.8); }
.arrival-track { display: none; position: absolute; left: 0; right: 0; bottom: 32px; height: 20px; background: repeating-linear-gradient(90deg, #40382e 0 9px, #111414 9px 38px); box-shadow: 0 7px 15px rgba(0,0,0,.75); }
.arrival-track span { position: absolute; left: 0; right: 0; height: 4px; background: linear-gradient(180deg, #8a9290, #3d4443); box-shadow: 0 2px #020303; }
.arrival-track span:first-child { top: 1px; }.arrival-track span:last-child { bottom: 1px; }
.arrival-footer { position: relative; z-index: 5; min-height: 42px; background: rgba(7,9,10,.92); }
.arrival-share-actions { display: flex; align-items: center; gap: 7px; }
.arrival-share-actions button { min-height: 30px; padding: 0 11px; border: 1px solid #343c3d; background: #111516; color: #aab2b1; font: 900 .62rem/1 var(--font-ui); letter-spacing: .09em; cursor: pointer; }
.arrival-share-actions button:hover { border-color: var(--acid); color: var(--acid); }
.arrival-share-actions button:first-child { border-color: #8da520; background: rgba(215,255,49,.08); color: var(--acid); }

.topbar {
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 30px;
  border-bottom: 1px solid #2f3738;
  background: rgba(7, 9, 10, .94);
}

.brand { display: flex; align-items: baseline; gap: 10px; white-space: nowrap; }
.brand-mark, .brand-name { font-family: var(--font-condensed); font-weight: 900; letter-spacing: .045em; }
.brand-mark { font-size: 1.55rem; color: var(--acid); transform: skew(-7deg); }
.brand-slash { color: #5c6667; font-weight: 300; }
.brand-name { font-size: 1.25rem; }
.version { color: var(--muted); font: 700 .7rem/1 var(--font-ui); letter-spacing: .1em; }

.status-row { display: flex; align-items: center; gap: 25px; font: 700 .74rem/1 var(--font-ui); letter-spacing: .08em; color: #aab2b1; }
.status-dot { display: inline-block; width: 7px; height: 7px; margin-right: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 9px var(--green); }
.text-button { border: 0; background: transparent; padding: 10px 0; color: #aab2b1; font-weight: 800; letter-spacing: .08em; cursor: pointer; }
.text-button:hover { color: var(--acid); }

main { max-width: 1680px; margin: 0 auto; }

.rail-window { position: relative; height: 218px; overflow: hidden; border-bottom: 1px solid #303637; background: linear-gradient(180deg, rgba(5,8,10,.46), rgba(5,7,8,.26) 58%, rgba(3,5,5,.7)), url("./midnight-rail-yard.png") center 58% / cover no-repeat; }
.rail-heading { position: relative; z-index: 4; display: flex; justify-content: space-between; padding: 14px 30px 0; font: 800 .67rem/1 var(--font-ui); letter-spacing: .14em; color: #788183; }
.rail-instruction { color: #aab2b1; }
.city-glow { position: absolute; inset: 0; opacity: .9; background: linear-gradient(90deg, rgba(4,7,8,.3), transparent 18% 82%, rgba(4,7,8,.3)), linear-gradient(0deg, rgba(5,8,9,.5), transparent 55%); }

.train-viewport { position: absolute; left: 0; right: 0; top: 42px; height: 145px; overflow: hidden; }
.train-line { position: absolute; bottom: 8px; display: flex; gap: 9px; width: max-content; animation: rolling var(--live-train-duration) linear infinite; will-change: transform; }
body.train-hover-ready .train-line:hover { animation-play-state: paused; }
@keyframes rolling { from { transform: translateX(0); } to { transform: translateX(-50%); } }

.rail-car {
  position: relative;
  width: 270px;
  height: 119px;
  flex: none;
  border: 1px solid #111;
  border-radius: 7px 7px 2px 2px;
  overflow: hidden;
  cursor: pointer;
  background:
    linear-gradient(180deg, rgba(255,255,255,.23), transparent 9%, rgba(0,0,0,.09) 10% 11%, transparent 12%),
    repeating-linear-gradient(90deg, rgba(255,255,255,.09) 0 1px, rgba(0,0,0,.05) 1px 4px),
    linear-gradient(180deg, #aeb4b3 0%, #737b7a 56%, #c3c7c4 58%, #7a817f 100%);
  box-shadow: 0 10px 20px rgba(0,0,0,.8);
  transition: filter .2s, transform .2s;
}
.rail-car:hover { filter: brightness(1.18); transform: translateY(-3px); }
.rail-car.selected { box-shadow: 0 0 0 2px var(--acid), 0 0 22px rgba(215,255,49,.34); }
.rail-car .mini-windows { position: absolute; display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; left: 20px; right: 20px; top: 14px; height: 28px; }
.rail-car .mini-windows i { background: linear-gradient(145deg, #142229, #42565c); border: 2px solid #5e6868; box-shadow: inset 0 0 8px #020505; }
.rail-car .mini-art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; pointer-events: none; z-index: 2; }
.rail-car .mini-weathering { position: absolute; inset: 0; z-index: 3; pointer-events: none; background: radial-gradient(ellipse at 14% 108%, rgba(73,44,23,.18), transparent 20%), radial-gradient(ellipse at 71% 110%, rgba(47,34,24,.15), transparent 22%), linear-gradient(180deg, transparent 60%, rgba(22,20,18,.12)); }
.rail-car .mini-code { position: absolute; right: 8px; bottom: 13px; padding: 2px 3px; border: 1px solid rgba(22,25,24,.3); color: #222; font: 900 .66rem/1 var(--font-ui); letter-spacing: .08em; z-index: 4; }
.rail-car::before, .rail-car::after { content: ""; position: absolute; top: 48px; bottom: 8px; width: 1px; background: rgba(25,27,27,.45); z-index: 1; }
.rail-car::before { left: 33.333%; }.rail-car::after { right: 33.333%; }
.rail-car .mini-wheels::before, .rail-car .mini-wheels::after { content: ""; position: absolute; bottom: -7px; width: 30px; height: 17px; border-radius: 50%; background: radial-gradient(ellipse at center, #646b6a 0 10%, #090b0b 12% 58%, #333837 60% 72%, #060707 74%); border: 4px solid #242929; box-shadow: 0 3px 5px rgba(0,0,0,.8); z-index: 4; }
.rail-car .mini-wheels::before { left: 32px; }.rail-car .mini-wheels::after { right: 32px; }

.track { position: absolute; left: 0; right: 0; bottom: 17px; height: 14px; background: repeating-linear-gradient(90deg, #3c342b 0 6px, #101313 6px 25px); }
.track span { position: absolute; left: 0; right: 0; height: 3px; background: linear-gradient(180deg, #858d8b, #3a4140); box-shadow: 0 1px #020303; }
.track span:first-child { top: 1px; }.track span:last-child { bottom: 1px; }

.yard { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: calc(100vh - 324px); }
.toolbox { border-right: 1px solid var(--line); background: rgba(15,18,19,.96); padding: 22px; }
.panel-label { color: #697374; font: 900 .67rem/1 var(--font-ui); letter-spacing: .16em; }

.tool-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0 25px; }
.tool { min-height: 66px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; border: 1px solid #343c3d; background: #171b1c; color: #8d9695; font: 900 .68rem/1 var(--font-ui); letter-spacing: .08em; cursor: pointer; }
.tool[data-tool="line"] { grid-column: 1 / -1; min-height: 48px; flex-direction: row; }
.tool:hover { border-color: #65706f; color: #d7dcda; }
.tool.active { border-color: var(--acid); color: var(--acid); background: rgba(215,255,49,.055); box-shadow: inset 0 -2px var(--acid); }
.tool-icon { position: relative; display: block; width: 23px; height: 23px; }
.spray-icon { width: 14px; height: 24px; border: 2px solid currentColor; border-radius: 2px; }
.spray-icon::before { content: ""; position: absolute; left: 2px; right: 2px; top: -6px; height: 5px; border: 2px solid currentColor; }
.marker-icon { width: 9px; height: 26px; border: 2px solid currentColor; transform: rotate(35deg); }
.marker-icon::after { content:""; position: absolute; left: 0; right: 0; bottom: -6px; margin: auto; border: 4px solid transparent; border-top-color: currentColor; }
.eraser-icon { width: 23px; height: 15px; margin-top: 5px; border: 2px solid currentColor; transform: skew(-20deg); }
.fill-icon { width: 18px; height: 18px; margin-top: 2px; border: 2px solid currentColor; transform: rotate(45deg); }
.fill-icon::after { content:""; position: absolute; width: 6px; height: 8px; border-radius: 50% 50% 55% 55%; right: -10px; bottom: -9px; background: currentColor; }
.line-icon::before { content: ""; position: absolute; left: -1px; top: 10px; width: 26px; height: 3px; border-radius: 3px; background: currentColor; transform: rotate(-27deg); transform-origin: center; }
.line-icon::after { content: ""; position: absolute; width: 6px; height: 6px; right: -1px; top: 2px; border: 2px solid currentColor; border-radius: 50%; background: #171b1c; }

.control-group { padding: 19px 0 22px; border-top: 1px solid #2c3334; }
.control-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 13px; color: #919a99; font: 800 .7rem/1 var(--font-ui); letter-spacing: .11em; }
.control-title output { color: #cdd3d1; font-variant-numeric: tabular-nums; }
.cap-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.cap-button { min-height: 48px; display: grid; grid-template-columns: 28px 1fr; align-items: center; gap: 4px; padding: 0 7px; border: 1px solid #343c3d; background: #171b1c; color: #8d9695; font: 900 .57rem/1.05 var(--font-ui); letter-spacing: .055em; text-align: left; cursor: pointer; }
.cap-button:hover { border-color: #65706f; color: #d7dcda; }
.cap-button.active { border-color: var(--acid); background: rgba(215,255,49,.055); color: var(--acid); box-shadow: inset 0 -2px var(--acid); }
.cap-mark { position: relative; display: block; justify-self: center; width: 16px; height: 16px; border: 2px solid currentColor; border-radius: 50%; }
.cap-button[data-cap="lego"] .cap-mark { width: 17px; height: 15px; border-radius: 4px 4px 7px 7px; }
.cap-button[data-cap="lego"] .cap-mark::before { content: ""; position: absolute; left: 4px; top: -6px; width: 5px; height: 4px; border: 2px solid currentColor; border-bottom: 0; border-radius: 2px 2px 0 0; }
.cap-button[data-cap="lego"] .cap-mark::after { content: ""; position: absolute; left: 4px; top: 4px; width: 5px; height: 3px; border-radius: 50%; background: currentColor; }
.cap-button[data-cap="ny-fat"] .cap-mark { width: 25px; height: 12px; border-radius: 50%; box-shadow: inset 0 0 0 3px #171b1c; background: currentColor; }
.cap-button[data-cap="chisel"] .cap-mark { width: 24px; height: 8px; border-radius: 1px; transform: rotate(-18deg) skewX(-17deg); }
.cap-control.is-idle .control-title output { color: #697374; }
.swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 7px; }
.swatch { aspect-ratio: 1; border: 1px solid rgba(255,255,255,.35); cursor: pointer; padding: 0; }
.swatch.active { box-shadow: 0 0 0 2px #0f1213, 0 0 0 4px #fff; }
.custom-color { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; color: #798283; font: 800 .65rem/1 var(--font-ui); letter-spacing: .1em; }
.custom-color input { width: 42px; height: 24px; padding: 0; border: 1px solid #596262; background: transparent; cursor: pointer; }
input[type="range"] { width: 100%; accent-color: var(--acid); cursor: pointer; }

.paint-bay { min-width: 0; display: grid; grid-template-rows: auto 1fr auto; background: linear-gradient(180deg, rgba(8,11,12,.68), rgba(6,8,9,.82)), url("./midnight-rail-yard.png") center 56% / cover no-repeat; }
.bay-header, .bay-footer { min-height: 62px; display: flex; justify-content: space-between; align-items: center; padding: 0 27px; border-bottom: 1px solid var(--line); background: rgba(13,16,17,.76); }
.bay-header > div:first-child { display: flex; align-items: baseline; gap: 15px; }
.bay-header strong { font-family: var(--font-condensed); font-size: 1.12rem; letter-spacing: .08em; }
.history-actions { display: flex; gap: 7px; }
.history-actions button { min-width: 39px; height: 34px; border: 1px solid #394142; background: #161a1b; cursor: pointer; font-weight: 800; }
.history-actions button:hover:not(:disabled) { border-color: var(--acid); color: var(--acid); }
.history-actions button:disabled { opacity: .28; cursor: not-allowed; }
.history-actions .clear-button { width: auto; padding: 0 14px; font-size: .68rem; letter-spacing: .1em; }

.bay-stage { position: relative; min-height: 380px; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 50px 44px 34px; overflow: hidden; }
.bay-stage::before { content:""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at center, transparent 42%, rgba(0,0,0,.34) 100%), linear-gradient(180deg, rgba(0,0,0,.28), transparent 30%, transparent 72%, rgba(0,0,0,.4)); }
.work-lights { position: absolute; top: 0; left: 9%; right: 9%; display: flex; justify-content: space-between; }
.work-lights i { width: 90px; height: 115px; background: linear-gradient(180deg, rgba(215,255,49,.18), transparent 72%); clip-path: polygon(42% 0, 58% 0, 100% 100%, 0 100%); }

.editor-viewport { position: relative; z-index: 2; width: min(100%, 1340px); overflow: hidden; overscroll-behavior: contain; }
.editor-viewport.can-pan, .editor-viewport.is-panning { cursor: grab; box-shadow: inset 0 0 0 1px rgba(215,255,49,.45); }
.editor-viewport.is-panning { cursor: grabbing; }
.editor-viewport.can-pan #paintCanvas, .editor-viewport.is-panning #paintCanvas { cursor: inherit !important; }
.editor-zoom-stage { position: relative; width: 100%; aspect-ratio: 5 / 1; }
.editor-shell { position: relative; width: 100%; height: 100%; transform-origin: top left; border: 3px solid #111515; border-top-color: #4e5554; border-bottom-width: 6px; border-radius: 11px 11px 3px 3px; overflow: hidden; background: linear-gradient(180deg, rgba(255,255,255,.28) 0 1.5%, transparent 2% 49%, rgba(33,38,37,.22) 50% 51%, transparent 52%), repeating-linear-gradient(90deg, rgba(255,255,255,.08) 0 1px, rgba(0,0,0,.04) 1px 4px), linear-gradient(180deg, #c3c7c4 0%, #858c8a 52%, #d1d4d0 54%, #727a78 100%); box-shadow: inset 0 3px rgba(255,255,255,.18), inset 0 -18px 28px rgba(25,28,27,.3), 0 26px 40px rgba(0,0,0,.68); }
.editor-shell::after { content: ""; position: absolute; inset: 0; z-index: 4; pointer-events: none; background: radial-gradient(ellipse at 12% 106%, rgba(72,45,26,.16), transparent 18%), radial-gradient(ellipse at 45% 108%, rgba(48,35,25,.14), transparent 17%), radial-gradient(ellipse at 81% 107%, rgba(75,45,25,.13), transparent 20%), repeating-linear-gradient(172deg, transparent 0 31px, rgba(255,255,255,.045) 32px, transparent 33px), linear-gradient(180deg, transparent 61%, rgba(24,22,19,.1) 100%); }
.editor-car-details { position: absolute; inset: 0; pointer-events: none; }
.window-row { position: absolute; display: grid; grid-template-columns: repeat(8, 1fr); gap: 12px; left: 7%; right: 7%; top: 9%; height: 27%; }
.window-row i { border-radius: 2px; background: linear-gradient(145deg, #0b171c 0%, #293d43 54%, #516268 100%); border: clamp(3px, .45vw, 6px) solid #555e5d; box-shadow: inset 0 0 18px rgba(0,0,0,.95), inset 2px 2px rgba(167,184,186,.12), 0 1px rgba(255,255,255,.18); }
.door-lines { position: absolute; inset: 38% 0 7%; }
.door-lines i { position: absolute; top: 0; bottom: 0; width: 2px; background: rgba(29,32,32,.38); box-shadow: 2px 0 rgba(255,255,255,.13); }
.door-lines i:nth-child(1) { left: 25%; }.door-lines i:nth-child(2) { left: 50%; }.door-lines i:nth-child(3) { left: 75%; }
.car-code { position: absolute; right: 2%; bottom: 7%; color: #272b2a; font: 900 clamp(.5rem, 1vw, .78rem)/1 var(--font-ui); }
#paintCanvas { position: absolute; inset: 0; z-index: 3; width: 100%; height: 100%; cursor: crosshair; touch-action: none; }
.wheel-set { position: relative; z-index: 1; width: min(94%, 1020px); height: 30px; margin-top: -4px; display: flex; justify-content: space-around; }
.wheel-set i { width: 65px; height: 36px; border-radius: 50%; background: radial-gradient(ellipse at center, #626a69 0 9%, #171a1a 10% 25%, #050606 26% 58%, #343938 59% 71%, #090b0b 72%); border: 7px solid #242929; box-shadow: inset 0 0 0 2px #090b0b, 0 6px 8px rgba(0,0,0,.8); }
.empty-hint { position: relative; z-index: 2; margin: 19px 0 0; color: #687172; font: 800 .66rem/1 var(--font-ui); letter-spacing: .14em; }
.mobile-hint, .mobile-canvas-bar { display: none; }

/* Long-form subway car based on the approved reference. */
.arrival-car-wrap { width: clamp(900px, 84vw, 1480px); aspect-ratio: 5 / 1; }
.arrival-car-body { inset: 0; overflow: visible; border: 0; border-radius: 0; background: transparent; box-shadow: none; filter: drop-shadow(0 24px 22px rgba(0,0,0,.74)); }
.arrival-car-body::after { content: none; }
.arrival-car:hover .arrival-car-body,
.arrival-car:focus-visible .arrival-car-body { filter: brightness(1.06) drop-shadow(0 30px 25px rgba(0,0,0,.8)); transform: translateY(-7px); box-shadow: none; }
.arrival-car:disabled:hover .arrival-car-body { filter: drop-shadow(0 24px 22px rgba(0,0,0,.74)); transform: none; box-shadow: none; }
.arrival-car[data-status="claimed"]:disabled .arrival-car-body,
.arrival-car[data-status="loading"]:disabled .arrival-car-body { filter: brightness(.58) saturate(.72) drop-shadow(0 24px 22px rgba(0,0,0,.74)); }
.arrival-car-base { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.arrival-windows, .arrival-doors, .arrival-wheelset { display: none; }
.arrival-art { inset: 4% 3% 20%; z-index: 2; width: 94%; height: 76%; object-fit: contain; }
.arrival-line-badge,
.editor-line-badge,
.mini-line-badge { display: grid; place-items: center; border-radius: 50%; background: var(--line-color); color: var(--line-ink); font-family: var(--font-condensed); font-weight: 950; line-height: 1; box-shadow: inset 0 0 0 2px rgba(255,255,255,.18), 0 0 0 2px #111515; }
.arrival-line-badge { position: absolute; z-index: 5; left: 5.5%; top: 25%; width: clamp(28px, 2.5vw, 42px); aspect-ratio: 1; font-size: clamp(.95rem, 1.5vw, 1.45rem); }
.arrival-code { z-index: 5; left: 9.4%; right: auto; top: 27%; bottom: auto; padding: 4px 7px; border: 1px solid #454c4b; background: #101414; color: #e2e5e2; font-size: clamp(.58rem, .75vw, .78rem); letter-spacing: .12em; box-shadow: 0 1px 3px rgba(0,0,0,.6); }
.arrival-status { left: 50%; bottom: 4%; transform: translateX(-50%); white-space: nowrap; }
.train-coupler { position: absolute; z-index: 0; display: block; object-fit: contain; pointer-events: none; }
.arrival-car .train-coupler { right: -38px; top: 65%; width: clamp(52px, 4vw, 70px); height: 24%; filter: drop-shadow(0 5px 4px rgba(0,0,0,.8)); }
.car-story-share { position: absolute; z-index: 8; right: 3.8%; bottom: 3%; min-height: 32px; padding: 0 10px; border: 1px solid #9bb823; background: rgba(9,12,12,.94); color: var(--acid); font: 950 .68rem/1 var(--font-ui); letter-spacing: .08em; cursor: pointer; box-shadow: 3px 3px 0 rgba(0,0,0,.48); transition: opacity .18s ease, background-color .18s ease, color .18s ease; }
.car-story-share::before { content: ""; position: absolute; inset: -6px; }
.car-story-share:hover { background: var(--acid); color: #101313; }
.car-story-share:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 rgba(0,0,0,.48); }
.car-story-share:disabled { opacity: .6; cursor: wait; }

@media (hover: hover) and (pointer: fine) {
  .car-story-share { opacity: 0; pointer-events: none; }
  .arrival-car-wrap:hover .car-story-share,
  .arrival-car-wrap:focus-within .car-story-share { opacity: 1; pointer-events: auto; }
}

.rail-car { width: 410px; height: auto; aspect-ratio: 5 / 1; overflow: visible; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
.rail-car:hover { filter: brightness(1.12) drop-shadow(0 8px 8px rgba(0,0,0,.72)); transform: translateY(-3px); }
.rail-car.selected { box-shadow: none; filter: drop-shadow(0 0 8px rgba(215,255,49,.58)); }
.rail-car::before, .rail-car::after, .rail-car .mini-windows, .rail-car .mini-weathering, .rail-car .mini-wheels { display: none; content: none; }
.rail-car .mini-car-base { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.rail-car .mini-art { inset: 4% 3% 20%; width: 94%; height: 76%; object-fit: contain; }
.rail-car .mini-line-badge { position: absolute; z-index: 5; left: 5.5%; top: 24%; width: 18px; aspect-ratio: 1; font-size: .7rem; box-shadow: inset 0 0 0 1px rgba(255,255,255,.2), 0 0 0 1px #111515; }
.rail-car .mini-code { z-index: 5; left: 10.5%; right: auto; top: 27%; bottom: auto; padding: 2px 4px; border-color: #444b4a; background: #101414; color: #e0e3e0; font-size: .48rem; letter-spacing: .08em; }
.rail-car .train-coupler { right: -17px; top: 64%; width: 28px; height: 25%; filter: drop-shadow(0 3px 2px rgba(0,0,0,.86)); }

.editor-shell { overflow: visible; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
.editor-shell::after { content: none; }
.editor-car-details, .wheel-set { display: none; }
.editor-car-base { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
#paintCanvas { inset: 4% 3% 20%; z-index: 3; width: 94%; height: 76%; }
.editor-line-badge { position: absolute; z-index: 5; left: 5.5%; top: 25%; width: clamp(22px, 2.4vw, 37px); aspect-ratio: 1; color: var(--line-ink, #fff); font-size: clamp(.78rem, 1.35vw, 1.28rem); pointer-events: none; }
.car-code { z-index: 5; left: 9.6%; right: auto; top: 27%; bottom: auto; padding: 3px 6px; border: 1px solid #454c4b; background: #101414; color: #e2e5e2; font-size: clamp(.48rem, .72vw, .72rem); letter-spacing: .1em; pointer-events: none; }

.bay-footer { border-top: 1px solid var(--line); border-bottom: 0; color: #7e8887; font: 800 .68rem/1 var(--font-ui); letter-spacing: .12em; }
.send-button { min-width: 196px; height: 43px; border: 0; background: var(--acid); color: #111; font: 950 .78rem/1 var(--font-ui); letter-spacing: .09em; cursor: pointer; transform: skew(-5deg); box-shadow: 5px 5px 0 #4c5817; }
.send-button > * { transform: skew(5deg); }
.send-button span { margin-left: 12px; font-size: 1.15rem; }
.send-button:hover { filter: brightness(1.08); transform: skew(-5deg) translateY(-2px); }
.send-button:active { transform: skew(-5deg) translate(3px, 3px); box-shadow: 2px 2px 0 #4c5817; }

footer { min-height: 40px; display: flex; justify-content: space-between; align-items: center; padding: 0 30px; border-top: 1px solid #242a2b; color: #5f6868; font: 800 .6rem/1 var(--font-ui); letter-spacing: .13em; }

dialog { width: min(92vw, 520px); border: 1px solid #667171; padding: 34px; color: var(--ink); background: #111617; box-shadow: 0 30px 90px rgba(0,0,0,.8); }
dialog::backdrop { background: rgba(0,0,0,.8); backdrop-filter: blur(3px); }
dialog h2 { margin: 10px 0 20px; font: 900 2rem/1 var(--font-condensed); text-transform: uppercase; }
dialog ol { padding-left: 22px; color: #bec6c4; line-height: 1.65; }
dialog p { color: #828c8b; font-size: .9rem; line-height: 1.55; }
.dialog-close { position: absolute; right: 15px; top: 12px; border: 0; background: transparent; font-size: 1.6rem; cursor: pointer; color: #87918f; }
.tag-dialog form { display: grid; gap: 10px; margin-top: 22px; }
.tag-dialog label { color: #8f9998; font: 900 .68rem/1 var(--font-ui); letter-spacing: .13em; }
.tag-dialog input { width: 100%; height: 54px; border: 1px solid #505b5b; background: #090d0e; color: var(--ink); padding: 0 15px; font: 900 1.2rem/1 var(--font-condensed); letter-spacing: .08em; text-transform: uppercase; }
.tag-dialog input:focus { border-color: var(--acid); }
.tag-error { min-height: 18px; color: #ff806d; font-size: .78rem; }
.claim-button { height: 48px; border: 0; background: var(--acid); color: #111; font: 950 .76rem/1 var(--font-ui); letter-spacing: .1em; cursor: pointer; box-shadow: 4px 4px 0 #4c5817; }
.claim-button:disabled, .send-button:disabled { opacity: .55; cursor: wait; }

.toast { position: fixed; z-index: 20; left: 50%; bottom: 25px; padding: 15px 20px; background: var(--acid); color: #101313; font: 900 .75rem/1 var(--font-ui); letter-spacing: .1em; transform: translate(-50%, 140%); transition: transform .32s cubic-bezier(.2,.8,.2,1); box-shadow: 6px 6px 0 rgba(0,0,0,.45); }
.toast.show { transform: translate(-50%, 0); }

@media (max-width: 850px) {
  .arrival-header { padding: 0 18px; }
  .arrival-actions { gap: 10px; }
  .train-speed-control > span { display: none; }
  .arrival-copy { padding-top: 28px; }
  .arrival-car-wrap { width: 900px; min-width: 900px; }
  .topbar { align-items: flex-start; flex-direction: column; padding: 14px 18px; gap: 8px; }
  .status-row { width: 100%; justify-content: space-between; gap: 8px; }
  .rail-heading { padding-left: 18px; padding-right: 18px; }
  .rail-instruction { display: none; }
  .yard { grid-template-columns: 1fr; }
  .toolbox { border-right: 0; border-bottom: 1px solid var(--line); padding: 15px 18px; }
  .tool-grid { grid-template-columns: repeat(5, 1fr); margin: 11px 0 14px; }
  .tool { min-height: 56px; }
  .tool[data-tool="line"] { grid-column: auto; min-height: 56px; flex-direction: column; }
  .tool-controls { display: grid; grid-template-columns: 1fr 1fr; column-gap: 12px; }
  .control-group { width: auto; padding: 14px 0 5px; }
  .cap-control, .color-control { grid-column: 1 / -1; }
  .cap-grid { grid-template-columns: repeat(4, 1fr); }
  .cap-button { min-height: 44px; grid-template-columns: 24px 1fr; }
  .swatches { grid-template-columns: repeat(12, 1fr); }
  .bay-stage { min-height: 360px; align-items: center; overflow: hidden; padding: 24px 14px 20px; }
  .mobile-canvas-bar { position: relative; z-index: 3; width: 100%; display: grid; grid-template-columns: 1fr 44px 62px 44px auto; align-items: center; margin-bottom: 10px; border: 1px solid #353e3f; background: rgba(12,16,17,.92); }
  .mobile-canvas-bar > span { padding-left: 12px; color: #75807f; font: 900 .68rem/1 var(--font-ui); letter-spacing: .13em; }
  .mobile-canvas-bar button { min-width: 44px; min-height: 44px; border: 0; border-left: 1px solid #353e3f; background: #171c1d; color: #d6dcda; font: 900 1.05rem/1 var(--font-ui); cursor: pointer; }
  .mobile-canvas-bar button:disabled { opacity: .3; cursor: not-allowed; }
  .mobile-canvas-bar output { display: grid; place-items: center; min-height: 44px; border-left: 1px solid #353e3f; color: var(--acid); font: 900 .7rem/1 var(--font-ui); }
  .mobile-canvas-bar .move-canvas-button { padding: 0 13px; color: #aeb7b5; font-size: .68rem; letter-spacing: .09em; }
  .mobile-canvas-bar .move-canvas-button[aria-pressed="true"] { background: var(--acid); color: #101313; }
  .editor-viewport { width: 100%; height: clamp(190px, 32vh, 270px); border: 1px solid rgba(100,111,111,.44); background: rgba(3,5,6,.58); touch-action: none; }
  .editor-viewport.is-moving { cursor: grab; box-shadow: inset 0 0 0 2px var(--acid); }
  .editor-viewport.is-moving:active { cursor: grabbing; }
  .editor-viewport.is-moving #paintCanvas { cursor: grab !important; }
  .editor-zoom-stage { aspect-ratio: auto; }
  .empty-hint { align-self: center; }
  .desktop-hint { display: none; }
  .mobile-hint { display: block; max-width: 92vw; text-align: center; line-height: 1.45; }
  .bay-header, .bay-footer { padding: 0 18px; }
}

@media (max-width: 520px) {
  .arrival-screen { grid-template-rows: 64px auto minmax(0, 1fr) 56px; }
  .arrival-screen { background-position: 47% center; }
  .arrival-live, .arrival-header .version { display: none; }
  .train-speed-control button { min-height: 30px; padding: 0 7px; font-size: .65rem; }
  .arrival-copy { padding: 26px 16px 5px; }
  .arrival-copy h1 { font-size: 2.25rem; }
  .arrival-copy p { font-size: .82rem; }
  .arrival-car-wrap { width: 760px; min-width: 760px; }
  .car-story-share { min-height: 34px; padding: 0 10px; font-size: .68rem; }
  .arrival-train-viewport { bottom: 22px; }
  .arrival-footer { justify-content: center; padding: 0 8px; }
  .arrival-footer > span { display: none; }
  .arrival-share-actions { width: 100%; gap: 5px; }
  .arrival-share-actions button { flex: 1; min-height: 42px; padding: 0 5px; font-size: .58rem; }
  .brand-name { font-size: 1rem; }
  .brand-mark { font-size: 1.25rem; }
  .version, .status-row > span { display: none; }
  .status-row { justify-content: flex-end; }
  .rail-window { height: 190px; }
  .rail-car { width: 360px; height: auto; }
  .train-viewport { height: 120px; }
  .tool { font-size: .56rem; }
  .bay-header > div:first-child { gap: 8px; }
  .bay-stage { min-height: 340px; }
  .empty-hint { font-size: .55rem; text-align: center; }
  .bay-footer > span { display: none; }
  .send-button { width: 100%; }
  footer span:nth-child(2) { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .arrival-train-line, .train-line { animation-duration: 120s; }
  *, *::before, *::after { scroll-behavior: auto !important; }
}
