:root {
  color-scheme: dark;
  --bg: #071116;
  --panel: rgba(8, 22, 31, 0.72);
  --panel-strong: rgba(8, 22, 31, 0.92);
  --panel-soft: rgba(255, 255, 255, 0.08);
  --line: rgba(255, 255, 255, 0.16);
  --text: #edf7f6;
  --muted: #a9b8bd;
  --accent: #49d0bb;
  --accent-2: #f2b36d;
  --accent-3: #9ed66f;
  --danger: #ff7a7a;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.36);
  --radius: 22px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body,
#map {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  font-family: var(--font);
  background: radial-gradient(circle at top left, #10393b 0, var(--bg) 45%, #05090d 100%);
  color: var(--text);
}

button,
input,
textarea,
select {
  font: inherit;
}

button,
select {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.72rem 0.82rem;
  background: rgba(255, 255, 255, 0.09);
  color: var(--text);
}

button {
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

button:hover,
button:focus-visible,
select:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(73, 208, 187, 0.7);
  background: rgba(73, 208, 187, 0.14);
  outline: none;
}

button.active {
  color: #061311;
  background: linear-gradient(135deg, var(--accent), #96eadb);
  border-color: rgba(255, 255, 255, 0.2);
}

button.danger {
  color: #fff;
  border-color: rgba(255, 122, 122, 0.45);
  background: rgba(255, 122, 122, 0.15);
}

button.small-button {
  padding: 0.5rem 0.64rem;
  font-size: 0.78rem;
  border-radius: 999px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.72rem 0.82rem;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  outline: none;
}

select {
  width: 100%;
  outline: none;
}

textarea {
  min-height: 86px;
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: rgba(73, 208, 187, 0.75);
  box-shadow: 0 0 0 3px rgba(73, 208, 187, 0.13);
}

label {
  display: block;
  margin-bottom: 0.4rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.glass-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(1.25);
}

#sidebar {
  position: absolute;
  z-index: 10;
  top: 1rem;
  left: 1rem;
  bottom: 1rem;
  width: min(405px, calc(100vw - 2rem));
  border-radius: var(--radius);
  overflow-y: auto;
  padding: 1rem;
  scrollbar-width: thin;
}

#sidebar.collapsed {
  display: none;
}

.app-header,
.details-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid var(--line);
}

h1,
h2 {
  margin: 0;
  line-height: 1.08;
}

h1 {
  font-size: 1.42rem;
  letter-spacing: -0.03em;
}

h1 span {
  color: var(--accent-2);
}

h2 {
  font-size: 1.08rem;
}

.eyebrow {
  margin: 0 0 0.25rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.68rem;
  font-weight: 700;
}

.icon-button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 50%;
  font-size: 1.4rem;
  line-height: 1;
}

.tool-section {
  padding: 1rem 0;
  border-bottom: 1px solid var(--line);
}

.tool-section:last-child {
  border-bottom: 0;
}

.compact-section {
  padding-bottom: 0.6rem;
}

.section-title {
  margin-bottom: 0.75rem;
  font-size: 0.84rem;
  color: #d7efea;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.section-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.7rem;
}

.section-row .section-title {
  margin-bottom: 0;
}

.inline-row {
  display: flex;
  gap: 0.5rem;
}

.inline-row button {
  flex: 0 0 auto;
}

.button-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.button-grid.two-col {
  grid-template-columns: repeat(2, 1fr);
}

.range-label {
  margin-top: 0.9rem;
}

.status-text,
.muted {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.status-text {
  min-height: 1.2rem;
  margin: 0.75rem 0 0;
}

.layer-list,
.legend,
.point-list,
.result-list,
.bookmark-list {
  display: grid;
  gap: 0.55rem;
}

.layer-card,
.legend-item,
.point-card,
.result-card,
.bookmark-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.065);
  padding: 0.7rem;
}

.layer-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.65rem;
}

.layer-card input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.layer-title,
.point-title,
.bookmark-title {
  font-weight: 760;
  font-size: 0.92rem;
}

.layer-meta,
.point-meta,
.result-meta,
.bookmark-meta {
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.35;
}

.badge {
  justify-self: end;
  padding: 0.22rem 0.48rem;
  border-radius: 999px;
  color: #08151a;
  background: var(--accent-2);
  font-size: 0.68rem;
  font-weight: 800;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.swatch {
  width: 22px;
  height: 14px;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  flex: 0 0 auto;
}

.swatch.circle {
  width: 15px;
  height: 15px;
  border-radius: 50%;
}

.swatch.triangle {
  width: 0;
  height: 0;
  background: transparent !important;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 14px solid #050505;
  border-top: 0;
  border-radius: 0;
}

.bookmark-card {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.5rem;
}

.bookmark-actions {
  display: flex;
  gap: 0.35rem;
}

.bookmark-actions button {
  padding: 0.42rem 0.5rem;
  border-radius: 999px;
  font-size: 0.74rem;
}

.details-panel {
  position: absolute;
  z-index: 9;
  top: 1rem;
  right: 1rem;
  width: min(420px, calc(100vw - 2rem));
  max-height: calc(100vh - 7.6rem);
  overflow: auto;
  border-radius: var(--radius);
  padding: 1rem;
}

.details-panel.hidden {
  display: none;
}

.details-content {
  padding-top: 0.8rem;
}

.field-grid {
  display: grid;
  gap: 0.55rem;
}

.field-row {
  display: grid;
  grid-template-columns: minmax(95px, 0.38fr) 1fr;
  gap: 0.7rem;
  padding: 0.56rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  word-break: break-word;
}

.field-row strong {
  color: #cae7e3;
  font-size: 0.78rem;
}

.field-row span {
  color: var(--text);
  font-size: 0.82rem;
}

.form-stack {
  display: grid;
  gap: 0.75rem;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.map-footer {
  position: absolute;
  z-index: 8;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  display: flex;
  gap: 0.8rem;
  align-items: center;
  justify-content: center;
  max-width: calc(100vw - 2rem);
  padding: 0.55rem 0.8rem;
  border-radius: 999px;
  color: #d8e7e6;
  font-size: 0.75rem;
  white-space: nowrap;
}

.floating-button {
  display: none;
  position: absolute;
  z-index: 11;
  top: 1rem;
  left: 1rem;
  width: 46px;
  height: 46px;
  padding: 0;
  border-radius: 50%;
}

.floating-button.visible {
  display: grid;
  place-items: center;
}

.maplibregl-ctrl-group,
.maplibregl-ctrl-attrib,
.maplibregl-ctrl-scale {
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.32));
}

.maplibregl-popup-content {
  color: #102024;
  border-radius: 14px;
  padding: 0.85rem;
  max-width: 280px;
}

.maplibregl-popup-content strong {
  display: block;
  margin-bottom: 0.2rem;
}

@media (max-width: 920px) {
  #sidebar {
    width: min(370px, calc(100vw - 2rem));
  }

  .details-panel {
    left: 1rem;
    right: auto;
    top: auto;
    bottom: 4.5rem;
    width: min(420px, calc(100vw - 2rem));
    max-height: 44vh;
  }

  .map-footer {
    display: none;
  }
}

@media (max-width: 520px) {
  #sidebar {
    top: 0.65rem;
    left: 0.65rem;
    bottom: 0.65rem;
    width: calc(100vw - 1.3rem);
  }

  .button-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .inline-row {
    flex-direction: column;
  }
}
