:root {
  --bg: #f3f5f6;
  --panel: #ffffff;
  --ink: #122126;
  --muted: #496068;
  --line: #d2dde1;
  --brand: #0a7f85;
  --accent: #ff8c42;
  --focus: #003d4a;
  --shadow: 0 8px 28px rgba(11, 31, 40, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 10%, #ffffff 0%, rgba(255, 255, 255, 0) 30%),
    radial-gradient(circle at 95% 90%, #dff4f5 0%, rgba(223, 244, 245, 0) 35%),
    var(--bg);
  min-height: 100vh;
  overflow: hidden;
}

.app {
  max-width: 1480px;
  margin: 0 auto;
  padding: 1rem;
  height: 100vh;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.55rem 0.85rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.brand h1 {
  margin: 0;
  font-size: clamp(1.4rem, 2.2vw, 2rem);
}

.brand p {
  margin: 0.2rem 0 0;
  color: var(--muted);
}

.workspace {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: 2.2fr 1fr;
  gap: 1rem;
  height: 78vh;
  overflow: hidden;
}

.map-panel,
.detail-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.map-panel {
  display: grid;
  grid-template-rows: minmax(0, 1fr) 132px auto;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.map-panel.feed-mode {
  grid-template-rows: minmax(0, 1fr);
}

.global-controls {
  display: inline-flex;
  gap: 0.45rem;
  align-items: center;
}

.global-status {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.24rem 0.5rem;
  font-size: 0.68rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.86);
  max-width: min(42ch, 46vw);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.data-root-hint {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.24rem 0.5rem;
  font-size: 0.68rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.86);
  max-width: min(34ch, 36vw);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.data-modes,
.view-modes {
  display: inline-flex;
  gap: 0.35rem;
  margin: 0;
  padding: 0.2rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(2px);
}

.data-modes button,
.view-modes button {
  border: 0;
  background: transparent;
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  font-size: 0.78rem;
  color: var(--muted);
  cursor: pointer;
}

.data-modes.compact button,
.view-modes.compact button {
  font-size: 0.7rem;
  padding: 0.25rem 0.52rem;
  min-width: 2.3rem;
}

.data-modes button.active,
.view-modes button.active {
  background: #e8f6f7;
  color: var(--brand);
}

.map-viewport {
  position: relative;
  overflow: hidden;
  margin: 1rem;
  border-radius: 12px;
  background: #d9edf3;
  border: 1px solid #accbd7;
  min-height: 0;
}

.map-canvas {
  position: absolute;
  inset: 0;
  z-index: 100;
}

.globe-viewport {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 22% 22%, rgba(255, 255, 255, 0.18), transparent 40%),
    radial-gradient(circle at 78% 84%, rgba(255, 255, 255, 0.08), transparent 35%),
    linear-gradient(180deg, #030f23 0%, #0a1f3a 45%, #071225 100%);
  z-index: 200;
}

.globe-viewport.is-hidden {
  display: none;
}

.globe-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.feed-panel {
  margin: 0;
  border-radius: 12px;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background:
    radial-gradient(circle at 12% 10%, rgba(255, 255, 255, 0.22), transparent 32%),
    linear-gradient(180deg, #e8f4f8 0%, #d7ebf1 100%);
  border: 1px solid #accbd7;
  min-height: 0;
  height: 100%;
}

.feed-panel.is-hidden {
  display: none;
}

.feed-toolbar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
  padding: 0.55rem;
  background: rgba(248, 252, 253, 0.92);
  backdrop-filter: blur(5px);
  border-bottom: 1px solid var(--line);
}

.feed-toolbar input {
  border: 1px solid #b9d0d7;
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
  font-size: 0.76rem;
  color: var(--ink);
  background: #fff;
}

.feed-list {
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.35rem;
  display: grid;
  gap: 0.55rem;
  align-content: start;
  scroll-snap-type: y proximity;
  touch-action: pan-y;
  pointer-events: auto;
  min-height: 0;
  height: 100%;
}

.feed-card {
  border: 1px solid #b8d0d7;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.98);
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 9fr) minmax(96px, 1fr);
  min-height: 248px;
  cursor: pointer;
  scroll-snap-align: start;
  align-items: stretch;
}

.feed-card.is-selected {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(10, 127, 133, 0.2);
}

.feed-main {
  display: grid;
  grid-template-rows: auto auto;
  min-width: 0;
  justify-items: center;
  align-content: start;
}

.feed-media {
  background: #d5e8ee;
  width: 300px;
  height: 240px;
  min-height: 240px;
  max-height: 240px;
  margin-top: 0.45rem;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #c6d9de;
}

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

.feed-title {
  width: 300px;
  padding: 0.42rem 0.35rem 0.5rem;
  font-size: 0.9rem;
  line-height: 1.25;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.95);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  white-space: normal;
}

.feed-year-cell {
  border-left: 1px solid #d2dde1;
  padding: 0.55rem 0.45rem;
  display: grid;
  align-content: center;
  justify-items: center;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
  background: #f7fbfc;
}

.feed-empty {
  border: 1px dashed #9fbac2;
  border-radius: 10px;
  padding: 0.85rem;
  text-align: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.78);
}

.leaflet-container {
  width: 100%;
  height: 100%;
  font: inherit;
}

.leaflet-control-attribution {
  font-size: 0.65rem;
}

.status-badge {
  position: absolute;
  left: 0.7rem;
  bottom: 0.7rem;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.24rem 0.48rem;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.1;
  max-width: min(44ch, 62%);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  z-index: 1300;
}

.map-location-strip {
  border-top: 1px solid var(--line);
  padding: 0.45rem 0.65rem 0.55rem;
  background: #f8fbfc;
  min-height: 132px;
  max-height: 132px;
  overflow: hidden;
}

.map-location-strip.is-hidden {
  visibility: hidden;
}

.timeline {
  border-top: 1px solid var(--line);
  padding: 0.8rem 1rem 1.1rem;
}

.timeline-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.timeline input[type="range"] {
  width: 100%;
  accent-color: var(--brand);
}

.timeline input[type="range"]:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.detail-panel {
  padding: 1rem;
  overflow: hidden;
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto;
  gap: 0.8rem;
}

.artifact-card {
  min-height: 200px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.9rem;
  background: #f8fbfc;
}

.artifact-card.empty {
  display: grid;
  place-items: center;
  color: var(--muted);
}

.artifact-card h4 {
  margin: 0;
}

.artifact-card dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.4rem 0.8rem;
  margin: 0.8rem 0 0;
}

.artifact-card dt {
  color: var(--muted);
}

.artifact-card dd {
  margin: 0;
  word-break: break-word;
}

.location-thumb-strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 86px;
  gap: 0.4rem;
  overflow-x: auto;
  overflow-y: hidden;
  height: 100%;
  padding: 0.15rem 0 0.25rem;
  align-content: start;
}

.location-thumb {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  padding: 0.22rem;
  display: grid;
  gap: 0.2rem;
}

.location-thumb.is-selected {
  border-color: var(--brand);
  box-shadow: inset 0 0 0 1px rgba(10, 127, 133, 0.25);
}

.location-thumb-media {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 6px;
  overflow: hidden;
  background: #dbecef;
  border: 1px solid #d2dde1;
}

.location-thumb-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.location-thumb-fallback {
  width: 100%;
  height: 100%;
  border-radius: 6px;
}

.location-thumb-label {
  font-size: 0.62rem;
  line-height: 1.15;
  color: var(--ink);
  max-height: 2.3em;
  overflow: hidden;
}

.data-modes button:focus-visible,
.view-modes button:focus-visible,
.location-thumb:focus-visible,
.feed-toolbar input:focus-visible,
.feed-card:focus-visible,
.location-thumb:hover,
.location-thumb.is-selected {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

@media (max-width: 980px) {
  .topbar {
    flex-wrap: wrap;
    align-items: center;
  }

  .global-controls {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .global-status {
    max-width: 100%;
  }

  .data-root-hint {
    max-width: 100%;
  }

  .workspace {
    grid-template-columns: 1fr;
    height: auto;
  }

  .map-panel {
    height: auto;
    min-height: 58vh;
    grid-template-rows: minmax(42vh, 1fr) 116px auto;
  }

  .map-viewport {
    min-height: 42vh;
  }

  .feed-toolbar {
    grid-template-columns: 1fr;
  }

  .feed-card {
    grid-template-columns: minmax(0, 9fr) minmax(84px, 1fr);
    min-height: 300px;
  }

  .feed-media {
    width: 240px;
    height: 208px;
    min-height: 208px;
    max-height: 208px;
  }

  .feed-title {
    width: 240px;
    font-size: 0.8rem;
    padding: 0.34rem 0.3rem 0.42rem;
  }

  .feed-year-cell {
    font-size: 0.68rem;
    padding: 0.35rem 0.3rem;
  }

  .map-location-strip {
    min-height: 116px;
    max-height: 116px;
  }

  .detail-panel {
    height: auto;
    min-height: 0;
    display: block;
  }
}

@media (max-width: 720px) {
  .status-badge {
    max-width: 56%;
  }
}
