@import url('https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=JetBrains+Mono:wght@400;500;600&family=Sora:wght@300;400;500;600&display=swap');

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

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: #ffffff;
  color: #000000;
  font-family: 'Sora', Arial, sans-serif;
}

.screenplay-viewer {
  --sp-ink: #000000;
  --sp-paper: #ffffff;
  --sp-gray: #ebebeb;
  --sp-muted: #555555;
  --sp-accent: #c77dcd;
  --sp-border: 3px solid #000000;
  --sp-mono: 'JetBrains Mono', 'Courier New', monospace;
  --sp-serif: 'Instrument Serif', Georgia, serif;
  --sp-sans: 'Sora', Arial, sans-serif;

  display: flex;
  flex-direction: column;
  height: 100dvh;
  background: var(--sp-paper);
  color: var(--sp-ink);
  font-family: var(--sp-sans);
  overflow: hidden;
}

.sp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border-bottom: var(--sp-border);
  flex-shrink: 0;
  gap: 12px;
}

.sp-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.sp-scene-id {
  font-family: var(--sp-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--sp-ink);
  color: var(--sp-paper);
  padding: 3px 8px;
  flex-shrink: 0;
}

.sp-scene-title {
  font-family: var(--sp-serif);
  font-size: clamp(14px, 2.5vw, 20px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sp-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.sp-counter {
  font-family: var(--sp-mono);
  font-size: 11px;
  color: var(--sp-muted);
  letter-spacing: 0.05em;
}

.sp-btn {
  font-family: var(--sp-mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: #ffffff;
  color: #000000;
  border: 2px solid #000000;
  padding: 6px 14px;
  cursor: pointer;
  user-select: none;
}

.sp-btn:hover {
  background: var(--sp-accent);
  color: var(--sp-ink);
}

.sp-btn:active {
  background: var(--sp-accent);
  transform: translate(1px, 1px);
}

.sp-btn-sm {
  font-size: 10px;
  padding: 4px 10px;
}

.sp-btn-dark {
  background: #000000;
  color: #ffffff;
}

.sp-main {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

.sp-image-container {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--sp-ink);
  cursor: pointer;
  min-width: 0;
}

/* Adapted for background-image divs (not <img> tags) */
.sp-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  user-select: none;
  pointer-events: none;
}

.sp-image-prev {
  z-index: 1;
}

.sp-caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 32px 16px 10px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.85));
  pointer-events: none;
  z-index: 2;
}

.sp-caption-toggle {
  background: none;
  border: none;
  color: var(--sp-accent);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  pointer-events: auto;
  font-family: var(--sp-mono);
}

.sp-caption-toggle:hover {
  color: #fff;
}

.sp-caption-text {
  font-family: var(--sp-mono);
  font-size: clamp(10px, 1.5vw, 13px);
  line-height: 1.5;
  color: var(--sp-paper);
}

.sp-text-panel {
  width: 360px;
  flex-shrink: 0;
  border-left: var(--sp-border);
  background: var(--sp-paper);
  overflow-y: auto;
  padding: 20px;
  z-index: 5;
}

@media (max-width: 768px) {
  .sp-text-panel {
    position: absolute;
    inset: 0;
    width: 100%;
    z-index: 10;
    border-left: none;
  }
  .sp-main {
    position: relative;
  }
}

.sp-text-content {
  font-family: var(--sp-sans);
  font-size: 13px;
  line-height: 1.7;
  color: var(--sp-ink);
}

.sp-text-content p {
  margin-bottom: 12px;
}

.sp-text-content strong {
  font-family: var(--sp-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--sp-accent);
}

.sp-text-content blockquote {
  border-left: 3px solid var(--sp-accent);
  padding-left: 12px;
  margin: 8px 0;
  font-style: italic;
  color: var(--sp-muted);
}

@keyframes sp-fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}
@keyframes sp-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes sp-slide-out-left {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(-100%); opacity: 0; }
}
@keyframes sp-slide-in-right {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.sp-tx-crossfade-exit {
  animation: sp-fade-out var(--sp-transition-duration, 300ms) ease-in-out forwards;
}
.sp-tx-crossfade-enter {
  animation: sp-fade-in var(--sp-transition-duration, 300ms) ease-in-out forwards;
}
.sp-tx-slide-left-exit {
  animation: sp-slide-out-left var(--sp-transition-duration, 300ms) ease-in-out forwards;
}
.sp-tx-slide-left-enter {
  animation: sp-slide-in-right var(--sp-transition-duration, 300ms) ease-in-out forwards;
}
.sp-tx-fade-to-black-exit {
  animation: sp-fade-out calc(var(--sp-transition-duration, 400ms) / 2) ease-in forwards;
}
.sp-tx-fade-to-black-enter {
  animation: sp-fade-in calc(var(--sp-transition-duration, 400ms) / 2) ease-out forwards;
  animation-delay: calc(var(--sp-transition-duration, 400ms) / 2);
  opacity: 0;
}
.sp-tx-none-exit,
.sp-tx-none-enter {
  animation: none;
}

.sp-nav {
  flex-shrink: 0;
  border-top: var(--sp-border);
  background: var(--sp-paper);
}

.sp-nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  gap: 12px;
}

.sp-scene-dots {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.sp-dot {
  width: 10px;
  height: 10px;
  border: 2px solid var(--sp-ink);
  background: transparent;
  padding: 0;
  cursor: pointer;
}

.sp-dot-active {
  background: var(--sp-accent);
  border-color: var(--sp-accent);
}

.sp-dot:hover {
  background: var(--sp-ink);
}

.sp-progress-bar {
  height: 3px;
  background: var(--sp-gray);
  width: 100%;
}

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

.sp-footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px 8px;
  border-top: 1px solid var(--sp-gray);
}

.sp-act-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.sp-act-name {
  font-family: var(--sp-serif);
  font-size: 14px;
  font-style: italic;
}

.sp-act-subtitle {
  font-family: var(--sp-mono);
  font-size: 10px;
  color: var(--sp-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
