:root {
    /* base atmosphere — deep night sky with a high-altitude horizon glow */
    --bg: #0a0e16;
    --bg-grad: radial-gradient(1200px 620px at 72% -12%, #1b2c4a 0%, transparent 60%),
               radial-gradient(900px 500px at 8% 4%, rgba(255,154,61,.10) 0%, transparent 55%),
               linear-gradient(180deg, #0c1424 0%, #0a0e16 55%);
    --panel: #121826;
    --panel-2: #1a2233;
    --text: #eef2f8;
    --muted: #9aa6bd;
    /* sky-blue primary + golden-hour secondary */
    --accent: #5aa0ff;
    --accent-2: #3f7fe0;
    --gold: #ffb454;
    --gold-2: #ff9a3d;
    --ok: #34d399;
    --err: #ff6b6b;
    --border: #232c40;
    --radius: 12px;
    /* larger radius for big surfaces (hero, cards) so the rounding reads as intentional */
    --radius-lg: 18px;
    /* elevation + motion */
    --shadow-1: 0 2px 8px rgba(0,0,0,.35);
    --shadow-2: 0 12px 32px rgba(0,0,0,.45);
    --shadow-glow: 0 0 0 1px rgba(90,160,255,.18), 0 8px 28px rgba(20,60,140,.40);
    --ease: cubic-bezier(.2,.7,.2,1);
    --font-display: "Space Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

/* Never let a stray wide element (table, media, long token) push the page sideways. */
html, body { overflow-x: hidden; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg-grad), var(--bg);
    background-attachment: fixed;
    background-repeat: no-repeat;
    color: var(--text);
    line-height: 1.5;
}

img, video { max-width: 100%; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 28px;
    border-bottom: 1px solid var(--border);
    background: rgba(12,18,30,.72);
    -webkit-backdrop-filter: saturate(140%) blur(12px);
    backdrop-filter: saturate(140%) blur(12px);
    position: sticky;
    top: 0;
    z-index: 50;
}
.brand { font-family: var(--font-display); font-weight: 700; font-size: 21px; letter-spacing: -.01em; color: var(--text); }
.brand span {
    background: linear-gradient(120deg, var(--accent), var(--gold));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: var(--accent);
}
.topbar nav { display: flex; align-items: center; gap: 18px; }
.inline { display: inline; margin: 0; }

/* Hamburger button — hidden on desktop, shown on small screens (see media query below). */
.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 42px;
    height: 38px;
    padding: 0 9px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
}
.nav-toggle span { display: block; height: 2px; width: 100%; background: var(--text); border-radius: 2px; transition: transform .2s var(--ease), opacity .2s var(--ease); }
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

@media (max-width: 640px) {
    .nav-toggle { display: flex; }
    .topbar nav {
        position: absolute;
        top: calc(100% + 8px);
        right: 16px;
        left: 16px;
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
        padding: 8px;
        background: var(--panel);
        border: 1px solid var(--border);
        border-radius: var(--radius-lg);
        box-shadow: var(--shadow-2);
        /* hidden until toggled */
        opacity: 0;
        transform: translateY(-8px);
        pointer-events: none;
        transition: opacity .18s var(--ease), transform .18s var(--ease);
    }
    .topbar nav.open { opacity: 1; transform: translateY(0); pointer-events: auto; }
    .topbar nav a { padding: 11px 12px; border-radius: 10px; }
    .topbar nav a:hover { background: rgba(90,160,255,.08); text-decoration: none; }
    .topbar nav .btn.small { text-align: center; }
}
button.link, .link { background: none; border: none; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }

.container { max-width: 920px; margin: 0 auto; padding: 32px 24px 64px; }
@media (max-width: 560px) { .container { padding: 20px 16px 48px; } }
.foot { text-align: center; color: var(--muted); padding: 32px; border-top: 1px solid var(--border); }

h1, h2, h3 { font-family: var(--font-display); }
h1 { font-size: 28px; margin: 0 0 12px; letter-spacing: -.02em; }
h2 { font-size: 20px; margin: 0 0 12px; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.lead { font-size: 18px; color: var(--muted); max-width: 60ch; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
/* On phones the title + status badge + action buttons can't share one row — give the title
   its own line and let the badge/buttons wrap onto the row below (left-aligned). */
@media (max-width: 640px) {
    .page-head { flex-wrap: wrap; gap: 10px 10px; }
    .page-head > h1 { flex: 1 1 100%; margin-bottom: 0; }
    .page-head-actions { margin-left: 0; flex-wrap: wrap; }
}

.btn {
    display: inline-block;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
    padding: 10px 18px;
    border-radius: var(--radius);
    border: none;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-glow);
    transition: transform .15s var(--ease), box-shadow .2s var(--ease), background .2s var(--ease);
}
.btn:hover { background: linear-gradient(135deg, #6cabff, var(--accent-2)); text-decoration: none; transform: translateY(-1px); box-shadow: 0 0 0 1px rgba(90,160,255,.28), 0 10px 30px rgba(20,60,140,.5); }
.btn:active { transform: translateY(0); }
.btn.small { padding: 6px 12px; font-size: 14px; }
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--text); box-shadow: none; }
.btn.ghost:hover { background: rgba(90,160,255,.08); border-color: var(--accent); }
.btn.danger { background: var(--err); box-shadow: none; }
.btn.danger:hover { background: #e04040; }
.page-head-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.form-actions { display: flex; align-items: center; gap: 16px; margin-top: 8px; }

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin: 20px 0;
    box-shadow: var(--shadow-1);
}
.card.narrow { max-width: 440px; margin: 40px auto; }
.card.narrow-lg { max-width: 560px; }
.email-display { margin: 0 0 16px; font-size: 13px; }

label { display: block; margin: 0 0 16px; font-weight: 600; }
label small { font-weight: 400; color: var(--muted); }
input[type=text], input[type=email], input[type=password], textarea {
    width: 100%;
    margin-top: 6px;
    padding: 10px 12px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font: inherit;
    font-weight: 400;
}
textarea { resize: vertical; }

/* Privacy/metadata toggles — replace the default square browser checkbox with a
   rounded, accent-filled custom box. Used in drops/new.ftl & drops/edit.ftl. */
fieldset.toggles { border: none; margin: 0 0 16px; padding: 0; display: flex; flex-direction: column; gap: 12px; }
fieldset.toggles legend { padding: 0; margin-bottom: 4px; font-weight: 600; }
label.check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0 0 16px;
    font-weight: 400;
    cursor: pointer;
}
fieldset.toggles label.check { margin: 0; }
label.check input[type=checkbox] {
    appearance: none;
    -webkit-appearance: none;
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    margin: 1px 0 0;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    transition: background .15s var(--ease), border-color .15s var(--ease);
}
label.check input[type=checkbox]:hover { border-color: var(--accent); }
label.check input[type=checkbox]:checked { background: var(--accent); border-color: var(--accent); }
label.check input[type=checkbox]:checked::after {
    content: "";
    position: absolute;
    left: 6px; top: 2px;
    width: 5px; height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
label.check input[type=checkbox]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
label.check > span { line-height: 1.4; }

.field-error { display: block; color: var(--err); font-weight: 400; font-size: 13px; margin-top: 4px; }
.notice { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.notice.ok { background: rgba(46,204,113,.12); color: var(--ok); }
.notice.error { background: rgba(255,93,93,.12); color: var(--err); }
/* Default (no modifier): neutral informational accent, e.g. the closed-beta notice. */
.notice:not(.ok):not(.error) { background: rgba(79,140,255,.12); border: 1px solid rgba(79,140,255,.28); }
.hero-notice { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 24px; margin-bottom: 0; }
.hero-notice .btn { flex-shrink: 0; }

.hero { position: relative; padding: 96px 0 72px; overflow: hidden; border-radius: var(--radius-lg); }
.hero.compact { padding: 24px 0; }
.hero::before {
    content: "";
    position: absolute;
    top: -10%; left: -20%; right: -20%;
    height: 150%;
    background: radial-gradient(60% 80% at 28% 0%, rgba(90,160,255,.28), transparent 60%),
                radial-gradient(50% 60% at 92% 8%, rgba(255,180,84,.20), transparent 55%);
    /* Heavier blur + a radial fade so the glow dissolves into the page instead of being
       hard-clipped to a rectangle by overflow:hidden (which looked like sharp edges). */
    filter: blur(40px);
    -webkit-mask-image: radial-gradient(72% 70% at 50% 32%, #000 8%, transparent 62%);
    mask-image: radial-gradient(72% 70% at 50% 32%, #000 8%, transparent 62%);
    z-index: -1;
    pointer-events: none;
}
.hero h1 { font-size: clamp(40px, 6vw, 64px); line-height: 1.05; }
.hero .lead { font-size: 19px; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: 13px; color: var(--muted); }
.cta-row { display: flex; gap: 12px; margin-top: 28px; }

.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; margin-top: 32px; }
.feature {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px 20px;
    box-shadow: var(--shadow-1);
    transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s var(--ease);
}
.feature:hover { transform: translateY(-4px); box-shadow: var(--shadow-2); border-color: rgba(90,160,255,.35); }
.feature h3 { margin: 0 0 8px; }
.feature-icon {
    display: inline-flex;
    width: 40px; height: 40px;
    margin-bottom: 12px;
    color: var(--accent);
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: rgba(90,160,255,.12);
    border: 1px solid rgba(90,160,255,.22);
}
.feature-icon svg { width: 22px; height: 22px; }

table.drops { width: 100%; border-collapse: collapse; margin-top: 16px; }
table.drops th, table.drops td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
table.drops th { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .04em; }
/* --- dashboard: drops as cover-banner cards --- */
.drops-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 18px;
    margin-top: 16px;
}
.drop-card {
    display: flex;
    flex-direction: column;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-1);
    transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s var(--ease);
}
.drop-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-2); border-color: rgba(90,160,255,.35); }
.drop-card-cover {
    display: block;
    position: relative;
    aspect-ratio: 16 / 10;
    background: #0c0e12;
    overflow: hidden;
}
.drop-card-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .5s var(--ease);
}
.drop-card:hover .drop-card-cover img { transform: scale(1.05); }
.drop-card-cover-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(120% 120% at 30% 0%, rgba(90,160,255,.18), transparent 60%),
                radial-gradient(120% 120% at 100% 100%, rgba(255,180,84,.14), transparent 55%),
                var(--panel-2);
}
.drop-card-cover-empty .empty-drone { width: 64px; margin: 0; opacity: .5; }
.drop-card-lock {
    position: absolute;
    top: 10px; right: 10px;
    padding: 3px 9px;
    border-radius: 999px;
    background: rgba(0,0,0,.55);
    font-size: 12px;
    line-height: 1;
}
.drop-card-body { display: flex; flex-direction: column; gap: 4px; flex: 1; padding: 14px 16px 16px; }
.drop-card-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 17px;
    color: var(--text);
    letter-spacing: -.01em;
}
.drop-card-title:hover { color: var(--accent); text-decoration: none; }
.drop-card-meta { margin: 0; font-size: 14px; color: var(--text); }
.drop-card-date { margin: 0; font-size: 12px; color: var(--muted); }
.drop-card-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 12px; }
.drop-card-manage { color: var(--muted); font-size: 13px; font-weight: 600; }
.drop-card-manage:hover { color: var(--accent); text-decoration: none; }
.copy-link.copied { color: var(--ok); border-color: var(--ok); }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.draft { background: rgba(152,162,179,.15); color: var(--muted); }
.badge.ready { background: rgba(46,204,113,.15); color: var(--ok); }
.badge.role-admin { background: rgba(79,140,255,.15); color: var(--accent); }
.badge.role-user { background: rgba(152,162,179,.15); color: var(--muted); }

/* Slack-style unread count: a red circle pinned to the top-right corner of its anchor. */
.badge-anchor { position: relative; display: inline-block; }
.count-badge {
    position: absolute;
    top: -8px;
    right: -10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    box-sizing: border-box;
    border-radius: 999px;
    background: var(--err);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
}

/* Admin tables: inline per-row action forms + dimmed disabled/handled rows. */
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.row-actions form { margin: 0; }
.row-disabled td { opacity: .55; }
.admin-beta .msg-cell { max-width: 360px; white-space: pre-wrap; word-break: break-word; }
.small { font-size: 12px; }

.empty { text-align: center; padding: 56px 0; color: var(--muted); }
.empty .btn { margin-top: 12px; }
.empty-drone { width: 120px; height: auto; margin: 0 auto 20px; color: var(--accent); opacity: .85; }
.empty-drone .rotor { opacity: .7; }

.share-row { display: flex; gap: 10px; align-items: center; }
.share-row input { flex: 1; }

.dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 32px;
    text-align: center;
    color: var(--muted);
    transition: border-color .15s, background .15s;
}
.dropzone.over { border-color: var(--accent); background: rgba(90,160,255,.08); box-shadow: var(--shadow-glow); }
.dropzone .hint { font-size: 13px; margin-top: 8px; }

ul.files { list-style: none; padding: 0; margin: 16px 0 0; }
ul.files li {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 14px;
    padding: 12px 4px;
    border-bottom: 1px solid var(--border);
}
ul.files li .bar { grid-column: 1 / -1; height: 5px; background: var(--panel-2); border-radius: 4px; overflow: hidden; }
ul.files li .bar-fill { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--gold)); box-shadow: 0 0 8px rgba(90,160,255,.6); transition: width .25s var(--ease); }
.fname { font-weight: 600; word-break: break-all; }
.fsize { color: var(--muted); font-size: 14px; }
.fstatus { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.fstatus.pending { background: rgba(152,162,179,.15); color: var(--muted); }
.fstatus.done { background: rgba(46,204,113,.15); color: var(--ok); }
.fstatus.failed { background: rgba(255,93,93,.15); color: var(--err); }

/* --- file gallery --- */
.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
    margin-top: 16px;
}
.tile {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px;
    transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s var(--ease);
}
.tile:hover { transform: translateY(-4px); box-shadow: var(--shadow-2); border-color: rgba(90,160,255,.4); }
.tile.is-cover { border-color: rgba(255,180,84,.5); }
.tile .thumb {
    position: relative;
    aspect-ratio: 4 / 3;
    border-radius: 8px;
    overflow: hidden;
    background: #0c0e12;
    display: flex;
    align-items: center;
    justify-content: center;
}
.tile .thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    opacity: 0;
    transform: scale(1.03);
    transition: opacity .45s var(--ease), transform .6s var(--ease);
}
.tile .thumb img.loaded { opacity: 1; transform: scale(1); }
.tile:hover .thumb img.loaded { transform: scale(1.05); }
.tile .placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: var(--muted);
    text-align: center;
    padding: 8px;
}
.placeholder .ph-ext { font-size: 22px; font-weight: 700; letter-spacing: .03em; color: var(--text); }
.placeholder .ph-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.placeholder.error .ph-ext { color: var(--err); }

/* colored accents per kind */
.thumb.kind-photo .placeholder .ph-label { color: var(--accent); }
.thumb.kind-video .placeholder .ph-label { color: #c08cff; }
.thumb.kind-raw .placeholder .ph-label { color: #ffb24f; }

/* video play badge */
.play-badge {
    position: absolute;
    width: 44px; height: 44px;
    border-radius: 50%;
    background: rgba(0,0,0,.55);
    border: 2px solid rgba(255,255,255,.85);
}
.play-badge::after {
    content: "";
    position: absolute;
    top: 50%; left: 54%;
    transform: translate(-50%, -50%);
    border-style: solid;
    border-width: 9px 0 9px 15px;
    border-color: transparent transparent transparent #fff;
}

/* cover badge (top-left star on the thumbnail) */
.cover-badge {
    position: absolute;
    top: 6px; left: 6px;
    width: 22px; height: 22px;
    border-radius: 50%;
    background: rgba(255,180,0,.92);
    display: flex; align-items: center; justify-content: center;
    font-size: 11px;
    pointer-events: none;
}
.cover-badge::after { content: "★"; color: #fff; }
.tbtn.cover-active { color: #ffb24f; }

/* sleek drone loader — hovers, tilts, and spins its rotors while loading */
.drone-loader {
    width: 56px;
    height: 40px;
    color: var(--accent);
    overflow: visible;
    animation: drone-hover 2.4s var(--ease) infinite;
}
.drone-loader .rotor {
    transform-box: fill-box;
    transform-origin: center;
    animation: rotor-spin .4s linear infinite;
    opacity: .9;
}
.drone-loader .rotor.r2 { animation-duration: .34s; }
/* faint shadow on the ground to sell the hover */
.drone-loader .drone-shadow {
    transform-box: fill-box;
    transform-origin: center;
    animation: drone-shadow 2.4s var(--ease) infinite;
}
@keyframes drone-hover {
    0%, 100% { transform: translateY(0) rotate(-2.5deg); }
    50%      { transform: translateY(-6px) rotate(2.5deg); }
}
@keyframes rotor-spin { to { transform: rotate(360deg); } }
@keyframes drone-shadow {
    0%, 100% { transform: scaleX(1); opacity: .28; }
    50%      { transform: scaleX(.8); opacity: .16; }
}

/* upload progress overlay on the thumb — a glowing "flight path" with a drone marker */
.tile .thumb .bar {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: 6px;
    background-color: rgba(255,255,255,.10);
    background-image: repeating-linear-gradient(90deg, rgba(255,255,255,.35) 0 6px, transparent 6px 14px);
    background-size: 14px 1px;
    background-position: 0 50%;
    background-repeat: repeat-x;
}
.tile .thumb .bar-fill {
    position: relative;
    display: block;
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--accent), var(--gold));
    box-shadow: 0 0 10px rgba(90,160,255,.7);
    transition: width .25s var(--ease);
}
/* the drone riding the leading edge of the fill */
.tile .thumb .bar-fill::after {
    content: "";
    position: absolute;
    right: -5px; top: 50%;
    width: 10px; height: 10px;
    transform: translateY(-50%);
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 8px 2px rgba(255,180,84,.9);
}
/* animated sheen sweeping along the fill */
.tile .thumb .bar-fill::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,.55), transparent);
    background-size: 40% 100%;
    background-repeat: no-repeat;
    animation: sheen 1.4s linear infinite;
}
@keyframes sheen {
    0%   { background-position: -40% 0; }
    100% { background-position: 140% 0; }
}

.tile-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tile-meta .fname { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-meta .fsize { font-size: 12px; }
.btn.block { display: block; text-align: center; }

.tile-exif {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 11px;
    color: var(--muted);
    min-width: 0;
}
.tile-exif .exif-row { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tile-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tile-actions .btn.small { flex: 1; text-align: center; }
.tbtn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    font: inherit;
    font-size: 13px;
    padding: 5px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: border-color .15s var(--ease), background .15s var(--ease), color .15s var(--ease);
}
.tbtn:hover { border-color: var(--accent); }
.tbtn:disabled { opacity: .5; cursor: default; }
.tbtn.danger { color: var(--err); }
.tbtn.danger:hover { border-color: var(--err); background: rgba(255,93,93,.08); }
.tbtn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.tbtn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }

/* inline delete confirm */
.tile-actions.confirming { gap: 6px; }
.confirm-q { flex: 1; font-size: 13px; color: var(--muted); }
.confirm-q.error { color: var(--err); }

/* inline rename editor (replaces the meta row while editing) */
.tile.editing .tile-meta,
.tile.editing .tile-actions { display: none; }
.rename-edit { display: flex; flex-direction: column; gap: 6px; }
.rename-input {
    width: 100%;
    padding: 7px 9px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font: inherit;
    font-size: 13px;
}
.rename-input:focus { outline: none; border-color: var(--accent); }
.rename-input.invalid { border-color: var(--err); }
.rename-actions { display: flex; gap: 6px; }
.rename-actions .tbtn { flex: 1; }

@media (max-width: 520px) {
    .gallery { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
}

/* per-tile metadata info button (top-right of the thumb) */
.info-btn {
    position: absolute;
    top: 8px; right: 8px;
    width: 26px; height: 26px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,.6);
    background: rgba(0,0,0,.5);
    color: #fff;
    font: italic 700 15px/1 Georgia, "Times New Roman", serif;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity .15s, background .15s;
    z-index: 2;
}
.tile:hover .info-btn,
.thumb:focus-within .info-btn,
.info-btn:focus-visible { opacity: 1; }
.info-btn:hover { background: var(--accent); border-color: var(--accent); }
@media (hover: none) { .info-btn { opacity: 1; } }

/* --- clickable thumbnails + full-screen viewer (lightbox) --- */
.thumb[data-viewable] { cursor: zoom-in; }
.thumb[data-viewable]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.thumb.kind-video { cursor: pointer; }
.thumb img { cursor: zoom-in; }

body.lb-open { overflow: hidden; }

/* While a fullscreen overlay (lightbox / metadata) is open, the sticky topbar must not
   paint over it. main.container carries a persistent transform from its entrance
   animation, which traps the overlay inside main's stacking context — so the topbar
   (a body-level sibling with z-index) would otherwise sit on top. Hide it instead. */
body.lb-open .topbar,
body.meta-open .topbar { display: none; }

/* Full-viewport overlay. Longhand offsets (not `inset`) for the widest browser support,
   incl. older iPad/Safari where the `inset` shorthand was being dropped. */
.lightbox {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(6, 9, 16, .88);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    opacity: 0;
    transition: opacity .25s var(--ease);
}
.lightbox.open { opacity: 1; }
.lightbox[hidden] { display: none; }

/* The media fills the space between the side nav buttons; the controls float above it
   so the image/video is always centred regardless of control sizes. */
.lb-stage {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 64px 72px;
    box-sizing: border-box;
}
.lb-stage img,
.lb-stage video {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 6px;
    background: #000;
    box-shadow: 0 24px 60px rgba(0,0,0,.6);
    animation: lb-zoom .3s var(--ease);
}
@keyframes lb-zoom {
    from { opacity: 0; transform: scale(.97); }
    to   { opacity: 1; transform: scale(1); }
}
.lb-note {
    position: absolute;
    bottom: 64px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, .7);
    font-size: 13px;
    margin: 0;
    text-align: center;
}

/* Buffering overlay: centred spinner over the media while it waits for data. */
.lb-buffering {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    color: rgba(255, 255, 255, .85);
    font-size: 13px;
    pointer-events: none;
    opacity: 0;
    transition: opacity .2s var(--ease);
    z-index: 1;
}
.lb-buffering.on { opacity: 1; }
.lb-spinner {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, .25);
    border-top-color: var(--accent);
    animation: rotor-spin .8s linear infinite;
}

.lb-close,
.lb-nav {
    position: absolute;
    background: rgba(255, 255, 255, .12);
    color: #fff;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}
.lb-close:hover,
.lb-nav:hover { background: rgba(255, 255, 255, .25); }
.lb-close {
    top: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    font-size: 26px;
}
.lb-nav {
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    font-size: 32px;
}
.lb-prev { left: 12px; }
.lb-next { right: 12px; }
.lb-download {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1;
}
.lb-info {
    position: absolute;
    top: 16px;
    left: 16px;
    width: 44px;
    height: 44px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .12);
    color: #fff;
    border: none;
    cursor: pointer;
    z-index: 1;
    font: italic 700 24px/1 Georgia, "Times New Roman", serif;
}
.lb-info:hover { background: rgba(255, 255, 255, .25); }
.lb-info[hidden] { display: none; }

/* Tablet: trim the gutters so portrait tablets give the media more room. */
@media (max-width: 900px) {
    .lb-stage { padding: 48px 52px; }
}

/* Phone: shrink controls, give the media nearly the whole screen, and move the nav
   buttons to the bottom corners so they never sit on top of the image. */
@media (max-width: 560px) {
    .lb-stage { padding: 52px 8px 64px; }
    .lb-close { width: 40px; height: 40px; font-size: 24px; top: 10px; right: 10px; }
    .lb-nav { top: auto; bottom: 14px; transform: none; width: 44px; height: 44px; font-size: 28px; }
    .lb-prev { left: 10px; }
    .lb-next { right: 10px; }
    .lb-download { bottom: 18px; }
    .lb-note { bottom: 70px; }
    .lb-info { width: 40px; height: 40px; font-size: 22px; top: 10px; left: 10px; }
}

/* Very small phones: shrink controls + trim padding so portrait media isn't squeezed. */
@media (max-width: 380px) {
    .lb-stage { padding: 46px 6px 56px; }
    .lb-close, .lb-info { width: 36px; height: 36px; font-size: 20px; }
    .lb-nav { width: 40px; height: 40px; font-size: 24px; }
    .lb-download.btn.small { padding: 5px 11px; font-size: 13px; }
}

/* --- per-image metadata panel (opened from the tile or lightbox info button) --- */
body.meta-open { overflow: hidden; }
.meta-modal {
    position: fixed;
    top: 0; right: 0; bottom: 0; left: 0;
    width: 100%;
    height: 100dvh;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    background: rgba(0, 0, 0, .6);
}
.meta-modal[hidden] { display: none; }
.meta-card {
    position: relative;
    width: 100%;
    max-width: 460px;
    max-height: 85vh;
    overflow-y: auto;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 22px 24px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, .5);
}
.meta-close {
    position: absolute;
    top: 12px; right: 12px;
    width: 32px; height: 32px;
    border-radius: 50%;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}
.meta-close:hover { border-color: var(--accent); }
.meta-title {
    margin: 0 36px 16px 0;
    font-size: 16px;
    font-weight: 600;
    word-break: break-word;
}
.meta-group { margin-bottom: 16px; }
.meta-group:last-child { margin-bottom: 0; }
.meta-group h3 {
    margin: 0 0 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--accent);
}
.meta-group dl {
    margin: 0;
    display: grid;
    grid-template-columns: minmax(0, 40%) minmax(0, 60%);
    gap: 4px 12px;
    font-size: 13px;
}
.meta-group dt { color: var(--muted); }
.meta-group dd { margin: 0; word-break: break-word; }
.meta-group dd a { color: var(--accent); }

/* Phones: let the metadata panel use nearly the full width instead of a 460px column. */
@media (max-width: 560px) {
    .meta-modal { padding: 12px; }
    .meta-card { max-width: none; padding: 18px 16px 20px; }
}

/* --- bulk download (share page) ------------------------------------------- */
.bulk-bar { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.btn:disabled,
.btn[disabled] {
    opacity: .45;
    cursor: default;
    transform: none;
    box-shadow: none;
    pointer-events: none;
}

/* Per-tile selection checkbox, shown only in select mode (added by bulk-download.js). */
.bulk-check {
    position: absolute;
    top: 16px; left: 16px;
    width: 24px; height: 24px;
    border-radius: 50%;
    border: 2px solid #fff;
    background: rgba(10, 14, 22, .45);
    box-shadow: 0 1px 4px rgba(0, 0, 0, .5);
    cursor: pointer;
    z-index: 3;
}
.tile { position: relative; }
.bulk-check::after {
    content: "";
    position: absolute;
    top: 5px; left: 8px;
    width: 5px; height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    opacity: 0;
}
.bulk-check[aria-checked="true"] {
    background: var(--accent);
    border-color: var(--accent);
}
.bulk-check[aria-checked="true"]::after { opacity: 1; }

/* In select mode the whole tile is a selection target: suppress the hover-lift and show a
   pointer so it reads like a togglable cell rather than a link. */
.gallery.bulk-select .tile { cursor: pointer; }
.gallery.bulk-select .tile:hover { transform: none; }
.gallery.bulk-select .tile .thumb { cursor: pointer; }
.gallery.bulk-select .tile-actions { display: none; }
.gallery.bulk-select .tile.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

/* Raw-vs-zip choice modal (reuses .meta-modal / .meta-card). */
.bulk-card { max-width: 380px; }
.bulk-sub { margin: 0 0 16px; font-size: 13px; }
.bulk-choices { display: flex; flex-direction: column; gap: 10px; }
.bulk-choices .btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    text-align: left;
    padding: 12px 16px;
}
.bulk-choices .btn small { font-weight: 400; font-size: 12px; opacity: .8; }

/* --- analytics page ------------------------------------------------------- */
.eyebrow { font-size: 13px; color: var(--muted); margin: 0 0 4px; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin: 20px 0;
}
@media (max-width: 640px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
.stat-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.stat-value { font-family: var(--font-display); font-size: 32px; font-weight: 700; line-height: 1; letter-spacing: -.02em; }
.stat-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

.analytics-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.analytics-table th, .analytics-table td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.analytics-table th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.analytics-table tbody tr:last-child td { border-bottom: none; }
.fname-cell { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.date-cell { white-space: nowrap; color: var(--muted); font-size: 12px; }
.mono { font-family: monospace; font-size: 12px; }
/* Scroll-wraps wide tables so they can never widen the page; rounded frame softens the box. */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); }

.event-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}
.event-badge.event-drop_view  { background: rgba(79,140,255,.15); color: var(--accent); }
.event-badge.event-file_view  { background: rgba(192,140,255,.15); color: #c08cff; }
.event-badge.event-file_download { background: rgba(46,204,113,.15); color: var(--ok); }

/* --- page entrance: a gentle fade/slide-up of the main content on load ----- */
main.container { animation: fade-up .5s var(--ease) both; }
@keyframes fade-up {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* --- respect reduced-motion: kill all decorative animation + transitions --- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
        scroll-behavior: auto !important;
    }
    .tile .thumb img { opacity: 1; transform: none; }
}
