/* Assets (/assets): Sume's /assets layout. A side panel (Assets, Uploads, Tools › Videos) and a main panel with
   search, Filter, View, a thumbnail-size slider and a date-grouped grid. Clicking a tile opens a full-screen viewer. */
.as-page { flex: 1; min-height: 0; display: flex; gap: 8px; padding: 0 8px 8px; }
.as-side, .as-main { border: 1px solid var(--line-2); border-radius: 12px; background: var(--bg); }

/* side panel */
.as-side { width: 168px; flex: none; padding: 6px; display: flex; flex-direction: column; gap: 2px; overflow: auto; }
.as-nav { display: flex; align-items: center; gap: 10px; width: 100%; height: 32px; padding: 0 8px; border-radius: 8px; color: var(--ink-2); font-size: 14px; text-align: left; }
.as-nav:hover { background: var(--hover); color: var(--ink); }
.as-nav[aria-current=true] { background: var(--active); color: var(--accent); }
.as-nav span { flex: 1; }
.as-nav em { font-style: normal; font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.as-label { padding: 12px 8px 4px; font-size: 12px; color: var(--ink-3); }

/* main panel */
.as-main { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.as-head { display: flex; align-items: center; gap: 12px; padding: 12px 12px 8px; flex-wrap: wrap; }
.as-head h1 { margin: 0; font-size: 20px; font-weight: 500; line-height: 28px; flex: 1; }
.as-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.as-search { display: flex; align-items: center; gap: 6px; height: 32px; width: 200px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: 8px; color: var(--ink-3); }
.as-search:focus-within { border-color: var(--accent); }
.as-search input { flex: 1; min-width: 0; background: none; border: 0; outline: none; color: var(--ink); font: inherit; font-size: 13px; }
.as-search input::-webkit-search-cancel-button { filter: invert(1) opacity(.5); }
.as-btn { position: relative; display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: 8px; color: var(--ink); font-size: 13px; white-space: nowrap; }
.as-btn:hover { background: var(--hover); }
.as-btn.danger { color: #ff7b72; }
.as-btn .dot { position: absolute; top: 5px; right: 5px; width: 6px; height: 6px; border-radius: 3px; background: var(--accent); }
.as-size { -webkit-appearance: none; appearance: none; width: 120px; height: 32px; margin: 0; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; cursor: pointer;
  background: linear-gradient(to right, var(--active) calc(100% * var(--fill, .5)), transparent 0); }
.as-size::-webkit-slider-thumb { -webkit-appearance: none; width: 2px; height: 14px; border-radius: 1px; background: var(--ink); }
.as-size::-moz-range-thumb { width: 2px; height: 14px; border: 0; border-radius: 1px; background: var(--ink); }
.as-size:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.as-body { --h: 260px; flex: 1; min-height: 0; overflow: auto; padding: 4px 12px 80px; }
.as-group { margin-bottom: 20px; }
.as-day { display: flex; align-items: center; gap: 10px; height: 32px; margin-bottom: 6px; font-size: 14px; }
.as-check { width: 18px; height: 18px; border-radius: 4px; border: 1px solid var(--line-2); background: var(--raised); display: grid; place-items: center; flex: none; }
.as-check svg { width: 12px; height: 12px; stroke-width: 2.4; visibility: hidden; }
.as-check[aria-checked=true] { background: var(--accent); border-color: var(--accent); }
.as-check[aria-checked=true] svg { visibility: visible; }
.as-grid { display: flex; flex-wrap: wrap; gap: 4px; }

/* tiles: fixed height (the slider), width from the clip's shape */
.as-tile { position: relative; height: var(--h); width: calc(var(--h) * var(--ar, .5625)); max-width: 100%; border-radius: 4px; overflow: hidden; background: var(--elev); cursor: pointer; flex: none; }
.as-tile > img, .as-tile > video { width: 100%; height: 100%; object-fit: cover; display: block; }
.as-tile .t-play { position: absolute; left: 8px; bottom: 8px; width: 14px; height: 14px; color: #fff; fill: #fff; stroke: none; filter: drop-shadow(0 1px 2px #0008); }
.as-tile .t-dur { position: absolute; right: 8px; bottom: 6px; font-size: 11px; color: #fff; text-shadow: 0 1px 2px #000a; font-variant-numeric: tabular-nums; }
.as-tile .t-state { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 12px; color: var(--ink-2); font-size: 12px; text-align: center; }
.as-tile .t-state.fail { color: #ff9b94; }
.as-tile .t-aud { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; gap: 12px; padding: 14px; color: var(--ink-2); font-size: 12px; word-break: break-word; }
.as-tile .t-aud svg { width: 28px; height: 28px; color: var(--ink-3); }
.as-tile .t-tag { position: absolute; left: 8px; top: 8px; padding: 2px 6px; border-radius: 4px; background: #000a; color: #fff; font-size: 10px; font-weight: 600; letter-spacing: .02em; text-transform: uppercase; }
.as-tile .t-sel { position: absolute; left: 8px; top: 8px; width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid #fff; background: #0004; display: grid; place-items: center; opacity: 0; transition: opacity .12s; }
.as-tile .t-sel svg { width: 12px; height: 12px; stroke-width: 2.6; visibility: hidden; }
.as-tile .t-acts { position: absolute; right: 8px; top: 8px; display: flex; flex-direction: column; gap: 8px; opacity: 0; transition: opacity .12s; }
.as-tile .t-acts button, .as-tile .t-acts a { width: 32px; height: 32px; border-radius: 50%; background: #0009; color: #fff; display: grid; place-items: center; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.as-tile .t-acts button:hover, .as-tile .t-acts a:hover { background: #000c; }
.as-tile:hover .t-sel, .as-tile:hover .t-acts, .as-tile:focus-visible .t-sel, .as-tile:focus-visible .t-acts { opacity: 1; }
.as-tile:hover .t-tag { opacity: 0; }
.as-tile[aria-selected=true] { outline: 2px solid var(--accent); outline-offset: -2px; }
.as-tile[aria-selected=true] .t-sel { opacity: 1; background: var(--accent); border-color: var(--accent); }
.as-tile[aria-selected=true] .t-sel svg { visibility: visible; }
.as-tile[aria-selected=true] .t-tag { opacity: 0; }
.as-tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.spin { width: 22px; height: 22px; border: 2px solid #444; border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.as-empty { margin: 12vh auto 0; max-width: 360px; text-align: center; color: var(--ink-2); }
.as-empty h2 { margin: 0 0 6px; color: var(--ink); font-size: 16px; font-weight: 500; }
.as-empty p { margin: 0 0 16px; }
.as-more { padding: 12px 0; color: var(--ink-3); font-size: 12px; }

/* selection bar */
.as-bar { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 14px; border-radius: 12px; background: var(--dd-surface); box-shadow: var(--dd-edge); white-space: nowrap; z-index: 5; }
.as-bar[hidden] { display: none; }
#selN { margin-right: 4px; font-size: 13px; }

/* menus */
.dd-rule { width: 100%; height: 1px; margin: 4px 0; border: 0; background: var(--dd-rule); }
.dd-item[data-on]::after { content: ''; width: 16px; height: 16px; margin-left: auto; background: currentColor;
  -webkit-mask: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m5 12 5 5 9-10"/></svg>') center / contain no-repeat;
  mask: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m5 12 5 5 9-10"/></svg>') center / contain no-repeat; color: var(--accent); }
.as-switch { position: relative; width: 28px; height: 16px; margin-left: auto; border-radius: 8px; background: #ffffff2a; transition: background .15s; }
.as-switch::after { content: ''; position: absolute; left: 2px; top: 2px; width: 12px; height: 12px; border-radius: 6px; background: #fff; transition: transform .15s; }
#hideFailed { gap: 16px; }
#hideFailed[aria-checked=true] .as-switch { background: var(--accent); }
#hideFailed[aria-checked=true] .as-switch::after { transform: translateX(12px); }
#hideFailed[aria-checked=true] { background: none; }
#hideFailed[aria-checked=true]:hover { background: var(--dd-wash); }

.btn.danger { background: #d0342c; color: #fff; font-weight: 500; }
.btn.danger:hover { background: #e0443c; }
.as-confirm { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

/* viewer */
.as-viewer { position: fixed; inset: 0; z-index: 950; display: flex; background: #050506fa; -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
.as-viewer[hidden] { display: none; }
.av-stage { flex: 1; min-width: 0; display: grid; place-items: center; padding: 16px 64px; }
.av-stage > video, .av-stage > img { max-width: 100%; max-height: calc(100dvh - 32px); border-radius: 4px; background: #000; }
.av-stage > audio { width: min(480px, 100%); }
.av-stage .av-msg { color: var(--ink-2); text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.av-nav { position: absolute; top: 50%; translate: 0 -50%; width: 40px; height: 40px; border-radius: 50%; background: #ffffff14; color: #fff; display: grid; place-items: center; }
.av-nav:hover { background: #ffffff26; }
.av-nav:disabled { opacity: .25; pointer-events: none; }
.av-nav.prev { left: 12px; }
.av-nav.next { right: calc(320px + 12px); }
.av-panel { width: 320px; flex: none; margin: 8px 8px 8px 0; display: flex; flex-direction: column; border-radius: 12px; background: var(--elev); box-shadow: var(--dd-edge); overflow: hidden; }
.av-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; padding: 12px 12px 8px; }
.av-top b { display: block; font-size: 14px; font-weight: 500; }
.av-top small { color: var(--ink-3); font-size: 12px; }
.av-icons { display: flex; gap: 2px; }
.av-icons button, .av-icons a { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: var(--ink-2); }
.av-icons button:hover, .av-icons a:hover { background: var(--hover); color: var(--ink); }
.av-scroll { flex: 1; overflow: auto; padding: 0 12px 16px; }
.av-sec { display: flex; align-items: center; justify-content: space-between; margin: 12px 0 8px; color: var(--ink-2); font-size: 13px; }
.av-sec span { display: inline-flex; align-items: center; gap: 6px; }
.av-copy { display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 8px; border-radius: 6px; background: var(--s-wash); color: var(--ink-2); font-size: 12px; }
.av-copy:hover { background: var(--s-wash-2); color: var(--ink); }
.av-copy svg { width: 13px; height: 13px; }
.av-prompt { max-height: 180px; overflow: auto; padding: 10px 12px; border-radius: 10px; background: var(--raised); color: var(--ink); font-size: 13px; line-height: 19px; white-space: pre-wrap; word-break: break-word; }
.av-details { padding: 4px 12px; border-radius: 10px; background: var(--raised); font-size: 13px; }
.av-details div { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; }
.av-details dt { color: var(--ink-3); }
.av-details dd { margin: 0; text-align: right; word-break: break-word; }
.av-refs { display: flex; flex-wrap: wrap; gap: 6px; }
.av-refs > * { width: 48px; height: 48px; border-radius: 6px; object-fit: cover; background: var(--raised); display: grid; place-items: center; color: var(--ink-3); font-size: 10px; }
.av-recreate { width: 100%; margin-top: 16px; }

@media (max-width: 760px) {
  .content { bottom: calc(59px + env(safe-area-inset-bottom)); }   /* clear the bottom tab bar */
  .as-page { flex-direction: column; padding: 0 8px 8px; gap: 6px; }
  .as-side { width: auto; flex-direction: row; align-items: center; padding: 4px; overflow-x: auto; }
  .as-nav { width: auto; flex: none; }
  .as-label { display: none; }
  .as-head { padding: 10px; }
  .as-tools { width: 100%; }
  .as-search { flex: 1; width: auto; }
  .as-size { display: none; }
  .as-body { padding: 4px 10px 80px; }
  .as-tile .t-sel, .as-tile .t-acts { opacity: 1; }
  .as-tile .t-tag { display: none; }
  .as-viewer { flex-direction: column; overflow: auto; }
  .av-stage { padding: 12px 12px 0; flex: none; }
  .av-stage > video, .av-stage > img { max-height: 60dvh; }
  .av-nav { display: none; }
  .av-panel { width: auto; margin: 8px; overflow: visible; }
  .av-scroll { overflow: visible; }
}
@media (hover: none) { .as-tile .t-sel, .as-tile .t-acts { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .spin { animation-duration: 3s; } }
