html, body { height: 100%; margin: 0; }
#map { height: 100%; }

.panel {
  position: absolute; top: 10px; left: 10px; z-index: 1000;
  background: rgba(255,255,255,.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 10px 12px; border-radius: 10px;
  box-shadow: 0 2px 12px rgba(0,0,0,.18);
  font: 14px/1.2 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  width: min(440px, calc(100vw - 20px));
  max-height: calc(100vh - 20px);
  overflow: auto;
}
.panelHeader{ display:flex; align-items:center; justify-content:space-between; gap:10px; position: sticky; top: 0; background: rgba(255,255,255,.78); padding-bottom: 8px; }
.panelTitle { font-weight: 900; }
.panelSub { color:#666; font-weight:650; }
.headerBtns { display:flex; gap:8px; align-items:center; }
.collapseBtn, .legendBtn{
  border: 1px solid rgba(0,0,0,.15);
  background: rgba(250,250,250,.85);
  padding: 6px 10px;
  border-radius: 10px;
  cursor: pointer;
  user-select:none;
  font-weight:800;
  line-height: 1;
}
.collapseBtn:hover,.legendBtn:hover { background: rgba(240,240,240,.92); }
.panelBody { margin-top: 8px; }
.panel.collapsed { width: auto; max-width: 240px; overflow: hidden; }
.panel.collapsed .panelBody { display:none; }
.panel.collapsed .panelSub { display:none; }

.row { display: grid; grid-template-columns: 140px 1fr; gap: 8px; align-items: center; margin-top: 8px; }
label { font-weight: 650; }
select, input {
  width: 100%; padding: 6px 8px;
  border: 1px solid #ddd; border-radius: 8px;
  font: inherit;
  background: rgba(255,255,255,.9);
}
.toggles { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.btn {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 10px;
  background: rgba(250,250,250,.9);
  cursor: pointer;
  user-select: none;
  text-align: center;
  font-weight: 800;
}
.btn.active { background: rgba(233,242,255,.92); border-color: rgba(183,212,255,.95); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chip {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  border: 1px solid #ddd;
  background: rgba(255,255,255,.9);
  border-radius: 999px;
  padding: 6px 10px;
  user-select: none;
}
.chip input { width: auto; }
.chip span { font-weight: 800; }

.muted { color: #666; font-size: 12px; margin-top: 8px; }
.stat { margin-top: 8px; font-size: 12px; color: #333; }
code { background: rgba(243,243,243,.92); padding: 1px 4px; border-radius: 6px; }

.rangeWrap { display: grid; grid-template-columns: 1fr; gap: 6px; }
.rangeLabel { font-size: 12px; color: #333; display:flex; justify-content:space-between; }
.dualRange { position: relative; height: 26px; }
.dualRange input[type="range"]{
  position: absolute; left: 0; right: 0; top: 0;
  width: 100%; margin: 0; padding: 0;
  background: transparent;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
  height: 26px;
}
.dualRange input[type="range"]::-webkit-slider-thumb{
  pointer-events: auto;
  -webkit-appearance: none;
  appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,.25);
  background: rgba(255,255,255,.98);
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
.dualRange input[type="range"]::-moz-range-thumb{
  pointer-events: auto;
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,.25);
  background: rgba(255,255,255,.98);
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
.dualRangeTrack{
  position:absolute; left:0; right:0;
  top: 50%; transform: translateY(-50%);
  height: 6px; border-radius: 999px;
  background: rgba(0,0,0,.12);
}
.dualRangeFill{
  position:absolute;
  top: 50%; transform: translateY(-50%);
  height: 6px; border-radius: 999px;
  background: rgba(120,170,255,.75);
  left: 0%; right: 0%;
}

.legendBox{
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px dashed rgba(0,0,0,.25);
  border-radius: 10px;
  background: rgba(255,255,255,.7);
  font-size: 12px;
  color:#333;
  display:none;
}
.legendBox strong{ font-weight: 900; }
.legendBox ul{ margin: 8px 0 0 18px; padding: 0; }
.legendBox li{ margin: 2px 0; }

.modalOverlay{
  position: fixed; inset: 0;
  background: rgba(0,0,0,.25);
  z-index: 2000;
  display:none;
  align-items: center;
  justify-content: center;
  padding: 10px;
}
.modal{
  width: min(980px, calc(100vw - 20px));
  max-height: calc(100vh - 20px);
  overflow: auto;
  background: rgba(255,255,255,.98);
  border-radius: 14px;
  border: 1px solid rgba(0,0,0,.08);
  box-shadow: 0 18px 48px rgba(0,0,0,.18);
  padding: 14px 14px 10px;
  font: 14px/1.35 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}
.modalHeader{ display:flex; align-items:center; justify-content:space-between; gap:10px; position: sticky; top: 0; background: rgba(255,255,255,.98); padding-bottom: 10px; }
.modalTitle{ font-weight: 950; font-size: 16px; }
.modalBtns{ display:flex; gap:8px; flex-wrap: wrap; }
.smallBtn{
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 10px;
  background: rgba(250,250,250,.96);
  cursor:pointer;
  font-weight: 850;
  user-select:none;
}
.smallBtn:hover{ background: rgba(240,240,240,.98); }
.progressLine{ margin: 10px 0; font-size: 12px; color:#333; }

table.report{ width:100%; border-collapse:collapse; margin-top:6px; font-size:13px; }
table.report th, table.report td{ padding:6px 6px; border-bottom:1px solid rgba(0,0,0,.08); vertical-align: top; }
table.report thead th{ border-bottom:1px solid rgba(0,0,0,.15); text-align:left; }
.pill{ display:inline-block; padding:2px 8px; border:1px solid rgba(0,0,0,.12); border-radius:999px; background:rgba(255,255,255,.7); }

/* Layer Legend Control (bottom right) */
.layer-legend-control {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 10px;
}

.legend-item {
  width: 40px;
  height: 40px;
  border: 2px solid rgba(0, 0, 0, 0.15);
  border-radius: 8px;
  background: rgba(250, 250, 250, 0.9);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transition: all 0.2s ease;
  user-select: none;
  padding: 0;
}

.legend-item:hover {
  background: rgba(240, 240, 240, 1);
  border-color: rgba(0, 0, 0, 0.25);
  transform: scale(1.05);
}

.legend-item.active {
  background: rgba(233, 242, 255, 0.95);
  border-color: rgba(66, 135, 245, 0.8);
  box-shadow: 0 0 0 2px rgba(66, 135, 245, 0.2);
}

.legend-item.active:hover {
  background: rgba(220, 235, 255, 1);
}

.legend-item:not(.active) {
  opacity: 0.5;
  filter: grayscale(80%);
}

.legend-item:not(.active):hover {
  opacity: 0.7;
  filter: grayscale(50%);
}

.legend-icon {
  display: block;
  line-height: 1;
}

/* ============================================================
   Tour Overlay
   ============================================================ */
.tourOverlay {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 3000;
  pointer-events: none;
}

.tourBanner {
  background: rgba(30, 30, 40, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #fff;
  padding: 8px 14px 6px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  font: 13px/1.3 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  pointer-events: auto;
  box-shadow: 0 2px 12px rgba(0,0,0,.35);
}

.tourMeta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.tourNameEl {
  font-weight: 800;
  font-size: 12px;
  color: rgba(255,255,255,.7);
  white-space: nowrap;
}

.tourProgressEl {
  font-weight: 700;
  font-size: 12px;
  color: rgba(180,210,255,.9);
  white-space: nowrap;
}

.tourDescRow {
  flex: 1;
  min-width: 180px;
}

.tourStepDescEl {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}

.tourProgressBar {
  width: 100%;
  order: 10;
  height: 3px;
  background: rgba(255,255,255,.15);
  border-radius: 999px;
  overflow: hidden;
  flex-basis: 100%;
  margin-top: 2px;
}

.tourProgressFill {
  height: 100%;
  background: rgba(99,179,255,.9);
  border-radius: 999px;
  width: 0%;
  transition: width 0.4s ease;
}

.tourControls {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.tourBtn {
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.2);
  color: #fff;
  padding: 5px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
  font-size: 13px;
  line-height: 1;
  transition: background 0.15s;
}
.tourBtn:hover {
  background: rgba(255,255,255,.22);
}
.tourBtnStop {
  background: rgba(220,60,60,.3);
  border-color: rgba(220,80,80,.4);
}
.tourBtnStop:hover {
  background: rgba(220,60,60,.5);
}

/* ============================================================
   Recorder Badge & Panel Buttons
   ============================================================ */
.recBadge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(220,50,50,.85);
  color: #fff;
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 800;
  margin-left: 4px;
  vertical-align: middle;
}

/* ============================================================
   Recorder Editor Modal
   ============================================================ */
.recorderModal {
  width: min(720px, calc(100vw - 20px));
  max-height: calc(100vh - 20px);
}

.recorderStepList {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 320px;
  overflow-y: auto;
  padding: 4px 2px;
}

.recStepRow {
  display: grid;
  grid-template-columns: 90px 1fr 80px 28px 28px 28px;
  gap: 6px;
  align-items: center;
  padding: 5px 8px;
  border: 1px solid rgba(0,0,0,.1);
  border-radius: 8px;
  background: rgba(248,249,250,.9);
  font-size: 12px;
}

.recStepLabel {
  font-weight: 800;
  color: #444;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recStepDesc {
  padding: 4px 6px !important;
  font-size: 12px !important;
  border-radius: 6px !important;
}

.recStepPause {
  padding: 4px 4px !important;
  font-size: 12px !important;
  border-radius: 6px !important;
  text-align: right;
}

.recStepMoveBtn, .recStepDelBtn {
  background: rgba(250,250,250,.96);
  border: 1px solid #ddd;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  padding: 3px 6px;
  font-weight: 800;
  line-height: 1;
}
.recStepMoveBtn:hover { background: rgba(240,240,240,.98); }
.recStepDelBtn { color: #c00; }
.recStepDelBtn:hover { background: rgba(255,240,240,.98); }
.recStepMoveBtn:disabled { opacity: .35; cursor: default; }

.recorderJsonArea {
  width: 100%;
  min-height: 160px;
  resize: vertical;
  padding: 8px 10px;
  margin-top: 4px;
  border-radius: 10px;
  border: 1px solid rgba(0,0,0,.12);
  font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: rgba(250,250,250,.9);
  box-sizing: border-box;
}
