#media-container {
  width: 100%;
  aspect-ratio: 3840 / 1600;
  background-color: #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  overflow: hidden;
  margin-top: 15px;
  position: relative;
}

html.dark-mode #empty-state rect {
  fill: #333;
}

html.dark-mode #empty-state text {
  fill: #bbb;
}

/* Canvas */
#archive-canvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
  cursor: pointer;
  aspect-ratio: 3840 / 1600;
  background-color: transparent;
}

#archive-canvas:focus-visible,
#archive-image-fallback:focus-visible {
  outline: 3px solid #16a34a;
  outline-offset: 2px;
}

/* Time Slider — custom track with buffered indicator */
#time-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  cursor: pointer;
  outline: none;
  background: linear-gradient(to right,
      #16a34a 0%, #16a34a var(--decode-pct, 0%),
      #e5e7eb var(--decode-pct, 0%), #e5e7eb 100%);
}

#time-slider:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

#time-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #16a34a;
  cursor: pointer;
}

#time-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #16a34a;
  cursor: pointer;
  border: none;
}

#time-slider::-moz-range-track {
  height: 4px;
  background: transparent;
}

/* Playback Controls */
#playback-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 12px;
}

#play-pause-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid #16a34a;
  background: #fff;
  color: #16a34a;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background-color 0.2s;
}

#play-pause-btn:hover:not(:disabled) {
  background-color: #f0fdf4;
}

#play-pause-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#speed-select {
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid #ccc;
  font-size: 14px;
  cursor: pointer;
  font-family: system-ui, -apple-system, sans-serif;
}

/* Dark mode additions */
html.dark-mode #play-pause-btn {
  background: #333;
  color: #4ade80;
  border-color: #4ade80;
}

html.dark-mode #play-pause-btn:hover:not(:disabled) {
  background: #444;
}

html.dark-mode #time-slider {
  background: linear-gradient(to right,
      #4ade80 0%, #4ade80 var(--decode-pct, 0%),
      #555 var(--decode-pct, 0%), #555 100%);
}

html.dark-mode #time-slider::-webkit-slider-thumb {
  background: #4ade80;
}

html.dark-mode #time-slider::-moz-range-thumb {
  background: #4ade80;
}

/* AI Tag Hint Styling */
#daily-ai-tags {
  margin: 10px 0 0 0;
  font-size: 13px;
  color: #666;
  display: none;
  text-align: center;
}

html.dark-mode #daily-ai-tags {
  color: #aaa;
}

.ai-tag-link {
  color: #16a34a;
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.2s;
}

.ai-tag-link:hover {
  text-decoration: underline;
  color: #15803d;
}

html.dark-mode .ai-tag-link {
  color: #4ade80;
}

html.dark-mode .ai-tag-link:hover {
  color: #86efac;
}

/* Tag Cloud */
.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid #ddd;
  background-color: #f3f4f6;
  color: #333;
  text-decoration: none;
  transition: background-color 0.2s;
}

.tag-pill:hover {
  background-color: #e5e7eb;
}

.tag-pill.active {
  background-color: #16a34a;
  color: #fff;
  border-color: #16a34a;
}

.tag-pill-count {
  font-size: 12px;
  font-weight: 400;
  opacity: 0.7;
}

/* Tag Thumbnail Grid */
.tag-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 15px;
}

.tag-grid a {
  display: block;
}

/* Tag cloud dark mode */
html.dark-mode .tag-pill {
  background-color: #444;
  color: #e0e0e0;
  border-color: #555;
}

html.dark-mode .tag-pill:hover {
  background-color: #555;
}

html.dark-mode .tag-pill.active {
  background-color: #16a34a;
  color: #fff;
  border-color: #16a34a;
}

/* Tag Card — used for both Days and Detail views */
.tag-card {
  display: block;
  text-decoration: none;
  color: inherit;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  background: #f9fafb;
  transition: transform 0.2s;
  will-change: transform;
  /* Performance: Offload hover scaling to GPU */
}

.tag-card:hover {
  transform: scale(1.02);
}

.tag-card img {
  width: 100%;
  height: auto;
  aspect-ratio: 3840 / 1600;
  object-fit: cover;
  display: block;
}

.tag-card-info {
  padding: 10px 12px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tag-card-text {
  display: flex;
  flex-direction: column;
}

.tag-card-title {
  font-size: 14px;
  font-weight: 600;
}

.tag-card-subtitle {
  font-size: 12px;
  color: #666;
  margin-top: 2px;
}

/* Player return button container */
#player-return-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: #16a34a;
  text-decoration: none;
}

/* Highlight the icon when hovering the text/container */
#player-return-btn:hover .btn-icon-circle {
  background-color: #16a34a;
  color: white;
  border-color: #16a34a;
}

/* "View All" button in tag list header */
#tag-view-all-btn {
  font-size: 13px;
  color: #16a34a;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid #16a34a;
  padding: 3px 10px;
  border-radius: 14px;
  display: none;
  transition: all 0.2s;
}

#tag-view-all-btn:hover {
  background-color: #16a34a;
  color: white;
}

/* Sort button in tag detail header */
#tag-sort-btn,
#tag-days-sort-btn {
  font-size: 13px;
  color: #666;
  background: none;
  border: 1px solid #ccc;
  padding: 3px 10px;
  border-radius: 14px;
  cursor: pointer;
  display: none;
}

#tag-sort-btn:hover,
#tag-days-sort-btn:hover {
  background-color: #eee;
}

/* Vote Controls */
.vote-controls {
  display: flex;
  justify-content: center;
  gap: 8px;
  align-items: center;
}

.vote-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #cbd5e1;
  /* slate-300 */
  padding: 4px;
  transition: color 0.2s, transform 0.1s;
  display: flex;
  align-items: center;
}

.vote-btn:not(:disabled):hover {
  transform: scale(1.1);
}

.vote-btn.vote-up:not(:disabled):hover {
  color: #16a34a;
}

.vote-btn.vote-down:not(:disabled):hover {
  color: #dc2626;
}

.vote-btn.voted-up {
  color: #16a34a;
  cursor: default;
}

.vote-btn.voted-down {
  color: #dc2626;
  cursor: default;
}

.vote-btn:disabled {
  cursor: default;
  opacity: 0.5;
}

/* Dark mode — new tag elements */
html.dark-mode .tag-card {
  background: #3a3a3a;
}

html.dark-mode .tag-card-subtitle {
  color: #aaa;
}

html.dark-mode #tag-view-all-btn {
  color: #4ade80;
  border-color: #4ade80;
}

html.dark-mode #tag-view-all-btn:hover {
  background-color: #4ade80;
  color: #1f2937;
}

html.dark-mode #tag-sort-btn,
html.dark-mode #tag-days-sort-btn {
  color: #aaa;
  border-color: #555;
}

html.dark-mode #tag-sort-btn:hover,
html.dark-mode #tag-days-sort-btn:hover {
  background-color: #444;
}

html.dark-mode .vote-btn {
  color: #4b5563;
}

html.dark-mode .vote-btn.vote-up:not(:disabled):hover {
  color: #4ade80;
}

html.dark-mode .vote-btn.vote-down:not(:disabled):hover {
  color: #f87171;
}

html.dark-mode #player-return-link {
  border-top-color: #444 !important;
}

html.dark-mode #player-return-btn {
  color: #4ade80;
}

html.dark-mode #player-return-btn:hover .btn-icon-circle {
  background-color: #4ade80;
  color: #1f2937;
  border-color: #4ade80;
}

/* View in Timelapse Link */
.timelapse-link {
  font-size: 12px;
  color: #16a34a;
  text-decoration: none;
  font-weight: 600;
  margin-top: 6px;
  display: inline-block;
  transition: color 0.2s;
}

.timelapse-link:hover {
  text-decoration: underline;
  color: #15803d;
}

html.dark-mode .timelapse-link {
  color: #4ade80;
}

html.dark-mode .timelapse-link:hover {
  color: #86efac;
}

/* Spinner */
.spinner {
  width: 30px;
  height: 30px;
  border: 3px solid rgba(0, 0, 0, 0.1);
  border-top-color: #16a34a;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}

html.dark-mode .spinner {
  border-color: rgba(255, 255, 255, 0.1);
  border-top-color: #4ade80;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ========== Player Mode Toggle ========== */
/* Segmented control to switch between the frame-by-frame player and the MP4 video */
#player-mode-toggle {
  display: flex;
  border: 1px solid #ddd;
  border-radius: 8px;
  overflow: hidden;
  width: fit-content;
  margin: 0 auto 15px;
}

.mode-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  background: none;
  cursor: pointer;
  color: #666;
  transition: background-color 0.15s, color 0.15s;
  font-family: system-ui, -apple-system, sans-serif;
}

.mode-btn + .mode-btn {
  border-left: 1px solid #ddd;
}

.mode-btn.active {
  background-color: #16a34a;
  color: #fff;
}

.mode-btn:not(.active):hover {
  background-color: #f3f4f6;
  color: #333;
}

html.dark-mode #player-mode-toggle {
  border-color: #555;
}

html.dark-mode .mode-btn {
  color: #aaa;
}

html.dark-mode .mode-btn + .mode-btn {
  border-left-color: #555;
}

html.dark-mode .mode-btn.active {
  background-color: #16a34a;
  color: #fff;
}

html.dark-mode .mode-btn:not(.active):hover {
  background-color: #444;
  color: #e0e0e0;
}

/* Video element — inherits the media-container aspect-ratio box */
#timelapse-video {
  width: 100%;
  display: block;
  border-radius: 8px;
}

#timelapse-video:focus-visible {
  outline: 3px solid #16a34a;
  outline-offset: 2px;
}

/* Unavailable notice shown when no MP4 exists for the selected date */
#video-unavailable {
  font-size: 14px;
}

/* Quality badge — overlaid top-right of the video in Video mode.
   Shows HD when hires is playing, SD when thumb is playing.
   Acts as a toggle button when hires is available; non-interactive when only thumb exists.
   data-state="hd"        — green  (hires playing, click switches to SD)
   data-state="sd-choice" — amber  (SD playing by choice, click switches back to HD)
   data-state="sd-only"   — grey   (no hires available, non-interactive) */
#video-quality-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  letter-spacing: 0.05em;
  font-family: system-ui, -apple-system, sans-serif;
  color: #fff;
  transition: background-color 0.15s, opacity 0.4s;
  z-index: 2;
}

#video-quality-badge[data-state="hd"] {
  background-color: #16a34a;
}

#video-quality-badge[data-state="sd-choice"] {
  background-color: #d97706;
}

#video-quality-badge[data-state="sd-only"] {
  background-color: #6b7280;
  cursor: default;
}

#video-quality-badge:not([data-state="sd-only"]):hover {
  background-color: #15803d;
}

#video-quality-badge[data-state="sd-choice"]:hover {
  background-color: #b45309;
}

/* Share button — overlaid top-left of the video in Video mode.
   Uses btn-icon-circle base style from shared.css; this just sets its absolute position. */
#video-share-btn {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  transition: opacity 0.4s;
}

/* Fade out overlay badges while the video is actively playing; they fade back in on pause or end.
   opacity + pointer-events:none is used instead of display:none so CSS transitions can animate. */
#media-container.video-playing #video-quality-badge,
#media-container.video-playing #video-share-btn {
  opacity: 0 !important;
  pointer-events: none !important;
}