:root {
  --bg: #0b0b0c;
  --surface: #141416;
  --surface-2: #1b1b1e;
  --line: #26262b;
  --text: #ebe9e4;
  --muted: #8d8b87;
  --gold: #d9b56c;
  --rose: #e2607a;
  --ok: #7fbf8e;
  --danger: #e0685c;
  --radius: 6px;
  --bar: 56px;
}

*, *::before, *::after { box-sizing: border-box; }

html { color-scheme: dark; }

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

a { color: inherit; }
h1 { font-size: 1.35rem; font-weight: 500; letter-spacing: .01em; margin: 0 0 .4rem; overflow-wrap: anywhere; }
h2 { font-size: .78rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin: 2.2rem 0 .8rem; }
p { margin: 0 0 .8rem; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.gold { color: var(--gold); }
.rose { color: var(--rose); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---- Top bar ---------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;
  min-height: var(--bar); padding: .5rem 1.5rem;
  background: rgba(11, 11, 12, .92); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand, .wordmark {
  font-size: .82rem; font-weight: 600; letter-spacing: .32em; text-transform: uppercase; text-decoration: none;
}
.topbar nav { display: flex; gap: 1.25rem; flex: 1; }
.topbar nav a { color: var(--muted); text-decoration: none; font-size: .9rem; padding: .3rem 0; border-bottom: 1px solid transparent; }
.topbar nav a:hover { color: var(--text); }
.topbar nav a[aria-current] { color: var(--text); border-bottom-color: var(--gold); }
.logout { display: flex; align-items: center; gap: .9rem; font-size: .85rem; }
.who { color: var(--muted); }

main { padding: 1.5rem; }

/* ---- Buttons & forms -------------------------------------------------- */
button { font: inherit; color: inherit; cursor: pointer; }
.btn {
  display: inline-block; padding: .55rem 1rem; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface-2); color: var(--text); text-decoration: none; font-size: .9rem; line-height: 1.3;
  transition: border-color .15s, background .15s;
}
.btn:hover { border-color: #3a3a41; background: #222226; }
.btn.primary { background: var(--text); border-color: var(--text); color: #111; font-weight: 600; }
.btn.primary:hover { background: #fff; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); }
.link { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.link:hover { color: var(--text); }
.danger-text { color: var(--danger); }

label { display: block; font-size: .82rem; color: var(--muted); margin-bottom: .9rem; }
input[type=text], input[type=password], input[type=date], select, textarea {
  display: block; width: 100%; margin-top: .35rem; padding: .6rem .7rem;
  background: var(--bg); color: var(--text); font: inherit;
  border: 1px solid var(--line); border-radius: var(--radius);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); }
textarea { resize: vertical; min-height: 4.5rem; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 1.5rem; }
.stack .btn { margin-top: .3rem; }
.stack > p:last-child { margin: 1rem 0 0; }
.narrow > h1 { margin-bottom: 1rem; }
.row { display: flex; gap: .5rem; margin-bottom: .9rem; }
.row input { margin-top: 0; }
.row .btn { white-space: nowrap; }

.flash { padding: .7rem 1rem; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); font-size: .9rem; max-width: 60rem; margin-inline: auto; }
.flash-ok { border-color: rgba(127, 191, 142, .45); color: var(--ok); }
.flash-error { border-color: rgba(224, 104, 92, .5); color: var(--danger); }

/* ---- Sign-in / error pages -------------------------------------------- */
body.bare main { min-height: 100vh; display: grid; place-items: center; align-content: center; gap: 1rem; }
.auth { width: min(100%, 22rem); text-align: center; padding: 2.2rem 1.8rem; }
.auth form { text-align: left; margin-top: 1.4rem; }
.auth .btn { width: 100%; text-align: center; margin-top: .4rem; }
.auth .wordmark { font-size: .95rem; margin-bottom: .8rem; }
.status-code { font-size: 3rem; font-weight: 200; letter-spacing: .1em; color: var(--muted); margin: 0; }

/* ---- Gallery grid ----------------------------------------------------- */
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .6rem .8rem; margin-bottom: 1.1rem; }
.filters label { margin: 0; font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; }
.filters select, .filters input { width: auto; min-width: 9.5rem; height: 2.3rem; padding: 0 .6rem; font-size: .88rem; background: var(--surface); }
.filters .push { margin-left: auto; }
.filters.js .btn { display: none; }
.result-count { margin: -.3rem 0 1rem; }

.grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px;
}
.tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; transition: border-color .15s; scroll-margin-top: calc(var(--bar) + 1rem);
}
.tile:hover, .tile:target { border-color: #3d3d44; }
.tile-img { display: block; aspect-ratio: 1; padding: 12px; background: #0f0f11; }
.tile-img img { width: 100%; height: 100%; object-fit: contain; display: block; transition: transform .25s ease; }
.tile-img:hover img { transform: scale(1.025); }
.tile-bar { display: flex; align-items: center; justify-content: space-between; padding: .45rem .6rem 0; }
.tile-meta { display: flex; align-items: center; justify-content: space-between; gap: .6rem; padding: .1rem .75rem .6rem; font-size: .78rem; color: var(--muted); }
.tile-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.empty { text-align: center; padding: 6rem 1rem; color: var(--muted); }

/* ---- Icons, stars, hearts --------------------------------------------- */
.icon { fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; display: block; }
.stars { display: inline-flex; }
.star, .fav { background: none; border: 0; padding: 3px; color: #55545a; line-height: 0; border-radius: 4px; transition: color .12s, transform .12s; }
.star.on { color: var(--gold); }
.star.on .icon, .fav.on .icon { fill: currentColor; }
.stars:hover .star { color: #55545a; }
.stars .star:hover, .stars .star:has(~ .star:hover) { color: var(--gold); }
.fav:hover { color: var(--rose); transform: scale(1.12); }
.fav.on { color: var(--rose); }
.fav-form { display: inline-flex; }

.summary { display: inline-flex; gap: .7rem; flex-shrink: 0; color: var(--muted); font-size: .78rem; }
.summary > span { display: inline-flex; align-items: center; gap: .2rem; }
.summary .icon { width: 13px; height: 13px; }

/* ---- Image viewer ----------------------------------------------------- */
.viewer { display: grid; grid-template-columns: minmax(0, 1fr) 360px; margin: -1.5rem; min-height: calc(100vh - var(--bar)); }
.stage {
  position: sticky; top: var(--bar); height: calc(100vh - var(--bar));
  display: flex; align-items: center; justify-content: center; padding: 1.5rem; background: #060607;
}
.stage img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; box-shadow: 0 10px 50px rgba(0, 0, 0, .6); }
.nav-arrow {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  background: rgba(20, 20, 22, .7); border: 1px solid var(--line); color: var(--muted);
}
.nav-arrow:hover { color: var(--text); border-color: #3d3d44; }
.nav-arrow.prev { left: 1rem; }
.nav-arrow.next { right: 1rem; }

.panel { position: relative; padding: 1.5rem; border-left: 1px solid var(--line); background: var(--surface); }
.panel h1 { padding-right: 2.2rem; }
.panel .close { position: absolute; top: 1.2rem; right: 1.1rem; color: var(--muted); }
.panel .close:hover { color: var(--text); }
.my-feedback { display: flex; align-items: center; justify-content: space-between; margin: 1.1rem 0 .5rem; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); }
.my-feedback .icon { width: 26px; height: 26px; }

.others { list-style: none; padding: 0; margin: 1rem 0 0; font-size: .85rem; }
.others li { display: flex; justify-content: space-between; padding: .3rem 0; border-top: 1px solid var(--line); color: var(--muted); }
.other-marks { display: inline-flex; gap: .5rem; letter-spacing: .1em; }

.comment { padding: .7rem .8rem; margin-bottom: .6rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); }
.comment.own { border-color: #34322b; background: #121210; }
.comment header { display: flex; align-items: baseline; gap: .6rem; font-size: .82rem; margin-bottom: .25rem; }
.comment header time { flex: 1; font-size: .75rem; }
.comment p { margin: 0; overflow-wrap: anywhere; }
.comment-form { margin-top: 1rem; }
.comment-form textarea { margin: 0 0 .6rem; }
.panel-actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 2rem; padding-top: 1.2rem; border-top: 1px solid var(--line); }

/* ---- Admin pages ------------------------------------------------------ */
.narrow { max-width: 40rem; margin: 1rem auto; }
.narrow.wide { max-width: 60rem; }

.dropzone { position: relative; display: grid; gap: 1rem; justify-items: center; padding: 2.5rem 1.5rem; margin-top: 1.2rem; border: 1px dashed #3a3a41; border-radius: 10px; background: var(--surface); text-align: center; transition: border-color .15s, background .15s; }
.dropzone.over { border-color: var(--gold); background: #17160f; }
.drop-label { display: grid; gap: .2rem; margin: 0; font-size: 1rem; color: var(--text); cursor: pointer; }
.dropzone.js input[type=file], .dropzone.js .btn { display: none; }
.dropzone.js .drop-label::after { content: ""; position: absolute; inset: 0; }

.upload-list { list-style: none; padding: 0; margin: 1rem 0 0; font-size: .88rem; }
.upload-list li { display: flex; justify-content: space-between; gap: 1rem; padding: .5rem .2rem; border-bottom: 1px solid var(--line); }
.upload-list li span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-list .done span:last-child { color: var(--ok); }
.upload-list .failed span:last-child { color: var(--danger); }

.recent { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px; }
.recent a { display: block; aspect-ratio: 1; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 5px; }
.recent img { width: 100%; height: 100%; object-fit: contain; display: block; }

.user-list { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.user-row { display: grid; grid-template-columns: minmax(10rem, 1fr) auto auto; gap: 1rem; align-items: center; padding: 1rem 1.2rem; border-bottom: 1px solid var(--line); }
.user-row:last-child { border-bottom: 0; }
.user-row.is-disabled .user-info strong { color: var(--muted); text-decoration: line-through; }
.user-info p { margin: .2rem 0 0; }
.tag { display: inline-block; margin-left: .35rem; padding: .05rem .5rem; border: 1px solid var(--line); border-radius: 99px; font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.tag.warn { color: var(--danger); border-color: rgba(224, 104, 92, .5); }
.inline-form { display: flex; gap: .5rem; align-items: center; }
.inline-form input { margin: 0; width: 15rem; }
.inline-form .btn { white-space: nowrap; }
.user-actions { display: flex; gap: 1rem; font-size: .85rem; justify-content: flex-end; min-width: 7rem; }

/* ---- Small screens ---------------------------------------------------- */
@media (max-width: 900px) {
  .viewer { grid-template-columns: 1fr; }
  .stage { position: relative; top: 0; height: auto; max-height: 75vh; padding: .75rem; }
  .stage img { max-height: 70vh; }
  .panel { border-left: 0; border-top: 1px solid var(--line); }
  .user-row { grid-template-columns: 1fr; }
  .inline-form { flex-wrap: wrap; }
  .inline-form input { width: 100%; }
  .user-actions { justify-content: flex-start; }
}
@media (max-width: 560px) {
  main { padding: 1rem; }
  .viewer { margin: -1rem; }
  .topbar { padding: .5rem 1rem; gap: .6rem 1rem; }
  .who { display: none; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .filters label { flex: 1 1 45%; }
  .filters select, .filters input { width: 100%; min-width: 0; }
  .filters .push { margin-left: 0; }
  .tile-bar .icon { width: 18px; height: 18px; }
  .tile-meta .tile-title { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
