/* Wakil Gallery — a terminal window full of pictures.
   Tokyo Night after dark, Tokyo Day in the light. Same family as Books, Flicks and BBS. */

:root, [data-theme="dark"] {
  --bg: #16161e;
  --win: #1a1b26;
  --bar: #1f2335;
  --hl: #292e42;
  --line: #2f334d;
  --text: #c0caf5;
  --muted: #a9b1d6;
  --faint: #565f89;
  --blue: #7aa2f7;
  --cyan: #7dcfff;
  --green: #9ece6a;
  --yellow: #e0af68;
  --orange: #ff9e64;
  --red: #f7768e;
  --magenta: #bb9af7;
  --shadow: 0 20px 60px rgba(0, 0, 0, .45);
  --mono: "JetBrains Mono", "Iosevka", "Fira Code", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #d0d5e3; --win: #e1e2e7; --bar: #d5d6db; --hl: #c4c8da; --line: #b9bdd2;
    --text: #3760bf; --muted: #4c5a8a; --faint: #848cb5;
    --blue: #2e7de9; --cyan: #007197; --green: #587539; --yellow: #8c6c3e;
    --orange: #b15c00; --red: #f52a65; --magenta: #9854f1;
    --shadow: 0 20px 50px rgba(55, 96, 191, .18);
    color-scheme: light;
  }
}
[data-theme="light"] {
  --bg: #d0d5e3; --win: #e1e2e7; --bar: #d5d6db; --hl: #c4c8da; --line: #b9bdd2;
  --text: #3760bf; --muted: #4c5a8a; --faint: #848cb5;
  --blue: #2e7de9; --cyan: #007197; --green: #587539; --yellow: #8c6c3e;
  --orange: #b15c00; --red: #f52a65; --magenta: #9854f1;
  --shadow: 0 20px 50px rgba(55, 96, 191, .18);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; padding: 28px 16px; color: var(--text); font: 13.5px/1.6 var(--mono); }
a { color: var(--blue); text-decoration: none; }
a, button, label, summary, select { touch-action: manipulation; }  /* no double-tap-zoom delay on controls */
a:hover { color: var(--cyan); }
img { display: block; }
.c-blue { color: var(--blue); } .c-green { color: var(--green); } .c-yellow { color: var(--yellow); }
.c-red { color: var(--red); } .c-cyan { color: var(--cyan); } .c-magenta { color: var(--magenta); }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: 11.5px; }
.err { color: var(--red); }

/* ---------------------------------------------------------------- window */
.win { max-width: 1280px; margin: 0 auto; background: var(--win); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: var(--shadow); overflow: hidden; }
.titlebar { display: flex; align-items: center; gap: 14px; padding: 10px 14px; background: var(--bar);
  border-bottom: 1px solid var(--line); }
.dots { display: flex; gap: 7px; }
.dots i { width: 12px; height: 12px; border-radius: 50%; background: var(--red); }
.dots i:nth-child(2) { background: var(--yellow); }
.dots i:nth-child(3) { background: var(--green); }
.title { flex: 1; text-align: center; color: var(--muted); font-size: 12.5px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.theme-btn { background: none; border: 0; color: var(--faint); font: 15px var(--mono); cursor: pointer; padding: 0 4px; }
.theme-btn:hover { color: var(--yellow); }

.tabs { display: flex; align-items: stretch; border-bottom: 1px solid var(--line); padding: 0 8px;
  overflow-x: auto; }
.tabs a, .tab-btn { padding: 8px 14px; color: var(--muted); font: 12.5px var(--mono);
  border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a:hover, .tab-btn:hover { color: var(--text); }
.tabs a.on { color: var(--text); border-bottom-color: var(--blue); }
.tab-right { margin-left: auto; }
.tab-btn { background: none; border: 0; border-bottom: 2px solid transparent; cursor: pointer; }
.tab-btn:hover { color: var(--red); }

.body { padding: 26px 28px 34px; min-height: 50vh; }
.foot { display: flex; justify-content: space-between; align-items: center; padding: 10px 18px;
  border-top: 1px solid var(--line); background: var(--bar); font-size: 11.5px; }
.ar { font: 17px/1 "Amiri", "Noto Naskh Arabic", "Scheherazade New", serif; color: var(--yellow); }

/* ---------------------------------------------------------------- type & bits */
.h { font-size: 13px; font-weight: 500; letter-spacing: .04em; margin: 0 0 14px;
  display: flex; align-items: baseline; gap: 10px; }
.h::before { content: "▍"; color: currentColor; opacity: .8; }
.h .meta { margin-left: 2px; }
* + .h { margin-top: 32px; }
.meta { color: var(--faint); font-size: 12px; }
.crumbs { color: var(--faint); font-size: 12px; margin-bottom: 12px; }
.crumbs a { color: var(--faint); } .crumbs a:hover { color: var(--text); }
.empty { padding: 40px 0; text-align: center; }
.motd { margin: 0 0 20px; padding: 14px 18px; border: 1px dashed var(--line); border-radius: 4px;
  font: 13px/1.7 var(--mono); white-space: pre-wrap; }

.flash { margin: 0 0 18px; padding: 8px 12px; border-left: 3px solid var(--green);
  background: color-mix(in srgb, var(--green) 8%, transparent); }
.flash-err { border-color: var(--red); background: color-mix(in srgb, var(--red) 8%, transparent); }

.pill { display: inline-block; padding: 0 7px; border: 1px solid currentColor; border-radius: 3px;
  font-size: 10.5px; line-height: 17px; text-transform: lowercase; vertical-align: 1px; }
.pill-public, .pill-ready { color: var(--green); }
.pill-unlisted, .pill-pending, .pill-processing { color: var(--yellow); }
.pill-private, .pill-failed { color: var(--red); }
.pill-lock { color: var(--magenta); }

.btn { display: inline-block; padding: 6px 14px; border: 1px solid var(--line); border-radius: 4px;
  background: var(--hl); color: var(--text); font: 12.5px var(--mono); cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--blue); color: var(--text); }
.btn.on { border-color: var(--blue); color: var(--blue); }
.btn-go { background: color-mix(in srgb, var(--green) 18%, var(--hl)); border-color: color-mix(in srgb, var(--green) 50%, var(--line)); }
.btn-go:hover { border-color: var(--green); }
.btn-danger { color: var(--red); }
.btn-danger:hover { border-color: var(--red); }
.btn-small { padding: 3px 10px; font-size: 12px; }
.linkish { background: none; border: 0; padding: 0; color: var(--blue); font: inherit; cursor: pointer; }
.linkish:hover { color: var(--cyan); }
.linkish:disabled { color: var(--faint); opacity: .4; cursor: default; }
.linkish.danger { color: var(--red); }
.inline { display: inline; }

/* ---------------------------------------------------------------- forms */
.form { display: grid; gap: 16px; max-width: 640px; }
.form.narrow { max-width: 340px; }
.form label { display: grid; gap: 5px; color: var(--muted); font-size: 12.5px; }
input, textarea, select { width: 100%; padding: 7px 10px; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 4px; font: 13px var(--mono); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--blue); }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--blue); }
.prefix-input { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 4px;
  background: var(--bg); padding-left: 10px; font-size: 12.5px; }
.prefix-input input { border: 0; padding-left: 2px; }
fieldset { border: 1px solid var(--line); border-radius: 4px; padding: 10px 14px 12px; margin: 0; display: grid; gap: 6px; }
legend { color: var(--muted); font-size: 12.5px; padding: 0 6px; }
.form .radio { display: flex; gap: 10px; align-items: baseline; color: var(--muted); }
.radio b { font-weight: 500; display: inline-block; min-width: 72px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row .grow { flex: 1 1 240px; width: auto; }
code.share { padding: 5px 10px; background: var(--bg); border: 1px solid var(--line); border-radius: 4px;
  font-size: 12px; color: var(--cyan); word-break: break-all; }

/* ---------------------------------------------------------------- album index */
.albums { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 22px; }
.album-card { min-width: 0; }
.cover { display: block; aspect-ratio: 4 / 3; border: 1px solid var(--line); border-radius: 6px;
  overflow: hidden; background: var(--bar); position: relative; }
.cover img { width: 100%; height: 100%; object-fit: cover; transition: transform .35s ease, filter .35s; filter: saturate(.92); }
.cover:hover img { transform: scale(1.04); filter: none; }
.cover:hover { border-color: var(--blue); }
.cover-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--faint); font-size: 12px; }
.album-info { padding: 9px 2px 0; }
.album-title { color: var(--text); font-weight: 500; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.album-title:hover { color: var(--blue); }
.album-admin { margin-top: 4px; display: flex; gap: 10px; align-items: center; font-size: 12px; }

/* ---------------------------------------------------------------- album page */
.album-head { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; margin-bottom: 20px; flex-wrap: wrap; }
.album-h1 { margin: 0; font-size: 20px; font-weight: 500; }
.album-h1::before { content: "❯ "; color: var(--green); }
.album-desc { margin: 8px 0 0; color: var(--muted); max-width: 70ch; white-space: pre-line; }
.album-tools { display: flex; gap: 8px; flex-wrap: wrap; }

/* justified rows: each tile grows in proportion to its aspect ratio (--r = w/h) */
.grid { --row: 230px; display: flex; flex-wrap: wrap; gap: 6px; }
.grid::after { content: ""; flex-grow: 999999; }
.tile { position: relative; display: block; flex-grow: calc(var(--r) * 100);
  width: calc(var(--r) * var(--row)); max-width: 100%; background: var(--bar); overflow: hidden;
  border-radius: 3px; cursor: zoom-in; }
.tile > i { display: block; padding-bottom: calc(100% / var(--r)); }
.tile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform .3s ease, opacity .3s; }
.tile:hover img { transform: scale(1.03); }
.tile:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.badge { position: absolute; right: 6px; bottom: 6px; padding: 1px 7px; border-radius: 3px;
  background: rgba(22, 22, 30, .78); color: #c0caf5; font-size: 11px; }
.badge-l { left: 6px; right: auto; top: 6px; bottom: auto; color: #e0af68; }
.managing .tile { cursor: pointer; }
.managing .tile input { position: absolute; top: 8px; right: 8px; z-index: 2; width: 18px; height: 18px; }
.managing .tile:has(input:checked) { outline: 3px solid var(--blue); outline-offset: -3px; }
.managing .tile:has(input:checked) img { opacity: .7; }

.actionbar { position: sticky; top: 0; z-index: 5; display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding: 10px 12px; margin-bottom: 12px; background: var(--bar); border: 1px solid var(--line); border-radius: 4px; }
.actionbar select { width: auto; padding: 3px 8px; font-size: 12px; }
.actionbar .grow { flex: 1; }
.check { display: flex; gap: 6px; align-items: center; cursor: pointer; }

/* uploader */
.drop { margin: 0 0 26px; padding: 18px 20px; border: 1px dashed var(--line); border-radius: 6px;
  background: color-mix(in srgb, var(--blue) 3%, transparent); transition: border-color .15s, background .15s; }
.drop p { margin: 0 0 2px; }
.drop.over { border-color: var(--green); background: color-mix(in srgb, var(--green) 8%, transparent); }
.drop input[type=file] { display: none; }
.drop-touch { display: none; }
.btn-big { padding: 12px 20px; font-size: 14px; }
@media (hover: none) and (pointer: coarse) {
  .drop-desk { display: none; }
  .drop-touch { display: block; margin-bottom: 8px; }
  .drop-touch .btn { display: block; text-align: center; }
}
.queue { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 4px; font-size: 12px; }
.queue:empty { display: none; }
.queue li { display: grid; grid-template-columns: minmax(0, 1fr) 160px 90px; gap: 12px; align-items: center; }
.queue .qname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue .bar { height: 6px; background: var(--hl); border-radius: 3px; overflow: hidden; }
.queue .bar b { display: block; height: 100%; width: 0; background: var(--blue); transition: width .2s; }
.queue .done .bar b { background: var(--green); }
.queue .fail .bar b { background: var(--red); width: 100%; }
.queue .qstate { text-align: right; color: var(--faint); }
.queue .done .qstate { color: var(--green); } .queue .fail .qstate { color: var(--red); }
.queue .qerr { grid-column: 1 / -1; color: var(--red); margin-top: -2px; }

.pending { margin-bottom: 26px; }
.pending-list { list-style: none; padding: 0; margin: 0 0 10px; display: grid; gap: 4px; font-size: 12.5px; }

/* ---------------------------------------------------------------- lightbox */
.lb { position: fixed; inset: 0; height: 100vh; height: 100dvh; z-index: 100; display: flex; flex-direction: column;
  background: color-mix(in srgb, #0f0f14 94%, transparent); color: #c0caf5;
  animation: lb-in .16s ease-out; backdrop-filter: blur(6px); }
.lb[hidden] { display: none; }
@keyframes lb-in { from { opacity: 0; } }
.lb-bar { position: relative; z-index: 3; display: flex; align-items: center; gap: 14px; padding: 9px 14px;
  padding-top: max(9px, env(safe-area-inset-top)); padding-left: max(14px, env(safe-area-inset-left));
  padding-right: max(14px, env(safe-area-inset-right)); background: #1f2335;
  border-bottom: 1px solid #2f334d; font-size: 12.5px; }
.lb-path { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-path .c-green { color: #9ece6a; }
.lb-count { color: #565f89; }
.lb-btn { background: none; border: 1px solid #2f334d; border-radius: 4px; color: #a9b1d6; padding: 3px 10px;
  font: 12px var(--mono); cursor: pointer; }
.lb-btn:hover { border-color: #7aa2f7; color: #c0caf5; }
.lb-stage { flex: 1; position: relative; display: flex; align-items: center; justify-content: center; min-height: 0;
  overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
.lb-media { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; padding: 18px 64px; }
.lb-media img, .lb-media video { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 2px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .5); background: #16161e; }
.lb-media img { transition: opacity .2s; cursor: zoom-in; will-change: transform; transform-origin: center center;
  -webkit-touch-callout: default; }
.lb.zoomed .lb-media img { cursor: grab; box-shadow: none; }
.lb.zoomed .lb-media img:active { cursor: grabbing; }
.lb.zoomed .lb-nav { opacity: .25; }
.lb-media img.loading { opacity: .25; }
.lb-nav { position: absolute; z-index: 2; top: 50%; transform: translateY(-50%); width: 48px; height: 72px; border: 0;
  background: transparent; color: #565f89; font: 44px/1 var(--mono); cursor: pointer; z-index: 2; }
.lb-nav:hover { color: #7aa2f7; }
.lb-prev { left: 6px; } .lb-next { right: 6px; }
.lb-info { position: relative; z-index: 3; display: flex; gap: 16px; align-items: baseline; justify-content: center;
  padding: 8px 16px 14px; padding-bottom: max(14px, env(safe-area-inset-bottom));
  font-size: 12.5px; min-height: 38px; flex-wrap: wrap; text-align: center; }
.lb-caption { color: #c0caf5; }
.lb-info .meta { color: #565f89; }
.lb-info .linkish { color: #7aa2f7; }
.lb-spin { position: absolute; color: #565f89; font-size: 12px; }

/* ---------------------------------------------------------------- tables */
.table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-bottom: 12px; }
.table th { text-align: left; font-weight: 400; color: var(--faint); padding: 6px 10px 6px 0; border-bottom: 1px solid var(--line); }
.table td { padding: 7px 10px 7px 0; border-bottom: 1px dashed color-mix(in srgb, var(--line) 70%, transparent); vertical-align: middle; }
.table tfoot td { border-bottom: 0; color: var(--muted); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-col { width: 28%; }
.hbar { display: block; height: 8px; background: var(--hl); border-radius: 2px; overflow: hidden; }
.hbar b { display: block; height: 100%; background: var(--blue); }
.df { line-height: 1.75; }
.meter b { font-weight: 400; }

/* ---------------------------------------------------------------- share + upload links */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 2px 18px; font-size: 12.5px; }
.share-settings { margin-top: 16px; max-width: 720px; gap: 12px; }
.form .inline-label { display: grid; gap: 5px; }
.inline-label select { width: auto; }
.new-link { margin-top: 6px; }
.new-link select { width: auto; }
.narrow-num { width: 90px; }
.form .check { display: flex; flex-direction: row; gap: 8px; }

/* ---------------------------------------------------------------- review, trash, uploads */
.review { margin-bottom: 30px; }
.badge-bl { left: 6px; right: auto; max-width: calc(100% - 60px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.review-badge { color: #bb9af7; }
.tile-name { position: absolute; inset: 0; display: grid; place-items: center; padding: 8px; color: var(--faint);
  font-size: 11px; text-align: center; word-break: break-all; }
.queue .dup .bar b { background: var(--yellow); }
.queue .dup .qstate, .queue .dup .qerr { color: var(--yellow); }
.guest-name { margin: 18px 0 14px; }
#guest-done { margin-top: -10px; }

/* ---------------------------------------------------------------- slideshow */
.lb-icon { padding: 3px 8px; }
.lb-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; }
.lb-progress b { display: block; height: 100%; width: 0; background: #7aa2f7; opacity: .8; }
.lb .lb-bar, .lb .lb-info, .lb .lb-nav { transition: opacity .4s; }
.lb.idle { cursor: none; }
.lb.idle .lb-bar, .lb.idle .lb-info, .lb.idle .lb-nav { opacity: 0; }
.lb:fullscreen { background: #000; }
.lb:fullscreen .lb-media { padding: 6px 0; }
.lb:fullscreen .lb-media img, .lb:fullscreen .lb-media video { box-shadow: none; }

/* ---------------------------------------------------------------- small screens */
@media (max-width: 700px) {
  body { padding: 0; }
  .win { border-radius: 0; border-left: 0; border-right: 0; min-height: 100vh; }
  .body { padding: 18px 14px 26px; }
  .grid { --row: 130px; gap: 4px; }
  .albums { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  .lb-media { padding: 0; }
  .lb-nav { display: none; }
  .lb-btn { padding: 7px 11px; font-size: 14px; }
  .lb-btn .lbl { display: none; }
  .lb-path { display: none; }
  .queue li { grid-template-columns: minmax(0, 1fr) 80px 70px; }
  .lb-bar { gap: 6px; padding: 6px 8px; padding-top: max(6px, env(safe-area-inset-top)); }
  .lb-count { flex: 1; font-size: 13px; padding-left: 4px; }
  #lb-fs { display: none; }
  .lb-info { flex-direction: column; align-items: center; gap: 2px; font-size: 12px; }
  .album-tools { width: 100%; }
  .album-tools .btn { flex: 1 1 auto; text-align: center; padding: 7px 10px; }
  .actionbar .btn { padding: 6px 10px; }
  .managing .tile input { width: 22px; height: 22px; }
  .bar-col { display: none; }
  .tabs { padding: 0 4px; }
  .tabs a, .tab-btn { padding: 9px 8px; }
  .wide-only { display: none; }
  .actionbar .grow { flex-basis: 100%; height: 0; }
  .table th:nth-child(4), .storage-table td:nth-child(4) { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
