:root {
  color-scheme: dark;
  --bg: #050608;
  --panel: rgba(23, 25, 29, 0.94);
  --panel-soft: rgba(43, 46, 52, 0.92);
  --line: rgba(255, 255, 255, 0.18);
  --text: #f7f8fa;
  --muted: #a9b0bb;
  --accent: #22b573;
  --accent-2: #5ba8ff;
  --danger: #f05252;
  --warn: #f5b84b;
  --shadow: 0 18px 46px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

body.is-player-fullscreen-fallback {
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--text);
  cursor: pointer;
}

button:hover {
  border-color: rgba(255, 255, 255, 0.36);
  background: rgba(63, 67, 76, 0.96);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

[hidden] {
  display: none !important;
}

.player-app {
  --controls-panel-height: 0px;
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  height: var(--player-viewport-height, 100dvh);
  min-width: 320px;
  overflow: hidden;
  background: #000;
}

.player-app:fullscreen,
.player-app:-webkit-full-screen,
.player-app:-moz-full-screen {
  width: 100%;
  height: 100%;
  min-width: 0;
  max-width: none;
  max-height: none;
  background: #000;
}

.player-app:fullscreen::backdrop,
.player-app:-webkit-full-screen::-webkit-backdrop {
  background: #000;
}

.player-app.is-fullscreen-fallback {
  position: fixed;
  inset: 0;
  z-index: 2147483647;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
}

.stage {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background: #000;
  touch-action: none;
  --video-zoom-scale: 1;
  --video-zoom-x: 0px;
  --video-zoom-y: 0px;
}

.video-region { display: flex; min-height: 0; min-width: 0; overflow: hidden; }
.video-region > .stage { flex: 1; min-width: 0; }
.ptz-panel {
  flex: 0 0 224px; min-width: 0; padding: 14px; overflow: auto;
  background: var(--panel); border-right: 1px solid var(--line); font-size: 13px;
  touch-action: pan-y; color: var(--text);
}
.ptz-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.ptz-head strong { font-size: 16px; }
.ptz-panel .icon-button { width: 40px; min-width: 40px; height: 40px; padding: 8px; }
.ptz-status { min-height: 70px; margin: 0 0 12px; line-height: 1.5; overflow-wrap: anywhere; }
.ptz-error { color: #ffb8b8; line-height: 1.4; overflow-wrap: anywhere; }
.ptz-dpad { display: grid; grid-template-columns: repeat(3, 40px); gap: 6px; justify-content: center; }
.ptz-panel button[data-axis] { touch-action: none; }
.ptz-panel svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ptz-zoom { display: flex; justify-content: center; gap: 12px; margin: 14px 0; }
.ptz-speed { display: grid; gap: 8px; margin: 14px 0; }
.ptz-speed input { width: 100%; margin: 0; accent-color: var(--text); }
.ptz-queue { width: 100%; min-height: 40px; border-radius: 6px; padding: 8px; white-space: normal; }
.control-ptz { order: 12; }
.control-ptz[aria-expanded="true"] { border-color: var(--text); background: #42464e; }
.control-ptz svg { fill: none; }
.player-app.wall-controlled .ptz-panel, .player-app.wall-controlled .control-ptz { display: none; }
@media (max-width: 640px) {
  .ptz-panel { flex-basis: 148px; padding: 8px; font-size: 12px; }
  .ptz-dpad { grid-template-columns: repeat(3, 36px); gap: 4px; }
  .ptz-panel .icon-button { width: 36px; min-width: 36px; height: 36px; padding: 6px; }
}

video,
.preview-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  user-select: none;
  transform: translate3d(var(--video-zoom-x), var(--video-zoom-y), 0) scale(var(--video-zoom-scale));
  transform-origin: 50% 50%;
  will-change: transform;
}

video {
  z-index: 0;
  object-fit: contain;
  background: #000;
}

.preview-canvas {
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  transition: opacity 120ms ease;
}

.preview-canvas.is-visible {
  opacity: 1;
}

.player-auth-overlays {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  overflow: hidden;
  pointer-events: none;
  visibility: hidden;
}

.player-auth-overlay {
  position: absolute;
  display: block;
  pointer-events: auto;
}

.player-auth-overlay img {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
}

.stage.is-video-zoomed {
  cursor: grab;
}

.stage.is-video-zoomed.is-video-panning {
  cursor: grabbing;
}

.top-overlay {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  z-index: 5;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  pointer-events: none;
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.top-overlay h1 {
  margin: 0;
}

.top-overlay-main {
  display: flex;
  min-width: 0;
  align-items: flex-start;
  gap: 10px;
  pointer-events: none;
}

.camera-heading {
  min-width: 0;
}

.embed-back-button {
  display: inline-flex;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  background: rgba(23, 25, 29, 0.72);
  color: #fff;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(8px);
  pointer-events: auto;
  text-decoration: none;
}

.embed-back-button[hidden] {
  display: none;
}

.embed-back-button:hover,
.embed-back-button:focus-visible {
  border-color: rgba(255, 255, 255, 0.42);
  background: rgba(43, 46, 52, 0.92);
}

.embed-back-button svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.top-overlay h1 {
  max-width: min(560px, 72vw);
  overflow: hidden;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.55);
}

.status-pill {
  display: block;
  max-width: 42vw;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.58);
  color: #fff;
  padding: 7px 10px;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.playback-mode-switch {
  position: relative;
  pointer-events: auto;
}

.playback-mode-switch .status-pill {
  cursor: pointer;
}

.playback-mode-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 10;
  display: grid;
  min-width: 142px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(12, 13, 16, 0.95);
  box-shadow: var(--shadow);
}

.playback-mode-menu[hidden] {
  display: none;
}

.playback-mode-option {
  display: block;
  width: 100%;
  border: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  padding: 9px 12px;
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.playback-mode-option:last-child {
  border-bottom: 0;
}

.playback-mode-option.is-active {
  background: rgba(34, 181, 115, 0.22);
  color: #d9ffec;
}

.status-pill.is-live {
  border-color: rgba(34, 181, 115, 0.5);
  color: #d9ffec;
}

.status-pill.is-error {
  border-color: rgba(240, 82, 82, 0.58);
  color: #ffd8d8;
}

.server-decryption-indicator {
  position: absolute;
  top: 54px;
  left: 50%;
  z-index: 4;
  display: flex;
  max-width: calc(100% - 28px);
  align-items: center;
  gap: 7px;
  overflow: hidden;
  border: 1px solid rgba(245, 184, 75, 0.58);
  border-radius: 6px;
  background: rgba(20, 17, 10, 0.88);
  color: #ffe1a6;
  padding: 6px 9px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  pointer-events: none;
  text-overflow: ellipsis;
  transform: translateX(-50%);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
  white-space: nowrap;
}

.server-decryption-indicator svg {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.center-play {
  position: absolute;
  z-index: 6;
  top: 50%;
  left: 50%;
  display: none;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.58);
  transform: translate(-50%, -50%);
  box-shadow: var(--shadow);
}

.center-play.is-visible {
  display: grid;
  place-items: center;
}

.center-play span {
  display: block;
  width: 0;
  height: 0;
  margin-left: 6px;
  border-top: 16px solid transparent;
  border-bottom: 16px solid transparent;
  border-left: 24px solid #fff;
}

.video-overlay-actions {
  position: absolute;
  right: 8px;
  bottom: 8px;
  z-index: 7;
  display: flex;
  min-width: 104px;
  min-height: 52px;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 8px;
  padding: 6px;
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.overlay-button {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(23, 25, 29, 0.72);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition:
    opacity 140ms ease,
    transform 140ms ease,
    border-color 120ms ease,
    background 120ms ease;
}

.video-overlay-actions:hover .overlay-button,
.video-overlay-actions:focus-within .overlay-button {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.overlay-button.is-active {
  border-color: rgba(91, 168, 255, 0.64);
  color: #fff;
}

.controls {
  position: relative;
  z-index: 8;
  display: grid;
  gap: 10px;
  padding: 12px 14px max(14px, calc(14px + env(safe-area-inset-bottom)));
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  background: var(--panel);
  box-shadow: 0 -18px 40px rgba(0, 0, 0, 0.34);
}

.player-app.is-fullscreen .stage,
.player-app.controls-auto-hide .stage,
.player-app.controls-always-hidden .stage {
  grid-row: 1 / -1;
}

.player-app.is-fullscreen .controls,
.player-app.controls-auto-hide .controls {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  transition:
    opacity 140ms ease,
    transform 140ms ease;
}

.player-app.is-fullscreen.controls-hidden .controls,
.player-app.controls-auto-hide.controls-hidden .controls {
  opacity: 0;
  pointer-events: none;
  transform: translateY(100%);
}

.player-app.is-fullscreen.controls-hidden .mobile-controls-toggle,
.player-app.controls-auto-hide.controls-hidden .mobile-controls-toggle {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 6px);
}

.player-app.controls-always-hidden {
  grid-template-rows: minmax(0, 1fr) 0;
}

.player-app.controls-always-hidden .controls,
.player-app.controls-always-hidden .mobile-controls-toggle {
  display: none !important;
}

.mobile-controls-toggle {
  position: absolute;
  bottom: calc(var(--controls-panel-height) + 4px);
  left: 50%;
  z-index: 12;
  display: none;
  width: 48px;
  height: 16px;
  place-items: center;
  border-color: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(23, 25, 29, 0.62);
  color: #fff;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(8px);
  transform: translateX(-50%);
  transition:
    opacity 160ms ease,
    transform 160ms ease,
    bottom 160ms ease;
}

.player-app.osd-hidden .top-overlay,
.player-app.osd-hidden .server-decryption-indicator,
.player-app.osd-hidden .video-overlay-actions,
.player-app.osd-hidden .mobile-controls-toggle {
  opacity: 0;
  pointer-events: none;
}

.player-app.osd-hidden .top-overlay {
  transform: translateY(-6px);
}

.player-app.osd-hidden .server-decryption-indicator {
  transform: translate(-50%, -6px);
}

.player-app.osd-hidden .video-overlay-actions {
  transform: translateY(6px);
}

.player-app.osd-hidden .mobile-controls-toggle {
  transform: translate(-50%, 6px);
}

.mobile-controls-toggle span {
  width: 24px;
  height: 3px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.82;
}

.player-app.no-dvr .timeline-panel,
.player-app.no-dvr #download-button,
.player-app.no-dvr #seek-back,
.player-app.no-dvr #seek-forward,
.player-app.no-dvr #jump-button,
.player-app.no-dvr #jump-input,
.player-app.no-dvr #speed-select,
.player-app.no-dvr #selection-toggle,
.player-app.no-dvr #motion-playback-toggle,
.player-app.no-dvr #timelapse-playback-toggle,
.player-app.no-dvr #timeline-zoom {
  display: none;
}

.player-app.is-timelapse-archive #selection-toggle,
.player-app.is-timelapse-archive #timeline-zoom,
.player-app.is-timelapse-archive #speed-select,
.player-app.is-timelapse-archive #jump-button,
.player-app.is-timelapse-archive #jump-input,
.player-app.is-timelapse-archive #seek-back,
.player-app.is-timelapse-archive #seek-forward,
.player-app.is-timelapse-archive #mute-toggle,
.player-app.is-timelapse-archive #clock {
  display: none;
}

.timeline-panel {
  display: grid;
  gap: 7px;
}

.timeline-head,
.control-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.timeline-head {
  justify-content: space-between;
}

.timeline-head[hidden] {
  display: none !important;
}

.timeline-labels {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.range-label,
.export-label {
  min-width: 0;
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.range-label {
  color: var(--muted);
}

.export-label {
  color: #ffd98d;
  font-variant-numeric: tabular-nums;
}

.timeline-zoom {
  display: flex;
  gap: 4px;
}

.timeline-zoom button {
  min-width: 34px;
  height: 38px;
  border-radius: 4px;
  padding: 0;
  color: var(--text);
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
}

.timeline-zoom button.is-active {
  border-color: rgba(91, 168, 255, 0.62);
  color: #fff;
}

.timeline {
  position: relative;
  height: 58px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 5px;
  background:
    linear-gradient(to bottom, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0)),
    linear-gradient(to bottom, transparent 29px, rgba(255, 255, 255, 0.11) 29px, rgba(255, 255, 255, 0.11) 30px, transparent 30px),
    #111318;
  cursor: grab;
  overflow: visible;
  touch-action: none;
}

.timeline.is-panning {
  cursor: grabbing;
}

.timeline:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

.timeline-track,
.timeline-selection,
.timeline-handle,
.timeline-playhead,
.timeline-live,
.timeline-tooltip {
  position: absolute;
}

.timeline-track {
  inset: 0;
}

.range-bar,
.gap-bar,
.future-bar,
.unknown-bar,
.outside-timeline-bar,
.motion-event-bar {
  position: absolute;
  border-radius: 0;
}

.range-bar,
.gap-bar,
.future-bar,
.unknown-bar,
.outside-timeline-bar {
  top: 38px;
  height: 10px;
}

.range-bar {
  background: var(--accent);
  box-shadow: 0 0 10px rgba(34, 181, 115, 0.22);
}

.timelapse-range-bar {
  background: rgba(176, 183, 194, 0.35);
  box-shadow: none;
}

.gap-bar {
  background: rgba(240, 82, 82, 0.55);
}

.future-bar {
  background: rgba(176, 183, 194, 0.42);
}

.unknown-bar {
  background: rgba(139, 149, 163, 0.48);
}

.outside-timeline-bar {
  background: rgba(0, 0, 0, 0.72);
}

.motion-event-bar {
  top: 9px;
  height: 14px;
  margin: 0;
  border: 0;
  padding: 0;
  appearance: none;
  opacity: 0.82;
}

.motion-event-bar.is-motion {
  background: rgba(245, 158, 11, 0.9);
  cursor: pointer;
}

.motion-event-bar.is-motion:hover,
.motion-event-bar.is-motion:focus-visible {
  opacity: 1;
  outline: 1px solid rgba(255, 244, 199, 0.95);
  outline-offset: 1px;
}

.motion-event-bar.is-idle {
  background: rgba(148, 163, 184, 0.48);
}

.motion-event-bar.is-unavailable {
  background: rgba(239, 68, 68, 0.76);
}

.timeline-selection {
  top: 6px;
  z-index: 6;
  height: 20px;
  border: 1px solid rgba(245, 184, 75, 0.9);
  border-radius: 4px;
  background: rgba(245, 184, 75, 0.22);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18);
  opacity: 0;
  pointer-events: none;
}

.timeline-selection.is-visible {
  opacity: 1;
}

.selection-duration {
  position: absolute;
  top: 50%;
  left: 50%;
  display: none;
  overflow: hidden;
  max-width: calc(100% - 14px);
  color: #fff4c7;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  pointer-events: none;
  text-overflow: ellipsis;
  transform: translate(-50%, -50%);
  white-space: nowrap;
}

.selection-duration.is-visible {
  display: block;
}

.timeline-handle {
  top: 1px;
  z-index: 8;
  display: none;
  width: 26px;
  height: 28px;
  border: none;
  border-radius: 4px;
  background: transparent;
  padding: 0;
  transform: translateX(-50%);
  cursor: ew-resize;
}

.timeline-handle.is-visible {
  display: block;
}

.timeline-handle::before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 3px;
  border-radius: 2px;
  background: #ffd166;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35), 0 0 12px rgba(245, 184, 75, 0.34);
  content: "";
  transform: translateX(-50%);
}

.timeline-handle::after {
  position: absolute;
  top: -1px;
  left: 50%;
  width: 14px;
  height: 9px;
  border-radius: 2px;
  background: #ffd166;
  content: "";
  transform: translateX(-50%);
}

.timeline-handle-end::after {
  top: auto;
  bottom: -1px;
}

.timeline-handle:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.handle-time {
  position: absolute;
  top: -24px;
  left: 50%;
  min-width: 74px;
  border-radius: 4px;
  background: #ffffff;
  color: #111318;
  padding: 3px 5px;
  font-size: 11px;
  line-height: 1.1;
  pointer-events: none;
  transform: translateX(-50%);
  white-space: nowrap;
}

.timeline-handle-end .handle-time {
  top: -24px;
  bottom: auto;
}

.timeline-playhead {
  top: 31px;
  bottom: 0;
  z-index: 7;
  width: 28px;
  background: transparent;
  cursor: ew-resize;
  pointer-events: none;
  transform: translateX(-50%);
  opacity: 0;
}

.timeline-playhead::before {
  position: absolute;
  top: 12px;
  left: 50%;
  z-index: 2;
  width: 12px;
  height: 12px;
  border: 2px solid #f7fff9;
  border-radius: 50%;
  background: #20d67a;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.34), 0 0 14px rgba(32, 214, 122, 0.48);
  content: "";
  transform: translate(-50%, -50%);
}

.timeline-playhead::after {
  position: absolute;
  top: 18px;
  bottom: 4px;
  left: 50%;
  width: 2px;
  border-radius: 2px;
  background: rgba(32, 214, 122, 0.86);
  content: "";
  transform: translateX(-50%);
}

.timeline-playhead.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.timeline-live {
  display: none;
  top: 34px;
  bottom: 8px;
  width: 2px;
  background: var(--accent-2);
  transform: translateX(-1px);
  opacity: 0;
}

.timeline-live.is-visible {
  opacity: 1;
}

.timeline-tooltip {
  top: 5px;
  z-index: 3;
  display: none;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.76);
  color: #fff;
  padding: 4px 7px;
  font-size: 12px;
  line-height: 1.2;
  pointer-events: none;
  transform: translateX(-50%);
  white-space: nowrap;
}

.timeline-tooltip.is-visible {
  display: block;
}

.timeline.has-hover-preview .timeline-tooltip {
  visibility: hidden;
}

.timeline-preview {
  position: absolute;
  bottom: calc(100% + 8px);
  z-index: 10;
  width: 224px;
  max-width: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #111318;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}

.timeline-preview-frame {
  position: relative;
  height: 126px;
  background: #000;
}

.timeline-preview-frame video {
  transform: none;
  will-change: auto;
  object-fit: contain;
}

.timeline-preview-time {
  display: block;
  padding: 5px 4px;
  color: var(--text);
  font-size: 12px;
  line-height: 16px;
  font-variant-numeric: tabular-nums;
  text-align: center;
  white-space: nowrap;
}

.timeline-ticks {
  position: relative;
  height: 20px;
  color: var(--muted);
  cursor: grab;
  font-size: 11px;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.timeline-ticks.is-panning {
  cursor: grabbing;
}

.timeline-tick,
.timeline-minor-tick {
  position: absolute;
  transform: translateX(-50%);
}

.timeline-tick {
  top: 7px;
  white-space: nowrap;
}

.timeline-minor-tick {
  top: 0;
  width: 1px;
  height: 4px;
  background: rgba(245, 184, 75, 0.48);
}

.timeline-tick::before {
  position: absolute;
  top: -7px;
  left: 50%;
  width: 1px;
  height: 7px;
  background: rgba(245, 184, 75, 0.78);
  content: "";
}

.control-row {
  min-width: 0;
  flex-wrap: nowrap;
  overflow: hidden;
}

.icon-button,
.text-button {
  flex: 0 0 auto;
  height: 38px;
  border-radius: 5px;
}

.icon-button {
  display: grid;
  width: 40px;
  place-items: center;
  padding: 0;
}

.icon-button svg {
  width: 21px;
  height: 21px;
  fill: currentColor;
}

.icon-button .screenshot-icon {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.icon-button .archive-key-icon {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.timelapse-playback-toggle .timelapse-icon {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.motion-playback-toggle.is-active,
.timelapse-playback-toggle.is-active,
.selection-toggle.is-active {
  border-color: rgba(245, 184, 75, 0.72);
  background: rgba(245, 184, 75, 0.18);
  color: #ffd166;
}

.text-button {
  min-width: 58px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 800;
}

.text-button.is-live {
  border-color: rgba(34, 181, 115, 0.58);
  background: rgba(34, 181, 115, 0.18);
  color: #d9ffec;
}

.jump-button {
  min-width: 78px;
}

.clock {
  flex: 0 1 190px;
  min-width: 0;
  max-width: 230px;
  overflow: hidden;
  color: #fff;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.jump-input,
.speed-select {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.28);
  color: var(--text);
  padding: 0 9px;
}

.jump-input {
  flex: 0 1 220px;
  min-width: 190px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-variant-numeric: tabular-nums;
}

.jump-input span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jump-input svg { width: 18px; height: 18px; flex: 0 0 18px; }

.archive-calendar {
  position: fixed;
  inset: auto;
  margin: 0;
  box-sizing: border-box;
  width: 344px;
  max-width: calc(100vw - 16px);
  max-height: calc(100dvh - 16px);
  overflow: auto;
  padding: 16px;
  border: 1px solid #575b60;
  border-radius: 8px;
  background: #202225;
  color: #f5f5f5;
  color-scheme: dark;
  box-shadow: 0 8px 24px #0008;
  font-size: 14px;
  letter-spacing: 0;
}

.archive-calendar::backdrop { background: transparent; }
.archive-calendar form { display: grid; gap: 12px; margin: 0; }
.archive-calendar-header { display: grid; grid-template-columns: 28px minmax(0, 1fr) 64px 28px 28px; gap: 4px; align-items: center; }
.archive-calendar button { min-width: 0; padding: 0; color: inherit; border: 1px solid transparent; border-radius: 4px; background: transparent; cursor: pointer; font: inherit; }
.archive-calendar-header button { width: 28px; height: 32px; display: grid; place-items: center; }
.archive-calendar-header svg { width: 18px; height: 18px; }
.archive-calendar select, .archive-calendar input { min-width: 0; width: 100%; box-sizing: border-box; height: 32px; color: inherit; background: #292c30; border: 1px solid #575b60; border-radius: 4px; padding: 2px 4px; font: inherit; }
.archive-calendar-weekdays, .archive-calendar-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.archive-calendar-weekdays { color: #aeb3ba; text-align: center; font-size: 12px; }
.archive-calendar-days { grid-template-rows: repeat(6, 34px); }
.archive-calendar .archive-calendar-day { position: relative; height: 34px; font-variant-numeric: tabular-nums; }
.archive-calendar-day.no-archive { color: #949aa3; }
.archive-calendar-day.has-archive { color: #90e2bd; background: #174337; font-weight: 600; }
.archive-calendar-day.has-archive::after { content: ""; position: absolute; bottom: 2px; left: calc(50% - 2px); width: 4px; height: 4px; border-radius: 50%; background: #79e1b2; }
.archive-calendar-day[aria-current="date"] { text-decoration: underline; text-underline-offset: 3px; }
.archive-calendar .archive-calendar-day[aria-pressed="true"] { border-color: #ffd17d; color: #fff; box-shadow: inset 0 0 0 1px #ffd17d; }
.archive-calendar button:hover { background-color: #44494f; }
.archive-calendar button:disabled { opacity: .4; cursor: default; }
.archive-calendar button:focus-visible, .archive-calendar select:focus-visible, .archive-calendar input:focus-visible { outline: 2px solid #ffd17d; outline-offset: 1px; }
.archive-calendar-status { min-height: 32px; color: #b7bec7; font-size: 12px; display: flex; align-items: center; gap: 7px; }
.archive-calendar-status.has-archive::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #79e1b2; flex: 0 0 7px; }
.archive-calendar-footer { display: flex; align-items: end; justify-content: space-between; gap: 12px; }
.archive-calendar-footer label { display: grid; gap: 4px; min-width: 0; }
.archive-calendar-footer label span { color: #b7bec7; font-size: 12px; }
.archive-calendar .archive-calendar-footer button { min-height: 34px; padding: 4px 12px; border-color: #575b60; }

.speed-select {
  flex: 0 0 74px;
}

.control-play {
  order: 1;
}

.control-motion {
  order: 2;
}

.control-timelapse {
  order: 3;
}

.control-speed {
  order: 4;
}

.control-select {
  order: 6;
}

.control-download {
  order: 7;
}

.control-clock {
  order: 12;
}

.control-jump {
  order: 8;
}

.control-screenshot,
.control-mute,
.control-fullscreen {
  order: 12;
}

.control-seek {
  order: 9;
}

.control-zoom {
  order: 5;
}

.control-live {
  order: 11;
}

.archive-key-dialog {
  width: min(560px, calc(100vw - 28px));
  max-height: calc(100dvh - 28px);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #17191d;
  color: var(--text);
  box-shadow: var(--shadow);
}

.archive-key-dialog::backdrop {
  background: rgba(0, 0, 0, 0.78);
}

.archive-key-dialog form {
  display: grid;
  gap: 16px;
  padding: 20px;
}

.archive-key-dialog header,
.archive-key-dialog footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.archive-key-dialog h2,
.archive-key-dialog p {
  margin: 0;
}

.archive-key-dialog p {
  color: var(--muted);
  line-height: 1.45;
}

.archive-key-dialog label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
}

.archive-key-dialog input,
.archive-key-dialog textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0c0d10;
  color: var(--text);
}

.archive-key-dialog input {
  padding: 10px;
}

.archive-key-dialog textarea {
  min-height: 132px;
  padding: 10px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.archive-key-dialog .archive-key-remember {
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  color: var(--text);
}

.archive-key-dialog .archive-key-remember input {
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  padding: 0;
  accent-color: var(--accent);
}

.archive-key-remember-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.archive-key-remember-copy strong {
  font-size: 14px;
  font-weight: 650;
}

.archive-key-remember-copy small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.archive-key-dialog footer {
  justify-content: flex-end;
}

.archive-key-dialog .text-button.is-primary {
  border-color: rgba(245, 184, 75, 0.62);
  background: rgba(245, 184, 75, 0.18);
  color: #ffe1a6;
}

.server-decryption-consent-dialog {
  width: min(520px, calc(100vw - 28px));
}

.archive-key-dialog-status {
  min-height: 20px;
}

.archive-key-dialog-status.is-error {
  color: var(--danger);
}

.archive-key-dialog-status.is-ready {
  color: var(--accent);
}

@media (max-width: 1180px) {
  .control-clock,
  .control-live {
    display: none;
  }
}

@media (max-width: 1080px) {
  .control-zoom {
    display: none;
  }

  .jump-input {
    flex-basis: 180px;
    min-width: 160px;
  }

  .jump-button {
    min-width: 68px;
  }
}

@media (max-width: 980px) {
  .control-seek {
    display: none;
  }
}

@media (max-width: 900px) {
  .control-mute,
  .control-fullscreen {
    display: none;
  }
}

@media (max-width: 760px) {
  .control-jump {
    display: none;
  }
}

@media (max-width: 640px) {
  .control-clock {
    display: none;
  }
}

@media (max-width: 820px) {
  .controls {
    padding: 9px 9px max(9px, calc(9px + env(safe-area-inset-bottom)));
  }

  .timeline-head {
    align-items: stretch;
    flex-direction: column;
    gap: 6px;
  }

  .control-row {
    gap: 6px;
  }

  .clock {
    min-width: 0;
  }
}

@media (max-width: 520px) {
  .top-overlay {
    top: 9px;
    left: 9px;
    right: 9px;
    gap: 9px;
  }

  .top-overlay-main {
    gap: 8px;
  }

  .embed-back-button {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
  }

  .embed-back-button svg {
    width: 21px;
    height: 21px;
  }

  .top-overlay h1 {
    max-width: 58vw;
    font-size: 14px;
  }

  .status-pill {
    max-width: 36vw;
    padding: 6px 8px;
  }

  .server-decryption-indicator {
    top: 50px;
    max-width: calc(100% - 18px);
  }

  .controls {
    gap: 8px;
  }

  .timeline {
    height: 54px;
  }

  .control-row {
    gap: 5px;
  }

  .icon-button,
  .text-button,
  .jump-input,
  .speed-select {
    height: 36px;
  }

  .icon-button {
    width: 38px;
  }

  .timelapse-playback-toggle .timelapse-icon {
    width: 21px;
    height: 21px;
  }

  .timeline-zoom button {
    flex-basis: 38px;
    height: 36px;
  }

  .video-overlay-actions {
    right: 9px;
    bottom: 9px;
    gap: 6px;
  }
}

@media (hover: none), (pointer: coarse) {
  .control-mute,
  .control-fullscreen {
    display: none;
  }

  .overlay-button {
    opacity: 1;
    pointer-events: auto;
    transform: none;
  }

  .mobile-controls-toggle {
    display: grid;
  }

  .player-app.mobile-controls-collapsed {
    grid-template-rows: minmax(0, 1fr) 0;
  }

  .player-app.mobile-controls-collapsed .controls {
    display: none;
  }

  .player-app.mobile-controls-collapsed .mobile-controls-toggle {
    bottom: max(6px, env(safe-area-inset-bottom));
  }

  .player-app.mobile-controls-collapsed .mobile-controls-toggle {
    height: 18px;
  }
}
.player-app.wall-controlled { min-width: 0; grid-template-rows: minmax(0, 1fr); }
.wall-controlled .top-overlay,
.wall-controlled .center-play,
.wall-controlled .controls,
.wall-controlled .mobile-controls-toggle { display: none !important; }
