/* ============================================================
   AKMENŲ ARCHYVAS – Pagrindinis stilius
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green:       #1D9E75;
  --green-light: #E1F5EE;
  --green-dark:  #0F6E56;
  --amber:       #BA7517;
  --amber-light: #FAEEDA;
  --red:         #A32D2D;
  --red-light:   #FCEBEB;
  --purple:      #534AB7;
  --purple-light:#EEEDFE;
  --blue:        #185FA5;
  --blue-light:  #E6F1FB;
  --gray-50:     #f9f9f8;
  --gray-100:    #f1f0ed;
  --gray-200:    #e2e1dc;
  --gray-400:    #9a9890;
  --gray-600:    #6b6960;
  --gray-900:    #1a1a18;
  --border:      rgba(0,0,0,0.1);
  --radius:      8px;
  --radius-lg:   12px;
  --shadow:      0 1px 4px rgba(0,0,0,0.12);
  --font:        -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html, body { height: 100%; overflow: hidden; font-family: var(--font); color: var(--gray-900); background: var(--gray-100); font-size: 14px; }

/* ── TOP BAR ─────────────────────────────────────────────── */
#topbar {
  display: flex; align-items: center; gap: 12px;
  height: 52px; padding: 0 16px;
  background: white; border-bottom: 1px solid var(--border);
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
}
.logo { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; color: var(--gray-900); text-decoration: none; white-space: nowrap; }
.logo-icon { width: 30px; height: 30px; background: var(--green-light); border-radius: 7px; display: flex; align-items: center; justify-content: center; font-size: 16px; }
#search-wrap { flex: 1; max-width: 440px; position: relative; }
#search-input { width: 100%; padding: 8px 12px 8px 36px; border: 1px solid var(--gray-200); border-radius: var(--radius); background: var(--gray-50); font-size: 13px; outline: none; transition: border-color .15s; }
#search-input:focus { border-color: var(--green); background: white; }
.search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--gray-400); font-size: 15px; pointer-events: none; }
#search-results { position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: white; border: 1px solid var(--gray-200); border-radius: var(--radius); box-shadow: var(--shadow); z-index: 200; display: none; max-height: 280px; overflow-y: auto; }
.search-result-item { padding: 9px 14px; cursor: pointer; font-size: 13px; border-bottom: 1px solid var(--gray-100); display: flex; align-items: center; gap: 8px; }
.search-result-item:hover { background: var(--gray-50); }
.search-result-item:last-child { border-bottom: none; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: var(--radius); font-size: 13px; cursor: pointer; border: 1px solid var(--gray-200); background: white; color: var(--gray-900); text-decoration: none; transition: background .12s; }
.btn:hover { background: var(--gray-50); }
.btn-primary { background: var(--green); color: white; border-color: var(--green-dark); }
.btn-primary:hover { background: var(--green-dark); }
.btn-icon { padding: 7px 10px; }
#mobile-search-overlay { display: none; }
#lock-menu-wrap { position: relative; }
#lock-menu { position: absolute; top: calc(100% + 6px); right: 0; background: white; border: 1px solid var(--gray-200); border-radius: var(--radius); box-shadow: 0 4px 12px rgba(0,0,0,.12); min-width: 160px; z-index: 500; overflow: hidden; }
#lock-menu.hidden { display: none; }
.lock-menu-item { display: flex; align-items: center; gap: 8px; padding: 10px 14px; font-size: 13px; color: var(--gray-900); text-decoration: none; transition: background .1s; }
.lock-menu-item:hover { background: var(--gray-50); }
.lock-menu-logout { color: #c0392b; border-top: 1px solid var(--gray-100); }

/* ── LAYOUT ──────────────────────────────────────────────── */
#app { display: flex; height: calc(100vh - 52px); margin-top: 52px; }

/* ── SIDENAV ─────────────────────────────────────────────── */
#sidenav {
  width: 52px; flex-shrink: 0;
  background: white; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center;
  padding: 10px 0; gap: 4px; z-index: 100;
}
.snav-btn { width: 38px; height: 38px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--gray-400); font-size: 19px; transition: all .12s; border: none; background: none; position: relative; }
.snav-btn:hover { background: var(--gray-100); color: var(--gray-900); }
.snav-btn.active { background: var(--green-light); color: var(--green); }
.snav-sep { width: 28px; height: 1px; background: var(--border); margin: 4px 0; }
.snav-bottom { margin-top: auto; }

/* ── VIEWS ───────────────────────────────────────────────── */
.view { display: none; flex: 1; overflow: hidden; }
.view.active { display: flex; }

/* ── SIDE PANEL TOGGLE ───────────────────────────────────── */
.side-panel {
  transition: width .25s ease, min-width .25s ease;
  overflow: hidden;
}
.side-panel.collapsed { width: 0 !important; min-width: 0 !important; padding: 0 !important; border: none !important; }

/* ── FILTERS PANEL ───────────────────────────────────────── */
#filters-panel {
  width: 210px; flex-shrink: 0; background: white;
  border-right: 1px solid var(--border);
  overflow-y: auto; padding: 14px 12px;
}
.fp-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.fp-head-title { font-size: 11px; font-weight: 600; color: var(--gray-600); letter-spacing: .05em; text-transform: uppercase; }
.fp-clear { font-size: 11px; color: var(--blue); cursor: pointer; background: none; border: none; }
.fp-section { margin-bottom: 16px; }
.fp-section-label { font-size: 11px; font-weight: 600; color: var(--gray-600); margin-bottom: 7px; }
.fp-item { display: flex; align-items: center; justify-content: space-between; padding: 4px 0; cursor: pointer; user-select: none; }
.fp-item-l { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--gray-900); }
.fp-item-l input[type=checkbox] { accent-color: var(--green); width: 14px; height: 14px; cursor: pointer; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.fp-count { font-size: 11px; color: var(--gray-400); }
.fp-select { width: 100%; font-size: 12px; padding: 6px 8px; border: 1px solid var(--gray-200); border-radius: var(--radius); background: white; outline: none; color: var(--gray-900); }
.fp-toggle-row { display: flex; align-items: center; justify-content: space-between; font-size: 12px; }
.toggle-sw { width: 34px; height: 19px; border-radius: 10px; background: var(--gray-200); position: relative; cursor: pointer; transition: background .15s; flex-shrink: 0; }
.toggle-sw.on { background: var(--green); }
.toggle-sw::after { content: ''; width: 15px; height: 15px; border-radius: 50%; background: white; position: absolute; top: 2px; left: 2px; transition: left .15s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.toggle-sw.on::after { left: 17px; }
.fp-footer { border-top: 1px solid var(--border); padding-top: 12px; font-size: 12px; color: var(--gray-600); display: flex; flex-direction: column; gap: 4px; }
.fp-footer strong { color: var(--gray-900); }

/* ── MAP ─────────────────────────────────────────────────── */
#map-wrap { flex: 1; position: relative; z-index: 1; }
#map { width: 100%; height: 100%; }

/* Leaflet customization */
.leaflet-popup-content-wrapper { border-radius: var(--radius-lg); box-shadow: 0 4px 16px rgba(0,0,0,.15); border: 1px solid var(--border); }
.leaflet-popup-content { margin: 14px 16px; min-width: 180px; }
.popup-name { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.popup-loc { font-size: 12px; color: var(--gray-600); margin-bottom: 8px; display: flex; align-items: center; gap: 4px; }
.popup-status { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; padding: 3px 8px; border-radius: 20px; margin-bottom: 10px; }
.popup-btn { display: block; width: 100%; text-align: center; padding: 7px; background: var(--green); color: white; border: none; border-radius: var(--radius); cursor: pointer; font-size: 12px; font-weight: 500; margin-bottom: 5px; }
.popup-btn:hover { background: var(--green-dark); }
.popup-btn-outline { display: block; width: 100%; text-align: center; padding: 6px; background: white; color: var(--blue); border: 1px solid var(--gray-200); border-radius: var(--radius); cursor: pointer; font-size: 11px; font-weight: 500; }
.popup-btn-outline:hover { background: var(--blue-light); }
.stone-name-tooltip { background: white; border: 1px solid var(--gray-200); border-radius: 6px; box-shadow: 0 2px 8px rgba(0,0,0,.14); color: var(--gray-900); font-size: 12px; font-weight: 600; padding: 4px 8px; }
.stone-name-tooltip::before { border-top-color: var(--gray-200); }

/* Custom pin icons */
.pin-icon { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid white; box-shadow: 0 1px 5px rgba(0,0,0,.35); }

/* ── STONE LIST PANEL ────────────────────────────────────── */
#stone-list-panel {
  width: 240px; flex-shrink: 0; background: white;
  border-left: 1px solid var(--border);
  display: flex !important; flex-direction: column; overflow: hidden;
}
.slp-head { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.slp-title { font-size: 13px; font-weight: 600; color: var(--gray-900); }
.slp-sort { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.slp-sort label { font-size: 11px; color: var(--gray-600); }
.slp-sort select { font-size: 11px; border: 1px solid var(--gray-200); border-radius: 5px; padding: 3px 6px; flex: 1; outline: none; }
#stone-list { flex: 1; overflow-y: auto; }
.stone-item { display: flex; align-items: center; gap: 9px; padding: 9px 12px; border-bottom: 1px solid var(--gray-100); cursor: pointer; transition: background .1s; }
.stone-item:hover, .stone-item.active { background: var(--green-light); }
.stone-thumb { width: 38px; height: 38px; border-radius: 6px; object-fit: cover; background: var(--gray-100); flex-shrink: 0; display: flex; align-items: center; justify-content: center; color: var(--gray-400); font-size: 16px; overflow: hidden; }
.stone-thumb img { width: 100%; height: 100%; object-fit: cover; }
.stone-info { flex: 1; min-width: 0; }
.stone-name { font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stone-reg { font-size: 11px; color: var(--gray-600); }
.stone-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.slp-pagination { padding: 8px 12px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: var(--gray-600); }
.pg-btn { padding: 3px 8px; border: 1px solid var(--gray-200); border-radius: 5px; cursor: pointer; background: white; font-size: 12px; }
.pg-btn:hover { background: var(--gray-50); }
.pg-btn:disabled { opacity: .4; cursor: default; }

/* ── DETAIL PANEL ────────────────────────────────────────── */
#detail-panel {
  width: 320px; flex-shrink: 0; background: white;
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
  transition: transform .2s;
}
#detail-panel.hidden { display: none; }
.dp-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.dp-back { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--blue); cursor: pointer; background: none; border: none; }
.dp-actions { display: flex; gap: 6px; }
.icon-btn { width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; border: 1px solid var(--gray-200); border-radius: var(--radius); cursor: pointer; color: var(--gray-600); background: white; font-size: 15px; text-decoration: none; }
.icon-btn:hover { background: var(--gray-50); }
.dp-photo { height: 170px; flex-shrink: 0; position: relative; overflow: hidden; background: var(--gray-200); }
.dp-photo img { width: 100%; height: 100%; object-fit: cover; }
.dp-photo-empty { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; color: var(--gray-400); font-size: 40px; }
.dp-photo-count { position: absolute; bottom: 8px; right: 8px; background: rgba(0,0,0,.55); color: white; font-size: 11px; padding: 2px 8px; border-radius: 20px; }
.dp-body { flex: 1; overflow-y: auto; padding: 0 14px 16px; }
.dp-title { font-size: 17px; font-weight: 600; padding: 12px 0 2px; }
.dp-alt-name { font-size: 12px; color: var(--gray-400); font-style: italic; padding-bottom: 6px; }
.dp-badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; padding: 3px 9px; border-radius: 20px; margin-bottom: 12px; }
.dp-tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 12px; gap: 0; }
.dp-tab { font-size: 11px; padding: 7px 10px; cursor: pointer; color: var(--gray-600); border-bottom: 2px solid transparent; white-space: nowrap; }
.dp-tab.active { color: var(--green); border-bottom-color: var(--green); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }
.dp-sec-label { font-size: 10px; font-weight: 600; color: var(--gray-400); letter-spacing: .05em; text-transform: uppercase; margin: 12px 0 6px; }
.dp-row { display: flex; justify-content: space-between; align-items: flex-start; padding: 5px 0; border-bottom: 1px solid var(--gray-100); gap: 8px; font-size: 12px; }
.dp-row:last-child { border-bottom: none; }
.dp-k { color: var(--gray-600); flex-shrink: 0; }
.dp-v { color: var(--gray-900); font-weight: 500; text-align: right; }
.dp-desc-text { font-size: 12px; color: var(--gray-600); line-height: 1.65; }
.dp-comment-box { background: var(--gray-50); border-radius: var(--radius); padding: 9px 11px; font-size: 12px; color: var(--gray-600); line-height: 1.65; margin-top: 4px; }
.dp-status-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 4px; }
.dp-status-card { background: var(--gray-50); border-radius: var(--radius); padding: 8px 10px; }
.dp-status-lbl { font-size: 10px; color: var(--gray-400); margin-bottom: 3px; }
.dp-status-val { font-size: 11px; font-weight: 500; display: flex; align-items: center; gap: 4px; }
.dp-source-link { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--blue); padding: 5px 0; border-bottom: 1px solid var(--gray-100); text-decoration: none; }
.dp-source-link:hover { text-decoration: underline; }
.dp-source-link:last-child { border-bottom: none; }
.route-tag { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--blue); background: var(--blue-light); padding: 3px 9px; border-radius: 20px; margin: 3px 3px 0 0; }
.photo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 4px; }
.photo-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius); cursor: pointer; }

/* ── TABLE VIEW ──────────────────────────────────────────── */
#view-table { flex-direction: column; background: white; }
.tv-toolbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.tv-title { font-size: 15px; font-weight: 600; }
.tv-actions { margin-left: auto; display: flex; gap: 8px; }
.tv-table-wrap { flex: 1; overflow: auto; }
.tv-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.tv-table th { padding: 9px 14px; text-align: left; font-size: 11px; font-weight: 600; color: var(--gray-600); border-bottom: 1px solid var(--border); background: var(--gray-50); white-space: nowrap; position: sticky; top: 0; cursor: pointer; user-select: none; }
.tv-table th:hover { background: var(--gray-100); }
.tv-table td { padding: 9px 14px; border-bottom: 1px solid var(--gray-100); color: var(--gray-900); vertical-align: middle; }
.tv-table tr:hover td { background: var(--gray-50); cursor: pointer; }
.tv-thumb { width: 34px; height: 34px; border-radius: 5px; object-fit: cover; background: var(--gray-100); display: flex; align-items: center; justify-content: center; color: var(--gray-400); font-size: 14px; }
.tv-thumb img { width: 34px; height: 34px; border-radius: 5px; object-fit: cover; }

/* ── ROUTE VIEW ──────────────────────────────────────────── */
#view-route { }
.rv-panel { width: 280px; flex-shrink: 0; background: white; border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; }
.rv-head { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.rv-head-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.rv-title { font-size: 14px; font-weight: 600; }
.rv-select { width: 100%; font-size: 12px; padding: 6px 8px; border: 1px solid var(--gray-200); border-radius: var(--radius); margin-bottom: 8px; outline: none; }
.rv-items { flex: 1; overflow-y: auto; }
.rv-item { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--gray-100); cursor: pointer; }
.rv-item:hover { background: var(--gray-50); }
.rv-num { width: 25px; height: 25px; border-radius: 50%; background: var(--green); color: white; font-size: 11px; font-weight: 600; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.rv-info { flex: 1; }
.rv-name { font-size: 13px; font-weight: 500; }
.rv-loc { font-size: 11px; color: var(--gray-600); }
.rv-dist { font-size: 11px; color: var(--gray-400); white-space: nowrap; }
.rv-footer { padding: 12px 14px; border-top: 1px solid var(--border); }
.rv-total { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 10px; }
.rv-map { flex: 1; }
#route-map { width: 100%; height: 100%; }

/* ── STATUS COLORS ───────────────────────────────────────── */
.dot-neaplankyta  { background: var(--gray-400); }
.dot-rastas       { background: var(--amber); }
.dot-nufoto       { background: var(--green); }
.dot-nerastas     { background: var(--red); }
.dot-reikia       { background: var(--purple); }

.badge-neaplankyta { background: var(--gray-100);   color: var(--gray-600); }
.badge-rastas      { background: var(--amber-light); color: var(--amber); }
.badge-nufoto      { background: var(--green-light); color: var(--green-dark); }
.badge-nerastas    { background: var(--red-light);   color: var(--red); }
.badge-reikia      { background: var(--purple-light);color: var(--purple); }

.mat-nera     { color: var(--gray-400); }
.mat-pirmine  { color: var(--amber); }
.mat-saltiniai{ color: var(--blue); }
.mat-viska    { color: var(--green); }

/* ── STATUS PILL ─────────────────────────────────────────── */
.status-pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; padding: 2px 9px; border-radius: 20px; white-space: nowrap; }

/* ── MODAL ───────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 2000; display: flex; align-items: center; justify-content: center; }
.modal-overlay.hidden { display: none; }
.modal-box { background: white; border-radius: var(--radius-lg); width: 360px; max-width: 92vw; box-shadow: 0 8px 32px rgba(0,0,0,.2); overflow: hidden; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.modal-title { font-size: 14px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--gray-400); width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius); }
.modal-close:hover { background: var(--gray-100); color: var(--gray-900); }
.modal-body { padding: 16px; }
.modal-route-list { display: flex; flex-direction: column; gap: 6px; max-height: 200px; overflow-y: auto; margin-bottom: 12px; }
.modal-route-btn { text-align: left; justify-content: flex-start; }
.modal-divider { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 4px; }
.modal-inline { display: flex; gap: 6px; margin-top: 6px; }
.modal-inline input { flex: 1; padding: 7px 9px; border: 1px solid var(--gray-200); border-radius: var(--radius); font-size: 12px; outline: none; }
.modal-inline input:focus { border-color: var(--green); }

/* ── TOAST ───────────────────────────────────────────────── */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #1a1a18; color: white; padding: 9px 18px; border-radius: var(--radius); font-size: 13px; z-index: 9999; pointer-events: none; opacity: 0; transition: opacity .2s; }
.toast.show { opacity: 1; }

/* ── LIGHTBOX ────────────────────────────────────────────── */
#lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.85); z-index: 9000; display: none; align-items: center; justify-content: center; }
#lightbox.open { display: flex; }
#lightbox img { max-width: 90vw; max-height: 90vh; border-radius: var(--radius); }
#lightbox-close { position: absolute; top: 20px; right: 24px; color: white; font-size: 28px; cursor: pointer; background: none; border: none; }

/* ── EMPTY STATE ─────────────────────────────────────────── */
.empty-state { padding: 40px 20px; text-align: center; color: var(--gray-400); }
.empty-state i { font-size: 36px; margin-bottom: 10px; display: block; }
.empty-state p { font-size: 13px; }

/* ── LOADING ─────────────────────────────────────────────── */
.loading { display: flex; align-items: center; justify-content: center; padding: 40px; color: var(--gray-400); gap: 10px; font-size: 13px; }
@keyframes spin { to { transform: rotate(360deg); } }
.spinner { width: 20px; height: 20px; border: 2px solid var(--gray-200); border-top-color: var(--green); border-radius: 50%; animation: spin .7s linear infinite; }

/* ── GALLERY VIEW ────────────────────────────────────────── */
#view-gallery { background: #0a0a0a; position: relative; overflow: hidden; }
#gallery-container { width: 100%; height: 100%; display: flex; flex-direction: column; position: relative; }

#gallery-topbar {
  position: absolute;
  top: 14px; left: 50%; transform: translateX(-50%);
  z-index: 20;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  border-radius: 20px;
  padding: 5px 16px;
  color: rgba(255,255,255,0.9);
  font-size: 13px;
  font-weight: 500;
  pointer-events: none;
}

#gallery-photo-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

#gallery-photo-wrap {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
}

#gallery-photo {
  max-width: 100%; max-height: 100%;
  object-fit: contain;
  user-select: none;
  transition: opacity 0.18s ease;
}
#gallery-photo.loading-fade { opacity: 0; }

.gallery-arrow {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(255,255,255,0.15); backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,0.2);
  color: white; font-size: 15px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  z-index: 20;
  transition: background 0.15s, opacity 0.15s;
}
.gallery-arrow:hover { background: rgba(255,255,255,0.3); }
.gallery-arrow:disabled { opacity: 0.2; cursor: default; }
.gallery-arrow-left  { left: 16px; }
.gallery-arrow-right { right: 16px; }

#gallery-info {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 60px 24px 28px;
  background: linear-gradient(to top, rgba(0,0,0,0.82) 0%, transparent 100%);
  color: white;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
#gallery-info > * { pointer-events: auto; }
#gallery-name { font-size: 22px; font-weight: 700; text-shadow: 0 1px 4px rgba(0,0,0,.6); }
#gallery-meta { display: flex; align-items: center; gap: 8px; }
.gallery-open-btn { align-self: flex-start; margin-top: 4px; }

#gallery-empty {
  display: none;
  position: absolute; inset: 0;
  align-items: center; justify-content: center; flex-direction: column; gap: 12px;
  color: rgba(255,255,255,0.4); font-size: 14px; text-align: center;
}
#gallery-empty i { font-size: 40px; display: block; }
#gallery-empty.visible { display: flex; }

/* ── DESKTOP ONLY: hide mobile elements ──────────────────── */
@media (min-width: 769px) {
  #mobile-bottom-nav { display: none; }
  #mobile-stone-mini { display: none !important; }
  #mobile-filter-btn { display: none; }
  #mobile-backdrop   { display: none !important; }
  .fp-mobile-close   { display: none; }
  .fp-mobile-apply   { display: none; }
}

/* ── MOBILE (≤ 768px) ────────────────────────────────────── */
@media (max-width: 768px) {

  /* Topbar */
  #topbar { height: 48px; padding: 0 10px; gap: 8px; }
  .logo-text { display: none; }
  .logo-icon { width: 34px; height: 34px; font-size: 18px; }
  .top-right .btn-icon { display: inline-flex; }
  #search-wrap { display: none; }
  #mobile-filter-btn { display: none; }

  /* Mobile search overlay */
  #mobile-search-overlay {
    display: none;
    position: fixed; top: 0; left: 0; right: 0;
    z-index: 1100;
    background: white;
    padding: 8px 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,.12);
  }
  #mobile-search-overlay.open { display: block; }
  #mobile-search-inner { position: relative; }
  #mobile-search-inner .search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--gray-400); font-size: 15px; pointer-events: none; }
  #mobile-search-input { width: 100%; padding: 9px 40px 9px 36px; border: 1px solid var(--gray-200); border-radius: var(--radius); background: var(--gray-50); font-size: 16px; outline: none; box-sizing: border-box; }
  #mobile-search-input:focus { border-color: var(--green); background: white; }
  #mobile-search-close { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); background: none; border: none; font-size: 16px; color: var(--gray-500); cursor: pointer; padding: 4px; }
  #mobile-search-results { position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: white; border: 1px solid var(--gray-200); border-radius: var(--radius); box-shadow: 0 4px 12px rgba(0,0,0,.1); z-index: 200; display: none; max-height: 280px; overflow-y: auto; }

  /* App layout – leave room for bottom nav */
  #app { margin-top: 48px; height: calc(100vh - 48px - 56px); }

  /* Hide desktop sidenav */
  #sidenav { display: none; }

  /* Hide desktop side panels */
  #stone-list-panel { display: none !important; }

  /* Map view */
  #view-map { position: relative; }
  #map-wrap { width: 100%; position: relative; }

  /* Leaflet zoom + attribution – shift up above mini stone card (~150px) */
  .leaflet-bottom.leaflet-right { bottom: 155px !important; }
  .leaflet-bottom.leaflet-left  { bottom: 155px !important; }

  /* ── Filters as bottom sheet on mobile ── */
  #filters-panel,
  #filters-panel.collapsed {
    display: flex !important;
    flex-direction: column;
    position: fixed !important;
    bottom: 56px; left: 0; right: 0; top: auto !important;
    width: 100% !important;
    min-width: 0 !important;
    max-height: 78vh;
    overflow-y: auto;
    border-right: none !important;
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
    padding: 0 16px 16px !important;
    z-index: 650;
    transform: translateY(calc(100% + 60px));
    transition: transform 0.3s ease;
  }
  #filters-panel.mobile-open {
    transform: translateY(0) !important;
  }
  .fp-mobile-close {
    background: none; border: none; cursor: pointer;
    color: var(--gray-400); font-size: 16px;
    width: 28px; height: 28px; display: flex;
    align-items: center; justify-content: center;
    border-radius: var(--radius); margin-left: 4px;
  }
  .fp-mobile-close:hover { background: var(--gray-100); color: var(--gray-900); }
  .fp-head { padding-top: 12px; }
  .fp-mobile-apply { padding-top: 8px; border-top: 1px solid var(--border); margin-top: 8px; }

  /* ── Mobile mini stone card ── */
  #mobile-stone-mini {
    position: fixed; bottom: 56px; left: 0; right: 0; z-index: 600;
    background: white; border-radius: 16px 16px 0 0;
    border-top: 1px solid var(--border);
    padding: 8px 16px 16px;
    box-shadow: 0 -2px 12px rgba(0,0,0,.15);
    transition: transform 0.3s ease;
  }
  #mobile-stone-mini.hidden {
    transform: translateY(calc(100% + 56px));
    pointer-events: none;
  }
  .msm-handle {
    width: 32px; height: 4px; background: var(--gray-200);
    border-radius: 2px; margin: 0 auto 10px;
  }
  .msm-name { font-size: 16px; font-weight: 600; margin-bottom: 4px; color: var(--gray-900); }
  .msm-meta {
    display: flex; align-items: center; gap: 8px;
    font-size: 12px; color: var(--gray-600); margin-bottom: 12px;
  }
  .msm-btns { display: flex; gap: 8px; }
  .msm-btns .btn { flex: 1; justify-content: center; padding: 10px; font-size: 13px; }

  /* ── Detail panel as bottom sheet ── */
  #detail-panel {
    position: fixed !important;
    bottom: 56px; left: 0; right: 0; top: auto !important;
    width: 100% !important;
    height: 80vh;
    border-left: none !important;
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
    z-index: 700;
    display: flex !important;
    transform: translateY(0);
    transition: transform 0.3s ease;
  }
  #detail-panel.hidden {
    transform: translateY(calc(100% + 60px));
    pointer-events: none;
  }
  /* Drag handle above detail panel head */
  .dp-head {
    position: relative;
    padding-top: 20px;
  }
  .dp-head::before {
    content: '';
    position: absolute;
    top: 8px; left: 50%;
    transform: translateX(-50%);
    width: 32px; height: 4px;
    background: var(--gray-200); border-radius: 2px;
  }

  /* ── Mobile backdrop ── */
  #mobile-backdrop {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 600;
    display: none;
  }
  #mobile-backdrop.active { display: block; }

  /* ── Mobile bottom nav ── */
  #mobile-bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0;
    height: 56px; background: white;
    border-top: 1px solid var(--border);
    display: flex; z-index: 800;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .mbn-btn {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 3px; font-size: 10px; color: var(--gray-400);
    background: none; border: none; cursor: pointer;
    padding: 6px 0; transition: color .12s;
    -webkit-tap-highlight-color: transparent;
  }
  .mbn-btn i { font-size: 20px; }
  .mbn-btn span { line-height: 1; }
  .mbn-btn.active { color: var(--green); }

  /* ── Table view on mobile ── */
  #view-table { flex-direction: column; }
  .tv-toolbar { padding: 8px 12px; }
  .tv-table-wrap { -webkit-overflow-scrolling: touch; }

  /* ── Route view on mobile – stack vertically ── */
  #view-route { flex-direction: column; }
  .rv-panel {
    width: 100% !important;
    height: 50%;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .rv-map { height: 50%; min-height: 180px; }

  /* Toast above bottom nav */
  .toast { bottom: 68px; }

  /* ── Gallery on mobile ── */
  #gallery-info {
    padding-bottom: calc(56px + env(safe-area-inset-bottom, 0) + 16px);
  }
  #gallery-name { font-size: 18px; }
  .gallery-arrow { display: none; }
  #gallery-topbar { top: 10px; font-size: 12px; padding: 4px 12px; }
}
