:root {
  --bg: #f5f0e8;
  --panel: rgba(255, 252, 247, 0.92);
  --ink: #2b2118;
  --muted: #7c6d5f;
  --line: rgba(70, 50, 31, 0.14);
  --coffee: #5e3f2a;
  --orange: #c87032;
  --orange-strong: #e58b43;
  --green: #3f6f61;
  --shadow: 0 14px 42px rgba(62, 41, 24, 0.16);
}

* {
  box-sizing: border-box;
}

html,
body,
.map-shell {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI", sans-serif;
  overflow: hidden;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.map-shell {
  position: relative;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  overflow: hidden;
}

.app-header {
  position: relative;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(12px, env(safe-area-inset-top)) 14px 8px;
  background: linear-gradient(180deg, rgba(245, 240, 232, 0.98), rgba(245, 240, 232, 0.82));
}

.app-header p {
  margin: 0 0 2px;
  color: var(--orange);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.app-header h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0;
}

.icon-button {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--coffee);
  color: #fff;
  font-size: 19px;
  box-shadow: 0 8px 22px rgba(94, 63, 42, 0.24);
}

.icon-button.is-active {
  background: var(--orange);
}

.toolbar {
  position: relative;
  z-index: 1200;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  padding: 0 14px 10px;
  background: rgba(245, 240, 232, 0.82);
}

.search {
  min-width: 0;
  width: min(300px, calc(100vw - 72px));
  justify-self: center;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(62, 41, 24, 0.06);
}

.search span {
  color: var(--orange);
  font-size: 12px;
  font-weight: 800;
}

.search input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-size: 16px;
}

.search-count {
  display: inline-grid;
  min-width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 999px;
  color: #fff;
  background: var(--green);
  font-size: 11px;
  font-style: normal;
  font-weight: 900;
}

.search-suggestions {
  position: absolute;
  top: 46px;
  left: 50%;
  right: auto;
  z-index: 2;
  width: min(300px, calc(100vw - 72px));
  transform: translateX(-50%);
  max-height: min(44vh, 360px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fffaf4;
  box-shadow: 0 16px 36px rgba(62, 41, 24, 0.18);
  padding: 8px;
}

.suggestion-group + .suggestion-group {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.suggestion-group strong {
  display: block;
  margin: 2px 4px 6px;
  color: var(--orange);
  font-size: 12px;
}

.suggestion-option {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  padding: 9px 8px;
  text-align: left;
}

.suggestion-option span {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
  font-weight: 800;
}

.suggestion-option i {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
}

.suggestion-option:active,
.suggestion-option:hover {
  background: rgba(200, 112, 50, 0.1);
}

.map-zone {
  position: relative;
  min-height: 0;
}

#map {
  position: absolute;
  inset: 0;
  background: #f7f5f0;
}

.leaflet-container {
  font-family: inherit;
}

.leaflet-container.map-locked {
  cursor: default;
}

.leaflet-container.map-virtual-drag {
  cursor: grab;
  touch-action: none;
}

.leaflet-container.map-virtual-drag.is-dragging {
  cursor: grabbing;
}

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

.leaflet-control-zoom a {
  width: 38px !important;
  height: 38px !important;
  line-height: 38px !important;
  border: 0 !important;
  color: var(--ink) !important;
}

.leaflet-bottom.leaflet-left {
  bottom: 10px;
  left: 10px;
}

.coffee-marker {
  transition: transform 0.2s ease;
}

.coffee-marker div {
  transform-origin: center;
}

.coffee-marker.is-active {
  transform: scale(1.18);
}

.selected-country {
  filter: drop-shadow(0 7px 7px rgba(156, 85, 35, 0.36));
}

.country-flag {
  pointer-events: none;
}

.country-flag div {
  width: 78px;
  display: grid;
  justify-items: center;
  gap: 4px;
  font-size: 28px;
  line-height: 1;
  overflow: visible;
}

.country-flag img {
  width: 72px;
  height: 48px;
  display: block;
  border: 2px solid rgba(255, 255, 255, 0.82);
  border-radius: 9px;
  background: rgba(255, 252, 247, 0.86);
  box-shadow: 0 10px 28px rgba(62, 41, 24, 0.22);
  object-fit: cover;
}

.country-flag .flag-fallback {
  width: 72px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.82);
  border-radius: 9px;
  background: rgba(255, 252, 247, 0.86);
  box-shadow: 0 10px 28px rgba(62, 41, 24, 0.22);
  font-size: 19px;
  font-weight: 900;
}

.country-flag strong {
  color: #3d2a1c;
  text-shadow: 0 1px 0 rgba(255, 250, 244, 0.92), 0 0 8px rgba(255, 250, 244, 0.88);
  font-size: 18px;
  font-weight: 950;
  line-height: 1.1;
  letter-spacing: 0;
  text-align: center;
  white-space: nowrap;
}

.region-label {
  pointer-events: none;
}

.region-label i {
  position: absolute;
  left: 0;
  top: 0;
  width: 5px;
  height: 5px;
  border: 1px solid #fffaf4;
  border-radius: 999px;
  background: var(--orange);
  box-shadow: 0 3px 8px rgba(43, 33, 24, 0.22);
  transform: translate(-50%, -50%);
}

.region-label span {
  position: absolute;
  left: 0;
  top: 0;
  display: block;
  padding: 0;
  border: 0;
  color: #5e3f2a;
  background: transparent;
  text-shadow: 0 1px 0 rgba(255, 250, 244, 0.88), 0 0 6px rgba(255, 250, 244, 0.82);
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  text-align: center;
  transform: translate(calc(-50% + var(--label-x, 0px)), calc(-100% - 9px + var(--label-y, 0px)));
  white-space: nowrap;
}

.loading,
.empty-map {
  position: absolute;
  left: 50%;
  top: 46%;
  z-index: 800;
  transform: translate(-50%, -50%);
  border-radius: 999px;
  padding: 8px 16px;
  color: #fff;
  background: rgba(43, 33, 24, 0.76);
  font-size: 13px;
  white-space: nowrap;
}

.hidden {
  display: none !important;
}

.sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 900;
  max-height: min(48vh, 420px);
  padding: 8px 12px max(12px, env(safe-area-inset-bottom));
  border-radius: 16px 16px 0 0;
  border-top: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 -18px 42px rgba(62, 41, 24, 0.18);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.sheet.is-empty {
  pointer-events: none;
}

.sheet-handle {
  width: 38px;
  height: 4px;
  margin: 0 auto 8px;
  border-radius: 99px;
  background: rgba(43, 33, 24, 0.18);
}

.sheet-empty {
  display: grid;
  gap: 2px;
  padding: 12px 4px;
}

.sheet-empty strong {
  font-size: 16px;
}

.sheet-empty span {
  color: var(--muted);
  font-size: 13px;
}

.country-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.country-summary span {
  display: block;
  color: var(--orange);
  font-size: 13px;
  font-weight: 800;
}

.country-summary strong {
  display: block;
  margin-top: 2px;
  font-size: 17px;
}

.country-summary button,
.filter-head button {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: var(--ink);
  background: rgba(43, 33, 24, 0.07);
  font-size: 24px;
  line-height: 1;
}

.sheet-columns {
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr;
}

.bean-list,
.bean-detail {
  max-height: calc(min(48vh, 420px) - 84px);
  overflow: auto;
  padding-top: 8px;
}

.bean-list {
  display: grid;
  gap: 8px;
}

.sheet.detail-mode .bean-list {
  display: none;
}

.bean-card {
  width: 100%;
  display: grid;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  padding: 11px;
  text-align: left;
}

.bean-card.is-selected {
  border-color: rgba(200, 112, 50, 0.55);
  box-shadow: inset 4px 0 0 var(--orange);
}

.bean-card strong {
  font-size: 15px;
}

.bean-card span,
.bean-card small {
  color: var(--muted);
  line-height: 1.5;
}

.bean-list-empty {
  display: grid;
  gap: 5px;
  border: 1px dashed rgba(43, 33, 24, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
  padding: 18px 12px;
  text-align: center;
}

.bean-list-empty strong {
  color: var(--ink);
  font-size: 15px;
}

.bean-list-empty span {
  color: var(--muted);
  font-size: 13px;
}

.bean-detail {
  position: relative;
  display: grid;
  gap: 10px;
}

.back-btn {
  justify-self: start;
  border-radius: 8px;
  padding: 7px 10px;
  color: var(--orange);
  background: rgba(200, 112, 50, 0.1);
  font-weight: 800;
}

.detail-title {
  display: grid;
  gap: 4px;
}

.detail-title h2 {
  margin: 0;
  font-size: 20px;
}

.detail-title span {
  color: var(--muted);
  font-size: 13px;
}

.meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.meta-grid div,
.flavor-box,
.scene-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.66);
}

.meta-grid span,
.flavor-box span,
.scene-box span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.meta-grid strong {
  font-size: 13px;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tags i {
  display: inline-flex;
  border-radius: 999px;
  padding: 4px 8px;
  background: rgba(63, 111, 97, 0.1);
  color: var(--green);
  font-size: 12px;
  font-style: normal;
  font-weight: 700;
}

.buy-button {
  position: sticky;
  bottom: 0;
  display: block;
  width: 100%;
  border-radius: 8px;
  padding: 12px;
  color: #fff;
  background: var(--orange);
  font-weight: 900;
  box-shadow: 0 8px 20px rgba(200, 112, 50, 0.28);
}

.filter-panel {
  position: absolute;
  top: 46px;
  left: 50%;
  right: auto;
  z-index: 1;
  width: min(300px, calc(100vw - 72px));
  display: block;
  background: transparent;
  transform: translateX(-50%);
}

.filter-card {
  max-height: min(48vh, 360px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fffaf4;
  padding: 10px;
  box-shadow: 0 16px 36px rgba(62, 41, 24, 0.18);
}

.filter-head,
.filter-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.filter-head h2 {
  margin: 0;
  font-size: 15px;
}

.filter-groups {
  margin: 8px 0;
}

.filter-cascade {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  height: min(30vh, 230px);
  min-height: 190px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.64);
}

.filter-category-list {
  display: grid;
  align-content: start;
  gap: 2px;
  max-height: 100%;
  overflow: auto;
  border-right: 1px solid var(--line);
  background: rgba(245, 240, 232, 0.72);
}

.filter-category {
  min-height: 38px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 5px;
  padding: 8px 10px;
  border-left: 3px solid transparent;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.filter-category span {
  font-size: 12px;
  font-weight: 800;
}

.filter-category strong {
  min-width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  color: #fff;
  background: var(--orange);
  font-size: 11px;
}

.filter-category.is-active {
  border-left-color: var(--orange);
  background: rgba(255, 255, 255, 0.88);
  color: var(--orange);
}

.filter-option-panel {
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.filter-option-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}

.filter-option-head span {
  color: var(--orange);
  font-size: 14px;
  font-weight: 900;
}

.filter-option-head strong {
  color: var(--muted);
  font-size: 12px;
}

.filter-option-list {
  flex: 1;
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 6px;
  overflow-y: auto;
  padding: 8px;
}

.filter-option {
  width: 100%;
  min-height: 34px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  padding: 7px 8px;
  text-align: left;
}

.filter-option span {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
}

.filter-option i {
  color: var(--orange);
  font-size: 11px;
  font-style: normal;
  font-weight: 900;
}

.filter-option.is-on {
  border-color: rgba(200, 112, 50, 0.55);
  background: rgba(200, 112, 50, 0.1);
  box-shadow: inset 3px 0 0 var(--orange);
}

.filter-option-empty {
  border: 1px dashed rgba(43, 33, 24, 0.16);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.58);
  padding: 14px 10px;
  font-size: 13px;
  text-align: center;
}

.filter-actions button {
  flex: 1;
  min-height: 36px;
  border-radius: 8px;
  color: #fff;
  background: var(--green);
  font-weight: 900;
}

.filter-actions .ghost {
  color: var(--ink);
  background: rgba(43, 33, 24, 0.08);
}

body.is-virtual-landscape {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

body.is-virtual-landscape .map-shell {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vh;
  height: 100vw;
  transform: rotate(90deg) translateY(-100%);
  transform-origin: top left;
  grid-template-rows: auto minmax(0, 1fr);
}

body.is-virtual-landscape .app-header {
  grid-row: 1;
  padding: 10px 12px 8px;
}

body.is-virtual-landscape .toolbar {
  position: absolute;
  top: 10px;
  left: 180px;
  right: 66px;
  width: min(620px, calc(100% - 260px));
  border-radius: 10px;
  padding: 0;
  background: transparent;
}

body.is-virtual-landscape .map-zone {
  grid-row: 2;
}

body.is-virtual-landscape .sheet {
  left: auto;
  top: 76px;
  right: 12px;
  bottom: 12px;
  width: min(62%, 720px);
  max-height: none;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}

body.is-virtual-landscape .sheet.is-empty {
  display: none;
}

body.is-virtual-landscape .sheet-handle {
  display: none;
}

body.is-virtual-landscape .sheet-columns {
  grid-template-columns: minmax(180px, 0.9fr) minmax(0, 1.1fr);
  gap: 12px;
}

body.is-virtual-landscape .sheet.detail-mode .bean-list {
  display: grid;
}

body.is-virtual-landscape .bean-list,
body.is-virtual-landscape .bean-detail {
  max-height: calc(100vw - 166px);
}

body.is-virtual-landscape .back-btn {
  display: none;
}

body.is-virtual-landscape .filter-panel {
  top: 46px;
  left: 50%;
  right: auto;
  width: min(300px, calc(100vw - 72px));
  transform: translateX(-50%);
}

body.is-virtual-landscape .filter-card {
  width: 100%;
  border-radius: 10px;
}

@media (orientation: landscape) and (max-height: 620px), (min-width: 900px) {
  .map-shell {
    grid-template-rows: auto minmax(0, 1fr);
  }

  .app-header {
    grid-row: 1;
  }

  .toolbar {
    position: absolute;
    top: max(10px, env(safe-area-inset-top));
    left: 180px;
    right: 66px;
    width: min(620px, calc(100vw - 260px));
    border-radius: 10px;
    padding: 0;
    background: transparent;
  }

  .map-zone {
    grid-row: 2;
  }

  .sheet {
    left: auto;
    top: 76px;
    right: 12px;
    bottom: 12px;
    width: min(62vw, 720px);
    max-height: none;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px;
  }

  .sheet.is-empty {
    top: 96px;
    right: 18px;
    bottom: auto;
    width: 260px;
    max-height: none;
    padding: 14px 16px;
    border-radius: 12px;
  }

  .sheet.is-empty .sheet-empty {
    padding: 0;
  }

  .sheet-handle {
    display: none;
  }

  .sheet-columns {
    grid-template-columns: minmax(180px, 0.9fr) minmax(0, 1.1fr);
    gap: 12px;
  }

  .sheet.detail-mode .bean-list {
    display: grid;
  }

  .bean-list,
  .bean-detail {
    max-height: calc(100vh - 166px);
  }

  .back-btn {
    display: none;
  }

  .filter-panel {
    top: 46px;
    left: 50%;
    right: auto;
    width: min(300px, calc(100vw - 72px));
    transform: translateX(-50%);
  }

  .filter-card {
    width: 100%;
    border-radius: 10px;
  }
}

@media (orientation: portrait) and (max-width: 700px) {
  .leaflet-control-zoom {
    display: none;
  }
}
.purchase-message {
  color: #9c3e29;
  font-size: 13px;
  line-height: 1.6;
  padding: 8px 0;
}
