:root {
  --bg: #12100d;
  --panel: #1a1713;
  --panel-2: #211d18;
  --line: #41382d;
  --line-soft: #302a23;
  --text: #eee7d9;
  --muted: #a99f90;
  --gold: #c8a96b;
  --gold-2: #e0c58a;
  --danger: #b76d62;
  --ok: #7e9f78;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; }

.hidden { display: none !important; }

.topbar {
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 18px;
  background: linear-gradient(180deg, #1d1813, #17130f);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  width: 42px; height: 42px; display: grid; place-items: center;
  border: 1px solid var(--gold); color: var(--gold-2);
  font-size: 24px; font-weight: 700;
}
.brand h1 { margin: 0; font-size: 19px; letter-spacing: .12em; text-transform: uppercase; }
.brand span { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; letter-spacing: .08em; }
.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.layout {
  height: calc(100% - 70px);
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr) 330px;
}
.sidebar, .details-panel {
  min-width: 0;
  background: var(--panel);
  overflow-y: auto;
}
.sidebar { border-right: 1px solid var(--line); }
.details-panel { border-left: 1px solid var(--line); padding: 16px; }

.panel { padding: 16px; border-bottom: 1px solid var(--line-soft); }
.panel h2, .detail-section h3 {
  margin: 0 0 10px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .11em;
  color: var(--gold-2);
}
.section-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.field-label, .form-grid label > span, .editor-dialog label > span {
  display: block; margin-bottom: 6px; color: var(--muted);
  font-size: 12px; text-transform: uppercase; letter-spacing: .08em;
}

.input, .textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #110f0c;
  color: var(--text);
  padding: 10px 11px;
  outline: none;
}
.input:focus, .textarea:focus { border-color: var(--gold); }
.textarea { resize: vertical; min-height: 80px; }
.color-input { height: 42px; padding: 4px; }

.btn {
  border: 1px solid var(--line);
  background: #252019;
  color: var(--text);
  padding: 9px 12px;
  cursor: pointer;
}
.btn:hover { border-color: #6a5a47; }
.btn-gold { border-color: #8d754a; background: #392f20; color: #f5e7c6; }
.btn-danger { border-color: #714944; background: #35201e; color: #f0c1ba; }
.text-btn, .icon-btn {
  border: 0; background: transparent; color: var(--gold); cursor: pointer;
}
.icon-btn { font-size: 27px; line-height: 1; color: var(--muted); }

.connection-badge, .user-badge {
  padding: 7px 9px; border: 1px solid var(--line); color: var(--muted); font-size: 12px;
}
.connection-badge.online { color: #bdd1b8; border-color: #42583f; }

.filter-list { display: grid; gap: 5px; margin-bottom: 10px; }
.filter-row, .switch-row {
  display: flex; align-items: center; gap: 9px;
  min-height: 32px; cursor: pointer; color: #d8d0c2;
}
.category-dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; flex: 0 0 auto; }
.help-panel p { color: var(--muted); font-size: 13px; line-height: 1.45; }

.map-shell { position: relative; min-width: 0; background: #0e0c0a; }
#map { height: 100%; width: 100%; background: #0e0c0a; }
.leaflet-container { font-family: Georgia, "Times New Roman", serif; }
.leaflet-bar a { background: #1e1a16; color: var(--text); border-color: var(--line); }
.leaflet-bar a:hover { background: #2b251f; color: var(--gold-2); }
.leaflet-control-attribution { background: rgba(18,16,13,.8) !important; color: var(--muted); }
.leaflet-control-attribution a { color: var(--gold); }

.map-notice {
  position: absolute; z-index: 1000; left: 50%; top: 12px; transform: translateX(-50%);
  max-width: min(560px, calc(100% - 24px));
  padding: 10px 14px; background: rgba(25,20,15,.95);
  border: 1px solid var(--gold); color: #efe1c4;
}

.map-marker {
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 50% 50% 50% 8px;
  transform: rotate(-45deg);
  border: 2px solid rgba(255,255,255,.72);
  box-shadow: 0 2px 7px rgba(0,0,0,.65);
}
.map-marker span { transform: rotate(45deg); font-size: 16px; color: #15120e; font-weight: 700; }
.map-label {
  white-space: nowrap; padding: 3px 7px; background: rgba(18,16,13,.88);
  border: 1px solid rgba(200,169,107,.45); color: #f0e7d8; font-size: 12px;
}

.details-empty { text-align: center; color: var(--muted); padding: 50px 18px; }
.empty-icon { font-size: 34px; color: var(--gold); }
.details-empty h2 { color: var(--text); font-size: 18px; margin: 12px 0 6px; }

.details-heading { display: flex; gap: 12px; align-items: flex-start; }
.large-symbol {
  width: 48px; height: 48px; border: 1px solid var(--line);
  display: grid; place-items: center; font-size: 24px; color: var(--gold-2); flex: 0 0 auto;
}
.eyebrow { color: var(--gold); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; }
.details-heading h2 { margin: 4px 0; font-size: 21px; }
.muted { color: var(--muted); font-size: 12px; }
.description { margin: 16px 0; color: #d7cfc1; line-height: 1.55; white-space: pre-wrap; }
.action-row { display: flex; gap: 7px; flex-wrap: wrap; margin: 14px 0; }
.detail-section { border-top: 1px solid var(--line-soft); padding-top: 16px; margin-top: 16px; }

.comments { display: grid; gap: 10px; }
.comment {
  border-left: 2px solid #5d503f; padding: 8px 9px; background: #15120f;
}
.comment-head { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); }
.comment-body { margin-top: 6px; color: #ddd4c6; white-space: pre-wrap; line-height: 1.4; }
.comment-form { margin-top: 10px; display: grid; gap: 7px; }
.attachments { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
.attachment { position: relative; border: 1px solid var(--line); background: #100e0b; }
.attachment img { display: block; width: 100%; aspect-ratio: 4/3; object-fit: cover; }
.attachment button {
  position: absolute; right: 4px; top: 4px; border: 1px solid #704b45;
  background: rgba(29,17,15,.9); color: #efc0b8; cursor: pointer;
}
.upload-row { display: flex; gap: 7px; margin-top: 8px; }
.upload-row input { min-width: 0; flex: 1; color: var(--muted); }

.editor-dialog {
  width: min(650px, calc(100vw - 24px));
  max-height: calc(100vh - 30px);
  border: 1px solid #66563f;
  background: #191611;
  color: var(--text);
  padding: 0;
}
.editor-dialog::backdrop { background: rgba(0,0,0,.72); }
.editor-dialog form { padding: 18px; }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.dialog-head h2 { margin: 4px 0 0; font-size: 21px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid small { display: block; color: var(--muted); margin-top: 5px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.form-error { margin-top: 10px; color: #e7a49a; }
.small-dialog { width: min(420px, calc(100vw - 24px)); }

@media (max-width: 1080px) {
  .layout { grid-template-columns: 230px minmax(0,1fr); }
  .details-panel {
    position: absolute;
    right: 0; top: 70px; bottom: 0;
    width: min(360px, 90vw);
    z-index: 1100;
    box-shadow: -8px 0 20px rgba(0,0,0,.35);
  }
}

@media (max-width: 760px) {
  body { overflow: auto; }
  .topbar { height: auto; min-height: 70px; align-items: flex-start; padding: 11px; }
  .brand span { display: none; }
  .top-actions { max-width: 55%; }
  .layout { height: calc(100vh - 76px); grid-template-columns: 1fr; }
  .sidebar {
    position: absolute; z-index: 1050; left: 8px; top: 86px;
    width: min(245px, 72vw); max-height: 60vh; border: 1px solid var(--line);
    background: rgba(26,23,19,.96);
  }
  .help-panel { display: none; }
  .map-shell { grid-column: 1; }
  .details-panel { top: 76px; width: min(340px, 92vw); }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: 1; }
}

/* =========================================================
   LEAFLET DRAW TOOLBAR FIX
   Replaces missing Leaflet Draw sprite images with local CSS
   ========================================================= */

.leaflet-draw-toolbar a {
    background-image: none !important;
    position: relative;
    width: 34px !important;
    height: 34px !important;
    line-height: 34px !important;
    text-align: center;
    color: var(--text) !important;
    font-size: 18px;
    font-weight: bold;
}

/* Add Marker */
.leaflet-draw-draw-marker::before {
    content: "●";
    display: block;
    color: var(--gold-2);
    font-size: 18px;
}

/* Draw Route */
.leaflet-draw-draw-polyline::before {
    content: "⌁";
    display: block;
    color: var(--gold-2);
    font-size: 21px;
}

/* Draw Zone */
.leaflet-draw-draw-polygon::before {
    content: "◇";
    display: block;
    color: var(--gold-2);
    font-size: 21px;
}

/* Edit existing route / zone */
.leaflet-draw-edit-edit::before {
    content: "✎";
    display: block;
    color: var(--gold-2);
    font-size: 18px;
}

/* Delete tool if enabled later */
.leaflet-draw-edit-remove::before {
    content: "×";
    display: block;
    color: #d99b91;
    font-size: 22px;
}

/* =========================================================
   AMAROQ MAP - LEAFLET DRAW POINT / VERTEX FIX
   Removes the default white square drawing handles.
   ========================================================= */

/* Default Leaflet Draw point / vertex handles */
.leaflet-div-icon,
.leaflet-editing-icon {
    width: 14px !important;
    height: 14px !important;

    margin-left: -7px !important;
    margin-top: -7px !important;

    background: #c8a96b !important;
    border: 2px solid #241d15 !important;
    border-radius: 50% !important;

    box-shadow:
        0 0 0 1px rgba(235, 216, 176, 0.75),
        0 2px 5px rgba(0, 0, 0, 0.6) !important;
}

/* Prevent Leaflet's missing default marker artwork from appearing
   as a blank/white square while placing a marker. */
.leaflet-draw-guide-dash {
    background-color: #c8a96b !important;
    border-color: #c8a96b !important;
}

/* Drawing handles when editing routes/zones */
.leaflet-marker-icon.leaflet-editing-icon {
    background: #c8a96b !important;
    border: 2px solid #241d15 !important;
    border-radius: 50% !important;
}

/* Middle edit handles - make them smaller so they are distinguishable */
.leaflet-marker-icon.leaflet-editing-icon.leaflet-touch-icon {
    width: 12px !important;
    height: 12px !important;
}

/* Marker shown while placing a new map marker */
.amaroq-placement-marker {
    background: transparent !important;
    border: none !important;
}

.amaroq-placement-marker.leaflet-div-icon {
    width: 34px !important;
    height: 34px !important;

    margin-left: -17px !important;
    margin-top: -32px !important;

    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
}
