body.modal-open {
  overflow: hidden;
}

.location-modal {
  position: fixed;
  inset: 0;
  z-index: 1300;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background: rgba(18, 24, 22, 0.72);
  cursor: pointer;
}

.location-modal[hidden] {
  display: none !important;
}

.location-dialog {
  width: min(100%, 1240px);
  height: min(92vh, 820px);
  height: min(92dvh, 820px);
  max-height: min(92vh, 820px);
  max-height: min(92dvh, 820px);
  display: grid;
  grid-template-columns: minmax(420px, 520px) 1fr;
  background: #fff;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
  animation: location-pop 0.35s ease;
  cursor: default;
}

.location-close {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 6;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  color: #3a2a28;
  font-size: 1.55rem;
  line-height: 1;
  cursor: pointer;
}

.location-close:hover,
.location-close:focus {
  background: #fff;
}

.location-form {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1.35rem;
  padding: 3.15rem 1.85rem 1.85rem;
  overflow: auto;
  background: #fff;
  min-width: 0;
  z-index: 1;
}

.location-lantern {
  position: absolute;
  top: -6px;
  right: 18px;
  width: 92px;
  height: auto;
  transform-origin: top center;
  pointer-events: none;
  z-index: 0;
  animation: lantern-swing 4.6s ease-in-out infinite;
  filter: drop-shadow(0 10px 18px rgba(74, 4, 4, 0.18));
}

.location-form.is-delivery,
.location-form.is-pickup {
  background-color: #f9e8d2;
}

.location-form.is-delivery .mode-switch,
.location-form.is-delivery .addr-type-switch,
.location-form.is-pickup .mode-switch,
.location-form.is-pickup .addr-type-switch {
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 4px 16px rgba(60, 20, 12, 0.08);
}

.location-form.is-delivery .location-hint,
.location-form.is-delivery .location-delivery-price,
.location-form.is-delivery .location-title,
.location-form.is-delivery .field-label,
.location-form.is-pickup .location-hint,
.location-form.is-pickup .location-delivery-price,
.location-form.is-pickup .location-title,
.location-form.is-pickup .field-label {
  text-shadow: 0 1px 0 rgba(255, 240, 238, 0.85);
}

.location-form.is-delivery .field-input,
.location-form.is-delivery .field-input-sm,
.location-form.is-delivery .pickup-card,
.location-form.is-pickup .field-input,
.location-form.is-pickup .field-input-sm,
.location-form.is-pickup .pickup-card {
  background: rgba(255, 255, 255, 0.88);
  border-color: rgba(165, 28, 28, 0.22);
  box-shadow: 0 4px 14px rgba(60, 20, 12, 0.06);
}

.location-form.is-delivery .location-confirm:disabled,
.location-form.is-pickup .location-confirm:disabled {
  opacity: 0.55;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
  padding: 0.4rem;
  border-radius: 14px;
  background: #eef1f4;
  flex-shrink: 0;
}

.mode-switch.is-delivery-only {
  grid-template-columns: 1fr;
}

.mode-tab {
  min-height: 52px;
  padding: 0.75rem 1rem;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #222;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.mode-tab.is-active {
  background: #a51c1c;
  color: #fff;
}

.location-hint {
  margin: 0;
  color: #6b7280;
  font-size: 1rem;
  line-height: 1.5;
}

.location-delivery-price {
  margin: 0.15rem 0 0;
  color: #5c4540;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.45;
}

.location-delivery-price[hidden] {
  display: none !important;
}

.location-title {
  margin: 0;
  font-family: var(--font-display, "Zen Maru Gothic", "Manrope", sans-serif);
  font-size: clamp(1.85rem, 2.4vw, 2.25rem);
  font-weight: 700;
  line-height: 1.2;
  color: #111;
}

.saved-locations {
  display: grid;
  gap: 0.65rem;
  flex-shrink: 0;
}

.saved-locations[hidden] {
  display: none !important;
}

.saved-locations-title {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 700;
  color: #3b241c;
}

.saved-locations-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
  max-height: 168px;
  overflow: auto;
}

.saved-location-item {
  width: 100%;
  display: grid;
  gap: 0.2rem;
  padding: 0.7rem 0.85rem;
  border: 1.5px solid rgba(60, 28, 18, 0.16);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.82);
  color: #22140f;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.saved-location-item:hover {
  border-color: rgba(165, 28, 28, 0.45);
}

.saved-location-item.is-selected {
  border-color: #a51c1c;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(165, 28, 28, 0.14);
}

.saved-location-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.55rem;
}

.saved-location-label {
  font-size: 0.98rem;
}

.saved-location-default {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #a51c1c;
}

.saved-location-facts {
  color: #6b5a52;
  font-size: 0.86rem;
  line-height: 1.4;
}

.saved-locations-other {
  justify-self: start;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #a51c1c;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 0.15em;
  cursor: pointer;
}

.saved-locations-other:hover {
  color: #7f1414;
}

.field {
  display: grid;
  gap: 0.55rem;
  min-width: 0;
}

.field-label {
  font-size: 1rem;
  font-weight: 600;
  color: #222;
}

.req {
  color: #a51c1c;
}

.field-input,
.field-input-sm {
  width: 100%;
  min-height: 56px;
  padding: 0.9rem 1.1rem;
  border: 1px solid #d7dde3;
  border-radius: 14px;
  background: #fff;
  color: #111;
  font-size: 1.05rem;
  line-height: 1.3;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.field-input:focus,
.field-input-sm:focus {
  border-color: #a51c1c;
  box-shadow: 0 0 0 3px rgba(165, 28, 28, 0.16);
}

.field-shell {
  position: relative;
  display: block;
  min-width: 0;
}

.field-ph {
  position: absolute;
  left: 1.1rem;
  right: 1.1rem;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  pointer-events: none;
  color: #9aa3ad;
  font-size: 1.05rem;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.field-ph .req {
  color: #a51c1c;
  font-weight: 700;
}

.field-shell.has-value .field-ph {
  opacity: 0;
  visibility: hidden;
}

#address-extra[hidden],
.extra-grid[hidden] {
  display: none !important;
}

#delivery-panel,
#pickup-panel {
  display: grid;
  gap: 1.25rem;
  min-width: 0;
}

.address-suggest {
  position: relative;
  display: grid;
  gap: 0;
  min-width: 0;
  z-index: 5;
}

.address-status {
  margin-top: -2px;
  padding: 0.85rem 1rem;
  border: 1px solid #d7dde3;
  border-top: 0;
  border-radius: 0 0 14px 14px;
  background: #eceff3;
  color: #6b7280;
  font-size: 0.95rem;
  line-height: 1.4;
}

.address-status.is-error {
  color: #5b6470;
}

.address-suggest:has(.address-status:not([hidden])) .field-input,
.address-suggest:has(.address-suggestions:not([hidden])) .field-input {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.address-suggestions {
  list-style: none;
  margin: -2px 0 0;
  padding: 0.25rem 0;
  border: 1px solid #d7dde3;
  border-top: 0;
  border-radius: 0 0 14px 14px;
  background: #fff;
  max-height: 260px;
  overflow: auto;
  box-shadow: 0 12px 28px rgba(20, 20, 20, 0.12);
}

.address-suggestion {
  display: grid;
  gap: 0.2rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: background 0.15s ease;
}

.address-suggestion:hover {
  background: #f5f7fa;
}

.address-suggestion-title {
  color: #111;
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.3;
}

.address-suggestion-title mark {
  background: #ffe566;
  color: inherit;
  padding: 0 0.05em;
}

.address-suggestion-sub {
  color: #8b93a0;
  font-size: 0.88rem;
  line-height: 1.35;
}

#delivery-panel[hidden],
#pickup-panel[hidden] {
  display: none !important;
}

.addr-type-group {
  display: grid;
  gap: 0.7rem;
  min-width: 0;
}

.addr-type-switch {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.35rem;
  padding: 0.35rem;
  border-radius: 14px;
  background: #eef1f4;
}

.addr-type-btn {
  min-height: 52px;
  padding: 0.7rem 0.5rem;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #222;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  white-space: nowrap;
}

.addr-type-btn.is-active {
  background: #a51c1c;
  color: #fff;
}

.extra-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
  min-width: 0;
}

.pickup-card {
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  padding: 1.25rem 1.35rem;
  display: grid;
  gap: 0.9rem;
  background: #fafbfc;
}

.pickup-card p {
  margin: 0;
  color: #222;
  font-size: 1.05rem;
  line-height: 1.5;
}

.pickup-card strong {
  display: inline;
}

.pickup-prep {
  font-weight: 700;
}

.location-confirm {
  position: relative;
  z-index: 0;
  margin-top: 0.5rem;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  width: 100%;
  padding: 0.65rem 1.25rem;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  clip-path: polygon(
    9px 0%,
    calc(100% - 9px) 0%,
    100% 9px,
    100% calc(100% - 9px),
    calc(100% - 9px) 100%,
    9px 100%,
    0% calc(100% - 9px),
    0% 9px
  );
  transition: color 0.2s ease, opacity 0.2s ease, filter 0.2s ease;
}

.location-confirm::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  clip-path: inherit;
  background: linear-gradient(155deg, #e2c878 0%, #c5a059 42%, #9a7840 100%);
  transition: background 0.2s ease;
}

.location-confirm::after {
  content: "";
  position: absolute;
  inset: 2px;
  z-index: -1;
  clip-path: polygon(
    7px 0%,
    calc(100% - 7px) 0%,
    100% 7px,
    100% calc(100% - 7px),
    calc(100% - 7px) 100%,
    7px 100%,
    0% calc(100% - 7px),
    0% 7px
  );
  background: #4a0404;
  box-shadow: inset 0 0 0 1px rgba(197, 160, 89, 0.58);
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.location-confirm:hover:not(:disabled)::before {
  background: linear-gradient(155deg, #f0dfa0 0%, #e2c878 40%, #c5a059 100%);
}

.location-confirm:hover:not(:disabled)::after {
  background: #5c0a0a;
  box-shadow: inset 0 0 0 1px rgba(226, 200, 120, 0.72);
}

.location-confirm:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  color: #fff;
}

.location-confirm:disabled::after {
  background: #6b7280;
  box-shadow: none;
}

.location-confirm:disabled::before {
  background: linear-gradient(155deg, #d1d5db 0%, #9ca3af 100%);
}

.location-delivery-info-link {
  display: block;
  margin-top: 0.65rem;
  flex-shrink: 0;
  text-align: center;
  border: 0;
  padding: 0;
  background: transparent;
  color: #8a1818;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

.location-delivery-info-link:hover {
  color: #4a0404;
}

.location-map-wrap {
  position: relative;
  min-height: 100%;
  background: #e8eef2;
}

#yori-map {
  width: 100%;
  height: 100%;
  min-height: 100%;
}

.yori-map-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 2rem;
  text-align: center;
  color: #334155;
  background:
    linear-gradient(160deg, rgba(165, 28, 28, 0.1), rgba(20, 32, 27, 0.06)),
    #e8eef2;
  font-size: 1.05rem;
  line-height: 1.55;
}

.yori-map-fallback[hidden],
#yori-map[hidden] {
  display: none !important;
}

.location-reopen {
  margin-left: auto;
  min-height: 38px;
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--line, rgba(26, 21, 20, 0.12));
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink, #1a1514);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.location-reopen:hover {
  border-color: var(--accent, #a51c1c);
  color: var(--accent, #a51c1c);
  background: rgba(165, 28, 28, 0.06);
}

@keyframes lantern-swing {
  0%,
  100% { transform: rotate(-4deg); }
  50% { transform: rotate(4deg); }
}

@keyframes location-pop {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 980px) {
  .location-dialog {
    grid-template-columns: 1fr;
    height: auto;
    max-height: 94vh;
    max-height: 94dvh;
    width: min(100%, 640px);
  }

  .location-map-wrap,
  #yori-map {
    min-height: 240px;
  }

  .location-form {
    max-height: none;
  }
}

@media (max-width: 720px) {
  .location-modal {
    padding: 0.65rem;
    align-items: start;
    overflow: auto;
  }

  .location-dialog {
    width: 100%;
    border-radius: 16px;
    height: auto;
    max-height: calc(100dvh - 1.3rem);
    overflow: auto;
  }

  .location-form {
    padding: 2.85rem 1.15rem 1.35rem;
    gap: 1.1rem;
  }

  .location-lantern {
    width: 72px;
    right: 10px;
  }

  .location-map-wrap,
  #yori-map {
    min-height: 200px;
  }

  .mode-tab,
  .addr-type-btn {
    min-height: 48px;
    font-size: 0.95rem;
  }

  .field-input,
  .field-input-sm,
  .field-ph {
    font-size: 1rem;
  }

  .extra-grid {
    gap: 0.75rem;
  }

  .header-inner {
    flex-wrap: wrap;
  }

  .location-reopen {
    order: 3;
    width: 100%;
    margin-left: 0;
  }
}

/* Light theme overrides */
[data-theme="light"] .location-lantern {
  display: none !important;
}

[data-theme="light"] .location-form.is-delivery,
[data-theme="light"] .location-form.is-pickup {
  background-color: #ffffff;
  background-image: none;
}

[data-theme="light"] .mode-tab.is-active,
[data-theme="light"] .addr-type-btn.is-active {
  background: #1a1514;
  color: #ffffff;
}

[data-theme="light"] .location-confirm {
  clip-path: none;
  color: #ffffff;
  background: #1a1514;
  border-radius: 10px;
}

[data-theme="light"] .location-confirm::before,
[data-theme="light"] .location-confirm::after {
  content: none;
}

[data-theme="light"] .location-confirm:hover:not(:disabled) {
  background: #333333;
  filter: none;
}

[data-theme="light"] .location-confirm:disabled {
  background: #cccccc;
  color: #666666;
}

[data-theme="light"] .saved-location-default,
[data-theme="light"] .saved-locations-other,
[data-theme="light"] .req,
[data-theme="light"] .field-ph .req,
[data-theme="light"] .location-delivery-info-link {
  color: var(--ink, #1a1514);
}

[data-theme="light"] .saved-location-item.is-selected {
  border-color: #1a1514;
  box-shadow: 0 0 0 3px rgba(26, 21, 20, 0.1);
}

[data-theme="light"] .field-input:focus,
[data-theme="light"] .field-input-sm:focus {
  border-color: #1a1514;
  box-shadow: 0 0 0 3px rgba(26, 21, 20, 0.1);
}

.is-inapp-browser .location-modal {
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

.is-inapp-browser .location-dialog {
  animation: none;
}

@media (min-width: 901px) {
  .location-form.is-delivery,
  .location-form.is-pickup {
    background-image: url("../images/delivery-bg.png");
    background-size: 100% 100%;
    background-position: center;
    background-repeat: no-repeat;
  }
}
