:root {
  color-scheme: dark;
  --bg: #0e0f12;
  --surface: #17191e;
  --surface-2: #22252c;
  --line: #2e323a;
  --text: #f1f0ec;
  --muted: #a3a6ad;
  --accent: #f2b84b;
  --accent-ink: #1c1505;
  --danger: #ff7a70;
  --discord: #5865f2;
  --row-h: 230px;
  --serif: ui-serif, "Iowan Old Style", Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 16px/1.5 var(--sans); min-height: 100dvh; }
a { color: inherit; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.15; margin: 0; }
h1 { font-size: clamp(1.9rem, 4vw, 2.8rem); }
main { padding: 0 clamp(16px, 3vw, 40px) 64px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px clamp(16px, 3vw, 40px); }
.brand { font: 600 1.25rem var(--serif); text-decoration: none; }
.topbar-nav { display: flex; align-items: center; gap: 18px; font-size: .92rem; color: var(--muted); }
.topbar-nav a { text-decoration: none; }
.topbar-nav a:hover { color: var(--text); }
.person { display: inline-flex; align-items: center; gap: 8px; }
.person img { border-radius: 50%; }
@media (max-width: 560px) { .person span { display: none; } }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; padding: 22px 0 24px; }
.head-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.meta { color: var(--muted); font-size: .88rem; margin: 4px 0 0; }
.description { max-width: 62ch; margin: 10px 0 0; }
.hint { color: var(--muted); font-size: .85rem; margin: 6px 0 12px; }
.notice { color: var(--accent); }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 0 18px; border: 0; border-radius: 8px; background: var(--accent); color: var(--accent-ink); font: 600 .95rem var(--sans); text-decoration: none; cursor: pointer; }
.button:hover { filter: brightness(1.08); }
.button-quiet { background: var(--surface-2); color: var(--text); }
.button-danger { background: transparent; color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger); }
.button-discord { background: var(--discord); color: #fff; }
.link-button { background: none; border: 0; padding: 0; color: var(--muted); font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.link-button:hover { color: var(--text); }

.login { min-height: 90dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 14px; }
.login h1 { font-size: clamp(3rem, 9vw, 5.5rem); }
.login p { color: var(--muted); margin: 0 0 12px; max-width: 42ch; }

.album-grid { display: grid; gap: 28px 22px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.album-card { text-decoration: none; display: block; }
.album-cover { position: relative; aspect-ratio: 3 / 2; border-radius: 10px; overflow: hidden; background: var(--surface); margin-bottom: 12px; }
.album-cover img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .4s ease; }
.album-card:hover .album-cover img { transform: scale(1.03); }
.album-cover .badge { position: absolute; top: 10px; right: 10px; }
.album-card h2 { font-size: 1.25rem; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 6px; background: var(--accent); color: var(--accent-ink); font: 700 .75rem var(--sans); font-variant-numeric: tabular-nums; }
.badge-dark { background: rgb(0 0 0 / .72); color: #fff; }

.tiles { display: flex; flex-wrap: wrap; gap: 6px; }
.tiles::after { content: ""; flex-grow: 9999; }
.tile { position: relative; flex-grow: var(--r); flex-basis: calc(var(--r) * var(--row-h)); max-width: calc(var(--r) * var(--row-h) * 1.6); aspect-ratio: var(--r); background: var(--surface); border-radius: 4px; overflow: hidden; display: block; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; transition: opacity .2s; }
.tile:hover img { opacity: .86; }
.tile-badges { position: absolute; left: 8px; bottom: 8px; display: flex; gap: 6px; }
.tile-placeholder { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 12px; color: var(--muted); font-size: .85rem; overflow-wrap: anywhere; }
@media (max-width: 640px) { :root { --row-h: 130px; } .tiles { gap: 3px; } }

.empty { text-align: center; padding: 72px 16px; color: var(--muted); border: 1px dashed var(--line); border-radius: 12px; }
.empty h2 { color: var(--text); margin-bottom: 8px; }
.empty.is-over, .tiles.is-over { outline: 2px dashed var(--accent); outline-offset: 6px; }

.dropzone { background: var(--surface); border-radius: 10px; padding: 12px 16px; margin-bottom: 22px; }
.upload-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.upload-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; font-size: .88rem; }
.upload-list .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-list .state { color: var(--muted); font-variant-numeric: tabular-nums; }
.upload-list .state.error { color: var(--danger); }
.upload-list progress { grid-column: 1 / -1; width: 100%; height: 4px; accent-color: var(--accent); }

.panel { width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 24px; }
.panel::backdrop { background: rgb(0 0 0 / .65); }
.panel h3 { margin: 22px 0 0; font-size: 1.05rem; }
.panel label { display: block; margin-top: 14px; font-size: .9rem; color: var(--muted); }
.panel input:not([type=checkbox]), .panel textarea, .panel select { display: block; width: 100%; margin-top: 5px; min-height: 42px; padding: 8px 10px; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; font: inherit; }
.panel-actions { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
form .panel-actions { justify-content: flex-end; }
.pick-list, .share-list { list-style: none; margin: 0; padding: 0; }
.pick-list button { width: 100%; text-align: left; padding: 8px 10px; background: var(--surface-2); color: var(--text); border: 0; border-bottom: 1px solid var(--line); cursor: pointer; font: inherit; }
.share-list li { display: flex; align-items: baseline; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.share-list .meta { margin: 0; }
.share-list .link-button { margin-left: auto; }
.link-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.link-row input { flex: 1 1 100%; margin: 0 !important; }

.lightbox { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: #050506; color: var(--text); overflow: hidden; }
.lightbox[open] { display: grid; grid-template-rows: auto minmax(0, 1fr); grid-template-columns: minmax(0, 1fr); }
.lightbox::backdrop { background: #050506; }
.lightbox-bar { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 10px 16px; font-size: .88rem; }
.lightbox-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); min-width: 0; }
.lightbox-end { display: flex; align-items: center; gap: 14px; min-width: 0; }
.lightbox-actions { display: flex; align-items: center; gap: 14px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.lightbox-actions button, .lightbox-actions a, .lightbox-close { background: none; border: 0; padding: 6px 0; color: var(--text); font: inherit; cursor: pointer; text-decoration: none; white-space: nowrap; }
.lightbox-actions button:hover, .lightbox-actions a:hover, .lightbox-close:hover { color: var(--accent); }
.lightbox-close { flex-shrink: 0; min-width: 28px; font-size: 1.05rem; }
.lightbox-actions .danger { color: var(--danger); }
.lightbox-actions [data-lb-size] { color: var(--muted); margin-left: 5px; }
@media (max-width: 760px) {
  .lightbox-name { display: none; }
  .lightbox-end { width: 100%; justify-content: space-between; }
}
.lightbox-stage { position: relative; min-height: 0; display: grid; place-items: center; }
.lightbox-stage > img, .lightbox-stage > video { max-width: 100%; max-height: 100%; object-fit: contain; }
.lightbox-nav { position: absolute; top: 50%; width: 48px; height: 72px; translate: 0 -50%; background: rgb(0 0 0 / .4); color: #fff; border: 0; border-radius: 8px; font-size: 2rem; cursor: pointer; }
.lightbox-nav.prev { left: 10px; }
.lightbox-nav.next { right: 10px; }
.lightbox-nav:disabled { display: none; }

.viewer360 { position: absolute; inset: 0; touch-action: none; cursor: grab; overflow: hidden; }
.viewer360.dragging { cursor: grabbing; }
.viewer360 canvas { display: block; width: 100%; height: 100%; }
.viewer-status { position: absolute; top: 12px; left: 50%; translate: -50% 0; padding: 4px 12px; border-radius: 6px; background: rgb(0 0 0 / .65); font-size: .82rem; pointer-events: none; text-align: center; }
.viewer-controls { position: absolute; left: 50%; bottom: 14px; translate: -50% 0; width: min(620px, calc(100% - 24px)); display: flex; align-items: center; gap: 12px; padding: 8px 14px; border-radius: 10px; background: rgb(0 0 0 / .68); font-size: .85rem; font-variant-numeric: tabular-nums; cursor: default; }
.viewer-controls button { background: none; border: 0; color: #fff; font-size: 1rem; cursor: pointer; min-width: 26px; padding: 4px; }
.viewer-controls input { flex: 1; min-width: 0; accent-color: var(--accent); }

.toast { position: fixed; left: 50%; bottom: 24px; translate: -50% 0; z-index: 10; max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 8px; background: var(--text); color: var(--bg); font-size: .9rem; }

.admin-block { background: var(--surface); border-radius: 12px; padding: 20px; margin-bottom: 20px; }
.admin-block h2 { margin-bottom: 8px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th { text-align: left; color: var(--muted); font-weight: 500; }
th, td { padding: 10px 12px 10px 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
td input { width: 18px; height: 18px; accent-color: var(--accent); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
