.download-view {
  width: min(38rem, calc(100% - 2rem));
  min-height: calc(100vh - 7.25rem);
  margin: 0 auto;
  padding: 2.5rem 0;
  display: grid;
  place-items: center;
}

.download-view-wide {
  width: min(58rem, calc(100% - 2rem));
}

.download-card {
  text-align: center;
}

.preview-view {
  width: min(72rem, calc(100% - 2rem));
  min-height: auto;
  padding-block: clamp(2rem, 7vh, 4.5rem);
  display: block;
}

.preview-card {
  width: 100%;
  margin: 0 auto;
  text-align: left;
}

.preview-card .card-content {
  padding: clamp(1rem, 2.4vw, 1.5rem);
}

.preview-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.preview-title-group {
  min-width: 0;
}

.preview-header .file-name {
  margin: 0;
  font-size: clamp(1.35rem, 2.4vw, 2rem);
  line-height: 1.12;
}

.preview-header .download-subtitle {
  margin: 0.45rem 0 0;
}

.preview-header > .button {
  flex: 0 0 auto;
  padding-inline: 1rem;
  overflow: visible;
}

.preview-header > .button svg {
  flex: 0 0 auto;
}

[data-theme="retro"] .preview-header > .button-primary:active {
  padding-right: calc(1rem - 1px);
}

.preview-window {
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--border) 78%, var(--primary));
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--card) 94%, transparent), color-mix(in srgb, var(--background) 92%, transparent));
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
}

.preview-window-titlebar {
  min-height: 3rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.72rem 0.9rem;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--muted) 62%, transparent);
}

.preview-window-titlebar > div:first-child {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
}

.preview-window-titlebar strong {
  font-size: 0.92rem;
}

.preview-window-titlebar span {
  overflow: hidden;
  color: var(--muted-foreground);
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-window-tools {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
}

.preview-fullscreen-button {
  appearance: none;
  min-height: 2rem;
  padding: 0.35rem 0.7rem;
  border: 1px solid color-mix(in srgb, var(--border) 82%, var(--primary));
  border-radius: calc(var(--radius) - 0.35rem);
  background: color-mix(in srgb, var(--muted) 74%, transparent);
  color: var(--foreground);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.preview-fullscreen-button:hover {
  background: color-mix(in srgb, var(--primary) 18%, var(--muted));
}

.preview-fullscreen-button[hidden] {
  display: none !important;
}

.preview-window-actions {
  display: inline-flex;
  gap: 0.35rem;
}

.preview-window-actions span {
  width: 0.72rem;
  height: 0.72rem;
  border: 1px solid color-mix(in srgb, var(--border) 75%, var(--foreground));
  border-radius: 999px;
  background: var(--muted);
}

.preview-tabs {
  display: flex;
  gap: 0.35rem;
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--card) 78%, transparent);
}

.preview-tabs[hidden] {
  display: none !important;
}

.preview-tab {
  appearance: none;
  min-height: 2rem;
  padding: 0.35rem 0.7rem;
  border: 1px solid transparent;
  border-radius: calc(var(--radius) - 0.35rem);
  background: transparent;
  color: var(--muted-foreground);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.preview-tab:hover,
.preview-tab.is-active {
  border-color: color-mix(in srgb, var(--border) 82%, var(--primary));
  background: color-mix(in srgb, var(--muted) 78%, transparent);
  color: var(--foreground);
}

.preview-stage {
  overflow: hidden;
  min-height: clamp(18rem, 64vh, 38rem);
  display: grid;
  place-items: center;
  background:
    linear-gradient(45deg, color-mix(in srgb, var(--muted) 18%, transparent) 25%, transparent 25%),
    linear-gradient(-45deg, color-mix(in srgb, var(--muted) 18%, transparent) 25%, transparent 25%),
    color-mix(in srgb, var(--background) 88%, #000);
  background-position: 0 0, 0.5rem 0.5rem;
  background-size: 1rem 1rem;
}

.preview-stage > * {
  grid-area: 1 / 1;
}

.preview-stage > img,
.preview-stage > video {
  max-height: clamp(18rem, 64vh, 38rem);
  width: 100%;
  object-fit: contain;
}

.preview-stage > audio {
  width: min(42rem, calc(100% - 2rem));
}

.default-preview,
.large-preview-gate {
  width: min(26rem, calc(100% - 2rem));
  display: grid;
  place-items: center;
  gap: 0.9rem;
  padding: 2rem;
  color: var(--muted-foreground);
  text-align: center;
}

.default-preview img {
  width: 5.5rem;
  height: 5.5rem;
  object-fit: contain;
}

.default-preview div {
  min-width: 0;
  display: grid;
  gap: 0.25rem;
}

.default-preview strong {
  max-width: 100%;
  overflow: hidden;
  color: var(--foreground);
  font-size: 1rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.default-preview span {
  font-size: 0.86rem;
}

.large-preview-gate {
  border: 1px solid color-mix(in srgb, var(--border) 82%, var(--danger));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--card) 92%, #000);
}

.large-preview-gate strong {
  color: var(--foreground);
  font-size: 1rem;
}

.large-preview-gate p {
  margin: 0;
  line-height: 1.45;
}

.large-preview-gate div {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}

.native-preview {
  width: 100%;
  height: clamp(18rem, 64vh, 38rem);
}

.video-scenes-preview {
  object-fit: contain;
  background: color-mix(in srgb, var(--background) 88%, black 12%);
}

.native-audio-preview {
  align-self: center;
  width: min(42rem, calc(100% - 2rem));
  height: auto;
}

.archive-browser-preview {
  width: 100%;
  height: clamp(18rem, 64vh, 38rem);
  overflow: auto;
  background: color-mix(in srgb, var(--card) 86%, black 14%);
  color: var(--foreground);
}

.archive-browser-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--card) 92%, black 8%);
}

.archive-browser-header strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 0.98rem;
}

.archive-browser-header span {
  color: var(--muted-foreground);
  font-size: 0.82rem;
}

.archive-tree {
  padding: 0.6rem 0.8rem 1rem;
  font-family: Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace;
  font-size: 0.88rem;
  line-height: 1.45;
}

.archive-node {
  min-width: max-content;
}

.archive-node-row {
  display: grid;
  grid-template-columns: 1.25rem 1.45rem minmax(12rem, 1fr) auto;
  align-items: center;
  gap: 0.45rem;
  min-height: 2.1rem;
  padding: 0.18rem 0.45rem;
  border-radius: 6px;
  color: var(--foreground);
}

.archive-node-row:hover {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.archive-folder > summary {
  cursor: pointer;
  list-style: none;
}

.archive-folder > summary::-webkit-details-marker {
  display: none;
}

.archive-chevron,
.archive-chevron-spacer,
.archive-file-icon {
  display: inline-grid;
  place-items: center;
  width: 1.25rem;
  height: 1.25rem;
}

.archive-chevron {
  color: var(--muted-foreground);
  transition: transform 140ms ease, color 140ms ease;
}

.archive-folder[open] > summary .archive-chevron {
  transform: rotate(90deg);
  color: var(--accent);
}

.archive-chevron svg {
  width: 1.18rem;
  height: 1.18rem;
}

.archive-file-icon {
  color: var(--muted-foreground);
}

.archive-svg-icon,
.archive-retro-icon {
  display: inline-grid;
  place-items: center;
  width: 100%;
  height: 100%;
}

.archive-retro-icon {
  display: none;
  object-fit: contain;
  image-rendering: pixelated;
}

.archive-file-icon svg,
.archive-chevron svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.archive-file-icon-folder {
  color: var(--accent);
}

.archive-file-icon-folder svg {
  fill: color-mix(in srgb, var(--accent) 18%, transparent);
}

.archive-file-icon-img {
  color: #67e8f9;
}

.archive-file-icon-vid {
  color: #f9a8d4;
}

.archive-file-icon-aud {
  color: #86efac;
}

.archive-file-icon-code {
  color: #c4b5fd;
}

.archive-file-icon-arc {
  color: #fcd34d;
}

.archive-file-icon-txt {
  color: #f8fafc;
}

[data-theme="retro"] .archive-browser-preview {
  border: 1px solid #000000;
  background: #ffffff;
  color: #000000;
  box-shadow:
    inset -1px -1px 0 #808080,
    inset 1px 1px 0 #ffffff;
}

[data-theme="retro"] .archive-browser-header {
  border-bottom: 1px solid #808080;
  background: #c0c0c0;
  color: #000000;
  box-shadow:
    inset -1px -1px 0 #808080,
    inset 1px 1px 0 #ffffff;
}

[data-theme="retro"] .archive-browser-header span {
  color: #404040;
}

[data-theme="retro"] .archive-tree {
  background: #ffffff;
  font-family: "PixelOperatorMono", "Courier New", monospace;
}

[data-theme="retro"] .archive-node-row {
  min-height: 1.8rem;
  border-radius: 0;
  color: #000000;
}

[data-theme="retro"] .archive-node-row:hover {
  background: #000078;
  color: #ffffff;
}

[data-theme="retro"] .archive-node-size {
  color: #404040;
}

[data-theme="retro"] .archive-node-row:hover .archive-node-size {
  color: #ffffff;
}

[data-theme="retro"] .archive-chevron {
  color: #000000;
}

[data-theme="retro"] .archive-folder[open] > summary .archive-chevron {
  color: #000078;
}

[data-theme="retro"] .archive-node-row:hover .archive-chevron,
[data-theme="retro"] .archive-node-row:hover .archive-file-icon {
  color: #ffffff;
}

[data-theme="retro"] .archive-chevron svg {
  width: 1.35rem;
  height: 1.35rem;
  stroke-width: 2.4;
}

[data-theme="retro"] .archive-file-icon {
  width: 1.45rem;
  height: 1.45rem;
  color: #000000;
}

[data-theme="retro"] .archive-svg-icon {
  display: none;
}

[data-theme="retro"] .archive-retro-icon {
  display: block;
}

[data-theme="retro"] .archive-browser-empty,
[data-theme="retro"] .archive-browser-legacy {
  color: #000000;
  background: #ffffff;
  font-family: "PixelOperatorMono", "Courier New", monospace;
}

.archive-node-name {
  min-width: 0;
  overflow-wrap: anywhere;
}

.archive-node-size {
  color: var(--muted-foreground);
  font-size: 0.78rem;
}

.archive-browser-empty {
  margin: 0;
  padding: 1rem;
  color: var(--muted-foreground);
}

.archive-browser-legacy {
  min-width: max-content;
  margin: 0;
  padding: 1rem;
  color: var(--foreground);
  font-family: Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace;
  font-size: 0.88rem;
  line-height: 1.55;
  white-space: pre;
}

.preview-placeholder {
  display: grid;
  place-items: center;
  gap: 0.8rem;
  padding: 2rem;
  color: var(--muted-foreground);
  text-align: center;
}

.preview-placeholder[hidden],
.default-preview[hidden],
.native-preview[hidden],
.archive-browser-preview[hidden],
.large-preview-gate[hidden],
.code-preview[hidden],
.render-preview[hidden] {
  display: none !important;
}

.preview-placeholder img {
  width: 5rem;
  height: 5rem;
  object-fit: contain;
  opacity: 0.78;
}

.preview-placeholder p {
  margin: 0;
  font-size: 0.9rem;
}

.code-preview {
  min-width: 0;
  width: 100%;
  height: clamp(18rem, 64vh, 38rem);
  overflow: auto;
  background: #1b1724;
}

.code-preview pre[class*="language-"] {
  width: max-content;
  min-width: 100%;
  min-height: 100%;
  margin: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  font-size: 0.88rem;
  line-height: 1.55;
  overflow: visible;
  text-shadow: none;
}

.code-preview pre {
  width: max-content;
  min-width: 100%;
  min-height: 100%;
  margin: 0;
  padding: 1rem;
  overflow: visible;
  color: #f5f3ff;
  font-family: Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace;
  font-size: 0.88rem;
  line-height: 1.55;
  white-space: pre;
}

.code-preview pre[class*="language-"] > code {
  white-space: pre;
}

.code-preview code[class*="language-"] {
  text-shadow: none;
}

.code-preview .token.punctuation {
  opacity: 0.9;
}

.render-preview {
  width: 100%;
  height: clamp(18rem, 64vh, 38rem);
  border: 0;
  background: var(--background);
}

.preview-window:fullscreen,
.preview-window.is-render-fullscreen {
  width: 100dvw;
  height: 100dvh;
  max-width: none;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  border: 0;
  border-radius: 0;
  background: var(--background);
}

.preview-window.is-render-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 1000;
}

.preview-window:fullscreen .preview-stage,
.preview-window.is-render-fullscreen .preview-stage {
  min-height: 0;
  height: 100%;
  place-items: stretch;
}

.preview-window:fullscreen .render-preview,
.preview-window.is-render-fullscreen .render-preview {
  width: 100%;
  height: 100%;
}

.file-emblem {
  width: 4rem;
  height: 4rem;
  margin: 0 auto 1rem;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: var(--muted);
  color: var(--muted-foreground);
}

.svg-icon {
  width: 1rem;
  height: 1rem;
  display: inline-block;
  flex: 0 0 auto;
  background-color: currentColor;
  vertical-align: -0.125em;
  mask: var(--svg-icon-url) center / contain no-repeat;
  -webkit-mask: var(--svg-icon-url) center / contain no-repeat;
}

.svg-icon-document {
  --svg-icon-url: url("/static/icons/regular/submit-document.svg");
}

.svg-icon-share {
  --svg-icon-url: url("/static/icons/regular/share-android.svg");
}

.svg-icon-download {
  --svg-icon-url: url("/static/icons/regular/download.svg");
}

.svg-icon-list {
  --svg-icon-url: url("/static/icons/regular/list.svg");
}

.svg-icon-grid {
  --svg-icon-url: url("/static/icons/regular/view-grid.svg");
}

.svg-icon-emoji {
  --svg-icon-url: url("/static/icons/regular/emoji.svg");
}

.svg-icon-open {
  --svg-icon-url: url("/static/icons/regular/open-in-browser.svg");
}

.svg-icon-copy {
  --svg-icon-url: url("/static/icons/regular/copy.svg");
}

.svg-icon-eye {
  --svg-icon-url: url("/static/icons/regular/eye.svg");
}

.file-emblem .svg-icon {
  width: 1.75rem;
  height: 1.75rem;
}

.badge-row {
  margin-top: 1rem;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}


.download-item {
  color: var(--foreground);
  text-align: left;
  text-decoration: none;
}

.button.is-disabled {
  opacity: .62;
  cursor: not-allowed;
  pointer-events: none;
}

.download-share-button {
  margin-top: 1rem;
  margin-bottom: 0.65rem;
}

.upload-processing-alert {
  margin: 1rem 0;
  padding: .85rem 1rem;
  border: 1px solid color-mix(in srgb, var(--primary) 45%, transparent);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  color: var(--foreground);
}

.upload-processing-alert-error {
  border-color: color-mix(in srgb, var(--danger) 55%, transparent);
  background: color-mix(in srgb, var(--danger) 14%, transparent);
}

.thumb-link {
  flex: 0 0 4.75rem;
  width: 4.75rem;
  aspect-ratio: 16 / 10;
  display: block;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 0.2rem);
  background: var(--muted);
}

.thumb-link img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.button.is-active {
  background: var(--primary);
  color: var(--primary-foreground);
}

.file-browser-window {
  overflow: hidden;
  margin-top: 1.25rem;
  border: 1px solid color-mix(in srgb, var(--border) 78%, var(--primary));
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--card) 94%, transparent), color-mix(in srgb, var(--background) 92%, transparent));
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.24);
  text-align: left;
}

.file-browser-titlebar {
  min-height: 3rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--muted) 62%, transparent);
}

.file-browser-titlebar > div:first-child {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
}

.file-browser-titlebar strong {
  font-size: 0.95rem;
}

.file-browser-titlebar span {
  color: var(--muted-foreground);
  font-size: 0.78rem;
  white-space: nowrap;
}

.file-browser-window-actions {
  display: inline-flex;
  gap: 0.35rem;
}

.file-browser-window-actions span {
  width: 0.72rem;
  height: 0.72rem;
  border: 1px solid color-mix(in srgb, var(--border) 75%, var(--foreground));
  border-radius: 999px;
  background: var(--muted);
}

.file-browser-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--card) 74%, transparent);
}

.view-toolbar {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.view-toolbar .button,
.file-browser-toolbar > .button {
  min-height: 2rem;
  padding: 0.35rem 0.65rem;
  font-size: 0.78rem;
}

.view-toolbar .icon-button {
  width: 2.25rem;
  padding-inline: 0;
  justify-content: center;
}

.view-toolbar .svg-icon {
  width: 0.95rem;
  height: 0.95rem;
}

.file-browser-head {
  display: grid;
  grid-template-columns: 3rem minmax(0, 1fr) minmax(8rem, 0.38fr) minmax(5rem, 0.18fr) minmax(8rem, 0.32fr);
  gap: 0.75rem;
  padding: 0.42rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--muted-foreground);
  background: color-mix(in srgb, var(--background) 78%, transparent);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.file-browser-head span:first-child {
  grid-column: 2;
}

.file-browser {
  display: grid;
  gap: 0;
  padding: 0.35rem;
  transition: opacity 160ms ease;
}

.file-browser .download-item {
  display: grid;
  min-width: 0;
  border: 0;
  border-radius: calc(var(--radius) - 0.25rem);
  background: transparent;
  box-shadow: none;
  padding: 0;
  transform: none;
}

.file-browser .download-item:hover {
  transform: none;
}

.file-card {
  position: relative;
  padding: 0;
}

.file-card.is-processing {
  opacity: .62;
  filter: grayscale(.25);
}

.file-card.is-processing .file-open {
  cursor: wait;
}

.file-card.is-failed {
  border-color: color-mix(in srgb, var(--danger) 55%, var(--border));
  background: color-mix(in srgb, var(--danger) 8%, var(--background));
}

.file-card.is-failed .file-open {
  cursor: not-allowed;
}

.file-error {
  display: block;
  max-width: 100%;
  margin-top: 0.18rem;
  color: var(--danger);
  white-space: normal;
  overflow-wrap: anywhere;
}

.file-reaction-dock {
  position: static;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
  max-width: 100%;
  gap: 0.35rem;
  pointer-events: none;
  padding-right: 0.65rem;
}

.file-reactions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
  gap: 0.25rem;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.reaction-pill {
  appearance: none;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  min-height: 1.6rem;
  padding: 0.16rem 0.38rem;
  border: 1px solid color-mix(in srgb, var(--border) 84%, var(--primary));
  border-radius: 999px;
  background: color-mix(in srgb, var(--card) 88%, #000);
  color: var(--foreground);
  font-size: 0.75rem;
  font-weight: 700;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.24);
  pointer-events: auto;
  cursor: pointer;
}

.reaction-pill.is-hidden-summary {
  display: none;
}

.reaction-pill img {
  width: 1rem;
  height: 1rem;
  display: block;
}

.reaction-more {
  appearance: none;
  flex: 0 0 auto;
  min-height: 1.6rem;
  padding: 0.16rem 0.45rem;
  border: 1px solid color-mix(in srgb, var(--border) 84%, var(--primary));
  border-radius: 999px;
  background: color-mix(in srgb, var(--card) 88%, #000);
  color: var(--foreground);
  font-size: 0.75rem;
  font-weight: 800;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.24);
  pointer-events: auto;
  cursor: pointer;
}

.reaction-pill:hover,
.reaction-pill:focus-visible,
.reaction-more:hover,
.reaction-more:focus-visible {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--primary-foreground);
}

.reaction-button {
  width: 2.1rem;
  height: 2.1rem;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: color-mix(in srgb, var(--card) 92%, #000);
  color: var(--foreground);
  opacity: 0;
  transform: translateY(0.3rem) scale(0.94);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.32);
  transition: opacity 150ms ease, transform 150ms ease, border-color 150ms ease, background 150ms ease;
  pointer-events: auto;
}

.reaction-button .svg-icon {
  width: 1.15rem;
  height: 1.15rem;
}

.file-card:hover .reaction-button,
.file-card:focus-within .reaction-button,
.reaction-button:focus-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.reaction-button:hover,
.reaction-button:focus-visible {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--primary-foreground);
}

.reaction-picker {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 70;
  width: min(21rem, calc(100vw - 1rem));
}

html.reaction-picker-open,
html.reaction-picker-open body {
  overflow: hidden;
  touch-action: none;
}

.reaction-picker[hidden] {
  display: none;
}

.reaction-picker.is-mobile {
  inset: 0;
  width: auto;
  height: 100dvh;
  display: grid;
  place-items: end center;
  overflow: hidden;
  padding: 0.75rem 0.75rem max(1.5rem, env(safe-area-inset-bottom));
  background: rgba(0, 0, 0, 0.54);
}

.reaction-picker-panel {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--card) 97%, #000);
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.52);
}

.reaction-picker.is-mobile .reaction-picker-panel {
  width: min(100%, 34rem);
  height: 75dvh;
  max-height: 75dvh;
  display: flex;
  flex-direction: column;
}

.reaction-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem;
  border-bottom: 1px solid var(--border);
}

.reaction-picker-close {
  min-height: 2rem;
  padding: 0.3rem 0.55rem;
  font-size: 0.75rem;
}

.reaction-existing {
  padding: 0.55rem 0.7rem 0;
}

.reaction-existing small,
.reaction-readonly-note {
  display: block;
  color: var(--muted-foreground);
  font-size: 0.74rem;
  font-weight: 700;
}

.reaction-existing-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.4rem;
}

.reaction-readonly-note {
  margin: 0;
  padding: 0.55rem 0.7rem 0.7rem;
}

.reaction-picker-tabs {
  display: flex;
  gap: 0.35rem;
  overflow-x: auto;
  padding: 0.55rem 0.7rem 0;
}

.reaction-tab {
  flex: 0 0 auto;
  min-height: 1.8rem;
  padding: 0.25rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--muted);
  color: var(--muted-foreground);
  font-size: 0.75rem;
  font-weight: 700;
}

.reaction-tab.is-active {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--primary-foreground);
}

.reaction-search {
  display: block;
  padding: 0.55rem 0.7rem;
}

.reaction-search input {
  width: 100%;
  min-height: 2.15rem;
  padding: 0.35rem 0.55rem;
}

.reaction-grid-wrap {
  max-height: 18rem;
  overflow: auto;
  padding: 0 0.7rem 0.7rem;
}

.reaction-picker.is-mobile .reaction-grid-wrap {
  max-height: none;
  flex: 1;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.reaction-grid {
  display: none;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 0.25rem;
}

.reaction-grid.is-active {
  display: grid;
}

.reaction-picker.is-mobile .reaction-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.reaction-emoji {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  min-width: 0;
  padding: 0.18rem;
  border: 1px solid transparent;
  border-radius: calc(var(--radius) - 0.25rem);
  background: transparent;
}

.reaction-emoji:hover,
.reaction-emoji:focus-visible {
  border-color: var(--border);
  background: var(--accent);
}

.reaction-emoji[hidden] {
  display: none;
}

.reaction-emoji img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

/* A file row behaves like an entry in a desktop file explorer: a small
   thumbnail/icon followed by the name and metadata. The whole row is the click
   target (raw view of the file). */
.file-open {
  min-width: 0;
  flex: 1;
  display: grid;
  grid-template-columns: 3rem minmax(0, 1fr) minmax(8rem, 0.38fr) minmax(5rem, 0.18fr);
  align-items: center;
  gap: 0.75rem;
  color: var(--foreground);
  text-decoration: none;
  padding: 0.55rem 0.65rem;
  border-radius: calc(var(--radius) - 0.25rem);
}

.file-open:hover,
.file-open:focus-visible {
  background: var(--surface-1-hover);
}

.file-media {
  flex: 0 0 3rem;
  width: 3rem;
  height: 3rem;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 0.125rem);
  background: var(--muted);
}

.file-thumb {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.file-icon {
  width: 2.1rem;
  height: 2.1rem;
  display: block;
  object-fit: contain;
}

/* Retro (Win98) icons are tiny pixel art. Keep them crisp and swap them in
   only when the retro theme is active. */
.file-icon-retro {
  display: none;
  image-rendering: pixelated;
}

[data-theme="retro"] .file-icon-standard {
  display: none;
}

[data-theme="retro"] .file-icon-retro {
  display: block;
}

.file-main {
  min-width: 0;
  max-width: 100%;
  color: var(--foreground);
  text-decoration: none;
}

.file-name {
  min-width: 0;
}

.file-main small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file type,
.file-size {
  overflow: hidden;
  color: var(--muted-foreground);
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-size {
  text-align: right;
}

.file-browser.is-thumbs {
  gap: 0.75rem;
  padding: 0.75rem;
  grid-template-columns: repeat(auto-fill, minmax(8.75rem, 1fr));
}

.file-browser-window.is-icon-view .file-browser-head {
  display: none;
}

.file-browser.is-thumbs .file-card {
  display: grid;
  min-height: 13.75rem;
  min-width: 0;
  align-content: start;
  gap: 0.5rem;
}

.file-browser.is-list .file-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(8rem, 0.32fr);
  align-items: center;
  min-height: 4.25rem;
  cursor: pointer;
}

.file-browser.is-list .file-card:hover,
.file-browser.is-list .file-card:focus-within {
  background: var(--surface-1-hover);
}

.file-browser.is-list .file-card:hover .file-open,
.file-browser.is-list .file-card:focus-within .file-open {
  background: transparent;
}

.file-browser.is-thumbs .file-open {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 6.75rem auto;
  gap: 1rem;
  height: 100%;
  min-height: 0;
  padding: 0.65rem 0.65rem 3.05rem;
  text-align: center;
  justify-items: center;
  align-content: start;
  overflow: hidden;
}

.file-browser.is-thumbs .file-media {
  width: min(6.75rem, 76%);
  height: 6.75rem;
  flex-basis: auto;
  aspect-ratio: 1;
}

.file-browser.is-thumbs .file-icon {
  width: 64%;
  height: 64%;
}

.file-browser.is-thumbs .file-main {
  width: 100%;
  grid-template-columns: 1fr;
  gap: 0.25rem;
  align-self: start;
  padding-top: 0.25rem;
}

.file-browser.is-thumbs .file type,
.file-browser.is-thumbs .file-size {
  display: none;
}

.file-browser.is-thumbs .file-reaction-dock {
  position: absolute;
  right: 0.6rem;
  bottom: 0.65rem;
  max-width: calc(100% - 1.2rem);
  padding-right: 0;
}

.context-menu {
  position: fixed;
  z-index: 30;
  width: 10.75rem;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 0.125rem);
  background: color-mix(in srgb, var(--card) 96%, #000);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.46);
  padding: 0.4rem;
}

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

.context-menu button {
  width: 100%;
  min-height: 2.05rem;
  justify-content: flex-start;
  border-radius: calc(var(--radius) - 0.25rem);
  padding: 0.42rem 0.5rem;
  color: var(--foreground);
  font-size: 0.8rem;
}

.context-menu button:hover,
.context-menu button:focus-visible,
.context-menu button.is-copied {
  background: var(--accent);
}

.context-menu-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.1rem 0.1rem 0.2rem 0.45rem;
}

.context-menu-top small {
  color: color-mix(in srgb, var(--muted-foreground) 74%, transparent);
  font-size: 0.72rem;
  font-weight: 600;
}

.context-menu-icons {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}

.context-menu-icons button {
  width: 1.9rem;
  min-height: 1.9rem;
  padding: 0;
  justify-content: center;
}

.context-menu hr {
  height: 1px;
  margin: 0.35rem 0.2rem;
  border: 0;
  background: var(--border);
}

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

.unlock-form {
  margin: 1rem auto 0;
  display: grid;
  max-width: 22rem;
  gap: 0.75rem;
}

.manage-details {
  display: grid;
  gap: 0.5rem;
  margin: 1rem 0 0;
  text-align: left;
}

.manage-details div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--border);
  padding: 0.45rem 0;
}

.manage-details dt,
.manage-details dd {
  margin: 0;
  min-width: 0;
}

.manage-details dt {
  color: var(--muted-foreground);
  font-size: 0.78rem;
  font-weight: 600;
}

.manage-details dd {
  color: var(--foreground);
  font-size: 0.84rem;
  text-align: right;
}

@media (max-width: 720px) {
  .preview-view {
    width: min(100%, calc(100% - 1rem));
    padding-block: 1rem;
  }

  .preview-header {
    flex-direction: column;
    align-items: stretch;
  }

  .preview-header .button {
    justify-content: center;
  }

  .preview-window-titlebar > div:first-child {
    display: grid;
    gap: 0.2rem;
  }

  .preview-stage,
  .code-preview,
  .render-preview,
  .native-preview {
    min-height: 18rem;
    height: min(60vh, 32rem);
  }

  .preview-stage > img,
  .preview-stage > video {
    max-height: min(60vh, 32rem);
  }
}
