:root {
  --ink: #2b2a28;
  --ink-soft: #6b6660;
  --paper: #faf7f1;
  --card: #ffffff;
  --line: #e7e1d6;
  --sage: #5b8a72;
  --sage-dark: #3e6350;
  --gold: #e0a23b;
  --radius: 18px;
  --shadow: 0 8px 24px rgba(43, 42, 40, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: 'Nunito Sans', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: 'Fraunces', Georgia, serif; margin: 0; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, select, input { font-family: inherit; }

.topnav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { font-family: 'Fraunces', serif; font-weight: 700; font-size: 1.15rem; color: var(--sage-dark); }
.nav-links { display: flex; align-items: center; gap: 16px; font-weight: 600; font-size: 0.92rem; }
.nav-links a { color: var(--ink-soft); }
.nav-cta {
  background: var(--sage); color: #fff !important; padding: 8px 14px; border-radius: 999px;
}

main { max-width: 1080px; margin: 0 auto; }
.page-wrap { padding: 24px 20px 60px; }

.section-title {
  font-size: 1.4rem; margin: 28px 0 14px; color: var(--ink);
}
.empty-msg { color: var(--ink-soft); }

/* login */
.login-wrap { min-height: 90vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 40px 32px; width: 100%; max-width: 360px; text-align: center;
}
.login-emoji { font-size: 2.4rem; }
.login-card h1 { font-size: 1.6rem; margin: 8px 0 4px; }
.login-sub { color: var(--ink-soft); font-size: 0.92rem; margin-bottom: 24px; }
.login-card form { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.login-card label { font-size: 0.85rem; font-weight: 600; color: var(--ink-soft); display: flex; flex-direction: column; gap: 6px; }
.login-card input {
  padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line); font-size: 1rem;
}
.login-error { color: #b5382f; font-size: 0.85rem; }
.login-card button {
  margin-top: 6px; background: var(--sage); color: #fff; border: none; padding: 12px;
  border-radius: 999px; font-weight: 800; font-size: 1rem; cursor: pointer;
}

/* clusters */
.cluster-card {
  display: flex; gap: 16px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; margin-bottom: 14px; box-shadow: var(--shadow);
  flex-wrap: wrap;
}
.cluster-strip { display: flex; gap: 6px; position: relative; }
.cluster-strip img { width: 58px; height: 58px; object-fit: cover; border-radius: 10px; }
.cluster-more {
  width: 58px; height: 58px; border-radius: 10px; background: var(--ink);
  color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.85rem;
}
.cluster-meta { flex: 1; min-width: 220px; }
.cluster-count { font-size: 0.82rem; color: var(--ink-soft); margin-bottom: 8px; font-weight: 600; }
.cluster-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.cluster-name {
  flex: 1; min-width: 160px; padding: 9px 10px; border-radius: 10px; border: 1px solid var(--line); font-size: 0.95rem;
}
.cluster-theme { padding: 9px 8px; border-radius: 10px; border: 1px solid var(--line); }
.cluster-actions { display: flex; gap: 8px; }

.btn-primary {
  background: var(--sage); color: #fff; border: none; padding: 9px 16px;
  border-radius: 999px; font-weight: 700; cursor: pointer; font-size: 0.9rem;
}
.btn-ghost {
  background: none; color: var(--ink-soft); border: 1px solid var(--line); padding: 9px 14px;
  border-radius: 999px; font-weight: 600; cursor: pointer; font-size: 0.9rem;
}
.btn-light {
  background: rgba(255,255,255,0.22); color: #fff; border: 1px solid rgba(255,255,255,0.55);
  padding: 9px 16px; border-radius: 999px; font-weight: 700; cursor: pointer; font-size: 0.9rem;
  backdrop-filter: blur(4px);
}

/* album grid */
.album-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; }
.album-tile {
  position: relative; border-radius: var(--radius); overflow: hidden; aspect-ratio: 1;
  box-shadow: var(--shadow); background: linear-gradient(135deg, var(--accent, #5b8a72), var(--accent2, #3e6350));
}
.album-tile img { width: 100%; height: 100%; object-fit: cover; }
.album-tile-empty { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 2.6rem; }
.album-tile-label {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 24px 12px 10px;
  background: linear-gradient(to top, rgba(0,0,0,0.65), transparent);
  color: #fff; display: flex; flex-direction: column; gap: 2px;
}
.album-tile-emoji { font-size: 1.1rem; }
.album-tile-name { font-weight: 800; font-family: 'Fraunces', serif; }
.album-tile-count { font-size: 0.75rem; opacity: 0.85; }

.photo-strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; }
.photo-strip img { width: 100px; height: 100px; object-fit: cover; border-radius: 10px; flex-shrink: 0; }

/* upload */
.upload-wrap { max-width: 620px; }
.upload-hint { color: var(--ink-soft); margin-bottom: 18px; }
.dropzone {
  display: block; border: 2px dashed var(--line); border-radius: var(--radius);
  padding: 36px 20px; text-align: center; cursor: pointer; background: var(--card);
}
.dropzone input { display: none; }
.dropzone-icon { font-size: 2.2rem; }
.dropzone-text { color: var(--ink-soft); font-weight: 600; margin-top: 6px; }
.preview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px; margin: 18px 0; }
.preview-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; }
.submit-btn { width: 100%; padding: 14px; font-size: 1rem; }
.upload-status { margin-top: 12px; color: var(--ink-soft); font-weight: 600; text-align: center; }

/* album hero */
.album-hero { padding: 40px 20px 60px; color: #fff; }
.album-hero-inner { max-width: 1080px; margin: 0 auto; }
.album-emoji { font-size: 2.2rem; }
.album-title, .album-title-input {
  font-family: 'Fraunces', serif; font-size: 2rem; font-weight: 700; margin: 4px 0; color: #fff;
}
.album-title-input {
  background: transparent; border: none; border-bottom: 2px solid rgba(255,255,255,0.5);
  padding: 2px 0; width: 100%; max-width: 480px;
}
.album-title-input:focus { outline: none; border-color: #fff; }
.album-sub { opacity: 0.9; font-weight: 600; margin-bottom: 16px; }
.album-hero-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.theme-select { padding: 9px 10px; border-radius: 999px; border: none; }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: -34px; }
.photo-grid img {
  width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 12px; cursor: pointer;
  box-shadow: var(--shadow);
}

/* viewer */
.viewer-overlay {
  position: fixed; inset: 0; background: rgba(10,10,12,0.92); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.viewer-overlay[hidden] { display: none; }
.viewer-overlay img { max-width: 100%; max-height: 100%; border-radius: 8px; }

/* slideshow */
.slideshow { position: fixed; inset: 0; background: #05050a; z-index: 200; }
.slideshow[hidden] { display: none; }
.slideshow canvas { width: 100%; height: 100%; display: block; }
.ss-close {
  position: absolute; top: 18px; right: 22px; background: rgba(255,255,255,0.12); color: #fff;
  border: none; width: 42px; height: 42px; border-radius: 50%; font-size: 1.4rem; cursor: pointer;
}

@media (max-width: 560px) {
  .album-hero { padding: 28px 16px 46px; }
  .album-title, .album-title-input { font-size: 1.5rem; }
  .cluster-card { flex-direction: column; }
}
