:root {
  color-scheme: dark;
  --bg: #090b0d;
  --panel: #111417;
  --panel-raised: #171b1f;
  --line: rgba(255, 255, 255, .10);
  --muted: #8d969e;
  --text: #f3f6f8;
  --accent: #35e88d;
  --accent-soft: rgba(53, 232, 141, .14);
  --danger: #ff7c6e;
  --radius: 15px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 50% -20%, rgba(47, 70, 60, .22), transparent 40%),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }
button, select, input[type="range"] { cursor: pointer; }
button:disabled, select:disabled, input:disabled { cursor: not-allowed; opacity: .45; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.topbar {
  height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(24px, calc((100vw - 1500px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(9, 11, 13, .82);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 760;
  letter-spacing: .13em;
}

.brand-mark {
  width: 12px;
  height: 12px;
  border: 3px solid var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 18px rgba(53, 232, 141, .45);
}

.brand-divider { height: 15px; width: 1px; background: var(--line); margin: 0 2px; }
.brand-muted { color: var(--muted); font-weight: 600; }

.connection {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.connection-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #e9b94d;
  box-shadow: 0 0 0 4px rgba(233, 185, 77, .10);
}

.connection-dot.online { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.connection-dot.error { background: var(--danger); box-shadow: 0 0 0 4px rgba(255, 124, 110, .12); }

.page {
  width: min(1500px, calc(100% - 48px));
  margin: 26px auto 40px;
}

.viewer-shell {
  position: relative;
  width: 100%;
  aspect-ratio: 32 / 9;
  min-height: 300px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: var(--radius) var(--radius) 0 0;
  background:
    linear-gradient(110deg, rgba(255,255,255,.025), transparent 30%),
    #050607;
  user-select: none;
  touch-action: pan-y;
  box-shadow: 0 25px 80px rgba(0, 0, 0, .28);
}

.frame-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  opacity: 0;
  transition: opacity .18s ease;
}

.frame-image.visible { opacity: 1; }

.playback-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #050607;
  opacity: 0;
  pointer-events: none;
  z-index: 1;
  transition: opacity 180ms linear;
}

.playback-canvas.visible { opacity: 1; }

.viewer-shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background: linear-gradient(180deg, rgba(0,0,0,.16), transparent 30%, transparent 60%, rgba(0,0,0,.62));
}

.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.empty-state strong { color: #d5dade; font-size: 15px; }
.empty-state.hidden { display: none; }

.empty-icon {
  width: 42px;
  height: 32px;
  border: 1px solid rgba(255,255,255,.20);
  border-radius: 7px;
  margin-bottom: 7px;
  position: relative;
}

.empty-icon::after {
  content: "";
  position: absolute;
  width: 10px;
  height: 10px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  inset: 9px auto auto 14px;
}

.frame-meta {
  position: absolute;
  left: 24px;
  bottom: 20px;
  display: flex;
  align-items: baseline;
  gap: 11px;
  text-shadow: 0 2px 18px #000;
  z-index: 3;
}

.frame-date { font-size: 14px; color: rgba(255,255,255,.70); text-transform: capitalize; }
.frame-time { font-size: 25px; line-height: 1; font-variant-numeric: tabular-nums; font-weight: 650; letter-spacing: .025em; }

.live-badge {
  position: absolute;
  top: 18px;
  left: 18px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border-radius: 99px;
  background: rgba(4, 8, 6, .68);
  border: 1px solid rgba(53, 232, 141, .28);
  color: #dffbed;
  backdrop-filter: blur(12px);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .03em;
  transition: opacity .2s ease;
  z-index: 3;
}

.live-badge:not(.active) { opacity: 0; }
.live-badge span, .live-button span { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); }

.icon-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 9px;
  border: 1px solid rgba(255,255,255,.13);
  color: white;
  background: rgba(5,6,7,.50);
  backdrop-filter: blur(10px);
}
.icon-button:hover { background: rgba(28,32,35,.82); }
.icon-button svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.fullscreen-button { position: absolute; top: 18px; right: 18px; z-index: 3; }

.loading {
  position: absolute;
  z-index: 4;
  inset: 0;
  display: none;
  place-items: center;
  pointer-events: none;
}
.loading.active { display: grid; }
.loading span {
  width: 28px;
  height: 28px;
  border: 2px solid rgba(255,255,255,.18);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .75s linear infinite;
  filter: drop-shadow(0 0 8px rgba(53,232,141,.28));
}
@keyframes spin { to { transform: rotate(360deg); } }

.controls {
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 20px 22px 18px;
  background: rgba(17, 20, 23, .90);
}

.action-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 25px; }
.transport { display: flex; gap: 8px; }

.primary-button, .secondary-button, .speed-control select, .date-jump input {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  background: var(--panel-raised);
}

.primary-button {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 0 16px;
  border-color: rgba(53, 232, 141, .30);
  color: #e7fff2;
  background: var(--accent-soft);
  font-size: 13px;
  font-weight: 650;
}
.primary-button:hover:not(:disabled) { background: rgba(53, 232, 141, .22); }
.primary-button svg { width: 15px; height: 15px; fill: currentColor; stroke: currentColor; stroke-width: 2; }
.primary-button .pause-icon { display: none; fill: none; }
.primary-button.playing .play-icon { display: none; }
.primary-button.playing .pause-icon { display: block; }

.speed-control select { padding: 0 34px 0 11px; font-size: 12px; color: var(--muted); }

.date-jump { display: grid; grid-template-columns: auto auto auto; align-items: center; gap: 9px; }
.date-jump label { font-size: 12px; color: var(--muted); margin-right: 3px; }
.date-jump input { color-scheme: dark; padding: 0 11px; font-size: 12px; }
.secondary-button { padding: 0 14px; font-size: 12px; font-weight: 620; }
.secondary-button:hover:not(:disabled) { background: #20252a; }

.timeline-heading, .timeline-footer { display: flex; align-items: center; justify-content: space-between; }
.timeline-heading { margin-bottom: 9px; color: #aab1b7; font-size: 11px; font-variant-numeric: tabular-nums; }
.timeline-hint { color: #636c73; }

.timeline {
  --position: 100%;
  width: 100%;
  height: 22px;
  margin: 0;
  appearance: none;
  background: transparent;
}
.timeline::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 9px;
  background: linear-gradient(to right, var(--accent) 0 var(--position), #343a3f var(--position) 100%);
}
.timeline::-moz-range-track { height: 4px; border-radius: 9px; background: #343a3f; }
.timeline::-moz-range-progress { height: 4px; border-radius: 9px; background: var(--accent); }
.timeline::-webkit-slider-thumb {
  appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -6px;
  border: 4px solid var(--accent);
  border-radius: 50%;
  background: #0c100e;
  box-shadow: 0 0 0 4px rgba(53,232,141,.12), 0 0 16px rgba(53,232,141,.22);
}
.timeline::-moz-range-thumb {
  width: 9px;
  height: 9px;
  border: 4px solid var(--accent);
  border-radius: 50%;
  background: #0c100e;
  box-shadow: 0 0 0 4px rgba(53,232,141,.12);
}
.timeline:focus-visible { outline: 2px solid rgba(53,232,141,.50); outline-offset: 7px; border-radius: 4px; }

.timeline-footer { margin-top: 8px; min-height: 25px; color: #697179; font-size: 11px; }
.live-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 0;
  padding: 4px 0;
  background: none;
  color: #aab3b9;
  font-size: 11px;
}
.live-button:hover:not(:disabled) { color: var(--accent); }

.export-panel {
  margin-top: 18px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(17, 20, 23, .82);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .18);
}

.export-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.export-kicker { color: var(--accent); font-size: 10px; font-weight: 750; letter-spacing: .14em; }
.export-heading h2 { margin: 5px 0 4px; font-size: 19px; font-weight: 680; letter-spacing: -.015em; }
.export-heading p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }

.export-form {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) minmax(190px, 1fr) minmax(120px, .5fr) auto;
  align-items: end;
  gap: 10px;
  margin-top: 19px;
}

.export-field { display: grid; gap: 7px; min-width: 0; }
.export-field > span { color: #aab1b7; font-size: 11px; }
.export-field input, .export-field select, .export-button {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  background: var(--panel-raised);
}
.export-field input { min-width: 0; padding: 0 11px; color-scheme: dark; font-size: 12px; }
.export-field select { padding: 0 32px 0 11px; font-size: 12px; }

.export-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: auto;
  padding: 0 17px;
  border-color: rgba(53, 232, 141, .30);
  color: #e7fff2;
  background: var(--accent-soft);
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}
.export-button:hover:not(:disabled) { background: rgba(53, 232, 141, .22); }
.export-button svg { width: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.export-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 9px;
  color: #697179;
  font-size: 11px;
}
.export-meta span:last-child { color: #77b995; }

.export-status {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid rgba(53, 232, 141, .18);
  border-radius: 10px;
  background: rgba(53, 232, 141, .055);
}
.export-status.failed { border-color: rgba(255,124,110,.25); background: rgba(255,124,110,.06); }
.export-status-line, .export-result { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.export-status-line { font-size: 12px; }
.export-status-line strong { font-weight: 640; }
.export-status-line span { color: var(--muted); font-variant-numeric: tabular-nums; }
.export-progress { height: 4px; margin: 10px 0; overflow: hidden; border-radius: 4px; background: #30363a; }
.export-progress span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--accent); transition: width .25s ease; }
.failed .export-progress span { background: var(--danger); }
.export-result { color: var(--muted); font-size: 11px; }
.export-download {
  flex: none;
  padding: 7px 11px;
  border-radius: 8px;
  color: #08130d;
  background: var(--accent);
  text-decoration: none;
  font-weight: 720;
}
.export-download:hover { background: #6bf2aa; }

.notice {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  max-width: min(420px, calc(100% - 44px));
  padding: 12px 15px;
  border: 1px solid rgba(255,124,110,.25);
  border-radius: 10px;
  background: rgba(42,23,22,.94);
  color: #ffd6d1;
  box-shadow: 0 16px 40px rgba(0,0,0,.35);
  font-size: 12px;
}

.viewer-shell:fullscreen { border: 0; border-radius: 0; background: #000; }

@media (max-width: 800px) {
  .topbar {
    height: 58px;
    padding-right: max(16px, env(safe-area-inset-right));
    padding-left: max(16px, env(safe-area-inset-left));
  }
  .brand-divider, .brand-muted { display: none; }
  .connection { max-width: 54%; }
  .connection span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .page { width: calc(100% - 24px); margin-top: 12px; }
  .viewer-shell { height: min(46svh, 380px); min-height: 230px; aspect-ratio: auto; border-radius: 12px 12px 0 0; }
  .frame-meta { left: 16px; bottom: 16px; }
  .frame-time { font-size: 21px; }
  .live-badge { top: 12px; left: 12px; }
  .fullscreen-button { top: 12px; right: 12px; }
  .controls { padding: 16px; }
  .action-row { align-items: stretch; flex-direction: column; margin-bottom: 21px; gap: 16px; }
  .transport { width: 100%; }
  .primary-button { flex: 1; justify-content: center; }
  .date-jump { grid-template-columns: 1fr auto; }
  .date-jump label { grid-column: 1 / -1; }
  .date-jump input { min-width: 0; width: 100%; }
  .timeline-hint { display: none; }
  .timeline { height: 32px; }
  .timeline::-webkit-slider-thumb { width: 20px; height: 20px; margin-top: -8px; }
  .timeline::-moz-range-thumb { width: 12px; height: 12px; }
  .export-form { grid-template-columns: 1fr 1fr; }
  .export-fps { grid-column: 1; }
  .export-button { grid-column: 2; width: 100%; }
}

@media (max-width: 480px) {
  body { padding-bottom: env(safe-area-inset-bottom); }
  .topbar { position: relative; }
  .brand { font-size: 12px; gap: 8px; }
  .connection { max-width: 50%; font-size: 11px; }
  .page { width: 100%; margin: 0; }
  .viewer-shell {
    height: clamp(220px, 45svh, 340px);
    min-height: 0;
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }
  .frame-meta { left: max(14px, env(safe-area-inset-left)); bottom: 14px; gap: 8px; }
  .frame-date { font-size: 12px; }
  .frame-time { font-size: 20px; }
  .live-badge { left: max(10px, env(safe-area-inset-left)); padding: 6px 9px; }
  .fullscreen-button { right: max(10px, env(safe-area-inset-right)); }
  .controls {
    padding: 14px max(14px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }
  .action-row { gap: 14px; margin-bottom: 17px; }
  .primary-button, .secondary-button, .speed-control select, .date-jump input { min-height: 44px; }
  .speed-control select { max-width: 112px; }
  .date-jump { gap: 8px; }
  .timeline-heading { margin-bottom: 5px; }
  .timeline-footer { margin-top: 4px; }
  .export-panel { margin-top: 10px; padding: 17px max(14px, env(safe-area-inset-right)) 18px max(14px, env(safe-area-inset-left)); border-right: 0; border-left: 0; border-radius: 0; }
  .export-heading h2 { font-size: 18px; }
  .export-form { grid-template-columns: 1fr; gap: 12px; }
  .export-fps, .export-button { grid-column: 1; }
  .export-field input, .export-field select, .export-button { min-height: 44px; }
  .export-meta { align-items: flex-start; flex-direction: column; gap: 4px; }
  .export-status-line, .export-result { align-items: flex-start; }
  .export-result { flex-direction: column; }
  .export-download { width: 100%; padding: 10px 12px; text-align: center; }
  .notice { right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); max-width: calc(100% - 24px); }
}

@media (max-height: 600px) and (orientation: landscape) {
  .topbar { height: 48px; }
  .page { width: 100%; margin: 0; }
  .viewer-shell { height: calc(100svh - 48px); min-height: 0; border: 0; border-radius: 0; }
  .controls { border-right: 0; border-left: 0; border-radius: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
