:root {
  color-scheme: dark;
  --bg: #101315;
  --panel: #191d20;
  --panel-strong: #20262a;
  --line: #2d3439;
  --text: #f3f5f2;
  --muted: #a9b1aa;
  --accent: #d8b04c;
  --accent-strong: #f0c85a;
  --danger: #e26558;
  --loot: #61c279;
  --weapon: #e0a24b;
  --vehicle: #55a8d7;
  --base: #ba81d8;
  --other: #c9cfd2;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

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

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(300px, 360px) 1fr;
  height: 100vh;
  min-height: 640px;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  padding: 18px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  z-index: 1000;
}

.brand {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.brand h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.15;
}

.brand p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.toolbar,
.form-actions,
.zoom-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.primary-button,
.ghost-button,
.danger-button,
.icon-button,
.zoom-controls button,
.category-tabs button {
  min-height: 38px;
  border-radius: 7px;
  padding: 0 13px;
  color: var(--text);
  background: var(--panel-strong);
  border: 1px solid var(--line);
}

.primary-button {
  background: var(--accent);
  border-color: var(--accent);
  color: #16130a;
  font-weight: 700;
}

.primary-button.active {
  background: var(--accent-strong);
  box-shadow: 0 0 0 3px rgb(216 176 76 / 20%);
}

.ghost-button:hover,
.icon-button:hover,
.zoom-controls button:hover,
.category-tabs button:hover {
  border-color: #59636a;
}

.danger-button {
  background: transparent;
  color: #ffafa7;
  border-color: rgb(226 101 88 / 50%);
}

.icon-button,
.zoom-controls button {
  display: inline-grid;
  place-items: center;
  width: 38px;
  padding: 0;
  font-size: 20px;
}

.search {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.search input,
.marker-form input,
.marker-form select,
.marker-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 11px;
  color: var(--text);
  background: #111517;
  outline: none;
}

.search input:focus,
.marker-form input:focus,
.marker-form select:focus,
.marker-form textarea:focus {
  border-color: var(--accent);
}

.category-tabs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.category-tabs button {
  min-width: 0;
  padding: 0 8px;
  font-size: 13px;
}

.category-tabs button.active {
  background: #2f352f;
  border-color: var(--accent);
}

.marker-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.marker-item {
  display: grid;
  grid-template-columns: 12px 1fr;
  gap: 10px;
  padding: 12px;
  text-align: left;
  color: var(--text);
  background: #14181b;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.marker-empty {
  margin: 0;
  padding: 14px;
  color: var(--muted);
  background: #14181b;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
}

.marker-item.selected {
  border-color: var(--accent);
}

.marker-dot-preview {
  background: var(--marker-color, var(--other));
  width: 10px;
  height: 10px;
  margin-top: 5px;
  border-radius: 999px;
}

.marker-item strong {
  display: block;
  margin-bottom: 3px;
  font-size: 14px;
}

.marker-item span,
.marker-item p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

/* ── Map area ─────────────────────────────────── */
.map-area {
  position: relative;
  min-width: 0;
  background: #0c0f10;
}

.map-topbar {
  position: absolute;
  z-index: 1000;
  top: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

#hintText {
  pointer-events: auto;
  background: rgb(16 19 21 / 86%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px;
  backdrop-filter: blur(12px);
  color: var(--muted);
  font-size: 13px;
  max-width: min(56vw, 520px);
}

/* Leaflet map container — must fill the map-area */
#map {
  width: 100%;
  height: 100%;
  background: #0c0f10;
}

/* Custom marker pins rendered via Leaflet divIcon */
.marker-pin {
  background: var(--marker-color, var(--other));
  width: 18px;
  height: 18px;
  border: 2px solid #101315;
  border-radius: 999px;
  box-shadow: 0 0 0 2px rgb(255 255 255 / 50%), 0 6px 14px rgb(0 0 0 / 45%);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.marker-pin.selected {
  width: 24px;
  height: 24px;
  box-shadow: 0 0 0 3px var(--accent), 0 8px 18px rgb(0 0 0 / 55%);
  z-index: 999 !important;
}

.marker-pin:hover {
  transform: scale(1.2);
}

/* Leaflet adding-mode cursor */
#map.adding-mode {
  cursor: crosshair !important;
}

/* Dark theme for Leaflet controls */
.leaflet-container {
  background: #0c0f10;
  font-family: inherit;
}

.leaflet-control-zoom a {
  background: var(--panel-strong) !important;
  color: var(--text) !important;
  border-color: var(--line) !important;
}

.leaflet-control-zoom a:hover {
  background: var(--panel) !important;
}

.leaflet-control-attribution {
  display: none;
}

/* ── Dialog ───────────────────────────────────── */
dialog {
  width: min(440px, calc(100vw - 32px));
  padding: 0;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

dialog::backdrop {
  background: rgb(0 0 0 / 58%);
}

.marker-form {
  display: grid;
  gap: 15px;
  padding: 16px;
}

.marker-form header,
.marker-form footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.marker-form h2 {
  margin: 0;
  font-size: 18px;
}

.marker-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.marker-form textarea {
  resize: vertical;
}

/* ── Responsive ───────────────────────────────── */
@media (max-width: 820px) {
  body {
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: 44vh 56vh;
    height: 100dvh;
    min-height: 0;
  }

  .sidebar {
    grid-row: 2;
    border-right: 0;
    border-top: 1px solid var(--line);
    padding: 14px;
  }

  .map-area {
    grid-row: 1;
  }

  .map-topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  #hintText {
    max-width: calc(100vw - 28px);
  }
}
