:root {
  --bg: #f2efe8;
  --bg-strong: #e7dfd1;
  --surface: rgba(255, 252, 246, 0.72);
  --surface-strong: rgba(255, 252, 246, 0.92);
  --text: #1d1a16;
  --muted: #5f5648;
  --line: rgba(29, 26, 22, 0.12);
  --accent: #b36a2e;
  --accent-deep: #784318;
  --accent-soft: rgba(179, 106, 46, 0.14);
  --shadow: 0 30px 80px rgba(68, 42, 16, 0.14);
  --font-body: "Manrope", sans-serif;
  --font-display: "Cormorant Garamond", serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(179, 106, 46, 0.18), transparent 32%),
    radial-gradient(circle at bottom right, rgba(120, 67, 24, 0.12), transparent 28%),
    linear-gradient(180deg, var(--bg), #f8f5ee 48%, var(--bg-strong));
}

body {
  min-height: 100vh;
  color: var(--text);
  font-family: var(--font-body);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.32;
  background-image:
    linear-gradient(rgba(29, 26, 22, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(29, 26, 22, 0.02) 1px, transparent 1px);
  background-size: 24px 24px;
}

.page-shell {
  position: relative;
  max-width: 1380px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 28px 24px 32px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 22px;
}

.app-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
}

.header-copy {
  max-width: 780px;
}

.back-link,
.download-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 18px;
  border-radius: 999px;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.back-link {
  color: var(--accent-deep);
  border: 1px solid var(--line);
  background: rgba(255, 252, 246, 0.74);
  margin-bottom: 16px;
}

.download-link {
  color: #fff8f1;
  background: linear-gradient(135deg, var(--accent) 0%, #d09152 52%, #a75923 100%);
  box-shadow:
    0 14px 40px rgba(167, 89, 35, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.eyebrow {
  margin-bottom: 10px;
  color: var(--accent-deep);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.title-row {
  display: grid;
  gap: 16px;
}

.title-row h1 {
  font-family: var(--font-display);
  font-size: clamp(3.2rem, 6vw, 5.8rem);
  line-height: 0.95;
  letter-spacing: -0.04em;
}

.header-lede {
  max-width: 54ch;
  color: var(--muted);
  line-height: 1.7;
  font-size: 1rem;
}

.header-actions {
  display: grid;
  gap: 14px;
  justify-items: end;
}

.locale-switcher {
  display: inline-flex;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 252, 246, 0.82);
  backdrop-filter: blur(18px);
}

.locale-button {
  background: transparent;
  border: none;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 800;
  padding: 0.8rem 1rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all 180ms ease;
}

.locale-button.is-active {
  background: var(--text);
  color: #f8f3eb;
}

.player-wrapper {
  display: block;
  min-height: 0;
}

.video-container {
  position: relative;
  width: 100%;
  min-height: min(74vh, 980px);
  aspect-ratio: 2992 / 1680;
  border-radius: 28px;
  overflow: hidden;
  background: #111;
  border: 1px solid rgba(29, 26, 22, 0.08);
  box-shadow: var(--shadow);
  cursor: grab;
}

.video-container:active {
  cursor: grabbing;
}

.frame-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: opacity 0.15s ease-out;
}

.frame-img.hidden,
.hidden {
  display: none !important;
}

.loader {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  z-index: 4;
  background: rgba(12, 10, 9, 0.36);
}

.spinner {
  width: 42px;
  height: 42px;
  border: 3px solid rgba(255, 248, 241, 0.14);
  border-top-color: #f5c28d;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loader span {
  color: rgba(255, 248, 241, 0.88);
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.viewer-overlay {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
  z-index: 3;
}

.frame-tag,
.action-hint,
.ctrl-btn,
.speed-selector {
  border: 1px solid var(--line);
  background: var(--surface);
  backdrop-filter: blur(18px);
}

.frame-tag,
.action-hint {
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  font-size: 0.75rem;
}

.frame-tag {
  color: var(--text);
  font-weight: 800;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.action-hint {
  color: var(--muted);
}

.controls-section {
  padding: 22px 24px;
  border-radius: 28px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.timeline-container {
  width: 100%;
  padding: 8px 0;
  cursor: pointer;
}

.timeline-track {
  position: relative;
  height: 8px;
  background: rgba(29, 26, 22, 0.08);
  border-radius: 9999px;
}

.timeline-progress {
  position: absolute;
  inset: 0 auto 0 0;
  height: 100%;
  background: linear-gradient(135deg, var(--accent) 0%, #d09152 100%);
  border-radius: 9999px;
  width: 0%;
}

.timeline-handle {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  left: 0%;
  width: 18px;
  height: 18px;
  background: #fff8f1;
  border: 3px solid var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 0 6px var(--accent-soft);
}

.control-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.left-controls,
.right-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.ctrl-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text);
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.ctrl-btn:hover,
.download-link:hover,
.back-link:hover {
  transform: translateY(-1px);
}

.ctrl-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.play-btn {
  background: linear-gradient(135deg, var(--accent) 0%, #d09152 52%, #a75923 100%);
  color: #fff8f1;
  border-color: transparent;
}

.center-controls {
  flex: 1;
  display: flex;
  justify-content: center;
}

.time-display {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.speed-selector {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  font-size: 0.8rem;
  color: var(--muted);
}

.speed-selector select {
  background: transparent;
  border: none;
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
  outline: none;
  font-family: var(--font-body);
}

@media (max-width: 1100px) {
  .app-header,
  .control-bar {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .app-header,
  .control-bar {
    align-items: stretch;
  }

  .header-actions {
    justify-items: start;
  }
  .viewer-overlay {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 720px) {
  .page-shell {
    padding: 18px 16px 24px;
  }

  .title-row h1 {
    font-size: clamp(2.8rem, 12vw, 4rem);
  }

  .controls-section {
    padding: 18px;
  }
}
