:root {
  color-scheme: light dark;
  --bg: #f6f6f4;
  --panel: #ffffff;
  --line: #e2e1dd;
  --ink: #1b1b19;
  --muted: #6d6c66;
  --accent: #2f6fd0;
  --accent-ink: #ffffff;
  --danger: #b23a2e;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 8px 24px rgba(0, 0, 0, .05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17171a;
    --panel: #1f1f23;
    --line: #33333a;
    --ink: #ececeb;
    --muted: #9a9a96;
    --accent: #6ea8fe;
    --accent-ink: #10131a;
    --danger: #ef7b6d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 20px 72px;
}

header.bar {
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

header.bar .wrap {
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  font-weight: 650;
  letter-spacing: -.01em;
  text-decoration: none;
  color: var(--ink);
}

.spacer { flex: 1; }

h1 {
  font-size: 26px;
  letter-spacing: -.02em;
  margin: 0 0 6px;
}

h2 {
  font-size: 17px;
  margin: 32px 0 12px;
}

.muted { color: var(--muted); }
.small { font-size: 13px; }

button, .btn {
  font: inherit;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

button:hover, .btn:hover { border-color: var(--muted); }
button:disabled { opacity: .5; cursor: default; }

.btn-primary, button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 550;
}

.btn-danger { color: var(--danger); }

input[type="text"], input[type="password"] {
  font: inherit;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  width: 100%;
}

input:focus, button:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.row { display: flex; gap: 10px; align-items: center; }
.stack > * + * { margin-top: 12px; }

.notice {
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
}
.notice.err { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.notice.ok  { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); }

/* photo grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.tile {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 1;
}

.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  cursor: zoom-in;
  background: var(--bg);
}

.tile .noprev {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 12px;
  font-size: 12px;
  color: var(--muted);
  word-break: break-all;
}

.tile figcaption {
  position: absolute;
  inset: auto 0 0 0;
  padding: 20px 8px 6px;
  font-size: 11px;
  color: #fff;
  background: linear-gradient(transparent, rgba(0, 0, 0, .72));
  display: flex;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
}

.tile figcaption span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tile .acts {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity .12s;
}

.tile:hover .acts, .tile:focus-within .acts { opacity: 1; }

/* Touch devices never hover, so the download button must always be visible. */
@media (hover: none) {
  .tile .acts { opacity: 1; }
}

.tile .acts a, .tile .acts button {
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 6px;
  background: rgba(255, 255, 255, .94);
  color: #1b1b19;
  border: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
}

/* lightbox */
dialog.lightbox {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: 100vw;
  max-height: 100vh;
  width: 100%;
  height: 100%;
}
dialog.lightbox::backdrop { background: rgba(0, 0, 0, .9); }

dialog.lightbox .lb {
  height: 100%;
  display: grid;
  grid-template-rows: 1fr auto;
}

dialog.lightbox img {
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  margin: auto;
  display: block;
}

dialog.lightbox .lbbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  color: #fff;
  font-size: 13px;
  background: rgba(0, 0, 0, .5);
}

dialog.lightbox .lbbar .spacer {
  flex: 1 1 100px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

dialog.lightbox .lbbar .btn { background: rgba(255, 255, 255, .95); color: #1b1b19; border: 0; }

/* upload list */
.uplist { list-style: none; margin: 12px 0 0; padding: 0; font-size: 13px; }
.uplist li { display: flex; align-items: center; gap: 10px; padding: 5px 0; border-top: 1px solid var(--line); }
.uplist .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uplist progress { width: 110px; height: 6px; }

.drop {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 34px 18px;
  text-align: center;
  color: var(--muted);
  background: var(--panel);
}
.drop.hot { border-color: var(--accent); color: var(--accent); }

table.albums { width: 100%; border-collapse: collapse; }
table.albums td, table.albums th { text-align: left; padding: 10px 8px; border-top: 1px solid var(--line); vertical-align: middle; }
table.albums th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border-top: 0; }
table.albums td.acts { text-align: right; white-space: nowrap; }

code.link {
  font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 6px;
  word-break: break-all;
}

@media (max-width: 640px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  table.albums thead { display: none; }
  table.albums tr { display: block; border-top: 1px solid var(--line); padding: 10px 0; }
  table.albums td { display: block; border: 0; padding: 3px 0; }
  table.albums td.acts { text-align: left; padding-top: 8px; }
}
