:root {
  --bg: #0d0d0d;
  --surface: #161616;
  --surface2: #222222;
  --border: #2a2a2a;
  --text: #f0f0f0;
  --text-muted: #777777;
  --text-dim: #444444;
  --accent: #f0f0f0;
  --cycle-label: #555555;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(circle at 20% 0%, #171717 0%, var(--bg) 45%);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-weight: 400;
  min-height: 100vh;
}

a {
  color: var(--text);
  text-decoration: none;
}

a:hover {
  color: var(--accent);
}

.hidden {
  display: none !important;
}

/* Lazy-load fade-in for timeline thumbnails */
.timeline-image img {
  opacity: 0;
  transition: opacity 0.4s ease;
}
.timeline-image img.loaded {
  opacity: 1;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 60;
  background: rgba(13, 13, 13, 0.95);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}

.nav-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0.9rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: relative;
}

.brand {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1rem;
  color: var(--accent);
  letter-spacing: 0.08em;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.site-nav a,
.nav-link-button,
.admin-trigger {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  background: none;
  border: 0;
  cursor: pointer;
  padding: 0;
}

.nav-link-button:hover,
.site-nav a:hover,
.admin-trigger:hover {
  color: var(--text);
}

.admin-inline-links {
  display: flex;
  align-items: center;
  gap: 1rem;
}

#admin-logout-form-inline {
  margin: 0;
}

.admin-trigger {
  color: var(--text);
}

.nav-toggle {
  display: none;
  background: none;
  border: 0;
  color: var(--text);
  font-size: 1.2rem;
}

.admin-dropdown {
  position: absolute;
  right: 1rem;
  top: 3.3rem;
  width: 240px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem;
  z-index: 80;
  display: grid;
  gap: 0.5rem;
}

.dropdown-action,
.dropdown-link,
.dropdown-select {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  border-radius: 4px;
  padding: 0.5rem 0.65rem;
  text-align: left;
  font-size: 0.8rem;
  cursor: pointer;
}

.dropdown-link {
  display: block;
}

.dropdown-label {
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-muted);
  font-size: 0.72rem;
  margin-top: 0.35rem;
}

.timeline-main,
.content-main {
  max-width: 1400px;
  margin: 1.4rem auto 3rem;
  padding: 0 1rem;
}

.loading-block {
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  margin: 0.8rem 0 1.2rem;
}

.timeline {
  display: grid;
  gap: 1rem;
}

.timeline-strip {
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 0.55rem;
  transition: filter 0.2s ease;
}

.timeline-strip:hover {
  filter: brightness(1.06);
}

.cycle-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: var(--cycle-label);
  margin-bottom: 0.4rem;
}

.timeline-images {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 2px;
}

.timeline-image {
  position: relative;
  aspect-ratio: 1;
  background: var(--surface2);
  border: 1px solid #1b1b1b;
  overflow: hidden;
  cursor: pointer;
}

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

.timeline-summary {
  margin: 0.45rem 0 0;
  color: var(--text-muted);
  font-size: 0.74rem;
  font-style: italic;
  line-height: 1.5;
}

.skeleton {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, #1c1c1c 0%, #2a2a2a 50%, #1c1c1c 100%);
  background-size: 200% 100%;
  animation: pulse 1.4s ease infinite;
}

@keyframes pulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.back-link {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.panel {
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 1rem;
}

.section-block {
  border: 1px solid var(--border);
  background: #121212;
  padding: 0.85rem;
  margin-top: 0.8rem;
  line-height: 1.65;
  white-space: pre-wrap;
}

.panel h1,
.panel h2,
.panel h3,
.about-content h1,
.about-content h2,
.modal-content h2 {
  font-weight: 300;
}

.image-container img {
  width: 100%;
  max-height: 72vh;
  object-fit: contain;
  background: #090909;
  border: 1px solid var(--border);
}

.cycle-fallback-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.5rem;
}

.cycle-fallback-grid img {
  width: 100%;
  display: block;
  background: #0b0b0b;
}

.logs-controls {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
  color: var(--text-muted);
  font-size: 0.82rem;
}

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

button,
.stack-form button,
.logs-controls button {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.52rem 0.75rem;
  border-radius: 4px;
  cursor: pointer;
}

button:hover {
  border-color: #444;
}

.stack-form {
  display: grid;
  gap: 0.6rem;
}

.stack-form input,
.stack-form textarea,
.stack-form select,
.dropdown-select {
  width: 100%;
  background: #111;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  padding: 0.58rem;
}

.stack-form textarea {
  resize: vertical;
}

.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 1100;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal.open {
  display: flex;
}

.modal-content {
  position: relative;
  width: min(480px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 1rem;
}

.modal-wide {
  width: min(720px, 100%);
}

.modal-close {
  position: absolute;
  right: 0.6rem;
  top: 0.6rem;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  padding: 0;
}

.modal-subtitle,
.muted {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.error-text {
  color: #ff8e8e;
  font-size: 0.8rem;
}

.status-panel {
  border: 1px solid var(--border);
  padding: 0.75rem;
  margin-bottom: 0.8rem;
}

.progress-bar {
  width: 100%;
  height: 10px;
  background: #111;
  border: 1px solid var(--border);
  margin: 0.5rem 0;
}

.progress-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
}

.versions-list {
  display: grid;
  gap: 0.4rem;
  margin-bottom: 0.8rem;
}

.version-item {
  border: 1px solid var(--border);
  background: #121212;
  padding: 0.5rem 0.6rem;
  font-size: 0.8rem;
}

.version-item-link {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  text-decoration: none;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.version-item-link:hover {
  background: #1c1c1c;
  border-color: #444;
}

.version-item-name {
  font-weight: 500;
}

.log-content {
  margin: 0;
  padding: 0.75rem;
  border: 1px solid var(--border);
  background: #0a0a0a;
  color: #cbcbcb;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  line-height: 1.5;
  white-space: pre-wrap;
  max-height: 400px;
  overflow: auto;
}

.login-page {
  background: #0d0d0d;
}

.login-main {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.login-card {
  width: min(380px, 100%);
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 1.2rem;
}

.login-brand {
  margin: 0;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.about-main {
  display: flex;
  justify-content: center;
  padding: 2rem 1rem 3rem;
}

.about-content {
  max-width: 680px;
  line-height: 1.8;
  color: var(--text);
}

.about-content h2 {
  margin-top: 2rem;
  margin-bottom: 0.5rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.06em;
}

.about-secondary {
  color: var(--text-muted);
}

.img-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 2000;
  flex-direction: column;
}

.img-modal.open {
  display: flex;
}

.img-modal-image-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#img-modal-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.img-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.4,0,0.2,1);
  overflow-y: auto;
  padding: 2rem;
  color: #f0f0f0;
  font-size: 0.9rem;
  line-height: 1.7;
}

.img-modal-overlay.visible {
  transform: translateY(0);
}

.img-modal-overlay-content {
  max-width: 900px;
  margin: 0 auto;
  white-space: pre-wrap;
}

.img-modal-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: #0d0d0d;
  border-top: 1px solid #222;
  flex-shrink: 0;
}

.img-overlay-btn {
  background: none;
  border: 1px solid #333;
  color: #aaa;
  padding: 0.4rem 0.9rem;
  border-radius: 3px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.2s;
  margin-left: 0.5rem;
}

.img-overlay-btn:hover,
.img-overlay-btn.active {
  border-color: #f0f0f0;
  color: #f0f0f0;
}

.img-modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(0, 0, 0, 0.5);
  border: none;
  color: #fff;
  font-size: 1.2rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  z-index: 10;
}

.img-modal-prev,
.img-modal-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.4);
  border: none;
  color: #fff;
  font-size: 2rem;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  cursor: pointer;
  z-index: 10;
}

.img-modal-prev {
  left: 1rem;
}

.img-modal-next {
  right: 1rem;
}

@media (max-width: 900px) {
  .site-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    background: #0f0f0f;
    padding: 1rem;
    flex-direction: column;
    align-items: flex-start;
  }

  .site-nav.open {
    display: flex;
  }

  .nav-toggle {
    display: block;
  }

  .admin-inline-links {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.7rem;
  }

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

  .img-modal-controls {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.7rem;
  }
}


/* Persistent cycle progress bar */
.cycle-progress-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #111;
  border-top: 1px solid var(--border);
  z-index: 900;
  padding: 0.6rem 1.5rem;
}
.cycle-progress-bar.hidden {
  display: none !important;
}
.cpb-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  max-width: 960px;
  margin: 0 auto;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.cpb-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4caf50;
  flex-shrink: 0;
  animation: cpb-pulse 1.5s infinite;
}
@keyframes cpb-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}
.cpb-count {
  white-space: nowrap;
  color: var(--text-muted);
  flex-shrink: 0;
}
.cpb-bar-wrap {
  flex: 1;
  height: 4px;
  background: var(--surface2);
  border-radius: 2px;
  overflow: hidden;
  min-width: 60px;
}
.cpb-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.4s ease;
  border-radius: 2px;
}
.cpb-stop {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  cursor: pointer;
  flex-shrink: 0;
}
.cpb-stop:hover { border-color: var(--text); color: var(--text); }

/* ─── Model badge (Feature: model tag per cycle) ─────────────────────────── */
.model-badge {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.1rem 0.45rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-family: monospace;
  font-size: 0.65rem;
  color: var(--text-muted);
  vertical-align: middle;
  line-height: 1.4;
  letter-spacing: 0.02em;
}

/* ─── Fork version button (Feature: fork from archived version) ──────────── */
.fork-version-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 1.25rem;
  padding: 0.45rem 1rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.fork-version-btn:hover {
  border-color: var(--accent, #888);
  background: #2a2a2a;
}
.fork-version-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Version Seed Viewer ─────────────────────────────────────────────────── */

.seed-text {
  background: #0a0a0a;
  border: 1px solid var(--border);
  padding: 0.75rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  white-space: pre-wrap;
  overflow-x: auto;
  color: #cbcbcb;
  border-radius: 4px;
  margin: 0;
}

.seeds-section {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.seeds-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.seeds-modal-content {
  width: min(760px, 100%);
}

.seeds-modal-body {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

/* ── Version list row with seeds button ─────────────────────────────────── */

.version-item-row {
  display: flex;
  align-items: stretch;
  gap: 0;
  border: 1px solid var(--border);
  background: #121212;
  font-size: 0.8rem;
}

.version-item-link-inline {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  text-decoration: none;
  color: var(--text);
  cursor: pointer;
  padding: 0.5rem 0.6rem;
  transition: background 0.15s, border-color 0.15s;
}

.version-item-link-inline:hover {
  background: #1c1c1c;
}

.seeds-btn {
  padding: 0.3rem 0.6rem;
  font-size: 0.7rem;
  background: #1a1a1a;
  border: none;
  border-left: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  align-self: center;
  margin: 0.3rem 0.4rem;
  border-radius: 3px;
}

.seeds-btn:hover {
  background: #2a2a2a;
  color: var(--text);
}

/* ── Create version form ─────────────────────────────────────────────────── */

.version-create-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.75rem;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.btn-secondary:hover {
  background: var(--surface2);
  color: var(--text);
}

/* ── Header seeds button (archived pages) ───────────────────────────────── */

.header-seeds-btn {
  font-size: 0.75rem;
  padding: 0.3rem 0.6rem;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 3px;
  background: transparent;
  cursor: pointer;
}

.header-seeds-btn:hover {
  color: var(--text);
  background: var(--surface2);
}
