:root {
  --sv-bg: #121214;
  --sv-panel: #1a1a1d;
  --sv-line: #2a2a2e;
  --sv-text: #ececef;
  --sv-muted: #8b8b93;
  --sv-accent: #7c3aed;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--sv-bg);
  color: var(--sv-text);
  font-family: "Manrope", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--sv-text); }

.viewer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1.1rem clamp(1rem, 4vw, 2.5rem) 0.9rem;
  border-bottom: 1px solid var(--sv-line);
}

.back-link {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--sv-muted);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
  transition: color 0.15s ease;
}

.back-link:hover { color: var(--sv-text); text-decoration: none; }

.viewer-heading { text-align: right; }

.viewer-heading h1 {
  margin: 0;
  font-family: "Space Grotesk", ui-sans-serif, sans-serif;
  font-weight: 600;
  font-size: clamp(1rem, 2vw, 1.25rem);
  color: var(--sv-text);
}

.deck-title {
  margin: 0.2rem 0 0;
  color: var(--sv-muted);
  font-size: 0.85rem;
}

.deck-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.9rem clamp(1rem, 4vw, 2.5rem);
  border-bottom: 1px solid var(--sv-line);
}

.deck-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 650;
  color: var(--sv-muted);
  background: var(--sv-panel);
  border: 1px solid var(--sv-line);
  border-radius: 9px;
  padding: 0.55rem 1.05rem;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.deck-tab-num {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--sv-muted);
  background: rgba(255, 255, 255, 0.07);
  border-radius: 5px;
  padding: 0.15rem 0.4rem;
}

.deck-tab:hover {
  color: var(--sv-text);
  border-color: #3a3a40;
}

.deck-tab.active {
  color: #18181b;
  border-color: var(--sv-text);
  background: var(--sv-text);
}

.deck-tab.active .deck-tab-num {
  color: #18181b;
  background: rgba(24, 24, 27, 0.12);
}

.viewer-stage {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(0.5rem, 2vw, 1.5rem);
  padding: 1.5rem clamp(0.5rem, 3vw, 2rem);
  min-height: 0;
}

.slide-frame {
  position: relative;
  width: min(100%, 1400px, calc(70vh * 16 / 9));
  max-height: 70vh;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--sv-line);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}

.slide-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #000;
}

.nav-arrow {
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--sv-line);
  background: var(--sv-panel);
  color: var(--sv-text);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.nav-arrow:hover:not(:disabled) {
  border-color: var(--sv-accent);
  background: #201a33;
  color: #fff;
}

.nav-arrow:disabled {
  opacity: 0.3;
  cursor: default;
}

.viewer-controls {
  padding: 0.9rem clamp(1rem, 4vw, 2.5rem) calc(1.1rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--sv-line);
}

.progress-bar {
  height: 3px;
  border-radius: 999px;
  background: var(--sv-line);
  overflow: hidden;
  margin-bottom: 0.65rem;
}

.progress-fill {
  height: 100%;
  background: var(--sv-accent);
  width: 0%;
  transition: width 0.2s ease;
}

.viewer-meta {
  display: flex;
  justify-content: center;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.78rem;
  color: var(--sv-muted);
}

@media (prefers-reduced-motion: reduce) {
  .progress-fill, .nav-arrow, .slide-thumb img { transition: none; }
}

@media (max-width: 720px) {
  .viewer-top { flex-direction: column; align-items: flex-start; }
  .viewer-heading { text-align: left; }
  .deck-tabs { gap: 1rem; }
  .viewer-stage { gap: 0.4rem; }
  .nav-arrow { width: 36px; height: 36px; font-size: 1.05rem; }
  .slide-frame { max-height: 42vh; }
}
