/* Night platform departure board: graphite ramp, off-white text, Asakusa line rose as the only chrome accent. */
:root {
  color-scheme: dark;
  --bg: #0e0f11;
  --surface: #16171a;
  --surface-raised: #1f2125;
  --hairline: rgb(236 237 240 / 0.08);
  --hairline-strong: rgb(236 237 240 / 0.24);
  --text: #ecedf0;
  --text-2: #a4a7ae;
  --text-3: #71747c;
  --line: #e85298;
  --line-tint: rgb(232 82 152 / 0.12);
  --soon: #f5a524;
  --alert: #ff7a85;
  --ease: cubic-bezier(0.2, 0, 0, 1);
  /* Soft corners: controls 10, rows 10, panels 14, dialog 18. Station numbers stay full circles. */
  --radius-s: 6px;
  --radius-m: 10px;
  --radius-l: 14px;
  --radius-xl: 18px;

  color: var(--text);
  background: var(--bg);
  --font-text: "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  /* Numbers use the monospace face so times line up; any Japanese inside falls back to BIZ UDPGothic. */
  --font-number: "Google Sans Code", var(--font-text);

  font-family: var(--font-text);
  font-synthesis: none;
  line-height: 1.6;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
body { min-width: 1024px; margin: 0; background: var(--bg); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
::selection { background: var(--line-tint); color: var(--text); }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }

/* One screen, no page scroll: departures on the top half, the network map on the bottom half. */
.dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) minmax(0, 1fr);
  grid-template-areas: "top" "board" "route";
  gap: 8px;
  height: 100vh;
  min-height: 600px;
  padding: 0 12px 8px;
}

.topbar { grid-area: top; display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 12px; padding: 6px 0; }
.station-picker { display: flex; align-items: center; gap: 8px; min-width: 0; }
.station-code { flex: 0 0 44px; width: 44px; height: 44px; display: flex; flex-direction: column; align-items: center; justify-content: center; border: 4px solid var(--line-color, var(--line)); border-radius: 50%; font-family: var(--font-number); font-size: 0.75rem; font-weight: 700; line-height: 1.15; }
.station-picker select { width: 240px; height: 36px; padding: 4px 28px 4px 10px; border: 1px solid var(--hairline-strong); border-radius: var(--radius-m); background: var(--surface); color: var(--text); font: inherit; font-size: 1rem; cursor: pointer; transition: border-color 120ms var(--ease); }
.station-picker select#line-select { width: 160px; }
.station-picker select#station-select { width: 220px; }
.station-picker select:hover { border-color: var(--text-2); }
#clock-canvas { width: 176px; }
#clock-canvas canvas { display: block; width: 100% !important; height: auto !important; }
.topbar-end { justify-self: end; display: flex; align-items: center; gap: 8px; min-width: 0; }
.connections { display: grid; grid-auto-flow: column; grid-template-rows: repeat(3, auto); min-width: 0; margin: 0; border-left: 1px solid var(--hairline); color: var(--text-2); font-size: 0.75rem; line-height: 1.5; }
.connections > span { padding: 0 10px; border-right: 1px solid var(--hairline); white-space: nowrap; }
.connections-label { grid-row: 1 / -1; align-self: center; color: var(--text-3); }

/* Departures: one column per direction, the next train of each column is the brightest thing on screen. */
.departures { grid-area: board; display: flex; flex-direction: column; min-height: 0; overflow-y: auto; }
#station-title:focus { outline: none; }
.station-data-note { margin: 0 0 6px; padding: 6px 10px; border-radius: var(--radius-m); background: var(--surface); color: var(--text-2); font-size: 0.875rem; }
.board { flex: 1; display: grid; grid-auto-columns: minmax(0, 1fr); grid-auto-flow: column; gap: 8px; min-height: 0; }
.board:empty { display: none; }
.board-column { display: flex; flex-direction: column; min-height: 0; container-type: inline-size; }
.column-title { margin: 0; padding: 0 8px 4px; color: var(--text-2); font-size: 0.875rem; font-weight: 400;  display: flex; align-items: baseline; gap: 12px; }
.column-through { color: var(--text-3); font-size: 0.75rem; }
/* Fixed table: every row is one line tall and nothing wraps. Text wider than its cell scrolls sideways instead. */
.train-list { display: grid; grid-template-columns: auto 48px minmax(0, 1fr) 80px 72px; gap: 4px 12px; margin: 0; padding: 0; list-style: none; }
.train-list:empty { display: none; }
.train {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: subgrid;
  align-items: center;
  height: 40px;
  padding: 0 10px;
  border-radius: var(--radius-m);
  background: var(--surface);
  overflow: hidden;
}
.train.is-next { background: var(--surface-raised); }
.train-detail, .train-meta { display: contents; }
.detail-heading .service { border-radius: var(--radius-s); padding: 0 7px; }
.service { grid-column: 1; justify-self: start; display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: var(--radius-s); background: var(--service-background, #4a4c53); color: var(--service-foreground, #fff); font-family: var(--font-text); font-size: 0.75rem; font-weight: 700; white-space: nowrap; }
.departure-time { grid-column: 2; color: var(--text-2); font-family: var(--font-number); font-size: 0.875rem; font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; }
.destination { grid-column: 3; min-width: 0; color: var(--text-2); font-size: 1rem; line-height: 1.5; }
.is-next .destination { color: var(--text); font-weight: 700; }
/* Several notes share one cell and take turns (sketch.js rotates .is-active), so the row height never changes. */
.train-notes { grid-column: 4; position: relative; min-width: 0; height: 1.4em; font-size: 0.75rem; }
.train-tag { position: absolute; inset: 0; color: var(--text-3); line-height: 1.4; opacity: 0; transition: opacity 200ms var(--ease); }
.train-tag.is-active { opacity: 1; }
.train-tag.is-warn { color: var(--soon); font-weight: 700; }
.train-tag.is-alert { color: var(--alert); font-weight: 700; }
.remaining-value { grid-column: 5; color: var(--text-2); font-family: var(--font-number); font-size: 1.25rem; font-weight: 500; font-variant-numeric: tabular-nums; line-height: 1.2; text-align: right; white-space: nowrap; }
.is-next .remaining-value { color: var(--text); font-size: 1.5rem; font-weight: 700; }
.remaining-value.is-soon, .is-next .remaining-value.is-soon { color: var(--soon); font-family: var(--font-text); font-size: 0.875rem; font-weight: 700; }
.remaining-unit { margin-left: 4px; color: var(--text-3); font-family: var(--font-text); font-size: 0.75rem; font-weight: 400; }
.marquee { overflow: hidden; white-space: nowrap; }
.marquee-text { display: inline-block; }
.marquee-copy { padding-left: 48px; }
.marquee.is-scrolling .marquee-text { animation: marquee var(--marquee-duration, 8s) linear infinite; }
@keyframes marquee { 0%, 20% { transform: translateX(0); } 100% { transform: translateX(var(--marquee-shift, 0)); } }
@media (prefers-reduced-motion: reduce) { .marquee.is-scrolling .marquee-text { animation: none; } }
/* Columns under 500px (most PC widths, Sengakuji's three columns): two fixed lines per row,
   type and time above, destination and notes below. */
@container (max-width: 500px) {
  .train-list { grid-template-columns: minmax(0, 1fr) 64px 56px; column-gap: 8px; }
  .train { grid-template-rows: 22px 22px; height: 52px; padding: 0 8px; }
  .train-meta { grid-column: 1 / 3; grid-row: 1; display: flex; align-items: center; gap: 4px; min-width: 0; overflow: hidden; }
  .departure-time { font-size: 0.8125rem; }
  .destination { grid-column: 1; grid-row: 2; }
  .train-notes { grid-column: 2; grid-row: 2; }
  .remaining-value { grid-column: 3; grid-row: 1 / 3; }
  .remaining-value.is-soon, .is-next .remaining-value.is-soon { font-size: 0.75rem; }
}
.column-empty { margin: 0; padding: 10px 8px; border-radius: var(--radius-m); background: var(--surface); color: var(--text-3); text-align: center; }
.empty-state { margin: 0; padding: 24px 16px; border-radius: var(--radius-l); background: var(--surface); color: var(--text-2); text-align: center; }

/* Network map: Asakusa and all Keikyu lines at a fixed extent. */
.positions { grid-area: route; position: relative; display: flex; flex-direction: column; min-height: 0; border-radius: var(--radius-l); background: var(--surface); overflow: hidden; }
.network-map { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; scrollbar-color: var(--text-3) transparent; }
.network-map svg { display: block; }
.net-edge { stroke-width: 4; stroke-linecap: round; }
.net-link { stroke: var(--text-3); stroke-width: 2; stroke-dasharray: 3 4; stroke-linecap: round; }
.net-station { cursor: pointer; }
.net-station circle { stroke-width: 2.5; }
.net-label { fill: var(--text-2); font-size: 11px; }
.net-label.is-vertical { writing-mode: vertical-rl; text-anchor: end; }
.net-label.is-left { text-anchor: end; }
.net-label.is-stub { fill: var(--text-3); font-size: 10px; }
.net-station:hover .net-label, .net-station.is-selected .net-label { fill: var(--text); font-weight: 700; }
.net-station:focus-visible, .net-train:focus-visible { outline: 2px solid var(--text); }
.net-train { cursor: pointer; }
.net-train polygon { stroke: var(--surface); stroke-width: 1.5; stroke-linejoin: round; }
.net-train.is-selected polygon { stroke: var(--text); stroke-width: 2; }
.position-detail { position: absolute; right: 8px; bottom: 8px; width: 360px; z-index: 2; padding: 10px 14px; border: 1px solid var(--hairline-strong); border-radius: var(--radius-l); background: var(--surface-raised); box-shadow: 0 8px 24px rgb(0 0 0 / 0.4); }
.detail-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 0.875rem; }
.detail-close { margin-left: auto; height: 28px; padding: 0 10px; border: 0; border-radius: var(--radius-m); background: transparent; color: var(--text-2); font: inherit; cursor: pointer; transition: background-color 120ms var(--ease); }
.detail-close:hover { background: var(--hairline); color: var(--text); }
.detail-location { margin: 6px 0; font-size: 1rem; }
.detail-table { display: grid; grid-template-columns: auto 1fr; margin: 0; border-top: 1px solid var(--hairline); font-size: 0.75rem; }
.detail-table dt, .detail-table dd { margin: 0; padding: 4px 8px 4px 0; border-bottom: 1px solid var(--hairline); }
.detail-table dt { color: var(--text-3); }
.detail-table dd { color: var(--text-2); font-family: var(--font-number); }
.position-delay { margin: 4px 0 0; color: var(--alert); font-size: 0.875rem; }

/* Small PC screens: give the departure columns the room, the route map still fits its trains. */
@media (max-width: 1100px) {
  .board { gap: 8px; }
  .station-picker select#line-select { width: 128px; }
  .station-picker select#station-select { width: 184px; }
}
/* Icon buttons (Lucide) and the settings dialog that holds data sources and licences. */
.icon-button { display: grid; place-items: center; flex: 0 0 auto; width: 36px; height: 36px; padding: 0; border: 1px solid var(--hairline-strong); border-radius: var(--radius-m); background: var(--surface); color: var(--text-2); cursor: pointer; transition: background-color 120ms var(--ease), color 120ms var(--ease); }
.icon-button:hover { background: var(--surface-raised); color: var(--text); }
.icon-button svg { width: 18px; height: 18px; stroke-width: 1.75; }
.settings { width: min(480px, calc(100vw - 32px)); padding: 14px 16px 16px; border: 1px solid var(--hairline-strong); border-radius: var(--radius-xl); background: var(--surface-raised); color: var(--text); }
.settings::backdrop { background: rgb(0 0 0 / 0.55); }
.settings-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.settings-head h2 { margin: 0; font-size: 1.125rem; }
.settings-section + .settings-section { margin-top: 12px; }
.settings-section h3 { margin: 0 0 4px; color: var(--text-2); font-size: 0.8125rem; font-weight: 400; }
.settings-table { display: grid; grid-template-columns: 7.5em 1fr; margin: 0; border-radius: var(--radius-m); background: var(--surface); overflow: hidden; font-size: 0.875rem; }
.settings-table dt, .settings-table dd { margin: 0; padding: 6px 10px; }
.settings-table dt { color: var(--text-3); }
.settings-table dt:not(:first-of-type), .settings-table dd:not(:first-of-type) { border-top: 1px solid var(--hairline); }
.settings-table dt:empty { border-top-color: transparent; }
.settings a { color: var(--text); text-underline-offset: 3px; }

/* Company: a two-way switch in the top bar and a first-visit chooser.
   Line-number rings (same shape as the station code) stand in for icons; they carry the only colour. */
.line-marks { display: inline-flex; gap: 4px; }
.line-mark { display: inline-grid; place-items: center; width: 40px; height: 40px; border: 4px solid var(--mark); border-radius: 50%; background: var(--surface); color: var(--text); font-family: var(--font-number); font-size: 0.875rem; font-weight: 700; line-height: 1; }
.line-mark.is-small { width: 18px; height: 18px; border-width: 2.5px; font-size: 0.5rem; }
.company-switch { display: flex; flex: 0 0 auto; gap: 2px; padding: 3px; border: 1px solid var(--hairline-strong); border-radius: var(--radius-m); background: var(--surface); }
.company-switch button { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px 0 6px; border: 0; border-radius: var(--radius-s); background: transparent; color: var(--text-3); font: inherit; font-size: 0.875rem; cursor: pointer; transition: background-color 120ms var(--ease), color 120ms var(--ease); }
.company-switch button .line-marks { gap: 2px; }
.company-switch button:not([aria-pressed="true"]) .line-mark { opacity: 0.45; }
.company-switch button:hover { color: var(--text); }
.company-switch button[aria-pressed="true"] { background: var(--surface-raised); color: var(--text); font-weight: 700; }
.company-dialog h2 { margin: 0; font-size: 1.125rem; }
.company-hint { margin: 2px 0 12px; color: var(--text-3); font-size: 0.8125rem; }
.company-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.company-choice { display: grid; align-content: start; justify-items: start; gap: 10px; padding: 16px; border: 1px solid var(--hairline); border-radius: var(--radius-l); background: var(--surface); color: var(--text); font: inherit; text-align: left; cursor: pointer; transition: border-color 120ms var(--ease), background-color 120ms var(--ease); }
.company-choice:hover { border-color: var(--hairline-strong); background: var(--bg); }
.company-choice:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.company-name { font-size: 1.125rem; font-weight: 700; line-height: 1.3; }
.company-lines { display: flex; flex-wrap: wrap; gap: 2px 12px; margin-top: -4px; }
.company-lines span { color: var(--text-2); font-size: 0.8125rem; }
