* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: Arial, "Segoe UI", sans-serif;
  background: #cfe8f7;
  color: #142033;
}

button,
input {
  font: inherit;
}

button {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  padding: 8px 12px;
  background: #14395f;
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

button.secondary,
.chip {
  border: 1px solid rgba(20, 57, 95, 0.22);
  background: #fff;
  color: #14395f;
}

button:disabled {
  opacity: 0.55;
  cursor: wait;
}

input {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(20, 57, 95, 0.2);
  border-radius: 8px;
  padding: 9px 10px;
  background: #fff;
  color: #142033;
}

.app-shell {
  min-height: 100vh;
  padding: 14px;
  background:
    radial-gradient(circle at 18% 14%, rgba(255, 255, 255, 0.62), transparent 25%),
    linear-gradient(135deg, #f3e6c5, #bfe4f8 56%, #95d1ef);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  max-width: 1500px;
  margin: 0 auto 12px;
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 14px;
}

.brand-logo {
  display: block;
  width: clamp(72px, 8vw, 118px);
  height: clamp(72px, 8vw, 118px);
  flex: 0 0 auto;
  border-radius: 8px;
  object-fit: contain;
}

.brand-text {
  min-width: 0;
  max-width: min(68vw, 780px);
}

.eyebrow {
  margin: 0 0 2px;
  color: #0c5f69;
  font-size: clamp(0.72rem, 1vw, 0.9rem);
  font-weight: 900;
  text-transform: uppercase;
}

.topbar h1 {
  margin: 0;
  color: #0f2f4f;
  font-size: clamp(1.18rem, 2.35vw, 2.05rem);
  line-height: 1.08;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.session-label {
  max-width: 220px;
  overflow: hidden;
  color: #14395f;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-view {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 420px));
  justify-content: center;
  gap: 16px;
  padding: 9vh 0;
}

.panel {
  border: 1px solid rgba(20, 57, 95, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 12px 35px rgba(24, 46, 62, 0.14);
}

.auth-panel,
.trip-form {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.panel h2 {
  margin: 0;
  color: #14395f;
  font-size: 1.1rem;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(330px, 420px) minmax(0, 1fr);
  gap: 14px;
  max-width: 1500px;
  margin: 0 auto;
}

.planner {
  display: grid;
  align-content: start;
  gap: 12px;
}

.shared-mode .workspace {
  grid-template-columns: minmax(0, 1fr);
}

.shared-mode .planner {
  display: none;
}

.shared-mode .route-area {
  max-width: 980px;
  width: 100%;
  justify-self: center;
}

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

.panel-head {
  padding: 16px 16px 0;
}

.row-title span {
  color: #14395f;
  font-weight: 900;
}

.date-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

label {
  display: grid;
  gap: 5px;
  color: #415468;
  font-size: 0.86rem;
  font-weight: 800;
}

.destination-grid,
.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  border-radius: 8px;
  padding: 7px 10px;
  color: #14395f;
  font-weight: 800;
}

.chip.is-selected {
  background: #14395f;
  color: #fff;
}

.chip .dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--chip-color, #14395f);
}

.suggestion {
  align-items: flex-start;
  max-width: 100%;
  text-align: left;
}

.suggestion small {
  display: block;
  color: inherit;
  font-weight: 600;
  opacity: 0.8;
}

.duration-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.duration-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 76px 76px 38px;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(20, 57, 95, 0.12);
  border-radius: 8px;
  padding: 8px;
  background: rgba(246, 251, 255, 0.9);
}

.duration-row strong {
  min-width: 0;
  overflow: hidden;
  color: #14395f;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.duration-row input {
  min-height: 36px;
  padding: 6px;
}

.remove-stop {
  display: grid;
  place-items: center;
  min-width: 38px;
  padding: 0;
  background: #b4232a;
}

.status {
  min-height: 18px;
  margin: 0;
  color: #5c6f83;
  font-size: 0.9rem;
  font-weight: 700;
}

.share-box {
  display: grid;
  gap: 7px;
  border: 1px solid rgba(20, 57, 95, 0.14);
  border-radius: 8px;
  padding: 10px;
  background: #f6fbff;
}

.share-box span {
  color: #14395f;
  font-size: 0.84rem;
  font-weight: 900;
}

.share-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.trip-list-panel,
.stats-panel {
  padding: 16px;
}

.trip-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.trip-item {
  display: grid;
  gap: 3px;
  width: 100%;
  border: 1px solid rgba(20, 57, 95, 0.13);
  background: #fff;
  color: #142033;
  text-align: left;
}

.trip-item strong,
.trip-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0;
}

.stats-grid span {
  border-radius: 8px;
  padding: 10px;
  background: #f6fbff;
  color: #415468;
}

.stats-grid strong {
  display: block;
  color: #14395f;
  font-size: 1.4rem;
}

.activity-list {
  display: grid;
  gap: 7px;
  max-height: 170px;
  overflow: auto;
  color: #415468;
  font-size: 0.86rem;
}

.route-area {
  min-width: 0;
}

.map-stage {
  display: grid;
  place-items: center;
  width: 100%;
}

.map-scroller {
  width: 100%;
  display: grid;
  place-items: center;
  overflow: visible;
}

.map-wrap {
  position: relative;
  width: min(100%, calc((100vh - 92px) * 1122 / 1402), 1122px);
  aspect-ratio: 1122 / 1402;
  overflow: hidden;
  background: #d8edf8;
  box-shadow: 0 18px 50px rgba(24, 46, 62, 0.25);
}

.map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  user-select: none;
}

.trip-dates {
  position: absolute;
  left: 50%;
  top: auto;
  bottom: 4.5%;
  z-index: 3;
  width: fit-content;
  max-width: min(88%, 560px);
  border: 1px solid rgba(12, 31, 119, 0.16);
  border-radius: 999px;
  padding: 9px 18px;
  background: rgba(255, 255, 255, 0.92);
  color: #0c1f77;
  box-shadow: 0 10px 24px rgba(20, 32, 51, 0.18);
  font-size: clamp(13px, 1.15vw, 18px);
  font-weight: 900;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  transform: translateX(-50%);
  white-space: nowrap;
}

.hotspots,
.route-animation {
  position: absolute;
  inset: 0;
}

.route-animation {
  z-index: 1;
  pointer-events: none;
}

.hotspots {
  z-index: 2;
}

.route-line {
  fill: none;
  stroke: #14395f;
  stroke-width: 4;
  stroke-dasharray: 10 11;
  stroke-linecap: round;
  opacity: 0.35;
  animation: routeDash 1.4s linear infinite;
}

.origin-hotspot {
  width: clamp(42px, 4.6vw, 66px);
  height: clamp(42px, 4.6vw, 66px);
  font-size: clamp(10px, 0.85vw, 13px);
  text-transform: uppercase;
}

.origin-hotspot::before {
  content: "";
  position: absolute;
  inset: -13px;
  border: 2px dashed rgba(107, 53, 185, 0.48);
  border-radius: 50%;
  animation: originPulse 2.4s ease-in-out infinite;
}

.origin-label {
  min-width: 116px;
  transform: translate(22px, -50%);
}

.origin-label.label-left {
  transform: translate(calc(-100% - 22px), -50%);
  text-align: right;
}

.origin-label.label-right {
  transform: translate(22px, -50%);
}

.origin-label.label-up {
  transform: translate(-50%, calc(-100% - 22px));
  text-align: center;
}

.origin-label.label-down {
  transform: translate(-50%, 22px);
  text-align: center;
}

.origin-label.label-left.label-up {
  transform: translate(calc(-100% - 18px), calc(-100% - 18px));
}

.origin-label.label-left.label-down {
  transform: translate(calc(-100% - 18px), 18px);
}

.origin-label.label-right.label-up {
  transform: translate(18px, calc(-100% - 18px));
}

.origin-label.label-right.label-down {
  transform: translate(18px, 18px);
}

.marker-leader {
  stroke: rgba(20, 57, 95, 0.46);
  stroke-width: 2;
  stroke-dasharray: 4 5;
  stroke-linecap: round;
}

.hotspot {
  position: absolute;
  display: grid;
  place-items: center;
  width: clamp(28px, 3.2vw, 50px);
  height: clamp(28px, 3.2vw, 50px);
  border: 3px solid #fff;
  border-radius: 50%;
  padding: 0;
  background: var(--spot-color, #14395f);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.72), 0 8px 20px rgba(8, 22, 36, 0.25);
  color: #fff;
  transform: translate(-50%, -50%);
}

.hotspot.has-avatar {
  width: clamp(42px, 4.8vw, 68px);
  height: clamp(42px, 4.8vw, 68px);
  border-width: 4px;
  background: #fff;
  box-shadow: 0 0 0 5px var(--spot-color, #14395f), 0 10px 24px rgba(8, 22, 36, 0.34);
}

.hotspot.animated-stop {
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.78), transparent 24%),
    linear-gradient(135deg, var(--spot-color, #14395f), #f7c948);
  animation: aiStopGlow 3s ease-in-out infinite;
}

.hotspot.has-ai-visual {
  animation: aiStopGlow 3.4s ease-in-out infinite;
}

.hotspot-avatar {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  pointer-events: none;
}

.hotspot-number {
  position: absolute;
  left: -9px;
  bottom: -9px;
  display: grid;
  place-items: center;
  min-width: 25px;
  height: 25px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: var(--spot-color, #14395f);
  color: #fff;
  box-shadow: 0 4px 12px rgba(8, 22, 36, 0.25);
  font-size: 12px;
  font-weight: 900;
  pointer-events: none;
}

.hotspot.has-photos::after {
  content: attr(data-photo-count);
  position: absolute;
  right: -8px;
  top: -10px;
  display: grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: #f7c948;
  color: #172033;
  font-size: 12px;
  font-weight: 900;
}

.hotspot-label {
  position: absolute;
  max-width: 150px;
  min-height: 28px;
  border: 1px solid rgba(255, 255, 255, 0.86);
  border-left: 5px solid var(--spot-color, #14395f);
  border-radius: 7px;
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.9);
  color: #14395f;
  box-shadow: 0 6px 16px rgba(8, 22, 36, 0.22);
  font-size: clamp(11px, 1.05vw, 14px);
  font-weight: 900;
  line-height: 1.12;
  overflow-wrap: anywhere;
  text-align: left;
  transform: translate(18px, -50%);
  backdrop-filter: blur(5px);
}

.hotspot-label:hover,
.hotspot-label:focus-visible {
  background: #fff;
  outline: 2px solid var(--spot-color, #14395f);
}

.mobile-stops {
  display: none;
}

.gallery {
  width: min(980px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  overflow: auto;
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 24px 70px rgba(8, 22, 36, 0.35);
}

.gallery::backdrop {
  background: rgba(7, 18, 30, 0.58);
}

.close {
  position: sticky;
  top: 12px;
  float: right;
  z-index: 2;
  width: 40px;
  min-height: 40px;
  margin: 12px 12px 0 0;
  border-radius: 50%;
  padding: 0;
  background: #fff;
  color: #14395f;
  font-size: 28px;
  line-height: 1;
}

.gallery-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 24px;
  border-bottom: 1px solid rgba(30, 43, 58, 0.14);
}

.stop-number {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--stop-color, #1463c2);
  color: #fff;
  font-weight: 900;
}

.gallery-head h2,
.gallery-head p {
  margin: 0;
}

.gallery-head p {
  margin-top: 4px;
  color: #647083;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
  padding: 22px 24px 26px;
}

.photo {
  position: relative;
  overflow: hidden;
  margin: 0;
  border: 1px solid rgba(30, 43, 58, 0.14);
  border-radius: 8px;
  background: #fff;
}

.photo img,
.photo video {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #101820;
}

.initial-visual-card {
  grid-column: 1 / -1;
}

.initial-visual-card img,
.animated-stop-visual {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: min(48vh, 420px);
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background:
    radial-gradient(circle at 25% 20%, rgba(255, 255, 255, 0.72), transparent 20%),
    radial-gradient(circle at 78% 76%, rgba(247, 201, 72, 0.5), transparent 22%),
    linear-gradient(135deg, var(--spot-color, #14395f), #77c6df);
}

.animated-stop-visual {
  color: #fff;
  font-size: clamp(1.8rem, 7vw, 4.5rem);
  font-weight: 900;
  text-align: center;
  text-shadow: 0 4px 18px rgba(8, 22, 36, 0.42);
  animation: visualDrift 5s ease-in-out infinite alternate;
}

.photo video {
  object-fit: contain;
}

.photo figcaption {
  padding: 10px 12px;
  color: #647083;
  font-size: 0.92rem;
}

.youtube-links {
  grid-column: 1 / -1;
  display: grid;
  gap: 12px;
  border: 1px solid rgba(30, 43, 58, 0.14);
  border-radius: 8px;
  padding: 16px;
  background: #fff;
}

.youtube-links h3 {
  margin: 0;
  color: #14395f;
  font-size: 1rem;
}

.youtube-link-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}

.youtube-link-card {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 68px;
  border: 1px solid rgba(20, 57, 95, 0.12);
  border-radius: 8px;
  padding: 10px;
  background: #f6fbff;
  color: #142033;
  text-decoration: none;
}

.youtube-link-card:hover,
.youtube-link-card:focus-visible {
  border-color: rgba(196, 32, 32, 0.45);
  background: #fff;
  outline: 2px solid rgba(196, 32, 32, 0.18);
}

.youtube-play {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #c42020;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 900;
}

.youtube-link-text {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.youtube-link-text strong,
.youtube-link-text small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.youtube-link-text strong {
  color: #14395f;
  font-size: 0.94rem;
}

.youtube-link-text small {
  color: #647083;
  font-size: 0.82rem;
}

.delete-photo {
  position: absolute;
  right: 8px;
  top: 8px;
  min-height: 32px;
  padding: 5px 10px;
  background: #b4232a;
  font-size: 0.85rem;
}

.empty {
  grid-column: 1 / -1;
  padding: 36px 20px;
  border: 1px dashed rgba(30, 43, 58, 0.22);
  border-radius: 8px;
  text-align: center;
  color: #647083;
}

.admin-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  border-top: 1px solid rgba(30, 43, 58, 0.14);
  background: rgba(235, 245, 255, 0.88);
}

.upload-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.upload-form input[type="password"] {
  width: 150px;
}

.upload-form input[type="file"] {
  max-width: min(100%, 280px);
}

@keyframes routeDash {
  to {
    stroke-dashoffset: -21;
  }
}

@keyframes originPulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.72;
  }
  50% {
    transform: scale(1.12);
    opacity: 0.3;
  }
}

@keyframes aiStopGlow {
  0%,
  100% {
    filter: saturate(1);
    transform: translate(-50%, -50%) scale(1);
  }
  50% {
    filter: saturate(1.2);
    transform: translate(-50%, -50%) scale(1.08);
  }
}

@keyframes visualDrift {
  from {
    background-position: 0% 0%, 100% 100%, 0 0;
  }
  to {
    background-position: 15% 10%, 82% 72%, 0 0;
  }
}

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .planner {
    order: 2;
  }

  .route-area {
    order: 1;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 6px;
  }

  .topbar {
    display: grid;
    gap: 8px;
    margin-bottom: 10px;
  }

  .brand {
    justify-content: center;
    width: 100%;
    border: 1px solid rgba(20, 57, 95, 0.14);
    border-radius: 8px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.82);
    box-shadow: 0 8px 22px rgba(24, 46, 62, 0.12);
    gap: 12px;
  }

  .brand-text {
    max-width: min(68vw, 280px);
  }

  .brand-logo {
    width: 74px;
    height: 74px;
  }

  .topbar h1 {
    font-size: 0.9rem;
    line-height: 1.16;
  }

  .eyebrow {
    font-size: 0.68rem;
    line-height: 1.05;
  }

  .top-actions {
    justify-content: flex-end;
    gap: 6px;
  }

  .session-label {
    max-width: 74px;
    font-size: 0.78rem;
  }

  .top-actions button {
    min-height: 32px;
    padding: 6px 8px;
    font-size: 0.78rem;
  }

  .auth-view {
    grid-template-columns: 1fr;
    padding: 4vh 0;
  }

  .date-grid,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .duration-row {
    grid-template-columns: minmax(0, 1fr) 64px 64px 38px;
  }

  .map-scroller {
    position: relative;
    width: 100%;
    height: auto;
    display: grid;
    place-items: center;
    overflow: visible;
    padding: 0;
  }

  .map-wrap {
    width: min(100%, calc(100vw - 12px));
    max-width: none;
  }

  .mobile-stops {
    display: block;
    padding: 14px 2px 6px;
  }

  .mobile-stops h2 {
    margin: 0 0 10px;
    color: #14395f;
    font-size: 1.1rem;
  }

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

  .mobile-stop {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) 42px;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 60px;
    background: #fff;
    color: #142033;
    text-align: left;
  }

  .mobile-stop-number {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--spot-color);
    color: #fff;
    font-weight: 900;
  }

  .mobile-stop-text {
    display: grid;
    min-width: 0;
  }

  .mobile-stop-text strong,
  .mobile-stop-text small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-stop-text small {
    color: #647083;
  }

  .mobile-stop-count {
    justify-self: end;
    color: #14395f;
    font-weight: 900;
  }

  .gallery {
    width: 100vw;
    max-width: none;
    height: 100svh;
    max-height: none;
    border-radius: 0;
  }

  .photo-grid {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .upload-form input[type="password"],
  .upload-form input[type="file"],
  .upload-form button {
    width: 100%;
    max-width: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .route-line {
    animation: none;
  }
}
