/* viewer.css - file view page, previews and the image viewer. Owned by the viewer work.
 * Uses the design tokens defined in app.css (:root). Sections:
 *   1. File page (Seafile-style file view)      .fv-*
 *   2. Text / code editor + markdown             .fv-editor, .md-body
 *   3. Public share page additions               .pf-*
 *   4. Image viewer overlay                      .pv-*
 *   5. Motion (all of it off under prefers-reduced-motion)
 *   6. Small screens */

/* ===================================================== 1. File page */
.fv { display: block; min-width: 0; }
.fv .ic.fv-ico, .pf-stage .ic.fv-ico, .pf-head .ic.fv-ico, .pf-state .ic.fv-ico { width: 17px; height: 17px; vertical-align: -3px; }
.btn .ic.fv-ico { width: 16px; height: 16px; vertical-align: 0; }

.fv-crumbs { margin-bottom: 8px; }
.fv-back {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 4px 10px 4px 6px;
  color: var(--text-2); font-size: 13px; font-weight: 600; text-decoration: none;
  border: 1px solid transparent; border-radius: 999px;
  transition: color .15s, background-color .15s, border-color .15s;
}
.fv-back span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fv-back:hover { color: var(--text); background: var(--panel-hi); border-color: var(--line); text-decoration: none; }
.fv-back .ic { transition: transform .2s var(--ease); }
.fv-back:hover .ic { transform: translateX(-2px); }

.fv-head {
  position: relative; display: flex; align-items: center; gap: 14px; margin-bottom: 12px; padding: 11px 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(14px) saturate(130%); backdrop-filter: blur(14px) saturate(130%);
}
.fv-head::before {
  content: ''; position: absolute; inset: 0 0 auto; height: 1px; border-radius: inherit; pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .14), transparent);
}
.fv-type-icon {
  flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 13px;
  background: var(--grad-soft); border: 1px solid var(--line-2); box-shadow: 0 14px 34px -16px rgba(139, 92, 246, .9);
}
.fv-type-icon .item-icon { width: 26px; height: 26px; }
.fv-titles { flex: 1 1 0; min-width: 0; }
.fv-title-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.fv-name {
  min-width: 0; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font: 700 clamp(18px, 1.7vw, 22px)/1.25 var(--display); letter-spacing: -.01em;
}
.fv-star-form { display: inline-flex; margin: 0; }
.fv-star .ic { transition: transform .3s var(--spring), fill .2s, color .2s; }
.fv-star:hover .ic { transform: scale(1.12) rotate(-8deg); }
.fv-star.on { color: var(--caution); }
.fv-star.on .ic { fill: currentColor; }
.fv-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px 12px; margin: 3px 0 0;
  color: var(--text-2); font-size: 13px;
}
.fv-meta-item { white-space: nowrap; }
.fv-meta-item + .fv-meta-item::before { content: '\00b7'; margin-right: 12px; color: var(--text-3); }
.fv-actions { flex: none; display: flex; align-items: center; gap: 4px; }
.fv-actions .icon-btn { width: 32px; height: 32px; }
.fv-actions .icon-btn .ic { width: 18px; height: 18px; }

/* ----- preview stage */
.fv-stage {
  position: relative; margin-bottom: 12px; padding: 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(14px) saturate(130%); backdrop-filter: blur(14px) saturate(130%);
}
.fv-stage-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.fv-stage-label {
  display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: 7px;
  color: var(--text-2); background: var(--panel-hi); border: 1px solid var(--line);
  font: 600 10.5px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase;
}
.fv-spacer { flex: 1 1 auto; }
.fv-status { color: var(--caution); font-size: 12.5px; font-weight: 600; }
.fv-stage-bar .btn { min-height: 32px; padding: 0 12px; font-size: 12.5px; }
.fv-stage-foot {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px; margin: 10px 0 0;
  color: var(--text-3); font-size: 12px; text-align: center;
}
.fv-stage-foot kbd { height: 19px; min-width: 19px; font-size: 10px; }

/* image */
.fv-image-stage, .pf-image-stage {
  position: relative; display: flex; align-items: center; justify-content: center;
  min-height: clamp(260px, 62vh, 720px); padding: 18px; overflow: hidden;
  background-color: rgba(0, 0, 0, .42);
  background-image: radial-gradient(rgba(255, 255, 255, .05) 1px, transparent 1px);
  background-size: 18px 18px;
  border: 1px solid var(--line); border-radius: var(--r);
}
.pf-image-stage { width: 100%; }
.fv-image-link { display: inline-flex; max-width: 100%; border-radius: 8px; cursor: zoom-in; }
.fv-image-link:focus-visible { outline: none; box-shadow: var(--ring); }
.fv-image {
  display: block; max-width: 100%; max-height: calc(100vh - 300px); min-height: 0; object-fit: contain;
  border-radius: 6px; box-shadow: 0 24px 60px -22px rgba(0, 0, 0, .95);
  /* checkerboard so transparent images read as transparent */
  background-color: #1b1f2b;
  background-image:
    linear-gradient(45deg, rgba(255, 255, 255, .06) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, .06) 75%),
    linear-gradient(45deg, rgba(255, 255, 255, .06) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, .06) 75%);
  background-size: 16px 16px; background-position: 0 0, 8px 8px;
  transition: transform .3s var(--ease), box-shadow .3s var(--ease);
}
.pf-image-stage .fv-image { max-height: calc(100vh - 320px); }
.fv-image-link:hover .fv-image { transform: scale(1.012); box-shadow: 0 30px 70px -22px rgba(0, 0, 0, 1), 0 0 0 1px rgba(255, 255, 255, .08); }
.fv-image-failed .fv-image-link { display: none; }
.fv-img-nav {
  position: absolute; top: 50%; z-index: 2; display: grid; place-items: center; width: 44px; height: 44px; margin-top: -22px;
  color: var(--text); background: rgba(10, 12, 20, .62); border: 1px solid var(--line-2); border-radius: 50%;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  box-shadow: 0 10px 26px -12px rgba(0, 0, 0, .9);
  transition: transform .2s var(--spring), background-color .15s, border-color .15s;
}
.fv-img-nav:hover { background: rgba(139, 92, 246, .32); border-color: rgba(139, 92, 246, .6); text-decoration: none; }
.fv-img-nav:focus-visible { outline: none; box-shadow: var(--ring); }
.fv-img-nav .ic { width: 20px; height: 20px; }
.fv-img-prev { left: 14px; }
.fv-img-next { right: 14px; }
.fv-img-prev:hover { transform: translateX(-2px) scale(1.06); }
.fv-img-next:hover { transform: translateX(2px) scale(1.06); }

/* media: the player itself is styled in app.css */
.fv-stage-media { padding: 16px; }
.fv-stage-audio .media-shell { width: min(100%, 760px); }

/* pdf */
.fv-pdf {
  display: block; width: 100%; height: calc(100vh - 250px); min-height: 520px;
  background: #2a2d36; border: 1px solid var(--line); border-radius: var(--r);
}

/* no preview / error card */
.fv-nopreview, .pf-nopreview {
  display: grid; justify-items: center; align-content: center; gap: 10px; min-height: 300px; padding: 34px 20px;
  text-align: center;
}
.fv-nopreview h2 { margin: 6px 0 0; font: 700 18px/1.3 var(--display); }
.fv-nopreview .hint { margin: 0; }
.fv-nopreview-icon, .pf-file-icon {
  display: grid; place-items: center; width: 84px; height: 84px; border-radius: 24px;
  background: var(--grad-soft); border: 1px solid var(--line-2);
  box-shadow: 0 22px 50px -22px rgba(139, 92, 246, .95), inset 0 1px 0 rgba(255, 255, 255, .08);
}
.fv-nopreview-icon .item-icon, .pf-file-icon .item-icon { width: 46px; height: 46px; }
.fv-nopreview-icon > .ic, .pf-file-icon > .ic { width: 38px; height: 38px; color: #c4b5fd; }
.fv-big-download, .fv-nopreview .btn.submit { min-height: 44px; padding: 0 20px; margin-top: 8px; font-size: 14px; }
.fv-image-error { position: relative; z-index: 1; min-height: 0; }

/* ----- panels below the preview */
.fv-panel > h2 { margin-top: 0; }
.fv-details > div { grid-template-columns: 160px minmax(0, 1fr); }
.fv-details dd .meta { margin-left: 6px; font: 500 12px var(--mono); color: var(--text-3); }
.fv .panel:target, .fv-stage:target {
  animation: fvTarget 1.4s var(--ease);
}
.fv-history .listing td:first-child { font: 600 12.5px var(--mono); color: #c4b5fd; }

/* ===================================================== 2. Editor + markdown */
.fv-seg {
  display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px;
  background: rgba(0, 0, 0, .35); border: 1px solid var(--line);
}
.fv-seg button {
  min-height: 28px; padding: 0 12px; border: 0; border-radius: 7px;
  color: var(--text-2); background: transparent; font: 600 12.5px var(--sans); cursor: pointer;
  transition: color .15s, background-color .2s var(--ease), box-shadow .2s;
}
.fv-seg button:hover { color: var(--text); }
.fv-seg button[aria-pressed='true'] {
  color: #fff; background: rgba(139, 92, 246, .28); box-shadow: inset 0 0 0 1px rgba(139, 92, 246, .55);
}
.fv-seg button:focus-visible { outline: none; box-shadow: var(--ring); }
.fv-wrap-btn[aria-pressed='true'] { --btn-bg: rgba(34, 211, 238, .14); --btn-bd: rgba(34, 211, 238, .45); --btn-fg: #a5f3fc; }

.fv-text-form { margin: 0; }
.fv-editor {
  position: relative; display: flex; align-items: stretch; overflow: hidden;
  background: rgba(0, 0, 0, .45); border: 1px solid var(--line); border-radius: var(--r);
  transition: border-color .2s, box-shadow .2s;
}
.fv-editor:focus-within { border-color: rgba(139, 92, 246, .55); box-shadow: var(--ring); }
.fv-editor.fv-dirty { border-color: rgba(250, 204, 21, .45); }
.fv-gutter {
  flex: none; min-width: 3.4em; padding: 14px 10px 14px 12px; overflow: hidden;
  color: var(--text-3); background: rgba(255, 255, 255, .025); border-right: 1px solid var(--line);
  font: 13px/1.6 var(--mono); text-align: right; white-space: pre; user-select: none;
}
.fv-editor .text-editor {
  flex: 1 1 auto; min-width: 0; margin: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none;
  font: 13px/1.6 var(--mono); white-space: pre; overflow-wrap: normal; overflow: auto;
}
.fv-editor .text-editor:focus { outline: none; box-shadow: none; }
.fv-editor.fv-wrap .text-editor { white-space: pre-wrap; overflow-wrap: anywhere; }
.fv-editor.fv-wrap .fv-gutter { display: none; }
.fv-kbd-hint { margin-left: auto; color: var(--text-3); font-size: 12px; }
.fv-kbd-hint kbd { height: 20px; min-width: 20px; font-size: 10px; }

/* Markdown (rendered by viewer.js from text nodes only) */
.md-body {
  max-width: 900px; margin: 0 auto; padding: 18px 26px 26px;
  color: var(--text); font: 400 15px/1.7 var(--sans); overflow-wrap: anywhere;
}
.fv-md { min-height: 200px; background: rgba(0, 0, 0, .22); border: 1px solid var(--line); border-radius: var(--r); max-width: none; }
.fv-md > :first-child, .md-body > :first-child { margin-top: 0; }
.md-body h1, .md-body h2, .md-body h3, .md-body h4, .md-body h5, .md-body h6 {
  margin: 1.5em 0 .55em; font-family: var(--display); line-height: 1.25; letter-spacing: -.01em; scroll-margin-top: 80px;
}
.md-body h1 { font-size: 1.9em; padding-bottom: .3em; border-bottom: 1px solid var(--line); }
.md-body h2 { font-size: 1.45em; padding-bottom: .25em; border-bottom: 1px solid var(--line); }
.md-body h3 { font-size: 1.2em; }
.md-body h4 { font-size: 1.05em; }
.md-body h5, .md-body h6 { font-size: .95em; color: var(--text-2); }
.md-body p, .md-body ul, .md-body ol, .md-body blockquote, .md-body .md-code, .md-body .md-table-wrap { margin: 0 0 1em; }
.md-body a { color: #a5b4fc; text-decoration: underline; text-decoration-color: rgba(165, 180, 252, .4); text-underline-offset: 3px; }
.md-body a:hover { color: #c7d2fe; text-decoration-color: currentColor; }
.md-body strong { font-weight: 700; color: #fff; }
.md-body del { color: var(--text-3); }
.md-body ul, .md-body ol { padding-left: 1.6em; }
.md-body li + li { margin-top: .25em; }
.md-body li > ul, .md-body li > ol { margin: .25em 0 0; }
.md-body li::marker { color: var(--text-3); }
.md-body li.md-task { list-style: none; margin-left: -1.4em; }
.md-body li.md-task > input { margin: 0 .5em 0 0; vertical-align: -2px; accent-color: var(--violet); }
.md-body blockquote {
  padding: .4em 1em; color: var(--text-2);
  background: rgba(139, 92, 246, .06); border-left: 3px solid rgba(139, 92, 246, .6); border-radius: 0 10px 10px 0;
}
.md-body blockquote > :last-child { margin-bottom: 0; }
.md-body hr { height: 1px; margin: 1.8em 0; border: 0; background: linear-gradient(90deg, transparent, var(--line-2), transparent); }
.md-body img { max-width: 100%; max-height: 520px; height: auto; border-radius: 8px; }
.md-body code { font-size: .86em; }
.md-code { position: relative; }
.md-code pre {
  margin: 0; padding: 14px 16px; overflow: auto;
  background: rgba(0, 0, 0, .5); border: 1px solid var(--line); border-radius: 12px;
  font: 13px/1.6 var(--mono); tab-size: 4;
}
.md-code pre code { padding: 0; color: #dbe2f3; background: none; border: 0; border-radius: 0; font-size: inherit; }
.md-lang {
  position: absolute; top: 8px; left: 12px; color: var(--text-3); font: 600 10px var(--mono); letter-spacing: .08em; text-transform: uppercase; pointer-events: none;
}
.md-code .md-lang + .md-copy + pre { padding-top: 30px; }
.md-copy {
  position: absolute; top: 7px; right: 8px; z-index: 1; min-height: 24px; padding: 0 9px;
  color: var(--text-2); background: rgba(255, 255, 255, .06); border: 1px solid var(--line-2); border-radius: 7px;
  font: 600 11px var(--sans); cursor: pointer; opacity: 0; transition: opacity .15s, background-color .15s, color .15s;
}
.md-code:hover .md-copy, .md-copy:focus-visible { opacity: 1; }
.md-copy:hover { color: var(--text); background: rgba(255, 255, 255, .12); }
.md-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.md-body table { width: 100%; border-collapse: collapse; font-size: 14px; }
.md-body th, .md-body td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--line); }
.md-body th { color: var(--text-2); background: rgba(255, 255, 255, .03); font-weight: 600; }
.md-body tr:last-child td { border-bottom: 0; }
.md-body tbody tr:hover { background: rgba(255, 255, 255, .025); }
.md-body .md-al-center { text-align: center; }
.md-body .md-al-right { text-align: right; }
.md-ext-image { color: var(--text-2); font-style: italic; }

/* ===================================================== 3. Public share page */
.pf-head .public-head-main { flex: 1 1 auto; }
.pf-titles { min-width: 0; }
.pf-head h1.pf-name { margin: 0; }
.pf-head .page-subtitle { margin: 6px 0 0; }
.pf-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; }
.pf-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px;
  color: var(--text-2); background: rgba(255, 255, 255, .04); border: 1px solid var(--line-2);
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.pf-chip .ic.fv-ico { width: 14px; height: 14px; vertical-align: 0; }
.pf-chip-warn { color: #fde68a; background: rgba(250, 204, 21, .08); border-color: rgba(250, 204, 21, .3); }
.pf-actions { flex: none; display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
.pf-download { min-height: 44px; padding: 0 20px; font-size: 14px; }
.pf-stage { padding: 18px; }
.pf-stage .media-shell { width: min(100%, 1080px); }
.pf-stage .fv-stage-foot { width: 100%; }
.pf-markdown { justify-items: stretch; }
.pf-text-bar { width: 100%; }
.pf-markdown .md-body { width: 100%; max-width: 920px; }
.pf-markdown .public-text-viewer { width: 100%; }
.pf-state { gap: 12px; }
.pf-state-icon {
  display: grid; place-items: center; width: 64px; height: 64px; border-radius: 20px;
  color: #c4b5fd; background: var(--grad-soft); border: 1px solid var(--line-2);
}
.pf-state-icon .ic.fv-ico { width: 30px; height: 30px; }
.pf-state .pf-file-icon { width: 72px; height: 72px; border-radius: 20px; }
.pf-state .pf-file-icon .item-icon { width: 38px; height: 38px; }
.pf-state h1.pf-name { margin: 0; font-size: 21px; overflow-wrap: anywhere; }
.pf-lock-note {
  display: inline-flex; align-items: center; gap: 8px; margin: 0; padding: 8px 12px; border-radius: 10px;
  color: var(--text-2); background: rgba(255, 255, 255, .04); border: 1px solid var(--line); font-size: 13px;
}
.pf-password-form { display: grid; gap: 10px; }
.pf-password-form label { display: grid; gap: 6px; }

/* ===================================================== 4. Image viewer overlay */
html.pv-lock, html.pv-lock body { overflow: hidden; }
.pv-overlay {
  position: fixed; inset: 0; z-index: 9400; display: block;
  color: #f1f4fb; background: rgba(3, 4, 9, .94);
  opacity: 0; transition: opacity .22s var(--ease);
  -webkit-user-select: none; user-select: none;
}
.pv-overlay[hidden] { display: none; }
.pv-overlay.is-open { opacity: 1; }
.pv-overlay::before {
  /* faint aurora glow behind the picture */
  content: ''; position: absolute; inset: -20%; pointer-events: none; opacity: .5;
  background:
    radial-gradient(40% 35% at 20% 15%, rgba(34, 211, 238, .12), transparent 70%),
    radial-gradient(40% 40% at 85% 25%, rgba(139, 92, 246, .14), transparent 70%),
    radial-gradient(45% 40% at 50% 100%, rgba(244, 114, 182, .1), transparent 70%);
}
.pv-stage {
  position: absolute; inset: 64px 72px 44px; display: flex; align-items: center; justify-content: center;
  overflow: hidden; touch-action: none; cursor: default;
}
.pv-frame { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; }
.pv-img {
  display: block; max-width: 100%; max-height: 100%; object-fit: contain;
  border-radius: 4px; box-shadow: 0 30px 90px -20px rgba(0, 0, 0, 1);
  transform-origin: 50% 50%; will-change: transform; cursor: zoom-in;
  background-color: #1b1f2b;
  background-image:
    linear-gradient(45deg, rgba(255, 255, 255, .05) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, .05) 75%),
    linear-gradient(45deg, rgba(255, 255, 255, .05) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, .05) 75%);
  background-size: 16px 16px; background-position: 0 0, 8px 8px;
}
.pv-img.pv-smooth { transition: transform .26s var(--ease); }
.pv-zoomed .pv-img { cursor: grab; }
.pv-zoomed .pv-img:active { cursor: grabbing; }

.pv-topbar {
  position: absolute; inset: 0 0 auto; z-index: 2; display: flex; align-items: center; gap: 16px;
  height: 60px; padding: 0 12px 0 20px;
  background: linear-gradient(180deg, rgba(3, 4, 9, .85), rgba(3, 4, 9, 0));
  transition: opacity .25s var(--ease), transform .25s var(--ease);
}
.pv-title { display: flex; align-items: baseline; gap: 12px; min-width: 0; flex: 1 1 auto; }
.pv-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 600 15px var(--display); }
.pv-count { flex: none; color: rgba(241, 244, 251, .6); font: 600 12px var(--mono); letter-spacing: .04em; }
.pv-tools { flex: none; display: flex; align-items: center; gap: 2px; }
.pv-sep { width: 1px; height: 22px; margin: 0 6px; background: rgba(255, 255, 255, .14); }
.pv-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; padding: 0;
  color: rgba(241, 244, 251, .82); background: transparent; border: 1px solid transparent; border-radius: 10px;
  cursor: pointer; text-decoration: none;
  transition: color .15s, background-color .15s, transform .15s var(--ease);
}
.pv-btn:hover { color: #fff; background: rgba(255, 255, 255, .1); text-decoration: none; }
.pv-btn:active { transform: scale(.92); }
.pv-btn:disabled { opacity: .35; cursor: default; background: transparent; transform: none; }
.pv-btn:focus-visible, .pv-zoom-level:focus-visible { outline: none; box-shadow: var(--ring); }
.pv-btn[hidden] { display: none; }
.pv-ico { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pv-close:hover { background: rgba(239, 68, 68, .2); color: #fecaca; }
.pv-zoom-level {
  min-width: 58px; height: 30px; padding: 0 8px; border-radius: 8px;
  color: rgba(241, 244, 251, .8); background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .1);
  font: 600 12px var(--mono); cursor: pointer;
}
.pv-zoom-level:hover { color: #fff; background: rgba(255, 255, 255, .12); }

.pv-nav {
  position: absolute; top: 50%; z-index: 2; width: 52px; height: 52px; margin-top: -26px; border-radius: 50%;
  background: rgba(16, 19, 30, .55); border: 1px solid rgba(255, 255, 255, .12);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  transition: opacity .25s var(--ease), background-color .15s, transform .2s var(--spring), border-color .15s;
}
.pv-nav .pv-ico { width: 24px; height: 24px; }
.pv-nav:hover { background: rgba(139, 92, 246, .35); border-color: rgba(139, 92, 246, .65); }
.pv-prev { left: 12px; }
.pv-next { right: 12px; }
.pv-prev:hover { transform: translateX(-2px) scale(1.06); }
.pv-next:hover { transform: translateX(2px) scale(1.06); }
.pv-single .pv-nav, .pv-single .pv-count { display: none; }

.pv-hint {
  position: absolute; left: 50%; bottom: 12px; z-index: 2; transform: translateX(-50%);
  max-width: calc(100% - 32px); padding: 5px 12px; border-radius: 999px;
  color: rgba(241, 244, 251, .55); background: rgba(16, 19, 30, .5); border: 1px solid rgba(255, 255, 255, .08);
  font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none;
  transition: opacity .3s var(--ease);
}
.pv-idle .pv-topbar:not(:has(:focus-visible)) { opacity: 0; transform: translateY(-8px); }
.pv-idle .pv-nav:not(:focus-visible), .pv-idle .pv-hint { opacity: 0; }
.pv-idle .pv-stage { cursor: none; }

.pv-spinner {
  position: absolute; left: 50%; top: 50%; width: 42px; height: 42px; margin: -21px 0 0 -21px;
  border-radius: 50%; border: 3px solid rgba(255, 255, 255, .12); border-top-color: var(--cyan); border-right-color: var(--violet);
  animation: pvSpin .8s linear infinite;
}
.pv-error {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 1;
  display: grid; justify-items: center; gap: 10px; padding: 26px 30px; border-radius: var(--r-lg);
  background: rgba(16, 19, 30, .8); border: 1px solid rgba(255, 255, 255, .1); text-align: center;
}
.pv-error p { margin: 0; color: rgba(241, 244, 251, .8); }
.pv-error .pv-ico { width: 36px; height: 36px; color: #c4b5fd; }
.pv-error[hidden], .pv-spinner[hidden] { display: none; }

/* ===================================================== 5. Motion */
.pv-overlay .pv-anim-open { animation: pvZoomIn .32s var(--ease) both; }
.pv-overlay .pv-anim-next { animation: pvSlideNext .26s var(--ease) both; }
.pv-overlay .pv-anim-prev { animation: pvSlidePrev .26s var(--ease) both; }
.pv-overlay.is-open .pv-topbar { animation: pvFadeDown .3s var(--ease) both; }
.pv-overlay.is-open .pv-nav { animation: pvFade .35s var(--ease) .05s both; }
.pv-overlay.pv-closing .pv-img { opacity: 0; scale: .96; transition: scale .2s var(--ease), opacity .2s var(--ease); }

.fv-head { animation: fvUp .32s var(--ease) both; }
.fv-stage { animation: fvUp .36s var(--ease) .04s both; }
.fv-panel { animation: fvUp .38s var(--ease) .08s both; }
.fv-image-loaded .fv-image { animation: fvImgIn .45s var(--ease) both; }
.fv-md:not([hidden]), .pf-markdown .md-body:not([hidden]) { animation: fvFade .25s var(--ease) both; }
.fv-actions .icon-btn.copied .ic, .fv-head .icon-btn.copied .ic { animation: fvPop .35s var(--spring); }
.btn.copy.copied, .md-copy.copied { animation: fvPop .35s var(--spring); }
.fv-nopreview-icon, .pf-file-icon { animation: fvFloat 5s ease-in-out infinite; }
.pf-stage { animation: fvUp .36s var(--ease) .04s both; }

@keyframes pvSpin { to { transform: rotate(360deg); } }
@keyframes pvZoomIn { from { opacity: 0; scale: .9; } to { opacity: 1; scale: 1; } }
@keyframes pvSlideNext { from { opacity: 0; translate: 46px 0; } to { opacity: 1; translate: 0 0; } }
@keyframes pvSlidePrev { from { opacity: 0; translate: -46px 0; } to { opacity: 1; translate: 0 0; } }
@keyframes pvFadeDown { from { opacity: 0; transform: translateY(-10px); } }
@keyframes pvFade { from { opacity: 0; } }
@keyframes fvUp { from { opacity: 0; transform: translateY(10px); } }
@keyframes fvFade { from { opacity: 0; } }
@keyframes fvImgIn { from { opacity: 0; transform: scale(.985); } }
@keyframes fvPop { 0% { transform: scale(1); } 40% { transform: scale(1.25); } 100% { transform: scale(1); } }
@keyframes fvFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes fvTarget { 0% { box-shadow: var(--shadow), 0 0 0 2px rgba(139, 92, 246, .7); } 100% { box-shadow: var(--shadow), 0 0 0 2px rgba(139, 92, 246, 0); } }

@media (prefers-reduced-motion: reduce) {
  .pv-overlay, .pv-topbar, .pv-nav, .pv-hint, .pv-btn, .pv-img.pv-smooth, .fv-image, .fv-img-nav, .fv-back .ic,
  .fv-star .ic, .fv-seg button, .fv-editor, .md-copy, .pv-overlay.pv-closing .pv-img { transition: none !important; }
  .pv-overlay .pv-anim-open, .pv-overlay .pv-anim-next, .pv-overlay .pv-anim-prev,
  .pv-overlay.is-open .pv-topbar, .pv-overlay.is-open .pv-nav,
  .fv-head, .fv-stage, .fv-panel, .fv-image-loaded .fv-image, .fv-md:not([hidden]), .pf-markdown .md-body:not([hidden]),
  .fv-actions .icon-btn.copied .ic, .fv-head .icon-btn.copied .ic, .btn.copy.copied, .md-copy.copied,
  .fv-nopreview-icon, .pf-file-icon, .pf-stage, .fv .panel:target, .fv-stage:target { animation: none !important; }
  .pv-spinner { animation-duration: 1.6s; }
  .fv-image-link:hover .fv-image, .fv-img-prev:hover, .fv-img-next:hover, .pv-prev:hover, .pv-next:hover,
  .fv-star:hover .ic, .fv-back:hover .ic { transform: none; }
}

/* ===================================================== 6. Small screens */
@media (max-width: 900px) {
  .fv-head { flex-wrap: wrap; }
  .fv-actions { width: 100%; justify-content: flex-start; padding-top: 10px; border-top: 1px solid var(--line); overflow-x: auto; }
  .fv-details > div { grid-template-columns: 1fr; gap: 4px; }
}
@media (max-width: 640px) {
  .fv-meta { gap: 6px 8px; }
  .fv-meta-item + .fv-meta-item::before { content: none; }
  .fv-head { gap: 12px; padding: 14px; }
  .fv-type-icon { width: 44px; height: 44px; border-radius: 13px; }
  .fv-type-icon .item-icon { width: 26px; height: 26px; }
  .fv-name { white-space: normal; overflow-wrap: anywhere; font-size: 19px; }
  .fv-stage { padding: 10px; }
  .fv-image-stage, .pf-image-stage { min-height: 220px; padding: 10px; }
  .fv-image { max-height: 60vh; }
  .fv-img-nav { width: 38px; height: 38px; margin-top: -19px; }
  .fv-img-prev { left: 8px; }
  .fv-img-next { right: 8px; }
  .fv-pdf { height: 70vh; min-height: 360px; }
  .fv-kbd-hint { display: none; }
  .md-body { padding: 14px 14px 18px; font-size: 14.5px; }
  .pf-head { flex-wrap: wrap; }
  .pf-actions { width: 100%; justify-content: stretch; }
  .pf-actions .btn { flex: 1 1 auto; }

  .pv-stage { inset: 56px 0 40px; }
  .pv-topbar { height: 56px; gap: 8px; padding: 0 6px 0 14px; }
  .pv-title { flex-direction: column; gap: 0; align-items: flex-start; }
  .pv-name { font-size: 14px; max-width: 100%; }
  .pv-btn { width: 36px; height: 36px; }
  .pv-zoom-level, .pv-sep, [data-pv-zoom-in], [data-pv-zoom-out], .pv-hint { display: none; }
  .pv-nav { top: auto; bottom: 14px; margin-top: 0; width: 46px; height: 46px; }
  .pv-prev { left: 14px; }
  .pv-next { right: 14px; }
}
