:root {
  --paper: #f4efe6;
  --paper-deep: #ebe3d3;
  --card: #fbf8f2;
  --ink: #171614;
  --muted: rgba(23, 22, 20, 0.54);
  --faint: rgba(23, 22, 20, 0.28);
  --line: rgba(23, 22, 20, 0.11);
  --line-strong: rgba(23, 22, 20, 0.24);
  --accent: #d65a38;
  --font-serif: "Instrument Serif", Georgia, serif;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: radial-gradient(circle at 50% 38%, #f8f4ec 0%, var(--paper) 62%, var(--paper-deep) 100%);
  color: var(--ink);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.ambient-grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.28;
  background-image: radial-gradient(rgba(23, 22, 20, 0.06) 1px, transparent 0);
  background-size: 20px 20px;
  z-index: 0;
}

/* Top Whisper Bar */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  padding: 0 clamp(16px, 3vw, 28px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 20;
  pointer-events: none;
}

.topbar > * {
  pointer-events: auto;
}

.brand-reset {
  appearance: none;
  background: transparent;
  border: 0;
  padding: 6px 8px;
  margin-left: -8px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: -0.02em;
  cursor: pointer;
  opacity: 0.85;
  transition: opacity 0.18s ease;
}

.brand-reset:hover {
  opacity: 1;
}

.brand-dot {
  color: var(--accent);
  margin: 0 2px;
}

.active-domain-whisper {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  background: rgba(251, 248, 242, 0.72);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  padding: 5px 12px;
  border-radius: 999px;
}

.whisper-sep {
  opacity: 0.45;
}

.info-trigger {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: rgba(251, 248, 242, 0.72);
  backdrop-filter: blur(8px);
  color: var(--ink);
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 15px;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.info-trigger:hover {
  transform: scale(1.05);
  border-color: var(--ink);
  background: var(--card);
}

/* Main Full-Viewport Stage */
.viewport {
  position: relative;
  z-index: 1;
  height: 100dvh;
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 56px clamp(14px, 3vw, 32px) 16px;
}

/* Entry Stage */
.entry-stage {
  width: min(560px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  animation: fadeRise 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.entry-heading {
  margin: 0 0 24px;
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: clamp(32px, 5vw, 46px);
  line-height: 1.08;
  letter-spacing: -0.015em;
  text-wrap: balance;
  color: var(--ink);
}

.url-capsule {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 7px 7px 7px 18px;
  box-shadow:
    0 12px 34px rgba(23, 22, 20, 0.06),
    0 1px 0 rgba(255, 255, 255, 0.8) inset;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.url-capsule:focus-within {
  border-color: rgba(23, 22, 20, 0.48);
  box-shadow:
    0 16px 40px rgba(23, 22, 20, 0.09),
    0 0 0 4px rgba(23, 22, 20, 0.04);
}

.capsule-icon {
  color: var(--muted);
  flex-shrink: 0;
}

.url-input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 15px;
  letter-spacing: -0.01em;
}

.url-input::placeholder {
  color: var(--faint);
}

.capsule-go {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 0;
  background: var(--ink);
  color: var(--card);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.16s ease, opacity 0.16s ease;
}

.capsule-go:hover {
  transform: translateX(1px) scale(1.03);
}

.capsule-go:active {
  transform: scale(0.97);
}

.preset-row {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.preset-chip {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(251, 248, 242, 0.55);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11.5px;
  padding: 5px 11px;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.preset-chip:hover {
  color: var(--ink);
  border-color: var(--line-strong);
  background: var(--card);
}

.entry-error {
  margin: 14px 0 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: #b53d20;
}

/* Studio Stage */
.studio-stage {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  justify-items: center;
  animation: fadeRise 0.38s cubic-bezier(0.22, 1, 0.36, 1);
}

.projection-shell {
  width: min(960px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 0;
}

.projection-frame {
  position: relative;
  width: min(100%, calc((100dvh - 215px) * 16 / 9));
  aspect-ratio: 16 / 9;
  border-radius: 14px;
  overflow: hidden;
  background: #efe9dc;
  border: 1px solid var(--line-strong);
  box-shadow:
    0 24px 60px rgba(23, 22, 20, 0.11),
    0 2px 8px rgba(23, 22, 20, 0.05);
}

#preview-canvas,
#reel-video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: #efe9dc;
}

.wayback-badge {
  position: absolute;
  bottom: 12px;
  right: 14px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(23, 22, 20, 0.76);
  backdrop-filter: blur(6px);
  color: #f8f4ec;
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-decoration: none;
  letter-spacing: 0.02em;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.projection-frame:hover .wayback-badge {
  opacity: 1;
}

/* Control Bar */
.control-bar {
  width: min(100%, calc((100dvh - 215px) * 16 / 9));
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.status-cluster {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.status-dot.is-busy {
  animation: pulseDot 1.1s ease-in-out infinite;
}

.status-dot.is-ready {
  background: #2f6f4e;
  animation: none;
}

.status-text {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.action-cluster {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.pace-group {
  display: inline-flex;
  align-items: center;
  padding: 2px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(251, 248, 242, 0.65);
}

.pace-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.pace-btn.is-active {
  background: var(--ink);
  color: var(--card);
}

.ghost-pill,
.primary-pill {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.14s ease, background 0.14s ease, opacity 0.14s ease;
}

.ghost-pill {
  background: rgba(251, 248, 242, 0.72);
  border: 1px solid var(--line-strong);
  color: var(--ink);
}

.ghost-pill:hover:not(:disabled) {
  background: var(--card);
  border-color: var(--ink);
}

.ghost-pill:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.primary-pill {
  background: var(--ink);
  border: 1px solid var(--ink);
  color: var(--card);
  font-weight: 500;
}

.primary-pill:hover {
  transform: translateY(-1px);
}

/* Filmstrip */
.filmstrip-wrap {
  width: min(1040px, 100%);
  min-width: 0;
  padding-bottom: 2px;
}

.filmstrip {
  display: flex;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: 100%;
  margin: 0 auto;
  overflow-x: auto;
  padding: 6px 4px 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(23, 22, 20, 0.2) transparent;
}

.filmstrip::-webkit-scrollbar {
  height: 5px;
}

.filmstrip::-webkit-scrollbar-thumb {
  background: rgba(23, 22, 20, 0.18);
  border-radius: 999px;
}

.year-tile {
  position: relative;
  flex: 0 0 88px;
  height: 64px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(251, 248, 242, 0.65);
  overflow: hidden;
  cursor: pointer;
  padding: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  transition: transform 0.16s ease, border-color 0.16s ease, opacity 0.2s ease, box-shadow 0.16s ease;
}

.year-tile:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
}

.year-tile.is-selected {
  border-color: var(--ink);
  box-shadow: 0 0 0 1.5px var(--ink);
}

.year-tile.is-loading::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(23, 22, 20, 0.06), transparent);
  animation: shimmer 1.4s infinite;
}

.year-tile.is-excluded,
.year-tile.is-failed {
  opacity: 0.36;
  filter: grayscale(1);
}

.tile-thumb {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  opacity: 0;
  transition: opacity 0.28s ease;
}

.year-tile.is-loaded .tile-thumb {
  opacity: 1;
}

.tile-label {
  position: relative;
  z-index: 2;
  width: 100%;
  padding: 12px 6px 4px;
  background: linear-gradient(to top, rgba(23, 22, 20, 0.78), transparent);
  color: #fbf8f2;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  text-align: left;
  font-variant-numeric: tabular-nums;
}

.year-tile:not(.is-loaded) .tile-label {
  background: none;
  color: var(--muted);
}

.tile-toggle {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 3;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 0;
  background: rgba(23, 22, 20, 0.68);
  color: #fbf8f2;
  display: grid;
  place-items: center;
  opacity: 0;
  cursor: pointer;
  padding: 0;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.year-tile:hover .tile-toggle,
.year-tile.is-excluded .tile-toggle {
  opacity: 1;
}

.tile-toggle:hover {
  background: var(--accent);
}

/* Info Modal */
.info-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(23, 22, 20, 0.28);
  backdrop-filter: blur(5px);
  display: grid;
  place-items: center;
  padding: 20px;
}

.info-sheet {
  width: min(440px, 100%);
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  padding: 22px 24px;
  box-shadow: 0 24px 64px rgba(23, 22, 20, 0.16);
  animation: fadeRise 0.22s ease;
}

.info-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.info-head h2 {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
}

.info-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.info-body {
  margin: 0 0 12px;
  font-size: 13.5px;
  line-height: 1.55;
  color: rgba(23, 22, 20, 0.82);
}

.info-list {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
}

.info-list li + li {
  margin-top: 6px;
}

.info-sheet code {
  font-family: var(--font-mono);
  font-size: 11.5px;
  background: rgba(23, 22, 20, 0.06);
  padding: 1px 5px;
  border-radius: 4px;
}

@keyframes fadeRise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulseDot {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.35;
    transform: scale(0.82);
  }
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

/* Mobile Responsive Adjustments */
@media (max-width: 680px) {
  .viewport {
    padding: 54px 12px 12px;
  }

  .active-domain-whisper {
    display: none;
  }

  .projection-frame,
  .control-bar {
    width: 100%;
  }

  .control-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .action-cluster {
    justify-content: space-between;
  }

  .year-tile {
    flex: 0 0 74px;
    height: 54px;
  }
}
