:root {
  /* Darkroom chrome — photos provide the color, the UI stays near-monochrome. */
  --stage: #0a0a0b;
  --bg: #0d0e11;
  --panel: #15171c;
  --panel-2: #1b1e25;
  --line: #262a32;
  --line-soft: #1e2128;

  --text: #eceef1;
  --muted: #9aa1ac;
  --faint: #6c7280;

  --primary: #f3f4f6;   /* white button */
  --on-primary: #0b0d10;
  --link: #8fb0ff;
  --danger: #e5484d;

  --radius: 10px;
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui,
    "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

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

/* --- buttons --- */
button, .btn {
  font: inherit;
  padding: 0.5rem 1rem;
  border: 0;
  border-radius: 8px;
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s, background 0.15s;
}
button:hover, .btn:hover { filter: brightness(0.94); }
.btn-danger { background: transparent; color: var(--danger); box-shadow: inset 0 0 0 1px currentColor; }
.btn-danger:hover { background: rgba(229, 72, 77, 0.12); filter: none; }
.linkbtn { background: none; color: var(--muted); padding: 0; font-weight: 400; }
.linkbtn:hover { color: var(--text); filter: none; }
.inline { display: inline; margin: 0; }

input, textarea {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0c0d10;
  color: var(--text);
  font: inherit;
}
input:focus, textarea:focus { border-color: var(--link); outline: none; }
textarea { resize: vertical; }
.stack { display: flex; flex-direction: column; gap: 0.7rem; }

/* --- top bar --- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 1.25rem;
  background: rgba(13, 14, 17, 0.85);
  backdrop-filter: saturate(1.2) blur(8px);
  border-bottom: 1px solid var(--line-soft);
}
.brand {
  color: var(--text);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.03em;
}
.brand:hover { text-decoration: none; }
.topnav { display: flex; align-items: center; gap: 1.1rem; }
.topnav__link { color: var(--muted); font-size: 0.9rem; }
.topnav__link:hover { color: var(--text); text-decoration: none; }
.avatar {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--panel-2);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
}
.avatar:hover { text-decoration: none; filter: brightness(1.15); }

main { max-width: 1240px; margin: 0 auto; padding: 1.5rem; }

.page__heading {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
  margin: 0 0 1.1rem;
}

/* --- auth --- */
.auth { max-width: 320px; margin: 4.5rem auto; }
.auth h1 { text-align: center; font-size: 1.5rem; letter-spacing: -0.02em; }
.auth label { display: flex; flex-direction: column; gap: 0.3rem; color: var(--muted); font-size: 0.85rem; }
.auth button { width: 100%; margin-top: 0.3rem; }
.error { color: var(--danger); }

/* --- justified grid (contact sheet) --- */
.grid { display: flex; flex-wrap: wrap; gap: 5px; align-content: flex-start; }
.tile {
  display: block;
  position: relative;
  overflow: hidden;
  border-radius: 4px;
  /* Blur-up placeholder: shows instantly, hidden once the real image paints over it. */
  background: var(--lqip, var(--panel-2)) center / cover no-repeat;
}
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.35s ease; }
.tile:hover img { transform: scale(1.045); }
.tile:hover { text-decoration: none; }
.tile__cap {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  padding: 1.6rem 0.7rem 0.55rem;
  color: #fff;
  font-size: 0.8rem;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.72), transparent);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tile:hover .tile__cap { opacity: 1; }
.tile__lock {
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 0.72rem;
  line-height: 1;
  padding: 3px 4px;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.55);
}

.visibility { display: flex; align-items: center; gap: 0.6rem; font-size: 0.85rem; color: var(--muted); }
.vis--private { color: var(--text); }

.tile--processing, .tile--failed {
  width: 200px; height: 200px;
  display: grid; place-items: center;
  color: var(--faint);
}
.tile--failed { color: var(--danger); font-size: 1.5rem; font-weight: 700; }
.spinner {
  width: 24px; height: 24px;
  border: 2px solid var(--line);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- detail: photo hero on a dark stage --- */
.detail { margin: -1.5rem -1.5rem 0; }
.stage {
  background: var(--lqip, var(--stage)) center / cover no-repeat;
  display: grid;
  place-items: center;
  padding: 2.5rem 1.5rem;
  min-height: 40vh;
}
.stage__img {
  max-width: min(100%, 1200px);
  max-height: 78vh;
  object-fit: contain;
  border-radius: 3px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}
.stage__state { text-align: center; color: var(--faint); display: grid; gap: 0.8rem; justify-items: center; }
.stage__state--error { color: var(--danger); }

.detail__body {
  max-width: 1000px;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 2.5rem;
  align-items: start;
}
.detail__aside { display: flex; flex-direction: column; gap: 1.5rem; }

.meta__title { font-size: 1.7rem; font-weight: 650; letter-spacing: -0.02em; margin: 0 0 0.4rem; }
.meta__desc { color: var(--muted); margin: 0 0 1rem; }
.editbox { margin-top: 0.6rem; }
.editbox > summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.85rem;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  user-select: none;
}
.editbox > summary::before { content: "✎"; }
.editbox > summary:hover { color: var(--text); }
.editbox[open] > summary { margin-bottom: 0.7rem; }

/* owner */
.owner { display: inline-flex; align-items: center; gap: 0.6rem; color: var(--text); }
.owner:hover { text-decoration: none; }
.owner:hover .owner__name { color: var(--link); }
.owner__avatar {
  display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--panel-2); font-weight: 600;
}
.owner__name { font-weight: 600; }

/* camera / exposure readout */
.camera {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 1rem 1.1rem;
}
.camera__h {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--faint);
  margin: 0 0 0.7rem;
}
.camera__data { display: grid; grid-template-columns: auto 1fr; gap: 0.4rem 1rem; margin: 0; }
.camera__data dt { color: var(--muted); font-size: 0.82rem; }
.camera__data dd { margin: 0; font-family: var(--font-mono); font-size: 0.82rem; text-align: right; }

/* tags */
.tags { display: flex; flex-direction: column; gap: 0.7rem; margin-top: 1.5rem; }
.taglist { list-style: none; display: flex; flex-wrap: wrap; gap: 0.4rem; padding: 0; margin: 0; }
.tagchip {
  display: inline-flex; align-items: center; gap: 0.3rem;
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  font-size: 0.82rem;
}
.tagchip a { color: var(--muted); }
.tagchip a:hover { color: var(--text); text-decoration: none; }
.tagx { background: none; color: var(--faint); padding: 0; font-size: 1rem; line-height: 1; }
.tagx:hover { color: var(--danger); filter: none; }
.tagadd { display: flex; gap: 0.4rem; max-width: 340px; }
.tagadd button { padding: 0.5rem 0.8rem; }

/* --- upload --- */
.upload { max-width: 720px; }
.dropzone {
  display: grid; place-items: center;
  min-height: 200px;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.dropzone.is-drag { border-color: var(--link); background: rgba(143, 176, 255, 0.06); color: var(--text); }
#new-tiles { margin-top: 1.25rem; }
.uploading {
  width: 200px; height: 200px;
  position: relative; overflow: hidden; border-radius: 4px;
  background: var(--panel-2);
}
.uploading img { width: 100%; height: 100%; object-fit: cover; opacity: 0.5; }
.uploading .bar { position: absolute; left: 0; bottom: 0; width: 100%; height: 3px; background: var(--line); }
.uploading .bar span { display: block; height: 100%; width: 0; background: var(--link); transition: width 0.15s; }
.uploading--error { outline: 2px solid var(--danger); }

/* --- albums --- */
.muted { color: var(--muted); }

.newalbum { display: flex; gap: 0.5rem; max-width: 420px; margin-bottom: 1.5rem; }
.newalbum input { flex: 1; }

.albumgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; }
.albumcard { display: block; color: var(--text); }
.albumcard:hover { text-decoration: none; }
.albumcard__cover { aspect-ratio: 4 / 3; border-radius: var(--radius); overflow: hidden; background: var(--panel-2); }
.albumcard__cover img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.35s ease; }
.albumcard:hover .albumcard__cover img { transform: scale(1.04); }
.albumcard__empty { width: 100%; height: 100%; display: grid; place-items: center; color: var(--faint); font-size: 0.85rem; }
.albumcard__meta { display: flex; flex-direction: column; margin-top: 0.5rem; }
.albumcard__title { font-weight: 600; }
.albumcard__count { color: var(--muted); font-size: 0.82rem; }

.albummeta { margin-bottom: 1.5rem; }
.albummeta__title { font-size: 1.6rem; font-weight: 650; letter-spacing: -0.02em; margin: 0 0 0.3rem; }
.albumactions { display: flex; align-items: center; gap: 1rem; margin-top: 0.8rem; flex-wrap: wrap; }

.albumpicker { border: 1px solid var(--line-soft); border-radius: var(--radius); background: var(--panel); padding: 1rem 1.1rem; }
.albumtoggles { list-style: none; margin: 0 0 0.7rem; padding: 0; display: flex; flex-direction: column; gap: 0.45rem; }
.albumtoggles li { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; font-size: 0.88rem; }
.albumtoggles__name { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.albumpicker .newalbum { max-width: none; margin: 0; }

@media (max-width: 760px) {
  .detail__body { grid-template-columns: 1fr; gap: 1.75rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
