:root {
  --ink: #132336;
  --muted: #6d7b8a;
  --line: #dce4eb;
  --paper: #f4f7f9;
  --white: #ffffff;
  --navy: #0b2d4f;
  --blue: #0a6dd8;
  --cyan: #12a8b0;
  --green: #10a37f;
  --orange: #f39a3f;
  --red: #dc4c56;
  --shadow: 0 18px 50px rgba(23, 48, 75, .10);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, rgba(18, 168, 176, .09), transparent 26rem),
    linear-gradient(180deg, #eef4f7 0, var(--paper) 240px);
  font-family: "SF Pro Display", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

button, select, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, select:focus-visible, a:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid rgba(10, 109, 216, .48);
  outline-offset: 2px;
}

.topbar {
  min-height: 86px;
  padding: 18px clamp(22px, 3.2vw, 56px);
  display: flex;
  align-items: center;
  gap: 18px;
  color: white;
  background: linear-gradient(118deg, #071e36 0%, #0a355b 52%, #0a5970 100%);
  box-shadow: 0 8px 28px rgba(7, 30, 54, .24);
}

.brand-mark { width: 46px; height: 46px; position: relative; flex: 0 0 auto; transform: rotate(45deg); }
.brand-mark span { position: absolute; width: 23px; height: 23px; border-radius: 20px 4px 20px 4px; background: #34c3c8; }
.brand-mark span:nth-child(1) { top: 0; left: 0; }
.brand-mark span:nth-child(2) { right: 0; top: 0; background: #37a5e7; transform: rotate(90deg); }
.brand-mark span:nth-child(3) { left: 0; bottom: 0; background: #fff; transform: rotate(-90deg); }
.brand-copy { min-width: 0; }
.brand-copy h1 { font-size: clamp(20px, 2vw, 29px); margin: 2px 0 0; letter-spacing: .02em; font-weight: 650; }
.eyebrow, .section-kicker { margin: 0; font-size: 10px; letter-spacing: .16em; font-weight: 700; opacity: .72; }
.system-status { margin-left: auto; display: flex; align-items: center; gap: 9px; font-size: 12px; color: #d9f7f2; }
.system-status i { width: 8px; height: 8px; background: #50e3ae; border-radius: 50%; box-shadow: 0 0 0 5px rgba(80, 227, 174, .12); }
.system-status strong { margin-left: 10px; padding-left: 16px; border-left: 1px solid rgba(255,255,255,.22); font-variant-numeric: tabular-nums; color: white; }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(360px, .72fr);
  gap: 22px;
  padding: 24px clamp(18px, 2.8vw, 46px) 30px;
  max-width: 1920px;
  margin: 0 auto;
}

.map-column { min-width: 0; }
.map-toolbar { min-height: 64px; display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 12px; }
.section-kicker { color: var(--muted); margin-bottom: 9px; }
.floor-tabs { display: flex; gap: 7px; flex-wrap: wrap; }
.floor-tab { min-width: 58px; border: 1px solid var(--line); border-radius: 9px; padding: 9px 15px; background: rgba(255,255,255,.68); color: var(--muted); font-weight: 750; transition: .2s ease; }
.floor-tab:hover { border-color: #92b7ca; color: var(--navy); }
.floor-tab.active { color: white; border-color: var(--blue); background: linear-gradient(135deg, #0875d5, #0b5eae); box-shadow: 0 7px 18px rgba(10,109,216,.24); }
.map-actions { display: flex; gap: 8px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.layer-controls { display: flex; gap: 4px; padding: 4px; border: 1px solid #cbd7df; border-radius: 9px; background: rgba(255,255,255,.82); }
.layer-controls button { min-height: 34px; border: 0; border-radius: 6px; padding: 5px 8px; color: #718191; background: transparent; font-size: 11px; font-weight: 700; }
.layer-controls button[aria-pressed="true"] { color: white; background: #0a6cad; box-shadow: 0 3px 8px rgba(10,108,173,.20); }
.download-button { min-height: 44px; display: inline-flex; align-items: center; border: 1px solid #b9c8d4; border-radius: 9px; padding: 9px 12px; color: var(--navy); background: white; font-size: 12px; font-weight: 700; text-decoration: none; transition: .2s; }
.download-button:hover { border-color: var(--blue); color: var(--blue); }
.recognition-chip { border: 1px solid #a6d9c9; border-radius: 9px; padding: 10px 13px; color: #08745b; background: #e7f8f2; font-size: 12px; font-weight: 750; white-space: nowrap; }
.button-icon { font-size: 17px; vertical-align: -1px; margin-right: 3px; }

.map-card, .panel { border: 1px solid rgba(190, 205, 216, .82); background: rgba(255,255,255,.94); box-shadow: var(--shadow); }
.map-card { border-radius: 16px; overflow: hidden; }
.map-status-row { min-height: 48px; padding: 11px 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px; border-bottom: 1px solid #e3e9ee; background: #fbfdfe; }
.map-status-row > div:first-child { display: flex; align-items: center; gap: 10px; }
.map-status-row span { font-size: 13px; font-weight: 750; }
.map-status-row em { padding: 3px 7px; border-radius: 5px; background: #fff0dc; color: #9a611d; font-size: 10px; font-style: normal; }
.legend { display: flex; align-items: center; gap: 10px; color: var(--muted); overflow-x: auto; padding-bottom: 2px; }
.legend span { font-weight: 500; font-size: 10px; display: inline-flex; align-items: center; gap: 5px; }
.legend-dot { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.legend-dot.stair { background: var(--green); }
.legend-dot.elevator { background: var(--blue); }
.legend-dot.escalator { background: var(--orange); }
.legend-channel { width: 18px; height: 5px; display: inline-block; border-radius: 5px; background: rgba(18,168,176,.58); }
.legend-obstacle { width: 11px; height: 8px; display: inline-block; border: 1px solid var(--red); background: rgba(220,76,86,.18); }
.legend-partition { width: 16px; height: 5px; display: inline-block; background: #64748b; }
.legend-boundary { width: 16px; height: 0; display: inline-block; border-top: 3px solid #334155; }
.legend-line { width: 18px; height: 3px; display: inline-block; border-radius: 4px; background: var(--red); }

.map-stage { position: relative; aspect-ratio: 16 / 10; min-height: 420px; background: #eef3f6; overflow: hidden; cursor: crosshair; }
.map-stage svg { display: block; width: 100%; height: 100%; overflow: hidden; touch-action: none; }
.map-stage.selecting { box-shadow: inset 0 0 0 4px rgba(10,109,216,.65); }
.selection-hint { position: absolute; left: 50%; bottom: 14px; transform: translate(-50%, 10px); padding: 9px 14px; border-radius: 20px; color: white; background: rgba(7,30,54,.90); font-size: 11px; opacity: 0; pointer-events: none; transition: .2s; }
.map-stage.selecting .selection-hint { opacity: 1; transform: translate(-50%, 0); }
.map-caption { padding: 10px 14px; display: flex; justify-content: space-between; color: #7a8793; font-size: 10px; border-top: 1px solid #e8edf1; background: #fbfcfd; }
.map-caption strong { color: #4b7598; font-weight: 700; }

.control-column { display: grid; gap: 15px; align-content: start; }
.panel { border-radius: 14px; padding: 17px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.panel-heading > div { display: flex; align-items: center; gap: 11px; }
.panel-heading p { margin: 0 0 1px; color: var(--muted); font-size: 9px; letter-spacing: .12em; text-transform: uppercase; }
.panel-heading h2 { margin: 0; font-size: 16px; }
.panel-heading.compact { margin-bottom: 12px; }
.step-number { width: 34px; height: 34px; display: grid; place-items: center; color: var(--blue); border: 1px solid #b7d3e8; border-radius: 8px; background: #edf7fe; font-weight: 800; font-size: 11px; }
.mode-badge, .result-state, .ai-status { padding: 5px 8px; border-radius: 6px; font-size: 10px; font-weight: 750; }
.mode-badge { color: #b03c45; background: #feecee; }
.result-state.idle, .ai-status.pending { color: #667888; background: #edf1f4; }
.result-state.ok, .ai-status.completed { color: #08745b; background: #e3f8f1; }
.result-state.error, .ai-status.error { color: #b0353f; background: #fee9eb; }

.point-grid { display: grid; grid-template-columns: 1fr 32px 1fr; gap: 7px; align-items: stretch; }
.point-card { padding: 11px; border: 1px solid var(--line); border-radius: 10px; background: #fbfcfd; }
.point-title { display: grid; grid-template-columns: 24px 1fr; align-items: center; gap: 7px; margin-bottom: 9px; }
.point-title i { grid-row: span 2; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; color: white; background: var(--blue); font-size: 10px; font-style: normal; font-weight: 800; }
.end-card .point-title i { background: var(--red); }
.point-title span { font-size: 11px; font-weight: 700; }
.point-title strong { color: var(--muted); font-size: 9px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.point-controls { display: grid; grid-template-columns: 1fr; gap: 6px; }
.point-controls select, .point-controls button { width: 100%; min-width: 0; border: 1px solid #d5dee6; border-radius: 7px; padding: 7px 8px; background: white; color: var(--ink); font-size: 10px; }
.point-controls button { color: var(--blue); font-weight: 700; }
.point-link { display: flex; flex-direction: column; align-items: center; justify-content: center; color: #9aa9b5; }
.point-link span { width: 1px; height: 28%; background: #dfe5ea; }
.point-link b { font-size: 14px; font-weight: 500; }

.mode-switch { border: 0; padding: 0; margin: 14px 0 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.mode-switch legend { margin-bottom: 6px; color: var(--muted); font-size: 10px; font-weight: 700; }
.mode-switch label { cursor: pointer; position: relative; }
.mode-switch input { position: absolute; opacity: 0; }
.mode-switch span { min-height: 54px; display: flex; flex-direction: column; justify-content: center; padding: 8px 10px 8px 31px; border: 1px solid var(--line); border-radius: 9px; background: white; transition: .2s; }
.mode-switch span::before { content: ""; position: absolute; left: 11px; top: 19px; width: 10px; height: 10px; border: 2px solid #a9b6c1; border-radius: 50%; }
.mode-switch input:checked + span { border-color: #4b94cf; background: #f0f8fe; }
.mode-switch input:checked + span::before { border-color: var(--blue); box-shadow: inset 0 0 0 2px white; background: var(--blue); }
.mode-switch b { font-size: 11px; }
.mode-switch small { color: var(--muted); font-size: 8px; margin-top: 2px; }

.constraints { margin: 6px 0 13px; border: 1px solid #e0e6eb; border-radius: 9px; background: #fbfcfd; }
.constraints summary { padding: 9px 10px; cursor: pointer; font-size: 10px; font-weight: 700; }
.constraints summary span { float: right; color: var(--muted); font-weight: 500; }
.constraint-grid { padding: 0 10px 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; color: #5d6d7a; font-size: 9px; }

.primary-button { width: 100%; border: 0; border-radius: 9px; padding: 12px 14px; display: flex; justify-content: center; gap: 14px; color: white; background: linear-gradient(125deg, #0873d1, #07599f); box-shadow: 0 9px 22px rgba(8,100,181,.23); font-weight: 750; }
.primary-button:hover { filter: brightness(1.05); transform: translateY(-1px); }
.primary-button:disabled { opacity: .55; cursor: wait; }

.empty-state { min-height: 108px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); }
.empty-state p { margin: 9px 0 2px; font-size: 11px; font-weight: 700; }
.empty-state small { font-size: 9px; }
.radar-icon { width: 30px; height: 30px; position: relative; display: grid; place-items: center; }
.radar-icon i { position: absolute; border: 1px solid #9ec5d8; border-radius: 50%; }
.radar-icon i:nth-child(1) { width: 8px; height: 8px; background: #25a8bd; }
.radar-icon i:nth-child(2) { width: 20px; height: 20px; }
.radar-icon i:nth-child(3) { width: 30px; height: 30px; opacity: .45; }
.route-metrics { display: grid; grid-template-columns: repeat(3,1fr); border: 1px solid #e0e7ec; border-radius: 9px; overflow: hidden; }
.route-metrics div { padding: 9px 7px; text-align: center; background: #fbfcfd; border-right: 1px solid #e0e7ec; }
.route-metrics div:last-child { border-right: 0; }
.route-metrics span { display: block; font-size: 16px; font-weight: 800; color: var(--navy); }
.route-metrics small { color: var(--muted); font-size: 8px; }
.instruction-list { margin: 12px 0 0; padding-left: 22px; max-height: 160px; overflow: auto; }
.instruction-list li { padding: 4px 0 4px 3px; color: #425465; font-size: 10px; line-height: 1.45; }
.instruction-list li::marker { color: var(--blue); font-weight: 800; }
.policy-note { margin: 9px 0 0; padding: 8px; border-left: 3px solid var(--orange); color: #745329; background: #fff8ed; font-size: 9px; line-height: 1.5; }

.ai-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.ai-summary div { padding: 8px; display: flex; align-items: baseline; gap: 5px; border-radius: 8px; background: #f3f7fa; }
.ai-summary b { font-size: 17px; }
.ai-summary span { color: var(--muted); font-size: 9px; }
.scene-summary { margin-top: 7px; display: grid; grid-template-columns: repeat(4,1fr); gap: 5px; }
.scene-summary span { padding: 6px 4px; border: 1px solid #dfe8ed; border-radius: 7px; color: var(--muted); background: #fbfdfe; text-align: center; font-size: 8px; }
.scene-summary b { color: var(--navy); font-size: 10px; }
.feature-list { margin-top: 9px; max-height: 130px; overflow: auto; }
.feature-list > p { margin: 0; color: var(--muted); font-size: 9px; line-height: 1.55; }
.feature-item { padding: 7px 2px; display: flex; gap: 8px; align-items: center; border-bottom: 1px solid #edf1f3; }
.feature-item i { width: 8px; height: 8px; border-radius: 2px; flex: 0 0 auto; }
.feature-item div { min-width: 0; flex: 1; }
.feature-item b { display: block; font-size: 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feature-item small { color: var(--muted); font-size: 8px; }
.feature-item strong { font-size: 9px; color: var(--green); }

.warning-bar { margin-top: 2px; padding: 12px clamp(20px, 3.2vw, 56px); display: flex; gap: 12px; align-items: center; color: #77511d; background: #fff3df; border-top: 1px solid #efd6ae; font-size: 10px; line-height: 1.5; }
.warning-bar strong { padding: 3px 7px; border-radius: 5px; color: white; background: #c9822a; white-space: nowrap; }
.toast { position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px); max-width: min(560px, 86vw); padding: 11px 16px; border-radius: 9px; color: white; background: rgba(8,35,59,.94); box-shadow: 0 12px 30px rgba(0,0,0,.2); font-size: 11px; opacity: 0; pointer-events: none; transition: .25s; z-index: 20; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: rgba(163,42,52,.96); }

.route-polyline { fill: none; stroke: var(--red); stroke-width: 5; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; filter: drop-shadow(0 2px 2px rgba(0,0,0,.2)); }
.route-halo { fill: none; stroke: white; stroke-width: 9; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; opacity: .88; }
.route-transfer-halo { fill: white; stroke: white; stroke-width: 5; vector-effect: non-scaling-stroke; opacity: .9; }
.route-transfer { fill: var(--red); stroke: white; stroke-width: 2; vector-effect: non-scaling-stroke; filter: drop-shadow(0 2px 2px rgba(0,0,0,.2)); }
.point-marker circle { vector-effect: non-scaling-stroke; stroke: white; stroke-width: 3; }
.point-marker text { fill: white; font-weight: 800; font-size: 18px; text-anchor: middle; dominant-baseline: central; }
.facility-box { fill: rgba(255,255,255,.10); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-dasharray: 5 4; }
.facility-label { font-size: 15px; font-weight: 800; paint-order: stroke; stroke: white; stroke-width: 4px; stroke-linejoin: round; }
.topology-dot { fill: #526675; stroke: white; stroke-width: 2; vector-effect: non-scaling-stroke; opacity: .65; }
.connector-dot { fill: var(--navy); stroke: white; stroke-width: 2; vector-effect: non-scaling-stroke; opacity: .86; }
.recognized-boundary { fill: none; stroke: rgba(11,45,79,.65); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-dasharray: 8 5; }
.recognized-channel { fill: none; stroke: rgba(18,168,176,.40); stroke-width: 8; vector-effect: non-scaling-stroke; stroke-linecap: round; stroke-linejoin: round; }
.recognized-obstacle { fill: rgba(220,76,86,.16); stroke: rgba(176,53,63,.82); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.recognized-partition { fill: none; stroke: rgba(176,53,63,.82); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-dasharray: 4 3; }

.layer-hidden { display: none; }
.plan-background { fill: #eef3f6; }
.plan-grid { opacity: .60; }
.grid-line { fill: none; stroke: #dce5eb; stroke-width: 1; }
.hazard-line { stroke: #f7a6a0; stroke-width: 4; }
.plan-title { font-size: 27px; font-weight: 800; fill: #102a43; }
.plan-subtitle { font-size: 14px; font-weight: 650; fill: #627d98; }
.demo-badge rect { fill: #fff3cd; stroke: #d99614; stroke-width: 2; }
.demo-badge text { font-size: 15px; font-weight: 850; fill: #8a5700; text-anchor: middle; }
.demo-badge .demo-badge-small { font-size: 12px; }
.boundary-fill { fill: #f8fafc; filter: drop-shadow(0 3px 5px rgba(23,50,75,.16)); }
.building-boundary { fill: none; stroke: #334155; stroke-width: 7; stroke-linejoin: round; }
.zone-label { font-size: 15px; font-weight: 750; fill: #637381; text-anchor: middle; }
.channel-surface { fill: none; stroke: #d8f3ec; stroke-width: 22; stroke-linecap: round; stroke-linejoin: round; }
.channel-centre { fill: none; stroke: #087f8c; stroke-width: 4; stroke-dasharray: 12 8; stroke-linecap: round; stroke-linejoin: round; }
.route-node { fill: #087f8c; stroke: white; stroke-width: 2; }
.obstacle { fill: url(#hazard); stroke: #b42318; stroke-width: 3; stroke-linejoin: round; }
.obstacle-label { font-size: 12px; font-weight: 800; fill: #8d1c13; text-anchor: middle; dominant-baseline: middle; paint-order: stroke; stroke: #fff5f4; stroke-width: 4px; }
.partition { fill: none; stroke: #64748b; stroke-width: 9; stroke-linecap: square; }
.facility rect { fill: white; stroke-width: 4; }
.facility-stair rect { stroke: #168a73; }
.facility-elevator rect { stroke: #1769aa; }
.facility-escalator rect { stroke: #d97706; }
.facility-symbol { fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.facility-stair .facility-symbol { stroke: #168a73; }
.facility-elevator .facility-symbol { stroke: #1769aa; }
.facility-escalator .facility-symbol { stroke: #d97706; }
.facility-code { font-size: 10px; font-weight: 900; fill: #102a43; text-anchor: middle; }
.facility-name { font-size: 11px; font-weight: 850; fill: #102a43; text-anchor: middle; paint-order: stroke; stroke: white; stroke-width: 4px; }
.facility-unavailable { opacity: .46; }
.facility-closed-mark { fill: none; stroke: #b42318; stroke-width: 6; stroke-linecap: round; }
.endpoint { fill: #168a73; stroke: white; stroke-width: 4; }
.endpoint-label { font-size: 12px; font-weight: 800; fill: #102a43; text-anchor: middle; }
.plan-summary { font-size: 13px; font-weight: 650; fill: #526675; }
.plan-watermark { font-size: 22px; font-weight: 900; fill: #b42318; letter-spacing: 2px; text-anchor: middle; }
.plan-version { font-size: 10px; fill: #8295a5; text-anchor: end; }
.selection-cursor { fill: rgba(10,109,216,.12); stroke: #0a6dd8; stroke-width: 4; stroke-dasharray: 6 4; }

@media (max-width: 1100px) {
  .workspace { grid-template-columns: 1fr; }
  .control-column { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .route-panel { grid-row: span 2; }
}

@media (max-width: 720px) {
  .topbar { padding: 14px 18px; }
  .system-status span { display: none; }
  .system-status strong { margin-left: 0; }
  .brand-mark { width: 34px; height: 34px; }
  .brand-mark span { width: 17px; height: 17px; }
  .workspace { padding: 15px 10px 24px; }
  .map-toolbar { align-items: flex-start; flex-direction: column; }
  .map-actions { width: 100%; }
  .map-actions > * { text-align: center; }
  .layer-controls { width: 100%; overflow-x: auto; }
  .layer-controls button { flex: 1 0 auto; min-height: 44px; }
  .legend { width: 100%; }
  .legend span { flex: 0 0 auto; }
  .map-stage { min-height: 250px; }
  .control-column { grid-template-columns: 1fr; }
  .route-panel { grid-row: auto; }
  .warning-bar { align-items: flex-start; }
}
