/* Grid Marks — Markup mode. See markup.js. */

.mk-toggle {
    display: flex; align-items: center; gap: 0.35rem;
    background: #fff; color: #0f172a; border: 2px solid rgba(0, 0, 0, 0.2); border-radius: 0.5rem;
    padding: 0.35rem 0.6rem; font: 700 12px/1 system-ui, sans-serif; cursor: pointer; background-clip: padding-box;
}
.mk-toggle i { font-size: 16px; }
.mk-toggle.is-active { background: #f59e0b; color: #fff; border-color: #b45309; }

/* while marking up, the marks FABs and list toggle get out of the way */
body.markup-mode .map-fab { display: none !important; }

#mk-ui.hidden { display: none; }
.mk-bar, .mk-toolbar, .mk-panel {
    position: fixed; z-index: 1100; background: #fff; box-shadow: 0 8px 30px rgba(15, 23, 42, 0.25);
    font-family: system-ui, -apple-system, 'Segoe UI', sans-serif; color: #0f172a;
}
.mk-bar {
    top: var(--mk-top, 72px); left: 50%; transform: translateX(-50%);
    width: min(640px, calc(100vw - 24px)); border-radius: 0.9rem; padding: 0.5rem 0.6rem;
}
.mk-bar-row { display: flex; align-items: center; gap: 0.4rem; }
.mk-badge { background: #f59e0b; color: #fff; font-size: 10px; font-weight: 800; letter-spacing: 0.06em; padding: 0.25rem 0.45rem; border-radius: 0.35rem; }
.mk-name { flex: 1; min-width: 0; font-size: 13px; font-weight: 700; border: 1px solid #e2e8f0; border-radius: 0.5rem; padding: 0.35rem 0.5rem; }
.mk-summary { font-size: 11px; color: #475569; margin-top: 0.35rem; }
.mk-detail-hint { font-size: 10px; color: #94a3b8; margin-top: 0.15rem; min-height: 0.8rem; }
.mk-menu { display: grid; gap: 0.25rem; margin-top: 0.5rem; border-top: 1px solid #e2e8f0; padding-top: 0.5rem; }
.mk-menu.hidden { display: none; }
.mk-menu-summary { font-size: 11px; color: #475569; padding: 0 0.2rem 0.2rem; }
@media (min-width: 768px) { .mk-menu-summary { display: none; } }
.mk-menu > button { text-align: left; font-size: 12px; font-weight: 600; padding: 0.5rem 0.6rem; border-radius: 0.5rem; background: #f8fafc; border: 1px solid #e2e8f0; cursor: pointer; }
.mk-menu > button:hover { background: #eef2ff; }
.mk-legend { display: grid; grid-template-columns: 1fr 1fr; gap: 0.2rem 0.8rem; font-size: 11px; color: #334155; padding: 0.4rem 0.2rem 0; }
.mk-legend-note { grid-column: 1 / -1; font-size: 10px; color: #64748b; margin-top: 0.2rem; }
.mk-sw { display: inline-block; width: 22px; height: 4px; border-radius: 2px; vertical-align: middle; margin-right: 0.4rem; }
.mk-sw-dash { height: 0; border-top: 3px dashed; background: none !important; }
.mk-sw-dot { height: 0; border-top: 3px dotted; background: none !important; }

.mk-act {
    display: inline-flex; align-items: center; gap: 0.3rem; font-size: 12px; font-weight: 700;
    background: #f1f5f9; color: #0f172a; border: none; border-radius: 0.5rem; padding: 0.45rem 0.6rem; cursor: pointer; min-height: 34px;
}
.mk-act:hover { background: #e2e8f0; }
.mk-act i { font-size: 15px; }
.mk-primary { background: #16a34a; color: #fff; }
.mk-primary:hover { background: #15803d; }
.mk-exit { background: #0f172a; color: #fff; }
.mk-exit:hover { background: #1e293b; }
.mk-danger { color: #dc2626 !important; }

.mk-toolbar {
    bottom: calc(env(safe-area-inset-bottom, 0px) + 14px); left: 50%; transform: translateX(-50%);
    width: min(720px, calc(100vw - 24px)); border-radius: 1rem; padding: 0.5rem;
}
.mk-tools { display: flex; gap: 0.3rem; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.mk-tools::-webkit-scrollbar { display: none; }
.mk-tool {
    flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 0.15rem; min-width: 62px;
    background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 0.7rem; padding: 0.4rem 0.35rem; font-size: 10.5px; font-weight: 700; color: #334155; cursor: pointer;
}
.mk-tool i { font-size: 20px; }
.mk-tool.is-active { background: #0f172a; border-color: #0f172a; color: #fff; }
.mk-hint { font-size: 11px; color: #64748b; padding: 0.35rem 0.2rem 0; }
.mk-draft { display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; padding-bottom: 0.45rem; margin-bottom: 0.4rem; border-bottom: 1px solid #e2e8f0; }
.mk-draft > span { flex: 1; font-size: 12px; font-weight: 700; min-width: 140px; }

.mk-panel {
    /* desktop: over the sidebar (not needed while marking up), so the map stays clear to tap */
    left: 12px; top: var(--mk-top, 84px); width: 360px; max-height: calc(100vh - var(--mk-top, 84px) - 20px);
    overflow-y: auto; border-radius: 1rem; padding: 0.7rem;
}
.mk-panel.hidden { display: none; }
.mk-ed-head { display: flex; align-items: center; gap: 0.4rem; }
.mk-ed-head > i { font-size: 20px; color: #0f172a; }
.mk-ed-label { flex: 1; min-width: 0; font-size: 15px; font-weight: 800; border: 1px solid transparent; border-radius: 0.4rem; padding: 0.2rem 0.3rem; }
.mk-ed-label:focus { border-color: #93c5fd; outline: none; }
.mk-ed-type { font-size: 10px; font-weight: 700; text-transform: uppercase; color: #64748b; }
.mk-seg { display: flex; gap: 0.25rem; margin: 0.55rem 0 0.35rem; flex-wrap: wrap; }
.mk-seg > button { flex: 1; font-size: 11.5px; font-weight: 700; padding: 0.45rem 0.4rem; border-radius: 0.5rem; border: 1px solid #e2e8f0; background: #f8fafc; cursor: pointer; min-height: 34px; }
.mk-seg > button.is-active { background: #0f172a; color: #fff; border-color: #0f172a; }
.mk-coords { font-size: 11px; color: #475569; font-family: ui-monospace, Menlo, monospace; margin: 0.3rem 0 0.5rem; }
.mk-ed-body { display: grid; gap: 0.45rem; }
.mk-field { display: grid; gap: 0.15rem; font-size: 11px; font-weight: 700; color: #475569; }
.mk-field input, .mk-field select, .mk-field textarea {
    font: 13px system-ui, sans-serif; color: #0f172a; border: 1px solid #e2e8f0; border-radius: 0.5rem; padding: 0.4rem 0.5rem; background: #fff; width: 100%; box-sizing: border-box;
}
.mk-row2 { display: grid; grid-template-columns: 1fr 2fr; gap: 0.4rem; }
.mk-src { font-size: 10.5px; color: #64748b; }
.mk-link { background: none; border: none; color: #2563eb; font-weight: 700; cursor: pointer; padding: 0; font-size: 10.5px; }
.mk-checks { display: grid; gap: 0.25rem; font-size: 12px; font-weight: 600; }
.mk-ed-foot { margin-top: 0.6rem; display: flex; justify-content: flex-end; }

/* map symbols */
.mk-pt {
    position: relative; width: 26px; height: 26px; display: flex; align-items: center; justify-content: center;
    border-radius: 50%; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5); color: #fff; font-size: 14px;
}
.mk-pt .mk-lbl {
    position: absolute; left: 50%; top: 100%; transform: translate(-50%, 2px); white-space: nowrap;
    font: 700 10px/1.2 system-ui, sans-serif; color: #0f172a; background: rgba(255, 255, 255, 0.92); padding: 0 3px; border-radius: 3px; pointer-events: none;
}
.mk-pole.mk-st-new { background: #16a34a; }
.mk-pole.mk-st-existing { background: #2563eb; }
.mk-pole.mk-st-recover { background: #dc2626; }
.mk-box { border-radius: 4px; }
.mk-box.mk-st-new { background: #16a34a; }
.mk-box.mk-st-existing { background: #2563eb; }
.mk-property { background: #f97316; }
.mk-hazard { background: var(--mk-c, #7c3aed); border-radius: 4px; transform: rotate(45deg); }
.mk-hazard > i { transform: rotate(-45deg); }
.mk-hazard .mk-lbl { transform: rotate(-45deg) translate(-30%, 8px); }
.mk-note { background: #475569; }
.mk-selected { outline: 3px solid #facc15; outline-offset: 2px; }
.mk-len { transform: translate(-50%, -50%); white-space: nowrap; font: 700 10px/1.2 system-ui, sans-serif; background: rgba(15, 23, 42, 0.8); color: #fff; padding: 1px 4px; border-radius: 3px; display: inline-block; }
.mk-hn { transform: translate(-50%, -50%); font: 800 10px/1 system-ui, sans-serif; color: #0f172a; background: rgba(255, 255, 255, 0.85); padding: 1px 3px; border-radius: 3px; display: inline-block; white-space: nowrap; }

@media (max-width: 767px) {
    /* one row on phones — every pixel of map matters; counts live in the menu */
    .mk-bar { padding: 0.35rem 0.45rem; }
    /* the bar has Exit and the street/satellite switch — these would only sit under it */
    body.markup-mode .leaflet-control-layers, body.markup-mode .mk-toggle { display: none; }
    .mk-bar .mk-summary { display: none; }
    .mk-detail-hint { font-size: 9.5px; margin-top: 0.1rem; min-height: 0; }
    .mk-badge { display: none; }
    .mk-panel {
        left: 8px; right: 8px; width: auto; top: auto; bottom: calc(env(safe-area-inset-bottom, 0px) + 8px);
        max-height: 58vh; border-radius: 1rem 1rem 0.8rem 0.8rem; z-index: 1110;
    }
    .mk-tool { min-width: 56px; }
}

/* design picker button in the bar */
.mk-design-btn {
    flex: 1; min-width: 0; display: flex; align-items: center; gap: 0.4rem; text-align: left;
    border: 1px solid #e2e8f0; border-radius: 0.5rem; padding: 0.35rem 0.5rem; background: #fff; cursor: pointer;
}
.mk-design-name { font-size: 13px; font-weight: 800; color: #0f172a; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.mk-design-btn > i { margin-left: auto; color: #64748b; }
.mk-tag { font-size: 10px; font-weight: 800; color: #1e40af; background: #dbeafe; border-radius: 0.3rem; padding: 0.1rem 0.35rem; white-space: nowrap; max-width: 40%; overflow: hidden; text-overflow: ellipsis; }

/* designs panel */
.mk-ds-title { flex: 1; font-size: 15px; }
.mk-ds-current { display: grid; gap: 0.4rem; margin: 0.5rem 0; padding: 0.5rem; background: #f8fafc; border-radius: 0.7rem; }
.mk-meter { margin: 0.4rem 0 0.6rem; }
.mk-meter-bar { height: 7px; background: #e2e8f0; border-radius: 4px; overflow: hidden; }
.mk-meter-bar > i { display: block; height: 100%; background: #16a34a; }
.mk-meter-text { font-size: 11.5px; font-weight: 700; margin-top: 0.25rem; }
.mk-meter-note { font-size: 10.5px; color: #64748b; }
.mk-ds-search { width: 100%; box-sizing: border-box; font-size: 13px; border: 1px solid #e2e8f0; border-radius: 0.5rem; padding: 0.45rem 0.55rem; }
.mk-ds-list { list-style: none; margin: 0.4rem 0; padding: 0; display: grid; gap: 0.3rem; }
.mk-ds-list > li { display: flex; align-items: center; gap: 0.4rem; padding: 0.45rem 0.5rem; border: 1px solid #e2e8f0; border-radius: 0.6rem; }
.mk-ds-list > li.is-open { border-color: #0f172a; background: #f8fafc; }
.mk-ds-info { flex: 1; min-width: 0; font-size: 12.5px; }
.mk-ds-info b { overflow-wrap: anywhere; }
.mk-ds-info small { display: block; color: #64748b; font-size: 10.5px; margin-top: 0.1rem; }
.mk-ds-open { font-size: 11px; font-weight: 800; color: #16a34a; padding: 0 0.3rem; }
.mk-ds-empty { justify-content: center; color: #64748b; font-size: 12px; }
.mk-ds-new { display: grid; gap: 0.35rem; margin-top: 0.4rem; padding-top: 0.5rem; border-top: 1px solid #e2e8f0; }
.mk-ds-new input { font-size: 13px; border: 1px solid #e2e8f0; border-radius: 0.5rem; padding: 0.45rem 0.55rem; }
.mk-ds-new .mk-act { justify-content: center; }
.mk-ds-full { font-size: 12px; font-weight: 600; color: #b45309; background: #fffbeb; border-radius: 0.5rem; padding: 0.5rem; margin: 0; }

/* photos */
.mk-photos { margin-top: 0.6rem; border-top: 1px solid #e2e8f0; padding-top: 0.5rem; }
.mk-photos-head { display: flex; align-items: center; justify-content: space-between; font-size: 11px; font-weight: 700; color: #475569; }
.mk-photo-add { background: #0f172a; color: #fff; }
.mk-photo-add:hover { background: #1e293b; }
.mk-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 0.35rem; margin-top: 0.4rem; }
.mk-thumb { padding: 0; border: none; border-radius: 0.4rem; overflow: hidden; aspect-ratio: 1; background: #e2e8f0; cursor: pointer; }
.mk-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mk-cam { position: absolute; top: -7px; right: -9px; width: 16px; height: 16px; border-radius: 50%; background: #0f172a; color: #fff; font-size: 10px; display: flex; align-items: center; justify-content: center; border: 1px solid #fff; }
.mk-len i { font-size: 10px; }
.mk-viewer { position: fixed; inset: 0; z-index: 1200; background: rgba(2, 6, 23, 0.92); display: flex; flex-direction: column; }
.mk-viewer.hidden { display: none; }
.mk-viewer-top { display: flex; align-items: center; gap: 0.5rem; padding: calc(env(safe-area-inset-top, 0px) + 0.6rem) 0.8rem 0.6rem; color: #e2e8f0; font: 600 12px system-ui, sans-serif; }
.mk-viewer-top > span { flex: 1; min-width: 0; }
.mk-viewer img { flex: 1; min-height: 0; width: 100%; object-fit: contain; }

/* design ↔ mark link */
.mk-link-line { font-size: 11px; color: #334155; margin-top: 0.2rem; display: flex; align-items: center; gap: 0.3rem; flex-wrap: wrap; }
.mk-link-line i { color: #d97706; }
.mk-link-deleted { color: #b91c1c; }
.mk-link-deleted i { color: #b91c1c; }
.mk-link-free { color: #64748b; }
.mk-link-free i { color: #94a3b8; }

/* floating panels: grip handles (drag the bar / toolbar out of the way) */
.mk-grip, .mk-grip-row { touch-action: none; cursor: grab; color: #94a3b8; user-select: none; -webkit-user-select: none; }
.mk-grip { display: flex; align-items: center; justify-content: center; width: 26px; min-height: 34px; border-radius: 0.4rem; font-size: 18px; flex: 0 0 auto; }
.mk-grip:hover, .mk-grip-row:hover { color: #475569; background: #f1f5f9; }
.mk-grip-row { display: flex; justify-content: center; font-size: 20px; line-height: 1; margin: -0.3rem 0 0.15rem; border-radius: 0.5rem; padding: 0.05rem 0; }
.mk-dragging { box-shadow: 0 16px 40px rgba(15, 23, 42, 0.35); opacity: 0.96; }
.mk-dragging .mk-grip, .mk-dragging .mk-grip-row { cursor: grabbing; color: #0f172a; }
