:root {
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top, rgba(148, 163, 184, 0.16), transparent 32%),
    radial-gradient(circle at 20% 0%, rgba(59, 130, 246, 0.12), transparent 26%),
    linear-gradient(180deg, #2a2f36 0%, #1f2328 100%);
  color: #e2e8f0;
}

body.pdf-mode {
  overflow: hidden;
  background: #1f2328;
  overscroll-behavior: none;
}

.page-shell {
  width: min(1200px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.5rem 0 4rem;
}

.content-panel {
  margin-top: 1.5rem;
  display: grid;
  gap: 1rem;
}

.status-card,
.selection-card,
.viewer-card {
  padding: 1.5rem;
  border-radius: 1.5rem;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: linear-gradient(180deg, rgba(43, 50, 60, 0.96), rgba(29, 34, 40, 0.96));
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.28);
}

.selection-card {
  position: relative;
  overflow: hidden;
}

.selection-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at top right, rgba(96, 165, 250, 0.16), transparent 28%),
    radial-gradient(circle at bottom left, rgba(148, 163, 184, 0.08), transparent 30%);
  pointer-events: none;
}

.selection-hero,
.file-list {
  position: relative;
  z-index: 1;
}

.selection-hero {
  display: grid;
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}

.selection-kicker {
  margin: 0;
  color: #93c5fd;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.selection-count {
  margin: 0;
  padding: 0.55rem 0.9rem;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.32);
  color: #cbd5e1;
  font-size: 0.95rem;
  font-weight: 700;
  white-space: nowrap;
}

.file-list {
  display: grid;
  gap: 0.9rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.file-button {
  width: 100%;
  min-height: 11.5rem;
  padding: 1.15rem;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 1.35rem;
  background:
    linear-gradient(180deg, rgba(51, 65, 85, 0.9), rgba(30, 41, 59, 0.92)),
    linear-gradient(135deg, rgba(96, 165, 250, 0.08), transparent 50%);
  color: #e2e8f0;
  text-align: left;
  cursor: pointer;
  display: grid;
  gap: 1rem;
  align-content: space-between;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03), 0 16px 34px rgba(2, 6, 23, 0.18);
  transition:
    transform 140ms ease,
    box-shadow 140ms ease,
    border-color 140ms ease,
    background 140ms ease;
}

.file-preview {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 13rem;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 1rem;
  background:
    linear-gradient(180deg, rgba(15, 23, 42, 0.72), rgba(15, 23, 42, 0.92)),
    linear-gradient(135deg, rgba(96, 165, 250, 0.12), transparent 60%);
}

.file-preview::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 24%, rgba(15, 23, 42, 0.14) 100%);
  pointer-events: none;
}

.file-preview-placeholder,
.file-preview-fallback,
.file-preview-audio {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  gap: 0.65rem;
  padding: 1rem;
  color: #cbd5e1;
  text-align: center;
}

.file-preview-loader {
  width: 1.1rem;
  height: 1.1rem;
  border: 2px solid rgba(148, 163, 184, 0.32);
  border-top-color: #f8fafc;
  border-radius: 999px;
  animation: pdf-loader-spin 0.8s linear infinite;
}

.file-preview-image,
.file-preview-canvas {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}

.file-preview-canvas {
  width: 100%;
  height: auto;
  background: #fff;
}

.file-preview-audio-bars {
  display: flex;
  align-items: end;
  gap: 0.35rem;
  height: 3rem;
}

.file-preview-audio-bars span {
  width: 0.45rem;
  border-radius: 999px;
  background: linear-gradient(180deg, #93c5fd, #c4b5fd);
  opacity: 0.9;
}

.file-preview-audio-bars span:nth-child(1) {
  height: 36%;
}

.file-preview-audio-bars span:nth-child(2) {
  height: 82%;
}

.file-preview-audio-bars span:nth-child(3) {
  height: 58%;
}

.file-preview-audio-bars span:nth-child(4) {
  height: 100%;
}

.file-preview-audio-bars span:nth-child(5) {
  height: 44%;
}

.file-preview-audio-label,
.file-preview-fallback-label {
  color: #cbd5e1;
  font-size: 0.92rem;
  font-weight: 700;
}

.file-button-topline,
.file-button-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.file-type-badge {
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.file-type-pdf {
  background: rgba(248, 113, 113, 0.14);
  color: #fca5a5;
}

.file-type-image {
  background: rgba(45, 212, 191, 0.12);
  color: #99f6e4;
}

.file-type-audio {
  background: rgba(167, 139, 250, 0.14);
  color: #ddd6fe;
}

.file-size {
  color: #94a3b8;
  font-size: 0.88rem;
  font-weight: 600;
}

.file-name {
  color: #f8fafc;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.45;
  word-break: break-word;
}

.file-open-label {
  color: #cbd5e1;
  font-size: 0.92rem;
  font-weight: 700;
}

.file-open-arrow {
  color: #93c5fd;
  font-size: 1.15rem;
  font-weight: 700;
}

.file-button:hover,
.file-button:focus-visible {
  transform: translateY(-3px);
  border-color: rgba(147, 197, 253, 0.38);
  background:
    linear-gradient(180deg, rgba(59, 74, 95, 0.96), rgba(37, 47, 63, 0.96)),
    linear-gradient(135deg, rgba(96, 165, 250, 0.14), transparent 50%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 22px 46px rgba(2, 6, 23, 0.28);
  outline: none;
}

.viewer-stack {
  display: grid;
  gap: 1rem;
}

.pdf-viewer-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: linear-gradient(180deg, #2a2f36 0%, #1f2328 100%);
}

.pdf-reader-shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  padding:
    calc(env(safe-area-inset-top, 0px) + 0.5rem)
    calc(env(safe-area-inset-right, 0px) + 0.5rem)
    calc(env(safe-area-inset-bottom, 0px) + 0.5rem)
    calc(env(safe-area-inset-left, 0px) + 0.5rem);
}

.pdf-back-bar {
  position: fixed;
  left: calc(env(safe-area-inset-left, 0px) + 1rem);
  top: calc(env(safe-area-inset-top, 0px) + 1rem);
  z-index: 31;
}

.pdf-back-button {
  min-height: 2.8rem;
  padding: 0.75rem 1rem;
  border: 1px solid rgba(148, 163, 184, 0.26);
  background: rgba(226, 232, 240, 0.92);
  box-shadow: 0 14px 28px rgba(2, 6, 23, 0.22);
}

.pdf-page-stack {
  flex: 1 1 auto;
  overflow: auto;
  display: block;
  counter-reset: pdf-page;
  padding-top: 0.35rem;
  padding-bottom: 1rem;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y;
  scrollbar-gutter: stable both-edges;
}

.pdf-page {
  counter-increment: pdf-page;
  position: relative;
  padding: 0;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  min-height: 0;
  width: 100%;
  box-shadow: none;
  margin: 0 0 2.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.pdf-page:last-child {
  margin-bottom: 0;
}

.pdf-page:not(:first-child)::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -1.45rem;
  width: min(100%, 56rem);
  height: 1px;
  transform: translateX(-50%);
  background: linear-gradient(90deg, rgba(148, 163, 184, 0), rgba(148, 163, 184, 0.95) 18%, rgba(15, 23, 42, 0.28) 50%, rgba(148, 163, 184, 0.95) 82%, rgba(148, 163, 184, 0));
}

.pdf-page:not(:first-child)::after {
  content: "Seite " counter(pdf-page);
  position: absolute;
  left: 50%;
  top: -1.45rem;
  transform: translate(-50%, -50%);
  padding: 0.22rem 0.8rem;
  border: 1px solid rgba(148, 163, 184, 0.75);
  border-radius: 999px;
  background: rgba(248, 250, 252, 0.96);
  color: #475569;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.2;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
  pointer-events: none;
}

.pdf-zoom-overlay {
  position: fixed;
  right: calc(env(safe-area-inset-right, 0px) + 2.1rem);
  top: env(safe-area-inset-top, 0px);
  z-index: 30;
  display: grid;
  justify-items: end;
  gap: 0.65rem;
  pointer-events: none;
}

.pdf-menu-anchor {
  position: relative;
  display: grid;
  justify-items: end;
  pointer-events: auto;
}

.pdf-zoom-panel,
.pdf-zoom-fab,
.pdf-zoom-toast {
  pointer-events: auto;
}

.pdf-zoom-panel {
  position: absolute;
  top: calc(100% + 0.65rem);
  right: 0;
  width: min(22rem, calc(100vw - 1.5rem));
  display: grid;
  gap: 0.9rem;
  padding: 0.95rem;
  border: 1px solid rgba(148, 163, 184, 0.36);
  border-radius: 1.25rem;
  background: rgba(248, 250, 252, 0.97);
  backdrop-filter: blur(18px);
  box-shadow: 0 18px 38px rgba(15, 23, 42, 0.18);
}

.pdf-menu-section {
  display: grid;
  gap: 0.7rem;
}

.pdf-menu-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.pdf-menu-heading {
  color: #0f172a;
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.pdf-menu-status {
  color: #475569;
  font-size: 0.88rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.pdf-menu-divider {
  height: 1px;
  background: linear-gradient(90deg, rgba(148, 163, 184, 0), rgba(148, 163, 184, 0.9) 18%, rgba(148, 163, 184, 0.9) 82%, rgba(148, 163, 184, 0));
}

.pdf-zoom-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
}

.pdf-zoom-panel-button {
  min-height: 2.8rem;
  min-width: 0;
  width: 100%;
  padding: 0.75rem 0.9rem;
}

.pdf-zoom-fit-button {
  min-width: 0;
}

.pdf-page-jump {
  display: grid;
  gap: 0.55rem;
  padding-left: 0;
}

.pdf-page-jump-label {
  color: #0f172a;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.pdf-page-jump-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.5rem;
}

.pdf-page-jump-input {
  width: 100%;
  min-height: 2.8rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid rgba(148, 163, 184, 0.7);
  border-radius: 0.85rem;
  background: rgba(255, 255, 255, 0.92);
  color: #0f172a;
  font: inherit;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.pdf-page-jump-input:focus {
  outline: 2px solid rgba(37, 99, 235, 0.28);
  outline-offset: 2px;
  border-color: rgba(37, 99, 235, 0.55);
}

.pdf-page-jump-total {
  color: #64748b;
  font-size: 0.85rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.pdf-page-jump-button {
  min-height: 2.8rem;
  min-width: 3.6rem;
  padding: 0.75rem 0.95rem;
}

.pdf-icon-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.pdf-icon {
  display: block;
  width: 1.35rem;
  height: 1.35rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pdf-zoom-icon {
  width: 1.4rem;
  height: 1.4rem;
}

.pdf-zoom-fab {
  min-height: 3.3rem;
  min-width: 3.3rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  box-shadow: 0 18px 38px rgba(15, 23, 42, 0.22);
}

.pdf-zoom-fab[aria-expanded="true"] {
  background: #1e293b;
}

.pdf-zoom-fab-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  line-height: 0;
}

.pdf-menu-icon {
  width: 1.5rem;
  height: 1.5rem;
}

.pdf-zoom-toast {
  position: absolute;
  top: calc(100% + 0.65rem);
  right: 0;
  padding: 0.55rem 0.8rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.92);
  color: #fff;
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(0.35rem) scale(0.96);
  transition: opacity 160ms ease, transform 220ms ease;
}

.pdf-zoom-toast-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.pdf-canvas {
  display: block;
  height: auto;
  max-width: none;
  margin: 0 auto;
  user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
}

.pdf-document-loading {
  position: fixed;
  inset: 0;
  z-index: 21;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  padding: 2rem;
  background: linear-gradient(180deg, #2a2f36 0%, #1f2328 100%);
  color: #e2e8f0;
  font-size: 1.05rem;
  font-weight: 600;
  text-align: center;
}

.pdf-document-loading-error {
  color: #fecaca;
}

.pdf-placeholder {
  min-height: 14rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  color: #64748b;
  text-align: center;
}

.pdf-loader {
  width: 1rem;
  height: 1rem;
  border: 2px solid #cbd5e1;
  border-top-color: #0f172a;
  border-radius: 999px;
  animation: pdf-loader-spin 0.8s linear infinite;
  flex: 0 0 auto;
}

.pdf-loader-large {
  width: 1.35rem;
  height: 1.35rem;
  border-width: 3px;
  border-color: rgba(226, 232, 240, 0.28);
  border-top-color: #f8fafc;
}

@keyframes pdf-loader-spin {
  to {
    transform: rotate(360deg);
  }
}

.media-frame {
  overflow: hidden;
  border-radius: 1.25rem;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(15, 23, 42, 0.72);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}

.restricted-image-canvas {
  display: block;
  height: auto;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
  pointer-events: none;
  margin: 0 auto;
}

.audio-shell {
  display: grid;
  gap: 1rem;
}

.audio-element {
  width: 100%;
  pointer-events: none;
}

.audio-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.action-button {
  min-height: 2.9rem;
  padding: 0.85rem 1rem;
  border: none;
  border-radius: 999px;
  background: #0f172a;
  color: #fff;
  cursor: pointer;
  font: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.action-button:disabled {
  cursor: default;
  opacity: 0.72;
}

.action-button.secondary {
  background: #cbd5e1;
  color: #0f172a;
}

.meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.section-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: #f8fafc;
}

.section-copy {
  margin: 0;
  color: #94a3b8;
}

.hidden {
  display: none !important;
}

@media (max-width: 640px) {
  .page-shell {
    width: min(100% - 1rem, 1200px);
    padding-top: 0.75rem;
  }

  .status-card,
  .selection-card,
  .viewer-card {
    padding: 1.1rem;
    border-radius: 1rem;
  }

  .file-list {
    grid-template-columns: 1fr;
  }

  .file-button {
    min-height: 9.8rem;
    padding: 1rem;
  }

  .file-preview {
    min-height: 10.5rem;
  }

  .pdf-reader-shell {
    padding:
      calc(env(safe-area-inset-top, 0px) + 0.35rem)
      calc(env(safe-area-inset-right, 0px) + 0.35rem)
      calc(env(safe-area-inset-bottom, 0px) + 0.35rem)
      calc(env(safe-area-inset-left, 0px) + 0.35rem);
  }

  .pdf-page-stack {
    padding-top: 0.25rem;
    padding-bottom: 0.75rem;
  }

  .pdf-page {
    margin-bottom: 2.2rem;
  }

  .pdf-page:not(:first-child)::before {
    top: -1.15rem;
    width: min(100%, 42rem);
  }

  .pdf-page:not(:first-child)::after {
    top: -1.15rem;
    padding: 0.18rem 0.65rem;
    font-size: 0.72rem;
  }

  .pdf-zoom-overlay {
    right: calc(env(safe-area-inset-right, 0px) + 0.75rem);
    top: calc(env(safe-area-inset-top, 0px) + 0.75rem);
  }

  .pdf-zoom-panel {
    width: min(20rem, calc(100vw - 1rem));
    gap: 0.75rem;
    padding: 0.85rem;
  }

  .pdf-zoom-panel-button {
    min-height: 2.9rem;
  }

  .pdf-zoom-fit-button {
    padding-inline: 0.8rem;
  }

  .pdf-page-jump {
    width: 100%;
  }

  .pdf-page-jump-controls {
    grid-template-columns: 1fr;
    gap: 0.45rem;
  }

  .pdf-page-jump-input {
    min-height: 2.9rem;
  }

  .pdf-page-jump-button {
    min-height: 2.9rem;
    padding-inline: 0.8rem;
  }
}
