:root {
  --bg: #ffffff;
  --ink: #16251f;
  --muted: #5f746b;
  --panel: rgba(255, 255, 255, 0.98);
  --line: #d9dee5;
  --green: #0f766e;
  --deep: #1f2937;
  --blue: #1b68d1;
  --orange: #f2a93b;
  --red: #f04438;
  --shadow: 0 14px 36px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: #ffffff;
  font-family: "Hiragino Maru Gothic ProN", "Yu Gothic", "Meiryo", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: grid;
  grid-template-columns: auto auto auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 18px 24px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar.routes-mode {
  grid-template-columns: auto auto auto minmax(0, 1fr);
}

.topbar.routes-mode .tabs {
  display: none;
}

.topbar.tabs-collapsed {
  height: 0;
  min-height: 0;
  padding: 0;
  border-bottom: 0;
  gap: 0;
  overflow: visible;
  background: transparent;
  backdrop-filter: none;
}

.topbar.tabs-collapsed > :not(.tabs-toggle-btn) {
  display: none;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(14px, 1.7vw, 22px);
  line-height: 1.05;
  letter-spacing: 0.02em;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
}

.tabs,
.file-actions,
.diagram-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tabs-toggle-btn {
  position: fixed;
  top: 8px;
  right: 14px;
  z-index: 30;
  min-width: 0;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 999px;
  font-size: 16px;
  line-height: 1;
}

.tabs {
  position: relative;
  z-index: 2;
  min-width: 0;
  width: 100%;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

.tab,
.ghost-btn,
.primary-btn,
.delete-train {
  border: 1px solid rgba(15, 23, 42, 0.14);
  border-radius: 999px;
  padding: 9px 14px;
  background: #ffffff;
  color: var(--deep);
  font-weight: 800;
  white-space: nowrap;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.06);
}

.tab.is-active,
.primary-btn,
.ghost-btn.is-selected {
  background: #111827;
  color: white;
}

.ghost-btn:hover,
.tab:hover,
.delete-train:hover {
  transform: translateY(-1px);
}

main {
  flex: 1;
  padding: 22px;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.hero-panel,
.operation-main,
.dashboard-grid,
.editor-layout {
  display: grid;
  gap: 16px;
}

.hero-panel {
  grid-template-columns: 170px minmax(220px, 1fr) minmax(280px, 2fr) 170px;
  margin-bottom: 16px;
}

.clock-card,
.playback-card,
.range-card,
.score-card,
.panel {
  background: var(--panel);
  border: 1px solid rgba(14, 73, 52, 0.12);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.clock-card,
.playback-card,
.range-card,
.score-card {
  min-height: 108px;
  padding: 18px;
}

.clock-card strong,
.score-card strong {
  display: block;
  margin: 4px 0;
  font-size: 34px;
  letter-spacing: -0.04em;
}

.label,
.hint,
.range-scale,
.statusbar,
.panel-head span {
  color: var(--muted);
  font-size: 12px;
}

.playback-card {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.playback-card label,
.range-card label,
.editor-side label,
.diagram-controls label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

input,
select {
  min-height: 36px;
  border: 1px solid rgba(14, 73, 52, 0.16);
  border-radius: 12px;
  padding: 7px 10px;
  background: white;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--green);
}

.range-scale {
  display: flex;
  justify-content: space-between;
}

.operation-main {
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  align-items: start;
  margin-bottom: 16px;
}

.operation-main.is-horizontal-network {
  grid-template-columns: minmax(0, 1fr);
}

.operation-main.is-horizontal-network .operation-board,
.operation-main.is-horizontal-network .dashboard-grid {
  width: 100%;
}

.operation-main.is-horizontal-network .dashboard-grid {
  grid-template-columns: minmax(0, 1fr);
}

.operation-board {
  padding: 18px;
  border-radius: 28px;
  background:
    linear-gradient(90deg, rgba(15,23,42,0.04) 1px, transparent 1px) 0 0 / 72px 72px,
    linear-gradient(180deg, rgba(15,23,42,0.04) 1px, transparent 1px) 0 0 / 72px 72px,
    #ffffff;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.08), var(--shadow);
  overflow: auto;
}

.route-canvas {
  position: relative;
  min-height: 0;
  border-radius: 22px;
  overflow: hidden;
  background: #ffffff;
}

.route-network-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.route-canvas.is-single-track {
  --single-track-line-left: 29%;
}

.route-line {
  position: absolute;
  top: 8%;
  bottom: 8%;
  width: 22px;
  border-radius: 999px;
  background:
    repeating-linear-gradient(180deg, #fff 0 13px, transparent 13px 54px),
    linear-gradient(180deg, var(--route-line-before, var(--route-line-color, #cfd8e3)) 0%, var(--route-line-before, var(--route-line-color, #cfd8e3)) calc(var(--route-line-split, 50%)), var(--route-line-after, var(--route-line-color, #cfd8e3)) calc(var(--route-line-split, 50%)), var(--route-line-after, var(--route-line-color, #cfd8e3)) 100%);
  box-shadow: 0 10px 0 rgba(15, 23, 42, 0.08);
}

.route-line-single {
  display: none;
  left: var(--single-track-line-left, 29%);
  width: 14px;
  opacity: 0.94;
}

.route-line-down {
  left: 22%;
}

.route-line-up {
  left: 34%;
  opacity: 0.88;
}

.route-canvas.is-single-track .route-line-down,
.route-canvas.is-single-track .route-line-up {
  display: none;
}

.route-canvas.is-single-track .route-line-single {
  display: block;
}

.route-canvas.is-network-overview .route-line-down,
.route-canvas.is-network-overview .route-line-up,
.route-canvas.is-network-overview .route-line-single {
  display: none;
}

.route-canvas.is-network-overview .route-line {
  display: none;
}

.station-label-layer,
.station-dot-layer,
.train-layer {
  position: absolute;
  inset: 0;
}

.station-label-layer {
  z-index: 3;
}

.station-dot-layer {
  z-index: 2;
}

.train-layer {
  z-index: 4;
}

.station-label {
  position: absolute;
  transform: translateY(-50%);
  max-width: none;
  white-space: nowrap;
  text-align: left;
  font-weight: 900;
  font-size: 13px;
  line-height: 1.25;
}

.station-dot {
  position: absolute;
  width: 14px;
  height: 14px;
  border: 3px solid white;
  border-radius: 999px;
  background: #64748b;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.1);
}

.station-dot.is-terminal {
  width: 18px;
  height: 18px;
  background: #334155;
}

.station-dot.is-junction {
  width: 18px;
  height: 18px;
  background: #334155;
  border-color: #111827;
  box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.12);
}

.station-dot.is-exchange {
  width: 18px;
  height: 18px;
  background: #334155;
  border-color: #111827;
  box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.12);
}

.station-dot.is-double-track {
  background: #0f172a;
}

.route-canvas.is-single-track .station-dot-single {
  border-color: #ffffff;
}

.train-icon {
  --train-color: var(--blue);
  position: absolute;
  min-width: 54px;
  padding: 3px 5px 5px;
  border-radius: 8px;
  color: white;
  background: var(--train-color);
  text-align: center;
  transform: translate(-50%, -50%);
  box-shadow: 0 10px 18px rgba(0,0,0,0.16);
  transition: left 0.18s linear, top 0.18s linear;
}

.train-icon.up {
  transform: translate(-50%, -50%);
}

.train-icon::after {
  content: "";
  display: block;
  width: 32px;
  height: 3px;
  margin: 2px auto 0;
  border-radius: 999px;
  background: rgba(0,0,0,0.35);
}

.train-clock {
  position: absolute;
  left: 50%;
  top: -23px;
  transform: translateX(-50%);
  color: #123;
  font-weight: 900;
  white-space: nowrap;
}

.car {
  display: block;
  letter-spacing: 2px;
  line-height: 1;
}

.train-icon strong {
  display: block;
  font-size: 11px;
}

.crowded-low {
  background-color: #2563eb !important;
}

.crowded-mid {
  background-color: #f2a93b !important;
}

.crowded-high {
  background-color: #ef6a32 !important;
}

.crowded-max {
  background-color: #d8293d !important;
}

.dashboard-grid {
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
}

.panel {
  padding: 18px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.diagram-panel-head {
  align-items: flex-start;
}

.diagram-title-area {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  min-width: 280px;
}

.train-list,
.segment-list,
.formation-list,
.turnback-list {
  display: grid;
  gap: 10px;
}

.train-list-item,
.segment-item,
.formation-card,
.turnback-card {
  display: grid;
  gap: 4px;
  padding: 12px;
  border-radius: 16px;
  background: rgba(255,255,255,0.96);
  border: 1px solid rgba(15, 23, 42, 0.08);
}

.formation-group {
  display: grid;
  gap: 8px;
}

.formation-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 4px;
}

.formation-group-list {
  display: grid;
  gap: 8px;
}

.formation-card.is-child {
  margin-left: 18px;
}

.formation-operation-summary {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  color: #475569;
  font-size: 12px;
  font-weight: 800;
}

.formation-operation-summary span {
  padding: 3px 8px;
  border-radius: 999px;
  background: #f1f5f9;
}

.train-list-item {
  grid-template-columns: 92px 1fr auto;
  align-items: center;
}

mark {
  border-radius: 999px;
  padding: 4px 9px;
  color: white;
  font-weight: 900;
}

.segment-item {
  grid-template-columns: 210px 1fr 54px;
  align-items: center;
}

.load-meter {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #eef2f7;
}

.load-meter i {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.editor-layout {
  grid-template-columns: 280px minmax(0, 1fr);
}

.editor-side {
  align-self: start;
  display: grid;
  gap: 12px;
}

.table-wrap,
.diagram-wrap {
  overflow: auto;
  max-height: calc(100vh - 220px);
}

.diagram-wrap {
  position: relative;
}

.topbar.tabs-collapsed ~ main .diagram-wrap {
  max-height: calc(100vh - 132px);
}

.diagram-station-sticky-layer {
  position: absolute;
  top: 28px;
  left: 0;
  width: 92px;
  z-index: 5;
  pointer-events: none;
  overflow: hidden;
  background: #f8fafc;
}

.diagram-time-header {
  position: sticky;
  top: 0;
  z-index: 6;
  height: 28px;
  border-radius: 12px 12px 0 0;
  background: rgba(248, 250, 252, 0.96);
  border-bottom: 1px solid #d8e0ea;
  backdrop-filter: blur(2px);
}

.diagram-time-mark {
  position: absolute;
  top: 5px;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 800;
  color: #475569;
  white-space: nowrap;
  pointer-events: none;
}

.diagram-stop-editor {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0;
}

.diagram-stop-info {
  margin: 0;
  font-size: 13px;
  color: #475569;
}

.diagram-stop-editor label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #64748b;
}

.diagram-stop-editor input {
  width: 86px;
  min-height: 32px;
  border-radius: 8px;
}

.diagram-stop-editor button {
  min-height: 32px;
  padding: 6px 12px;
}

.diagram-selected-label,
.diagram-conflict-label {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.diagram-selected-label {
  color: #334155;
  background: #f1f5f9;
  border: 1px solid #dbe4ee;
}

.diagram-conflict-label {
  color: #166534;
  background: #ecfdf5;
  border: 1px solid #bbf7d0;
}

.diagram-conflict-label.has-conflict {
  color: #991b1b;
  background: #fef2f2;
  border-color: #fecaca;
}

.station-timetable-panel {
  display: grid;
  gap: 14px;
}

.station-timetable-controls {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: end;
}

.station-timetable-controls label {
  display: grid;
  gap: 6px;
  min-width: 220px;
  font-weight: 800;
  color: var(--muted);
}

.station-timetable-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.station-timetable-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 12px;
  background: rgba(255,255,255,0.96);
}

.station-timetable-card h3 {
  margin: 0;
  font-size: 16px;
}

.station-timetable-list {
  display: grid;
  gap: 6px;
}

.station-timetable-row {
  display: grid;
  grid-template-columns: 76px 28px 74px minmax(108px, 1fr) minmax(64px, auto);
  gap: 8px;
  align-items: center;
  padding: 7px 8px;
  border-radius: 8px;
  background: #f8fafc;
}

.station-timetable-row strong {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 16px;
}

.station-timetable-row em {
  font-style: normal;
  font-weight: 800;
}

.station-timetable-type {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  color: #ffffff;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);
}

.station-timetable-destination {
  color: #334155;
  font-weight: 700;
}

.station-hour-table {
  display: grid;
  gap: 6px;
}

.station-hour-row {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 44px;
  padding: 6px 8px;
  border-radius: 8px;
}

.station-hour-row.is-even {
  background: #f1f5f9;
}

.station-hour-row.is-odd {
  background: #ffffff;
}

.station-hour-row > strong {
  font-size: 22px;
  line-height: 1;
  color: #374151;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.station-hour-minutes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  align-items: baseline;
}

.station-minute-chip {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 40px;
  line-height: 1;
  font-weight: 500;
}

.timetable {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.timetable th,
.timetable td {
  border-bottom: 1px solid #e5e7eb;
  border-right: 1px solid #f1f5f9;
  padding: 7px;
  background: rgba(255,255,255,0.92);
}

.timetable th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  white-space: nowrap;
}

.timetable input,
.timetable select {
  width: 92px;
  min-height: 31px;
  border-radius: 9px;
}

.timetable .time-cell {
  width: 76px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.delete-train {
  padding: 6px 10px;
  color: #9d1f2e;
}

.diagram-editor-shell {
  display: grid;
  gap: 14px;
}

.diagram-editor-toolbar {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) auto auto auto auto auto auto auto auto;
  align-items: end;
  gap: 10px;
  padding: 14px;
  border-radius: 18px;
}

.direction-toggle {
  display: flex;
  gap: 6px;
  align-items: center;
}

.duplicate-controls,
.command-help {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.duplicate-controls input[type="number"] {
  width: 58px;
  min-height: 34px;
  padding: 5px 7px;
}

.duplicate-controls label {
  display: flex;
  align-items: center;
  gap: 3px;
}

.command-help {
  grid-column: 1 / -1;
  padding: 8px 10px;
  border-radius: 12px;
  background: #f8fafc;
}

.command-help strong {
  color: var(--deep);
}

.command-help span {
  padding: 2px 7px;
  border-radius: 999px;
  background: white;
}

.diagram-editor-toolbar label,
.time-panel-form label,
.ops-card label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.diagram-editor-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 14px;
  align-items: stretch;
}

.timetable-grid-card,
.time-side-panel {
  border-radius: 18px;
}

.tt-like-layout {
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr);
  min-height: 460px;
  overflow: hidden;
  border: 1px solid #d7e4dc;
  border-radius: 14px;
  background: white;
}

.station-column {
  display: grid;
  grid-template-rows: 56px 1fr;
  border-right: 2px solid #e5e7eb;
  background: #f8fafc;
}

.station-column-head {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 900;
  border-bottom: 2px solid #e5e7eb;
}

.station-rows {
  display: grid;
  grid-auto-rows: 32px;
}

.station-row-like {
  display: flex;
  align-items: center;
  padding: 0 8px;
  border-bottom: 1px solid #edf2f7;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
  height: 32px;
}

.station-row-like.terminal {
  color: var(--green);
}

.station-row-like.section {
  height: 26px;
  color: #ffffff;
  background: #1f2937;
  justify-content: center;
  letter-spacing: 0.06em;
  font-size: 10px;
}

.train-grid-wrap {
  overflow: auto;
  display: grid;
  grid-template-rows: 56px 1fr;
}

.train-header-grid,
.train-body-grid {
  display: grid;
  width: max-content;
  min-width: 100%;
}

.train-header-grid {
  position: sticky;
  top: 0;
  z-index: 2;
  border-bottom: 2px solid #e5e7eb;
  background: #f8fafc;
}

.train-body-grid {
  grid-auto-rows: 32px;
}

.tt-section-row {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  border-bottom: 1px solid #e5e7eb;
  background: #f1f5f9;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.06em;
}

.train-header-like,
.tt-cell-like {
  border: 0;
  border-right: 1px solid #edf2f7;
  border-bottom: 1px solid #edf2f7;
  border-radius: 0;
  background: rgba(255,255,255,0.96);
  color: var(--ink);
}

.train-header-like {
  min-height: 56px;
  padding: 5px 4px;
  display: grid;
  align-content: center;
  gap: 2px;
  text-align: center;
}

.train-header-like i {
  display: block;
  width: 100%;
  height: 3px;
  border-radius: 999px;
}

.train-header-like strong {
  font-size: 11px;
}

.train-header-like span {
  color: var(--muted);
  font-size: 9px;
}

.train-header-like.selected,
.tt-cell-like.selected {
  outline: 3px solid rgba(59, 130, 246, 0.24);
  outline-offset: -3px;
  background: #eff6ff;
}

.tt-cell-like.in-range {
  background: #d8f3e3;
}

.tt-cell-like.range-start,
.tt-cell-like.range-end {
  outline: 3px solid rgba(15, 118, 110, 0.52);
  outline-offset: -3px;
}

.tt-cell-like.range-start.selected,
.tt-cell-like.range-end.selected {
  outline-color: rgba(59, 130, 246, 0.54);
}

.tt-cell-like {
  min-height: 32px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  font-weight: 900;
  padding: 0 2px;
}

.tt-cell-like:hover,
.train-header-like:hover {
  background: #f8fafc;
}

.tt-cell-like:disabled {
  cursor: default;
  opacity: 1;
}

.tt-cell-like.pass {
  color: var(--blue);
  background: #eef4ff;
}

.tt-cell-like.out {
  color: #7f8c86;
  background: #f8fafc;
}

.tt-cell-like.pass.in-range,
.tt-cell-like.out.in-range {
  background: #d8f3e3;
}

.tt-cell-like.pass.selected,
.tt-cell-like.out.selected {
  background: #eff6ff;
}

.empty-grid-note {
  padding: 20px;
  color: var(--muted);
}

.time-side-panel {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 0;
  overflow: hidden;
  position: sticky;
  top: 112px;
  align-self: start;
  max-height: calc(100vh - 132px);
  overflow-y: auto;
}

.time-panel-title {
  padding: 12px 14px;
  color: white;
  background: var(--deep);
  font-weight: 900;
}

.time-panel-empty,
.time-panel-form {
  padding: 14px;
}

.time-panel-form {
  display: grid;
  gap: 10px;
}

.tp-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.tp-station {
  font-size: 20px;
  font-weight: 900;
}

.tp-preview {
  padding: 9px 10px;
  border-radius: 12px;
  background: #f8fafc;
  color: var(--deep);
  font-weight: 900;
}

.danger-text {
  color: #b3263a;
}

.ops-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
}

.route-picker-shell {
  display: grid;
  gap: 14px;
}

.route-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.route-card {
  display: grid;
  gap: 6px;
  text-align: left;
  align-content: start;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid rgba(14, 73, 52, 0.12);
  background: rgba(255,255,255,0.98);
  box-shadow: var(--shadow);
  color: var(--ink);
  cursor: pointer;
}

.route-card strong {
  font-size: 16px;
}

.route-card span,
.route-card small {
  color: var(--muted);
}

.route-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.route-card-head > div {
  display: grid;
  gap: 4px;
}

.route-card.is-active {
  border-color: rgba(59, 130, 246, 0.35);
  background: rgba(255,255,255,1);
}

.route-card:hover {
  transform: translateY(-1px);
}

.route-card:focus-visible {
  outline: 3px solid rgba(29, 159, 112, 0.34);
  outline-offset: 2px;
}

.route-card-nav {
  min-height: 108px;
}

.route-network {
  display: grid;
  gap: 10px;
  margin-top: 2px;
}

.route-network-top {
  display: flex;
  justify-content: center;
}

.route-network-spine {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 6px 0 2px;
}

.route-network-line {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  transform: translateX(-50%);
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.08), rgba(15, 23, 42, 0.22), rgba(15, 23, 42, 0.08));
}

.route-node {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 900;
  background: #f8fafc;
  border: 1px solid rgba(15, 23, 42, 0.12);
}

.route-node-top {
  background: #eef7f3;
  border-color: rgba(29, 159, 112, 0.22);
  color: var(--green);
}

.route-node-junction {
  background: white;
  border-color: rgba(15, 23, 42, 0.16);
}


.route-network-branches {
  display: grid;
  gap: 10px;
}

.route-path-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(15, 23, 42, 0.10);
  background: #ffffff;
}

.route-path-row strong {
  font-size: 13px;
  line-height: 1.35;
}

.route-path-row small {
  color: var(--muted);
}

.route-path-row.is-main {
  border-left: 4px solid var(--green);
}

.route-path-row.is-branch {
  border-left: 4px solid var(--orange);
}

.route-path-row.is-single {
  border-left: 4px solid var(--blue);
}

.ops-card {
  display: grid;
  align-content: start;
  gap: 12px;
}

.types-layout {
  grid-template-columns: 280px minmax(0, 1fr);
}

.form-actions,
.formation-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.setting-row {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 12px;
  border-radius: 14px;
  background: rgba(255,255,255,0.96);
  border: 1px solid rgba(15, 23, 42, 0.08);
}

.setting-row .swatch {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.22);
}

.setting-row small {
  color: var(--muted);
  font-size: 12px;
}

.setting-actions {
  display: flex;
  gap: 6px;
}

.type-delete-editor {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding-top: 6px;
}

.type-delete-editor p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.ghost-btn.compact {
  padding: 6px 10px;
  font-size: 12px;
  box-shadow: none;
}

.diagram-panel canvas {
  display: block;
  border-radius: 18px;
  box-shadow: inset 0 0 0 1px rgba(14, 73, 52, 0.12);
}

.world3d-shell {
  display: grid;
  gap: 16px;
}

.world3d-stage {
  position: relative;
  min-height: min(72vh, 760px);
  overflow: hidden;
  border: 1px solid rgba(159, 180, 174, 0.26);
  border-radius: 30px;
  background:
    radial-gradient(circle at 50% 18%, rgba(185, 225, 204, 0.16), transparent 36%),
    linear-gradient(180deg, #071014 0%, #10191f 42%, #020506 100%);
  box-shadow: 0 24px 70px rgba(4, 8, 10, 0.28);
}

.world3d-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 46px 46px;
  mix-blend-mode: screen;
  opacity: 0.14;
}

#world3dCanvas {
  display: block;
  width: 100%;
  height: min(72vh, 760px);
  min-height: 480px;
  outline: none;
  cursor: ns-resize;
}

.world3d-hud {
  position: absolute;
  inset: 18px 18px auto 18px;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(190px, 1.2fr) repeat(3, minmax(110px, 0.7fr)) 104px;
  gap: 10px;
  align-items: stretch;
  color: #ecfdf5;
}

.world3d-route,
.world3d-meter,
.world3d-notch,
.world3d-status {
  border: 1px solid rgba(190, 228, 214, 0.22);
  background: rgba(5, 12, 14, 0.74);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.26);
  backdrop-filter: blur(12px);
}

.world3d-route,
.world3d-meter {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 18px;
}

.world3d-route span,
.world3d-route small,
.world3d-meter span {
  color: rgba(209, 250, 229, 0.68);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.05em;
}

.world3d-route strong,
.world3d-meter strong {
  font-size: clamp(16px, 2vw, 24px);
  line-height: 1.05;
}

.world3d-notch {
  display: grid;
  place-items: center;
  min-height: 76px;
  border-radius: 24px;
  color: white;
  font-size: clamp(30px, 5vw, 54px);
  font-weight: 900;
  letter-spacing: -0.07em;
}

.world3d-notch[data-mode="power"] {
  border-color: rgba(54, 211, 153, 0.48);
  background: linear-gradient(160deg, rgba(11, 101, 73, 0.9), rgba(4, 40, 32, 0.82));
}

.world3d-notch[data-mode="brake"] {
  border-color: rgba(248, 113, 113, 0.5);
  background: linear-gradient(160deg, rgba(153, 27, 27, 0.92), rgba(47, 8, 8, 0.82));
}

.world3d-notch[data-mode="neutral"] {
  border-color: rgba(226, 232, 240, 0.28);
  background: linear-gradient(160deg, rgba(30, 41, 59, 0.9), rgba(8, 13, 22, 0.82));
}

.world3d-status {
  grid-column: 1 / -1;
  width: fit-content;
  max-width: 100%;
  padding: 10px 14px;
  border-radius: 999px;
  color: rgba(236, 253, 245, 0.86);
  font-weight: 800;
}

.world3d-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
}

.world3d-controls h2 {
  margin-bottom: 4px;
}

.world3d-button-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.formation-card ol {
  margin: 6px 0 0;
  padding-left: 20px;
  color: var(--muted);
}

.turnback-card.is-ok {
  border-color: rgba(29, 159, 112, 0.4);
}

.turnback-card.is-tight {
  border-color: rgba(240, 68, 56, 0.5);
}

.empty {
  margin: 0;
  color: var(--muted);
}

.statusbar {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 22px;
  border-top: 1px solid rgba(14, 73, 52, 0.12);
  background: rgba(255,255,255,0.68);
}

@media (max-width: 980px) {
  .topbar,
  .hero-panel,
  .operation-main,
  .dashboard-grid,
  .editor-layout,
  .diagram-editor-toolbar,
  .diagram-editor-main,
  .ops-layout,
  .station-timetable-grid,
  .world3d-hud {
    grid-template-columns: 1fr;
  }

  .world3d-stage,
  #world3dCanvas {
    min-height: 560px;
    height: 68vh;
  }

  .world3d-hud {
    inset: 12px;
  }

  .time-side-panel {
    position: static;
    max-height: none;
  }

  .world3d-status {
    width: 100%;
    border-radius: 18px;
  }

  .world3d-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .world3d-button-row {
    justify-content: stretch;
  }

  .world3d-button-row button {
    flex: 1 1 130px;
  }

  .route-canvas {
    min-height: 0;
  }

  .station-label {
    font-size: 11px;
    max-width: 92px;
  }

  .segment-item,
  .train-list-item {
    grid-template-columns: 1fr;
  }

  .route-card-head {
    flex-direction: column;
  }

  .route-network-branches {
    grid-template-columns: 1fr;
  }
}
