* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: Arial, sans-serif;
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Top bar ─────────────────────────────────────────────── */
.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 48px;
  background-color: #1a1a2e;
  color: #e0e0e0;
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 24px;
  z-index: 1000;
}

.top-bar-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.add-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #f1c40f;
  border: none;
  color: #1a1a2e;
  font-size: 22px;
  line-height: 1;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}

.add-btn:hover {
  background: #f4d03f;
}

.add-btn:active {
  transform: scale(0.93);
}

.cache-popover {
  display: none;
  position: fixed;
  top: 56px;
  left: 12px;
  background: #1a1a2e;
  border: 1px solid #2a4a7f;
  border-radius: 8px;
  padding: 12px;
  gap: 8px;
  flex-direction: column;
  z-index: 1100;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  min-width: 300px;
}

.cache-popover.open {
  display: flex;
}

.cache-popover input {
  background: #0f3460;
  border: 1px solid #2a4a7f;
  border-radius: 4px;
  color: #e0e0e0;
  font-size: 13px;
  padding: 7px 10px;
  outline: none;
  width: 100%;
}

.cache-popover input::placeholder {
  color: #6688aa;
}

.cache-popover input:focus {
  border-color: #f1c40f;
}

.cache-type-radios {
  display: flex;
  background: #0a0f1a;
  border: 1px solid #2a4a7f;
  border-radius: 4px;
  overflow: hidden;
}

.cache-type-radios input[type="radio"] {
  display: none;
  width: auto;
}

.cache-type-radios label {
  flex: 1;
  text-align: center;
  padding: 5px 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: #4a6a8a;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.cache-type-radios input[type="radio"]:checked + label {
  background: #0f3460;
  color: #e0e0e0;
}

.cache-popover button {
  background: #f1c40f;
  border: none;
  border-radius: 4px;
  color: #1a1a2e;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 12px;
  cursor: pointer;
  align-self: flex-end;
}

.cache-popover button:hover {
  background: #f4d03f;
}

/* ── Main content ────────────────────────────────────────── */
.main-content {
  margin-top: 48px;
  width: 100vw;
  height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Section headers ─────────────────────────────────────── */
.section-header {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #4a6a8a;
  background: #0a0f1a;
  padding: 4px 12px;
  border-bottom: 1px solid #1e3a5f;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  user-select: none;
  justify-content: space-between;
}

.section-count {
  color: #2a5280;
  font-weight: 400;
}

/* ── Panel toggle button ─────────────────────────────────── */
.panel-toggle {
  margin-left: auto;
  background: none;
  border: none;
  color: #4a6a8a;
  font-size: 12px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  transition: color 0.15s;
}

.panel-toggle:hover {
  color: #e0e0e0;
}

/* ── Timeline resize handle ──────────────────────────────── */
.tl-resize-handle {
  height: 5px;
  cursor: ns-resize;
  background: transparent;
  flex-shrink: 0;
}

.tl-resize-handle:hover,
.tl-resize-handle:active {
  background: #2a4a7f;
}

/* ── Timeline closed ─────────────────────────────────────── */
#timeline-section.panel-closed #timeline-canvas,
#timeline-section.panel-closed .tl-resize-handle {
  display: none;
}

#timeline-section.panel-closed {
  cursor: pointer;
}

#timeline-section.panel-closed .panel-toggle {
  display: none;
}

/* ── Column resize handle ────────────────────────────────── */
.col-resize-handle {
  width: 5px;
  cursor: ew-resize;
  background: transparent;
  flex-shrink: 0;
}

.col-resize-handle:hover,
.col-resize-handle:active {
  background: #2a4a7f;
}

/* ── Map column closed ───────────────────────────────────── */
.map-column.panel-closed {
  display: none;
}

.grid-panel.map-closed {
  width: 100% !important;
}

/* ── Timeline ────────────────────────────────────────────── */
#timeline-section {
  flex-shrink: 0;
  background: #111827;
  border-bottom: 1px solid #1e3a5f;
  position: relative;
}

#timeline-canvas {
  display: block;
  width: 100%;
  height: 200px;
  cursor: grab;
  background: #0d1117;
}

#tl-tooltip {
  position: fixed;
  background: rgba(17, 24, 39, 0.92);
  border: 1px solid #2a5280;
  color: #e0e0e0;
  font-size: 11px;
  padding: 5px 9px;
  border-radius: 4px;
  pointer-events: none;
  display: none;
  z-index: 2000;
  white-space: nowrap;
}

/* ── Workspace (grid + map) ──────────────────────────────── */
.workspace {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* ── Thumbnail grid panel ────────────────────────────────── */
.grid-panel {
  width: 50%;
  height: 100%;
  overflow-y: auto;
  background-color: #0d0d1a;
  border-right: 1px solid #0f3460;
}

.thumbnail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
  padding: 12px;
}

.grid-section-sep {
  grid-column: 1 / -1;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #2a4a6a;
  text-align: center;
  padding: 10px 0 6px;
  border-top: 1px solid #1e3a5f;
  margin-top: 4px;
  user-select: none;
}

.grid-empty {
  grid-column: 1 / -1;
  color: #556;
  font-size: 13px;
  text-align: center;
  padding: 40px 0;
}

.thumb-card {
  background-color: #16213e;
  border-radius: 6px;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  transition:
    transform 0.15s,
    box-shadow 0.15s;
  border: 1px solid transparent;
}

.thumb-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  border-color: #f1c40f;
}

.thumb-card.selected {
  border-color: #f1c40f;
  box-shadow: 0 0 0 2px #f1c40f44;
}

.thumb-indicators {
  position: absolute;
  top: 4px;
  left: 4px;
  display: flex;
  gap: 3px;
  z-index: 1;
}

.indicator {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 3px;
  color: #fff;
}

.indicator svg {
  width: 11px;
  height: 11px;
}

.indicator-map {
  color: #60a5fa;
}

.indicator-clock {
  color: #6ee7b7;
}

.thumb-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  background-color: #0f3460;
}

.thumb-card .thumb-meta {
  padding: 5px 7px;
  font-size: 11px;
  color: #aab;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Map column (map + notes) ────────────────────────────── */
.map-column {
  width: 50%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.map-panel {
  flex: 4;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
}

#leaflet-map {
  flex: 1;
  min-height: 0;
}

.notes-panel {
  flex: 1;
  background: #0a0f1a;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.notes-panel textarea {
  flex: 1;
  width: 100%;
  height: 100%;
  background: transparent;
  border: none;
  color: #c9d1d9;
  font-size: 13px;
  font-family: Arial, sans-serif;
  padding: 10px 12px;
  resize: none;
  outline: none;
  line-height: 1.5;
}

.notes-panel textarea::placeholder {
  color: #3a5280;
}

.map-drop-dot {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #f1c40f;
  border: 2px solid #fff;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  transform: translate(-50%, -50%);
  display: none;
  z-index: 1000;
}

.map-panel.drag-over .map-drop-dot {
  display: block;
}

#leaflet-map {
  width: 100%;
  height: 100%;
}

/* ── Marker popup ────────────────────────────────────────── */
.marker-popup {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 120px;
}

.marker-popup img {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: 4px;
  display: block;
}

.marker-popup-name {
  font-size: 12px;
  color: #1a1a2e;
  text-align: center;
  word-break: break-all;
  max-width: 120px;
}

/* ── Lightbox ────────────────────────────────────────────── */
#lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 3000;
  align-items: center;
  justify-content: center;
}

#lightbox.open {
  display: flex;
}

#lightbox-bg {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  cursor: zoom-out;
}

#lightbox-img {
  position: relative;
  max-width: 92vw;
  max-height: 88vh;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.8);
  z-index: 1;
}

#lightbox-caption {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
  z-index: 2;
  pointer-events: none;
  white-space: nowrap;
}

/* ── Popup (lightbox) ────────────────────────────────────── */
.popup {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.75);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
}

.popup img {
  max-width: 80%;
  max-height: 80%;
  object-fit: contain;
  border-radius: 6px;
  margin: 20px;
}

.popup .close-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  background-color: #e74c3c;
  color: white;
  border: none;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.popup .info-div {
  display: flex;
  flex-direction: column;
  background-color: rgba(0, 0, 0, 0.85);
  padding: 12px;
  border-radius: 6px;
  margin: 20px;
  max-width: 260px;
}

.popup .info-div p {
  padding: 4px 0;
  color: #ddd;
  font-size: 13px;
}

.highlight {
  border-color: #e74c3c !important;
}
