:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --ink: #1c1c1e;
  --ink-soft: #6e6e73;
  --border: #e5e5e7;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --danger: #c0392b;
  --ok-bg: #eaf6ea; --ok-text: #2f6b33; --ok-border: #bfdbc0;
  --err-bg: #fbeaea; --err-text: #8b2e2e; --err-border: #e3b3b3;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.qg-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.75rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.qg-brand { font-weight: 700; font-size: 1.1rem; color: var(--ink); }
.qg-admin-link { font-size: 0.9rem; color: var(--ink-soft); }

main { max-width: 68rem; margin: 0 auto; padding: 2rem 1.75rem 4rem; }

.qg-empty { color: var(--ink-soft); padding: 2rem 0; }

.qg-back { display: inline-block; margin-bottom: 1rem; font-size: 0.9rem; }
.qg-album-title { margin: 0 0 1.25rem; font-size: 1.7rem; }

/* Album grid */
.qg-albums {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.25rem;
}
.qg-album-card {
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.qg-album-card:hover { box-shadow: 0 6px 16px rgba(0,0,0,0.08); transform: translateY(-2px); text-decoration: none; }
.qg-album-cover { aspect-ratio: 4/3; background: var(--bg); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.qg-album-cover img { width: 100%; height: 100%; object-fit: contain; }
.qg-album-empty { color: var(--ink-soft); font-size: 0.85rem; }
.qg-album-name { padding: 0.7rem 0.9rem 0.1rem; font-weight: 600; }
.qg-album-count { padding: 0 0.9rem 0.8rem; font-size: 0.82rem; color: var(--ink-soft); }

/* Photo grid */
.qg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
}
.qg-thumb {
  padding: 0; border: none; background: var(--bg); cursor: pointer;
  border-radius: 8px; overflow: hidden; aspect-ratio: 1/1;
}
.qg-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; transition: transform 0.15s ease; }
.qg-thumb:hover img { transform: scale(1.04); }

/* Lightbox */
.qg-lightbox {
  position: fixed; inset: 0; background: rgba(10,10,12,0.92);
  z-index: 100; padding: 2rem;
}
/* Scoped to :not([hidden]) rather than a bare .qg-lightbox rule — a plain
   class selector has the same specificity as the browser's own
   [hidden] { display: none }, and author CSS wins that tie regardless of
   the hidden attribute, so "display: flex" here would silently keep the
   lightbox visible even after JS sets .hidden = true on close. */
.qg-lightbox:not([hidden]) {
  display: flex; align-items: center; justify-content: center; flex-direction: column;
}
.qg-lightbox img { max-width: 90vw; max-height: 78vh; object-fit: contain; border-radius: 4px; }
.qg-lightbox-caption { color: #eee; margin-top: 1rem; font-size: 0.95rem; text-align: center; max-width: 40rem; }
.qg-lightbox-close, .qg-lightbox-prev, .qg-lightbox-next {
  position: absolute; background: rgba(255,255,255,0.08); color: #fff; border: none;
  border-radius: 50%; cursor: pointer; font-size: 1.5rem; line-height: 1;
  width: 2.75rem; height: 2.75rem;
}
.qg-lightbox-close:hover, .qg-lightbox-prev:hover, .qg-lightbox-next:hover { background: rgba(255,255,255,0.18); }
.qg-lightbox-close { top: 1.25rem; right: 1.25rem; }
.qg-lightbox-prev { left: 1.25rem; top: 50%; transform: translateY(-50%); }
.qg-lightbox-next { right: 1.25rem; top: 50%; transform: translateY(-50%); }

/* Forms (admin) */
.qg-form, .qg-login-form { max-width: 28rem; }
.qg-form label, .qg-login-form label { display: block; font-size: 0.88rem; color: var(--ink-soft); margin: 1rem 0 0.3rem; font-weight: 600; }
.qg-form input, .qg-form select, .qg-login-form input {
  width: 100%; background: var(--surface); border: 1px solid var(--border);
  color: var(--ink); border-radius: 6px; padding: 0.6rem 0.75rem; font-size: 0.95rem; font-family: inherit;
}
.qg-submit-row { margin-top: 1.25rem; }
.qg-btn {
  display: inline-block; background: var(--accent); color: #fff; font-weight: 600;
  padding: 0.65rem 1.4rem; border-radius: 7px; border: none; cursor: pointer; font-size: 0.95rem;
}
.qg-btn:hover { background: var(--accent-dark); }

.qg-login-main { display: flex; align-items: center; justify-content: center; min-height: 70vh; }
.qg-login-form { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 2rem; width: 100%; }
.qg-login-form h1 { margin-top: 0; font-size: 1.4rem; }
.qg-login-form .qg-back { margin-top: 1.25rem; margin-bottom: 0; }

.qg-notice { border-radius: 8px; padding: 0.85rem 1.1rem; margin: 1rem 0; font-size: 0.92rem; }
.qg-notice-ok { background: var(--ok-bg); border: 1px solid var(--ok-border); color: var(--ok-text); }
.qg-notice-err { background: var(--err-bg); border: 1px solid var(--err-border); color: var(--err-text); }

.qg-album-tabs { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 1rem 0 1.5rem; }
.qg-album-tabs a { padding: 0.4rem 0.9rem; border: 1px solid var(--border); border-radius: 999px; font-size: 0.88rem; color: var(--ink); }
.qg-album-tabs a.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.qg-album-tabs a:hover { text-decoration: none; border-color: var(--accent); }

.qg-manage-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 1rem; }
.qg-manage-item { border: 1px solid var(--border); border-radius: 8px; padding: 0.6rem; background: var(--surface); }
.qg-manage-item img { width: 100%; aspect-ratio: 1/1; object-fit: cover; border-radius: 5px; display: block; }
.qg-manage-filename { font-size: 0.75rem; color: var(--ink-soft); margin: 0.4rem 0; word-break: break-all; }
.qg-caption-form { display: flex; gap: 0.35rem; margin-bottom: 0.35rem; }
.qg-caption-form input { flex: 1; padding: 0.4rem 0.5rem; font-size: 0.82rem; border: 1px solid var(--border); border-radius: 5px; }
.qg-btn-small { border: none; border-radius: 5px; padding: 0.4rem 0.6rem; font-size: 0.8rem; cursor: pointer; background: var(--accent); color: #fff; }
.qg-btn-small:hover { background: var(--accent-dark); }
.qg-delete-form { display: block; }
.qg-btn-danger { background: var(--danger); width: 100%; }
.qg-btn-danger:hover { background: #a5301f; }
