/* Демо «Контур здания по клику»: карта на весь экран и одна стеклянная панель управления. */
:root {
  --ink: #f4f5f7;
  --muted: rgb(244 245 247 / 0.62);
  --glass: rgb(18 20 24 / 0.66);
  --line: rgb(255 255 255 / 0.14);
  --fill: rgb(255 255 255 / 0.09);
  --fill-strong: rgb(255 255 255 / 0.2);
  --accent: #ffd60a;
  --gap: 16px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: #0b0d10;
  color: var(--ink);
  font: 14px/1.35 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button { font: inherit; color: inherit; }

.map {
  position: fixed;
  inset: 0;
  background: #0b0d10;
  cursor: crosshair;
}
.map[hidden] { display: none; }
.leaflet-container { font: inherit; background: #0b0d10; }
.leaflet-grab { cursor: crosshair; }
.leaflet-dragging .leaflet-grab { cursor: grabbing; }

.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(22px) saturate(1.5);
  backdrop-filter: blur(22px) saturate(1.5);
  box-shadow: inset 0 0 0 1px var(--line);
}

/* Панель. Скругления концентричны: панель 24 = отступ 12 + внутренние капсулы 12. */
.panel {
  position: fixed;
  z-index: 1000;
  top: var(--gap);
  left: var(--gap);
  width: 312px;
  max-height: calc(100% - 2 * var(--gap));
  padding: 12px;
  border-radius: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 2px 0 6px;
}
h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.seg {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 2px;
  padding: 2px;
  border-radius: 12px;
  background: var(--fill);
}
.seg button {
  height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--fill-strong); color: var(--ink); }
.seg button:disabled { opacity: 0.38; cursor: default; }
.seg.small button { height: 28px; padding: 0 9px; font-size: 13px; border-radius: 9px; }
.seg.small { border-radius: 11px; }
#langs { grid-auto-columns: auto; }

.chips {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.chips[hidden] { display: none; }
.chip {
  height: 30px;
  padding: 0 11px;
  border: 0;
  border-radius: 15px;
  background: var(--fill);
  color: var(--muted);
  cursor: pointer;
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
}
.chip:hover { color: var(--ink); background: var(--fill-strong); }

.row2 { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.file { display: flex; align-items: center; gap: 10px; min-width: 0; }
.file[hidden] { display: none; }
.file-name { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

.line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 34px;
  padding: 0 2px 0 6px;
}

.switch {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 42px;
  height: 26px;
  margin: 0;
  border-radius: 13px;
  background: var(--fill-strong);
  position: relative;
  cursor: pointer;
  transition: background 0.2s var(--ease);
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s var(--ease);
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(16px); }

.btn {
  height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 12px;
  background: var(--fill);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.18s var(--ease), transform 0.12s var(--ease), opacity 0.18s;
}
.btn:hover { background: var(--fill-strong); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.38; cursor: default; transform: none; background: var(--fill); }
.btn[hidden] { display: none; }

.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.actions .btn { flex: 1 1 auto; }

.active {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border-radius: 12px;
  background: var(--fill);
}
.active[hidden] { display: none; }
.active-head { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.active-head strong { font-weight: 600; white-space: nowrap; }
.muted { color: var(--muted); font-variant-numeric: tabular-nums; }
.swatch {
  flex: none;
  align-self: center;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
}
.active.pending .swatch { animation: blink 0.8s ease-in-out infinite; }
@keyframes blink { 50% { opacity: 0.25; } }

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  min-height: 0;
  flex: 0 1 auto;
  scrollbar-width: thin;
  scrollbar-color: var(--fill-strong) transparent;
}
.list:empty { display: none; }
.item {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 4px 0 8px;
  border-radius: 10px;
  cursor: pointer;
}
.item:hover { background: var(--fill); }
.item[aria-current="true"] { background: var(--fill); }
.item .name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .del {
  flex: none;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}
.item .del:hover { background: var(--fill-strong); color: var(--ink); }

.foot { display: flex; flex-direction: column; gap: 8px; }
.meter {
  margin: 0;
  padding: 0 6px 2px;
  min-height: 16px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.meter:empty { display: none; }
.credit { display: none; margin: 0; padding: 0 6px 2px; color: var(--muted); font-size: 11px; line-height: 1.3; }

.hint, .toast {
  position: fixed;
  z-index: 1000;
  left: 50%;
  transform: translateX(-50%);
  padding: 9px 16px;
  border-radius: 19px;
  white-space: nowrap;
  max-width: calc(100% - 2 * var(--gap));
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}
.hint { top: var(--gap); transition: opacity 0.3s var(--ease); }
.hint.off { opacity: 0; }
.toast {
  bottom: calc(var(--gap) + 28px);
  box-shadow: inset 0 0 0 1px rgb(255 214 10 / 0.55);
  animation: rise 0.25s var(--ease);
}
.toast[hidden] { display: none; }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } }

/* Точки и отклик на клик. */
.ping {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 2px rgb(0 0 0 / 0.5);
}
.ping::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid #fff;
  animation: ping 0.9s ease-out infinite;
}
@keyframes ping { to { transform: scale(2.6); opacity: 0; } }
.outline { transition: stroke-opacity 0.2s, fill-opacity 0.2s; }

.leaflet-control-attribution {
  background: rgb(18 20 24 / 0.6) !important;
  color: var(--muted) !important;
  border-radius: 8px 0 0 0;
  font-size: 11px;
  padding: 2px 8px !important;
}
.leaflet-control-attribution a { color: inherit !important; }
.leaflet-bar { border: 0 !important; box-shadow: inset 0 0 0 1px var(--line) !important; border-radius: 12px !important; overflow: hidden; }
.leaflet-bar a {
  background: var(--glass) !important;
  -webkit-backdrop-filter: blur(22px) saturate(1.5);
  backdrop-filter: blur(22px) saturate(1.5);
  color: var(--ink) !important;
  border-bottom: 1px solid var(--line) !important;
  width: 36px !important;
  height: 36px !important;
  line-height: 36px !important;
}
.leaflet-bar a:last-child { border-bottom: 0 !important; }
.leaflet-bar a.leaflet-disabled { color: var(--muted) !important; }
.leaflet-top.leaflet-right { top: 4px; right: 4px; }

/* Телефон: панель листом снизу, подсказка сверху. */
@media (max-width: 700px) {
  :root { --gap: 10px; }
  .panel {
    top: auto;
    left: var(--gap);
    right: var(--gap);
    bottom: calc(var(--gap) + env(safe-area-inset-bottom));
    width: auto;
    max-height: 52%;
    gap: 8px;
  }
  /* Лист занимает меньше половины экрана: заголовок и список прошлых объектов уходят, места — одной
     строкой с прокруткой, подпись источника снимков — последней строкой листа. */
  .panel { padding: 10px; max-height: 50%; overflow-y: auto; }
  .panel > * { flex-shrink: 0; }
  .head { position: absolute; top: 10px; right: 10px; padding: 0; }
  .head h1 { display: none; }
  #modes { margin-right: 84px; }
  .seg button, .btn { height: 38px; }
  .seg.small button { height: 34px; }
  #langs button { height: 34px; }
  /* Переключатель прямых углов и места (или выбор файла) — одной строкой: места прокручиваются вбок. */
  .row2 { flex-direction: row; align-items: center; gap: 8px; }
  .row2 .line { order: -1; flex: none; gap: 8px; padding: 0 0 0 4px; }
  .row2 .chips, .row2 .file { flex: 1; min-width: 0; }
  .chips { display: flex; overflow-x: auto; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: none; height: 32px; }
  .meter { display: none; }
  .line.tool > span { display: none; }
  .line.tool { padding: 0; }
  .line.tool .seg { flex: 1; }
  .list { display: none; }
  .credit { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .leaflet-control-zoom, .leaflet-control-attribution { display: none; }
  .hint { top: calc(var(--gap) + env(safe-area-inset-top)); }
  .toast { bottom: auto; top: calc(var(--gap) + 48px + env(safe-area-inset-top)); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
