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

:root {
  --rose: #d4736c;
  --rose-light: #f5e0de;
  --rose-dark: #b85a54;
  --bg: #fafafa;
  --surface: #ffffff;
  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --border: #e5e5e7;
  --radius: 12px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --transition: 0.2s ease;
}

html {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
}

a {
  color: var(--rose);
  text-decoration: none;
}

a:hover {
  color: var(--rose-dark);
}

/* ── Header ──────────────────────────────────────── */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.site-title {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.site-title .heart {
  color: var(--rose);
  font-size: 22px;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 20px;
}

.header-nav a {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: color var(--transition);
  padding: 6px 12px;
  border-radius: 8px;
}

.header-nav a:hover {
  color: var(--text);
  background: var(--rose-light);
}

.header-nav a.active {
  color: var(--rose);
}

/* ── Album Bar ───────────────────────────────────── */
.album-bar {
  max-width: 1400px;
  margin: 24px auto 0;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.album-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}

.album-tab {
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  transition: all var(--transition);
  white-space: nowrap;
  position: relative;
}

.album-tab:hover {
  border-color: var(--rose);
  color: var(--rose);
}

.album-tab.active {
  background: var(--rose);
  color: white;
  border-color: var(--rose);
}

/* "+" create album button */
.album-tab-add {
  border-style: dashed;
  color: var(--text-secondary);
  font-size: 18px;
  line-height: 1;
  padding: 8px 14px;
}

.album-tab-add:hover {
  border-color: var(--rose);
  color: var(--rose);
  background: var(--rose-light);
}

/* "..." dots on mobile touch */
.album-tab.has-dots {
  padding-right: 30px;
}

.album-tab-dots {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 1px;
  opacity: 0.5;
  padding: 0 4px;
  cursor: pointer;
}

.album-tab-dots:hover {
  opacity: 1;
}

/* ── Search Box ─────────────────────────────────── */
.search-box {
  flex-shrink: 0;
}

.search-box input[type="search"] {
  padding: 8px 16px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 14px;
  font-family: var(--font);
  color: var(--text);
  width: 160px;
  transition: width var(--transition), border-color var(--transition);
  outline: none;
}

.search-box input[type="search"]:focus {
  width: 240px;
  border-color: var(--rose);
}

.search-box input[type="search"]::placeholder {
  color: var(--text-secondary);
}

/* Remove default search cancel button styling inconsistency */
.search-box input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
  height: 14px;
  width: 14px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%236e6e73'%3E%3Cpath d='M18.3 5.7a1 1 0 00-1.4 0L12 10.6 7.1 5.7a1 1 0 00-1.4 1.4L10.6 12l-4.9 4.9a1 1 0 101.4 1.4L12 13.4l4.9 4.9a1 1 0 001.4-1.4L13.4 12l4.9-4.9a1 1 0 000-1.4z'/%3E%3C/svg%3E") center/contain no-repeat;
  cursor: pointer;
}

/* ── Album Context Menu ─────────────────────────── */
.album-context-menu {
  position: fixed;
  z-index: 200;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 4px 0;
  min-width: 160px;
}

.context-menu-item {
  display: block;
  width: 100%;
  padding: 10px 16px;
  font-size: 14px;
  font-family: var(--font);
  color: var(--text);
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  transition: background var(--transition);
}

.context-menu-item:hover {
  background: var(--rose-light);
}

.context-menu-danger {
  color: #d44;
}

.context-menu-danger:hover {
  background: #fde8e8;
}

/* ── Gallery Grid ────────────────────────────────── */
.gallery-container {
  max-width: 1400px;
  margin: 16px auto;
  padding: 0 16px;
}

.gallery-grid {
  position: relative;
}

.gallery-item {
  position: absolute;
  cursor: pointer;
  border-radius: 8px;
  overflow: hidden;
  background: var(--border);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.gallery-item:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.gallery-item img {
  display: block;
  width: 100%;
  height: auto;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.gallery-item img.loaded {
  opacity: 1;
}

.gallery-item .caption-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 32px 12px 10px;
  background: linear-gradient(transparent, rgba(0,0,0,0.5));
  color: white;
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.gallery-item:hover .caption-overlay {
  opacity: 1;
}

/* ── Empty State ─────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 120px 24px;
}

.empty-state .heart-icon {
  font-size: 64px;
  margin-bottom: 24px;
}

.empty-state h2 {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 8px;
}

.empty-state p {
  color: var(--text-secondary);
  font-size: 16px;
  margin-bottom: 24px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
}

.btn-primary {
  background: var(--rose);
  color: white;
}

.btn-primary:hover {
  background: var(--rose-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* ── Photo Count ─────────────────────────────────── */
.photo-count {
  text-align: center;
  padding: 16px;
  color: var(--text-secondary);
  font-size: 13px;
}

/* ── Loading ─────────────────────────────────────── */
.loading-spinner {
  text-align: center;
  padding: 80px 24px;
  color: var(--text-secondary);
}

.loading-spinner::after {
  content: '';
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--rose);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 768px) {
  .site-header {
    padding: 0 16px;
  }

  .header-inner {
    height: 56px;
  }

  .site-title {
    font-size: 17px;
  }

  .album-bar {
    padding: 0 16px;
    margin-top: 16px;
    flex-direction: column-reverse;
    align-items: stretch;
    gap: 8px;
  }

  .search-box input[type="search"] {
    width: 100%;
  }

  .search-box input[type="search"]:focus {
    width: 100%;
  }

  .gallery-container {
    padding: 0 8px;
    margin-top: 12px;
  }

  .gallery-item {
    border-radius: 6px;
  }

  .gallery-item .caption-overlay {
    font-size: 11px;
    padding: 20px 8px 6px;
  }

  .header-nav a {
    font-size: 13px;
    padding: 6px 8px;
  }
}
