:root {
  --paper-bg: #faf6ee;
  --paper-warm: #f3ecde;
  --ink-primary: #26231e;
  --ink-secondary: #595247;
  --ink-muted: #8a8070;
  --accent-blue: #2f6db0;
  --accent-coral: #d45b4a;
  --accent-green: #388862;
  --accent-amber: #c98624;
  --accent-violet: #7b52a0;
  --dock-bg: rgba(250, 246, 238, 0.86);
  --dock-border: rgba(38, 35, 30, 0.12);
  --shadow-soft: 0 10px 30px rgba(38, 35, 30, 0.08), 0 2px 6px rgba(38, 35, 30, 0.04);
}

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

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--paper-bg);
  color: var(--ink-primary);
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

.app-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 32% 45%, rgba(255, 253, 248, 0.92) 0%, rgba(247, 240, 226, 0.7) 58%, rgba(238, 229, 212, 0.88) 100%);
}

#stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* Top-left Title & Fancy Subtitle */
.title-block {
  position: absolute;
  top: 26px;
  left: 34px;
  z-index: 10;
  pointer-events: none;
  max-width: 48vw;
}

.main-title {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  font-size: clamp(1.55rem, 2.25vw, 2.25rem);
  letter-spacing: -0.02em;
  line-height: 1.08;
  color: var(--ink-primary);
}

.fancy-subtitle {
  margin-top: 5px;
  font-family: 'Fraunces', Georgia, serif;
  font-style: italic;
  font-weight: 400;
  font-size: clamp(0.88rem, 1.08vw, 1.04rem);
  color: var(--ink-secondary);
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.subtitle-ornament {
  font-family: 'Caveat', cursive;
  font-style: normal;
  font-size: 1.25em;
  color: var(--accent-coral);
  opacity: 0.85;
}

/* Right-side Calm Narration — no heavy boxes, gently fades in/out */
.narration-panel {
  position: absolute;
  top: 50%;
  right: clamp(28px, 3.8vw, 64px);
  transform: translateY(-54%);
  width: clamp(270px, 24vw, 370px);
  z-index: 10;
  pointer-events: none;
  padding: 18px 8px 18px 24px;
  background: linear-gradient(
    90deg,
    rgba(250, 246, 238, 0) 0%,
    rgba(250, 246, 238, 0.72) 18%,
    rgba(250, 246, 238, 0.88) 100%
  );
  border-radius: 14px;
}

.narration-chapter-tag {
  font-family: 'Caveat', cursive;
  font-size: 1.18rem;
  font-weight: 600;
  color: var(--accent-blue);
  letter-spacing: 0.02em;
  margin-bottom: 6px;
  opacity: 0.92;
  transition: opacity 0.65s ease, transform 0.65s ease;
}

.narration-content {
  transition: opacity 0.7s cubic-bezier(0.25, 0.8, 0.25, 1),
              transform 0.7s cubic-bezier(0.25, 0.8, 0.25, 1);
  opacity: 1;
  transform: translateY(0);
}

.narration-content.is-fading {
  opacity: 0;
  transform: translateY(8px);
}

.narration-heading {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  font-size: clamp(1.15rem, 1.45vw, 1.48rem);
  line-height: 1.24;
  color: var(--ink-primary);
  margin-bottom: 12px;
}

.narration-body {
  font-size: clamp(0.9rem, 1.02vw, 1.02rem);
  line-height: 1.64;
  color: var(--ink-secondary);
  font-weight: 400;
}

.narration-note {
  margin-top: 14px;
  font-family: 'Caveat', cursive;
  font-size: clamp(1.12rem, 1.32vw, 1.32rem);
  line-height: 1.35;
  color: var(--ink-primary);
  opacity: 0.88;
}

/* Bottom-center Video Player & Chapter Selector */
.player-dock {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  width: min(680px, calc(100vw - 44px));
  background: var(--dock-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--dock-border);
  border-radius: 18px;
  padding: 10px 16px 10px;
  box-shadow: var(--shadow-soft);
}

.player-timeline-wrap {
  position: relative;
  padding: 7px 2px 9px;
  cursor: pointer;
}

.timeline-track {
  position: relative;
  height: 5px;
  background: rgba(38, 35, 30, 0.13);
  border-radius: 99px;
  transition: height 0.16s ease;
}

.player-timeline-wrap:hover .timeline-track {
  height: 7px;
}

.timeline-progress {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-coral));
  border-radius: 99px;
  pointer-events: none;
}

.timeline-markers {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.timeline-marker {
  position: absolute;
  top: -1px;
  bottom: -1px;
  width: 2px;
  background: rgba(250, 246, 238, 0.9);
  transform: translateX(-1px);
}

.timeline-thumb {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--ink-primary);
  border: 2px solid var(--paper-bg);
  transform: translate(-50%, -50%) scale(0.85);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.22);
  transition: transform 0.15s ease;
  pointer-events: none;
}

.player-timeline-wrap:hover .timeline-thumb {
  transform: translate(-50%, -50%) scale(1.1);
}

.timeline-tooltip {
  position: absolute;
  bottom: 24px;
  left: 0;
  transform: translateX(-50%);
  background: var(--ink-primary);
  color: var(--paper-bg);
  font-size: 0.74rem;
  font-weight: 500;
  padding: 4px 9px;
  border-radius: 7px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.timeline-tooltip.visible {
  opacity: 1;
}

.player-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

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

.controls-center {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-width: 0;
}

.ctrl-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--ink-primary);
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.16s ease, transform 0.12s ease;
}

.ctrl-btn:hover {
  background: rgba(38, 35, 30, 0.08);
}

.ctrl-btn:active {
  transform: scale(0.94);
}

.ctrl-play {
  background: var(--ink-primary);
  color: var(--paper-bg);
  width: 36px;
  height: 36px;
  border-radius: 50%;
}

.ctrl-play:hover {
  background: #3d3830;
}

.ctrl-speed {
  width: auto;
  padding: 0 9px;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--ink-secondary);
}

.time-readout {
  margin-left: 6px;
  font-size: 0.77rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink-muted);
  white-space: nowrap;
}

.chapter-pill {
  appearance: none;
  border: 1px solid rgba(38, 35, 30, 0.12);
  background: rgba(255, 253, 248, 0.72);
  color: var(--ink-primary);
  padding: 5px 12px;
  border-radius: 99px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.82rem;
  max-width: 100%;
  transition: background-color 0.16s ease, border-color 0.16s ease;
}

.chapter-pill:hover {
  background: rgba(255, 253, 248, 0.96);
  border-color: rgba(38, 35, 30, 0.22);
}

.chapter-pill-index {
  font-weight: 600;
  color: var(--accent-blue);
  font-size: 0.75rem;
}

.chapter-pill-title {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chapter-pill .chevron {
  flex-shrink: 0;
  color: var(--ink-muted);
  transition: transform 0.2s ease;
}

.chapter-pill[aria-expanded="true"] .chevron {
  transform: rotate(180deg);
}

.chapter-popover {
  position: absolute;
  bottom: calc(100% + 14px);
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  width: 310px;
  max-height: 62vh;
  overflow-y: auto;
  background: rgba(251, 248, 241, 0.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(38, 35, 30, 0.14);
  border-radius: 14px;
  padding: 6px;
  box-shadow: 0 16px 40px rgba(38, 35, 30, 0.14);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.chapter-popover.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.chapter-item {
  width: 100%;
  appearance: none;
  border: none;
  background: transparent;
  text-align: left;
  padding: 8px 10px;
  border-radius: 9px;
  display: flex;
  align-items: baseline;
  gap: 10px;
  cursor: pointer;
  font-family: inherit;
  color: var(--ink-primary);
  transition: background-color 0.14s ease;
}

.chapter-item:hover {
  background: rgba(38, 35, 30, 0.06);
}

.chapter-item.active {
  background: rgba(47, 109, 176, 0.11);
}

.chapter-item-num {
  font-family: 'Caveat', cursive;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent-blue);
  width: 22px;
  flex-shrink: 0;
}

.chapter-item-name {
  font-size: 0.84rem;
  font-weight: 500;
  flex: 1;
}

.chapter-item-dur {
  font-size: 0.72rem;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

/* Bottom-right UiO source footer */
.source-footer {
  position: absolute;
  bottom: 14px;
  right: 22px;
  z-index: 15;
  font-size: 0.73rem;
  color: var(--ink-muted);
  letter-spacing: 0.01em;
}

.source-footer a {
  color: var(--ink-secondary);
  text-decoration: none;
  border-bottom: 1px dotted rgba(89, 82, 71, 0.5);
  transition: color 0.15s ease, border-color 0.15s ease;
}

.source-footer a:hover {
  color: var(--accent-blue);
  border-color: var(--accent-blue);
}

/* Responsive adjustments for smaller viewports */
@media (max-width: 1120px) {
  .narration-panel {
    width: 260px;
    right: 18px;
  }
  .source-footer {
    bottom: 6px;
    right: 14px;
    font-size: 0.68rem;
  }
  .player-dock {
    bottom: 30px;
  }
}

@media (max-width: 820px) {
  .narration-panel {
    top: auto;
    bottom: 108px;
    right: 16px;
    left: 16px;
    width: auto;
    transform: none;
    padding: 12px 16px;
    background: rgba(250, 246, 238, 0.86);
  }
}
