:root {
  color-scheme: dark;
  --bg: #090b0f;
  --panel: #101318;
  --panel-2: #181d24;
  --line: #2a3039;
  --text: #f2f5f8;
  --muted: #9aa4b2;
  --accent: #d6a34b;
  --public: #22c55e;
  --illegal: #ef4444;
  --retras: #f97316;
  --danger: #dc2626;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.46);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body,
.app-shell,
.map-stage,
#map {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

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

button,
select,
input,
textarea {
  border: 1px solid var(--line);
  background: #0f151d;
  color: var(--text);
}

button {
  min-height: 36px;
  border-radius: 7px;
  padding: 0 12px;
  cursor: pointer;
  font-weight: 650;
  transition: border-color 120ms ease, background 120ms ease, transform 120ms ease;
}

button:hover:not(:disabled) {
  border-color: rgba(214, 163, 75, 0.58);
  background: #202731;
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

button.danger {
  border-color: rgba(220, 38, 38, 0.65);
  background: rgba(220, 38, 38, 0.14);
  color: #fecaca;
}

select,
input {
  width: 100%;
  height: 38px;
  border-radius: 6px;
  padding: 0 10px;
  outline: none;
}

textarea {
  width: 100%;
  min-height: 150px;
  resize: vertical;
  border-radius: 6px;
  padding: 10px;
  outline: none;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
}

.app-shell {
  display: grid;
  grid-template-columns: 1fr minmax(360px, 430px);
}

.editor-panel {
  display: flex;
  min-height: 0;
  flex-direction: column;
  grid-column: 2;
  grid-row: 1;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  background:
    radial-gradient(circle at 20% 0%, rgba(214, 163, 75, 0.10), transparent 28%),
    linear-gradient(180deg, rgba(21, 25, 31, 0.98) 0%, rgba(13, 16, 21, 0.98) 100%);
  box-shadow: var(--shadow);
  z-index: 600;
}

.panel-header,
.panel-section,
.panel-footer {
  padding: 16px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
}

.panel-header h1,
.panel-section h2,
.eyebrow {
  margin: 0;
}

.panel-header h1 {
  font-size: 22px;
  letter-spacing: 0;
  font-weight: 800;
}

.panel-section h2 {
  font-size: 14px;
}

.eyebrow,
.field-label,
.muted {
  color: var(--muted);
  font-size: 12px;
}

.eyebrow {
  margin-bottom: 3px;
  text-transform: uppercase;
}

.status-pill {
  min-width: 82px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.status-pill.live {
  border-color: rgba(34, 197, 94, 0.45);
  background: rgba(34, 197, 94, 0.13);
  color: #86efac;
}

.status-pill.static {
  border-color: rgba(249, 115, 22, 0.45);
  background: rgba(249, 115, 22, 0.14);
  color: #fed7aa;
}

.panel-section {
  border-bottom: 1px solid rgba(38, 50, 65, 0.82);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.018), rgba(255, 255, 255, 0));
}

.coordinate-readout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--muted);
}

.coordinate-readout strong {
  color: var(--text);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 13px;
}

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

.field-label {
  display: block;
  margin-bottom: 7px;
}

.zone-browser {
  display: flex;
  min-height: 145px;
  flex: 1 1 auto;
  flex-direction: column;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.section-title-row input {
  max-width: 190px;
}

.zone-list {
  overflow: auto;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(9, 11, 15, 0.68);
}

.zone-row {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  border-bottom: 1px solid rgba(38, 50, 65, 0.7);
  border-radius: 0;
  background: transparent;
  padding: 10px 11px;
  text-align: left;
}

.zone-row.active {
  background: rgba(214, 163, 75, 0.15);
}

.zone-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.zone-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.zone-count {
  color: var(--muted);
  font-size: 12px;
}

.zone-details {
  flex: 0 0 auto;
}

.panel-footer {
  min-height: 48px;
  color: var(--muted);
  font-size: 12px;
}

.panel-footer {
  display: grid;
  gap: 6px;
}

.shortcut-line {
  color: #c7d0dc;
  line-height: 1.35;
}

.map-stage {
  position: relative;
  grid-column: 1;
  grid-row: 1;
  min-width: 0;
}

body:not(.dev-enabled) .app-shell {
  grid-template-columns: 1fr;
}

body:not(.dev-enabled) .editor-panel,
body:not(.dev-enabled) .map-toolbar {
  display: none;
}

#map {
  background: #05070a;
}

.map-layer-panel {
  position: absolute;
  left: 18px;
  bottom: 18px;
  z-index: 650;
  width: min(328px, calc(100% - 36px));
  border: 1px solid rgba(242, 245, 248, 0.14);
  border-radius: 8px;
  background: rgba(9, 12, 16, 0.9);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.42);
  padding: 10px;
  backdrop-filter: blur(14px);
}

.layer-panel-section + .layer-panel-section {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(242, 245, 248, 0.1);
}

.layer-panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
}

.layer-panel-title strong {
  color: #dbe4ee;
  font-size: 11px;
  font-weight: 800;
  text-transform: none;
}

.base-layer-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.overlay-layer-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.layer-choice,
.layer-toggle {
  min-width: 0;
  min-height: 34px;
  border-color: rgba(148, 163, 184, 0.24);
  background: rgba(18, 24, 32, 0.88);
  color: #dce5ef;
  font-size: 12px;
  line-height: 1.1;
  white-space: nowrap;
}

.layer-choice {
  padding: 0 8px;
}

.layer-toggle {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 7px;
  padding: 0 9px;
  text-align: left;
}

.layer-choice:hover:not(:disabled),
.layer-toggle:hover:not(:disabled) {
  border-color: rgba(226, 232, 240, 0.42);
  background: rgba(31, 41, 55, 0.94);
}

.layer-choice.active {
  border-color: rgba(214, 163, 75, 0.8);
  background: linear-gradient(180deg, rgba(214, 163, 75, 0.28), rgba(214, 163, 75, 0.14));
  color: #fff6df;
  box-shadow: inset 0 0 0 1px rgba(214, 163, 75, 0.16);
}

.layer-toggle.active {
  border-color: rgba(226, 232, 240, 0.34);
  background: rgba(31, 41, 55, 0.96);
  border-color: color-mix(in srgb, var(--layer-color) 58%, rgba(242, 245, 248, 0.2));
  background: color-mix(in srgb, var(--layer-color) 18%, rgba(18, 24, 32, 0.92));
  color: #f8fbff;
}

.layer-swatch {
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--layer-color);
  box-shadow: 0 0 0 3px rgba(226, 232, 240, 0.08);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--layer-color) 18%, transparent);
}

.map-toolbar {
  position: absolute;
  top: 14px;
  left: 50%;
  z-index: 650;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 36px);
  transform: translateX(-50%);
  border: 1px solid rgba(242, 245, 248, 0.13);
  border-radius: 8px;
  background: rgba(9, 12, 16, 0.9);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.42);
  padding: 7px;
  backdrop-filter: blur(14px);
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.map-toolbar button {
  min-height: 32px;
  border-color: rgba(148, 163, 184, 0.22);
  background: rgba(18, 24, 32, 0.88);
  color: #e5edf6;
  font-size: 12px;
  white-space: nowrap;
}

.map-toolbar button:hover:not(:disabled) {
  border-color: rgba(214, 163, 75, 0.58);
  background: rgba(31, 41, 55, 0.94);
}

.toolbar-status {
  min-width: 150px;
  max-width: 280px;
  overflow: hidden;
  border-left: 1px solid rgba(242, 245, 248, 0.12);
  padding: 0 8px 0 12px;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.toast {
  position: absolute;
  right: 18px;
  top: 74px;
  z-index: 700;
  max-width: min(420px, calc(100vw - 440px));
  border: 1px solid rgba(238, 243, 248, 0.16);
  border-radius: 8px;
  background: rgba(13, 17, 23, 0.92);
  box-shadow: var(--shadow);
  padding: 11px 14px;
  color: var(--text);
  font-size: 13px;
}

.leaflet-container {
  font-family: inherit;
  background: #05070a !important;
}

.leaflet-container,
.leaflet-pane,
.leaflet-tile-pane,
.leaflet-layer,
.leaflet-tile {
  background: transparent !important;
}

.leaflet-control-layers,
.leaflet-control-layers-expanded,
.leaflet-bar a,
.leaflet-bar a:hover {
  border-color: rgba(38, 50, 65, 0.85) !important;
  background: rgba(15, 21, 29, 0.93) !important;
  color: var(--text) !important;
}

.leaflet-control-layers label,
.leaflet-control-layers span,
.leaflet-control-layers input {
  color: var(--text) !important;
}

.leaflet-control-layers-separator {
  border-top-color: rgba(38, 50, 65, 0.8) !important;
}

.leaflet-control-attribution,
.leaflet-control-scale-line {
  background: rgba(15, 21, 29, 0.7) !important;
  color: var(--muted) !important;
  border-color: rgba(38, 50, 65, 0.85) !important;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: rgba(15, 21, 29, 0.98) !important;
  color: var(--text) !important;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.55) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
}

.leaflet-popup-content {
  color: var(--text) !important;
}

.leaflet-container a.leaflet-popup-close-button {
  color: #f8fafc !important;
}

.leaflet-popup-scrolled {
  border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
  border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
}

.leaflet-tooltip {
  background-color: rgba(15, 21, 29, 0.95) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  color: var(--text) !important;
}

.leaflet-div-icon {
  background: rgba(15, 21, 29, 0.95) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  color: var(--text) !important;
}

.zone-path {
  stroke-linejoin: round;
  stroke-linecap: round;
}

.zone-public {
  filter: drop-shadow(0 0 4px rgba(34, 197, 94, 0.55));
}

.zone-illegal {
  filter: drop-shadow(0 0 4px rgba(239, 68, 68, 0.45));
}

.zone-retras {
  filter: drop-shadow(0 0 3px rgba(249, 115, 22, 0.38));
}

.radar-icon-styled {
  filter: drop-shadow(0 0 7px rgba(239, 68, 68, 0.75));
}

.edit-vertex,
.edit-midpoint {
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(13, 17, 23, 0.9), 0 2px 8px rgba(0, 0, 0, 0.45);
}

.edit-vertex {
  width: 14px;
  height: 14px;
  background: #60a5fa;
  border: 2px solid #dbeafe;
}

.edit-midpoint {
  width: 10px;
  height: 10px;
  background: #f8fafc;
  border: 2px solid #64748b;
  opacity: 0.82;
}

.radar-popup {
  min-width: 190px;
  border: 1px solid rgba(248, 113, 113, 0.45);
  border-radius: 8px;
  background: #111827;
  padding: 12px;
  color: #f9fafb;
}

.radar-popup h3 {
  margin: 0 0 8px;
  color: #f87171;
  font-size: 14px;
}

.radar-popup p {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin: 4px 0;
  font-size: 12px;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(360px, 46vh) 1fr;
  }

  .editor-panel {
    order: 2;
    grid-column: 1;
    grid-row: 2;
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .map-stage {
    order: 1;
    grid-column: 1;
    grid-row: 1;
  }

  .toast {
    max-width: calc(100vw - 36px);
  }

  .map-layer-panel {
    left: 10px;
    right: 10px;
    bottom: 10px;
    width: auto;
    max-height: calc(100% - 92px);
    overflow: auto;
  }

  .base-layer-controls {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .overlay-layer-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .map-toolbar {
    left: 10px;
    right: 10px;
    transform: none;
    flex-wrap: wrap;
  }

  .toolbar-status {
    flex: 1 1 100%;
    border-left: 0;
    border-top: 1px solid rgba(242, 245, 248, 0.12);
    padding-top: 7px;
  }
}
