:root {
  --bg: #0b1220;
  --panel: rgba(11, 18, 32, 0.5);
  --panel-solid: #111827;
  --line: rgba(148, 163, 184, 0.28);
  --text: #f8fafc;
  --muted: #94a3b8;
  --accent: #22c55e;
  --accent-2: #16a34a;
  --danger: #f43f5e;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  --radius: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Cairo", system-ui, sans-serif;
  overflow: hidden;
}

button, input {
  font-family: inherit;
}

.hidden {
  display: none !important;
}

.setup {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: calc(24px + var(--safe-top)) 20px calc(24px + var(--safe-bottom));
  background:
    radial-gradient(circle at 20% 10%, rgba(34, 197, 94, 0.18), transparent 40%),
    radial-gradient(circle at 80% 90%, rgba(56, 189, 248, 0.12), transparent 40%),
    var(--bg);
}

.setup-card {
  width: min(440px, 100%);
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 28px 22px;
  box-shadow: var(--shadow);
}

.setup-logo {
  display: block;
  margin-bottom: 12px;
}

.setup h1 {
  margin: 0 0 8px;
  font-size: 1.55rem;
}

.setup p, .setup label {
  color: var(--muted);
  line-height: 1.7;
}

.setup label {
  display: block;
  margin: 18px 0 8px;
  color: var(--text);
  font-weight: 700;
}

.setup input {
  width: 100%;
  border: 1px solid var(--line);
  background: #0b1220;
  color: var(--text);
  border-radius: 14px;
  padding: 14px 12px;
  font-size: 16px;
}

.btn-primary {
  background: linear-gradient(180deg, #34d399, var(--accent-2));
  color: #052e16;
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  font-weight: 800;
  font-size: 1rem;
  cursor: pointer;
}

.setup .btn-primary {
  width: 100%;
  margin-top: 14px;
  min-height: 48px;
}

.help {
  margin-top: 16px;
  color: var(--muted);
}

.help ol {
  padding-right: 18px;
  line-height: 1.8;
}

.app {
  position: fixed;
  inset: 0;
}

#map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.leaflet-container {
  width: 100%;
  height: 100%;
  background: #0b1220;
  font-family: inherit;
}

.leaflet-div-icon {
  background: transparent;
  border: none;
}

.leaflet-control-attribution,
.leaflet-control-scale {
  display: none !important;
}

.img-meta {
  pointer-events: none;
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0 4px 2px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
  box-shadow: none;
}

.vertex-icon span {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: #052e16;
  font-weight: 800;
  font-size: 11px;
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.chrome-bar {
  display: grid;
  gap: 8px;
}

.search-wrap {
  position: relative;
}

.search {
  display: flex;
  gap: 8px;
  background: var(--panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 6px;
  box-shadow: var(--shadow);
}

.search input {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 10px 12px;
  font-size: 16px;
  outline: none;
  min-width: 0;
}

.search button,
.draw-actions button,
.color-toggle {
  border: 0;
  background: #1e293b;
  color: var(--text);
  border-radius: 12px;
  cursor: pointer;
}

.icon-btn,
.tool {
  border: 0;
  background: transparent;
  color: var(--text);
  border-radius: 12px;
  cursor: pointer;
}

.search button {
  padding: 0 14px;
  font-weight: 700;
}

.map-actions {
  display: flex;
  gap: 8px;
  justify-content: stretch;
}

.map-actions .icon-btn {
  flex: 1;
}

.icon-btn {
  width: 42px;
  height: 42px;
  background: transparent;
  backdrop-filter: none;
  border: 0;
  box-shadow: none;
  font-size: 20px;
  text-shadow: 0 1px 4px #000, 0 0 8px #000;
}

.icon-btn-text {
  width: auto;
  min-width: 42px;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 800;
}

.search-results {
  position: absolute;
  right: 0;
  left: 0;
  bottom: calc(100% + 6px);
  max-height: min(40vh, 280px);
  overflow-y: auto;
  z-index: 20;
  background: var(--panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.search-results button {
  display: block;
  width: 100%;
  text-align: right;
  background: transparent;
  color: var(--text);
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 12px;
  cursor: pointer;
}

.search-results button:last-child {
  border-bottom: 0;
}

.result {
  position: absolute;
  z-index: 1050;
  top: calc(10px + var(--safe-top));
  left: 10px;
  right: 10px;
  background: var(--panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px 12px;
  text-align: center;
  box-shadow: var(--shadow);
  pointer-events: none;
}

.result-kicker {
  font-weight: 800;
}

.result-extra, .empty, .toast {
  color: var(--muted);
}

.result-area {
  font-size: 1.35rem;
  font-weight: 800;
  color: #86efac;
  margin: 2px 0;
}

.tools-fab {
  position: absolute;
  z-index: 1100;
  left: 50%;
  bottom: calc(16px + var(--safe-bottom));
  transform: translateX(-50%);
  min-width: 148px;
  min-height: 48px;
  padding: 10px 22px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #14532d;
  color: #bbf7d0;
  font-size: 16px;
  font-weight: 800;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.app.tools-open .tools-fab,
.app.tools-open .annot-delete-fab,
.app.tools-open .annot-send-fab {
  display: none;
}

.annot-delete-fab,
.annot-send-fab {
  position: absolute;
  z-index: 1100;
  min-width: 88px;
  min-height: 48px;
  padding: 10px 18px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.annot-delete-fab {
  right: 16px;
  bottom: calc(16px + var(--safe-bottom));
  background: #9f1239;
}

.annot-send-fab {
  left: 16px;
  bottom: calc(16px + var(--safe-bottom));
  background: #1d4ed8;
}

body.has-pwa-ad .tools-fab,
body.has-pwa-ad .annot-delete-fab,
body.has-pwa-ad .annot-send-fab {
  bottom: calc(16px + var(--safe-bottom) + var(--pwa-ad-h, 64px));
}

.annot-delete-fab.hidden,
.annot-send-fab.hidden {
  display: none !important;
}

.tools-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-shadow: 0 1px 4px #000, 0 0 8px #000;
}

.tools-panel-head strong {
  font-size: 1.05rem;
}

.tools-close {
  border: 1px solid var(--line);
  background: #1e293b;
  color: var(--text);
  border-radius: 999px;
  min-height: 40px;
  padding: 8px 16px;
  font-weight: 800;
  cursor: pointer;
}

.toolbar {
  position: absolute;
  z-index: 1100;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: min(58vh, 520px);
  overflow-y: auto;
  padding: 10px 8px calc(10px + var(--safe-bottom));
  background: var(--panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 22px 22px 0 0;
  display: grid;
  gap: 8px;
  box-shadow: var(--shadow);
  transform: translateY(110%);
  visibility: hidden;
  pointer-events: none;
  transition: transform 0.22s ease, visibility 0.22s ease;
}

.toolbar.open {
  transform: translateY(0);
  visibility: visible;
  pointer-events: auto;
}

.pwa-copy {
  text-align: center;
  color: #e2e8f0;
  font-size: 11px;
  line-height: 1.55;
  padding: 6px 8px 0;
  text-shadow: 0 1px 4px #000, 0 0 8px #000;
}

.pwa-copy p { margin: 0; }

.pwa-copy strong {
  color: #e2e8f0;
  letter-spacing: 0.04em;
}

.pwa-install-bar {
  text-align: center;
  padding: 10px 10px 8px;
  background: #14532d;
  border: 1px solid rgba(187, 247, 208, 0.35);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.pwa-install-bar[hidden] { display: none !important; }

.pwa-install {
  display: inline-block;
  margin: 0;
  border: 0;
  background: #bbf7d0;
  color: #052e16;
  border-radius: 999px;
  padding: 10px 16px;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
}

#pwa-install-hint {
  margin: 6px 0 0;
  color: #bbf7d0;
  font-size: 12px;
  font-weight: 700;
}

.tools {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  overflow: visible;
  padding-bottom: 2px;
}

.tool {
  min-width: 0;
  min-height: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: transparent;
  border: 0;
  box-shadow: none;
  font-size: 11px;
  font-weight: 700;
  padding: 6px 4px;
  text-align: center;
  line-height: 1.25;
  text-shadow: 0 1px 4px #000, 0 0 8px #000;
}

.tool span {
  font-size: 22px;
  line-height: 1;
}

.tool.active {
  background: transparent;
  border: 0;
  color: #86efac;
}

.tool-pin,
.tool-pin {
  display: grid;
  place-items: center;
  height: 28px;
  line-height: 0;
}

.tool-pin svg,
.tool-pin svg {
  display: block;
}

.send-ways-label,
.send-ways-label {
  margin: 0 0 8px;
  font-size: 0.95rem;
  font-weight: 800;
  color: #e2e8f0;
}

.draw-bar {
  display: grid;
  gap: 6px;
  background: var(--panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 6px 8px;
}

.draw-bar-meta {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 24px;
}

.color-toggle {
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid #fff;
  flex: 0 0 auto;
  overflow: hidden;
  background: transparent;
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.45);
}

.color-swatch {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--c, #22c55e);
}

.draw-stats {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  font-weight: 700;
  color: #86efac;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.color-picker {
  position: absolute;
  inset-inline-start: 0;
  bottom: calc(100% + 6px);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: var(--panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow);
}

.color-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  flex: 0 0 auto;
  padding: 0;
  cursor: pointer;
  background: var(--c);
}

.color-dot.active {
  border-color: #fff;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.55);
}

.color-custom {
  width: 18px;
  height: 18px;
  border: 0;
  padding: 0;
  background: transparent;
  flex: 0 0 auto;
  cursor: pointer;
}

.layer-colors {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  align-items: center;
}

.layer-colors .color-dot {
  width: 24px;
  height: 24px;
}

.draw-actions {
  display: flex;
  align-items: stretch;
  gap: 4px;
}

#btn-right-angle.active,
.tool.recording {
  background: #14532d;
  border: 1px solid var(--accent);
  color: #bbf7d0;
}

.draw-actions button {
  flex: 1;
  min-width: 0;
  min-height: 36px;
  padding: 6px 4px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  border-radius: 10px;
}

#btn-finish {
  flex: 1.25;
}

.ghost {
  background: transparent !important;
  border: 1px solid var(--line) !important;
  color: var(--text);
}

.backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1200;
}

.sheet {
  position: absolute;
  right: 0;
  left: 0;
  bottom: 0;
  z-index: 1300;
  max-height: 72%;
  background: var(--panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top-left-radius: 22px;
  border-top-right-radius: 22px;
  padding: 8px 16px calc(16px + var(--safe-bottom));
  transform: translateY(110%);
  transition: transform 0.25s ease;
  box-shadow: var(--shadow);
}

.sheet.open {
  transform: translateY(0);
}

.sheet-handle {
  width: 48px;
  height: 5px;
  border-radius: 99px;
  background: #334155;
  margin: 6px auto 12px;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.sheet-head h2 {
  margin: 0;
  font-size: 1.15rem;
}

.sheet-head .ghost {
  border-radius: 10px;
  padding: 6px 10px;
  cursor: pointer;
}

.sheet-actions {
  display: flex;
  gap: 6px;
}

.layer-list {
  overflow: auto;
  max-height: 52vh;
}

.help-sheet {
  max-height: 82%;
  overflow: auto;
}

.guide-steps {
  margin: 0;
  padding: 0 0 8px;
  list-style: none;
  counter-reset: gstep;
  display: grid;
  gap: 10px;
}

.guide-steps li {
  counter-increment: gstep;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  font-size: 0.92rem;
  line-height: 1.6;
  color: #e2e8f0;
}

.guide-steps li::before {
  content: counter(gstep);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #052e16;
  font-weight: 800;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.guide-text {
  min-width: 0;
}

.guide-ex {
  display: block;
  margin-top: 6px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  color: #cbd5e1;
  font-size: 0.86rem;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.layer-item {
  display: block;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.layer-main {
  display: grid;
  grid-template-columns: 12px 1fr;
  gap: 10px;
  align-items: center;
}

.layer-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.swatch {
  width: 12px;
  height: 36px;
  border-radius: 99px;
}

.layer-item strong {
  display: block;
}

.layer-item small {
  color: var(--muted);
}

.layer-item .row-actions {
  display: flex;
  gap: 6px;
}

.layer-tools button,
.layer-item .row-actions button {
  border: 1px solid var(--line);
  background: #1e293b;
  color: var(--text);
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
  font-weight: 700;
}

.map-label {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: none;
  width: max-content;
  background: rgba(15, 23, 42, 0.92);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.map-label.area {
  background: #14532d;
  border-color: #22c55e;
  font-size: 13px;
  padding: 4px 10px;
}

.note-text {
  background: transparent !important;
  border: 0 !important;
  pointer-events: auto !important;
}

.note-text span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: none;
  border: 0;
  color: inherit;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.35;
  white-space: pre-wrap;
  text-align: center;
  pointer-events: auto;
  transform-origin: center center;
  text-shadow: 0 0 4px #000, 0 1px 2px #000, 0 0 10px #000;
}

.note-text.is-selected span {
  box-shadow: 0 0 0 2px #fff, 0 0 0 5px rgba(34, 197, 94, 0.55);
  border-radius: 8px;
  padding: 2px 6px;
}

.map-pin {
  background: transparent !important;
  border: 0 !important;
}

.map-pin,
.map-pin-wrap,
.map-pin-body,
.map-pin-name {
  pointer-events: auto !important;
  cursor: pointer;
}

.map-pin-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
}

.map-pin-body {
  display: grid;
  place-items: center;
  transform-origin: 50% 88%;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.45));
}

.map-pin-name {
  margin-top: 2px;
  padding: 1px 6px;
  border-radius: 8px;
  background: rgba(11, 18, 32, 0.82);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
  text-shadow: 0 1px 2px #000;
  pointer-events: auto;
  cursor: pointer;
}

.map-pin.is-selected .map-pin-body {
  filter: drop-shadow(0 0 0 2px #fff) drop-shadow(0 0 0 5px rgba(34, 197, 94, 0.55));
}

.rotate-handle {
  background: transparent !important;
  border: 0 !important;
}

.rotate-handle span {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #14532d;
  border: 2px solid #fff;
  color: #bbf7d0;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
}

.rotate-handle svg {
  display: block;
}

.scale-handle {
  background: transparent !important;
  border: 0 !important;
}

.scale-handle span {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #1d4ed8;
  border: 2px solid #fff;
  color: #dbeafe;
  font-size: 18px;
  font-weight: 800;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
}

.delete-handle {
  background: transparent !important;
  border: 0 !important;
}

.delete-handle span {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #9f1239;
  border: 2px solid #fff;
  color: #fff;
  font-size: 26px;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
}

.note-input {
  width: 100%;
  margin: 0 0 10px;
  border: 1px solid var(--line);
  background: #0b1220;
  color: var(--text);
  border-radius: 14px;
  padding: 14px 12px;
  font-size: 16px;
}

.coord-preview {
  margin: 0 0 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: #0b1220;
  border: 1px solid var(--line);
  color: #93c5fd;
  font-size: 0.92rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-align: center;
  direction: ltr;
  min-height: 38px;
}

.coord-preview-lg {
  font-size: 1.15rem;
  padding: 14px 10px;
  min-height: 52px;
}

.send-ways,
.send-ways {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin: 0 0 12px;
}

.send-ways button,
.send-ways button,
.btn-send-coords {
  min-height: 46px;
  border-radius: 14px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  border: 1px solid var(--line);
  color: #fff;
}

.btn-wa { background: #128c7e; border-color: #0f766e; }
.btn-copy { background: #334155; }
.btn-share { background: #1d4ed8; border-color: #1e40af; }

.btn-send-coords {
  width: 100%;
  margin-bottom: 12px;
  border: 1px solid #1d4ed8;
  background: #1e3a8a;
  color: #dbeafe;
}

.shot-sheet {
  max-height: none;
  z-index: 1350;
}

.shot-hint {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.shot-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.shot-option {
  min-height: 52px;
  border: 1px solid var(--line);
  background: #1e293b;
  color: var(--text);
  border-radius: 14px;
  padding: 10px 8px;
  font-weight: 800;
  font-size: 0.95rem;
  cursor: pointer;
}

.shot-option.active {
  background: #14532d;
  border-color: var(--accent);
  color: #bbf7d0;
}

.shot-actions {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 8px;
}

.shot-actions .btn-primary,
.shot-actions .ghost {
  min-height: 48px;
  border-radius: 14px;
  font-weight: 800;
  cursor: pointer;
}

.toast {
  position: fixed;
  left: 50%;
  top: calc(12px + var(--safe-top));
  bottom: auto;
  transform: translateX(-50%);
  z-index: 1400;
  background: #111827;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 16px;
  box-shadow: var(--shadow);
  max-width: 90%;
}

.gm-style img {
  max-width: none;
}
