:root {
  --sand: #0f141a;
  --sand-deep: #0a0f14;
  --card: rgba(22, 29, 36, 0.9);
  --card-strong: rgba(32, 40, 48, 0.96);
  --ink: #eef4f8;
  --muted: #95a7b6;
  --accent: #f36f3a;
  --accent-deep: #ff9751;
  --teal: #48c6c8;
  --teal-soft: rgba(72, 198, 200, 0.14);
  --border: rgba(255, 255, 255, 0.08);
  --line: rgba(255, 255, 255, 0.12);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
  --radius: 28px;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top, rgba(243, 111, 58, 0.16), transparent 28%),
    radial-gradient(circle at bottom right, rgba(72, 198, 200, 0.12), transparent 26%),
    linear-gradient(180deg, #0b1117 0%, #101821 100%);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  background: rgba(15, 21, 27, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 34px;
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
  backdrop-filter: blur(18px);
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-deep);
}

.hidden-input {
  display: none;
}

.dev-hidden {
  display: none !important;
}

.page-gate,
.page-redirect {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.page-gate .app-shell,
.redirect-shell {
  width: min(100%, 560px);
}

.gate-card,
.redirect-card {
  padding: 30px;
  border-radius: 34px;
  background: rgba(20, 28, 35, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow);
}

.gate-title {
  margin: 0;
  font-size: clamp(2rem, 5vw, 2.5rem);
  line-height: 1;
}

.gate-copy {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.gate-form {
  margin-top: 22px;
  display: grid;
  gap: 12px;
}

.gate-label,
.field label {
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.gate-input,
.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(18, 25, 32, 0.94);
  color: var(--ink);
}

.field textarea {
  min-height: 96px;
  resize: vertical;
}

.gate-submit {
  min-height: 50px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #fff8f2;
  font-weight: 700;
}

.gate-error {
  min-height: 20px;
  color: #ff8b7a;
  font-size: 0.92rem;
}

.page-map {
  display: flex;
  justify-content: center;
  padding: 16px;
}

.page-map .app-shell {
  width: min(100%, 1480px);
  min-height: calc(100vh - 32px);
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.topbar {
  padding: 18px 18px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: grid;
  gap: 4px;
}

.brand-title {
  margin: 0;
  font-size: 1.55rem;
  line-height: 1;
}

.subtle {
  color: var(--muted);
  font-size: 0.9rem;
}

.status-pill {
  padding: 10px 12px;
  border-radius: 999px;
  background: rgba(20, 28, 35, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 0.84rem;
  text-align: right;
  min-width: 102px;
}

.map-wrap {
  position: relative;
  padding: 0 14px 14px;
  min-height: 0;
}

#map {
  width: 100%;
  height: 100%;
  min-height: 320px;
  border-radius: 30px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.map-chips {
  position: absolute;
  left: 26px;
  right: 26px;
  top: 14px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
  z-index: 500;
}

.chip {
  pointer-events: auto;
  padding: 10px 12px;
  border-radius: 18px;
  background: rgba(18, 25, 32, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.18);
  font-size: 0.84rem;
}

.chip strong {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 2px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.fab-row {
  position: absolute;
  left: 26px;
  right: 26px;
  bottom: 28px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  z-index: 500;
}

.fab {
  min-height: 48px;
  border-radius: 18px;
  background: rgba(18, 25, 32, 0.9);
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 14px 24px rgba(0, 0, 0, 0.2);
  font-size: 0.84rem;
  font-weight: 700;
  transition: transform 0.18s ease, background 0.18s ease;
}

.fab.active {
  background: var(--accent);
  color: #fff8f2;
}

.fab:hover,
.action:hover {
  transform: translateY(-1px);
}

.sheet {
  margin: 0 14px 14px;
  min-height: 0;
  background: rgba(19, 26, 33, 0.92);
  border-radius: 32px 32px 0 0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.24);
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

.sheet.dragging {
  transition: none !important;
}

.sheet-handle {
  width: 52px;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  margin: 10px auto 2px;
  touch-action: none;
}

.sheet-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 12px 16px 14px;
}

.sheet-tab {
  min-height: 42px;
  border-radius: 16px;
  background: rgba(28, 36, 44, 0.84);
  color: var(--muted);
}

.sheet-tab.active {
  background: linear-gradient(135deg, rgba(243, 111, 58, 0.18), rgba(72, 198, 200, 0.14));
  color: var(--ink);
  font-weight: 700;
}

.sheet-content {
  overflow: auto;
  padding: 0 16px 16px;
  display: grid;
}

.sheet-panel {
  display: none;
  gap: 14px;
  align-content: start;
}

.sheet-panel.active {
  display: grid;
}

.status-box,
.card,
.editor-box {
  padding: 14px;
  border-radius: 22px;
  background: rgba(24, 32, 40, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.status-box {
  color: var(--muted);
  line-height: 1.45;
}

.button-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.action {
  min-height: 48px;
  border-radius: 18px;
  background: var(--card-strong);
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-weight: 700;
  transition: transform 0.18s ease;
}

.action.primary {
  background: var(--accent);
  color: #fff8f2;
}

.action.soft {
  background: var(--teal-soft);
  color: var(--teal);
}

.section-title {
  margin: 2px 0 0;
  font-size: 0.98rem;
}

.caption {
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.92rem;
}

.stack {
  display: grid;
  gap: 10px;
}

.list-btn {
  width: 100%;
  text-align: left;
  padding: 14px;
  border-radius: 20px;
  background: rgba(26, 34, 42, 0.92);
  border: 1px solid transparent;
  color: var(--ink);
}

.list-btn.selected {
  border-color: rgba(243, 111, 58, 0.34);
  box-shadow: inset 0 0 0 1px rgba(243, 111, 58, 0.18);
}

.list-btn strong,
.list-btn span {
  display: block;
}

.list-btn span {
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.35;
  font-size: 0.9rem;
}

.tunnel-list-item {
  width: 100%;
  text-align: left;
  padding: 14px;
  border-radius: 20px;
  background: rgba(26, 34, 42, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--ink);
}

.tunnel-list-item strong,
.tunnel-list-item span {
  display: block;
}

.tunnel-list-item span {
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.35;
  font-size: 0.9rem;
}

.editor-box {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.editor-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.editor-actions button {
  min-height: 44px;
  border-radius: 16px;
  background: var(--card-strong);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--ink);
  font-weight: 700;
}

.editor-actions .danger {
  background: rgba(243, 111, 58, 0.18);
  color: var(--accent-deep);
}

.image-preview {
  display: none;
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(20, 28, 35, 0.92);
}

.pin-marker {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.24);
}

.leaflet-control-zoom a {
  border-radius: 14px;
}

.leaflet-popup-content {
  margin: 12px 14px;
  min-width: 180px;
}

.popup-title {
  margin: 0 0 8px;
  font-size: 1rem;
  font-weight: 700;
}

.popup-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
  white-space: pre-wrap;
}

.popup-image {
  width: 100%;
  max-height: 120px;
  object-fit: cover;
  border-radius: 12px;
  margin: 8px 0;
}

@media (min-width: 1100px) {
  .page-map {
    padding: 24px;
  }

  .page-map .app-shell {
    min-height: calc(100vh - 48px);
    grid-template-columns: minmax(0, 1.45fr) 430px;
    grid-template-rows: auto 1fr auto;
  }

  .page-map .topbar {
    grid-column: 1 / -1;
    padding: 24px 24px 16px;
  }

  .page-map .brand-title {
    font-size: 1.9rem;
  }

  .page-map .subtle {
    font-size: 0.98rem;
  }

  .page-map .map-wrap {
    padding: 0 0 24px 24px;
    min-height: 760px;
  }

  .page-map #map {
    min-height: 760px;
  }

  .page-map .map-chips {
    left: 40px;
    right: 40px;
    max-width: 520px;
  }

  .page-map .fab-row {
    left: 40px;
    right: auto;
    bottom: 42px;
    width: min(560px, calc(100% - 80px));
  }

  .page-map .sheet {
    margin: 0 24px 24px 18px;
    min-height: 760px;
    border-radius: 32px;
  }

  .page-map .sheet-handle {
    display: none;
  }

  .page-map .sheet-tabs {
    padding: 18px 18px 14px;
  }

  .page-map .sheet-content {
    padding: 0 18px 18px;
  }

  .page-map .button-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 700px) and (max-width: 1099px) {
  .page-map .app-shell {
    width: min(100%, 980px);
  }

  .page-map .topbar {
    padding: 20px 20px 14px;
  }

  .page-map .map-wrap {
    padding: 0 18px 18px;
  }

  .page-map #map {
    min-height: 480px;
  }

  .page-map .sheet {
    margin: 0 18px 18px;
  }

  .page-map .sheet-content {
    padding: 0 18px 18px;
  }
}

@media (max-width: 560px) {
  .page-gate,
  .page-redirect {
    padding: 0;
  }

  .page-gate .app-shell,
  .page-map .app-shell {
    width: 100%;
    min-height: 100vh;
    border-radius: 0;
  }

  .page-map {
    padding: 0;
  }

  .page-map .field-row,
  .page-map .editor-actions {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 699px) {
  .page-map {
    padding: 0;
  }

  .page-map .app-shell {
    width: 100%;
    min-height: 100vh;
    border-radius: 0;
    display: block;
    position: relative;
    overflow: hidden;
  }

  .page-map .topbar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 800;
    padding: calc(14px + env(safe-area-inset-top)) 14px 10px;
    align-items: flex-start;
  }

  .page-map .brand {
    gap: 2px;
  }

  .page-map .brand-title {
    font-size: 1.4rem;
  }

  .page-map .subtle {
    max-width: 240px;
  }

  .page-map .status-pill {
    backdrop-filter: blur(14px);
  }

  .page-map .map-wrap {
    position: absolute;
    inset: 0;
    padding: 0;
    min-height: 100%;
  }

  .page-map #map {
    min-height: 100%;
    height: 100%;
    border-radius: 0;
    box-shadow: none;
  }

  .page-map .map-chips {
    left: 14px;
    right: 14px;
    top: calc(88px + env(safe-area-inset-top));
    z-index: 700;
  }

  .page-map .chip {
    backdrop-filter: blur(12px);
  }

  .page-map .fab-row {
    left: 14px;
    right: 14px;
    bottom: calc(166px + env(safe-area-inset-bottom));
    grid-template-columns: repeat(2, minmax(0, 1fr));
    z-index: 700;
  }

  .page-map .fab {
    backdrop-filter: blur(14px);
  }

  .page-map .sheet {
    position: absolute;
    left: 0;
    right: 0;
    bottom: env(safe-area-inset-bottom);
    margin: 0;
    height: calc(100dvh - 102px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    border-radius: 30px 30px 0 0;
    box-shadow: 0 -16px 40px rgba(0, 0, 0, 0.28);
    z-index: 750;
    transform: translateY(0);
    transition: transform 0.22s ease;
    will-change: transform;
  }

  .page-map .sheet-handle {
    width: 56px;
    height: 6px;
    margin-top: 12px;
    margin-bottom: 6px;
  }

  .page-map .sheet-tabs {
    padding-top: 8px;
    padding-bottom: 12px;
  }

  .page-map .sheet-content {
    padding-bottom: 20px;
  }
}
