:root {
  --paper: #eee6d5;
  --paper-fallback: #eee6d5;
  --ink: rgba(31, 30, 28, 0.82);
  --ink-soft: #847c75;
  --red: #dc6e66;
  --red-strong: #d65f57;
  --line-grey: #c9c1b8;

  --font-display: "Playfair", serif;
  --font-ui: "Zalando Sans SemiExpanded", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;

  --tile-size: 320px;
  --print-filter: url(#printOffsetFilter);

  --video-frame-line: 1.4px;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);

  --ui-edge-gap: 22px;

  --app-vw: 100vw;
  --app-vh: 100vh;

  --mobile-fs-ui-bottom: calc(18px + var(--safe-bottom));

  --title-main-center-offset: 88px;
  --title-meta-center-offset: 92px;

  --video-side-padding: 95px;
  --video-top-clearance: calc(86px + var(--safe-top));
  --video-bottom-clearance: calc(112px + var(--safe-bottom));

  --video-width: min(
    1110px,
    calc(100vw - (var(--video-side-padding) * 2)),
    calc((var(--app-vh) - var(--video-top-clearance) - var(--video-bottom-clearance)) * 16 / 9)
  );
}

#global-print-filter-svg {
  position: absolute;
  width: 0;
  height: 0;
  pointer-events: none;
  overflow: hidden;
}

html {
  -webkit-text-size-adjust: 100%;
}

html.app-is-loading body {
  overflow: hidden;
}

html.app-is-loading #app {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

html.app-is-ready #app {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  width: 100%;
  min-width: 100%;
  height: 100%;
  min-height: 100%;
  overflow: hidden;
  background: var(--paper-fallback);
  color: var(--ink);
  touch-action: manipulation;
  overscroll-behavior: none;
}

body {
  font-family: var(--font-ui);
}

button,
a,
iframe {
  font: inherit;
}

button {
  appearance: none;
  -webkit-appearance: none;
}

a {
  color: inherit;
  text-decoration: none;
}

#app {
  position: fixed;
  inset: 0;
  width: 100vw;
  width: 100dvw;
  min-width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--paper-fallback);
  filter: sepia(0.12) saturate(1.04) hue-rotate(-4deg) brightness(1.005);
}

/* Randfüllender Hintergrund */
#app::before {
  content: "";
  position: fixed;
  top: -50vmax;
  right: -50vmax;
  bottom: -50vmax;
  left: -50vmax;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(0deg, rgba(255,255,255,0.035), rgba(0,0,0,0.018)),
    linear-gradient(45deg, rgba(255,255,255,0.04), rgba(0,0,0,0.02)),
    url("assets/background/paper-texture2.jpg");
  background-repeat: repeat, repeat, repeat;
  background-size:
    100% 100%,
    100% 100%,
    var(--tile-size) var(--tile-size);
  background-position:
    center center,
    center center,
    0 0;
  opacity: 0.98;
}

#app::after {
  content: "";
  position: fixed;
  top: -50vmax;
  right: -50vmax;
  bottom: -50vmax;
  left: -50vmax;
  z-index: 0;
  pointer-events: none;
  opacity: 0.1;
  background:
    radial-gradient(circle at 20% 25%, rgba(255,255,255,0.22) 0 1px, transparent 2px),
    radial-gradient(circle at 68% 58%, rgba(0,0,0,0.05) 0 1px, transparent 2px),
    radial-gradient(circle at 42% 78%, rgba(255,255,255,0.12) 0 1px, transparent 2px);
  background-size: 180px 180px, 240px 240px, 160px 160px;
  mix-blend-mode: multiply;
}

#viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: transparent;
  z-index: 1;
}

#world {
  position: absolute;
  width: 8800px;
  height: 3000px;
  transform-origin: top left;
  will-change: transform;
}

#paper-background {
  position: absolute;
  z-index: 0;
  pointer-events: none;
  left: -4600px;
  top: -4600px;
  width: calc(8800px + 9200px);
  height: calc(3000px + 9200px);
  background-image:
    linear-gradient(0deg, rgba(255,255,255,0.035), rgba(0,0,0,0.018)),
    linear-gradient(45deg, rgba(255,255,255,0.04), rgba(0,0,0,0.02)),
    url("assets/background/paper-texture2.jpg");
  background-repeat: repeat, repeat, repeat;
  background-size:
    100% 100%,
    100% 100%,
    var(--tile-size) var(--tile-size);
  background-position:
    center center,
    center center,
    0 0;
  opacity: 0.98;
}

#paper-background::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.1;
  background:
    radial-gradient(circle at 20% 25%, rgba(255,255,255,0.22) 0 1px, transparent 2px),
    radial-gradient(circle at 68% 58%, rgba(0,0,0,0.05) 0 1px, transparent 2px),
    radial-gradient(circle at 42% 78%, rgba(255,255,255,0.12) 0 1px, transparent 2px);
  background-size: 180px 180px, 240px 240px, 160px 160px;
  mix-blend-mode: multiply;
}

/* Print-/Grain-/Versatz-Effekt
   überall außer Video und Hintergrund */
.title-chapter,
.title-chapter *,
.end-chapter,
.end-chapter *,
.video-chapter .chapter-action-slot,
.video-chapter .chapter-action-slot *,
.chapter-video-frame::before,
#top-ui,
#top-ui *,
#bottom-ui,
#bottom-ui *,
#chapterNav,
#chapterNav * {
  filter: var(--print-filter);
}

.chapter {
  position: absolute;
  transform: translate(-50%, -50%);
  width: min(1100px, calc(100vw - 120px));
  text-align: center;
  z-index: 3;
  opacity: 0.12;
  transition: opacity 0.4s ease;
  pointer-events: none;
}

.chapter.active {
  opacity: 1;
}

.title-chapter.is-dismissed {
  opacity: 0;
  pointer-events: none;
}

.chapter-inner {
  position: relative;
  width: 100%;
  min-height: 260px;
}

.video-chapter .chapter-inner {
  min-height: max(
    240px,
    calc(var(--video-width) * 0.5625)
  );
}

.chapter-video-frame {
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--video-width);
  aspect-ratio: 16 / 9;
  transform: translate(-50%, -50%);
  z-index: 1;
  background: #000;
  overflow: hidden;
}

.chapter-video-frame::before {
  content: "";
  position: absolute;
  inset: 0;
  border: var(--video-frame-line) solid rgba(31, 30, 28, 0.94);
  pointer-events: none;
  z-index: 3;
}

.chapter-inline-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
  pointer-events: none;
  z-index: 1;
  filter: none !important;
}

.chapter-inline-video iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  border: 0;
  pointer-events: none;
}

/* YouTube nur dann anklickbar machen, wenn pausiert / beendet */
.chapter-video-frame.is-youtube-interactive .chapter-inline-video,
.chapter-video-frame.is-youtube-interactive .chapter-inline-video iframe {
  pointer-events: auto;
}

/* In diesem Zustand den roten Button nicht drüberliegen lassen */
.chapter-video-frame.is-youtube-interactive ~ .chapter-action-slot .chapter-play-button {
  opacity: 0 !important;
  pointer-events: none !important;
}

.chapter-play-button {
  pointer-events: auto;
  z-index: 50;
}

.chapter-video-frame.is-video-fullscreen {
  position: fixed;
  top: 50%;
  left: 50%;
  width: min(var(--app-vw), calc(var(--app-vh) * 16 / 9));
  height: auto;
  aspect-ratio: 16 / 9;
  transform: translate(-50%, -50%);
  z-index: 220;
  background: #000;
  pointer-events: auto;
}

.chapter-video-frame.is-video-fullscreen::before {
  display: none;
}

.chapter-video-frame.is-video-fullscreen .chapter-inline-video {
  inset: 0;
  width: 100%;
  height: 100%;
  background: #000;
  filter: none !important;
}

.chapter-video-frame.is-video-fullscreen .chapter-inline-video iframe {
  width: 100%;
  height: 100%;
}

@media (max-width: 950px) and (orientation: portrait) {
  .chapter-video-frame.is-video-fullscreen {
    width: var(--app-vw);
    height: auto;
  }
}

@media (max-width: 950px) and (orientation: landscape) {
  .chapter-video-frame.is-video-fullscreen {
    width: auto;
    height: var(--app-vh);
  }
}

.title-main,
.chapter h2,
.chapter-label,
.title-meta {
  position: absolute;
  left: 50%;
  z-index: 3;
}

.title-main,
.chapter h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.03em;
  text-shadow:
    0.015em 0 rgba(95, 89, 84, 0.18),
    -0.015em 0 rgba(95, 89, 84, 0.1),
    0 0.02em rgba(95, 89, 84, 0.08);
}

/* Titelseite exakt um den Punkt herum zentriert */
.title-chapter .title-main {
  top: calc(50% - var(--title-main-center-offset));
  transform: translate(-50%, -50%);
  font-size: clamp(3rem, 4.8vw, 6rem);
  line-height: 0.98;
  width: max-content;
  max-width: min(980px, 100%);
}

.title-chapter .title-meta {
  top: calc(50% + var(--title-meta-center-offset));
  transform: translate(-50%, -50%);
  margin: 0;
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: clamp(0.95rem, 1vw, 1.1rem);
  line-height: 1.4;
  color: var(--ink-soft);
  width: max-content;
  max-width: 100%;
}

.chapter h2 {
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: clamp(2rem, 3.3vw, 4.2rem);
  line-height: 1.03;
  width: max-content;
  max-width: min(980px, 100%);
}

.chapter-label {
  top: calc(50% - 66px);
  transform: translate(-50%, -50%);
  margin: 0;
  font-family: var(--font-ui);
  font-weight: 800;
  font-size: clamp(1rem, 1.15vw, 1.35rem);
  line-height: 1;
  color: var(--ink);
  width: max-content;
  max-width: 100%;
}

i {
  font-style: italic;
}

.chapter-action-slot {
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none;
}

.chapter-dot {
  position: absolute;
  z-index: 21;
  pointer-events: auto;
  touch-action: manipulation;
}

.chapter-play-button {
  position: absolute;
  z-index: 21;
  pointer-events: auto;
  touch-action: manipulation;
  top: 50%;
  left: 50%;
  width: 48px;
  height: 48px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: none;
  background: var(--red-strong);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 0 rgba(214, 95, 87, 0.35);
  transition: opacity 0.22s ease, box-shadow 0.22s ease;
  opacity: 1;
}

.chapter-play-button.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.chapter-play-button:hover:not(:disabled) {
  box-shadow: 0 0 0 10px rgba(214, 95, 87, 0.12);
}

.chapter-play-button:disabled {
  cursor: default;
  opacity: 0.55;
}

.chapter-video-frame.is-video-fullscreen ~ .chapter-action-slot .chapter-play-button {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 240;
}

.chapter-dot {
  top: 50%;
  left: 50%;
  width: 14px;
  height: 14px;
  margin-left: -7px;
  margin-top: -7px;
  border-radius: 50%;
  border: none;
  background: var(--red-strong);
  cursor: pointer;
  box-shadow: 0 0 0 0 rgba(214, 95, 87, 0.35);
  transition: opacity 0.25s ease, box-shadow 0.25s ease;
}

.chapter.active .chapter-dot:not(:disabled):not(.is-hidden) {
  animation: pulseDot 1.3s ease-in-out infinite;
}

.chapter-dot:hover:not(:disabled) {
  box-shadow: 0 0 0 8px rgba(214, 95, 87, 0.12);
}

.chapter-dot:disabled {
  cursor: default;
  opacity: 0;
  box-shadow: none;
  animation: none;
}

.chapter-dot.is-hidden {
  opacity: 0;
  pointer-events: none;
}

@keyframes pulseDot {
  0% { transform: scale(1); opacity: 0.78; }
  50% { transform: scale(1.32); opacity: 1; }
  100% { transform: scale(1); opacity: 0.78; }
}

.play-icon,
.pause-icon {
  position: relative;
  display: block;
}

.play-icon {
  width: 0;
  height: 0;
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
  border-left: 13px solid #f7f2eb;
  margin-left: 3px;
}

.pause-icon {
  width: 14px;
  height: 16px;
}

.pause-icon::before,
.pause-icon::after {
  content: "";
  position: absolute;
  top: 0;
  width: 4px;
  height: 16px;
  background: #f7f2eb;
  border-radius: 1px;
}

.pause-icon::before {
  left: 1px;
}

.pause-icon::after {
  right: 1px;
}

#top-ui {
  position: absolute;
  top: calc(22px + var(--safe-top));
  left: calc(22px + var(--safe-left));
  right: calc(22px + var(--safe-right));
  z-index: 140;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, auto);
  align-items: start;
  gap: 16px;
  pointer-events: none;
}

#reloadProject {
  pointer-events: auto;
  border: none;
  background: transparent;
  padding: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.3rem, 1.7vw, 1.9rem);
  line-height: 1;
  color: var(--ink);
  cursor: pointer;
  transition: opacity 0.2s ease;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
  justify-self: start;
  min-width: 0;
  max-width: 100%;
}

#otherProjectsLink {
  pointer-events: auto;
  border: none;
  background: transparent;
  padding: 0;
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 1rem;
  color: var(--ink);
  cursor: pointer;
  transition: opacity 0.2s ease;
  text-align: right;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
  justify-self: end;
  min-width: 0;
  max-width: 220px;
}

#reloadProject:hover,
#otherProjectsLink:hover {
  opacity: 0.6;
}

#bottom-ui {
  position: absolute;
  left: calc(22px + var(--safe-left));
  right: calc(22px + var(--safe-right));
  bottom: calc(24px + var(--safe-bottom));
  z-index: 145;
  display: grid;
  grid-template-columns: 1fr auto auto auto 1fr;
  align-items: end;
  gap: 20px;
  pointer-events: none;
}

.side-link {
  pointer-events: auto;
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 0.96rem;
  color: var(--ink);
  transition: opacity 0.2s ease;
  min-width: 0;
}

.side-link:hover {
  opacity: 0.6;
}

.side-link-left {
  justify-self: start;
}

.side-link-right {
  justify-self: end;
}

.media-mini-btn {
  pointer-events: auto;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease, transform 0.2s ease;
  align-self: center;
}

.media-mini-btn:hover {
  transform: scale(1.08);
  opacity: 0.7;
}

#soundToggle {
  justify-self: end;
  margin-right: 4px;
}

#fullscreenToggle {
  justify-self: start;
  margin-left: 4px;
}

.sound-icon {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1px;
}

.sound-icon span {
  width: 2px;
  flex: 0 0 2px;
  height: 2px;
  background: var(--ink);
  border-radius: 2px;
}

.sound-icon span:nth-child(1) { animation: wave1 0.9s ease-in-out infinite; }
.sound-icon span:nth-child(2) { animation: wave2 0.75s ease-in-out infinite; }
.sound-icon span:nth-child(3) { animation: wave3 1s ease-in-out infinite; }
.sound-icon span:nth-child(4) { animation: wave2 0.82s ease-in-out infinite; }
.sound-icon span:nth-child(5) { animation: wave1 0.68s ease-in-out infinite; }

.media-mini-btn.is-muted .sound-icon span {
  height: 2px !important;
  animation: none !important;
  opacity: 0.85;
}

@keyframes wave1 {
  0% { height: 3px; }
  25% { height: 8px; }
  50% { height: 14px; }
  75% { height: 7px; }
  100% { height: 3px; }
}

@keyframes wave2 {
  0% { height: 4px; }
  25% { height: 12px; }
  50% { height: 7px; }
  75% { height: 16px; }
  100% { height: 4px; }
}

@keyframes wave3 {
  0% { height: 3px; }
  20% { height: 10px; }
  50% { height: 18px; }
  80% { height: 9px; }
  100% { height: 3px; }
}

.fullscreen-icon {
  position: relative;
  width: 15px;
  height: 15px;
  display: block;
}

.fullscreen-icon .corner {
  position: absolute;
  width: 5px;
  height: 5px;
  border-color: var(--ink);
  border-style: solid;
  border-width: 1.5px;
  transition: transform 0.2s ease, opacity 0.2s ease, border-color 0.2s ease;
}

.fullscreen-icon .corner-tl {
  top: 0;
  left: 0;
  border-right: none;
  border-bottom: none;
}

.fullscreen-icon .corner-tr {
  top: 0;
  right: 0;
  border-left: none;
  border-bottom: none;
}

.fullscreen-icon .corner-bl {
  bottom: 0;
  left: 0;
  border-right: none;
  border-top: none;
}

.fullscreen-icon .corner-br {
  bottom: 0;
  right: 0;
  border-left: none;
  border-top: none;
}

.media-mini-btn.is-fullscreen .corner-tl { transform: translate(1px, 1px); }
.media-mini-btn.is-fullscreen .corner-tr { transform: translate(-1px, 1px); }
.media-mini-btn.is-fullscreen .corner-bl { transform: translate(1px, -1px); }
.media-mini-btn.is-fullscreen .corner-br { transform: translate(-1px, -1px); }

#chapterNav {
  width: min(840px, 62vw);
  pointer-events: auto;
  align-self: end;
  transform: translateY(12px);
  min-width: 0;
}

.nav-line {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 18px;
  height: 44px;
}

.nav-line::before {
  content: "";
  position: absolute;
  left: calc(18px + 4px);
  right: calc(18px + 4px);
  top: 50%;
  transform: translateY(-50%);
  height: 2px;
  background: var(--line-grey);
  z-index: 0;
}

.video-progress-track {
  position: absolute;
  top: 50%;
  left: calc(18px + 4px);
  right: calc(18px + 4px);
  height: 2px;
  transform: translateY(-50%);
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  pointer-events: none;
}

.video-progress-segment {
  position: relative;
  height: 100%;
  background: var(--line-grey);
  overflow: hidden;
}

.video-progress-fill {
  width: 0%;
  height: 100%;
  background: var(--red);
  transition: width 0.08s linear;
}

.nav-item {
  position: relative;
  z-index: 2;
  width: 10px;
  height: 10px;
  border: none;
  border-radius: 50%;
  background: var(--red-strong);
  cursor: pointer;
  padding: 0;
  transition: transform 0.2s ease, opacity 0.2s ease, background 0.2s ease;
  flex: 0 0 auto;
}

.nav-item:hover {
  transform: scale(1.15);
}

.nav-item-label {
  position: absolute;
  left: 50%;
  top: -28px;
  transform: translateX(-50%);
  display: none;
  white-space: nowrap;
  font-family: var(--font-ui);
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--ink);
}

.nav-item.active {
  transform: scale(1.15);
}

.nav-item.active .nav-item-label {
  display: block;
}

.nav-item.nav-item-end .nav-item-label {
  top: -30px;
}

#soundToggle,
#fullscreenToggle {
  transform: translateY(12px);
}

/* UI im mobilen Video-Fullscreen */
.mobile-video-fullscreen #top-ui {
  opacity: 0;
  pointer-events: none;
}

.mobile-video-fullscreen .side-link,
.mobile-video-fullscreen #chapterNav {
  opacity: 0;
  pointer-events: none;
}

.mobile-video-fullscreen #bottom-ui {
  z-index: 245;
}

.mobile-video-fullscreen #soundToggle,
.mobile-video-fullscreen #fullscreenToggle {
  position: fixed;
  bottom: var(--mobile-fs-ui-bottom);
  transform: none;
  opacity: 1;
  pointer-events: auto;
  z-index: 246;
}

.mobile-video-fullscreen #soundToggle {
  left: calc(18px + var(--safe-left));
  margin-right: 0;
}

.mobile-video-fullscreen #fullscreenToggle {
  right: calc(18px + var(--safe-right));
  margin-left: 0;
}

@media (max-width: 1100px) {
  :root {
    --video-side-padding: 32px;
    --video-top-clearance: calc(84px + var(--safe-top));
    --video-bottom-clearance: calc(120px + var(--safe-bottom));
    --video-width: min(
      calc(100vw - (var(--video-side-padding) * 2)),
      calc((var(--app-vh) - var(--video-top-clearance) - var(--video-bottom-clearance)) * 16 / 9)
    );
  }

  .chapter {
    width: min(92vw, 980px);
  }

  #chapterNav {
    width: min(680px, 58vw);
  }
}

@media (max-width: 820px) {
  :root {
    --title-main-center-offset: 74px;
    --title-meta-center-offset: 78px;
    --video-side-padding: 16px;
    --video-top-clearance: calc(74px + var(--safe-top));
    --video-bottom-clearance: calc(138px + var(--safe-bottom));
    --video-frame-line: 1.2px;
  }

  .title-chapter .title-main {
    font-size: clamp(2.2rem, 8vw, 3.7rem);
    max-width: 88vw;
  }

  .title-chapter .title-meta {
    font-size: clamp(0.82rem, 2.9vw, 0.96rem);
    max-width: 80vw;
  }

  .chapter h2 {
    font-size: clamp(1.45rem, 5.4vw, 2.4rem);
    max-width: 84vw;
  }

  .chapter-label {
    font-size: clamp(0.9rem, 2.8vw, 1.05rem);
  }

  .nav-line {
    height: 52px;
    padding: 0 12px;
  }

  .nav-line::before {
    left: 18px;
    right: 18px;
  }

  .video-progress-track {
    left: 18px;
    right: 18px;
  }

  .nav-item {
    width: 12px;
    height: 12px;
  }

  .nav-item-label {
    font-size: 0.72rem;
    top: -24px;
  }

  .side-link {
    font-size: 0.82rem;
  }
}

@media (max-width: 820px) and (orientation: portrait) {
  #top-ui {
    top: calc(14px + var(--safe-top));
    left: calc(14px + var(--safe-left));
    right: calc(14px + var(--safe-right));
    gap: 8px;
    grid-template-columns: minmax(0, 1fr) minmax(0, 98px);
  }

  #reloadProject {
    font-size: clamp(1.3rem, 1.7vw, 1.9rem);
    line-height: 1;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    min-width: 0;
    max-width: 100%;
  }

  #otherProjectsLink {
    font-size: 0.86rem;
    line-height: 1.05;
    max-width: 98px;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    text-align: right;
    min-width: 0;
  }

  #bottom-ui {
    left: calc(14px + var(--safe-left));
    right: calc(14px + var(--safe-right));
    bottom: calc(14px + var(--safe-bottom));
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas:
      "left nav right"
      "sound nav full";
    gap: 10px 12px;
    align-items: end;
  }

  .side-link-left {
    grid-area: left;
    align-self: end;
  }

  .side-link-right {
    grid-area: right;
    align-self: end;
    justify-self: end;
  }

  #soundToggle {
    grid-area: sound;
    justify-self: start;
    margin-right: 0;
    transform: none;
  }

  #fullscreenToggle {
    grid-area: full;
    justify-self: end;
    margin-left: 0;
    transform: none;
  }

  #chapterNav {
    grid-area: nav;
    width: 100%;
    min-width: 0;
    transform: none;
  }
}

@media (max-width: 950px) and (orientation: landscape) {
  :root {
    --video-side-padding: 12px;
    --video-top-clearance: calc(48px + var(--safe-top));
    --video-bottom-clearance: calc(64px + var(--safe-bottom));
    --ui-edge-gap: 10px;
    --mobile-fs-ui-bottom: calc(-15px + var(--safe-bottom));
  }

  #top-ui {
    top: calc(var(--ui-edge-gap) + var(--safe-top));
    left: calc(var(--ui-edge-gap) + var(--safe-left));
    right: calc(var(--ui-edge-gap) + var(--safe-right));
    gap: 10px;
    grid-template-columns: minmax(0, 1fr) minmax(0, 150px);
  }

  @media (max-width: 950px) and (orientation: landscape) {
    #bottom-ui {
      left: calc(10px + var(--safe-left));
      right: calc(10px + var(--safe-right));
      bottom: calc(-15px + var(--safe-bottom));
      grid-template-columns: 1fr auto minmax(0, 56vw) auto 1fr;
      grid-template-areas: none;
      gap: 12px;
      align-items: end;
    }
  }

  .side-link-left {
    grid-area: auto;
    justify-self: start;
    align-self: center;
  }

  .side-link-right {
    grid-area: auto;
    justify-self: end;
    align-self: center;
  }

  #soundToggle {
    grid-area: auto;
    justify-self: end;
    align-self: center;
    margin-right: 4px;
    transform: none;
  }

  #fullscreenToggle {
    grid-area: auto;
    justify-self: start;
    align-self: center;
    margin-left: 4px;
    transform: none;
  }

  #chapterNav {
    grid-area: auto;
    width: min(560px, 56vw);
    min-width: 0;
    align-self: center;
    transform: none;
  }

  .nav-line {
    height: 38px;
    padding: 0 10px;
  }

  .nav-line::before,
  .video-progress-track {
    left: 14px;
    right: 14px;
  }

  .nav-item {
    width: 10px;
    height: 10px;
  }

  .nav-item-label {
    font-size: 0.62rem;
    top: -18px;
  }

  .side-link {
    font-size: 0.68rem;
  }

  .chapter-play-button {
    width: 42px;
    height: 42px;
  }

  .chapter-dot {
    width: 12px;
    height: 12px;
    margin-left: -6px;
    margin-top: -6px;
  }
}

@media (max-width: 560px) {
  :root {
    --title-main-center-offset: 68px;
    --title-meta-center-offset: 72px;
  }

  .chapter {
    width: calc(100vw - 12px);
  }

  .chapter-inner {
    min-height: 210px;
  }

  .video-chapter .chapter-inner {
    min-height: max(
      180px,
      calc(var(--video-width) * 0.5625)
    );
  }

  #bottom-ui {
    gap: 8px 10px;
  }

  .side-link {
    font-size: 0.72rem;
  }

  .media-mini-btn {
    width: 30px;
    height: 30px;
  }

  .sound-icon,
  .fullscreen-icon {
    transform: scale(0.95);
  }

  .nav-line {
    padding: 0 6px;
    height: 50px;
  }

  .nav-line::before,
  .video-progress-track {
    left: 12px;
    right: 12px;
  }

  .nav-item {
    width: 12px;
    height: 12px;
  }

  .nav-item-label {
    font-size: 0.64rem;
    top: -20px;
  }

  .chapter-play-button {
    width: 50px;
    height: 50px;
  }

  .chapter-dot {
    width: 16px;
    height: 16px;
    margin-left: -8px;
    margin-top: -8px;
  }
}

@media (max-width: 400px) and (orientation: portrait) {
  .nav-item-label,
  .nav-item.active .nav-item-label {
    display: none !important;
  }
}

@media (pointer: coarse) {
  .chapter-play-button:hover:not(:disabled) {
    box-shadow: none;
    opacity: 1;
  }

  .chapter-dot:hover:not(:disabled),
  .nav-item:hover,
  .media-mini-btn:hover,
  .side-link:hover,
  #reloadProject:hover,
  #otherProjectsLink:hover {
    transform: none;
    opacity: 1;
    box-shadow: none;
  }

  .chapter-video-frame.is-video-fullscreen ~ .chapter-action-slot .chapter-play-button {
    transform: translate(-50%, -50%);
  }
}

