:root {
  color-scheme: dark;
  --surface: #0e0e0e;
  --toolbar: #303030;
  --toolbar-hover: #3a3a3a;
  --text: #f4f4f4;
  --muted: #c9c9c9;
  --focus: #8bc4ff;
}

* {
  box-sizing: border-box;
}

html,
body,
.app {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  background: #000;
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

.app {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.app:fullscreen,
.app:-webkit-full-screen {
  width: 100%;
  height: 100%;
  background: #000;
}

.toolbar,
.slider {
  min-height: 44px;
  background: var(--toolbar);
  display: flex;
  align-items: center;
}

.toolbar {
  gap: 1px;
  overflow-x: auto;
}

.toolbar-spacer {
  flex: 1 1 auto;
  min-width: 12px;
}

.button,
.select-label,
.datetime-field,
.datetime-picker-toggle {
  height: 44px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
}

.button {
  padding: 0 14px;
  cursor: pointer;
}

.icon-button {
  width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.icon-button svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.icon-button polygon,
.icon-button rect,
.icon-button path {
  vector-effect: non-scaling-stroke;
}

.play-toggle .icon-pause,
.play-toggle.is-playing .icon-play,
.fullscreen-toggle .icon-minimize,
.fullscreen-toggle.is-fullscreen .icon-maximize {
  display: none;
}

.play-toggle.is-playing .icon-pause,
.fullscreen-toggle.is-fullscreen .icon-minimize {
  display: block;
}

.button:hover,
.button.active,
.select-label:hover,
.datetime-field:hover,
.datetime-picker-toggle:hover {
  background: var(--toolbar-hover);
}

.button:disabled {
  color: #777;
  cursor: default;
}

.button:disabled:hover {
  background: transparent;
}

.button:focus-visible,
select:focus-visible,
.datetime-field:focus-visible,
.datetime-picker-toggle:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}

.select-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  white-space: nowrap;
}

select {
  color: var(--text);
  background: var(--toolbar);
  border: 1px solid #555;
  height: 28px;
}

.datetime-control {
  display: flex;
  align-items: center;
  position: relative;
}

.datetime-field {
  min-width: 152px;
  padding: 0 12px;
  line-height: 44px;
  white-space: nowrap;
  user-select: text;
}

.datetime-field:empty::before {
  color: var(--muted);
  content: '--.--.---- --:--';
}

.datetime-picker-toggle {
  width: 34px;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.datetime-picker-toggle svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.datetime-picker {
  position: fixed;
  top: 44px;
  left: 0;
  z-index: 20;
  width: min(260px, calc(100vw - 16px));
  padding: 10px;
  background: #242424;
  border: 1px solid #4a4a4a;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
}

.datetime-picker-row,
.datetime-picker-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.datetime-picker-row + .datetime-picker-row,
.datetime-picker-actions {
  margin-top: 10px;
}

.datetime-picker-input {
  width: 100%;
  height: 36px;
  padding: 0 8px;
  color: var(--text);
  background: #151515;
  border: 1px solid #555;
  font: inherit;
  color-scheme: dark;
}

.datetime-picker-actions .button {
  flex: 1 1 0;
  background: #303030;
  border: 1px solid #555;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 54px 12px 12px;
  background: rgba(0, 0, 0, 0.48);
}

.modal-backdrop[hidden] {
  display: none;
}

.settings-modal {
  width: min(360px, calc(100vw - 24px));
  background: #202020;
  border: 1px solid #4a4a4a;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.52);
}

.settings-header {
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #3a3a3a;
}

.settings-header h2 {
  margin: 0;
  padding: 0 14px;
  font-size: 15px;
  font-weight: 700;
}

.settings-list {
  display: flex;
  flex-direction: column;
}

.settings-row {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
}

.settings-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.settings-copy strong {
  font-size: 14px;
}

.settings-copy span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.settings-toggle {
  width: 42px;
  height: 24px;
  flex: 0 0 auto;
  appearance: none;
  border: 1px solid #686868;
  border-radius: 999px;
  background: #141414;
  cursor: pointer;
  position: relative;
}

.settings-toggle::before {
  width: 18px;
  height: 18px;
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  border-radius: 50%;
  background: #d9d9d9;
  transition: transform 160ms ease, background 160ms ease;
}

.settings-toggle:checked {
  border-color: #8bc4ff;
  background: #245b86;
}

.settings-toggle:checked::before {
  transform: translateX(18px);
  background: #fff;
}

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

.exif-modal {
  width: min(330px, calc(100vw - 24px));
}

.exif-empty {
  margin: 0;
  padding: 14px;
  color: var(--muted);
  font-size: 13px;
}

.exif-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.exif-table th,
.exif-table td {
  padding: 9px 14px;
  border-bottom: 1px solid #333;
  text-align: left;
  vertical-align: top;
}

.exif-table th {
  width: 38%;
  color: var(--muted);
  font-weight: 400;
}

.exif-table td {
  overflow-wrap: anywhere;
}

.stage {
  flex: 1 1 auto;
  min-height: 0;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.status {
  color: var(--muted);
  font-size: 15px;
  position: relative;
  z-index: 2;
}

.ambilight {
  position: absolute;
  inset: -18%;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background-color: var(--ambilight-color, #050505);
  transition: background-color 800ms ease;
}

.ambilight-side {
  width: 30%;
  height: 100%;
  position: absolute;
  top: 0;
  display: grid;
  grid-template-rows: repeat(6, 1fr);
  filter: blur(52px) saturate(1.45) brightness(0.82);
  opacity: 0.82;
  transform: translateZ(0) scale(1.08);
  contain: strict;
}

.ambilight-side-left {
  left: -4%;
}

.ambilight-side-right {
  right: -4%;
}

.ambilight-strip {
  display: block;
  background-color: var(--ambilight-color, #050505);
  background-repeat: no-repeat;
  background-size: auto 600%;
  transition: background-color 800ms ease;
}

.ambilight::after {
  position: absolute;
  inset: 0;
  z-index: 2;
  content: '';
  background:
    radial-gradient(circle at 50% 50%, transparent 0, transparent 38%, rgba(0, 0, 0, 0.42) 72%, rgba(0, 0, 0, 0.76) 100%),
    rgba(0, 0, 0, 0.12);
}

.frame {
  --image-left: 0px;
  --image-top: 0px;
  --image-right: 100%;
  --image-bottom: 100%;
  width: 100%;
  height: 100%;
  margin: 0;
  position: relative;
  min-width: 10em;
  min-height: 10em;
  z-index: 1;
}

.image-stack {
  position: absolute;
  inset: 0;
}

.image-layer {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  opacity: 0;
  transition-property: opacity;
  transition-timing-function: ease-in;
}

.image-layer.current {
  opacity: 1;
  z-index: 2;
}

.image-layer.prev {
  opacity: 0;
  z-index: 3;
}

.image-layer.next {
  opacity: 1;
  z-index: 1;
}

.image-layer-inner {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.image-layer img {
  height: 100%;
  width: auto;
  max-width: 100%;
  display: block;
  object-fit: contain;
}

.viewer-overlay {
  position: absolute;
  z-index: 6;
  max-width: min(720px, calc(100% - 28px));
  padding: 6px 8px;
  color: #050505;
  font-size: clamp(11px, 1.15vw, 16px);
  font-weight: 500;
  line-height: 1.08;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.48);
  pointer-events: none;
}

.viewer-overlay-on-dark {
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.78);
}

.viewer-overlay-on-light {
  color: #070707;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.52);
}

.viewer-overlay-top-left {
  top: calc(var(--image-top) + 6px);
  left: calc(var(--image-left) + 6px);
}

.viewer-overlay-top-right {
  top: calc(var(--image-top) + 6px);
  right: calc(100% - var(--image-right) + 6px);
  text-align: right;
}

.viewer-overlay-bottom-left {
  bottom: calc(100% - var(--image-bottom) + 6px);
  left: calc(var(--image-left) + 6px);
}

.viewer-overlay-bottom-right {
  right: calc(100% - var(--image-right) + 6px);
  bottom: calc(100% - var(--image-bottom) + 6px);
  text-align: right;
}

.viewer-overlay-line {
  overflow-wrap: anywhere;
}

.viewer-overlay-line + .viewer-overlay-line {
  margin-top: 1px;
  font-size: 0.76em;
  font-weight: 500;
}

.viewer-overlay-line-strong {
  font-weight: 700;
}

.viewer-logo {
  position: absolute;
  z-index: 7;
  min-width: 44px;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #111;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(0, 0, 0, 0.16);
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  backdrop-filter: blur(3px);
}

.viewer-logo:hover {
  background: rgba(255, 255, 255, 0.9);
}

.viewer-logo[hidden] {
  display: none;
}

.viewer-logo img {
  display: block;
  max-width: min(118px, 22vw);
  max-height: min(72px, 14vh);
}

.viewer-logo-adaptive {
  width: min(92px, 16vw);
  height: min(92px, 16vw);
  min-width: 52px;
  min-height: 52px;
  padding: 0;
  background: transparent;
  border: 0;
  backdrop-filter: none;
}

.viewer-logo-adaptive:hover {
  background: transparent;
}

.viewer-logo-adaptive-raster {
  min-width: 44px;
  min-height: 24px;
  padding: 0;
  background: transparent !important;
  border: 0;
  backdrop-filter: none;
  font-style: normal;
  text-shadow: none;
}

.viewer-logo-adaptive-raster:hover {
  background: transparent !important;
}

.viewer-logo-adaptive-raster img {
  max-width: min(132px, 22vw);
  max-height: min(44px, 9vh);
}

.viewer-logo-mark {
  width: 100%;
  height: 100%;
  display: block;
  background: #070707;
  mask-repeat: no-repeat;
  mask-position: center;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  -webkit-mask-size: contain;
}

.viewer-logo-on-dark .viewer-logo-mark {
  background: #fff;
}

.viewer-logo-on-light .viewer-logo-mark {
  background: #070707;
}

.viewer-logo-top-right {
  top: calc(var(--image-top) + 10px);
  right: calc(100% - var(--image-right) + 10px);
}

.viewer-logo-bottom-right {
  right: calc(100% - var(--image-right) + 8px);
  bottom: calc(100% - var(--image-bottom) + 8px);
  background: rgba(0, 0, 0, 0.52);
  border-color: rgba(255, 255, 255, 0.28);
  color: #fff;
  font-style: italic;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.frame.is-loading-next::after {
  width: 44px;
  height: 44px;
  border: 4px solid rgba(255, 255, 255, 0.28);
  border-left-color: #e1e1e1;
  border-radius: 50%;
  content: '';
  position: absolute;
  left: calc(50% - 22px);
  top: calc(50% - 22px);
  z-index: 5;
  animation: loading-spin 1.1s linear infinite;
}

@keyframes loading-spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

.slider {
  padding: 0 18px;
  color: var(--muted);
  font-size: 14px;
  position: relative;
}

.slider[hidden] {
  display: none;
}

.timeline-track {
  width: 100%;
  height: 44px;
  position: relative;
  cursor: pointer;
  touch-action: none;
}

.timeline-track::before {
  height: 8px;
  position: absolute;
  right: 4px;
  bottom: 22px;
  left: 4px;
  content: '';
  background: #242424;
  border: 1px solid #555;
}

.timeline-progress {
  height: 8px;
  position: absolute;
  bottom: 23px;
  left: 5px;
  width: 0;
  background: #8bc4ff;
  opacity: 0.85;
  pointer-events: none;
}

.timeline-handle {
  width: 26px;
  height: 28px;
  position: absolute;
  bottom: 13px;
  left: 0;
  transform: translateX(-50%);
  border: 1px solid #777;
  border-radius: 3px;
  background: #f4f4f4;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.38);
  cursor: grab;
}

.timeline-handle:active {
  cursor: grabbing;
}

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

.timeline-ticks {
  position: absolute;
  inset: 0 4px;
  pointer-events: none;
}

.timeline-tick {
  position: absolute;
  bottom: 0;
  transform: translateX(-50%);
  color: #b8b8b8;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.timeline-tick-start {
  transform: none;
}

.timeline-tick-end {
  transform: translateX(-100%);
}

.timeline-tick::before {
  width: 1px;
  height: 7px;
  position: absolute;
  left: 50%;
  bottom: 22px;
  content: '';
  background: #666;
}

@media (max-width: 560px) {
  .toolbar {
    min-height: 88px;
    flex-wrap: wrap;
    align-content: stretch;
  }

  .button,
  .select-label,
  .datetime-control,
  .datetime-field {
    flex: 1 0 auto;
  }

  .datetime-picker {
    left: 0;
    right: auto;
  }

  .toolbar-spacer {
    flex-basis: 0;
    min-width: 0;
  }

  .modal-backdrop {
    align-items: flex-start;
    justify-content: center;
    padding-top: 98px;
  }

  .slider {
    padding: 0 12px;
  }

  .timeline-tick {
    font-size: 10px;
  }
}
