/* ── RESET ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── TOKENS ── */
:root {
  --font-display: 'Cormorant', Georgia, serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --color-bg: #f9f8f6;
  --color-text: #181816;
  --color-muted: #909088;
  --color-line: rgba(24,24,22,0.10);
  --sidebar-w: 220px;
}

html, body {
  height: 100%;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
}
body { overflow: hidden; }
body.admin-body { overflow: auto; }

/* ══ APP SHELL ══ */
#app, #admin-wrap {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* ══ SIDEBAR ══ */
#sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  display: flex; flex-direction: column;
  padding: 2.8rem 2.2rem 2rem;
  border-right: 0.5px solid var(--color-line);
  background: var(--color-bg);
  z-index: 50;
  transition: filter 0.3s ease;
}

/* Name — big, single line, display serif */
.site-name {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: 1.55rem;
  letter-spacing: 0.01em;
  white-space: nowrap;
  color: var(--color-text);
  text-decoration: none;
  line-height: 1;
  margin-bottom: 3rem;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  padding: 0;
  display: block;
}
span.site-name { cursor: default; }

/* Genre nav */
.nav-genres {
  list-style: none;
  display: flex; flex-direction: column;
  gap: 0;
  flex: 1;
}
.nav-genres li button {
  font-family: var(--font-body);
  font-weight: 200;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  color: var(--color-muted);
  background: none; border: none; cursor: pointer;
  padding: 0.38rem 0;
  text-align: left; width: 100%;
  transition: color 0.16s;
}
.nav-genres li button:hover { color: var(--color-text); }
.nav-genres li.active button { color: var(--color-text); }

/* Sidebar bottom */
.sidebar-bottom {
  display: flex; flex-direction: column;
  gap: 0.85rem; margin-top: 2rem;
}
.ig-link {
  color: var(--color-muted);
  transition: color 0.16s;
  text-decoration: none;
  display: inline-flex; align-items: center;
}
.ig-link:hover { color: var(--color-text); }
.ig-link svg { width: 15px; height: 15px; }
.admin-link {
  font-family: var(--font-body);
  font-weight: 200; font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--color-muted);
  background: none; border: none; cursor: pointer;
  text-align: left; padding: 0;
  transition: color 0.16s;
}
.admin-link:hover { color: var(--color-text); }

/* ══ MAIN GALLERY ══ */
#main-content {
  margin-left: var(--sidebar-w);
  flex: 1; overflow-y: auto; height: 100vh;
  padding: 2.8rem 2.4rem 3rem;
  transition: filter 0.32s ease;
}
#main-content.blurred {
  filter: blur(8px);
  pointer-events: none;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 4px;
  gap: 0 7px;
}
@media (max-width: 1000px) { .photo-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px)  { .photo-grid { grid-template-columns: 1fr; } }

.grid-item {
  display: block;
  background: #eae9e6;
  cursor: pointer;
  margin-bottom: 7px;
  overflow: hidden;
}
.grid-item img {
  width: 100%; display: block;
  transition: transform 0.45s ease;
  vertical-align: top;
}
.grid-item:hover img { transform: scale(1.028); }

.grid-empty {
  font-family: var(--font-display);
  font-style: italic; font-weight: 300;
  font-size: 1.05rem; color: var(--color-muted);
  padding: 4rem 0;
}

/* LIGHTBOX */
#lightbox {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.28s ease;
  background: rgba(249,248,246,0.97);
}
#lightbox.open { opacity: 1; pointer-events: all; }

#lb-img {
  display: block;
  position: relative; z-index: 1;
  width: calc(100vw - var(--sidebar-w) - 40px);
  height: 96vh;
  object-fit: contain;
  box-shadow: 0 16px 80px rgba(0,0,0,0.15);
  transition: opacity 0.12s ease;
}

#lb-close {
  position: fixed; top: 1.2rem; right: 1.5rem;
  background: none; border: none; cursor: pointer;
  font-family: var(--font-body); font-weight: 200;
  font-size: 2.2rem; line-height: 1;
  color: var(--color-text); opacity: 0;
  transition: opacity 0.2s; z-index: 210; padding: 4px 10px;
}
#lightbox.open #lb-close { opacity: 0.4; }
#lightbox.open #lb-close:hover { opacity: 1; }

.lb-arrow {
  position: fixed; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer;
  color: var(--color-text); opacity: 0;
  transition: opacity 0.2s; z-index: 210;
  padding: 1.4rem 0.8rem;
}
#lightbox.open .lb-arrow { opacity: 0.2; }
#lightbox.open .lb-arrow:hover { opacity: 0.9; }
#lb-prev { left: calc(var(--sidebar-w) + 0.5rem); }
#lb-next { right: 0.5rem; }
.lb-arrow svg { width: 26px; height: 26px; display: block; }

/* ══ MOBILE ══ */
@media (max-width: 600px) {
  :root { --sidebar-w: 0px; }

  body { overflow: auto; }

  #app { flex-direction: column; }

  #sidebar {
    position: relative;
    width: 100%; height: auto;
    flex-direction: row; align-items: center;
    padding: 1rem 1.2rem;
    border-right: none;
    border-bottom: 0.5px solid var(--color-line);
    flex-wrap: wrap; gap: 0.6rem;
  }

  .site-name {
    font-size: 1.2rem;
    margin-bottom: 0;
    margin-right: auto;
  }

  .nav-genres {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0; flex: none;
    width: 100%;
  }
  .nav-genres li button {
    font-size: 0.78rem;
    padding: 0.25rem 0.7rem 0.25rem 0;
  }

  .sidebar-bottom {
    flex-direction: row;
    margin-top: 0; gap: 0.8rem;
    align-items: center;
  }

  #main-content {
    margin-left: 0;
    height: auto;
    overflow-y: visible;
    padding: 0.8rem;
  }

  .photo-grid { grid-template-columns: repeat(2, 1fr); }

  /* Lightbox on mobile */
  #lb-img {
    width: 100vw;
    height: 100vh;
    object-fit: contain;
  }

  #lb-prev { left: 0; }
  #lb-next { right: 0; }

  #lb-close {
    top: 0.6rem; right: 0.6rem;
    font-size: 2rem;
  }

  /* Admin on mobile */
  #admin-page {
    margin-left: 0;
    padding: 1.2rem;
  }
}
#admin-page {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  padding: 2.8rem 2.8rem 4rem;
  flex: 1;
}

.admin-h1 {
  font-family: var(--font-display);
  font-weight: 300; font-size: 1.5rem;
  margin-bottom: 2.8rem; letter-spacing: 0.01em;
}
.admin-section { margin-bottom: 2.8rem; }
.admin-h2 {
  font-size: 0.62rem; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--color-muted);
  margin-bottom: 1rem; font-weight: 300;
}

.genre-list { display: flex; flex-direction: column; gap: 5px; }
.genre-row {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px;
  border: 0.5px solid var(--color-line);
  background: #fff; border-radius: 2px;
  cursor: default;
}
.drag-handle {
  color: var(--color-muted); cursor: grab; font-size: 1rem;
  line-height: 1; padding: 0 2px; user-select: none;
}
.drag-handle:active { cursor: grabbing; }
.admin-photo-item { cursor: grab; }
.admin-photo-item:active { cursor: grabbing; }
.genre-label { flex: 1; font-size: 0.84rem; font-weight: 300; }

.admin-btn {
  padding: 7px 12px;
  border: 0.5px solid rgba(24,24,22,0.18);
  background: var(--color-bg);
  font-family: var(--font-body); font-size: 0.73rem;
  font-weight: 300; letter-spacing: 0.04em;
  cursor: pointer; border-radius: 2px; color: var(--color-text);
  transition: background 0.14s, border-color 0.14s;
  white-space: nowrap;
}
.admin-btn:hover { background: #eeede9; border-color: rgba(24,24,22,0.35); }
.admin-btn:disabled { opacity: 0.25; cursor: default; pointer-events: none; }
.admin-btn.danger { color: #aa3333; border-color: rgba(170,51,51,0.22); }
.admin-btn.danger:hover { background: #fdf0f0; border-color: rgba(170,51,51,0.48); }

.admin-row { display: flex; gap: 8px; align-items: center; }
.admin-input {
  flex: 1; padding: 8px 12px;
  border: 0.5px solid rgba(24,24,22,0.18);
  background: #fff; font-family: var(--font-body);
  font-size: 0.84rem; font-weight: 300;
  color: var(--color-text); border-radius: 2px; outline: none;
  transition: border-color 0.2s;
}
.admin-input:focus { border-color: rgba(24,24,22,0.4); }

.admin-genre-tabs { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 1.1rem; }
.tab-btn {
  padding: 5px 13px;
  border: 0.5px solid var(--color-line);
  background: none; font-family: var(--font-body);
  font-size: 0.76rem; font-weight: 300;
  cursor: pointer; border-radius: 2px; color: var(--color-muted);
  transition: all 0.14s; letter-spacing: 0.04em;
}
.tab-btn.active {
  background: var(--color-text); color: var(--color-bg);
  border-color: var(--color-text);
}

.admin-photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 7px; margin-bottom: 1rem;
}
.admin-photo-item {
  position: relative; aspect-ratio: 3/2;
  background: #eae9e6; border-radius: 2px; overflow: hidden;
}
.admin-photo-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.admin-photo-remove {
  position: absolute; top: 4px; right: 4px;
  background: rgba(249,248,246,0.92);
  border: 0.5px solid var(--color-line);
  border-radius: 50%; width: 22px; height: 22px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: var(--color-text); line-height: 1;
  transition: background 0.14s;
}
.admin-photo-remove:hover { background: #fdf0f0; color: #aa3333; }

.upload-area {
  border: 1px dashed rgba(24,24,22,0.18);
  border-radius: 3px; padding: 2rem;
  text-align: center; cursor: pointer;
  transition: border-color 0.2s; margin-bottom: 0.7rem;
}
.upload-area:hover, .upload-area.dragover {
  border-color: rgba(24,24,22,0.42);
}
.upload-area p { font-size: 0.8rem; color: var(--color-muted); font-weight: 300; }
.upload-area input { display: none; }

.admin-note {
  font-size: 0.73rem; color: var(--color-muted);
  line-height: 1.75; max-width: 520px; font-weight: 300;
}
.admin-note code {
  font-family: 'SF Mono', 'Fira Code', monospace; font-size: 0.85em;
  background: rgba(24,24,22,0.06); padding: 1px 5px; border-radius: 2px;
}
.admin-note strong { font-weight: 400; color: var(--color-text); }

/* ══ LOGIN ══ */
#login-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: var(--color-bg);
  display: none; align-items: center; justify-content: center;
}
#login-overlay.show { display: flex; }

.login-box { width: 280px; text-align: center; }
.login-box h2 {
  font-family: var(--font-display); font-weight: 300;
  font-size: 1.5rem; margin-bottom: 0.3rem; letter-spacing: 0.01em;
}
.login-box > p {
  font-size: 0.78rem; color: var(--color-muted);
  margin-bottom: 1.8rem; font-weight: 300;
}
.login-box input {
  width: 100%; padding: 10px 14px;
  border: 0.5px solid rgba(24,24,22,0.2);
  font-family: var(--font-body); font-size: 0.86rem; font-weight: 300;
  background: #fff; border-radius: 2px; outline: none;
  text-align: center; margin-bottom: 10px;
  transition: border-color 0.2s;
}
.login-box input:focus { border-color: rgba(24,24,22,0.42); }
.login-submit {
  width: 100%; padding: 10px; border: none;
  background: var(--color-text);
  font-family: var(--font-body); font-size: 0.73rem;
  font-weight: 300; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--color-bg); cursor: pointer; border-radius: 2px;
  transition: opacity 0.15s;
}
.login-submit:hover { opacity: 0.75; }
.login-back-btn {
  margin-top: 1rem; display: block;
  font-family: var(--font-body); font-size: 0.73rem; font-weight: 300;
  color: var(--color-muted); text-decoration: none;
  transition: color 0.16s;
}
.login-back-btn:hover { color: var(--color-text); }
.login-err {
  font-size: 0.73rem; color: #aa3333;
  margin-top: 0.5rem; min-height: 1.1em;
}
