/* ==========================================================================
   NASA Space Apps Challenge · Venue & Floor Operations
   Clean, Professional Corporate Design System (Simple & Non-AI Aesthetic)
   ========================================================================== */

/* --------------------------------------------------------------------------
   Typography: Official Media Kit Fonts with Standard Fallbacks
   -------------------------------------------------------------------------- */
@font-face {
  font-family: 'Munake';
  src: url('assets/fonts/Munake-Demo.ttf') format('truetype');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'abeatbyKai';
  src: url('assets/fonts/abeatbyKaiRegular.otf') format('opentype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* --------------------------------------------------------------------------
   Color Palette & CSS Custom Properties
   Official NASA Space Apps Identity:
   - Primary: #0323b2 / #2548e6
   - Secondary: #514bb4
   - Accent: #fb9746
   -------------------------------------------------------------------------- */
:root {
  /* Brand Constants */
  --nsac-blue: #0323b2;
  --nsac-indigo: #514bb4;
  --nsac-orange: #fb9746;

  /* Clean Dark Theme (Default) */
  --bg: #090d18;
  --bg-surface: #0f1628;
  --card: rgba(18, 26, 48, 0.82);
  --card-solid: rgba(18, 26, 48, 0.90);
  --card-hover: rgba(22, 32, 58, 0.95);
  --ink: #e2e8f4;
  --ink-bright: #ffffff;
  --mut: #8292ab;
  --line: #222f4d;
  --line-bright: #314470;
  --line-active: #fb9746;
  --pri: #2548e6;
  --pri-hover: #385df0;
  --accent: #fb9746;
  --accent-hover: #ffaa63;
  --ok: #10b981;
  --no: #ef4444;
  --na: #64748b;
  --sel: #fb9746;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 14px;
  --bg-img-opacity: 0.36;
  --bg-img-blur: 3px;
  --bg-overlay: radial-gradient(circle at 50% 25%, rgba(9, 13, 24, 0.52) 0%, rgba(9, 13, 24, 0.90) 100%);
  --font-title: 'Munake', 'abeatbyKai', sans-serif;
  --font-body: 'abeatbyKai', sans-serif;
  color-scheme: dark;
}

:root[data-theme="light"] {
  /* Clean Professional Light Theme */
  --bg: #f5f7fb;
  --bg-surface: #ffffff;
  --card: rgba(255, 255, 255, 0.86);
  --card-solid: rgba(255, 255, 255, 0.93);
  --card-hover: rgba(249, 251, 253, 0.98);
  --ink: #111827;
  --ink-bright: #030712;
  --mut: #526079;
  --line: #d8e0ee;
  --line-bright: #b8c7e0;
  --line-active: #ea7a20;
  --pri: #0323b2;
  --pri-hover: #021a8a;
  --accent: #ea7a20;
  --accent-hover: #cf620f;
  --ok: #059669;
  --no: #dc2626;
  --na: #64748b;
  --sel: #0323b2;
  --bg-img-opacity: 0.18;
  --bg-img-blur: 3px;
  --bg-overlay: radial-gradient(circle at 50% 25%, rgba(245, 247, 251, 0.65) 0%, rgba(245, 247, 251, 0.93) 100%);
  color-scheme: light;
}

/* --------------------------------------------------------------------------
   Global Resets & Base Styles
   -------------------------------------------------------------------------- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-padding-top: env(safe-area-inset-top, 0px);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  max-width: 100vw;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.55 var(--font-body);
  font-family: var(--font-body);
  min-height: 100vh;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  max-width: 100vw;
}

[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--font-title); font-weight: 400; letter-spacing: .03em; }

/* --------------------------------------------------------------------------
   Ambient Blurred Space Hero Background
   -------------------------------------------------------------------------- */
.site-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.site-bg-image {
  position: absolute;
  top: -12px;
  left: -12px;
  right: -12px;
  bottom: -12px;
  background-image: url('assets/images/hero-optimized.jpg');
  background-position: center center;
  background-size: cover;
  background-repeat: no-repeat;
  filter: blur(var(--bg-img-blur));
  transform: scale(1.02);
  opacity: var(--bg-img-opacity);
  transition: opacity 0.3s ease;
}

.site-bg-overlay {
  position: absolute;
  inset: 0;
  background: var(--bg-overlay);
  transition: background 0.3s ease;
}

header, main {
  position: relative;
  z-index: 1;
}

button, input, select, textarea {
  font: inherit;
  font-family: var(--font-body);
  color: inherit;
}

a {
  color: var(--pri);
  text-decoration: none;
  transition: color 0.15s;
}

a:hover {
  color: var(--accent);
}

/* --------------------------------------------------------------------------
   Header / Navigation Bar
   -------------------------------------------------------------------------- */
header {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 12px 20px;
  background: var(--card-solid);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 45;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
}

.brand-logo-img {
  height: 36px;
  width: auto;
  display: block;
  object-fit: contain;
}

.logo-light { display: none; }
.logo-dark { display: block; }

:root[data-theme="light"] .logo-light { display: block; }
:root[data-theme="light"] .logo-dark { display: none; }

.brand-text {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--line);
  padding-left: 12px;
}

.brand-title {
  font-family: var(--font-title);
  font-size: 14.5px;
  letter-spacing: 0.5px;
  font-weight: 700;
  color: var(--ink-bright);
  line-height: 1.2;
}

.brand-sub {
  font-size: 10.5px;
  letter-spacing: 0.5px;
  color: var(--accent);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.live-beacon {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
  display: inline-block;
}

.sp {
  flex: 1;
}

/* Clean Search Bar */
.search {
  position: relative;
  flex: 1;
  min-width: 220px;
  max-width: 400px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--mut);
  pointer-events: none;
  display: flex;
}

.search input {
  width: 100%;
  padding: 8px 36px 8px 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--ink-bright);
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.15s;
}

.search input:focus {
  border-color: var(--pri);
}

.search-kbd {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10.5px;
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--mut);
  background: rgba(255, 255, 255, 0.04);
  pointer-events: none;
}

/* Search Results Dropdown */
.res {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--card-solid);
  border: 1px solid var(--line-bright);
  border-radius: var(--radius-sm);
  max-height: 320px;
  overflow-y: auto;
  z-index: 50;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.res div {
  padding: 9px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background 0.12s;
}

.res div:hover {
  background: rgba(37, 72, 230, 0.1);
}

.res b {
  color: var(--accent);
  font-family: var(--font-title);
  font-size: 13.5px;
}

.res small {
  color: var(--mut);
  font-size: 12px;
}

/* Action Buttons */
.btn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  user-select: none;
}

.btn:hover {
  border-color: var(--line-bright);
  color: var(--ink-bright);
  background: var(--card-hover);
}

.btn.on {
  background: var(--pri);
  color: #ffffff;
  border-color: var(--pri);
}

.btn-sheet {
  border-color: rgba(16, 185, 129, 0.4);
  color: var(--ok);
}

.btn-sheet:hover {
  border-color: var(--ok);
  background: rgba(16, 185, 129, 0.12);
}

/* --------------------------------------------------------------------------
   Main Content Layout
   -------------------------------------------------------------------------- */
main {
  padding: 20px;
  max-width: 1360px;
  width: 100%;
  margin: 0 auto;
  flex: 1;
}

/* Breadcrumbs */
.crumb {
  color: var(--mut);
  margin-bottom: 16px;
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.crumb a {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.crumb-sep {
  color: var(--line-bright);
}

.crumb-active {
  color: var(--ink-bright);
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   Floor Cards Grid (4 Top Boxes Erased)
   -------------------------------------------------------------------------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
  margin-top: 4px;
}

.fc {
  background: var(--card-solid);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.18s, transform 0.18s, box-shadow 0.18s;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
}

.fc:hover {
  border-color: var(--line-bright);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.fc-preview {
  position: relative;
  background: #000;
  overflow: hidden;
  height: 190px;
  border-bottom: 1px solid var(--line);
}

.fc-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.fc-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(9, 13, 24, 0.88);
  border: 1px solid var(--line);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  text-transform: uppercase;
}

.fc-body {
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.fc-meta {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.fc-title {
  font-family: var(--font-title);
  font-size: 17px;
  color: var(--ink-bright);
  margin: 0;
}

.fc-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.pill {
  font-size: 11.5px;
  color: var(--mut);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  padding: 2px 7px;
  border-radius: 4px;
}

.pill-ok {
  color: var(--ok);
  border-color: rgba(16, 185, 129, 0.3);
  background: rgba(16, 185, 129, 0.08);
}

.pill-accent {
  color: var(--accent);
  border-color: rgba(251, 151, 70, 0.3);
  background: rgba(251, 151, 70, 0.08);
}

.fc-btn {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--pri);
  font-size: 12.5px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}

.fc:hover .fc-btn {
  background: var(--pri);
  color: #fff;
  border-color: var(--pri);
}

/* --------------------------------------------------------------------------
   Tactical Floor View & Minimalist Mobile Map Toolbar
   -------------------------------------------------------------------------- */
[hidden] {
  display: none !important;
}

.desktop-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mobile-menu-btn {
  display: none;
  min-width: 40px;
  min-height: 40px;
  padding: 0;
  justify-content: center;
}

.mobile-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 95;
  background: rgba(6, 9, 18, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  justify-content: flex-end;
}

.mobile-drawer-card {
  width: min(310px, 86vw);
  height: 100%;
  background: var(--bg-surface);
  border-left: 1px solid var(--line-bright);
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: -12px 0 32px rgba(0, 0, 0, 0.5);
}

.mobile-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.mobile-drawer-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mobile-drawer-actions .btn {
  width: 100%;
  justify-content: flex-start;
  min-height: 44px;
  padding: 10px 14px;
  font-size: 13.5px;
}

.btn.bad {
  border-color: rgba(239, 68, 68, 0.45);
  color: #fca5a5;
}

.tools.map-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: nowrap;
  margin-bottom: 10px;
  position: relative;
  z-index: 25;
}

.floor-switcher {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--card-solid);
  border: 1px solid var(--line-bright);
  border-radius: 10px;
  padding: 3px;
  overflow-x: auto;
  max-width: 100%;
  scrollbar-width: none;
}

.floor-switcher::-webkit-scrollbar {
  display: none;
}

.floor-all-btn {
  border-color: transparent;
  background: rgba(255, 255, 255, 0.04);
  padding: 6px 10px;
  font-size: 12.5px;
  border-radius: 7px;
  flex-shrink: 0;
}

.all-floors-short {
  display: none;
}

#tabs {
  display: flex;
  align-items: center;
  gap: 3px;
}

#tabs .btn {
  padding: 6px 11px;
  font-size: 12.5px;
  border-color: transparent;
  background: transparent;
  border-radius: 7px;
  flex-shrink: 0;
}

#tabs .btn.on {
  background: var(--pri);
  border-color: var(--pri);
  color: #fff;
  box-shadow: 0 2px 8px rgba(37, 72, 230, 0.35);
}

.filter-wrap {
  position: relative;
  flex-shrink: 0;
}

.filter-toggle-btn {
  padding: 7px 12px;
  font-size: 12.5px;
  border-radius: 10px;
  background: var(--card-solid);
  border-color: var(--line-bright);
}

.filter-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: #090d18;
  font-size: 11px;
  font-weight: 700;
}

.map-filter-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: min(310px, calc(100vw - 24px));
  background: var(--bg-surface);
  border: 1px solid var(--line-bright);
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.55);
  z-index: 60;
}

.mfp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.mfp-head b {
  font-family: var(--font-title);
  font-size: 14px;
  color: var(--ink-bright);
  letter-spacing: 0.03em;
}

.mfp-head-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.mfp-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mfp-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mfp-field span {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--mut);
}

.mfp-field select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line-bright);
  border-radius: var(--radius-sm);
  background: var(--card-solid);
  color: var(--ink-bright);
  font-size: 13px;
  outline: none;
  cursor: pointer;
}

.mfp-field select:focus {
  border-color: var(--pri);
}

.map {
  position: relative;
  height: calc(100vh - 200px);
  min-height: 460px;
  background: #070a14;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  touch-action: none;
  cursor: grab;
}

.stage {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
}

.stage img {
  display: block;
  width: 1673px;
  height: 940px;
  user-select: none;
  -webkit-user-drag: none;
}

.stage svg {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 2;
}

/* Room Polygons */
.rm {
  cursor: pointer;
  transition: fill-opacity 0.15s, stroke-width 0.15s;
  vector-effect: non-scaling-stroke;
  outline: none;
}

.rm:hover {
  fill-opacity: 0.65 !important;
  stroke-width: 3.5 !important;
}

.rm.sel {
  stroke-width: 4 !important;
}

/* Zoom Controls */
.zc {
  position: absolute;
  right: 14px;
  top: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 10;
}

.zc .btn {
  min-width: 38px;
  min-height: 38px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  background: var(--card-solid);
}

/* Tooltip */
.tip {
  position: absolute;
  pointer-events: none;
  background: var(--card-solid);
  color: var(--ink-bright);
  border: 1px solid var(--line-bright);
  padding: 7px 11px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  display: none;
  z-index: 30;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.tip-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
}

.tip-head b {
  color: var(--accent);
  font-family: var(--font-title);
  font-size: 13.5px;
}

.tip-tag {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 3px;
}

.tip-ok { background: rgba(16, 185, 129, 0.2); color: var(--ok); }
.tip-no { background: rgba(239, 68, 68, 0.2); color: var(--no); }

.tip-sub {
  color: var(--mut);
  font-size: 11.5px;
}

/* Legend */
.leg {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 14px;
  color: var(--mut);
  font-size: 12px;
}

.leg span {
  display: inline-flex;
  align-items: center;
}

.leg i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 6px;
}

/* --------------------------------------------------------------------------
   Wayfinding / Directions Panel
   -------------------------------------------------------------------------- */
.dir {
  position: fixed;
  left: 20px;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  width: min(360px, calc(100% - 40px));
  max-height: 60vh;
  overflow-y: auto;
  background: var(--card-solid);
  border: 1px solid var(--line-bright);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 40;
  display: none;
}

.dir h3 {
  margin: 0 0 10px;
  font-family: var(--font-title);
  font-size: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--ink-bright);
}

.dir input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--ink-bright);
  margin-bottom: 6px;
  outline: none;
}

.dir input:focus {
  border-color: var(--pri);
}

.dir ol {
  padding-left: 18px;
  margin: 10px 0;
}

.dir li {
  margin: 6px 0;
  cursor: pointer;
  color: var(--ink);
  transition: color 0.12s;
}

.dir li:hover {
  color: var(--accent);
}

.rt {
  stroke-dasharray: 12 9;
  animation: dash 1.1s linear infinite;
}

@keyframes dash {
  to { stroke-dashoffset: -21; }
}

.dir .ed { display: none; }
.dir.min .ed { display: inline-block; }
.dir.min #dform, .dir.min .note { display: none; }

/* --------------------------------------------------------------------------
   Google Sheets Configuration Modal
   -------------------------------------------------------------------------- */
.gsheet-modal-box {
  max-width: 580px;
}

.gsheet-desc {
  font-size: 13px;
  color: var(--mut);
  line-height: 1.5;
  margin-bottom: 14px;
}

.gsheet-input-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
  margin-bottom: 12px;
}

.gsheet-input-row input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--ink-bright);
  outline: none;
}

.gsheet-input-row input:focus {
  border-color: var(--pri);
}

.sheet-status-badge {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  color: var(--mut);
}

.sheet-status-badge.success {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.4);
  color: var(--ok);
}

.sheet-status-badge.warning {
  background: rgba(251, 151, 70, 0.12);
  border-color: rgba(251, 151, 70, 0.4);
  color: var(--accent);
}

.sheet-status-badge.error {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.4);
  color: var(--no);
}

.sheet-status-badge.syncing {
  background: rgba(37, 72, 230, 0.12);
  border-color: rgba(37, 72, 230, 0.4);
  color: var(--pri);
}

.gsheet-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.gsheet-steps {
  padding-left: 20px;
  font-size: 12.5px;
  color: var(--ink);
  line-height: 1.6;
}

.gsheet-steps li {
  margin: 4px 0;
}

/* --------------------------------------------------------------------------
   Room Details Modal Dialog
   -------------------------------------------------------------------------- */
.bd {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 55;
  padding: 16px;
  opacity: 0;
  transition: opacity 0.18s ease;
}

.bd.show {
  opacity: 1;
}

.modal {
  background: var(--card-solid);
  border: 1px solid var(--line-bright);
  border-radius: var(--radius-md);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 22px;
  transform: scale(0.97);
  transition: transform 0.18s ease;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.bd.show .modal {
  transform: scale(1);
}

.mh {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.mh h2 {
  font-family: var(--font-title);
  margin: 0 0 3px;
  font-size: 22px;
  color: var(--accent);
}

.tag {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: #fff;
}

.sec {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-top: 10px;
}

.sec h4 {
  margin: 0 0 8px;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--mut);
  font-weight: 700;
}

.kv {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 6px 10px;
  font-size: 13px;
}

.kv span:nth-child(odd) {
  color: var(--mut);
}

.kv-val {
  color: var(--ink-bright);
  font-weight: 500;
}

.na {
  color: var(--mut);
  font-style: italic;
}

.chip {
  display: inline-block;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 8px;
  margin: 2px 4px 2px 0;
  font-size: 12px;
  color: var(--ink-bright);
}

.warn {
  text-align: center;
  padding: 24px 14px;
}

.warn b {
  display: block;
  font-size: 17px;
  margin: 10px 0 4px;
  color: var(--no);
  font-family: var(--font-title);
}

.modal-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.modal-actions .btn {
  flex: 1;
  min-width: 170px;
  justify-content: center;
}

.x {
  border: 0;
  background: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--mut);
  padding: 0 4px;
  line-height: 1;
}

.x:hover {
  color: var(--ink-bright);
}

.note {
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--mut);
  font-size: 12px;
  margin-top: 16px;
  display: flex;
  gap: 8px;
  align-items: center;
}

/* --------------------------------------------------------------------------
   Responsive Design Breakpoints (Mobile-First Optimization)
   -------------------------------------------------------------------------- */
@media (max-width: 820px) {
  header {
    padding: 8px 12px;
    gap: 8px;
  }
  .desktop-controls {
    display: none !important;
  }
  .mobile-menu-btn {
    display: inline-flex;
  }
  .brand-text {
    display: none;
  }
  .brand-logo-img {
    height: 30px;
  }
  .search {
    order: 3;
    min-width: 100%;
    max-width: 100%;
    margin-top: 2px;
  }
  .search input {
    padding: 7px 12px 7px 32px;
    font-size: 13px;
  }
  .search-kbd {
    display: none;
  }
  main {
    padding: 10px 12px 16px;
  }
  .crumb {
    margin-bottom: 10px;
    font-size: 12px;
  }
  .all-floors-full {
    display: none;
  }
  .all-floors-short {
    display: inline;
  }
  .tools.map-toolbar {
    gap: 6px;
    margin-bottom: 8px;
  }
  .floor-switcher {
    flex: 1;
    min-width: 0;
    padding: 2px;
    gap: 2px;
  }
  .floor-all-btn {
    padding: 5px 7px;
    font-size: 11px;
    gap: 3px;
  }
  #tabs {
    gap: 2px;
  }
  #tabs .btn {
    padding: 5px 6.5px;
    font-size: 11px;
  }
  .filter-toggle-btn {
    padding: 5px 8px;
    font-size: 11px;
    gap: 4px;
    min-height: 32px;
  }
  .map {
    height: clamp(240px, 35dvh, 300px);
    min-height: 240px;
  }
  .zc {
    right: 10px;
    top: 10px;
    gap: 5px;
  }
  .zc .btn {
    min-width: 36px;
    min-height: 36px;
  }
  .leg {
    flex-wrap: nowrap;
    overflow-x: auto;
    white-space: nowrap;
    gap: 12px;
    margin-top: 8px;
    padding-bottom: 4px;
    font-size: 11px;
    scrollbar-width: none;
  }
  .leg::-webkit-scrollbar {
    display: none;
  }
  .dir {
    left: 10px;
    right: 10px;
    width: auto;
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    max-height: 46vh;
    padding: 12px 14px;
  }
  .quick-wayfind-card {
    padding: 12px 14px;
    margin-bottom: 14px;
  }
  .qw-controls {
    gap: 8px;
  }
  .qw-input-col {
    min-width: 100%;
  }
  .qw-swap-col, .qw-action-col {
    padding-bottom: 0;
  }
  .qw-action-col {
    flex: 1;
  }
  .qw-btn {
    width: 100%;
    justify-content: center;
    min-height: 38px;
  }
}

@media (max-width: 600px) {
  .btn-text {
    display: none;
  }
  .kv {
    grid-template-columns: 110px 1fr;
  }
}


/* --------------------------------------------------------------------------
   Quick Wayfinding & Path Search Elements
   -------------------------------------------------------------------------- */
.quick-wayfind-card {
  background: var(--card-solid);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 22px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.qw-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.qw-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: rgba(37, 72, 230, 0.15);
  border: 1px solid var(--pri);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.qw-text {
  flex: 1;
}

.qw-title {
  font-family: var(--font-title);
  font-size: 15.5px;
  color: var(--ink-bright);
  margin-bottom: 3px;
}

.qw-desc {
  font-size: 12px;
  color: var(--mut);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.qw-badge-ok {
  color: var(--ok);
  font-weight: 600;
  background: rgba(16, 185, 129, 0.12);
  padding: 1px 7px;
  border-radius: 4px;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.qw-badge-no {
  color: #60a5fa;
  font-weight: 600;
  background: rgba(37, 72, 230, 0.12);
  padding: 1px 7px;
  border-radius: 4px;
  border: 1px solid rgba(37, 72, 230, 0.3);
}

.qw-controls {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.qw-input-col {
  flex: 1;
  min-width: 190px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.qw-input-col label {
  font-size: 11px;
  font-weight: 600;
  color: var(--mut);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.qw-input-wrap {
  display: flex;
  gap: 6px;
}

.qw-input-wrap input,
.qw-input-col > input {
  width: 100%;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(9, 13, 24, 0.65);
  color: var(--ink-bright);
  font-size: 13px;
  outline: none;
}

:root[data-theme="light"] .qw-input-wrap input,
:root[data-theme="light"] .qw-input-col > input {
  background: rgba(255, 255, 255, 0.85);
}

.qw-mini-btn {
  padding: 0 9px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--pri);
  cursor: pointer;
  white-space: nowrap;
}

.qw-swap-col {
  padding-bottom: 2px;
}

.qw-swap-btn {
  font-size: 15px;
  padding: 6px 10px;
}

.qw-action-col {
  padding-bottom: 2px;
}

.qw-btn {
  padding: 7px 16px;
  font-size: 13px;
  white-space: nowrap;
}

/* Staircase Markers on Blueprint Map */
.stair-marker {
  cursor: pointer;
  outline: none;
}

/* Hover scale lives on an inner group: the outer <g> keeps its SVG translate(x,y),
   a CSS transform on it would override that and make the icon jump to the corner. */
.stair-marker .stair-inner {
  transform-origin: 0 0;
  transition: transform 0.15s ease;
}

.stair-marker:hover .stair-inner,
.stair-marker:focus-visible .stair-inner {
  transform: scale(1.15);
}

.stair-active .stair-halo {
  animation: pulse-stair 2s infinite ease-in-out;
  transform-origin: center;
}

@keyframes pulse-stair {
  0% { r: 18px; opacity: 0.8; }
  50% { r: 26px; opacity: 0.2; }
  100% { r: 18px; opacity: 0.8; }
}

/* Legend items for staircases */
.leg-stair-ok {
  background: #10b981 !important;
  border-radius: 50% !important;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.7);
}

.leg-stair-no {
  background: #2548e6 !important;
  border-radius: 2px !important;
  position: relative;
}

.leg-stair-no::after {
  content: "✕";
  color: #fff;
  font-size: 8px;
  font-weight: 900;
  position: absolute;
  top: -1px;
  left: 2px;
}

/* Search results route button */
.res-dir-btn {
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  border: 1px solid var(--pri);
  background: rgba(37, 72, 230, 0.12);
  color: var(--pri);
  cursor: pointer;
  margin-left: 8px;
  flex-shrink: 0;
  transition: all 0.15s;
}

.res-dir-btn:hover {
  background: var(--pri);
  color: #fff;
}

/* Turn-by-turn route presentation */
.route-floor-switch {
  display: flex;
  gap: 6px;
  margin: 10px 0 12px;
}

.route-steps {
  padding-left: 0;
  list-style: none;
  margin: 10px 0;
}

.route-step-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.route-step-item:hover {
  background: rgba(251, 151, 70, 0.12);
}

.step-bullet {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--pri);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 1px;
}

.step-text {
  font-size: 12px;
  line-height: 1.4;
  color: var(--ink);
}
/* Bathrooms */
.leg-wc { background: #ec4899 !important; border-radius: 3px !important; }
.wc { cursor: pointer; }
.wc rect { transition: fill-opacity .15s; }
.wc:hover rect { fill-opacity: .55; }
.btn-wc { border-color: #ec4899; color: #f9a8d4; }
.btn-wc:hover { background: rgba(236, 72, 153, .15); }

/* Exits & Outer Stage */
.leg-exit { background: #22c55e !important; border-radius: 50% !important; }
.leg-stage { background: #14b8a6 !important; border-radius: 2px !important; }
.exit-mk { cursor: pointer; }
.exit-mk circle { transition: r .15s; }
.exit-mk:hover circle { r: 18; }

/* Unified Header User Chip & Status Pill (matches TechOps / Logistics / Competition) */
.pill-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line-bright);
  color: var(--mut);
  white-space: nowrap;
  flex-shrink: 0;
}
.pill-status i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
  display: inline-block;
}
.btn.primary {
  background: var(--pri);
  border-color: var(--pri);
  color: #fff;
}
.btn.primary:hover {
  background: var(--pri-hover);
  color: #fff;
}
.btn.is-active {
  border-color: var(--accent);
  background: rgba(37, 72, 230, 0.22);
  color: var(--ink-bright);
}
.btn.small {
  padding: 4px 10px;
  font-size: 12px;
  min-height: 30px;
}
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 4px 6px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line-bright);
}
.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--pri), var(--accent));
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}
.user-meta {
  display: inline-flex;
  flex-direction: column;
  line-height: 1.15;
  text-align: left;
}
.user-meta b {
  font-size: 12.5px;
  color: var(--ink-bright);
  font-weight: 600;
}
.user-meta small {
  font-size: 10.5px;
  color: var(--mut);
}

/* Outer Stage highlight: bright outline so it stands out from the dark-teal drawing */
.rm.stage { fill: #22d3ee !important; fill-opacity: .16 !important; stroke: #22d3ee !important; stroke-width: 4 !important; stroke-dasharray: 10 6; filter: drop-shadow(0 0 7px rgba(34, 211, 238, .9)); }
.rm.stage:hover { fill-opacity: .32 !important; }
.rm.stage.sel { stroke: #fb9746 !important; fill: #fb9746 !important; fill-opacity: .3 !important; stroke-dasharray: none; filter: drop-shadow(0 0 8px rgba(251, 151, 70, .9)); }
.leg-stage { background: #22d3ee !important; }
