:root {
  color-scheme: light;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --accent-soft: #dff5f1;
  --ink: #17212b;
  --muted: #667581;
  --surface: #ffffff;
  --surface-soft: #f4f7f6;
  --line: #dce5e2;
  --danger: #b42318;
  --shadow: 0 12px 35px rgb(23 33 43 / 16%);
  --shadow-small: 0 4px 16px rgb(23 33 43 / 13%);
  --radius: 18px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  overflow: hidden;
  color: var(--ink);
  background: #dce8e4;
  -webkit-tap-highlight-color: transparent;
}

button,
input,
select {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgb(15 118 110 / 28%);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hidden {
  display: none !important;
}

#map {
  position: fixed;
  inset: 0;
  z-index: 0;
}

.simple-map {
  overflow: hidden;
  touch-action: none;
  cursor: grab;
  background: #dce8e4;
  user-select: none;
}

.simple-map.is-dragging {
  cursor: grabbing;
}

.simple-map-tiles,
.simple-map-overlay {
  position: absolute;
  inset: 0;
}

.simple-map-tile {
  position: absolute;
  width: 256px;
  height: 256px;
  object-fit: cover;
  border: 0;
  user-select: none;
  pointer-events: none;
}

.simple-map-overlay {
  pointer-events: none;
}

.simple-map-marker {
  position: absolute;
  width: auto;
  height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  transform: translate(-50%, -100%);
  pointer-events: auto;
}

.simple-map-marker.user-location-marker {
  transform: translate(-50%, -50%);
}

.simple-map-circle {
  position: absolute;
  border-style: solid;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.simple-map-zoom {
  position: absolute;
  z-index: 20;
  top: 138px;
  right: 14px;
  display: grid;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow-small);
}

.simple-map-zoom button {
  width: 38px;
  height: 38px;
  border: 0;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  background: var(--surface);
  font-size: 24px;
  line-height: 1;
}

.simple-map-zoom button:last-child {
  border-bottom: 0;
}

.simple-map-attribution {
  position: absolute;
  z-index: 15;
  right: 3px;
  bottom: 3px;
  padding: 2px 4px;
  border-radius: 3px;
  color: #46534f;
  background: rgb(255 255 255 / 78%);
  font-size: 10px;
}

.simple-map-attribution a {
  color: #0b5f59;
}

.leaflet-control-attribution {
  font-size: 10px;
}

.auth-screen {
  position: fixed;
  z-index: 3000;
  inset: 0;
  padding: max(20px, env(safe-area-inset-top)) 18px max(20px, env(safe-area-inset-bottom));
  display: grid;
  place-items: center;
  overflow-y: auto;
  background:
    radial-gradient(circle at 20% 10%, rgb(54 179 165 / 24%), transparent 34%),
    radial-gradient(circle at 85% 90%, rgb(15 118 110 / 19%), transparent 38%),
    #eef6f3;
}

body.is-authenticated .auth-screen {
  display: none;
}

.auth-card {
  width: min(420px, 100%);
  padding: 34px 30px 28px;
  border: 1px solid rgb(220 229 226 / 90%);
  border-radius: 26px;
  background: rgb(255 255 255 / 96%);
  box-shadow: var(--shadow);
  text-align: center;
}

.auth-card img {
  border-radius: 18px;
  box-shadow: 0 10px 24px rgb(15 118 110 / 24%);
}

.auth-brand {
  margin: 15px 0 5px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: .18em;
}

.auth-card h1 {
  margin: 0 0 8px;
  font-size: 25px;
}

.auth-card > p:not(.auth-brand) {
  margin: 0 auto 23px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.auth-form {
  display: grid;
  gap: 14px;
  text-align: left;
}

.auth-form label,
.dialog-field {
  display: grid;
  gap: 6px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.auth-form input,
.dialog-field input,
.dialog-field select {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: 0;
  color: var(--ink);
  background: var(--surface-soft);
  font-size: 16px;
}

.auth-form input:focus,
.dialog-field input:focus,
.dialog-field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(15 118 110 / 13%);
}

.auth-submit {
  min-height: 48px;
  margin-top: 3px;
  border: 0;
  border-radius: 13px;
  color: #fff;
  background: var(--accent);
  font-weight: 800;
}

.auth-submit:disabled {
  opacity: .62;
  cursor: wait;
}

.auth-error {
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--danger);
  background: #fff1f0;
  font-size: 13px;
  line-height: 1.4;
}

#auth-help {
  margin-top: 18px;
  display: block;
  color: var(--muted);
}

.leaflet-top.leaflet-right {
  top: 128px;
  right: 5px;
}

.leaflet-bar {
  border: 0 !important;
  box-shadow: var(--shadow-small) !important;
}

.leaflet-bar a {
  color: var(--ink) !important;
  border-color: var(--line) !important;
}

.top-panel {
  position: fixed;
  z-index: 500;
  top: 0;
  left: 0;
  right: 0;
  padding: max(12px, env(safe-area-inset-top)) 12px 0;
  pointer-events: none;
}

.search-card {
  width: min(680px, 100%);
  min-height: 54px;
  margin: 0 auto;
  padding: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgb(220 229 226 / 80%);
  border-radius: var(--radius);
  background: rgb(255 255 255 / 96%);
  box-shadow: var(--shadow);
  pointer-events: auto;
  backdrop-filter: blur(12px);
}

.search-icon {
  width: 23px;
  height: 23px;
  margin-left: 8px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 2;
  stroke-linecap: round;
}

#search-input {
  min-width: 0;
  flex: 1;
  padding: 10px 2px;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-size: 16px;
}

#search-input::placeholder {
  color: #82908e;
}

.search-submit {
  min-height: 42px;
  padding: 0 17px;
  border: 0;
  border-radius: 13px;
  color: white;
  background: var(--accent);
  font-weight: 700;
}

.search-submit:active {
  background: var(--accent-strong);
}

.icon-button {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  font-size: 26px;
  line-height: 1;
}

.icon-button.subtle {
  color: var(--muted);
  background: transparent;
}

.category-strip {
  width: min(920px, calc(100% + 12px));
  margin: 8px auto 0;
  padding: 0 6px 6px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  pointer-events: auto;
  scroll-snap-type: x proximity;
}

.category-strip::-webkit-scrollbar {
  display: none;
}

.category-chip {
  min-height: 39px;
  padding: 8px 13px;
  flex: 0 0 auto;
  border: 1px solid rgb(220 229 226 / 85%);
  border-radius: 999px;
  color: var(--ink);
  background: rgb(255 255 255 / 96%);
  box-shadow: var(--shadow-small);
  font-size: 14px;
  font-weight: 650;
  scroll-snap-align: start;
}

.category-chip:hover,
.category-chip.is-active {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

.map-actions {
  position: fixed;
  z-index: 450;
  right: 14px;
  bottom: 82px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  transition: bottom 220ms ease;
}

body.panel-open .map-actions {
  bottom: min(68vh, 545px);
}

.floating-button,
.floating-pill {
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-small);
}

.floating-button {
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  border-radius: 50%;
}

.floating-button svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.9;
  stroke-linecap: round;
}

.floating-button.is-loading svg {
  animation: pulse 900ms infinite alternate;
}

.floating-pill {
  padding: 10px 15px;
  border-radius: 999px;
  color: var(--accent-strong);
  font-size: 14px;
  font-weight: 750;
}

.results-panel {
  position: fixed;
  z-index: 600;
  left: 0;
  right: 0;
  bottom: 0;
  height: min(68vh, 545px);
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 24px 24px 0 0;
  background: var(--surface);
  box-shadow: 0 -12px 40px rgb(23 33 43 / 16%);
  transform: translateY(0);
  transition: transform 220ms ease;
}

.results-panel.is-collapsed {
  transform: translateY(calc(100% - 66px - env(safe-area-inset-bottom)));
}

.panel-handle {
  position: relative;
  min-height: 66px;
  padding: 14px 18px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 0;
  border-radius: 24px 24px 0 0;
  color: var(--ink);
  background: var(--surface);
  text-align: left;
}

.handle-bar {
  position: absolute;
  top: 7px;
  left: 50%;
  width: 42px;
  height: 4px;
  border-radius: 99px;
  background: #cbd6d3;
  transform: translateX(-50%);
}

.panel-heading {
  min-width: 0;
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
}

.panel-heading strong,
.panel-heading small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel-heading strong {
  font-size: 16px;
}

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

.chevron {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 2;
  transition: transform 220ms ease;
}

.results-panel:not(.is-collapsed) .chevron {
  transform: rotate(180deg);
}

.panel-content {
  min-height: 0;
  display: flex;
  flex: 1;
  flex-direction: column;
  border-top: 1px solid var(--line);
}

.toolbar {
  padding: 10px 14px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}

.toolbar::-webkit-scrollbar {
  display: none;
}

.select-control select,
.toolbar-button {
  min-height: 39px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--ink);
  background: var(--surface-soft);
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}

.toolbar-button.is-active {
  border-color: #e7aa22;
  color: #7a4b00;
  background: #fff3cd;
}

.account-button {
  color: var(--muted);
}

.status {
  margin: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 14px;
  line-height: 1.45;
}

.status.is-loading::before {
  content: "";
  width: 16px;
  height: 16px;
  margin-right: 9px;
  display: inline-block;
  border: 2px solid #bdd4cf;
  border-top-color: var(--accent);
  border-radius: 50%;
  vertical-align: -3px;
  animation: spin 700ms linear infinite;
}

.status.is-error {
  color: var(--danger);
  background: #fff1f0;
}

.results-list {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.empty-state {
  min-height: 230px;
  padding: 34px 24px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  color: var(--muted);
  text-align: center;
}

.empty-state .empty-icon {
  font-size: 42px;
}

.empty-state strong {
  color: var(--ink);
}

.place-card {
  width: 100%;
  padding: 14px 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  background: var(--surface);
  text-align: left;
}

.place-card:hover,
.place-card:focus-within {
  background: #f7faf9;
}

.place-open {
  min-width: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  align-items: start;
  gap: 12px;
  border: 0;
  color: inherit;
  background: transparent;
  text-align: left;
}

.place-icon {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--accent-soft);
  font-size: 23px;
}

.place-main {
  min-width: 0;
  display: block;
}

.place-name {
  margin: 1px 0 4px;
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 15px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.place-meta,
.place-detail {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.place-detail {
  margin-top: 3px;
  color: var(--accent-strong);
}

.place-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 7px;
}

.distance {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.favorite-toggle {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  color: #8b9693;
  background: transparent;
  font-size: 25px;
  line-height: 1;
}

.favorite-toggle.is-favorite {
  color: #d58a00;
}

.marker-pin {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 3px solid white;
  border-radius: 50% 50% 50% 8px;
  background: var(--accent);
  box-shadow: 0 5px 12px rgb(23 33 43 / 30%);
  font-size: 19px;
  transform: rotate(-45deg);
}

.marker-pin span {
  transform: rotate(45deg);
}

.user-dot {
  width: 18px;
  height: 18px;
  border: 4px solid white;
  border-radius: 50%;
  background: #1677ff;
  box-shadow: 0 0 0 7px rgb(22 119 255 / 18%), 0 3px 8px rgb(23 33 43 / 28%);
}

.place-dialog {
  width: min(480px, calc(100% - 24px));
  max-height: min(680px, calc(100% - 32px));
  padding: 0;
  overflow: hidden auto;
  border: 0;
  border-radius: 22px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.compact-dialog {
  width: min(420px, calc(100% - 24px));
}

.compact-dialog h2 {
  margin: 0 0 5px;
  padding-right: 0;
  font-size: 21px;
}

.dialog-intro {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 14px;
}

.compact-dialog .dialog-field {
  margin-bottom: 14px;
}

.place-dialog::backdrop {
  background: rgb(16 24 32 / 48%);
  backdrop-filter: blur(2px);
}

.dialog-close {
  position: sticky;
  z-index: 2;
  top: 12px;
  float: right;
  width: 38px;
  height: 38px;
  margin: 12px 12px -50px 0;
  border: 0;
  border-radius: 50%;
  color: var(--ink);
  background: rgb(255 255 255 / 92%);
  box-shadow: var(--shadow-small);
  font-size: 25px;
}

.dialog-body {
  padding: 26px 22px 22px;
}

.dialog-hero {
  margin-bottom: 18px;
  padding-right: 42px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.dialog-hero .place-icon {
  flex: 0 0 auto;
}

.dialog-hero h2 {
  margin: 2px 0 5px;
  font-size: 22px;
  line-height: 1.2;
}

.dialog-hero p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.detail-list {
  margin: 0 0 18px;
  padding: 0;
  display: grid;
  gap: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}

.detail-list li {
  padding: 12px 2px;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 7px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.detail-list a {
  color: var(--accent-strong);
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.dialog-action {
  min-height: 45px;
  padding: 10px 12px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--accent-strong);
  background: var(--surface-soft);
  font-size: 14px;
  font-weight: 750;
  text-align: center;
  text-decoration: none;
}

.dialog-action.primary {
  border-color: var(--accent);
  color: white;
  background: var(--accent);
}

.toast {
  position: fixed;
  z-index: 1000;
  left: 50%;
  bottom: max(82px, calc(env(safe-area-inset-bottom) + 70px));
  max-width: calc(100% - 28px);
  padding: 11px 17px;
  border-radius: 999px;
  color: white;
  background: #17212b;
  box-shadow: var(--shadow-small);
  font-size: 14px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.mobile-tabbar {
  display: none;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  to { opacity: .38; }
}

@media (max-width: 430px) {
  .auth-screen {
    padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
  }

  .auth-card {
    padding: 24px 18px 22px;
    border-radius: 22px;
  }

  .auth-card img {
    width: 60px;
    height: 60px;
  }

  .auth-card > p:not(.auth-brand) {
    margin-bottom: 18px;
  }

  .top-panel {
    padding-right: 8px;
    padding-left: 8px;
  }

  .search-card {
    min-height: 50px;
  }

  .search-submit {
    min-height: 40px;
    padding: 0 13px;
  }

  .category-strip {
    width: 100%;
    padding-right: 0;
    padding-left: 0;
  }

  .simple-map-zoom {
    top: 130px;
    right: 10px;
  }

  .map-actions {
    right: 10px;
  }

  .panel-handle {
    padding-right: 14px;
    padding-left: 14px;
  }

  .toolbar {
    padding-right: 10px;
    padding-left: 10px;
  }
}

@media (max-width: 799px) {
  .mobile-tabbar {
    position: fixed;
    z-index: 750;
    right: 0;
    bottom: 0;
    left: 0;
    height: calc(64px + env(safe-area-inset-bottom));
    padding: 6px 14px max(6px, env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    border-top: 1px solid var(--line);
    background: rgb(255 255 255 / 96%);
    box-shadow: 0 -8px 26px rgb(23 33 43 / 12%);
    backdrop-filter: blur(14px);
  }

  .mobile-tab {
    min-width: 0;
    padding: 4px 8px;
    display: grid;
    place-items: center;
    gap: 1px;
    border: 0;
    border-radius: 13px;
    color: var(--muted);
    background: transparent;
  }

  .mobile-tab span {
    font-size: 19px;
    line-height: 1;
  }

  .mobile-tab small {
    font-size: 11px;
    font-weight: 750;
  }

  .mobile-tab.is-active {
    color: var(--accent-strong);
    background: var(--accent-soft);
  }

  .results-panel {
    bottom: calc(64px + env(safe-area-inset-bottom));
    height: min(58vh, 500px);
    padding-bottom: 0;
  }

  .results-panel.is-collapsed {
    transform: translateY(calc(100% - 66px));
  }

  .map-actions {
    bottom: calc(146px + env(safe-area-inset-bottom));
  }

  body.panel-open .map-actions {
    bottom: calc(min(58vh, 500px) + 76px + env(safe-area-inset-bottom));
  }

  .toast {
    bottom: calc(142px + env(safe-area-inset-bottom));
  }
}

@media (min-width: 800px) {
  .top-panel {
    left: 390px;
    padding-right: 18px;
    padding-left: 18px;
  }

  .results-panel,
  .results-panel.is-collapsed {
    top: 0;
    right: auto;
    width: 390px;
    height: 100%;
    padding-top: max(12px, env(safe-area-inset-top));
    border: 0;
    border-right: 1px solid var(--line);
    border-radius: 0;
    box-shadow: 8px 0 28px rgb(23 33 43 / 12%);
    transform: none;
  }

  .panel-handle {
    min-height: 78px;
    padding: 18px 20px;
    cursor: default;
  }

  .handle-bar,
  .chevron {
    display: none;
  }

  .panel-heading strong {
    font-size: 20px;
  }

  .map-actions,
  body.panel-open .map-actions {
    right: 18px;
    bottom: 28px;
  }

  .leaflet-left {
    left: 390px;
  }

  .simple-map-zoom {
    top: 140px;
    right: 18px;
  }

  .toast {
    bottom: 30px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}
