:root {
  --motion-ease-out: cubic-bezier(.2, .8, .2, 1);
  --motion-ease-spring: cubic-bezier(.16, 1, .3, 1);
}

/* Scroll feedback */
.scroll-progress {
  position: fixed;
  z-index: 1200;
  top: 0;
  right: 0;
  left: 0;
  height: 2px;
  background: var(--apple-blue);
  pointer-events: none;
  transform: scaleX(var(--scroll-progress, 0));
  transform-origin: left center;
  will-change: transform;
}

.topbar {
  transition: background-color 280ms ease, border-color 280ms ease, backdrop-filter 280ms ease;
}

.topbar.is-scrolled {
  background: rgba(255, 255, 255, .88);
  border-bottom-color: rgba(0, 0, 0, .12);
  backdrop-filter: blur(26px) saturate(180%);
}

/* Cinematic hero layer */
.hero-motion-bg {
  position: absolute;
  z-index: 0;
  inset: -5%;
  background: #07131d var(--hero-image) center 42% / cover no-repeat;
  pointer-events: none;
  transform: translate3d(0, var(--hero-pan-y, 0px), 0) scale(1.04);
  transform-origin: center;
  will-change: transform;
  animation: hero-camera 18s ease-in-out infinite alternate;
}

.hero::before,
.hero::after {
  z-index: 1;
}

.hero-copy {
  position: relative;
  z-index: 3;
}

.hero-stats {
  z-index: 3;
}

.hero-copy > * {
  animation: hero-detail-in 820ms var(--motion-ease-out) both;
}

.hero-copy > :nth-child(1) { animation-delay: 100ms; }
.hero-copy > :nth-child(2) { animation-delay: 180ms; }
.hero-copy > :nth-child(3) { animation-delay: 280ms; }
.hero-copy > :nth-child(4) { animation-delay: 380ms; }

@keyframes hero-camera {
  from { transform: translate3d(0, var(--hero-pan-y, 0px), 0) scale(1.04); }
  to { transform: translate3d(-1.2%, calc(var(--hero-pan-y, 0px) - 10px), 0) scale(1.1); }
}

@keyframes hero-detail-in {
  from { opacity: 0; transform: translateY(22px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Scroll reveals and staggered content */
.motion-reveal {
  transition-delay: var(--motion-delay, 0ms);
}

.motion-item {
  opacity: 0;
  transform: translateY(18px) scale(.975);
  transition:
    opacity 620ms var(--motion-ease-out) var(--item-delay, 0ms),
    transform 620ms var(--motion-ease-spring) var(--item-delay, 0ms);
}

.motion-item.is-motion-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* Tactile UI feedback */
button,
.hero-primary,
.nav-primary {
  transform-origin: center;
}

.is-motion-pressed {
  transform: scale(.965) !important;
  transition-duration: 90ms !important;
}

.spot-thumb {
  transition: transform 720ms var(--motion-ease-spring), filter 420ms ease;
  transform-origin: center;
  will-change: transform;
}

.spot-card:hover .spot-thumb {
  filter: saturate(1.08);
  transform: scale(1.07);
}

/* Scenic-spot imagery: never reuse the hero photograph as if it represented
   every destination. Verified images use .has-photo; missing assets receive a
   clearly labelled, stable category visual. */
.spot-thumb.has-photo {
  background-color: #d9e5ef;
  background-repeat: no-repeat;
  background-size: cover;
}

.spot-thumb.is-placeholder {
  --spot-a: #1769aa;
  --spot-b: #6fb4df;
  --spot-c: #d9f0ff;
  isolation: isolate;
  display: grid;
  min-height: 112px;
  place-content: center;
  justify-items: center;
  gap: 2px;
  overflow: hidden;
  color: #fff;
  background:
    radial-gradient(circle at 78% 20%, rgba(255, 255, 255, .46), transparent 22%),
    linear-gradient(145deg, var(--spot-a), var(--spot-b) 58%, var(--spot-c));
  text-align: center;
}

.spot-thumb.is-placeholder::before {
  content: "";
  position: absolute;
  z-index: -1;
  right: -24%;
  bottom: -34%;
  width: 92%;
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, .34);
  border-radius: 46% 54% 58% 42%;
  background: rgba(255, 255, 255, .12);
  transform: rotate(-18deg);
}

.spot-thumb.is-placeholder::after {
  z-index: -1;
  background: linear-gradient(180deg, rgba(255, 255, 255, .1), rgba(0, 0, 0, .12));
}

.spot-visual-mark {
  font-size: 1.75rem;
  font-style: normal;
  font-weight: 720;
  letter-spacing: -.06em;
  line-height: 1;
}

.spot-thumb.is-placeholder small,
.spot-thumb.is-placeholder em {
  color: rgba(255, 255, 255, .92);
  font-size: .62rem;
  font-style: normal;
  font-weight: 600;
  letter-spacing: .04em;
  line-height: 1.25;
}

.spot-thumb.is-placeholder em {
  margin-top: 4px;
  padding: 2px 6px;
  border: 1px solid rgba(255, 255, 255, .24);
  border-radius: 999px;
  color: rgba(255, 255, 255, .72);
  background: rgba(0, 0, 0, .08);
  font-size: .52rem;
}

.spot-thumb.spot-visual-water { --spot-a: #075985; --spot-b: #0ea5b7; --spot-c: #a5f3fc; }
.spot-thumb.spot-visual-grassland { --spot-a: #166534; --spot-b: #4d9b55; --spot-c: #c4e6a3; }
.spot-thumb.spot-visual-snow { --spot-a: #334a69; --spot-b: #7698bb; --spot-c: #e6f4ff; }
.spot-thumb.spot-visual-desert { --spot-a: #8a3f16; --spot-b: #d38638; --spot-c: #f5d49a; }
.spot-thumb.spot-visual-forest { --spot-a: #174b3a; --spot-b: #3d8265; --spot-c: #aed6bc; }
.spot-thumb.spot-visual-road { --spot-a: #28394f; --spot-b: #5b7795; --spot-c: #c7d7e6; }
.spot-thumb.spot-visual-border { --spot-a: #4c3b74; --spot-b: #7864a8; --spot-c: #d8cdf2; }
.spot-thumb.spot-visual-culture { --spot-a: #7c2d4a; --spot-b: #b65a73; --spot-c: #efc4c7; }
.spot-thumb.spot-visual-geology { --spot-a: #65392c; --spot-b: #a2674e; --spot-c: #dcb49e; }
.spot-thumb.spot-visual-nature { --spot-a: #155e75; --spot-b: #409aaa; --spot-c: #bae6df; }

.day-card {
  transition:
    transform 300ms var(--motion-ease-spring),
    box-shadow 300ms ease,
    background 300ms ease;
}

.day-card.active::after {
  position: absolute;
  right: 16px;
  bottom: 12px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  content: "";
  background: var(--apple-blue);
  animation: active-day-pulse 1.8s ease-in-out infinite;
}

@keyframes active-day-pulse {
  0%, 100% { opacity: .5; transform: scale(.8); }
  50% { opacity: 1; transform: scale(1.35); }
}

.studio-sync i {
  animation: sync-pulse 2.2s ease-in-out infinite;
}

@keyframes sync-pulse {
  0%, 100% { opacity: .55; transform: scale(.82); }
  50% { opacity: 1; transform: scale(1.15); }
}

/* Document movement */
.route-cover {
  --cover-pan-x: 0px;
  --cover-pan-y: 0px;
  background-position:
    calc(50% + var(--cover-pan-x))
    calc(45% + var(--cover-pan-y));
  transition: background-position 220ms ease-out;
}

.itinerary-document.preview-updated {
  animation: preview-refresh 620ms var(--motion-ease-spring);
  transform-origin: top center;
}

@keyframes preview-refresh {
  0% { opacity: .55; transform: translateY(10px) scale(.992); }
  60% { opacity: 1; transform: translateY(-2px) scale(1.002); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.doc-dot {
  animation: doc-live 2s ease-in-out infinite;
}

@keyframes doc-live {
  0%, 100% { opacity: .55; transform: scale(.82); }
  50% { opacity: 1; transform: scale(1.15); }
}

@media (max-width: 900px) {
  .hero-motion-bg {
    inset: -3%;
    animation-duration: 22s;
  }

  .motion-item {
    transform: translateY(12px) scale(.985);
  }

  .hero-stats {
    right: auto;
    left: 16px;
    width: calc(100% - 32px);
    min-width: 0;
  }

  .hero-stats > div {
    min-width: 0;
  }
}

@media (max-width: 560px) {
  .hero h1 {
    font-size: 2.85rem;
    letter-spacing: -0.015em;
    line-height: 1.04;
  }
}

@media (hover: none) {
  .spot-card:hover .spot-thumb {
    filter: none;
    transform: none;
  }
}

/* Keep the studio chrome in normal document flow. A sticky toolbar retained its
   original layout slot while moving over the first card, which made the card
   look as if it were covering the toolbar. */
@media (min-width: 901px) {
  .studio-shell > .studio-toolbar {
    position: relative;
    z-index: 40;
    top: auto;
  }

  .studio-shell > .planner-grid {
    position: relative;
    z-index: 1;
  }
}

/* Geometric centring plus a small optical correction for Chinese full-width
   punctuation, whose visual weight otherwise makes the titles look left-shifted. */
.hero-copy,
.studio-intro {
  justify-self: center;
  width: min(1040px, calc(100% - 40px));
  margin-right: auto;
  margin-left: auto;
}

.hero h1,
.studio-intro h2 {
  position: relative;
  left: 0.26em;
  box-sizing: border-box;
  width: 100%;
  text-align: center;
  text-indent: 0.07em;
}

.hero-copy > p,
.studio-intro > p,
.studio-intro > span {
  justify-self: center;
  text-align: center;
}

/* Apple-style version history */
.status-live[data-save-state="saving"] {
  color: #8a5a00;
  background: #fff4d6;
}

.status-live[data-save-state="restored"] {
  color: #0066cc;
  background: #e8f3ff;
}

.status-live[data-save-state="local"] {
  color: #6e6e73;
  background: #f0f0f2;
}

.save-plan-button {
  min-width: 88px;
  box-shadow: 0 7px 18px rgba(0, 113, 227, .18);
}

.save-plan-button[data-save-feedback="success"] {
  background: #248a3d;
  box-shadow: 0 7px 18px rgba(36, 138, 61, .2);
}

.save-plan-button[data-save-feedback="error"] {
  background: #c9342b;
  box-shadow: 0 7px 18px rgba(201, 52, 43, .18);
}

.history-status {
  position: relative;
  padding-left: 36px;
  color: #1d1d1f;
  background: #f2f2f4;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .055);
  transition: color 180ms ease, background 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}

.history-status::before {
  position: absolute;
  left: 15px;
  width: 13px;
  height: 13px;
  border: 1.6px solid currentColor;
  border-radius: 50%;
  content: "";
  opacity: .72;
}

.history-status::after {
  position: absolute;
  left: 21px;
  width: 4px;
  height: 1.5px;
  border-radius: 2px;
  content: "";
  background: currentColor;
  opacity: .72;
  transform: translateY(-1px) rotate(-90deg);
  transform-origin: left center;
}

.history-status[aria-expanded="true"] {
  color: #fff;
  background: var(--apple-blue);
  box-shadow: 0 8px 22px rgba(0, 113, 227, .22);
}

.history-panel {
  position: fixed;
  z-index: 180;
  top: auto;
  right: max(24px, calc((100vw - 1480px) / 2 + 24px));
  bottom: 24px;
  display: flex;
  width: min(456px, calc(100vw - 40px));
  max-height: min(600px, calc(100vh - 96px));
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, .09);
  border-radius: 26px;
  padding: 0;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 30px 90px rgba(0, 0, 0, .2), 0 2px 10px rgba(0, 0, 0, .08);
  backdrop-filter: saturate(180%) blur(30px);
  -webkit-backdrop-filter: saturate(180%) blur(30px);
  transform-origin: right bottom;
  animation: history-popover-in 240ms var(--motion-ease-spring);
}

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

.history-panel:focus {
  outline: none;
}

@keyframes history-popover-in {
  from { opacity: 0; transform: translateY(10px) scale(.965); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.history-panel-head {
  display: flex;
  flex: 0 0 auto;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 22px 17px;
  border-bottom: 1px solid rgba(0, 0, 0, .065);
}

.history-heading-copy {
  display: grid;
  min-width: 0;
  gap: 5px;
  text-align: left;
}

.history-kicker {
  color: var(--apple-blue);
  font-size: .61rem;
  font-weight: 750;
  letter-spacing: .14em;
  line-height: 1;
}

.history-heading-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.history-heading-copy strong {
  color: #1d1d1f;
  font-size: 1.18rem;
  font-weight: 680;
  letter-spacing: -.035em;
  line-height: 1.15;
}

.history-heading-line > span {
  padding: 3px 8px;
  border-radius: 999px;
  color: #6e6e73;
  background: #f0f0f2;
  font-size: .62rem;
  font-weight: 650;
}

.history-heading-copy small {
  color: #86868b;
  font-size: .69rem;
  line-height: 1.4;
}

.history-panel-close {
  display: grid;
  width: 30px;
  min-width: 30px;
  height: 30px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  padding: 0 0 2px;
  color: #6e6e73;
  background: #ededf0;
  font-size: 1.1rem;
  line-height: 1;
  transition: color 160ms ease, background 160ms ease, transform 160ms ease;
}

.history-panel-close:hover {
  color: #1d1d1f;
  background: #dedee2;
  transform: scale(1.04);
}

.history-overview {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 12px 14px 5px;
  border: 1px solid rgba(0, 0, 0, .055);
  border-radius: 16px;
  background: #f5f5f7;
}

.history-overview > span {
  display: grid;
  min-width: 0;
  gap: 2px;
  justify-items: center;
  padding: 10px 8px;
}

.history-overview > span + span {
  border-left: 1px solid rgba(0, 0, 0, .07);
}

.history-overview small {
  color: #86868b;
  font-size: .6rem;
}

.history-overview strong {
  color: #1d1d1f;
  font-size: .92rem;
  font-variant-numeric: tabular-nums;
}

.history-list {
  display: grid;
  min-height: 96px;
  flex: 1 1 auto;
  grid-auto-rows: max-content;
  align-content: start;
  gap: 8px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px 14px 14px;
  scrollbar-color: #c7c7cc transparent;
  scrollbar-width: thin;
}

.history-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 17px;
  background: #f5f5f7;
  transition: border-color 180ms ease, background 180ms ease, transform 180ms ease, opacity 180ms ease;
}

.history-row:hover {
  border-color: rgba(0, 0, 0, .08);
  background: #fff;
  transform: translateY(-1px);
}

.history-row.is-current {
  border-color: rgba(0, 113, 227, .2);
  background: #edf6ff;
}

.history-row.is-future {
  opacity: .64;
}

.history-row.is-future:hover {
  opacity: .9;
}

.history-item {
  display: grid;
  width: 100%;
  min-width: 0;
  gap: 4px;
  border: 0;
  border-radius: 0;
  padding: 13px 13px 12px;
  color: #1d1d1f;
  background: transparent;
  text-align: left;
}

.history-item.active {
  color: #1d1d1f;
  background: transparent;
}

.history-item-top {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.history-version {
  display: inline-flex;
  min-height: 20px;
  align-items: center;
  border-radius: 999px;
  padding: 0 7px;
  color: #6e6e73;
  background: #e7e7ea;
  font-size: .58rem;
  font-weight: 680;
  line-height: 1;
}

.history-row.is-current .history-version {
  color: #0066cc;
  background: #dceeff;
}

.history-item time {
  overflow: hidden;
  color: #86868b;
  font-size: .61rem;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-action {
  overflow: hidden;
  margin-top: 2px;
  color: #1d1d1f;
  font-size: .85rem;
  font-weight: 680;
  letter-spacing: -.015em;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-route-name,
.history-route {
  overflow: hidden;
  color: #6e6e73;
  font-size: .68rem;
  font-weight: 500;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-route {
  color: #86868b;
  font-size: .62rem;
}

.history-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 4px;
}

.history-metrics > span {
  border-radius: 999px;
  padding: 3px 7px;
  color: #6e6e73;
  background: rgba(255, 255, 255, .8);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .045);
  font-size: .57rem;
  line-height: 1.2;
}

.history-delete,
.history-current-mark {
  margin-right: 10px;
}

.history-delete {
  min-width: 40px;
  min-height: 32px;
  border: 0;
  border-radius: 999px;
  padding: 0 9px;
  color: #ff3b30;
  background: transparent;
  font-size: .61rem;
  font-weight: 650;
  opacity: 0;
  transform: translateX(5px);
  transition: opacity 160ms ease, transform 160ms ease, background 160ms ease;
}

.history-row:hover .history-delete,
.history-delete:focus-visible {
  opacity: 1;
  transform: translateX(0);
}

.history-delete:hover {
  background: #ffebe9;
}

.history-current-mark {
  display: grid;
  width: 27px;
  height: 27px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--apple-blue);
  box-shadow: 0 4px 12px rgba(0, 113, 227, .2);
  font-size: .7rem;
  font-weight: 750;
}

.history-undo-banner {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 14px 10px;
  border-radius: 13px;
  padding: 9px 11px 9px 13px;
  color: #3a3a3c;
  background: #fff3e8;
  font-size: .65rem;
}

.history-undo-banner button {
  border: 0;
  padding: 3px 5px;
  color: var(--apple-blue);
  background: transparent;
  font-size: .65rem;
  font-weight: 700;
}

.history-panel-foot {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 17px 13px;
  border-top: 1px solid rgba(0, 0, 0, .06);
  color: #86868b;
  font-size: .59rem;
}

.history-clear-all {
  border: 0;
  border-radius: 999px;
  padding: 5px 9px;
  color: #ff3b30;
  background: #ffebe9;
  font-size: .59rem;
  font-weight: 680;
}

.history-clear-all:hover:not(:disabled) {
  background: #ffdcd8;
}

.history-clear-all:disabled {
  color: #86868b;
  background: #f0f0f2;
  cursor: default;
}

.history-panel-foot i {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 3px;
  border-radius: 50%;
  background: #30d158;
  box-shadow: 0 0 0 3px rgba(48, 209, 88, .1);
}

.history-empty {
  margin: 14px;
  border-radius: 16px;
  padding: 28px 18px;
  color: #86868b;
  background: #f5f5f7;
  text-align: center;
}

@media (hover: none) {
  .history-delete {
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 900px) {
  body.history-panel-open {
    overflow: hidden;
  }

  .history-panel {
    position: fixed;
    z-index: 240;
    right: 12px;
    top: auto;
    bottom: max(12px, env(safe-area-inset-bottom));
    left: 12px;
    width: auto;
    max-height: min(72dvh, 640px);
    border-radius: 28px;
    transform-origin: center bottom;
  }

  .history-panel-head {
    padding: 20px 20px 15px;
  }

  .history-list {
    padding-right: 12px;
    padding-left: 12px;
  }

  .history-delete {
    min-width: 44px;
    min-height: 44px;
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero-motion-bg {
    animation: none;
    transform: none;
  }

  .hero-copy > *,
  .motion-item,
  .motion-item.is-motion-visible,
  .day-card.active::after,
  .studio-sync i,
  .doc-dot,
  .itinerary-document.preview-updated,
  .history-panel,
  .history-row,
  .history-status,
  .history-delete {
    animation: none;
    opacity: 1;
    transform: none;
    transition: none;
  }

  .scroll-progress {
    display: none;
  }
}
