:root {
  color-scheme: light;
  font-family: Pretendard, "Noto Sans KR", system-ui, sans-serif;
  color: #173f35;
  background: #f4efe4;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

a {
  color: inherit;
}

button,
input {
  font: inherit;
}

.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;
}

.landing-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at 80% 12%, rgb(224 136 73 / 24%), transparent 28rem),
    #f4efe4;
}

.landing-shell {
  width: min(70rem, calc(100% - 2rem));
  margin: 0 auto;
  padding: clamp(4rem, 12vh, 8rem) 0;
}

.eyebrow {
  margin: 0 0 0.45rem;
  color: #b24d2d;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0.7rem;
  font-size: clamp(2.2rem, 6vw, 4.8rem);
  letter-spacing: -0.055em;
}

.lede {
  color: #52665f;
  font-size: clamp(1rem, 2vw, 1.25rem);
}

.city-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 0.8rem;
  margin-top: 3rem;
}

.city-card {
  display: flex;
  align-items: end;
  justify-content: space-between;
  min-height: 9rem;
  padding: 1.2rem;
  border: 1px solid rgb(23 63 53 / 15%);
  border-radius: 1.2rem;
  background: rgb(255 255 255 / 74%);
  text-decoration: none;
  box-shadow: 0 1rem 3rem rgb(23 63 53 / 7%);
}

.city-card strong {
  font-size: 1.7rem;
}

.city-card.is-pending {
  color: #6d7f78;
  background: #eef2ef;
  box-shadow: none;
  cursor: default;
}

.city-card.is-pending span {
  color: inherit;
}

.city-card span {
  color: #b24d2d;
  font-size: 0.85rem;
  font-weight: 700;
}

.topbar {
  display: grid;
  grid-template-columns: 5rem 1fr auto;
  align-items: center;
  gap: 1rem;
  min-height: 5.25rem;
  padding: 0.75rem clamp(1rem, 3vw, 2rem);
  border-bottom: 1px solid #d8d1c5;
  background: #fffdf8;
}

.topbar h1 {
  margin: 0;
  font-size: 1.55rem;
  letter-spacing: -0.035em;
}

.topbar .eyebrow {
  font-size: 0.68rem;
}

.back-link {
  font-weight: 750;
  text-decoration: none;
}

.source-button,
.tabs button,
.visit-filters button,
.more-button {
  border: 1px solid #cfc7ba;
  border-radius: 999px;
  background: #fffdf8;
  color: #173f35;
  cursor: pointer;
}

.source-button {
  padding: 0.6rem 0.9rem;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.4rem;
  padding: 0.55rem clamp(1rem, 3vw, 2rem);
  background: #fffdf8;
}

.tabs button {
  padding: 0.65rem 1rem;
}

.tabs button[aria-selected="true"] {
  border-color: #173f35;
  background: #173f35;
  color: white;
}

/* 도시 화면은 창 높이에 맞춘다. 머리글 아래를 지도 탭이 채우고, 장부 탭은 그 안에서 스크롤한다. */
.city-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

.city-page > main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

/* 지도와 식당 목록을 나란히 둔다. 좁은 화면에서는 목록이 지도 위의 시트가 된다(아래 미디어 쿼리). */
.map-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 24rem;
  height: 100%;
}

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

/* 지도 SDK의 컨트롤이 목록 시트 위로 올라오지 않게 지도를 한 층에 가둔다. */
.map-stage {
  position: relative;
  z-index: 0;
  min-width: 0;
  min-height: 0;
}

.list-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-left: 1px solid #d8d1c5;
  background: #fffdf8;
}

.sheet-handle {
  display: none;
}

.search-panel {
  padding: 0.9rem 1rem 0.75rem;
  border-bottom: 1px solid #e4ddd1;
}

.list-view,
.restaurant-detail {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.list-view[hidden],
.restaurant-detail[hidden] {
  display: none;
}

.restaurant-list {
  padding: 0;
  margin: 0;
  list-style: none;
}

.restaurant-item {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.75rem 1rem;
  border: 0;
  border-bottom: 1px solid #eee8dd;
  background: transparent;
  color: #173f35;
  text-align: left;
  cursor: pointer;
}

.restaurant-item:hover,
.restaurant-item:focus-visible {
  background: #f6f1e7;
}

.item-rank {
  color: #8a978f;
  font-size: 0.85rem;
  font-weight: 750;
  text-align: center;
}

.item-body {
  display: grid;
  gap: 0.15rem;
  min-width: 0;
}

.item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-address {
  overflow: hidden;
  color: #6d7f78;
  font-size: 0.8rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.closed-tag {
  justify-self: start;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background: #fff0d9;
  color: #7b3c20;
  font-size: 0.7rem;
  font-weight: 750;
}

.visit-badge {
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.list-empty {
  padding: 1.5rem 1rem;
  color: #6d7f78;
  text-align: center;
}

.list-view .more-button {
  display: block;
  margin: 0.9rem auto 1.2rem;
}

.list-view .more-button[hidden] {
  display: none;
}

.restaurant-detail {
  padding: 0.9rem 1.15rem 1.5rem;
}

.restaurant-detail h2 {
  margin: 0.6rem 0 0.35rem;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}

.restaurant-detail p {
  margin-bottom: 0.45rem;
}

.detail-close {
  padding: 0.35rem 0.1rem;
  border: 0;
  background: transparent;
  color: #52665f;
  font-weight: 750;
  cursor: pointer;
}

.detail-visits {
  font-weight: 750;
}

.detail-address,
.detail-line {
  color: #52665f;
  font-size: 0.92rem;
}

.naver-link {
  display: inline-block;
  margin-top: 0.4rem;
  font-weight: 750;
}

.search-field input {
  width: 100%;
  padding: 0.8rem 0.9rem;
  border: 1px solid #cfc7ba;
  border-radius: 0.7rem;
  background: white;
}

.visit-filters {
  display: flex;
  gap: 0.35rem;
  padding: 0;
  margin: 0.65rem 0;
  border: 0;
  overflow-x: auto;
}

.visit-filters button {
  flex: 0 0 auto;
  padding: 0.42rem 0.7rem;
  font-size: 0.78rem;
}

.visit-filters button[aria-pressed="true"] {
  border-color: #b24d2d;
  background: #b24d2d;
  color: white;
}

.result-count,
.loading {
  margin: 0;
  color: #52665f;
  font-size: 0.82rem;
}

.map {
  width: 100%;
  height: 100%;
  background: #dce5dc;
}

.map > .loading {
  padding: 14rem 1rem 1rem;
  text-align: center;
}

.map-error {
  width: min(30rem, calc(100% - 2rem));
  padding: 1rem;
  margin: 0 auto;
  transform: translateY(14rem);
  border-radius: 0.8rem;
  background: rgb(255 253 248 / 88%);
  color: #7b3c20;
  text-align: center;
}

.map-marker {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border: 3px solid #fffdf8;
  border-radius: 50% 50% 50% 0.35rem;
  background: #b24d2d;
  color: white;
  font-size: 0.78rem;
  font-weight: 850;
  box-shadow: 0 0.35rem 0.8rem rgb(23 63 53 / 28%);
  transform: rotate(-45deg);
  cursor: pointer;
}

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

/* 방문 구간 색. 많을수록 짙다. 필터·범례·목록 배지가 같은 구간을 쓴다(site.VISIT_BAND_LABELS). */
.band-20 {
  background: #7a2412;
  color: white;
}

.band-10 {
  background: #b24d2d;
  color: white;
}

.band-5 {
  background: #df8a4c;
  color: #3b1a0c;
}

.band-1 {
  background: #f1c27d;
  color: #3b1a0c;
}

.map-marker.is-closed,
.legend-swatch.is-closed {
  background: #59645f;
  color: white;
}

.map-marker.is-closed {
  text-decoration: line-through;
}

/* 지도 위의 안내와 범례. 오른쪽 위의 확대 컨트롤을 피해 왼쪽 위에 쌓는다. */
.map-overlay {
  position: absolute;
  z-index: 10;
  top: 0.75rem;
  left: 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
  max-width: min(22rem, calc(100% - 5rem));
  pointer-events: none;
}

.map-overlay > * {
  pointer-events: auto;
}

.map-warning {
  padding: 0.55rem 0.65rem;
  margin: 0;
  font-size: 0.75rem;
  box-shadow: 0 0.4rem 1.2rem rgb(23 63 53 / 12%);
}

.map-legend {
  padding: 0.55rem 0.7rem;
  border: 1px solid rgb(23 63 53 / 12%);
  border-radius: 0.7rem;
  background: rgb(255 253 248 / 94%);
  box-shadow: 0 0.4rem 1.2rem rgb(23 63 53 / 12%);
  font-size: 0.75rem;
}

.map-legend p {
  margin: 0 0 0.3rem;
  font-weight: 800;
}

.map-legend ul {
  display: grid;
  gap: 0.2rem;
  padding: 0;
  margin: 0;
  list-style: none;
}

.map-legend li {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.legend-swatch {
  width: 0.75rem;
  height: 0.75rem;
  border: 2px solid #fffdf8;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgb(23 63 53 / 20%);
}

.records-panel {
  width: min(64rem, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 5rem;
}

.records-list {
  display: grid;
  gap: 0.7rem;
  margin: 1.5rem 0;
}

.record-card {
  padding: 1rem;
  border: 1px solid #ddd5c8;
  border-radius: 0.85rem;
  background: #fffdf8;
}

.record-card h3 {
  margin: 0 0 0.35rem;
}

.record-card p {
  margin-bottom: 0.35rem;
  color: #52665f;
}

.record-state,
.closed-state,
.open-state {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  background: #e5ece8;
  font-size: 0.75rem;
  font-weight: 750;
}

.outside-city {
  color: #7b3c20;
  font-weight: 700;
}

.state-geocode_failed,
.state-pending,
.closed-state {
  background: #fff0d9;
  color: #7b3c20;
}

.more-button {
  padding: 0.7rem 1rem;
}

.source-dialog {
  width: min(30rem, calc(100% - 2rem));
  border: 0;
  border-radius: 1rem;
  color: #173f35;
  background: #fffdf8;
  box-shadow: 0 1rem 4rem rgb(0 0 0 / 25%);
}

.source-dialog::backdrop {
  background: rgb(23 63 53 / 50%);
}

.dialog-close {
  float: right;
  border: 0;
  background: transparent;
  font-size: 1.5rem;
  cursor: pointer;
}

.collection-scope {
  color: #4a4a4a;
  font-size: 0.92rem;
}

.collection-warning {
  padding: 0.8rem;
  border-radius: 0.6rem;
  background: #fff0d9;
  color: #7b3c20;
}

.coordinate-source {
  color: #52665f;
  font-size: 0.85rem;
}

.collection-table {
  width: 100%;
  margin-bottom: 0.8rem;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.collection-table th,
.collection-table td {
  padding: 0.4rem 0.3rem;
  border-bottom: 1px solid #dfe6e1;
  text-align: left;
  vertical-align: top;
}

.collection-table thead th {
  color: #52665f;
  font-size: 0.8rem;
}

@media (max-width: 640px) {
  .topbar {
    grid-template-columns: auto 1fr auto;
  }
}

/* 좁은 화면: 지도가 화면을 채우고 목록은 아래에서 끌어올리는 시트다. app.js는 손잡이가 보이는지로 시트를 안다.
   시트가 보이는 높이(--sheet-visible)는 app.js가 접힘·중간·펼침에 맞춰 정한다. */
@media (max-width: 720px) {
  .map-panel {
    position: relative;
    display: block;
    overflow: hidden;
  }

  .map-stage {
    position: absolute;
    inset: 0;
  }

  .map-overlay {
    top: 0.6rem;
    left: 0.6rem;
  }

  .list-panel {
    position: absolute;
    z-index: 20;
    right: 0;
    bottom: 0;
    left: 0;
    height: calc(100% - 1rem);
    border: 1px solid rgb(23 63 53 / 13%);
    border-bottom: 0;
    border-radius: 1.2rem 1.2rem 0 0;
    box-shadow: 0 -0.6rem 2rem rgb(23 63 53 / 16%);
    transform: translateY(calc(100% - var(--sheet-visible, 11rem)));
    transition: transform 180ms ease-out;
  }

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

  .sheet-handle {
    display: block;
    flex: 0 0 auto;
    width: 100%;
    height: 1.4rem;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: grab;
    touch-action: none;
  }

  .sheet-handle::before {
    display: block;
    width: 2.6rem;
    height: 0.3rem;
    margin: 0 auto;
    border-radius: 999px;
    background: #cfc7ba;
    content: "";
  }

  .search-panel {
    padding-top: 0.2rem;
  }

  .list-view,
  .restaurant-detail {
    padding-bottom: env(safe-area-inset-bottom);
  }
}
