:root {
  --ink: #e8eef6;
  --ink-muted: #9aa8b8;
  --panel: rgba(18, 26, 38, 0.92);
  --panel-solid: #121a26;
  --line: rgba(255, 255, 255, 0.12);
  --accent: #3d9b84;
  --accent-press: #2f7d6a;
  --frame: #f0c14a;
  --radius: 999px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
}

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

html,
body {
  height: 100%;
  margin: 0;
  background: var(--panel-solid);
  color: var(--ink);
  font-family: var(--font);
  -webkit-text-size-adjust: 100%;
}

#app {
  position: relative;
  height: 100%;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
}

.bar {
  z-index: 500;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem 1rem;
  padding: calc(0.55rem + var(--safe-top)) 0.85rem 0.55rem;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  min-width: 0;
}

.logo {
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
  line-height: 1.1;
}

.tag {
  color: var(--ink-muted);
  font-size: 0.78rem;
  text-transform: lowercase;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
}

.scales {
  display: inline-flex;
  padding: 0.2rem;
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
}

.scale,
.tool {
  appearance: none;
  border: 0;
  margin: 0;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  white-space: nowrap;
}

.scale {
  background: transparent;
  color: var(--ink-muted);
}

.scale[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
}

.tool {
  background: var(--frame);
  color: #1a2332;
}

.tool:hover {
  filter: brightness(1.05);
}

.tool:disabled {
  opacity: 0.55;
  cursor: wait;
}

.scale:focus-visible,
.tool:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

#map {
  position: relative;
  min-height: 0;
  width: 100%;
  background: #2a3340;
}

#map .leaflet-container {
  width: 100%;
  height: 100%;
  font: inherit;
  background: #2a3340;
}

#map .leaflet-control-zoom a {
  width: 2.4rem;
  height: 2.4rem;
  line-height: 2.4rem;
  font-size: 1.15rem;
}

#map .leaflet-control-attribution {
  display: none;
}

#map .a4-frame {
  stroke: var(--frame);
  stroke-width: 2;
  stroke-dasharray: 8 5;
  fill: rgba(240, 193, 74, 0.06);
}

.credit {
  z-index: 500;
  padding: 0.45rem 0.85rem calc(0.45rem + var(--safe-bottom));
  background: var(--panel);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: grid;
  gap: 0.25rem;
}

.credit p {
  margin: 0;
  font-size: clamp(0.68rem, 2.6vw, 0.78rem);
  line-height: 1.35;
  color: var(--ink-muted);
  text-wrap: pretty;
}

.credit .hint {
  color: #c5d0dc;
}

.status {
  position: fixed;
  left: 50%;
  bottom: calc(4.5rem + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 1000;
  max-width: min(90vw, 24rem);
  padding: 0.65rem 1rem;
  border-radius: 0.75rem;
  background: rgba(18, 26, 38, 0.95);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 0.9rem;
  text-align: center;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

@media (min-width: 720px) {
  .bar,
  .credit {
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }

  .logo {
    font-size: 1.35rem;
  }

  .scale,
  .tool {
    padding: 0.5rem 1.1rem;
    font-size: 0.92rem;
  }
}

@media (max-width: 420px) {
  .tag {
    display: none;
  }

  .scale,
  .tool {
    padding: 0.42rem 0.7rem;
    font-size: 0.8rem;
  }
}

@media print {
  body * {
    visibility: hidden;
  }
}
