/* The interactive archive is shared across desktop and touch layouts.
   The original portfolio remains available when JavaScript is unavailable. */
.archive { display: none; }

@media (min-width: 0px) {
  .has-archive .portfolio-section > .index { display: none; }
  .archive {
    --paper: #000;
    --ink: #f2f2f2;
    --quiet: #a0a0a0;
    --edge: #343434;
    --layout-duration: 850ms;
    --layout-easing: cubic-bezier(.22,.72,.12,1);
    display: block;
    position: relative;
    width: 100%;
    height: 100dvh;
    min-height: 540px;
    overflow: clip;
    color: var(--ink);
    font: 400 13px/1.5 "Helvetica Neue", Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
  }
  .archive.is-overview-transition {
    --layout-duration: 1400ms;
    --layout-easing: cubic-bezier(.45,0,.55,1);
  }
  .archive button, .archive a { -webkit-tap-highlight-color: transparent; }
  .archive button { color: inherit; font: inherit; cursor: pointer; }
  .archive button:focus-visible, .archive a:focus-visible {
    outline: 2px solid #a0a0a0;
    outline-offset: 5px;
  }
  /* Returning focus after a preview must not add a second border or lift. */
  .archive .archive-card:focus,
  .archive .archive-card .archive-card-face { outline: none; outline-offset: 0; }
  .archive button:disabled { opacity: .25; cursor: default; }
  .archive > :not(.archive-viewer):not(.archive-sr) {
    opacity: 1;
    /* A filter here would isolate the controls' backdrop from the cards. */
    filter: none;
  }
  .archive.is-viewing > :not(.archive-viewer):not(.archive-sr) {
    opacity: 0;
    filter: blur(14px);
  }
  .archive.is-preview-navigating .archive-card,
  .archive.is-preview-navigating .archive-card-face { transition: none; }
  .archive-header {
    position: absolute;
    inset: 25px 34px auto;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: none;
  }
  .archive-header > * { pointer-events: auto; }
  .archive-home { display: flex; width: 92px; text-decoration: none; }
  .archive-home img { display: block; width: 92px; height: 44px; object-fit: contain; }
  .archive-brand { width: 265px; }
  .archive-tagline { max-width: 250px; color: var(--quiet); }
  .archive-utility-controls { position: absolute; right: 0; bottom: 0; }
  .archive-utility-controls { isolation: isolate; }
  .archive-utility-controls::before {
    content: '';
    position: absolute;
    z-index: -1;
    inset: -28px -36px;
    pointer-events: none;
    background: rgb(0 0 0 / .22);
    -webkit-backdrop-filter: blur(20px) brightness(.45);
    backdrop-filter: blur(20px) brightness(.45);
    -webkit-mask-image: radial-gradient(ellipse closest-side, #000 45%, rgb(0 0 0 / .92) 60%, transparent 100%);
    mask-image: radial-gradient(ellipse closest-side, #000 45%, rgb(0 0 0 / .92) 60%, transparent 100%);
  }
  .archive-stage { position: absolute; inset: 0; touch-action: none; cursor: grab; }
  .archive-stage.is-dragging { cursor: grabbing; }
  .archive-card {
    position: absolute;
    top: 0;
    left: 0;
    width: var(--card-width, 340px);
    height: var(--card-height, 226px);
    padding: 0;
    border: 0;
    background: transparent;
    opacity: var(--intro-opacity, 1);
    transform: translate3d(var(--x), var(--y), 0);
    transition: transform var(--layout-duration) var(--layout-easing);
    text-align: left;
    pointer-events: none;
  }
  .archive-card-face {
    --slab-depth: 6px;
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 0;
    transform: rotateY(-44deg) skewY(24deg);
    transition: transform 650ms cubic-bezier(.22,.72,.12,1), box-shadow 650ms;
    transform-origin: center;
    backface-visibility: hidden;
    pointer-events: auto;
  }
  /* One continuous white silhouette forms the front rim and both depth
     faces. Insetting the artwork over it avoids separate rasterized edges
     opening seams at fractional coordinates or during transforms. */
  .archive-card-face::before {
    content: '';
    position: absolute;
    z-index: 0;
    top: calc(-1 * var(--slab-depth));
    left: 0;
    width: calc(100% + var(--slab-depth));
    height: calc(100% + var(--slab-depth));
    background: #fff;
    clip-path: polygon(0 var(--slab-depth), var(--slab-depth) 0, 100% 0, 100% calc(100% - var(--slab-depth)), calc(100% - var(--slab-depth)) 100%, 0 100%);
    pointer-events: none;
  }
  .archive-card-surface {
    position: absolute;
    z-index: 1;
    inset: 1px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #080808;
    pointer-events: none;
  }
  .archive-card img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; user-select: none; }
  .archive-card[data-type="identity"] img { width: 76%; height: 58%; object-fit: contain; }
  .archive-card[data-type="portrait"] img,
  .archive-card[data-type="video"] img { object-fit: contain; }
  .archive-card[data-type="image"] img { object-fit: contain; }
  .archive-card[data-project="digifrens"] .archive-card-surface { background: #eee7d5; }
  .archive-card[data-project="digifrens"][data-type="identity"] .archive-card-surface { background: #080808; }
  .archive-card[data-project="ownership"] .archive-card-surface { background: #fff; }
  .archive-card[data-project="ownership"][data-type="identity"] .archive-card-surface { background: #000; }
  .archive-card:hover .archive-card-face { transform: translateY(-28px) rotateY(-44deg) skewY(24deg); }
  .archive-card.is-selected .archive-card-face {
    box-shadow: -28px 40px 35px -28px rgb(0 0 0 / .5);
  }
  .archive-card-label {
    position: absolute;
    /* Anchor just before the midpoint of the projected bottom edge, then
       extend toward the viewer. The offsets are cos(44deg)/12 horizontally
       and tan(24deg)/12 vertically, matching the card face. */
    top: calc(100% - var(--card-width) * .037102 + 22px);
    right: calc(50% + var(--card-width) * .059945);
    width: max-content;
    color: var(--quiet);
    font-size: 11px;
    white-space: nowrap;
    transform: skewY(-29deg);
    transform-origin: top right;
    pointer-events: none;
  }
  .archive-card-label strong { color: var(--ink); font-weight: 500; }
  .archive-card-label span { margin-left: 10px; }
  .archive-card:not(.is-selected) .archive-card-label { visibility: hidden; }
  .archive-card.is-group-start .archive-card-label { display: none; }
  .archive-section-marker {
    position: absolute;
    top: calc(100% + 22px);
    left: 50%;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--quiet);
    font-size: 10px;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
    transform: rotate(32deg);
    transition: transform var(--layout-duration) var(--layout-easing);
    transform-origin: left center;
    pointer-events: none;
  }
  .archive.is-browsing .archive-card:not(.is-selected) .archive-section-marker {
    transform: translate(calc(var(--card-width) * .4), calc(var(--card-width) * .223 - 6px)) rotate(32deg);
  }
  .archive-section-marker::before {
    content: '';
    width: 16px;
    height: 1px;
    background: #666;
  }
  .archive-card.is-preview-source { visibility: hidden; }
  .archive-detail { position: absolute; z-index: 70; left: 34px; top: 25px; width: 265px; pointer-events: none; }
  .archive-detail h2 { display: flex; align-items: center; height: 44px; margin: 0 0 16px; }
  /* Keep Glim at its original size; allow more width where the lettering
     occupies a smaller part of the artwork. */
  .archive-project-logo { display: block; flex: none; width: auto; height: auto; max-width: var(--project-logo-width, 132px); max-height: 44px; object-fit: contain; }
  .archive-detail[data-project="smelted"] { --project-logo-width: 200px; }
  .archive-detail[data-project="ownership"] { --project-logo-width: 170px; }
  .archive-detail p { margin: 0; color: var(--portfolio-copy-color); font-size: var(--portfolio-copy-size); line-height: var(--portfolio-copy-leading); }
  .archive-detail-actions { display: flex; gap: 20px; margin-top: 16px; pointer-events: auto; }
  .archive-detail-actions button, .archive-detail-actions a {
    border: 0;
    padding: 5px 0;
    background: none;
    color: var(--ink);
    font: inherit;
    font-size: 12px;
    text-decoration: underline;
    text-underline-offset: 4px;
  }
  .archive-index {
    --index-bottom: 91px;
    --index-fade: 22px;
    position: absolute;
    z-index: 80;
    right: 36px;
    bottom: var(--index-bottom);
    width: 160px;
    max-height: calc(100% - var(--index-bottom) - 32px);
    display: flex;
    flex-direction: column;
    text-align: right;
  }
  .archive-project-toggle, .archive-index-close { display: none; }
  .archive-index ul { list-style: none; margin: 0; padding: 0; }
  .archive-index-scroll {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-height: min(200px, 28dvh);
    margin-inline: -8px;
  }
  .archive-index .archive-projects {
    min-height: 0;
    padding: var(--index-fade) 8px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: none;
    scroll-padding-block: calc(var(--index-fade) + 6px);
    -webkit-mask-image: linear-gradient(to bottom, transparent, #000 var(--index-fade), #000 calc(100% - var(--index-fade)), transparent);
    mask-image: linear-gradient(to bottom, transparent, #000 var(--index-fade), #000 calc(100% - var(--index-fade)), transparent);
  }
  .archive-projects::-webkit-scrollbar { display: none; }
  .archive-index-scroll::before, .archive-index-scroll::after {
    content: '';
    position: absolute;
    z-index: 1;
    left: 0;
    right: 0;
    height: var(--index-fade);
    pointer-events: none;
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    -webkit-mask-image: radial-gradient(ellipse closest-side, #000 15%, transparent 100%);
    mask-image: radial-gradient(ellipse closest-side, #000 15%, transparent 100%);
  }
  .archive-index-scroll::before {
    top: 0;
    background: linear-gradient(to bottom, rgb(0 0 0 / .35), transparent);
  }
  .archive-index-scroll::after {
    bottom: 0;
    background: linear-gradient(to top, rgb(0 0 0 / .35), transparent);
  }
  .archive-index button { border: 0; background: transparent; padding: 4px 0 4px 10px; color: var(--quiet); }
  .archive-index button:hover, .archive-index button[aria-current="true"] { color: var(--ink); }
  .archive-index > button { flex: none; align-self: flex-end; margin-bottom: 8px; }
  .archive-index > button, .archive-project-button { font-size: 13px !important; }
  .archive-index sup { display: inline-block; min-width: 14px; font-size: 8px; margin-left: 4px; vertical-align: super; }
  .archive-project-date { white-space: nowrap; font-variant-numeric: tabular-nums; }
  .archive-index button[aria-current="true"] { font-weight: 500; }
  .archive-index .archive-items { margin: 0 0 9px; }
  .archive-items button { font-size: 11px; padding-block: 4px; }
  .archive-items button[aria-current="true"]::before { content: '·'; margin-right: 7px; }
  .archive-footer { position: absolute; z-index: 80; bottom: 25px; left: 36px; right: 36px; display: flex; justify-content: center; pointer-events: none; }
  .archive-footer > * { pointer-events: auto; }
  .archive-footer-center { display: flex; flex-direction: column; align-items: center; gap: 4px; }
  .archive-hint { color: var(--quiet); margin: 0; font-size: 11px; text-align: center; white-space: nowrap; background: var(--paper); padding: 4px 8px; }
  .archive-controls { display: flex; align-items: center; gap: 15px; }
  .archive-controls button { border: 0; background: none; padding: 10px 7px; }
  .archive-controls svg { width: 16px; height: 16px; display: block; }
  .archive-count { min-width: 42px; color: var(--quiet); text-align: center; font-size: 11px; font-variant-numeric: tabular-nums; }
  .archive-help { position: absolute; z-index: 120; bottom: 80px; right: 34px; width: 260px; padding: 22px; background: var(--paper); border: 1px solid var(--edge); box-shadow: 0 5px 30px rgb(0 0 0 / .1); }
  .archive-help p { margin: 0 0 10px; }
  .archive-help p:last-child { margin-bottom: 0; color: var(--quiet); }
  .archive-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
  .archive-viewer {
    --viewer-edge: 32px;
    --build-info-gap: 32px;
    --build-info-width: clamp(252px, 24vw, 320px);
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100dvh;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    overflow: hidden;
    background: transparent;
    color: var(--ink);
  }
  .archive-viewer[open] { display: grid; place-items: center; }
  .archive-viewer::backdrop { background: transparent; }
  .archive-viewer-panel { position: relative; display: flex; flex-direction: column; width: min(1040px, 76vw, 100dvh); }
  /* Reserve the notes column in the centered item's margin box so the website
     and its text form one centered group. Device previews retain their position. */
  .archive-viewer[open].is-showing-info:not([data-shape="device"]) {
    padding-inline: var(--viewer-edge);
    box-sizing: border-box;
  }
  .archive-viewer.is-showing-info:not([data-shape="device"]) .archive-viewer-panel {
    width: min(1040px, 76vw, 100dvh, calc(100vw - var(--viewer-edge) * 2 - var(--build-info-gap) - var(--build-info-width)));
    margin-inline-end: calc(var(--build-info-gap) + var(--build-info-width));
  }
  .archive-viewer.is-expanded .archive-viewer-panel { width: calc(100% - 48px); height: calc(100dvh - 48px); }
  .archive-viewer.is-expanded .archive-viewer-media { aspect-ratio: auto; }
  .archive-viewer[data-shape="device"] .archive-viewer-panel {
    --device-view-height: min(780px, 72dvh, calc(100dvh - 176px));
    width: calc(var(--device-view-height) * var(--device-aspect));
    height: auto;
  }
  .archive-viewer[data-shape="device"].is-expanded .archive-viewer-panel {
    --device-view-height: calc(100dvh - 144px);
  }
  .archive-viewer[data-shape="device"] .archive-viewer-media {
    flex: none;
    box-sizing: content-box;
    width: calc(100% - 2px);
    aspect-ratio: var(--device-aspect);
  }
  .archive-viewer-head, .archive-viewer-footer {
    opacity: 0;
    transform: translateY(8px);
  }
  .archive-viewer.is-active .archive-viewer-head,
  .archive-viewer.is-active .archive-viewer-footer {
    opacity: 1;
    transform: translateY(0);
  }
  .archive-viewer-head { display: flex; flex: none; align-items: center; justify-content: space-between; padding: 12px 0; }
  .archive-viewer-title-group { display: flex; align-items: center; gap: 5px; min-width: 0; }
  .archive-viewer-title-group h2 { min-width: 0; }
  .archive-viewer-info {
    display: grid;
    place-items: center;
    flex: none;
    width: 32px;
    height: 36px;
    padding: 7px;
    border: 0;
    background: none;
    color: var(--quiet);
  }
  .archive-viewer-info[hidden] { display: none; }
  .archive-viewer-info svg { display: block; width: 18px; height: 18px; }
  .archive-viewer-info:hover:enabled, .archive-viewer-info[aria-expanded="true"] { color: var(--ink); }
  .archive-viewer-info:disabled { color: #555; cursor: default; }
  .archive-viewer-info:focus-visible { outline: 1px solid var(--ink); outline-offset: 2px; }
  .archive-viewer h2 { margin: 0; font-size: 13px; font-weight: 500; }
  .archive-viewer-actions { flex: none; gap: 4px; margin-right: -8px; }
  .archive-viewer-actions button { display: grid; place-items: center; width: 36px; height: 36px; padding: 8px; }
  .archive-viewer-actions svg { width: 18px; height: 18px; }
  .archive-viewer-media {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    box-sizing: border-box;
    width: 100%;
    aspect-ratio: 1 / .665;
    border: 1px solid #fff;
    background: #080808;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transform-origin: 0 0;
  }
  .archive-viewer-media img, .archive-viewer-media video { display: block; width: 100%; height: 100%; object-fit: contain; }
  .archive-viewer-media[data-type="website"] > img { object-fit: cover; }
  .archive-website-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #080808; opacity: 0; transition: opacity 300ms ease; }
  .archive-website-frame.is-loaded { opacity: 1; }
  .archive-website-frame.is-closing { pointer-events: none; }
  .archive-website-status { position: absolute; bottom: 12px; left: 12px; right: 12px; padding: 8px 12px; color: var(--ink); background: rgb(0 0 0 / .8); font-size: 11px; }
  .archive-viewer-media[data-type="identity"] img { width: 76%; height: 58%; }
  .archive-viewer-media[data-project="digifrens"] { background: #eee7d5; }
  .archive-viewer-media[data-project="ownership"] { background: #fff; }
  .archive-viewer-media[data-type="identity"] { background: #080808; }
  .archive-viewer-build-info {
    position: absolute;
    top: var(--build-info-top, 60px);
    left: calc(100% + var(--build-info-gap));
    width: var(--build-info-width);
    max-height: calc(100% - var(--build-info-top, 60px) - 68px);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: #888 transparent;
    color: var(--quiet);
    font-size: 14px;
    line-height: 1.65;
  }
  .archive-viewer-build-info h3 { margin: 0 0 18px; color: var(--ink); font-size: 13px; font-weight: 500; }
  .archive-build-summary { margin: 0 0 24px; color: var(--ink); font-size: 16px; line-height: 1.6; }
  .archive-viewer-build-info ul { margin: 0; padding: 0 0 0 16px; }
  .archive-viewer-build-info li { padding-left: 3px; }
  .archive-viewer-build-info li + li { margin-top: 14px; }
  .archive-viewer-build-info::-webkit-scrollbar { width: 4px; background: transparent; }
  .archive-viewer-build-info::-webkit-scrollbar-track { background: transparent; }
  .archive-viewer-build-info::-webkit-scrollbar-thumb { background: #888; border-radius: 2px; }
  .archive-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    height: 100%;
    padding: 20px;
    background: #080808;
    color: var(--ink);
    text-align: center;
    pointer-events: none;
  }
  .archive .archive-placeholder img { width: 70%; height: 42%; object-fit: contain; }
  .archive-placeholder-label { font-size: 12px; line-height: 1.2; }
  .archive-placeholder-note { color: var(--quiet); font-size: 10px; line-height: 1.4; }
  .archive-viewer-footer { display: flex; flex: none; align-items: center; justify-content: space-between; padding: 16px 0; }
  .archive-viewer-footer a { color: var(--ink); text-underline-offset: 4px; }
  .archive-viewer-footer span { color: var(--quiet); font-size: 12px; }
  .archive-viewer-navigation button { min-width: 36px; min-height: 36px; }
  .archive-viewer-count { min-width: 42px; text-align: center; font-variant-numeric: tabular-nums; }
  @media (max-height: 720px) {
    .archive-detail { width: 235px; }
    .archive-index { --index-bottom: 70px; }
    .archive-index button { padding-block: 3px; }
  }
  @media (prefers-reduced-motion: reduce) {
    .archive-card, .archive-card-face, .archive-section-marker, .archive-website-frame,
    .archive > :not(.archive-viewer):not(.archive-sr),
    .archive-viewer .archive-viewer-head, .archive-viewer .archive-viewer-footer {
      transition-duration: 0s !important;
      transition-delay: 0s !important;
    }
  }
}

@media (max-width: 1023px) {
  .archive, .archive.is-overview-transition {
    --layout-duration: 400ms;
    --layout-easing: cubic-bezier(.22,.72,.12,1);
  }
  .archive {
    --mobile-left: max(20px, env(safe-area-inset-left));
    --mobile-right: max(20px, env(safe-area-inset-right));
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 16px;
    min-height: 0;
    padding: max(20px, env(safe-area-inset-top)) var(--mobile-right) max(16px, env(safe-area-inset-bottom)) var(--mobile-left);
  }
  .archive-header, .archive-detail {
    position: static;
    grid-row: 1;
    grid-column: 1;
    width: 100%;
  }
  .archive.is-browsing .archive-header, .archive-detail[hidden] { display: none; }
  .archive-brand { width: 100%; }
  .archive-tagline { max-width: 290px; font-size: 16px; line-height: 1.5; }
  .archive-detail h2 { margin-bottom: 12px; }
  .archive-detail p { max-width: 520px; font-size: 16px; line-height: 1.45; }
  .archive-detail-actions { gap: 24px; margin-top: 8px; }
  .archive-detail-actions button, .archive-detail-actions a { display: inline-flex; align-items: center; min-height: 44px; font-size: 14px; }
  .archive-stage {
    position: relative;
    inset: auto;
    grid-row: 2;
    grid-column: 1;
    display: block;
    width: calc(100% + var(--mobile-left) + var(--mobile-right));
    min-height: 0;
    margin-inline: calc(-1 * var(--mobile-left)) calc(-1 * var(--mobile-right));
    padding: 0;
    overflow: clip;
    /* The deck owns one-finger swipes; native pinch zoom remains available. */
    touch-action: pinch-zoom;
    cursor: grab;
  }
  .archive-card {
    position: absolute;
    height: var(--card-height);
    opacity: calc(var(--deck-opacity, 0) * var(--intro-opacity, 1));
    transform: translate3d(calc(var(--x) + var(--swipe-x, 0px)), calc(var(--y) + var(--swipe-y, 0px)), 0);
    transition: transform var(--layout-duration) var(--layout-easing), opacity var(--layout-duration) var(--layout-easing);
    pointer-events: none;
  }
  .archive-card.is-front { pointer-events: auto; }
  .archive-stage.is-dragging .archive-card.is-front { transition: none; }
  .archive-card-face, .archive-card:hover .archive-card-face {
    transform: rotateY(-28deg) skewY(14deg) scale(var(--deck-scale, 1));
    transition: transform var(--layout-duration) var(--layout-easing);
    box-shadow: none;
  }
  .archive-card:not(.is-front) .archive-card-face { pointer-events: none; }
  .archive .archive-card:focus-visible .archive-card-face { outline: 2px solid var(--quiet); outline-offset: 5px; }
  .archive-card-label {
    top: var(--deck-label-top);
    left: 0;
    right: 0;
    width: auto;
    transform: none;
    text-align: center;
    font-size: 13px;
  }
  .archive-card .archive-card-label { visibility: hidden; }
  .archive-card.is-front .archive-card-label { visibility: visible; }
  .archive-card.is-group-start .archive-card-label { display: block; }
  .archive-section-marker { display: none; }
  .archive-footer {
    position: static;
    grid-row: 3;
    grid-column: 1;
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    align-items: start;
  }
  .archive-footer-center { grid-row: 1; grid-column: 2; }
  .archive-hint { white-space: normal; padding: 0; font-size: 11px; line-height: 1.4; }
  .archive-controls { gap: 8px; }
  .archive-controls button { min-width: 44px; min-height: 44px; padding: 12px; }
  .archive-count { font-size: 13px; }
  .archive-project-toggle, .archive-index-close { display: grid; place-items: center; min-width: 44px; min-height: 44px; padding: 12px; border: 0; background: transparent; }
  .archive-project-toggle { grid-row: 1; grid-column: 1; }
  .archive-project-toggle svg, .archive-index-close svg { width: 20px; height: 20px; }
  .archive-utility-controls { position: static; grid-row: 1; grid-column: 3; }
  .archive-utility-controls::before, .archive-help-toggle, .archive-help { display: none; }
  .archive-index {
    display: none;
    left: max(16px, env(safe-area-inset-left));
    right: max(16px, env(safe-area-inset-right));
    bottom: calc(100px + env(safe-area-inset-bottom));
    width: auto;
    max-height: min(65dvh, 520px);
    padding: 16px;
    border: 1px solid var(--edge);
    background: var(--paper);
    box-shadow: 0 12px 40px rgb(0 0 0 / .6);
  }
  .archive.is-index-open .archive-index { display: flex; }
  .archive-index .archive-all { align-self: flex-start; padding-inline: 8px; }
  .archive-index-close { position: absolute; top: 10px; right: 10px; }
  .archive-index-scroll { max-height: min(48dvh, 390px); }
  .archive-index button { min-height: 44px; padding: 10px 8px; }
  .archive-index > button, .archive-project-button { font-size: 16px !important; }
  .archive-index sup { font-size: 11px; margin-left: 8px; }
  .archive-items button { font-size: 14px; }
  .archive-index .archive-items { margin-bottom: 8px; }
  .archive-viewer, .archive-viewer[open].is-showing-info:not([data-shape="device"]) {
    padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    background: var(--paper);
  }
  .archive-viewer-panel,
  .archive-viewer.is-showing-info:not([data-shape="device"]) .archive-viewer-panel {
    width: 100%;
    height: 100%;
    max-height: 100%;
    min-height: 0;
    margin: 0;
  }
  .archive-viewer-head { padding: 0 0 12px; }
  .archive-viewer h2 { font-size: 14px; }
  .archive-viewer-actions { margin: 0; gap: 0; }
  .archive-viewer-actions button, .archive-viewer-info { width: 44px; height: 44px; }
  .archive-viewer-media { aspect-ratio: auto; }
  .archive-viewer-footer { gap: 8px; padding: 12px 0 0; }
  .archive-viewer-footer a { display: inline-flex; align-items: center; min-height: 44px; font-size: 13px; }
  .archive-viewer-footer span { font-size: 13px; }
  .archive-viewer[data-shape="device"] .archive-viewer-panel,
  .archive-viewer[data-shape="device"].is-expanded .archive-viewer-panel {
    --device-view-height: min(calc(100dvh - 156px - env(safe-area-inset-top) - env(safe-area-inset-bottom)), calc((100vw - 32px) / var(--device-aspect)));
    width: 100%;
    height: 100%;
  }
  .archive-viewer[data-shape="device"] .archive-viewer-media {
    width: calc(var(--device-view-height) * var(--device-aspect));
    height: var(--device-view-height);
    max-width: 100%;
    box-sizing: border-box;
    margin: auto;
  }
  .archive-viewer.is-expanded { padding-inline: env(safe-area-inset-left) env(safe-area-inset-right); }
  .archive-viewer.is-expanded .archive-viewer-panel { width: 100%; height: 100%; }
  .archive-viewer-build-info {
    z-index: 4;
    top: var(--build-info-top);
    left: 0;
    right: 0;
    bottom: 56px;
    width: auto;
    max-height: none;
    padding: 20px;
    background: #080808;
    border: 1px solid #fff;
  }
  @media (max-height: 640px) {
    .archive { gap: 8px; padding-block: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-bottom)); }
    .archive-detail p, .archive-tagline { display: none; }
    .archive-detail h2 { margin-bottom: 0; }
    .archive-detail-actions { margin-top: 0; }
    .archive-hint { display: none; }
  }
}
