
:root{
  --bg:#f4f6fb;
  --panel:#ffffff;
  --line:#d8e0ee;
  --text:#1a2640;
  --muted:#5f6f8e;
  --accent:#295fff;
  --shadow:0 8px 24px rgba(20,40,90,.08);
  --radius:18px;
}
*{box-sizing:border-box}
body{margin:0;font-family:Inter,Segoe UI,Arial,sans-serif;background:var(--bg);color:var(--text)}
.app-shell{display:grid;grid-template-columns:380px 1fr;gap:18px;min-height:100vh;padding:18px}
.sidebar{display:flex;flex-direction:column;gap:16px}
.panel{background:var(--panel);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow);padding:16px}
.hero h1{margin:0 0 8px;font-size:28px}
.hero p{margin:0;color:var(--muted)}
h2{margin:0 0 12px;font-size:18px}
.form-row{display:flex;flex-direction:column;gap:6px;margin-bottom:12px}
label{font-size:13px;font-weight:700;color:#31415f}
select,input,button{font:inherit}
select,input{border:1px solid #ccd6e6;border-radius:14px;padding:10px 12px;background:#fff}
.button-row{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin-bottom:12px}
button{border:1px solid #ccd6e6;background:#fff;border-radius:14px;padding:10px 12px;cursor:pointer;font-weight:700}
button:hover{background:#f5f8ff}
.small{font-size:14px}
.stack{display:flex;flex-direction:column;gap:8px}
.line-toggle{display:flex;align-items:center;gap:10px}
.swatch{width:24px;height:8px;border-radius:99px;display:inline-block;flex:0 0 auto;border:1px solid rgba(0,0,0,.08)}
.legend-group{margin-bottom:10px}
.legend-group strong{display:block;margin-bottom:8px}
.badge{display:inline-block;padding:3px 8px;border-radius:999px;background:#eef3ff;color:#294a99;font-size:12px;font-weight:700;margin:2px 6px 2px 0}
.inspector p{margin:.35rem 0}.inspector code{font-size:12px}
.main{display:flex;flex-direction:column;gap:16px;min-width:0}
.canvas-toolbar{background:var(--panel);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow);padding:14px 18px;display:flex;justify-content:space-between;align-items:center;gap:12px}
.toolbar-title{display:flex;flex-direction:column;gap:4px}
#mapSubtitle{color:var(--muted);font-size:13px}
.toolbar-buttons{display:flex;gap:10px}.toolbar-buttons button{width:44px;height:44px;font-size:20px;padding:0}
.canvas-wrap{background:var(--panel);border:1px solid var(--line);border-radius:24px;box-shadow:var(--shadow);padding:16px;overflow:auto;min-height:720px}
#subwaySvg{width:100%;min-height:680px;display:block}
.zone-label{font-size:13px;font-weight:700;fill:#536480;pointer-events:none}
.station-label{font-size:14px;font-weight:700;fill:#18233f;cursor:pointer;paint-order:stroke;stroke:#fff;stroke-width:3px;stroke-linejoin:round}
.station-hit{fill:#fff;fill-opacity:0;stroke:none;pointer-events:all;cursor:pointer}
.station.selected .station-select-ring{display:block}
.station.search-hit .station-search-ring{display:block}
.station-search-ring,.station-select-ring{display:none;fill:none;pointer-events:none}
.station-search-ring{stroke:#295fff;stroke-width:4;opacity:.9}
.station-select-ring{stroke:#ff4d4f;stroke-width:3;opacity:.95}
.segment-label{font-size:11px;fill:#4a5b7a;paint-order:stroke;stroke:#fff;stroke-width:3px}
.hidden{display:none!important}
.help-note{color:var(--muted);font-size:12px}
@media (max-width:1200px){.app-shell{grid-template-columns:1fr}}

/* Desktop JSON compatibility: station-level annotation glyphs exported by the PySide editor. */
.station-annotation{
  font-size:18px;
  font-weight:800;
  dominant-baseline:middle;
  pointer-events:none;
  paint-order:stroke;
  stroke:#fff;
  stroke-width:3px;
  stroke-linejoin:round;
}
.annotation-legend-symbol{
  min-width:28px;
  display:inline-flex;
  justify-content:center;
  align-items:center;
  font-size:18px;
  font-weight:800;
  line-height:1;
}

/* Subway Library dashboard */
a{color:var(--accent);text-decoration:none;font-weight:700}
a:hover{text-decoration:underline}
.library-page{background:linear-gradient(180deg,#f7f9ff 0%,#eef3ff 100%);min-height:100vh}
.library-shell{max-width:1440px;margin:0 auto;padding:24px;display:flex;flex-direction:column;gap:18px}
.library-hero{display:flex;justify-content:space-between;align-items:center;gap:18px;padding:24px}
.library-hero h1{margin:0 0 8px;font-size:34px;letter-spacing:-.02em}
.library-hero p{margin:0;color:var(--muted);max-width:760px}
.eyebrow{text-transform:uppercase;letter-spacing:.12em;font-size:12px;font-weight:800;color:var(--accent)!important;margin-bottom:8px!important}
.button-link{display:inline-flex;align-items:center;justify-content:center;border:1px solid #ccd6e6;background:#fff;border-radius:14px;padding:10px 14px;font-weight:800;color:var(--text);box-shadow:0 3px 12px rgba(20,40,90,.05)}
.button-link:hover{background:#f5f8ff;text-decoration:none}
.library-controls{display:flex;flex-direction:column;gap:16px}
.search-block{display:flex;flex-direction:column;gap:6px}
.search-block input{font-size:16px;padding:14px 16px}
.filter-grid{display:grid;grid-template-columns:repeat(5,minmax(150px,1fr));gap:14px}
.library-layout{display:grid;grid-template-columns:300px 1fr;gap:18px;align-items:start}
.library-tree-panel{position:sticky;top:18px}
.library-tree details{border-bottom:1px solid #edf1f8;padding:7px 0}
.library-tree summary{cursor:pointer;font-weight:800;display:flex;justify-content:space-between;gap:12px;list-style:none}
.library-tree summary::-webkit-details-marker{display:none}
.library-tree summary span,.tree-link span{color:var(--muted);font-weight:700}
.tree-children{display:flex;flex-direction:column;gap:4px;margin:8px 0 4px 8px}
.tree-link{border:0;background:transparent;border-radius:10px;padding:7px 9px;display:flex;justify-content:space-between;gap:12px;text-align:left;font-weight:700;color:#31415f}
.tree-link:hover{background:#f5f8ff}
.library-results-panel{min-width:0}
.library-results-header{display:flex;justify-content:space-between;align-items:center;gap:12px;margin-bottom:16px}
.library-results-header h2{margin:0 0 4px}
.view-switch{display:flex;gap:8px}
.view-switch button{padding:8px 10px;border-radius:12px}
.view-switch button.active{background:#eaf0ff;border-color:#9fb7ff;color:#214ccf}
.map-card-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(310px,1fr));gap:16px}
.map-card{border:1px solid #dbe3f1;border-radius:18px;background:#fff;padding:16px;display:flex;flex-direction:column;gap:12px;min-height:310px;box-shadow:0 5px 18px rgba(20,40,90,.05)}
.map-card-top{display:flex;justify-content:space-between;align-items:center;gap:8px}
.badge-strong{background:#eaf0ff;color:#214ccf}
.status-pill,.source-pill{font-size:12px;font-weight:800;color:#486080;background:#f3f6fb;border:1px solid #e2e8f2;border-radius:999px;padding:3px 8px}
.source-pill{background:#fff7ed;color:#9a4b00;border-color:#fed7aa}
.source-json{background:#eef3ff;color:#294a99;border-color:#c7d5ff}
.source-sub{background:#ecfdf5;color:#047857;border-color:#bbf7d0}
.map-card h3{margin:0;font-size:20px;line-height:1.2}
.map-card p{margin:0;color:var(--muted);line-height:1.45}
.map-card dl{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin:0}
.map-card dt{font-size:11px;font-weight:800;color:#74829a;text-transform:uppercase;letter-spacing:.05em}
.map-card dd{margin:2px 0 0;font-weight:800;color:#263752}
.tag-row{display:flex;flex-wrap:wrap;gap:4px;margin-top:auto}
.map-card-actions{display:flex;justify-content:flex-end;margin-top:4px}
.map-table-wrap{overflow:auto;border:1px solid #dbe3f1;border-radius:16px}
.map-table{width:100%;border-collapse:collapse;background:#fff;min-width:840px}
.map-table th,.map-table td{padding:12px;border-bottom:1px solid #edf1f8;text-align:left;vertical-align:top}
.map-table th{font-size:12px;text-transform:uppercase;letter-spacing:.06em;color:#5f6f8e;background:#f8faff}
.map-table td span{color:var(--muted);font-size:13px}
.small-link{font-weight:800;color:var(--accent)}
@media (max-width:1000px){.library-layout{grid-template-columns:1fr}.library-tree-panel{position:static}.filter-grid{grid-template-columns:1fr 1fr}.library-hero{align-items:flex-start;flex-direction:column}}
@media (max-width:620px){.library-shell{padding:14px}.filter-grid{grid-template-columns:1fr}.map-card-grid{grid-template-columns:1fr}.library-results-header{align-items:flex-start;flex-direction:column}}

/* Phase 2C: full-text subway search */
.search-page .library-actions {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.search-form {
  display: grid;
  gap: 1rem;
}
.search-block-wide input {
  min-height: 44px;
  font-size: 1rem;
}
.search-actions {
  justify-content: flex-start;
}
.search-results-panel {
  margin-top: 1rem;
}
.search-results {
  display: grid;
  gap: 1rem;
}
.search-result-card {
  border: 1px solid var(--border, #d7e0ee);
  border-radius: 18px;
  background: #fff;
  padding: 1rem;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.06);
}
.search-result-card h3 {
  margin: 0.65rem 0 0.35rem;
  font-size: 1.15rem;
}
.search-result-card p {
  margin: 0.35rem 0;
}
.result-path {
  margin: 0.5rem 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  color: #64748b;
  word-break: break-word;
}
.search-match-list {
  list-style: none;
  padding: 0;
  margin: 0.75rem 0 0;
  display: grid;
  gap: 0.55rem;
}
.search-match {
  border-left: 4px solid #93c5fd;
  background: #f8fafc;
  border-radius: 12px;
  padding: 0.65rem 0.75rem;
}
.match-head {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  font-size: 0.84rem;
  color: #64748b;
  margin-bottom: 0.25rem;
}
.match-type {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
  background: #dbeafe;
  color: #1e3a8a;
  font-weight: 700;
  font-size: 0.76rem;
}
.search-match p {
  color: #172033;
  font-size: 0.92rem;
  line-height: 1.45;
}
.muted-badge {
  background: #f1f5f9;
  color: #475569;
}
.button-link.muted {
  background: #f8fafc;
  color: #1f2937;
  border: 1px solid #cbd5e1;
}

/* Phase 2D: compact labels, tooltips, and search-result highlights */
.station-label{font-size:12px;letter-spacing:.01em;dominant-baseline:middle}
.station.highlighted-station .station-search-ring{display:block;stroke:#f59e0b;stroke-width:5;opacity:.95;animation:subwayPulse 1.25s ease-in-out infinite}
.segment-group.highlighted-segment path{filter:drop-shadow(0 0 5px rgba(245,158,11,.85));stroke-width:calc(var(--segment-width, 10px) + 2px)}
.search-match-actions{display:flex;flex-wrap:wrap;gap:8px;margin-top:8px}
.match-link{display:inline-flex;align-items:center;gap:4px;border:1px solid #d7e0ee;border-radius:999px;padding:4px 8px;text-decoration:none;font-size:12px;font-weight:700;color:#26324d;background:#fff}
.match-link:hover{border-color:#9fb4d2;background:#f8fbff}
@keyframes subwayPulse{0%,100%{opacity:.45;transform:scale(1)}50%{opacity:1;transform:scale(1.18)}}


/* Shared Subway app top navigation */
.subway-topnav{
  position:sticky;
  top:0;
  z-index:50;
  background:rgba(255,255,255,.92);
  border-bottom:1px solid var(--line);
  backdrop-filter:blur(14px);
  box-shadow:0 8px 24px rgba(20,40,90,.06);
}
.subway-topnav-inner{
  max-width:1600px;
  margin:0 auto;
  padding:10px 18px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
}
.subway-brand{
  display:inline-flex;
  align-items:center;
  gap:10px;
  color:var(--text);
  min-width:max-content;
}
.subway-brand:hover{text-decoration:none}
.subway-brand-mark{
  width:34px;
  height:34px;
  border-radius:12px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  background:#eaf0ff;
  color:var(--accent);
  border:1px solid #c7d5ff;
  font-weight:900;
}
.subway-brand strong{display:block;font-size:15px;line-height:1.05}
.subway-brand small{display:block;margin-top:2px;color:var(--muted);font-size:11px;font-weight:800;letter-spacing:.03em;text-transform:uppercase}
.subway-navlinks{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:8px;
  flex-wrap:wrap;
}
.subway-navlink{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-height:36px;
  padding:8px 12px;
  border-radius:12px;
  color:#31415f;
  border:1px solid transparent;
  font-size:14px;
  font-weight:900;
}
.subway-navlink:hover{
  background:#f5f8ff;
  border-color:#dbe3f1;
  text-decoration:none;
}
.subway-navlink.active{
  background:#eaf0ff;
  color:#214ccf;
  border-color:#9fb7ff;
}
.subway-navlink.utility{
  color:#5f6f8e;
  background:#f8faff;
  border-color:#edf1f8;
}
.viewer-page .app-shell{min-height:calc(100vh - 58px)}
.library-page .library-shell{padding-top:18px}
@media (max-width:760px){
  .subway-topnav-inner{align-items:flex-start;flex-direction:column}
  .subway-navlinks{justify-content:flex-start;width:100%}
  .subway-navlink{flex:1 1 auto}
}

/* Defensive: invisible station click targets must never cover station visuals. */
.station-hit{fill:transparent!important;fill-opacity:0!important;stroke:none!important;opacity:0!important;pointer-events:all;cursor:pointer}

/* Phase 3B: modern colorful display polish */
:root{
  --bg:#eef4ff;
  --panel:#ffffff;
  --panel-blue:#eef7ff;
  --panel-green:#edfdf6;
  --panel-amber:#fff7df;
  --panel-purple:#f6f0ff;
  --panel-rose:#fff1f4;
  --line:#d7e3f5;
  --text:#14213d;
  --muted:#60708d;
  --accent:#2864e8;
  --accent-2:#06a77d;
  --accent-3:#f59e0b;
  --shadow:0 16px 42px rgba(26,55,110,.10);
  --shadow-soft:0 8px 22px rgba(26,55,110,.07);
}
body{
  background:
    radial-gradient(circle at top left, rgba(40,100,232,.12), transparent 34rem),
    radial-gradient(circle at 80% 12%, rgba(6,167,125,.10), transparent 28rem),
    linear-gradient(180deg,#f8fbff 0%,#eef4ff 54%,#f7f9ff 100%);
}
.viewer-page .app-shell{
  grid-template-columns:340px minmax(0,1fr);
  gap:20px;
  padding:20px;
}
.panel{
  border:1px solid rgba(129,153,196,.32);
  box-shadow:var(--shadow-soft);
  overflow:hidden;
}
.panel h2{
  color:#152442;
  letter-spacing:-.01em;
}
.viewer-page .sidebar .hero{
  background:linear-gradient(135deg,#edf6ff 0%,#f7f1ff 58%,#fff7e8 100%);
}
.viewer-page .sidebar .panel:nth-of-type(2){
  background:linear-gradient(180deg,#ffffff 0%,#f7fbff 100%);
}
.line-panel{
  background:linear-gradient(135deg,#f4efff 0%,#eef7ff 100%);
}
.inspector-top{
  background:linear-gradient(135deg,#eaf7ff 0%,#f3fbff 48%,#ffffff 100%);
  border-color:#b9dfff;
  box-shadow:0 14px 34px rgba(14,116,144,.12);
}
.legend-bottom{
  background:linear-gradient(135deg,#fff7df 0%,#f0fdf4 48%,#ffffff 100%);
  border-color:#f3dca3;
  box-shadow:0 14px 34px rgba(180,83,9,.10);
}
.panel-title-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom:10px;
}
.panel-title-row h2{margin:0}
.soft-pill{
  display:inline-flex;
  align-items:center;
  border:1px solid rgba(86,113,160,.20);
  border-radius:999px;
  padding:4px 9px;
  color:#4d6284;
  background:rgba(255,255,255,.72);
  font-size:12px;
  font-weight:800;
  white-space:nowrap;
}
.canvas-toolbar{
  background:linear-gradient(135deg,#ffffff 0%,#f4f8ff 100%);
  border-color:#cfdbef;
}
.canvas-wrap{
  background:
    linear-gradient(90deg, rgba(37,99,235,.035) 1px, transparent 1px),
    linear-gradient(0deg, rgba(37,99,235,.035) 1px, transparent 1px),
    #ffffff;
  background-size:36px 36px;
  border-color:#d5e1f2;
  box-shadow:0 18px 46px rgba(21,44,91,.12);
  min-height:620px;
}
#subwaySvg{min-height:600px}
.inspector-top #inspector{
  display:grid;
  gap:4px;
  color:#263854;
}
.inspector-top #inspector p{margin:.24rem 0}
.inspector-top #inspector code,
.result-path,
.help-note code{
  background:rgba(255,255,255,.72);
  border:1px solid rgba(119,142,177,.25);
  border-radius:8px;
  padding:1px 5px;
}
.legend-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(210px,1fr));
  gap:12px;
}
.legend-grid .legend-group{
  margin:0;
  padding:12px;
  border:1px solid rgba(145,115,35,.16);
  border-radius:16px;
  background:rgba(255,255,255,.66);
  box-shadow:0 6px 14px rgba(110,78,18,.05);
}
.legend-grid .legend-group strong{
  color:#523b09;
  font-size:13px;
  text-transform:uppercase;
  letter-spacing:.06em;
}
.legend-grid .line-toggle{
  padding:6px 0;
}
.badge{
  background:linear-gradient(135deg,#eaf0ff,#eefbf6);
  border:1px solid rgba(72,100,160,.18);
}
button,.button-link,.match-link{
  transition:transform .12s ease, box-shadow .12s ease, background .12s ease, border-color .12s ease;
}
button:hover,.button-link:hover,.match-link:hover{
  transform:translateY(-1px);
  box-shadow:0 8px 18px rgba(30,64,175,.09);
}
.subway-topnav{
  background:rgba(255,255,255,.84);
}
.subway-brand-mark{
  background:linear-gradient(135deg,#eaf0ff,#e6fff6);
  border-color:#c2d5ff;
}
.subway-navlink.active{
  background:linear-gradient(135deg,#eaf0ff,#e9fff6);
  border-color:#9fb7ff;
}

/* More colorful catalogue and search pages, without changing their behavior. */
.library-page,.search-page{
  background:
    radial-gradient(circle at 12% 0%, rgba(40,100,232,.13), transparent 34rem),
    radial-gradient(circle at 85% 8%, rgba(245,158,11,.11), transparent 30rem),
    linear-gradient(180deg,#f8fbff 0%,#eef4ff 100%);
}
.library-hero{
  background:linear-gradient(135deg,#ffffff 0%,#eef7ff 45%,#fff7e8 100%);
  border-color:#d6e4f6;
}
.library-controls{
  background:linear-gradient(135deg,#ffffff 0%,#f5fbff 100%);
}
.library-tree-panel{
  background:linear-gradient(135deg,#f6f0ff 0%,#ffffff 100%);
}
.library-results-panel,.search-results-panel{
  background:linear-gradient(135deg,#ffffff 0%,#f7fbff 100%);
}
.map-card{
  background:linear-gradient(180deg,#ffffff 0%,#fbfdff 100%);
  border-color:#dbe7f6;
}
.map-card:nth-child(3n+1){box-shadow:0 12px 28px rgba(37,99,235,.08)}
.map-card:nth-child(3n+2){box-shadow:0 12px 28px rgba(6,167,125,.08)}
.map-card:nth-child(3n){box-shadow:0 12px 28px rgba(245,158,11,.08)}
.search-result-card{
  background:linear-gradient(135deg,#ffffff 0%,#f9fcff 100%);
  border-color:#d8e4f5;
}
.search-match:nth-child(3n+1){background:#f3f8ff;border-left-color:#60a5fa}
.search-match:nth-child(3n+2){background:#f0fdf4;border-left-color:#34d399}
.search-match:nth-child(3n){background:#fff7ed;border-left-color:#f59e0b}

@media (max-width:1200px){
  .viewer-page .app-shell{grid-template-columns:1fr}
  .canvas-wrap{min-height:560px}
  #subwaySvg{min-height:540px}
}
@media (max-width:720px){
  .viewer-page .app-shell{padding:14px;gap:14px}
  .panel-title-row{align-items:flex-start;flex-direction:column}
  .legend-grid{grid-template-columns:1fr}
}
