:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --panel: #ffffff;
  --text: #1f2933;
  --muted: #5f6f7b;
  --border: #d9dfd7;
  --trail: #287c5b;
  --accent: #b34d2f;
  --shadow: 0 14px 38px rgba(31, 41, 51, 0.16);
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

a {
  color: #1464a5;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  min-height: 100vh;
}

.app-shell.is-recovery {
  display: block;
}

.app-shell.is-recovery .map-panel,
.app-shell.is-recovery .place-panel {
  display: none;
}

.map-panel {
  position: relative;
  min-width: 0;
  min-height: 100vh;
}

.map {
  width: 100%;
  height: 100%;
  min-height: 100vh;
}

.place-panel {
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: relative;
  min-height: 100vh;
  padding: 28px;
  background: var(--panel);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow-y: auto;
}

.place-panel:focus-visible {
  outline: 3px solid rgba(20, 100, 165, 0.32);
  outline-offset: -3px;
}

.place-panel__header {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.place-panel__body {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.08;
}

.place-panel h1 {
  font-size: 28px;
  line-height: 1.08;
  text-align: center;
}

.recovery-view {
  min-height: 100vh;
  padding: 48px 24px;
  background: var(--bg);
}

.recovery-view[hidden] {
  display: none;
}

.recovery-view__content {
  display: grid;
  gap: 20px;
  width: min(620px, 100%);
  margin: 0 auto;
  padding-top: 12vh;
}

.recovery-view p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.place-summary {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.place-logo {
  align-self: center;
  width: 72px;
  max-width: 35%;
  height: auto;
}

.place-logo[hidden] {
  display: none;
}

.place-summary[hidden] {
  display: none;
}

.place-facts {
  display: grid;
  gap: 14px;
  margin: 0;
}

.place-facts[hidden] {
  display: none;
}

.place-facts div {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.place-facts dt {
  color: var(--muted);
  font-size: 13px;
}

.place-facts dd {
  margin: 0;
  font-weight: 700;
}

.draw-mode-control {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.draw-mode-control[hidden] {
  display: none;
}

.draw-mode-control input {
  width: 16px;
  height: 16px;
  margin: 0;
}

.place-search-prompt {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f9faf7;
}

.place-search-prompt[hidden] {
  display: none;
}

.place-search-prompt label {
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.place-search-prompt__controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.place-search-prompt input,
.place-search-prompt button {
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
}

.place-search-prompt button {
  font-weight: 700;
}

.place-search-prompt p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.maplibregl-ctrl-bottom-right {
  right: 34px;
}

.maplibregl-ctrl-attrib {
  font-size: 12px;
}

.draw-panel {
  position: absolute;
  right: 18px;
  bottom: 18px;
  z-index: 2;
  display: grid;
  gap: 12px;
  width: min(460px, calc(100% - 36px));
  max-height: min(520px, calc(100% - 36px));
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.map-options {
  position: absolute;
  inset: 0;
  z-index: 2;
  --follow-hint-offset: 0px;
  pointer-events: none;
}

.follow-location-hint {
  position: absolute;
  top: 0;
  left: 50%;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: min(680px, calc(100% - 150px));
  padding: 10px 12px;
  border: 1px solid #86efac;
  border-top: 0;
  border-radius: 0 0 10px 10px;
  background: #ecfdf3;
  box-shadow: var(--shadow);
  transform: translate(-50%, 0);
  transition: opacity 180ms ease, transform 180ms ease;
}

.follow-location-hint[hidden] {
  display: flex;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -100%);
}

.follow-location-hint p {
  margin: 0;
  color: #14532d;
  font-size: 13px;
  line-height: 1.35;
}

.follow-location-hint button,
.tray-action {
  min-height: 32px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 9px;
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.follow-location-hint button {
  border-color: #86efac;
  color: #14532d;
}

.map-options__icon-button,
.map-options__toggle {
  position: absolute;
  display: grid;
  width: 40px;
  height: 40px;
  place-content: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  cursor: pointer;
  pointer-events: auto;
}

.map-options__icon-button {
  right: 4px;
  bottom: 7px;
  width: 29px;
  height: 29px;
  border: 0;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: none;
  color: var(--text);
  font: inherit;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
}

.map-options__toggle {
  top: calc(18px + var(--follow-hint-offset));
  right: 18px;
  gap: 4px;
}

.map-options__slider {
  position: relative;
  display: block;
  width: 20px;
  height: 2px;
  border-radius: 999px;
  background: var(--text);
}

.map-options__slider::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text);
  transform: translateY(-50%);
}

.map-options__slider:nth-child(1)::after {
  left: 3px;
}

.map-options__slider:nth-child(2)::after {
  right: 3px;
}

.map-options__slider:nth-child(3)::after {
  left: 8px;
}

.map-options__panel {
  position: absolute;
  top: 66px;
  left: 50%;
  display: grid;
  gap: 14px;
  width: min(280px, calc(100vw - 36px));
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow);
  pointer-events: auto;
  transform: translateX(-50%);
}

.map-options__panel[hidden],
.map-options__orientation[hidden] {
  display: none;
}

.map-options__panel h2,
.map-options__panel p {
  margin: 0;
}

.map-options__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: move;
  user-select: none;
}

.map-options__panel.is-dragging {
  user-select: none;
}

.map-options__panel h2 {
  font-size: 15px;
}

.map-options__field {
  display: grid;
  gap: 6px;
}

.map-options__field label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.map-options__field select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
}

.map-options__close {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
}

.map-options__check,
.map-options__orientation label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.map-options__check--secondary {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.map-options__orientation {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.map-options__orientation legend {
  padding: 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.map-options__status-pill {
  border-radius: 999px;
  padding: 3px 7px;
  background: #eef2ff;
  color: #334155;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.map-options__status-pill[hidden] {
  display: none;
}

.debug-tools__facts {
  display: grid;
  gap: 10px;
  margin: 0;
}

.debug-tools__facts div {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.debug-tools__facts dt {
  color: var(--muted);
  font-size: 13px;
}

.debug-tools__facts dd {
  margin: 0;
  font-weight: 700;
}

.draw-panel[hidden] {
  display: none;
}

.draw-panel__header {
  display: grid;
  gap: 4px;
  cursor: move;
  user-select: none;
}

.draw-panel.is-dragging {
  user-select: none;
}

.draw-panel h2,
.draw-panel p {
  margin: 0;
}

.draw-panel h2 {
  font-size: 16px;
}

.draw-panel p {
  color: var(--muted);
  font-size: 13px;
}

.draw-panel__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.draw-panel button {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
}

.draw-panel textarea {
  width: 100%;
  min-height: 190px;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  color: var(--text);
  font: 12px/1.4 Consolas, "Courier New", monospace;
}

@media (max-width: 820px) {
  html,
  body {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }

  .app-shell {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
    overflow: hidden;
  }

  .map-panel,
  .map {
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  .follow-location-hint {
    left: 12px;
    right: 12px;
    align-items: flex-start;
    max-width: none;
    transform: translateY(0);
  }

  .follow-location-hint[hidden] {
    transform: translateY(-100%);
  }

  .place-panel {
    gap: 14px;
    height: 42vh;
    height: 42dvh;
    max-height: 42vh;
    max-height: 42dvh;
    min-height: auto;
    padding: 14px 16px 16px;
    border-top: 1px solid var(--border);
    border-left: 0;
    box-shadow: none;
    overflow: hidden;
    transition: height 240ms ease, padding 240ms ease;
  }

  .place-panel__header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, auto);
    grid-template-rows: 4px auto;
    align-items: center;
    column-gap: 14px;
    row-gap: 6px;
    min-height: 20px;
    cursor: ns-resize;
    touch-action: none;
    user-select: none;
  }

  .place-panel__header::before {
    content: "";
    grid-column: 1 / -1;
    justify-self: center;
    transform: translateY(-3px);
    width: 38px;
    height: 4px;
    border-radius: 999px;
    background: #c6d0c4;
  }

  .place-panel__body {
    gap: 12px;
  }

  .place-summary,
  .place-facts {
    display: none;
  }

  .mobile-zoom-level {
    display: block;
  }

  .place-panel.is-collapsed {
    gap: 0;
    height: 47px;
    min-height: 47px;
    padding: 12px 16px;
    overflow: hidden;
  }

  .place-panel.is-collapsed .place-panel__body {
    display: none;
  }

  .place-panel.is-dragging .place-panel__body {
    display: flex;
  }

  .place-panel.is-dragging {
    transition: none;
  }

  .place-panel.is-collapsed .place-panel__header {
    min-height: 20px;
  }

  h1 {
    font-size: 30px;
  }

  .place-panel .eyebrow {
    font-size: 11px;
    line-height: 1;
  }

  .place-panel h1 {
    justify-self: end;
    max-width: 58vw;
    overflow: hidden;
    font-size: 18px;
    line-height: 1.1;
    text-align: right;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .draw-panel {
    right: 10px;
    bottom: 10px;
    width: calc(100% - 20px);
    max-height: calc(100% - 20px);
  }

  .draw-panel textarea {
    min-height: 150px;
  }
}
