:root {
  color-scheme: dark;
  font-family: system-ui, "Microsoft YaHei", sans-serif;
  color: #f3f7fb;
  background: #0b1119;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }

.viewer {
  position: relative;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: #0b1119;
}

.viewer:fullscreen { width: 100%; height: 100%; }

.stage {
  position: absolute;
  inset: env(safe-area-inset-top) env(safe-area-inset-right)
         env(safe-area-inset-bottom) env(safe-area-inset-left);
  display: grid;
  place-items: center;
  container-type: size;
  touch-action: pan-y pinch-zoom;
}

.frame {
  position: relative;
  width: min(100vw, 177.7778vh);
  width: min(100cqw, 177.7778cqh);
  aspect-ratio: 16 / 9;
}

.frame img {
  display: block;
  width: 100%;
  height: 100%;
  user-select: none;
  -webkit-user-drag: none;
}

/* Video bounds from the original PowerPoint, relative to the 16:9 slide. */
.clip {
  position: absolute;
  left: 14.6875%;
  top: 16.25%;
  width: 70.625%;
  height: 70.625%;
}

.clip video {
  display: block;
  width: 100%;
  height: 100%;
  background: #000;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible {
  outline: 2px solid #8bc3ff;
  outline-offset: -3px;
}

.play {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
}

.play-icon {
  display: grid;
  place-items: center;
  width: clamp(48px, 11cqw, 76px);
  aspect-ratio: 1;
  border: 1px solid #ffffffaa;
  border-radius: 50%;
  background: #101e32e8;
  box-shadow: 0 4px 20px #0006;
}

.play-icon::after {
  content: "";
  margin-left: 4px;
  border-block: 9px solid transparent;
  border-left: 14px solid white;
}

.dock {
  position: absolute;
  z-index: 1;
  bottom: max(12px, calc(env(safe-area-inset-bottom) + 6px));
  left: 50%;
  display: grid;
  justify-items: center;
  gap: 10px;
  transform: translateX(-50%);
  transition: opacity .18s ease;
}

.controls {
  display: flex;
  align-items: center;
  padding: 3px;
  border: 1px solid #ffffff30;
  border-radius: 26px;
  background: #111c2bf2;
  box-shadow: 0 4px 20px #0004;
}

.controls button, .close {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
}

.controls button:disabled { color: #9aacbf6e; cursor: default; }
.controls button:not(:disabled):hover, .close:hover { background: #ffffff16; }
.controls .page-count {
  display: block;
  width: 76px;
  font-size: .84rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.page-count span { padding: 0 1px; color: #9aacbf; }

.chevron {
  width: 9px;
  height: 9px;
  border-top: 2px solid;
  border-right: 2px solid;
  transform: rotate(45deg);
}
.chevron.left { transform: rotate(-135deg); }

.corners {
  display: grid;
  grid-template-columns: repeat(2, 6px);
  grid-template-rows: repeat(2, 6px);
  gap: 4px;
}
.corners i:nth-child(1) { border-top: 2px solid; border-left: 2px solid; }
.corners i:nth-child(2) { border-top: 2px solid; border-right: 2px solid; }
.corners i:nth-child(3) { border-bottom: 2px solid; border-left: 2px solid; }
.corners i:nth-child(4) { border-bottom: 2px solid; border-right: 2px solid; }
.viewer:fullscreen .corners { transform: rotate(180deg); }
.viewer:fullscreen .corners i { transform: rotate(180deg); }

.portrait-hint {
  display: none;
  margin: 0;
  color: #a1b2c4;
  font-size: .78rem;
  white-space: nowrap;
}

@media (orientation: portrait) {
  .portrait-hint { display: block; }
}

@media (orientation: landscape) {
  .viewer.controls-idle .dock:not(:has(:focus-visible)) {
    opacity: 0;
    pointer-events: none;
  }
}

dialog {
  width: min(420px, calc(100vw - 32px));
  max-height: min(72vh, 560px);
  padding: 0;
  border: 1px solid #34465b;
  border-radius: 18px;
  color: inherit;
  background: #111c2b;
}
dialog::backdrop { background: #000a; }

.picker-header {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 10px 4px 18px;
  border-bottom: 1px solid #ffffff1c;
  background: #111c2b;
}
.picker-header h2 { margin: 0; font-size: 1rem; }
.close { font-size: 1.4rem; }
#pageList { margin: 0; padding: 8px; list-style: none; }
#pageList button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  font-size: .9rem;
}
#pageList button:hover { background: #ffffff16; }
#pageList button[aria-current="page"] { background: #214166; }
.page-number { color: #adc9e6; font-variant-numeric: tabular-nums; }

.slide-error {
  position: absolute;
  top: 50%;
  left: 50%;
  width: max-content;
  max-width: 90%;
  margin: 0;
  padding: 12px;
  border-radius: 8px;
  background: #111c2b;
  text-align: center;
  transform: translate(-50%, -50%);
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  .dock { transition: none; }
}
