:root {
  --bg: #f7f8fa;
  --panel: #ffffff;
  --text: #1e2430;
  --muted: #6b7484;
  --line: #e4e7ec;
  --accent: #0061fe;
  --accent-hover: #0050d4;
  --danger: #d92d20;
  --radius: 10px;
  --shadow: 0 8px 30px rgba(16, 24, 40, .12);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c; --panel: #1c2027; --text: #e7eaf0; --muted: #9aa3b2;
    --line: #2b313b; --accent: #4c8dff; --accent-hover: #6ea3ff; --shadow: 0 8px 30px rgba(0,0,0,.5);
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
button, .button { font: inherit; border: 1px solid transparent; border-radius: 8px; padding: 8px 14px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.primary { background: var(--accent); color: #fff; }
.primary:hover { background: var(--accent-hover); }
.secondary { background: var(--panel); color: var(--text); border-color: var(--line); }
.secondary:hover { border-color: var(--muted); }
.ghost { background: transparent; color: var(--text); }
.ghost:hover { background: var(--line); }
.icon { background: transparent; color: var(--muted); padding: 4px 8px; }
.icon:hover { background: var(--line); color: var(--text); }
.muted { color: var(--muted); }
.error { color: var(--danger); margin: 8px 0 0; }

.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 20px; padding: 14px 24px; background: #000; border-bottom: 1px solid #222; }
.brand { display: flex; align-items: center; flex-shrink: 0; }
.brand img { height: 66px; width: auto; display: block; }
#lockBtn { margin-left: auto; white-space: nowrap; color: #ddd; }
#lockBtn:hover { background: #222; }
#lockBtn.unlocked { color: #3ddc84; }

main { max-width: 1100px; margin: 0 auto; padding: 20px 24px 80px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 18px; font-weight: 600; }
.crumbs a { color: var(--text); text-decoration: none; padding: 2px 6px; border-radius: 6px; }
.crumbs a:hover { background: var(--line); }
.crumbs .sep { color: var(--muted); }
.actions { display: flex; gap: 8px; }

.listing { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.listing:empty { display: none; }
.row { display: grid; grid-template-columns: 84px 1fr 110px 170px 40px; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--bg); }
.row .ico { font-size: 22px; text-align: center; display: flex; align-items: center; justify-content: center; height: 72px; }
.row .ico .thumb { width: 80px; height: 72px; object-fit: contain; border-radius: 6px; background: var(--line); display: block; }
.pdf-wrap { display: contents; }
.row .ico canvas.thumb { object-fit: contain; background: #fff; }
.row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .size, .row .date { color: var(--muted); font-size: 13px; }
.row.head { cursor: default; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--bg); }
.row.head span { cursor: pointer; user-select: none; }

.listing.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; padding: 12px; background: transparent; border: 0; }
.listing.grid .row.head { display: none; }
.listing.grid .row { position: relative; grid-template-columns: 1fr; text-align: center; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); padding: 12px; }
.listing.grid .row .ico { font-size: 56px; height: 190px; }
.listing.grid .row .ico .thumb { width: 100%; height: 190px; }
.listing.grid .row .size, .listing.grid .row .date { display: none; }
.listing.grid .row .more { position: absolute; top: 4px; right: 4px; z-index: 1; background: var(--panel); border: 1px solid var(--line); }

.empty { text-align: center; padding: 60px 0; font-size: 17px; }

.drop-overlay { position: fixed; inset: 0; z-index: 20; background: rgba(0, 97, 254, .12); border: 3px dashed var(--accent); display: flex; align-items: center; justify-content: center; pointer-events: none; }
.drop-overlay div { background: var(--panel); padding: 18px 28px; border-radius: var(--radius); box-shadow: var(--shadow); font-size: 18px; font-weight: 600; }

.uploads { position: fixed; right: 20px; bottom: 20px; width: 340px; max-height: 50vh; overflow: auto; z-index: 15; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.uploads header { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.uploads ul { list-style: none; margin: 0; padding: 6px 14px 12px; }
.uploads li { padding: 6px 0; font-size: 13px; }
.uploads .uname { display: flex; justify-content: space-between; gap: 8px; }
.uploads .uname span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { height: 5px; background: var(--line); border-radius: 3px; margin-top: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s; }
.uploads li.done .bar i { background: #12a150; }
.uploads li.failed .bar i { background: var(--danger); width: 100% !important; }

dialog { border: 0; border-radius: 14px; padding: 0; background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(10, 14, 22, .5); }
#dialog form { padding: 22px 24px; width: min(420px, 90vw); }
#dialog h2 { margin: 0 0 6px; font-size: 19px; }
#dialog p { margin: 0 0 12px; color: var(--muted); }
#dialogInput { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: var(--bg); color: var(--text); }
.dialog-buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.danger-btn { background: var(--danger); color: #fff; }

.preview { width: min(1000px, 95vw); height: min(800px, 90vh); }
.preview[open] { display: flex; flex-direction: column; }
.preview header { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.preview header strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview header div { display: flex; gap: 6px; }
.preview-body { flex: 1; overflow: auto; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.preview-body img, .preview-body video { max-width: 100%; max-height: 100%; }
.preview-body iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.preview-body pre { align-self: stretch; width: 100%; margin: 0; padding: 16px; white-space: pre-wrap; word-break: break-word; font: 13px/1.5 ui-monospace, Consolas, monospace; }
.preview-body .nopreview { text-align: center; color: var(--muted); }

.menu { position: fixed; z-index: 30; min-width: 170px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 6px; display: flex; flex-direction: column; }
.menu[hidden] { display: none; }
.menu button { background: transparent; color: var(--text); justify-content: flex-start; padding: 8px 10px; }
.menu button:hover { background: var(--bg); }
.menu .danger { color: var(--danger); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 40; background: #1e2430; color: #fff; padding: 10px 18px; border-radius: 8px; box-shadow: var(--shadow); }
.toast.err { background: var(--danger); }

@media (max-width: 700px) {
  .topbar { padding: 10px 12px; gap: 8px; }
  .brand img { height: 42px; max-width: calc(100vw - 90px); object-fit: contain; }
  main { padding: 14px 12px 80px; }
  .row { grid-template-columns: 72px 1fr 40px; }
  .row .ico { height: 60px; }
  .row .ico .thumb { width: 68px; height: 60px; }
  .listing.grid { grid-template-columns: repeat(2, 1fr); }
  .listing.grid .row .ico, .listing.grid .row .ico .thumb { height: 150px; }
  .row .size, .row .date, .row.head span:nth-child(3), .row.head span:nth-child(4) { display: none; }
  #lockBtn { padding: 8px; }
  #lockBtn .lbl { display: none; }
  .actions button { padding: 8px 10px; }
  .uploads { left: 12px; right: 12px; width: auto; }
}

/* Photo viewer arrows */
.preview { position: fixed; }
.nav { position: absolute; top: 50%; transform: translateY(-50%); width: 52px; height: 52px; padding: 0; justify-content: center; border-radius: 50%; background: rgba(0, 0, 0, .55); color: #fff; font-size: 34px; line-height: 1; z-index: 2; }
.nav:hover { background: rgba(0, 0, 0, .8); }
.nav.prev { left: 14px; }
.nav.next { right: 14px; }
@media (max-width: 700px) { .nav { width: 42px; height: 42px; font-size: 28px; } .nav.prev { left: 6px; } .nav.next { right: 6px; } }

/* Quick download arrow on photo thumbnails */
.row .ico { position: relative; }
.dl { position: absolute; top: 4px; left: 4px; z-index: 1; width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: rgba(0, 0, 0, .6); color: #fff; font-size: 14px; text-decoration: none; line-height: 1; }
.dl:hover { background: var(--accent); }
.listing.grid .dl { top: 6px; left: 6px; width: 36px; height: 36px; font-size: 18px; }
@media (max-width: 700px) { .listing.grid .dl { width: 34px; height: 34px; } }
button.dl { border: 0; padding: 0; cursor: pointer; font: inherit; }

/* Text logo, for sites without a logo image (e.g. Joshbox) */
.brand-text { color: #fff; font-weight: 800; font-size: 44px; line-height: 66px; letter-spacing: .08em; text-transform: uppercase; text-decoration: none; white-space: nowrap; }
@media (max-width: 700px) { .brand-text { font-size: 28px; line-height: 42px; } }
.brand { text-decoration: none; }
