* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: #1b1b1f;
  color: #f0f0f0;
}
.hidden { display: none !important; }

#setup {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 1rem;
  padding: 2rem;
}
#setup h1 { font-size: 2.2rem; margin: 0; }
#setup p { font-size: 1.3rem; max-width: 30rem; }
.error { color: #ff8080; }

.big-btn {
  font-size: 1.6rem;
  padding: 1.2rem 2.4rem;
  border-radius: 0.8rem;
  border: none;
  background: #4a8cff;
  color: white;
  cursor: pointer;
}
.big-btn:active { background: #326ad6; }
.skip-btn { background: #555; font-size: 1.1rem; padding: 0.7rem 1.4rem; }
.skip-btn:active { background: #3d3d3d; }

#toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #26262c;
  padding: 0.8rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 1.2rem;
}
#selectModeBtn {
  font-size: 1.2rem;
  padding: 0.6rem 1.2rem;
  border-radius: 0.6rem;
  border: none;
  background: #444;
  color: white;
  cursor: pointer;
}
#selectModeBtn.active { background: #4a8cff; }
#gridSizeBtn {
  font-size: 1.2rem;
  padding: 0.6rem 1.2rem;
  border-radius: 0.6rem;
  border: none;
  background: #444;
  color: white;
  cursor: pointer;
}
#downloadAllBtn {
  font-size: 1.2rem;
  padding: 0.6rem 1.2rem;
  border-radius: 0.6rem;
  border: none;
  background: #34c759;
  color: white;
  cursor: pointer;
}
#downloadAllBtn:disabled { opacity: 0.6; cursor: default; }
#visitedCounter { opacity: 0.8; font-size: 1rem; }
#downloadFolderLabel { opacity: 0.7; font-size: 1rem; }

#albumNavBar {
  position: sticky;
  top: 3.6rem;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.8rem 1rem;
  background: #202024;
  border-bottom: 1px solid #333;
}
#albumNav {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 0.6rem;
  flex: 1 1 auto;
  min-width: 0;
}
#albumNavBar.expanded #albumNav {
  flex-wrap: wrap;
  overflow-x: visible;
}
#albumNavToggle {
  flex: 0 0 auto;
  font-size: 1.05rem;
  font-weight: 600;
  padding: 0.7rem 1.3rem;
  border-radius: 1rem;
  border: none;
  background: #4a8cff;
  color: white;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(74, 140, 255, 0.5);
}
#albumNavToggle:active { background: #326ad6; }
.nav-pill {
  flex: 0 0 auto;
  font-size: 1.05rem;
  padding: 0.6rem 1.2rem;
  border-radius: 1rem;
  border: 1px solid #555;
  background: #2c2c33;
  color: #ddd;
  cursor: pointer;
  white-space: nowrap;
}
.nav-pill.visited { border-color: #34c759; color: #9ee6ae; }

#tree { padding: 1rem; }
.headline-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 1.6rem 0 0.4rem;
  border-bottom: 2px solid #444;
  padding-bottom: 0.3rem;
}
.headline { font-size: 1.8rem; margin: 0; }
.headline-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }
.collapse-btn, .visited-btn {
  font-size: 0.95rem;
  padding: 0.4rem 0.9rem;
  border-radius: 0.5rem;
  border: 1px solid #555;
  background: #2c2c33;
  color: #ddd;
  cursor: pointer;
  flex-shrink: 0;
}
.visited-btn.done { border-color: #34c759; color: #9ee6ae; }
.album-body.collapsed { display: none; }
.chunk-title { font-size: 1.1rem; opacity: 0.75; margin: 1rem 0 0.4rem; }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--thumb-min, 150px), 1fr));
  gap: 0.5rem;
}
body.large-thumbs { --thumb-min: 260px; }
.thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 0.4rem;
  cursor: pointer;
  background: #2c2c33;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.marked { outline: 4px solid #4a8cff; }
.thumb.marked::after {
  content: "\2713";
  position: absolute;
  top: 0.3rem;
  right: 0.3rem;
  background: #4a8cff;
  color: white;
  border-radius: 50%;
  width: 1.8rem;
  height: 1.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.floating-btn {
  position: fixed;
  bottom: 1.2rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.3rem;
  padding: 1rem 1.6rem;
  border-radius: 2rem;
  border: none;
  background: #34c759;
  color: white;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  cursor: pointer;
  z-index: 10;
}
.cancel-btn {
  bottom: auto;
  top: 1.2rem;
  background: #ff3b30;
  z-index: 25;
}

#lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}
#lightbox img {
  max-width: 92vw;
  max-height: 80vh;
  object-fit: contain;
}
.lb-btn {
  position: absolute;
  border: none;
  background: rgba(255,255,255,0.15);
  color: white;
  font-size: 1.5rem;
  border-radius: 50%;
  width: 3.2rem;
  height: 3.2rem;
  cursor: pointer;
}
.lb-close { top: 1rem; right: 1rem; }
.lb-prev { left: 1rem; top: 50%; transform: translateY(-50%); }
.lb-next { right: 1rem; top: 50%; transform: translateY(-50%); }
.lb-download {
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  width: auto;
  border-radius: 2rem;
  padding: 0 1.6rem;
  background: #34c759;
}

#voiceoverRecordBtn {
  font-size: 1.2rem;
  padding: 0.6rem 1.2rem;
  border-radius: 0.6rem;
  border: none;
  background: #ff5c5c;
  color: white;
  cursor: pointer;
}
#voiceoverListBtn {
  font-size: 1.2rem;
  padding: 0.6rem 1.2rem;
  border-radius: 0.6rem;
  border: none;
  background: #444;
  color: white;
  cursor: pointer;
}

#recordingBanner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: #ff2020;
  color: white;
  text-align: center;
  padding: 0.8rem 1rem;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  animation: story-pulse 1.6s infinite;
}
@keyframes story-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.75; }
}
#voiceoverStopBtn {
  font-size: 1rem;
  padding: 0.5rem 1.1rem;
  border-radius: 1.5rem;
  border: none;
  background: white;
  color: #ff2020;
  font-weight: 600;
  cursor: pointer;
  animation: none;
}

#voiceoverListModal {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.92);
  padding: 3rem 2rem;
  overflow-y: auto;
}
#voiceoverListModal h2 { margin-top: 0; }
#voiceoverListItems {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-width: 40rem;
}
.voiceover-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: #2c2c33;
  border-radius: 0.6rem;
  padding: 0.8rem 1.2rem;
}
.voiceover-item button {
  font-size: 1rem;
  padding: 0.5rem 1.1rem;
  border-radius: 1.5rem;
  border: none;
  background: #4a8cff;
  color: white;
  cursor: pointer;
  flex-shrink: 0;
}

#voiceoverPlayer {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
}
#voiceoverPlayerImageWrap {
  position: relative;
  max-width: 90vw;
  max-height: 75vh;
}
#voiceoverPlayerImg { max-width: 90vw; max-height: 75vh; object-fit: contain; display: block; }
#voiceoverPointerDot {
  position: absolute;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  background: rgba(255, 40, 40, 0.55);
  border: 3px solid #ff2020;
  transform: translate(-50%, -50%);
  pointer-events: none;
  transition: left 0.15s linear, top 0.15s linear;
}
#voiceoverPlayerAudio { width: 90vw; max-width: 40rem; }

#helpBtn {
  font-size: 1.2rem;
  padding: 0.6rem 1.2rem;
  border-radius: 0.6rem;
  border: none;
  background: #444;
  color: white;
  cursor: pointer;
}

#infoModal, #helpModal {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
#infoModalBox, #helpModalBox {
  position: relative;
  background: #26262c;
  border-radius: 1rem;
  padding: 2rem;
  max-width: 32rem;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
}
#infoModalBox h2, #helpModalBox h2 { margin-top: 0; }
#infoModalDontShowWrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 1rem 0;
  font-size: 1rem;
  opacity: 0.85;
}
#helpModalItems {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1rem;
}
#helpModalItems button {
  font-size: 1.05rem;
  padding: 0.7rem 1.1rem;
  border-radius: 0.6rem;
  border: none;
  background: #2c2c33;
  color: white;
  text-align: left;
  cursor: pointer;
}

#progress {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: #34c759;
  color: white;
  padding: 0.8rem 1.4rem;
  border-radius: 0.6rem;
  font-size: 1.2rem;
  z-index: 30;
}
