:root {
  color-scheme: dark;
  --bg: #07130f;
  --panel: rgba(12, 26, 22, 0.82);
  --panel-strong: rgba(19, 39, 33, 0.92);
  --line: rgba(190, 221, 203, 0.18);
  --text: #f4fbf7;
  --muted: #a9beb4;
  --accent: #70e3b1;
  --accent-2: #f2c66d;
  --danger: #ff8f8f;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui,
    sans-serif;
  color: var(--text);
  background:
    linear-gradient(115deg, rgba(112, 227, 177, 0.12), transparent 36%),
    linear-gradient(245deg, rgba(242, 198, 109, 0.12), transparent 42%),
    linear-gradient(135deg, #07130f 0%, #10241e 46%, #101718 100%);
  overflow-x: hidden;
}

button,
input,
textarea,
select {
  font: inherit;
}

button,
select,
input,
textarea {
  color: var(--text);
}

button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(112, 227, 177, 0.5);
  background: rgba(112, 227, 177, 0.12);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

.primary-btn {
  border-color: rgba(112, 227, 177, 0.45);
  background: linear-gradient(135deg, #7ff0bd, #47bd91);
  color: #062015;
  font-weight: 800;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 430px);
  gap: 18px;
  min-height: 100vh;
  padding: 18px;
}

.map-stage,
.memory-panel {
  min-width: 0;
}

.map-stage {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 16px;
}

.topbar,
.memory-panel,
.map-card {
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px;
  border-radius: 8px;
  background: rgba(10, 23, 20, 0.72);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.8rem, 3.2vw, 3.6rem);
  line-height: 1;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 76px);
  gap: 10px;
}

.stats div,
.summary-tile {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
  padding: 12px;
}

.stats strong,
.summary-tile strong {
  display: block;
  font-size: 1.45rem;
}

.stats span,
.summary-tile span {
  color: var(--muted);
  font-size: 0.8rem;
}

.map-card {
  position: relative;
  min-height: 620px;
  overflow: hidden;
  border-radius: 8px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    rgba(7, 19, 15, 0.74);
  background-size: 48px 48px;
}

.map-card::after {
  content: "";
  position: absolute;
  inset: auto 7% 6% 7%;
  height: 22%;
  background: linear-gradient(90deg, transparent, rgba(112, 227, 177, 0.12), transparent);
  filter: blur(28px);
  pointer-events: none;
}

#chinaMap {
  position: absolute;
  inset: 0;
  z-index: 3;
}

.journey-map-svg {
  display: block;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 26px 46px rgba(0, 0, 0, 0.28));
}

.province-path {
  stroke: rgba(248, 255, 250, 0.94);
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
  cursor: pointer;
  outline: none;
  transition:
    fill 180ms ease,
    stroke 180ms ease,
    filter 180ms ease;
}

.province-path:hover,
.province-path:focus-visible {
  stroke: rgba(255, 255, 255, 0.92);
  filter: brightness(1.16);
}

.province-path.is-visited {
  stroke: rgba(248, 255, 250, 0.9);
}

.province-path.is-selected {
  stroke: #fff7d7;
  stroke-width: 2.2;
  filter: drop-shadow(0 0 14px rgba(242, 198, 109, 0.55));
}

.province-label {
  fill: #f7fff9;
  paint-order: stroke;
  stroke: rgba(5, 17, 13, 0.82);
  stroke-width: 4;
  font-size: 17px;
  font-weight: 800;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
}

.journey-route {
  fill: none;
  stroke: rgba(242, 198, 109, 0.78);
  stroke-width: 2.4;
  stroke-dasharray: 9 9;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
  animation: route-drift 9s linear infinite;
}

.journey-marker {
  pointer-events: none;
}

.marker-pulse {
  fill: rgba(242, 198, 109, 0.2);
  stroke: rgba(242, 198, 109, 0.68);
  stroke-width: 2;
  transform-box: fill-box;
  transform-origin: center;
  animation: marker-pulse 2.6s ease-out infinite;
}

.marker-dot {
  fill: #f2c66d;
  stroke: #fff8dc;
  stroke-width: 2;
}

.map-error {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.map-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
}

@keyframes route-drift {
  to {
    stroke-dashoffset: -72;
  }
}

@keyframes marker-pulse {
  0% {
    opacity: 0.82;
    transform: scale(0.62);
  }

  100% {
    opacity: 0;
    transform: scale(1.75);
  }
}

.map-hint {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 18px;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(7, 19, 15, 0.72);
  backdrop-filter: blur(16px);
}

.map-hint span {
  color: var(--muted);
  min-width: 0;
}

.memory-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: calc(100vh - 36px);
  overflow: auto;
  border-radius: 8px;
  background: var(--panel);
  padding: 18px;
}

.panel-header,
.section-title,
.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.cloud-sync {
  display: grid;
  gap: 12px;
  border: 1px solid rgba(112, 227, 177, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  padding: 14px;
}

.sync-toggle {
  display: flex;
  align-items: center;
  grid-auto-flow: column;
  gap: 8px;
  color: var(--text);
}

.sync-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

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

.sync-status {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.storage-status {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.import-btn {
  display: grid;
  place-items: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  cursor: pointer;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease;
}

.import-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(112, 227, 177, 0.5);
  background: rgba(112, 227, 177, 0.12);
}

.import-btn input {
  display: none;
}

.panel-header h2 {
  margin-bottom: 0;
  font-size: 1.5rem;
}

.editor {
  border: 1px solid rgba(112, 227, 177, 0.2);
  border-radius: 8px;
  background: rgba(112, 227, 177, 0.065);
  padding: 14px;
}

form {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.88rem;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.22);
  padding: 11px 12px;
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 116px;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(112, 227, 177, 0.68);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 150px;
  gap: 10px;
}

.file-picker {
  border: 1px dashed rgba(112, 227, 177, 0.42);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.04);
}

.file-picker input {
  padding: 0;
  border: 0;
  background: transparent;
}

.pending-media,
.media-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.pending-media:empty {
  display: none;
}

.media-chip,
.media-item {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
}

.media-chip {
  padding: 9px;
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.media-item {
  position: relative;
  aspect-ratio: 1;
  cursor: pointer;
}

.media-item img,
.media-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

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

.timeline {
  min-height: 0;
}

.section-title {
  margin-bottom: 12px;
}

.section-title h3 {
  margin-bottom: 0;
}

.section-title select {
  max-width: 132px;
  padding: 9px 10px;
}

.memory-list {
  display: grid;
  gap: 12px;
}

.empty-state,
.memory-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
}

.empty-state {
  padding: 20px;
  color: var(--muted);
}

.empty-state strong {
  display: block;
  color: var(--text);
  margin-bottom: 8px;
}

.empty-state p {
  margin-bottom: 0;
}

.memory-card {
  padding: 14px;
}

.memory-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.memory-card h4 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.meta {
  color: var(--muted);
  font-size: 0.82rem;
}

.note {
  color: #d8e8df;
  line-height: 1.65;
  white-space: pre-wrap;
}

.card-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  padding: 0;
}

.delete-btn {
  color: var(--danger);
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(0, 0, 0, 0.78);
}

.lightbox[hidden] {
  display: none;
}

#closeLightboxBtn {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 2;
}

#lightboxContent {
  width: min(980px, 94vw);
  max-height: 86vh;
}

#lightboxContent img,
#lightboxContent video {
  display: block;
  width: 100%;
  max-height: 86vh;
  object-fit: contain;
  border-radius: 8px;
}

@media (max-width: 980px) {
  body {
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .map-card {
    min-height: 56vh;
  }

  .memory-panel {
    max-height: none;
  }
}

@media (max-width: 620px) {
  .topbar,
  .panel-header,
  .map-hint {
    align-items: stretch;
    flex-direction: column;
  }

  .stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .field-row,
  .data-tools,
  .sync-actions,
  .province-summary {
    grid-template-columns: 1fr;
  }

  .pending-media,
  .media-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  h1 {
    font-size: 2rem;
  }
}
