:root {
  --bg: #eef0ea;
  --panel: rgba(255, 255, 255, 0.94);
  --text: #1d211c;
  --muted: #6b7068;
  --line: rgba(0, 0, 0, 0.08);
  --line-strong: rgba(0, 0, 0, 0.16);
  --input-bg: #fff;
  --accent: #2f7d32;
  --danger: #d93025;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.08);
  --radius: 12px;
  --measure: #ff5a1f;
  --gap: max(16px, env(safe-area-inset-top));
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1d1a;
    --panel: rgba(36, 39, 35, 0.94);
    --text: #eceee9;
    --muted: #9ba096;
    --line: rgba(255, 255, 255, 0.1);
    --line-strong: rgba(255, 255, 255, 0.2);
    --input-bg: rgba(0, 0, 0, 0.25);
    --accent: #6cc070;
    --danger: #ff6b5e;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.3 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

button { font: inherit; }

#viewport {
  position: fixed;
  inset: 0;
  touch-action: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}
#viewport.dragging { cursor: grabbing; }
#viewport.over-feature { cursor: pointer; }
#viewport.measuring, #viewport.drawing { cursor: crosshair; }
#viewport.measuring.dragging, #viewport.drawing.dragging { cursor: grabbing; }

#map {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
}
.map-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  -webkit-user-drag: none;
  transition: opacity 0.2s ease, visibility 0s;
}
.map-layer.off { opacity: 0; visibility: hidden; transition: opacity 0.2s ease, visibility 0s 0.2s; }

.status {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  color: var(--muted);
  pointer-events: none;
}
.status[hidden] { display: none; }

.panel {
  position: fixed;
  background: var(--panel);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
[hidden] { display: none !important; }

/* ---------------------------------------------------------------------------
   Installations overlay
   --------------------------------------------------------------------------- */

#overlay, #measure-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}

#overlay path, #overlay line { fill: none; stroke-linecap: round; stroke-linejoin: round; }
#overlay .f-halo { stroke: #fff; stroke-width: 7; opacity: 0.9; }
#overlay .f-line { stroke: var(--c); stroke-width: 3.5; }
#overlay .dashed .f-line { stroke-dasharray: 8 7; }
#overlay .f-arrow-halo { stroke: #fff; stroke-width: 5.5; }
#overlay .f-arrow { stroke: var(--c); stroke-width: 2.5; }
#overlay .f-end { fill: var(--c); stroke: #fff; stroke-width: 2; }
#overlay .hover .f-line { stroke-width: 5; }
#overlay .hover .f-halo { stroke-width: 9; }
#overlay .sel .f-glow { stroke: var(--c); stroke-width: 18; stroke-opacity: 0.22; }
#overlay .sel .f-line { stroke-width: 5; }
#overlay .sel .f-halo { stroke-width: 9; }

#overlay .h-vertex { fill: #fff; stroke: var(--c); stroke-width: 2.5; }
#overlay .h-vertex.start { stroke-width: 3.5; }
#overlay .h-vertex.on { fill: var(--c); stroke: #fff; }
#overlay .h-mid { fill: var(--c); fill-opacity: 0.55; stroke: #fff; stroke-width: 1.5; }
#overlay .h-hit { fill: transparent; pointer-events: all; cursor: move; }
#overlay .h-preview { stroke: var(--c); stroke-width: 2; stroke-dasharray: 6 6; opacity: 0.85; }
#overlay .h-snap { fill: none; stroke: var(--c); stroke-width: 2.5; }

/* Measure overlay */
#measure-layer .m-line { fill: none; stroke: var(--measure); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
#measure-layer .m-halo { fill: none; stroke: #fff; stroke-width: 6; stroke-linejoin: round; stroke-linecap: round; opacity: 0.85; }
#measure-layer .m-fill { fill: var(--measure); fill-opacity: 0.18; stroke: none; }
#measure-layer .m-preview { fill: none; stroke: var(--measure); stroke-width: 2; stroke-dasharray: 6 6; opacity: 0.8; }
#measure-layer .m-vertex { fill: #fff; stroke: var(--measure); stroke-width: 3; }
#measure-layer .m-hit { fill: transparent; pointer-events: all; cursor: move; }
#measure-layer text {
  font: 600 12px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  fill: #1d211c;
  stroke: #fff;
  stroke-width: 4px;
  stroke-linejoin: round;
  paint-order: stroke;
  text-anchor: middle;
  dominant-baseline: central;
}
#measure-layer text.m-area-label { font-size: 15px; }

/* ---------------------------------------------------------------------------
   Top right: tools + mode button
   --------------------------------------------------------------------------- */

.top-right {
  position: fixed;
  top: var(--gap);
  right: max(16px, env(safe-area-inset-right));
  display: flex;
  gap: 8px;
}
.top-right > .panel { position: relative; }

.tools { display: flex; overflow: hidden; }
.tools button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.tools button + button { border-left: 1px solid var(--line); }
.tools button:hover { background: var(--line); }
.tools button[aria-pressed="true"] { background: var(--measure); color: #fff; }

.mode-btn {
  height: 44px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px 0 12px;
  border: 0;
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
}
.mode-btn:hover { background: var(--panel); filter: brightness(0.97); }
.mode-btn[aria-pressed="true"] { background: var(--accent); color: #fff; }

/* ---------------------------------------------------------------------------
   Left side panel (legend / editor)
   --------------------------------------------------------------------------- */

.side {
  top: var(--gap);
  left: max(16px, env(safe-area-inset-left));
  width: 230px;
  max-width: calc(100vw - 32px);
  max-height: calc(100dvh - var(--gap) - 24px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.side.editing { width: 320px; }
.side:empty { display: none; }

.side-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-right: 8px;
  flex: none;
}
.side-toggle {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}
.chev { transition: transform 0.2s ease; color: var(--muted); flex: none; }
.side.collapsed .chev { transform: rotate(-90deg); }
.side.collapsed .side-body { display: none; }

.side-body {
  overflow-y: auto;
  border-top: 1px solid var(--line);
  overscroll-behavior: contain;
}

.save-state {
  flex: none;
  border: 0;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: var(--line);
  white-space: nowrap;
}
.save-state.ok { color: var(--accent); background: transparent; }
.save-state.ok::before { content: "✓ "; }
.save-state.err { color: #fff; background: var(--danger); cursor: pointer; }

/* Legend */
.group-label {
  padding: 12px 14px 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.layer-list { list-style: none; margin: 0; padding: 0 6px 6px; }
.layer-list .empty { padding: 6px 8px 8px; font-size: 13px; color: var(--muted); }
.layer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 8px;
  border-radius: 8px;
  cursor: pointer;
}
.layer:hover { background: var(--line); }
.swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.line-swatch {
  width: 16px;
  height: 0;
  border-top: 3.5px solid var(--c);
  border-radius: 2px;
  flex: none;
}
.line-swatch.dashed { border-top-style: dashed; }
.layer-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Toggle switch */
.switch { position: relative; width: 36px; height: 22px; flex: none; }
.switch input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: inherit; }
.switch .track {
  position: absolute;
  inset: 0;
  border-radius: 11px;
  background: var(--muted);
  opacity: 0.45;
  transition: background 0.2s, opacity 0.2s;
}
.switch .thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s ease;
}
.switch input:checked ~ .track { background: var(--accent); opacity: 1; }
.switch input:checked ~ .thumb { transform: translateX(14px); }
.switch input:focus-visible ~ .track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Editor */
.ed-section { padding: 12px 10px 14px; }
.ed-section + .ed-section { border-top: 1px solid var(--line); }
.ed-section h3 {
  margin: 0 4px 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.ed-list { list-style: none; margin: 0; padding: 0; }
.ed-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 4px;
  border-radius: 8px;
}
.ed-row:hover { background: var(--line); }
.color-dot {
  position: relative;
  width: 22px;
  height: 22px;
  margin-right: 2px;
  border-radius: 6px;
  overflow: hidden;
  flex: none;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
}
.color-dot input {
  position: absolute;
  inset: -8px;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
}
.ed-name {
  flex: 1;
  min-width: 0;
  padding: 5px 6px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 14px;
}
.ed-name.strong { font-weight: 600; }
.ed-name:hover { border-color: var(--line-strong); }
.ed-name:focus { outline: none; border-color: var(--accent); background: var(--input-bg); }
.mini-btn {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  flex: none;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.mini-btn:hover:not(:disabled) { background: var(--line); color: var(--text); }
.mini-btn:disabled { opacity: 0.25; cursor: default; }
.mini-btn.off { color: var(--danger); }
.mini-btn.danger:hover:not(:disabled) { color: var(--danger); }

.ed-sys + .ed-sys { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.ed-opts {
  display: flex;
  gap: 14px;
  padding: 2px 6px 4px 34px;
  font-size: 12px;
  color: var(--muted);
}
.ed-opts label { display: flex; align-items: center; gap: 5px; cursor: pointer; }
.ed-opts input { margin: 0; accent-color: var(--accent); }

.feat-list { list-style: none; margin: 4px 0 0 28px; padding: 0; }
.feat-item {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.feat-item:hover { background: var(--line); }
.feat-item.sel { background: color-mix(in srgb, var(--accent) 16%, transparent); font-weight: 600; }
.feat-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feat-item .len { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; font-weight: 400; }

.add-btn {
  width: 100%;
  height: 34px;
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: transparent;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.add-btn:hover { background: var(--line); }
.add-btn.small { width: calc(100% - 28px); margin-left: 28px; height: 30px; margin-top: 4px; }
.add-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.ed-hint { margin: 0 4px 4px; font-size: 13px; color: var(--muted); }
.ed-scale { display: flex; align-items: center; gap: 8px; padding: 0 4px; font-size: 13px; color: var(--muted); }
.ed-scale .input { width: 90px; }

/* ---------------------------------------------------------------------------
   Cards (measure panel + inspector)
   --------------------------------------------------------------------------- */

.card {
  top: calc(var(--gap) + 56px);
  right: max(16px, env(safe-area-inset-right));
  width: 290px;
  max-height: calc(100dvh - var(--gap) - 56px - 200px);
  overflow-y: auto;
}
.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px 8px 14px;
  border-bottom: 1px solid var(--line);
}
.card-titles { flex: 1; min-width: 0; }
.card-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-sub { font-size: 12px; color: var(--muted); }
.card-body { padding: 12px 14px 14px; }

.icon-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  flex: none;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:hover { background: var(--line); color: var(--text); }

.big-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stats {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  margin: 8px 0 0;
  font-size: 13px;
}
.stats dt { color: var(--muted); }
.stats dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.hint { margin: 10px 0 0; font-size: 12px; color: var(--muted); }
.notes { margin: 12px 0 0; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }

.actions { display: flex; gap: 8px; margin-top: 12px; }
.text-btn {
  flex: 1;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.text-btn:hover:not(:disabled) { background: var(--line); }
.text-btn:disabled { color: var(--muted); opacity: 0.5; cursor: default; }
.text-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.text-btn.primary:hover:not(:disabled) { background: var(--accent); filter: brightness(1.08); }
.text-btn.danger { color: var(--danger); }
.text-btn.small { flex: none; height: 28px; font-size: 12px; }

.field { display: block; margin-top: 10px; }
.field:first-child { margin-top: 0; }
.field > span { display: block; margin-bottom: 4px; font-size: 12px; color: var(--muted); }
.input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
textarea.input { resize: vertical; min-height: 64px; line-height: 1.4; }

.dir-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; min-height: 28px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.check input { margin: 0; width: 16px; height: 16px; accent-color: var(--accent); }

/* ---------------------------------------------------------------------------
   Zoom, toasts, dialog
   --------------------------------------------------------------------------- */

.zoom {
  right: max(16px, env(safe-area-inset-right));
  bottom: max(24px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.zoom button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.zoom button + button { border-top: 1px solid var(--line); }
.zoom button:hover { background: var(--line); }
.zoom button:active { background: var(--line); transform: scale(0.94); }
.zoom button:disabled { color: var(--muted); opacity: 0.4; cursor: default; background: transparent; transform: none; }

.toasts {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(420px, calc(100vw - 140px));
  pointer-events: none;
  z-index: 20;
}
.toast {
  padding: 10px 14px;
  border-radius: 10px;
  background: #1d211c;
  color: #fff;
  font-size: 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
}
.toast.in { opacity: 1; transform: none; }
.toast.error { background: var(--danger); }

.dialog {
  width: min(340px, calc(100vw - 32px));
  padding: 20px;
  border: 0;
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}
.dialog::backdrop { background: rgba(0, 0, 0, 0.35); }
.dialog h2 { margin: 0 0 6px; font-size: 18px; }
.dialog p { margin: 0 0 12px; font-size: 14px; color: var(--muted); }
.dialog .pw-error { margin: 8px 0 0; color: var(--danger); }

/* ---------------------------------------------------------------------------
   Mobile
   --------------------------------------------------------------------------- */

@media (max-width: 600px) {
  .side { width: auto; min-width: 150px; max-width: calc(100vw - 32px - 152px); }
  .side.editing { width: calc(100vw - 32px - 152px); }
  /* Expanded: drop below the top-right buttons so "Listo" stays reachable */
  .side:not(.collapsed) {
    top: calc(var(--gap) + 56px);
    width: calc(100vw - 32px);
    max-width: calc(100vw - 32px);
    max-height: 58dvh;
    z-index: 5;
  }
  .mode-btn span { display: none; }
  .mode-btn { padding: 0 11px; }
  .card {
    top: auto;
    left: max(16px, env(safe-area-inset-left));
    right: calc(max(16px, env(safe-area-inset-right)) + 56px);
    bottom: max(24px, env(safe-area-inset-bottom));
    width: auto;
    max-height: 50dvh;
  }
  .big-value { font-size: 24px; }
  .input, .ed-name { font-size: 16px; } /* avoid iOS zoom on focus */
  .toasts { bottom: calc(max(24px, env(safe-area-inset-bottom)) + 150px); width: calc(100vw - 32px); }
}

/* Side panel footer (log out) */
.side-foot { padding: 6px 14px 12px; border-top: 1px solid var(--line); }
.ed-section + .side-foot, .layer-list + .side-foot { margin-top: 0; }
.link-btn {
  padding: 4px 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}
.link-btn:hover { color: var(--text); text-decoration: underline; }

/* Until the map has loaded (e.g. behind the login), hide the controls */
.booting .top-right, .booting .zoom { display: none; }

/* ---------------------------------------------------------------------------
   Photos: thumbnails on the card + full-screen viewer
   --------------------------------------------------------------------------- */

.feat-item .feat-name { flex: 1; }
.ph-count { display: inline-flex; align-items: center; gap: 2px; flex: none; color: var(--muted); font-size: 12px; font-weight: 400; }

.ph-head { margin: 14px 0 6px; font-size: 12px; color: var(--muted); }
.ph-head span { margin-left: 2px; color: var(--text); font-weight: 600; }
.ph-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.ph-thumb {
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 6px;
  overflow: hidden;
  background: var(--line);
  cursor: zoom-in;
}
.ph-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph-thumb:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.ph-busy { display: grid; place-items: center; cursor: default; }
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--line-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.ph-add { width: 100%; margin-top: 8px; gap: 6px; }

.lightbox {
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: #0d0e0d;
  color: #f2f3f0;
  overflow: hidden;
}
.lightbox::backdrop { background: #0d0e0d; }
.lightbox:focus { outline: none; }
.lb-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  touch-action: none;
}
.lb-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  cursor: zoom-in;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
}
.lightbox.zoomed .lb-stage { overflow: auto; touch-action: pan-x pan-y; }
.lightbox.zoomed .lb-img { width: auto; height: auto; max-width: none; max-height: none; cursor: zoom-out; }
.lightbox.zoomed .lb-bar, .lightbox.zoomed .lb-prev, .lightbox.zoomed .lb-next { display: none; }

.lb-btn {
  position: absolute;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  cursor: pointer;
}
.lb-btn:hover { background: rgba(0, 0, 0, 0.7); }
.lb-close { top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); }
.lb-prev { left: max(12px, env(safe-area-inset-left)); top: 50%; transform: translateY(-50%); }
.lb-next { right: max(12px, env(safe-area-inset-right)); top: 50%; transform: translateY(-50%); }

.lb-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 28px max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.75) 40%);
  font-size: 13px;
}
.lb-meta { display: flex; gap: 12px; color: rgba(255, 255, 255, 0.75); }
.lb-count { font-variant-numeric: tabular-nums; color: #fff; font-weight: 600; }
.lb-text { margin: 6px 0 0; max-width: 720px; font-size: 15px; white-space: pre-wrap; overflow-wrap: anywhere; }
.lb-edit { display: flex; gap: 8px; margin-top: 8px; max-width: 720px; }
.lb-edit .input { flex: 1; min-width: 0; background: rgba(255, 255, 255, 0.12); border-color: rgba(255, 255, 255, 0.2); color: #fff; }
.lb-edit .input::placeholder { color: rgba(255, 255, 255, 0.5); }
.lb-edit .text-btn { flex: none; height: auto; background: rgba(255, 255, 255, 0.1); border-color: transparent; color: #ff8a80; }

@media (max-width: 600px) {
  .lb-prev, .lb-next { display: none; } /* swipe instead */
  .lb-edit .input { font-size: 16px; }
}
