/* The Library screen (web/library.js). Colours come from the page's own variables, so light and dark follow the rest of the site. */
.dlg.lib-dlg { width: min(98vw, 1100px); height: min(92dvh, 900px); display: flex; flex-direction: column; }
.dlg.lib-dlg .dlg-body { flex: 1; max-height: none; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.dlg.lib-view { width: min(98vw, 1100px); max-height: 94dvh; }
.dlg.lib-view .dlg-body { max-height: calc(94dvh - 62px); }
.dlg.lib-view .dlg-body { padding-inline: 14px; }

.lib-top { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.lib-seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--surface); }
.lib-seg button { border: 0; background: transparent; padding: 8px 16px; min-height: 40px; color: var(--muted); }
.lib-seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-fg); font-weight: 600; }
.lib-search { flex: 1 1 160px; min-width: 120px; border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; min-height: 40px; background: var(--surface); }
.lib-top select { border: 1px solid var(--line); border-radius: 10px; padding: 8px; min-height: 40px; background: var(--surface); color: var(--fg); }
.lib-ico { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; width: 40px; height: 40px; font-size: 1rem; }
.lib-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.lib-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; font-size: .92rem; }
.lib-crumbs .crumb { border: 0; background: transparent; color: var(--accent); padding: 6px 8px; border-radius: 8px; min-height: 36px; }
.lib-crumbs .crumb:hover, .lib-crumbs .crumb.over { background: var(--accent-soft); }
.crumb-sep { color: var(--muted); }
.crumb-here { font-weight: 600; padding: 6px 8px; }
.lib-sel { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; background: var(--accent-soft); border-radius: 12px; padding: 8px 12px; }
.lib-sel .btn { text-decoration: none; }
.lib-status { text-align: left; min-height: 1.2em; margin: 0; }
.lib-status.warnline { color: var(--danger); }

.lib-uploads { border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; background: var(--surface); max-height: 30dvh; overflow: auto; }
.lib-up-head { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.lib-up-list { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 6px; }
.lib-up-list li { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(60px, 1fr) auto auto auto; gap: 8px; align-items: center; font-size: .88rem; }
.up-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-bar, .lib-bar { display: block; height: 8px; border-radius: 99px; background: var(--soft); overflow: hidden; }
.up-bar span, .lib-bar span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.up-err { grid-column: span 1; color: var(--danger); font-size: .82rem; }
.up.done .up-state { color: var(--muted); }
.up.error .up-state, .up.paused .up-state { color: var(--danger); }

.lib-area { position: relative; flex: 1; min-height: 160px; overflow: auto; border-radius: 12px; }
.lib-area.drop { outline: 2px dashed var(--accent); outline-offset: -4px; background: var(--accent-soft); }
.lib-dropmsg { display: none; position: absolute; inset: 0; place-items: center; font-weight: 600; color: var(--accent); pointer-events: none; }
.lib-area.drop .lib-dropmsg { display: grid; }
.lib-list { list-style: none; margin: 0; padding: 0; }
.lib-list.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.lib-list.rows { display: grid; gap: 4px; }
.lib-item { position: relative; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.lib-item.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.lib-item.over, .lib-item.folder.over { border-color: var(--accent); background: var(--accent-soft); }
.lib-item.off { opacity: .6; }
.lib-open { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 8px; border-radius: 12px; color: inherit; cursor: pointer; }
.lib-open.static { cursor: default; }
.lib-open:hover { background: var(--soft); }
.lib-thumb, .lib-list.grid .lib-icon { display: grid; place-items: center; width: 100%; aspect-ratio: 4 / 3; border-radius: 8px; background: var(--soft); font-size: 2.4rem; }
.lib-thumb { object-fit: cover; }
.lib-icon.big { font-size: 4rem; }
.lib-name { display: block; margin-top: 6px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-sub { display: block; color: var(--muted); font-size: .78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-check { position: absolute; top: 10px; left: 10px; width: 22px; height: 22px; z-index: 1; opacity: 0; accent-color: var(--accent); }
.lib-item:hover .lib-check, .lib-item:focus-within .lib-check, .lib-item.sel .lib-check { opacity: 1; }
@media (hover: none) { .lib-check { opacity: 1; } }
.lib-list.rows .lib-item { display: flex; align-items: center; }
.lib-list.rows .lib-check { position: static; margin: 0 4px 0 12px; flex: none; }
.lib-list.rows .lib-open { display: grid; grid-template-columns: 40px minmax(0, 1fr); column-gap: 10px; align-items: center; padding: 6px 8px; }
.lib-list.rows .lib-thumb, .lib-list.rows .lib-icon { grid-row: span 2; width: 40px; height: 40px; aspect-ratio: auto; font-size: 1.4rem; border-radius: 6px; display: grid; place-items: center; background: var(--soft); }
.lib-list.rows .lib-name { margin: 0; }
.lib-list.rows .lib-item.share { padding: 8px 10px; gap: 10px; }
.lib-list.rows .lib-item.share .lib-icon { width: 36px; height: 36px; grid-row: auto; flex: none; }
.lib-list.rows .lib-item.share .lib-open { flex: 1; }
.lib-row-act { margin-right: 12px; flex: none; }
.lib-empty { grid-column: 1 / -1; padding: 28px 12px; text-align: center; color: var(--muted); }
.lib-meter { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.lib-meter .lib-bar { width: 160px; }
.lib-bar.warn span { background: #c98b1a; }
.lib-bar.full span { background: var(--danger); }
.lib-meter .fine { margin: 0; text-align: left; }

/* the viewer */
.lv-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.lv-bar .btn { text-decoration: none; }
.lv-stage { display: grid; place-items: center; min-height: 40dvh; background: var(--soft); border-radius: 12px; overflow: hidden; }
.lv-image { width: 100%; display: grid; gap: 8px; }
.lv-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px; }
.lv-tools select { border: 1px solid var(--line); border-radius: 8px; padding: 4px; background: var(--surface); color: var(--fg); }
.lv-imgwrap { overflow: auto; max-height: 56dvh; text-align: center; }
.lv-img { max-width: none; }
.lv-img.fit { max-width: 100%; max-height: 54dvh; object-fit: contain; cursor: zoom-in; }
.lv-vid { width: 100%; }
.lv-video { width: 100%; max-height: 56dvh; background: #000; display: block; }
.lv-note { padding: 8px 12px; }
.lv-audio { display: grid; gap: 16px; place-items: center; padding: 28px; width: 100%; }
.lv-audio audio { width: min(100%, 520px); }
.lv-pdf { width: 100%; display: grid; gap: 6px; }
.lv-frame { width: 100%; height: 60dvh; border: 0; background: #fff; }
.lv-textwrap { width: 100%; padding: 8px; }
.lv-text { margin: 0; padding: 12px; max-height: 56dvh; overflow: auto; white-space: pre-wrap; word-break: break-word; background: var(--surface); border-radius: 8px; font: .85rem/1.5 ui-monospace, Menlo, Consolas, monospace; }
.lv-other { display: grid; gap: 8px; place-items: center; padding: 28px; }
.lv-info { text-align: left; }
.lib-shareform .fld { margin-bottom: 10px; display: grid; gap: 4px; }
.lib-shareform input[type="text"], .lib-shareform select { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; min-height: 40px; background: var(--surface); }
.lib-list.pick { max-height: 40dvh; overflow: auto; margin: 8px 0; }

@media (max-width: 600px) {
  .dlg.lib-dlg { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; }
  .lib-list.grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
  .lib-up-list li { grid-template-columns: 1fr auto; }
  .up-bar { grid-column: 1 / -1; order: 3; }
  .lib-meter .lib-bar { width: 100%; }
}
@media (prefers-reduced-motion: no-preference) { .lib-item, .lib-open { transition: background .12s, border-color .12s; } }
