:root {
  --hku-green: #006644;
  --hku-green-dark: #004d33;
  --hku-green-soft: #ecfdf5;
  --hku-emerald: #059669;
  --bg-page: #f4f7f6;
  --bg-panel: #ffffff;
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-light: #64748b;
  --border: #e2e8f0;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 10px 25px -5px rgba(15, 23, 42, 0.1), 0 8px 10px -6px rgba(15, 23, 42, 0.06);
  --radius-md: 12px;
  --radius-lg: 16px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang HK", "PingFang SC", "Noto Sans SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  color: var(--text-main);
  background: var(--bg-page);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Topbar */
.topbar {
  height: 58px;
  background: linear-gradient(135deg, #005236 0%, #006e49 60%, #047857 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  box-shadow: 0 2px 10px rgba(0, 50, 30, 0.18);
  z-index: 1000;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
}

.brand-crest {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.5px;
}

.brand-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.brand-sub {
  font-size: 11.5px;
  opacity: 0.85;
  display: block;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-top {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.28);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-top:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* Main Workspace Split */
.workspace {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

/* Left Sidebar */
.sidebar {
  width: 420px;
  max-width: 100%;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 500;
  overflow: hidden;
}

.sidebar-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 10px 14px 0;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}

.tab-btn {
  padding: 9px 10px;
  border: none;
  background: transparent;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2.5px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
}

.tab-btn.active {
  color: var(--hku-green);
  border-bottom-color: var(--hku-green);
}

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

/* Search & Route Box */
.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 13px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}

.section-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.input-wrap {
  position: relative;
  margin-bottom: 8px;
}

.input-wrap:last-child {
  margin-bottom: 0;
}

.input-badge {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  pointer-events: none;
}

.badge-start { background: #059669; }
.badge-end { background: #dc2626; }
.badge-search { background: #0f766e; }

.search-input {
  width: 100%;
  padding: 9px 34px 9px 38px;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  font-size: 13.5px;
  color: var(--text-main);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  background: #f8fafc;
}

.search-input:focus {
  border-color: var(--hku-emerald);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.12);
}

.clear-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  font-size: 15px;
  padding: 4px;
  line-height: 1;
}

.clear-btn:hover {
  color: var(--text-main);
}

/* Autocomplete Dropdown */
.suggestions {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  max-height: 260px;
  overflow-y: auto;
  z-index: 900;
  display: none;
}

.suggestions.open {
  display: block;
}

.sug-item {
  padding: 9px 12px;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sug-item:last-child {
  border-bottom: none;
}

.sug-item:hover, .sug-item.highlighted {
  background: var(--hku-green-soft);
}

.code-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  padding: 3px 7px;
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  background: var(--hku-green);
  flex-shrink: 0;
}

.sug-meta {
  flex: 1;
  min-width: 0;
}

.sug-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sug-sub {
  font-size: 11.5px;
  color: var(--text-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Route Controls Row */
.route-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
}

.mode-switch {
  display: inline-flex;
  background: #f1f5f9;
  padding: 3px;
  border-radius: 8px;
  flex: 1;
}

.mode-btn {
  flex: 1;
  border: none;
  background: transparent;
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.mode-btn.active {
  background: #fff;
  color: var(--hku-green);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.swap-btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-muted);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.swap-btn:hover {
  border-color: var(--hku-emerald);
  color: var(--hku-green);
}

/* Quick Chips */
.quick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  font-size: 11.5px;
  padding: 4px 9px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.chip:hover {
  background: var(--hku-green-soft);
  border-color: #a7f3d0;
  color: var(--hku-green-dark);
}

/* Parsed Room Banner */
.room-banner {
  background: linear-gradient(135deg, #ecfdf5 0%, #f0fdfa 100%);
  border: 1px solid #a7f3d0;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
  display: none;
}

.room-banner.visible {
  display: block;
}

.room-banner-title {
  font-size: 13px;
  font-weight: 700;
  color: #065f46;
  margin-bottom: 3px;
}

.room-banner-desc {
  font-size: 12px;
  color: #047857;
  line-height: 1.45;
}

/* Route Summary & Timeline */
.route-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.stat-group {
  display: flex;
  gap: 14px;
}

.stat-val {
  font-size: 18px;
  font-weight: 800;
  color: var(--hku-green);
}

.stat-lbl {
  font-size: 11px;
  color: var(--text-light);
  display: block;
}

.timeline {
  position: relative;
  padding-left: 20px;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 10px;
  bottom: 10px;
  width: 2px;
  background: #cbd5e1;
}

.step-item {
  position: relative;
  padding-bottom: 14px;
}

.step-item:last-child {
  padding-bottom: 2px;
}

.step-dot {
  position: absolute;
  left: -20px;
  top: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--hku-emerald);
}

.step-dot.start { border-color: #059669; background: #059669; }
.step-dot.end { border-color: #dc2626; background: #dc2626; }

.step-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.step-node-name {
  font-size: 13px;
  font-weight: 700;
}

.step-type-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 5px;
}

.tag-lift { background: #dbeafe; color: #1d4ed8; }
.tag-escalator { background: #e0e7ff; color: #4338ca; }
.tag-bridge { background: #d1fae5; color: #047857; }
.tag-walk { background: #f1f5f9; color: #334155; }
.tag-slope { background: #fef3c7; color: #b45309; }
.tag-transit { background: #fce7f3; color: #be185d; }

.step-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.5;
  background: #f8fafc;
  padding: 7px 10px;
  border-radius: 8px;
  border-left: 3px solid #94a3b8;
}

.step-desc.lift-highlight {
  border-left-color: #2563eb;
  background: #f0f7ff;
}

/* Directory List */
.zone-pills {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 10px;
}

.zone-pill {
  white-space: nowrap;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
}

.zone-pill.active {
  background: var(--hku-green);
  color: #fff;
  border-color: var(--hku-green);
}

.bldg-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 12px;
  margin-bottom: 9px;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
  cursor: pointer;
}

.bldg-card:hover {
  border-color: var(--hku-emerald);
  box-shadow: var(--shadow-sm);
}

.bldg-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
}

.bldg-names h4 {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-main);
}

.bldg-names p {
  font-size: 11.5px;
  color: var(--text-light);
}

.bldg-tips {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.45;
  margin-top: 5px;
}

.bldg-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.mini-btn {
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #f8fafc;
  color: var(--text-main);
  cursor: pointer;
}

.mini-btn:hover {
  background: var(--hku-green-soft);
  border-color: var(--hku-emerald);
  color: var(--hku-green-dark);
}

/* Right Map Pane */
.map-pane {
  flex: 1;
  position: relative;
  background: #e5e7eb;
}

#map {
  width: 100%;
  height: 100%;
}

/* Floating Map Filter Bar */
.map-overlay-bar {
  position: absolute;
  top: 12px;
  left: 52px;
  right: 14px;
  z-index: 450;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  pointer-events: none;
}

.map-filter-btn {
  pointer-events: auto;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(15, 23, 42, 0.12);
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  cursor: pointer;
}

.map-filter-btn.active {
  background: var(--hku-green);
  color: #fff;
  border-color: var(--hku-green);
}

/* Custom Map Code Marker */
.hku-marker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 6px;
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  font-weight: 800;
  color: #fff;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.28);
  white-space: nowrap;
  transition: transform 0.15s ease;
}

.hku-marker:hover, .hku-marker.selected {
  transform: scale(1.18);
  z-index: 999 !important;
}

.hku-marker.endpoint-start {
  background: #059669 !important;
  outline: 3px solid rgba(5, 150, 105, 0.35);
}

.hku-marker.endpoint-end {
  background: #dc2626 !important;
  outline: 3px solid rgba(220, 38, 38, 0.35);
}

/* Cheat-Sheet Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.52);
  backdrop-filter: blur(3px);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.modal-backdrop.open {
  display: flex;
}

.modal-box {
  background: #fff;
  width: 860px;
  max-width: 100%;
  max-height: 86vh;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-head {
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-head h3 {
  font-size: 16px;
  font-weight: 700;
}

.modal-body {
  padding: 14px 18px;
  overflow-y: auto;
}

.code-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.code-table th, .code-table td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid #f1f5f9;
}

.code-table th {
  background: #f8fafc;
  font-weight: 700;
  color: var(--text-muted);
  position: sticky;
  top: 0;
}

.code-table tr:hover td {
  background: #f0fdf4;
}

/* Responsive */
@media (max-width: 860px) {
  .workspace {
    flex-direction: column-reverse;
  }
  .sidebar {
    width: 100%;
    height: 54%;
    border-right: none;
    border-top: 1px solid var(--border);
  }
  .map-pane {
    height: 46%;
  }
  .brand-sub {
    display: none;
  }
}
