:root {
  color-scheme: light;
  --bg: #f3efe7;
  --bg-accent: #f7f2ea;
  --ink: #141414;
  --muted: #5c5c5c;
  --card: #ffffff;
  --stroke: #e5dfd4;
  --accent: #d25a3c;
  --accent-soft: #f6dfd7;
  --shadow: 0 18px 40px rgba(20, 20, 20, 0.12);
  --detail-pane-width: clamp(420px, 34vw, 560px);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 10%, #ffe9d6 0%, transparent 50%),
    radial-gradient(circle at 80% 0%, #e9f0ff 0%, transparent 55%),
    linear-gradient(120deg, var(--bg), var(--bg-accent));
}

.favorites-page .page {
  width: min(1120px, calc(100vw - var(--detail-pane-width) - 64px));
  max-width: 1120px;
  margin: 0 auto 0 40px;
  padding: 48px 24px 72px;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 32px;
}

.title-block h1 {
  font-size: clamp(32px, 4vw, 48px);
  margin: 8px 0 6px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.eyebrow {
  margin: 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--muted);
}

.subtitle {
  margin: 0;
  font-size: 16px;
  font-family: "Crimson Pro", "Times New Roman", serif;
  color: var(--muted);
}

.header-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.link-btn,
.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
  background: var(--card);
  color: var(--ink);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.link-btn {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
  box-shadow: var(--shadow);
}

.ghost-btn:hover,
.link-btn:hover {
  transform: translateY(-2px);
}

.controls {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(260px, 1fr) auto;
  align-items: end;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(8px);
  border-radius: 20px;
  padding: 18px;
  border: 1px solid var(--stroke);
  margin-bottom: 28px;
}

.saved-itineraries {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--stroke);
  border-radius: 18px;
  padding: 14px;
  margin-bottom: 20px;
}

.saved-itineraries-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.saved-itineraries-count {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.saved-itineraries-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}

.saved-itinerary-card {
  border: 1px solid var(--stroke);
  border-radius: 12px;
  background: #fff;
  padding: 10px;
  display: grid;
  gap: 6px;
}

.saved-itinerary-name {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.saved-itinerary-meta {
  font-size: 12px;
  color: var(--muted);
}

.saved-itinerary-actions {
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.saved-itinerary-actions button {
  border: 1px solid var(--stroke);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
  cursor: pointer;
}

.saved-itinerary-actions button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

input,
select {
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
}

.count {
  font-weight: 600;
  font-size: 15px;
  color: var(--ink);
  align-self: center;
}

.favorites-layout {
  position: relative;
  display: grid;
  gap: 0;
  grid-template-columns: 1fr;
  align-items: start;
}

.section-title {
  margin: 0 0 10px;
  font-size: 15px;
  letter-spacing: 0.01em;
}

.favorites-center {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--stroke);
  border-radius: 18px;
  padding: 14px;
}

.spots-grid,
.region-spot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 220px));
  gap: 10px;
  justify-content: start;
}
.spots-grid {
  grid-template-columns: 1fr; /* country sections must stack vertically */
}

.country-section + .country-section {
  margin-top: 18px;
}

.country-section-title {
  margin: 0 0 8px;
  font-size: 22px;
}

.region-group + .region-group {
  margin-top: 10px;
}

.region-group-title {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--muted);
}

.spot-tile {
  position: relative;
  border: 1px solid var(--stroke);
  border-radius: 12px;
  background: #fff;
  text-align: left;
  padding: 10px;
  display: grid;
  gap: 4px;
  cursor: pointer;
  min-height: 92px;
  transition: box-shadow 160ms ease, border-color 160ms ease, opacity 120ms ease, transform 120ms ease;
}

.spot-tile-photo {
  width: 100%;
  height: 140px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--stroke);
}

.spot-tile-photo-placeholder {
  width: 100%;
  height: 140px;
  border-radius: 10px;
  border: 1px solid var(--stroke);
  background: #e6ebf3;
  color: #6f7b8d;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.spot-tile:hover {
  border-color: var(--accent);
}

.spot-tile[draggable="true"] {
  cursor: grab;
}

.spot-tile[draggable="true"]:active {
  cursor: grabbing;
}

.spot-tile.is-dragging {
  transform: none;
}

.spot-tile.is-drag-origin-hidden {
  visibility: hidden;
}

.region-spot-grid.is-drag-active .spot-tile:not(.is-dragging) {
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.03);
  transform: translateY(-1px);
}

.spot-tile-drag-indicator {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: #fff;
  color: #5b677f;
  font-size: 12px;
  line-height: 20px;
  text-align: center;
  pointer-events: none;
}

.spot-tile-check-wrap {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.spot-tile-check {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
  cursor: pointer;
}

.spot-tile-drag-preview {
  position: fixed;
  top: -2000px;
  left: -2000px;
  z-index: 9999;
  box-shadow: 0 16px 34px rgba(20, 20, 20, 0.22);
  border-color: var(--accent);
}

.spot-tile.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(210, 90, 60, 0.24);
  background: #fff8f5;
}

.spot-tile-title {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
}

.spot-tile-rank {
  font-size: 13px;
  font-weight: 700;
}

.spot-tile-meta {
  font-size: 12px;
  color: var(--muted);
}

.spot-tile-rating {
  font-size: 12px;
  color: #2f3a55;
}

.spot-tile-category {
  font-size: 13px;
  font-weight: 600;
  color: #22314d;
}

.spot-tile-desc {
  font-size: 13px;
  color: #374054;
  line-height: 1.45;
}

.spot-tile-note {
  margin-top: 2px;
  padding-top: 6px;
  border-top: 1px dashed #e6ded3;
  font-size: 12px;
  color: #5c402f;
  line-height: 1.45;
}

.favorites-detail {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--detail-pane-width);
  z-index: 12;
  background: rgba(255, 255, 255, 0.82);
  border-left: 1px solid var(--stroke);
  border-radius: 16px 0 0 16px;
  padding: 20px 16px;
  min-height: auto;
  max-height: none;
  height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: -18px 0 40px rgba(20, 20, 20, 0.14);
}
.favorites-detail.slide-in {
  animation: detail-slide-in 280ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes detail-slide-in {
  0% {
    opacity: 0;
    transform: translateX(52px);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

.detail-heading h2 {
  margin: 0;
  font-size: clamp(24px, 3vw, 32px);
}

.detail-heading {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 8px;
  align-items: start;
}

.detail-heading p {
  grid-column: 1 / -1;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.detail-close-btn {
  border: 1px solid var(--stroke);
  background: #fff;
  border-radius: 999px;
  width: 32px;
  height: 32px;
  font-size: 20px;
  line-height: 1;
  padding: 0;
  cursor: pointer;
}

.notes-panel {
  margin-top: 14px;
  padding: 12px;
  border: 1px dashed var(--stroke);
  border-radius: 12px;
  background: #fff;
}

.notes-panel h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.notes-panel textarea {
  width: 100%;
  resize: vertical;
  min-height: 74px;
  border: 1px solid var(--stroke);
  border-radius: 10px;
  background: #fafafa;
  padding: 10px;
  font-family: inherit;
}

.detail-map-panel {
  margin-top: 12px;
  background: #fff;
  border: 1px solid var(--stroke);
  border-radius: 14px;
  padding: 10px;
}

.detail-map-panel h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.detail-map-frame {
  display: block;
  width: 100%;
  height: 420px;
  border: 1px solid var(--stroke);
  border-radius: 10px;
  background: #f7f7f7;
}

.open-basho-map-link {
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--stroke);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
}

.open-basho-map-link:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.detail-cards {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.detail-card {
  background: #fff;
  border: 1px solid var(--stroke);
  border-radius: 14px;
  padding: 12px;
}

.detail-card-photo {
  display: block;
  width: 100%;
  height: 180px;
  margin-top: 10px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--stroke);
}

.detail-card-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.detail-card-head h4 {
  margin: 0;
  font-size: 17px;
}

.detail-meta {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

.detail-tags {
  margin-top: 8px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.detail-foot {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}

.favorite-tag {
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
}

.remove-btn {
  border: 1px solid var(--stroke);
  background: #fff;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 12px;
}

.remove-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.open-map-btn {
  border: 1px solid var(--stroke);
  background: #fff;
  color: var(--ink);
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 12px;
}

.open-map-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.empty-state {
  margin-top: 32px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px dashed var(--stroke);
  padding: 24px;
  border-radius: 16px;
  text-align: center;
  color: var(--muted);
}

.hidden {
  display: none;
}

.itinerary-overlay {
  position: fixed;
  inset: 0;
  z-index: 45;
}

.itinerary-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 19, 32, 0.35);
  backdrop-filter: blur(3px);
}

.itinerary-panel {
  position: absolute;
  top: 12px;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: min(1080px, calc(100vw - 24px));
  max-height: none;
  overflow: auto;
  border-radius: 16px;
  border: 1px solid #dbe3ef;
  background: linear-gradient(180deg, #ffffff 0%, #fcfdff 100%);
  box-shadow: 0 24px 52px rgba(18, 22, 36, 0.22);
  padding: 16px;
}

.itinerary-head {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding-right: 44px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e8edf5;
}

.itinerary-head.has-inline-name {
  display: grid;
  grid-template-columns: auto minmax(260px, 1fr);
  align-items: center;
  gap: 8px 12px;
}

#itinerary-close-btn {
  position: absolute;
  top: 0;
  right: 0;
}

.itinerary-map-panel {
  margin-top: 8px;
  border: 1px solid #dbe3ef;
  border-radius: 14px;
  background: #fff;
  padding: 10px;
}

.itinerary-map-panel h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.itinerary-map-frame {
  width: 100%;
  height: 360px;
  border: 1px solid #d6deea;
  border-radius: 12px;
  overflow: hidden;
  background: #f7f7f7;
}

.itinerary-head h2 {
  margin: 0;
  font-size: 24px;
}

.itinerary-subtitle {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.itinerary-name-row {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 140px minmax(180px, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.itinerary-head.has-inline-name .itinerary-name-row {
  grid-column: 2 / 3;
  margin-top: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.itinerary-head.has-inline-name .itinerary-name-save-btn {
  display: none;
}

.itinerary-head.has-inline-name .itinerary-name-label {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  margin-right: 4px;
  font-weight: 700;
  color: #24314f;
}

.itinerary-name-label {
  font-size: 12px;
  color: #5a6578;
  font-weight: 600;
}

.itinerary-name-input {
  min-height: 40px;
  width: 100%;
  border: 1px solid var(--stroke);
  border-radius: 10px;
  padding: 0 12px;
  font-size: 14px;
  background: #fff;
  color: var(--ink);
}

.itinerary-name-input:focus {
  outline: none;
  border-color: #e28b5d;
  box-shadow: 0 0 0 3px rgba(226, 139, 93, 0.15);
}

.itinerary-name-save-btn {
  min-height: 40px;
  padding: 0 14px;
}

.itinerary-actions {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.itinerary-day-tabs {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.itinerary-day-tab,
.itinerary-day-add {
  border: 1px solid #d7dfeb;
  background: #fff;
  color: #2d3648;
  border-radius: 999px;
  min-height: 32px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.itinerary-day-tab-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.itinerary-day-tab.is-active {
  border-color: #d78e63;
  background: linear-gradient(180deg, #fff7f1 0%, #ffefe4 100%);
  color: #7a3e1b;
  box-shadow: 0 4px 10px rgba(202, 114, 50, 0.16);
}

.itinerary-day-remove {
  border: 1px solid #d7dfeb;
  background: #fff;
  color: #6f7380;
  border-radius: 999px;
  width: 24px;
  height: 24px;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  cursor: pointer;
}

.itinerary-day-tab-wrap.is-active .itinerary-day-remove {
  border-color: #efb98f;
  color: #8a471e;
  background: #fff6ef;
}

.itinerary-day-add {
  width: 32px;
  min-width: 32px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
}

/* Make sort actions visually distinct from back/share actions */
.itinerary-actions #itinerary-sort-btn,
.itinerary-actions #itinerary-sort-best-btn {
  background: linear-gradient(180deg, #fff6ef 0%, #ffe8d8 100%);
  border-color: #efb98f;
  color: #7a3e1b;
  font-weight: 700;
}

.itinerary-actions #itinerary-sort-btn:hover,
.itinerary-actions #itinerary-sort-best-btn:hover {
  box-shadow: 0 6px 14px rgba(202, 114, 50, 0.18);
}

.itinerary-sort-help {
  margin: 8px 0 0;
  font-size: 12px;
  color: #5c5c5c;
  line-height: 1.45;
}

.itinerary-list {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

.itinerary-time-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 4px;
}

.itinerary-time-note {
  margin: 0 0 10px;
  font-size: 12px;
  color: #5a667a;
  line-height: 1.45;
  padding: 8px 10px;
  border: 1px dashed #d7e0ec;
  border-radius: 10px;
  background: #fbfdff;
}

.itinerary-time-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid #d8e0eb;
  background: #f8fbff;
  color: #33455f;
  font-size: 12px;
  font-weight: 700;
}

.itinerary-time-pill.is-total {
  border-color: #efb98f;
  background: #fff6ef;
  color: #7a3e1b;
}

.itinerary-builder-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.itinerary-builder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.itinerary-builder-btn {
  border: 1px solid var(--stroke);
  background: #fff;
  color: var(--ink);
  border-radius: 12px;
  padding: 12px;
  text-align: left;
  cursor: pointer;
  display: grid;
  gap: 6px;
}

.itinerary-builder-btn:hover {
  border-color: var(--accent);
}

.itinerary-builder-btn-title {
  font-size: 15px;
  font-weight: 700;
}

.itinerary-builder-btn-meta {
  font-size: 12px;
  color: var(--muted);
}

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

.itinerary-builder-region-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.itinerary-builder-chip {
  border: 1px solid var(--stroke);
  border-radius: 999px;
  background: #fff;
  color: #2d3648;
  min-height: 32px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.itinerary-builder-chip.is-active {
  background: hsl(var(--region-hue, 18) 90% 96%);
  border-color: hsl(var(--region-hue, 18) 56% 74%);
  color: hsl(var(--region-hue, 18) 48% 32%);
}

.itinerary-builder-search {
  margin-bottom: 10px;
}

.itinerary-builder-search input {
  width: 100%;
}

.itinerary-builder-groups {
  display: grid;
  gap: 10px;
}

.itinerary-builder-region-group {
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.65);
  border-left: 4px solid hsl(var(--region-hue, 18) 62% 58%);
}

.itinerary-builder-region-title {
  margin: 0 0 8px;
  font-size: 13px;
  color: hsl(var(--region-hue, 18) 44% 30%);
}

.itinerary-builder-region-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.itinerary-builder-region-head .itinerary-builder-region-title {
  margin: 0;
}

.itinerary-builder-region-select-btn {
  border: 1px solid #d8cabc;
  background: #fff;
  border-radius: 999px;
  min-height: 28px;
  padding: 0 10px;
  font-size: 12px;
  color: #5b3e2b;
  cursor: pointer;
  white-space: nowrap;
}

.itinerary-builder-region-select-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.itinerary-builder-spot-row {
  border: 1px solid var(--stroke);
  border-radius: 10px;
  padding: 10px;
  background: #fff;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
}

.itinerary-builder-spot-check-wrap {
  width: 40px;
  min-height: 40px;
  border: 1px solid #e2d7ca;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  cursor: pointer;
  margin-top: 2px;
}

.itinerary-builder-spot-row input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: var(--accent);
  cursor: pointer;
}

.itinerary-builder-spot-main {
  display: grid;
  gap: 4px;
}

.itinerary-builder-spot-head {
  display: grid;
  grid-template-columns: 68px 1fr;
  gap: 10px;
  align-items: start;
}

.itinerary-builder-spot-headtext {
  display: grid;
  gap: 2px;
}

.itinerary-builder-spot-thumb {
  width: 68px;
  height: 52px;
  border: 1px solid var(--stroke);
  border-radius: 8px;
  object-fit: cover;
  display: block;
}

.itinerary-builder-spot-thumb.no-image {
  background: #e7edf6;
  color: #6d788a;
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.itinerary-builder-spot-title {
  font-size: 14px;
  font-weight: 700;
}

.itinerary-builder-spot-meta {
  font-size: 12px;
  color: var(--muted);
}

.itinerary-builder-spot-rating {
  font-size: 12px;
  color: #324161;
}

.itinerary-builder-spot-desc {
  font-size: 12px;
  color: #445066;
  line-height: 1.4;
}

.itinerary-builder-spot-actions {
  margin-top: 2px;
}

.itinerary-builder-preview-btn {
  border: 1px solid #d8cabc;
  background: #fff;
  border-radius: 999px;
  min-height: 28px;
  padding: 0 10px;
  font-size: 12px;
  color: #5b3e2b;
  cursor: pointer;
}

.itinerary-builder-preview-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.itinerary-location-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
}

.itinerary-location-overlay.hidden {
  display: none;
}

.itinerary-location-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(12, 18, 30, 0.38);
  backdrop-filter: blur(2px);
}

.itinerary-location-dialog {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(920px, calc(100vw - 32px));
  height: min(78vh, 760px);
  border-radius: 14px;
  border: 1px solid var(--stroke);
  background: #fff;
  box-shadow: 0 24px 52px rgba(18, 22, 36, 0.24);
  padding: 12px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 10px;
}

.itinerary-location-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.itinerary-location-head h3 {
  margin: 0;
  font-size: 19px;
}

.itinerary-location-frame {
  width: 100%;
  height: 100%;
  border: 1px solid var(--stroke);
  border-radius: 10px;
  background: #f7f7f7;
}

.itinerary-location-actions {
  display: flex;
  justify-content: flex-end;
}

.itinerary-builder-footer {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
}

.itinerary-item {
  border: 1px solid #d8e0eb;
  border-radius: 16px;
  background: #fff;
  padding: 14px;
  margin-bottom: 10px;
  display: grid;
  grid-template-columns: minmax(0, 2.2fr) minmax(220px, 1fr);
  gap: 8px;
  box-shadow: 0 6px 18px rgba(16, 26, 44, 0.08);
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease, opacity 120ms ease;
  border-left: 4px solid #dce6f4;
}

.itinerary-item:hover {
  border-color: #bfcddd;
  box-shadow: 0 12px 24px rgba(16, 26, 44, 0.12);
  transform: translateY(-1px);
  border-left-color: #d78e63;
}

.itinerary-item.is-dragging {
  opacity: 0.45;
}

.itinerary-item.is-drop-target {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(210, 90, 60, 0.18);
}

.itinerary-item-main {
  display: grid;
  gap: 6px;
}

.itinerary-item-tools {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.itinerary-move-btn {
  border: 1px solid #d5deea;
  background: #fff;
  color: #2d3648;
  border-radius: 999px;
  min-height: 28px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.itinerary-move-btn:hover:not(:disabled) {
  border-color: #d78e63;
  color: #7a3e1b;
  background: #fff8f2;
}

.itinerary-move-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.itinerary-drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  min-height: 28px;
  border: 1px dashed var(--stroke);
  border-radius: 999px;
  color: #5b677f;
  font-size: 14px;
}

.itinerary-item-rank {
  font-size: 12px;
  font-weight: 700;
  color: #374054;
}

.itinerary-item-photo {
  width: min(260px, 100%);
  height: 148px;
  border-radius: 10px;
  border: 1px solid var(--stroke);
  object-fit: contain;
  background: #f6f8fb;
  cursor: zoom-in;
}

.itinerary-item-title {
  margin: 0;
  font-size: 19px;
  line-height: 1.35;
  letter-spacing: -0.01em;
}

.itinerary-item-meta {
  font-size: 12px;
  color: #4e5d74;
}

.itinerary-stay-minutes-input {
  width: 78px;
  min-height: 28px;
  margin-left: 6px;
  border: 1px solid #d4dbe6;
  border-radius: 8px;
  padding: 0 8px;
  font-size: 12px;
}

.itinerary-item-cat {
  font-size: 13px;
  font-weight: 600;
}

.itinerary-item-distance {
  font-size: 13px;
  font-weight: 700;
  color: #2f3a55;
}

.itinerary-gap-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px 6px 2px;
}

.itinerary-gap-connector {
  position: relative;
  flex: 0 0 16px;
  width: 16px;
  height: 34px;
}

.itinerary-gap-connector::before {
  content: "";
  position: absolute;
  left: 7px;
  top: -12px;
  width: 2px;
  height: 58px;
  background: #6e6358;
  opacity: 0.9;
}

.itinerary-gap-distance {
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px dashed #d4c4af;
  background: #fff8f1;
  color: #5a4c3f;
  font-size: 12px;
  font-weight: 700;
  width: fit-content;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.itinerary-gap-main {
  white-space: nowrap;
}

.itinerary-gap-times {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}

.itinerary-gap-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid #e2d3bf;
  background: #fff;
  border-radius: 999px;
  padding: 2px 8px;
  font-weight: 600;
  color: #4a3c2f;
}

.itinerary-item-desc {
  font-size: 12px;
  color: #374054;
  line-height: 1.45;
}

.itinerary-item-note {
  margin-left: 8px;
  border-left: 1px dashed #d8e1ee;
  background: linear-gradient(180deg, #f9fbff 0%, #f6f9ff 100%);
  border-radius: 12px;
  padding-left: 12px;
  padding-top: 8px;
  padding-bottom: 8px;
}

.itinerary-item-note h4 {
  margin: 0 0 6px;
  font-size: 12px;
  color: #5b677f;
}

.itinerary-item-note p {
  margin: 0;
  font-size: 13px;
  color: #2d3648;
  line-height: 1.5;
  white-space: pre-wrap;
}

.itinerary-note-input {
  width: 100%;
  min-height: 78px;
  border: 1px solid #d5deea;
  border-radius: 10px;
  background: #fff;
  padding: 9px 10px;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.45;
  color: #2d3648;
  resize: vertical;
}

.itinerary-note-input:focus,
.itinerary-stay-minutes-input:focus,
.itinerary-name-input:focus {
  outline: none;
  border-color: #d78e63;
  box-shadow: 0 0 0 3px rgba(215, 142, 99, 0.16);
}

.itinerary-empty {
  border: 1px dashed #d5deea;
  border-radius: 12px;
  padding: 16px;
  color: #546177;
  font-size: 14px;
  background: #fbfdff;
}

.itinerary-empty-with-add {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.itinerary-inline-add-btn {
  border: 1px solid #d8cabc;
  background: #fff;
  color: #5b3e2b;
  border-radius: 999px;
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.itinerary-inline-add-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.itinerary-end-add-wrap {
  display: flex;
  justify-content: center;
  margin-top: 4px;
}

.itinerary-end-add-btn {
  width: 36px;
  height: 36px;
  font-size: 22px;
}

body.itinerary-share-only .page-header,
body.itinerary-share-only .controls,
body.itinerary-share-only .favorites-layout,
body.itinerary-share-only #favorites-empty {
  display: none !important;
}

body.itinerary-share-only .page {
  width: min(980px, calc(100vw - 24px));
  max-width: 980px;
  margin: 0 auto;
  padding: 0;
}

body.itinerary-share-only .itinerary-backdrop {
  display: none;
}

body.itinerary-share-only #itinerary-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

body.itinerary-share-only .itinerary-overlay {
  position: static;
  inset: auto;
  z-index: auto;
}

body.itinerary-share-only .itinerary-panel {
  position: static;
  top: auto;
  left: auto;
  transform: none;
  width: 100%;
  max-height: none;
  margin: 20px auto;
  box-shadow: 0 10px 28px rgba(18, 22, 36, 0.1);
}

@media (max-width: 980px) {
  .favorites-page .page {
    width: auto;
    max-width: 1100px;
    margin: 0 auto;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-actions {
    width: 100%;
  }

  .link-btn,
  .ghost-btn {
    flex: 1;
  }

  .controls {
    grid-template-columns: 1fr;
  }

  .favorites-layout {
    grid-template-columns: 1fr;
    margin-right: 0;
  }

  .favorites-center {
    padding: 8px;
    border-radius: 12px;
  }

  .section-title {
    margin: 0 0 6px;
    font-size: 13px;
  }

  .country-section-title {
    margin: 0 0 4px;
    font-size: 15px;
  }

  .region-group-title {
    margin: 0 0 4px;
    font-size: 11px;
  }

  .country-section + .country-section {
    margin-top: 8px;
  }

  .region-spot-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .spot-tile {
    padding: 5px;
    min-height: 0;
    border-radius: 8px;
    gap: 2px;
  }

  .spot-tile-photo {
    height: auto;
    aspect-ratio: 1 / 1;
    border-radius: 6px;
  }

  .spot-tile-photo-placeholder {
    height: auto;
    aspect-ratio: 1 / 1;
    border-radius: 6px;
    font-size: 11px;
  }

  .spot-tile-check-wrap {
    top: 5px;
    left: 5px;
    width: 18px;
    height: 18px;
  }

  .spot-tile-check {
    width: 11px;
    height: 11px;
  }

  .spot-tile-drag-indicator {
    top: 5px;
    right: 5px;
    width: 16px;
    height: 16px;
    font-size: 9px;
    line-height: 14px;
  }

  .spot-tile-rank {
    font-size: 10px;
  }

  .spot-tile-title {
    font-size: 11px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .spot-tile-meta,
  .spot-tile-rating,
  .spot-tile-category,
  .spot-tile-desc,
  .spot-tile-note {
    display: none;
  }

  .spot-tile.is-no-photo {
    min-height: 108px;
    gap: 3px;
  }

  .spot-tile.is-no-photo .spot-tile-title {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }

  .spot-tile.is-no-photo .spot-tile-meta,
  .spot-tile.is-no-photo .spot-tile-rating,
  .spot-tile.is-no-photo .spot-tile-category,
  .spot-tile.is-no-photo .spot-tile-desc {
    display: block;
    font-size: 10px;
    line-height: 1.35;
  }

  .spot-tile.is-no-photo .spot-tile-note {
    display: block;
    font-size: 10px;
    line-height: 1.35;
    margin-top: 1px;
    padding-top: 4px;
  }

  .favorites-detail {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100dvh;
    z-index: 120;
    border-left: none;
    border-radius: 0;
    min-height: 0;
    max-height: none;
    padding: 14px 12px 18px;
    background: #fff;
    box-shadow: none;
  }

  body.detail-open {
    overflow: hidden;
  }

  .detail-heading {
    grid-template-columns: 1fr;
    gap: 8px;
    padding-top: 40px;
    position: relative;
  }

  .detail-close-btn.is-mobile-back {
    position: absolute;
    top: 0;
    left: 0;
    width: auto;
    min-width: 0;
    height: 30px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
  }

  .detail-map-frame {
    height: 340px;
  }

  .itinerary-panel {
    top: 12px;
    bottom: 12px;
    left: 8px;
    transform: none;
    width: calc(100vw - 16px);
    max-height: none;
    padding: 12px;
  }

  .itinerary-map-frame {
    height: 260px;
  }

  .itinerary-name-row {
    grid-template-columns: 1fr;
  }

  .itinerary-item {
    grid-template-columns: 1fr;
  }

  .itinerary-item-note {
    margin-left: 0;
    border-left: none;
    border-top: 1px dashed #ddd3c4;
    padding-left: 0;
    padding-top: 8px;
  }

  .itinerary-item-photo {
    height: 150px;
  }
}

/* Blur-up image loading */
img.blur-up-img {
  filter: blur(16px);
  transform: scale(1.02);
  opacity: 0.92;
  transition: filter .28s ease, transform .28s ease, opacity .28s ease;
  will-change: filter, transform, opacity;
}

img.blur-up-img.is-loaded {
  filter: blur(0);
  transform: scale(1);
  opacity: 1;
}

.photo-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
}

.photo-modal.hidden {
  display: none;
}

.photo-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
}

#photo-modal-img {
  position: relative;
  z-index: 1;
  max-width: min(92vw, 1400px);
  max-height: 88vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.photo-modal-nav {
  position: absolute;
  z-index: 2;
  top: 50%;
  transform: translateY(-50%);
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.42);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.photo-modal-nav-prev {
  left: max(12px, 2vw);
}

.photo-modal-nav-next {
  right: max(12px, 2vw);
}

/* Force itinerary close button visibility */
#itinerary-close-btn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  position: absolute !important;
  top: 6px !important;
  right: 8px !important;
  width: 32px !important;
  height: 32px !important;
  z-index: 20 !important;
  color: #1f2a3d !important;
  background: #fff !important;
  border: 1px solid #cfd7e5 !important;
  border-radius: 999px !important;
  font-size: 20px !important;
  line-height: 1 !important;
}
