:root {
    --bg: #f5f6f8;
    --panel: #ffffff;
    --text: #1d2330;
    --muted: #6b7280;
    --line: #e2e5ea;
    --accent: #2f6feb;
    --danger: #c0392b;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #14181f;
        --panel: #1c222b;
        --text: #e6e9ef;
        --muted: #93a0b4;
        --line: #2b333f;
        --accent: #6b9cff;
        --danger: #ff7b6b;
    }
}

* { box-sizing: border-box; }

/* display rules below would otherwise override the hidden attribute */
[hidden] { display: none !important; }

/* Browsers give forms default margins, which knocks buttons off the flex
   baseline in the top bar and toolbar. */
form { margin: 0; }

body {
    margin: 0;
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
}

body.centered {
    display: grid;
    place-items: center;
    min-height: 100vh;
}

a { color: var(--accent); }

.topbar {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem 1.25rem;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 5;
}

/* Header contents stay inside the same column as the page content. */
.topbar-inner {
    display: flex;
    align-items: center;
    gap: .75rem;
    width: 100%;
    max-width: 80rem;
    margin: 0 auto;
}

.brand { white-space: nowrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.inline { display: inline; }
.crumbs { display: flex; gap: .35rem; flex-wrap: wrap; font-size: .95rem; }
.crumbs a { text-decoration: none; }
.sep { color: var(--muted); }

/* Content is centred in a readable column; the header keeps full-bleed
   background with the same inner width so both line up. */
main { padding: 1.25rem; max-width: 80rem; margin: 0 auto; width: 100%; }

.toolbar {
    display: flex;
    gap: .5rem;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

button, .button, .dropzone, summary.button {
    font: inherit;
    line-height: 1.4;
    padding: .45rem .8rem;
    border-radius: 6px;
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--text);
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    white-space: nowrap;
    min-height: 2.1rem;
}

button:hover, .button:hover, .dropzone:hover { border-color: var(--accent); }
button.ghost { background: transparent; }
button.danger { color: var(--danger); }
.dropzone.dragover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--panel)); }

/* Files can be dropped anywhere on the page; this covers the listing while a
   drag is over it, so the drop is not a guess. The overlay must not swallow
   the drag events that drive it. */
.drop-overlay {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: grid;
    place-items: center;
    padding: 2rem;
    pointer-events: none;
    text-align: center;
    color: var(--accent);
    font-weight: 600;
    background: color-mix(in srgb, var(--accent) 10%, transparent);
    border: 3px dashed var(--accent);
    border-radius: 10px;
}
.drop-overlay[hidden] { display: none; }
.drop-overlay p { margin: 0; padding: .8rem 1.2rem; border-radius: 8px; background: var(--panel); border: 1px solid var(--line); }

/* The file input is hidden; the label is the button. */
.dropzone input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.dropzone { position: relative; }

.listing { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: 8px; overflow: hidden; }
.listing th, .listing td { text-align: left; padding: .55rem .8rem; border-bottom: 1px solid var(--line); }
.listing th { font-weight: 600; font-size: .85rem; color: var(--muted); }
.listing tr:last-child td { border-bottom: 0; }
.listing td:first-child { word-break: break-all; }
.listing .actions { text-align: right; white-space: nowrap; }
/* Row actions are a mix of <button> and <a class="button"> (one navigates, the
   other calls into the app): both have to look and measure the same. */
.listing .actions button,
.listing .actions .button { padding: .2rem .5rem; font-size: .85rem; min-height: 0; }
.listing.compact td, .listing.compact th { padding: .35rem .5rem; }

.card {
    background: var(--panel);
    padding: 1.5rem;
    border-radius: 10px;
    border: 1px solid var(--line);
    width: min(360px, 92vw);
}

.card h1 { font-size: 1.25rem; margin: 0 0 1rem; }

label:not(.dropzone) { display: block; margin-bottom: .75rem; font-size: .9rem; color: var(--muted); }
label:not(.dropzone) input { display: block; width: 100%; margin-top: .25rem; padding: .45rem .6rem; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; }
label:not(.dropzone) input[type=checkbox] { display: inline-block; width: auto; }
/* The "remember me" row reads as one line: box, then text. */
label.remember { display: flex; align-items: center; gap: .45rem; color: var(--text); }
label:not(.dropzone) select {
    display: block;
    width: 100%;
    margin-top: .25rem;
    padding: .45rem .6rem;
    font: inherit;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 6px;
}

/* Full-width accent submit, scoped to the sign-in/setup cards only. */
.card form button[type=submit], .card button { width: 100%; margin-top: .5rem; background: var(--accent); color: #fff; border-color: var(--accent); }

.error { color: var(--danger); font-size: .9rem; }
.ok { color: #1a7f37; font-size: .9rem; }

.transfers-wrap { margin-top: 1rem; }
.transfers-wrap[hidden] { display: none; }
.transfers-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .35rem; font-size: .85rem; color: var(--muted); }
.transfers { display: grid; gap: .4rem; }
.transfer { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: .5rem .75rem; font-size: .9rem; }
.transfer-head { display: flex; align-items: baseline; gap: .6rem; }
/* The name gives up room first: state and the cancel button must stay put. */
.transfer-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.transfer-state { flex: 0 0 auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.transfer-head button { flex: 0 0 auto; }
.transfer progress { width: 100%; height: .5rem; margin-top: .3rem; }
.transfer[data-state="done"] { border-color: color-mix(in srgb, #1a7f37 45%, var(--line)); }
.transfer[data-state="done"] .transfer-state { color: #1a7f37; }
.transfer[data-state="failed"] .transfer-state { color: var(--danger); }
.transfer[data-state="cancelled"] .transfer-state { color: var(--muted); }

dialog { border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--text); padding: 1.25rem; width: min(460px, 94vw); }
dialog::backdrop { background: rgba(0, 0, 0, .35); }
dialog h2 { margin-top: 0; font-size: 1.1rem; }
dialog menu { display: flex; gap: .5rem; justify-content: flex-end; padding: 0; margin: 1rem 0 0; }
dialog menu button { width: auto; }
/* Explicit, so styling never depends on child order. */
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.primary:hover { filter: brightness(1.08); }
dialog code { background: var(--bg); padding: .1rem .3rem; border-radius: 4px; }
dialog output { display: block; margin-top: .75rem; word-break: break-all; }

/* bulk selection, search and index controls */
.listing th.check, .listing td.check { width: 2.2rem; text-align: center; }
.listing td.check input, .bulkbar input[type=checkbox] { width: auto; margin: 0; }

.bulkbar { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: .5rem .75rem; }
.bulkbar label { display: inline-flex; align-items: center; gap: .35rem; margin: 0; }

.toolbar > *, .topbar > * { flex: 0 0 auto; }
/* The spacer must still grow, or nothing gets pushed to the right edge. */
.toolbar > .spacer, .topbar > .spacer { flex: 1 1 auto; }
.search { display: inline-flex; gap: .35rem; align-items: center; }
.search input { width: 14rem; padding: .45rem .6rem; font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 6px; }

/* Users: three columns plus up to three row buttons, so this dialog is wider
   than the default and scrolls sideways on a phone instead of squeezing the
   name down to a few letters. The dialog itself stays inside the viewport. */
#dlg-users { width: min(720px, 96vw); max-width: 96vw; }
#dlg-users .listing { display: block; overflow-x: auto; }
#dlg-users td:first-child { white-space: nowrap; }
#dlg-users th:first-child { width: 1%; }
#dlg-users thead, #dlg-users tbody { display: table; width: 100%; table-layout: auto; }
/* The buttons already name themselves; a label column would only add noise. */
#dlg-users .listing thead th:last-child { width: 1%; }
/* A form label carrying a checkbox reads as a row, not a stacked field. */
#form-user label:has(input[type=checkbox]) { display: flex; align-items: center; gap: .5rem; }
#form-user label:has(input[type=checkbox]) input { width: auto; margin: 0; }
/* The hint continues the field's own line, so it must not look like a label. */
#form-user .hint { display: block; margin-top: .2rem; font-size: .8rem; }
#form-user output { margin-bottom: .75rem; }

/* share list: keep the path on one line, let the URL wrap instead */
/* Three short paragraphs instead of one: they wrap as sentences, not fragments. */
.index-intro p { margin: 0 0 .35rem; }
.index-intro p:last-child { margin-bottom: 0; }

#dlg-shares { width: min(640px, 94vw); }
#dlg-shares td:first-child { white-space: nowrap; }
#dlg-shares td a { word-break: break-all; }

/* "shared" marker in listings */
.badge {
    display: inline-block;
    margin-left: .4rem;
    padding: .05rem .4rem;
    border-radius: 999px;
    font-size: .7rem;
    font-weight: 600;
    letter-spacing: .02em;
    text-transform: uppercase;
    color: var(--accent);
    border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
    background: color-mix(in srgb, var(--accent) 10%, transparent);
    vertical-align: middle;
    /* Clickable: keep it out of the button sizing rules. */
    font-family: inherit;
    line-height: 1.4;
    cursor: pointer;
}

button.badge {
    min-height: 0;
    padding: .05rem .45rem;
}

button.badge:hover {
    background: color-mix(in srgb, var(--accent) 22%, transparent);
    border-color: var(--accent);
}
#dlg-share { width: min(620px, 94vw); }
#dlg-share h3 { font-size: .9rem; margin: 1.1rem 0 .5rem; color: var(--muted); }
#dlg-share h3:first-of-type { margin-top: 0; }

/* Status line sits under the toolbar, not inside the centred button row. */
.status-line { margin: -.4rem 0 1rem; font-size: .9rem; text-align: center; min-height: 1.2em; }

/* share links: one row per link, copy + delete actions right-aligned */
.share-list { list-style: none; margin: 0 0 .25rem; padding: 0; display: grid; gap: .5rem; }
.share-list li { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: .5rem .65rem; }
.share-row { display: flex; align-items: center; gap: .5rem; }
.share-url {
    flex: 1 1 auto;
    min-width: 0;
    font-size: .9rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    overflow-wrap: anywhere;
}
.diagnostics { display: grid; gap: 1rem; max-height: 60vh; overflow: auto; }
.diagnostics-group h3 { margin: 0 0 .3rem; font-size: .85rem; color: var(--muted); }
.diagnostics dl { display: grid; grid-template-columns: minmax(9rem, auto) 1fr; gap: .15rem .75rem; margin: 0; font-size: .85rem; }
.diagnostics dt { color: var(--muted); }
.diagnostics dd { margin: 0; font-variant-numeric: tabular-nums; word-break: break-word; }
/* What is absent is the answer to "why does this not work", so it is visible. */
.diagnostics dd.missing { color: var(--danger); }
#dlg-diagnostics { width: min(640px, 96vw); }

.share-details {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .4rem;
    margin-top: .3rem;
    font-size: .78rem;
    color: var(--muted);
}
/* Says whose link this is when an admin sees somebody else's. */
.share-details .share-owner { color: var(--text); font-weight: 600; }
button.small { padding: .2rem .5rem; font-size: .8rem; min-height: 0; }
.small { font-size: .8rem; }
#share-result { font-size: .85rem; word-break: break-all; }

/* link-type entries (Google Drive .desktop shortcuts) */
.badge.link-badge { color: var(--muted); border-color: var(--line); background: transparent; }

/* sortable column headers */
th button.sort {
    background: none;
    border: 0;
    padding: 0;
    margin: 0;
    min-height: 0;
    font: inherit;
    font-weight: 600;
    font-size: .85rem;
    color: var(--muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: .25rem;
}
th button.sort:hover { color: var(--text); }
th button.sort.active { color: var(--accent); }
th button.sort .arrow { font-size: .7em; }

/* AGPL source-offer footer */
.site-footer {
    margin-top: 2rem;
    padding: 1rem 1.25rem 1.5rem;
    text-align: center;
    font-size: .8rem;
    color: var(--muted);
    border-top: 1px solid var(--line);
}
.site-footer p { margin: 0; }
.site-footer a { color: var(--muted); text-decoration: underline; }
.site-footer a:hover { color: var(--accent); }

/* index dialog: status, progress and result live in the modal */
#dlg-index { width: min(520px, 94vw); }
.index-status { margin: .75rem 0 .25rem; padding: .65rem .75rem; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); }
.index-status p { margin: 0; font-size: .9rem; }
.index-status[data-state="built"] { border-color: color-mix(in srgb, #1a7f37 45%, var(--line)); }
.index-status[data-state="built"] #index-state { color: #1a7f37; }
.index-status[data-state="building"] #index-state { color: var(--accent); }
.index-status[data-state="error"] #index-state { color: var(--danger); }
.index-status progress { display: block; width: 100%; height: .4rem; margin-top: .5rem; }
.index-status .index-result { margin-top: .45rem; color: var(--muted); }

/* ------------------------------------------------------------------ narrow */

/*
 * Small screens: the header wraps instead of overflowing, the listing
 * collapses to name + actions, and row actions become icon-only buttons.
 * Breakpoints are on viewport width. See the ~560px rule below for the date.
 */
@media (max-width: 640px) {
  .topbar-inner { flex-wrap: wrap; row-gap: .5rem; }
  .topbar-inner .crumbs { order: 3; flex: 1 1 100%; }
  .topbar-inner .spacer { display: none; }
  #whoami { order: 2; margin-left: auto; }

  main { padding: .75rem; }
  .toolbar { justify-content: stretch; }
  .toolbar > button, .toolbar > .dropzone, .toolbar > .search { flex: 1 1 auto; }
  .search input { width: 100%; min-width: 0; }

  /* Table: drop the columns that do not fit, keep the actions reachable. */
  .listing th:nth-child(3), .listing td:nth-child(3) { display: none; }
  .listing .actions { padding-left: 0; }
  /* The checkbox column only needs room for the box itself: its .8rem
     padding on both sides was pure waste on a 360px screen. */
  .listing th.check, .listing td.check { width: 1.9rem; padding-left: .5rem; padding-right: .2rem; }
  .listing td:first-child { word-break: normal; overflow-wrap: anywhere; }
}

/* The date needs ~150px to stay on one line; below this it wraps and makes
   rows uneven, so drop it and leave names and actions. */
@media (max-width: 560px) {
  .listing th:nth-child(4), .listing td:nth-child(4) { display: none; }
}

/* The actions cell must not push the name column out of the way: it wraps its
   buttons onto a second line instead of forcing the row wider than the screen. */
@media (max-width: 640px) {
  .listing .actions { white-space: normal; }
}

/* Icon-only row actions on touch/narrow layouts. Links that are real
   navigations keep their text, so they stay readable without an icon font. */
@media (max-width: 640px), (pointer: coarse) {
  .listing .actions button {
    padding: .35rem;
    min-width: 2rem;
    min-height: 2rem;
    font-size: 1rem;
    line-height: 1;
  }
  /* Hide the label, keep it for screen readers and tooltips. */
  .listing .actions button .label { display: none; }
}

/* row action icons */
.listing .actions .icon { font-size: 1em; line-height: 1; }
@media (min-width: 641px) and (pointer: fine) {
  /* On roomy pointer layouts the icons are decorative padding; keep them
     visible but subordinate to the text. */
  .listing .actions .icon { opacity: .65; }
}

/* in-app document editor */
body.editing { overflow: hidden; }
.editor-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    background: var(--bg);
}
.editor-overlay[hidden] { display: none !important; }
.editor-bar {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .5rem .75rem;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
}
.editor-bar .muted { font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.editor-bar button.primary { width: auto; margin: 0; }
#editor-frame { flex: 1 1 auto; width: 100%; border: 0; background: var(--panel); }

/* "New document" dropdown in the toolbar */
.menu-wrap { position: relative; display: inline-block; }
.menu-wrap[hidden] { display: none !important; }
.menu-list {
    position: absolute;
    left: 0;
    top: calc(100% + .35rem);
    z-index: 30;
    display: grid;
    gap: .25rem;
    min-width: 12rem;
    padding: .35rem;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgb(0 0 0 / 12%);
}
.menu-list[hidden] { display: none !important; }
.menu-list button { width: 100%; justify-content: flex-start; border-color: transparent; background: transparent; }
.menu-list button:hover { border-color: var(--accent); }

/* internal link shown in the share dialog */
.share-internal {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
    margin: 0 0 .75rem;
    font-size: .8rem;
    color: var(--muted);
}
.share-internal a {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    word-break: break-all;
    min-width: 0;
}

/* a button that reads as a link, for names in the share listing */
button.linkish {
    background: none;
    border: 0;
    padding: 0;
    min-height: 0;
    font: inherit;
    color: var(--accent);
    cursor: pointer;
    text-align: left;
}
button.linkish:hover { text-decoration: underline; }

/* share dialog: related fields share a row */
.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .75rem;
}
.field-row > label { margin-bottom: .75rem; }
.field-row label:only-child { grid-column: 1 / -1; }
@media (max-width: 520px) {
    .field-row { grid-template-columns: 1fr; gap: 0; }
}

/* action buttons on the single-file share page */
.share-file-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0; }
.card .share-file-actions .button,
.card .share-file-actions button {
    width: auto;
    margin: 0;
    padding: .45rem .9rem;
}


/* access level opening the detail line under a share link */
.access-word { font-weight: 600; }
.access-word.view { color: var(--accent); }
.access-word.edit { color: #8a5a00; }
@media (prefers-color-scheme: dark) {
    .access-word.edit { color: #eab308; }
}

/* image gallery: a plain CSS grid, no JavaScript required */
.gallery {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: .75rem;
}
.gallery .tile { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.gallery .thumb {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}
.gallery .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* A video has no still: a play mark sits over the tile, drawn in CSS so it
   costs no request and needs nothing on the server. */
.gallery .thumb.is-video::after,
.gallery .thumb:has(img.is-video)::after {
    content: '';
    position: absolute;
    width: 2.6rem;
    height: 2.6rem;
    border-radius: 50%;
    background: rgba(0, 0, 0, .55) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23fff'%3E%3Cpath d='M8 5v14l11-7z'/%3E%3C/svg%3E") center/60% no-repeat;
    border: 1px solid rgba(255, 255, 255, .5);
    pointer-events: none;
}
.gallery .thumb.is-video,
.gallery .thumb:has(img.is-video) { position: relative; }
/* No still to show: keep the tile dark so the play mark reads. */
.gallery .thumb img.no-thumb { visibility: hidden; }
/* A document or an archive has no still either: a neutral file tile names
   the type and says what a click does, instead of a broken image. */
.gallery .thumb.is-file { background: var(--bg); }
.gallery .file-mark {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .15rem;
    width: 100%;
    height: 100%;
    color: var(--muted);
}
.gallery .file-kind {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: .06em;
    color: var(--text);
}
.gallery .file-action { font-size: .7rem; text-transform: lowercase; }
.gallery .file-icon { width: 2.2rem; height: 2.2rem; fill: currentColor; opacity: .8; }
.gallery .thumb:has(img.no-thumb) { background: #1b1f26; }
.gallery .thumb.dir { background: var(--bg); }
.gallery .thumb:hover { border-color: var(--accent); }
.gallery .dir-label { font-size: .85rem; color: var(--accent); padding: .5rem; text-align: center; word-break: break-all; }
.gallery .tile-name {
    font-size: .75rem;
    color: var(--muted);
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
@media (max-width: 480px) {
    .gallery { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: .5rem; }
}

/* Controls that only do something with JavaScript, on the public share page.
   Its <html> starts with .no-js-marked, which the inline script removes before
   the body is parsed: without script the controls stay hidden, with it they
   come back. Only the share page does this, the app always has them. */
html.no-js-marked .bulkbar,
html.no-js-marked td.check,
html.no-js-marked th.check,
html.no-js-marked .tile-select,
html.no-js-marked .tile-select-wrap { display: none; }

/* selection checkbox overlaid on a gallery tile */
.gallery .tile { position: relative; }

/* A folder's "shared" badge sits on the tile, under its name: the list puts
   it beside the name, and the grid must not be the quieter surface. */
.gallery .tile > .badge { align-self: center; }
/*
 * The checkbox sits in a label covering the corner of the tile, so the click
 * target is the whole corner and not the 18px box: aiming for the checkbox and
 * missing it opens the slideshow, which is the costlier mistake. The wrap is
 * placed explicitly because the generic `label:not(.dropzone)` rule makes it a
 * block, and flex would stretch it to the tile width.
 */
.gallery .tile-select-wrap {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    margin: 0;
    cursor: pointer;
}
.gallery .tile-select-wrap input {
    display: block;
    width: 1.15rem;
    height: 1.15rem;
    margin: 0;
    padding: 0;
    cursor: pointer;
    /* Readable over both light and dark thumbnails. */
    accent-color: var(--accent);
    filter: drop-shadow(0 1px 2px rgb(0 0 0 / 45%));
}
.gallery .tile.selected .thumb { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 40%, transparent); }

/* shared badge + list/gallery toggle: they take the place the share button
   used to hold, so they sit at the end of the bulk bar.
   The toolbar sizes every child to `0 0 auto`, and a flexible box does not get
   that width from its content: as inline-flex the group collapsed to nothing. */
.view-controls {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: .5rem;
}
.view-controls[hidden] { display: none; }
.view-controls .badge { margin-left: 0; }

/* archive listing in the share view */
.zip-list {
    list-style: none;
    margin: .5rem 0 0;
    padding: 0;
    max-height: 40vh;
    overflow: auto;
    font-size: .85rem;
}
.zip-list li { padding: .15rem .25rem; border-bottom: 1px solid var(--line); word-break: break-all; }
.zip-list li:last-child { border-bottom: 0; }

/* full-screen image viewer for the gallery */
.lightbox {
    width: min(96vw, 1400px);
    max-width: none;
    height: min(92vh, 1000px);
    padding: 0;
    border: 1px solid #2b333f;
    background: #14181f;
    color: #e6e9ef;
}
.lightbox[open] { display: flex; flex-direction: column; }
.lightbox::backdrop { background: rgb(0 0 0 / 78%); }

.lightbox-bar {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .5rem .75rem;
    border-bottom: 1px solid #2b333f;
    font-size: .9rem;
    flex: 0 0 auto;
    min-width: 0;
}
.lightbox-bar #lightbox-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
.lightbox-count {
    color: #93a0b4;
    font-variant-numeric: tabular-nums;
    flex: 0 0 auto;
}

/* Download and Close share one appearance: same box, same height, same text */
.lightbox-action {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 2rem;
    padding: 0 .75rem;
    border-radius: 6px;
    border: 1px solid #3a4452;
    background: #1c222b;
    color: #e6e9ef;
    font: inherit;
    font-size: .85rem;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    min-height: 0;
}
.lightbox-action:hover {
    border-color: #6b9cff;
    color: #fff;
    background: #232b36;
}
/* Same signal as a row action's danger button: red text, border on hover. */
.lightbox-action.is-danger { color: #ff8a7a; }
.lightbox-action.is-danger:hover { border-color: #ff8a7a; }

.lightbox-body {
    position: relative;
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    min-height: 0;
}
.lightbox-body img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
}
.lightbox-body img[hidden] { display: none !important; }
/* A video takes the same box; controls come from the browser. */
.lightbox-body video {
    max-width: 100%;
    max-height: 100%;
    display: block;
    background: #000;
}
.lightbox-body video[hidden] { display: none !important; }

/* stands in for the image while it is being fetched */
.lightbox-loading {
    margin: 0;
    color: #93a0b4;
    font-size: .95rem;
    letter-spacing: .02em;
}
.lightbox-loading[hidden] { display: none !important; }

/* solid chevrons drawn as svg, so they look the same at any size */
.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    border: 0;
    background: rgb(255 255 255 / 12%);
    color: #fff;
    cursor: pointer;
    min-height: 0;
    transition: background .12s ease;
}
.lightbox-nav:hover { background: rgb(255 255 255 / 26%); }
.lightbox-nav svg {
    width: 1.4rem;
    height: 1.4rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}
#lightbox-prev { left: .75rem; }
#lightbox-next { right: .75rem; }
