@import url('https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=DM+Sans:opsz,wght@9..40,300;9..40,400;9..40,500;9..40,600&display=swap');

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --font-display: 'Instrument Serif', Georgia, serif;
  --font-body: 'DM Sans', -apple-system, sans-serif;

  --bg: #0a0a0a;
  --bg-elevated: #141414;
  --bg-card: #1a1a1a;
  --bg-hover: #222;

  --text: #f5f5f4;
  --text-secondary: #a3a3a3;
  --text-muted: #525252;

  --accent: #e7e5e4;
  --accent-warm: #fbbf24;

  --border: #262626;
  --border-light: #333;

  --radius: 8px;
  --radius-lg: 16px;

  --header-height: 64px;
  --sidebar-width: 280px;

  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition: 300ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 500ms cubic-bezier(0.4, 0, 0.2, 1);
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
}

/* Noise texture overlay */
.noise {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
}

/* ═══════════════════════════════════════
   HEADER
   ═══════════════════════════════════════ */

.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--header-height);
  background: rgba(10, 10, 10, 0.8);
  backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border);
}

.header-content {
  height: 100%;
  max-width: 100%;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

/* Menu Toggle */
.menu-toggle {
  display: none;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 6px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px;
}

.menu-toggle span {
  display: block;
  width: 20px;
  height: 1.5px;
  background: var(--text);
  transition: var(--transition-fast);
}

.menu-toggle.active span:first-child {
  transform: rotate(45deg) translate(3px, 3px);
}

.menu-toggle.active span:last-child {
  transform: rotate(-45deg) translate(3px, -3px);
}

/* Logo */
.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text);
}

.logo-symbol {
  font-size: 1.75rem;
  line-height: 1;
  color: var(--accent-warm);
}

.logo-text {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 400;
  letter-spacing: -0.02em;
}

.logo-divider {
  width: 1px;
  height: 20px;
  background: var(--border-light);
}

.logo-sub {
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-secondary);
}

/* Search */
.search-wrapper {
  flex: 1;
  max-width: 400px;
  position: relative;
  margin-left: auto;
}

.search-wrapper input {
  width: 100%;
  padding: 0.625rem 1rem;
  padding-right: 3rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 100px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.875rem;
  outline: none;
  transition: var(--transition-fast);
}

.search-wrapper input:focus {
  border-color: var(--border-light);
  background: var(--bg-card);
}

.search-wrapper input::placeholder {
  color: var(--text-muted);
}

.search-wrapper kbd {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  padding: 0.125rem 0.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--font-body);
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Header Meta */
.header-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.image-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.view-toggle {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-fast);
}

.view-toggle:hover {
  color: var(--text);
  border-color: var(--border-light);
  background: var(--bg-elevated);
}

.view-toggle svg {
  width: 18px;
  height: 18px;
}

.view-toggle .icon-list {
  display: none;
}

.view-toggle.list-active .icon-grid {
  display: none;
}

.view-toggle.list-active .icon-list {
  display: block;
}

/* ═══════════════════════════════════════
   SIDEBAR
   ═══════════════════════════════════════ */

.sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 50;
  transition: transform var(--transition);
}

.sidebar-header {
  padding: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h3 {
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 400;
  font-style: italic;
}

.sidebar-badge {
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  background: var(--bg-elevated);
  border-radius: 100px;
  color: var(--text-muted);
}

.folder-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
}

.folder-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.75rem 1rem;
  background: transparent;
  border: none;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.875rem;
  cursor: pointer;
  transition: var(--transition-fast);
  text-align: left;
}

.folder-item:hover {
  background: var(--bg-elevated);
  color: var(--text);
}

.folder-item.active {
  background: var(--bg-card);
  color: var(--text);
}

.folder-item.active .folder-icon {
  color: var(--accent-warm);
}

.folder-icon {
  font-size: 0.875rem;
  opacity: 0.7;
}

.folder-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.folder-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
}

.storage-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
}

.storage-label {
  color: var(--text-muted);
}

.storage-status {
  color: #22c55e;
}

/* ═══════════════════════════════════════
   MAIN CONTENT
   ═══════════════════════════════════════ */

.main {
  margin-left: var(--sidebar-width);
  padding-top: var(--header-height);
  min-height: 100vh;
}

.gallery-container {
  padding: 2rem;
  max-width: 1800px;
  margin: 0 auto;
}

.gallery-hero {
  margin-bottom: 2.5rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
  animation: fadeInUp 0.6s ease-out;
}

.gallery-title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 400;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 0.5rem;
}

.gallery-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Loading */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6rem 2rem;
  color: var(--text-muted);
}

.loader {
  position: relative;
  width: 60px;
  height: 60px;
  margin-bottom: 1.5rem;
}

.loader-ring {
  position: absolute;
  inset: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}

.loader-ring:nth-child(2) {
  animation-delay: 0.3s;
}

.loader-ring:nth-child(3) {
  animation-delay: 0.6s;
}

@keyframes pulse {
  0%, 100% {
    transform: scale(0.8);
    opacity: 1;
  }
  50% {
    transform: scale(1.2);
    opacity: 0;
  }
}

/* ═══════════════════════════════════════
   GALLERY GRID
   ═══════════════════════════════════════ */

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}

.gallery-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  background: var(--bg-card);
  opacity: 0;
  animation: fadeInUp 0.5s ease-out forwards;
}

.gallery-item:nth-child(1) { animation-delay: 0.0s; }
.gallery-item:nth-child(2) { animation-delay: 0.03s; }
.gallery-item:nth-child(3) { animation-delay: 0.06s; }
.gallery-item:nth-child(4) { animation-delay: 0.09s; }
.gallery-item:nth-child(5) { animation-delay: 0.12s; }
.gallery-item:nth-child(6) { animation-delay: 0.15s; }
.gallery-item:nth-child(7) { animation-delay: 0.18s; }
.gallery-item:nth-child(8) { animation-delay: 0.21s; }
.gallery-item:nth-child(9) { animation-delay: 0.24s; }
.gallery-item:nth-child(10) { animation-delay: 0.27s; }
.gallery-item:nth-child(n+11) { animation-delay: 0.3s; }

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.gallery-item::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.7) 0%,
    rgba(0, 0, 0, 0) 50%
  );
  opacity: 0;
  transition: opacity var(--transition);
  z-index: 1;
}

.gallery-item:hover::before {
  opacity: 1;
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-slow);
}

.gallery-item:hover img {
  transform: scale(1.08);
}

.gallery-item .overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 1.25rem;
  z-index: 2;
  transform: translateY(10px);
  opacity: 0;
  transition: all var(--transition);
}

.gallery-item:hover .overlay {
  transform: translateY(0);
  opacity: 1;
}

.overlay-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.25rem;
}

.overlay-meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* List View */
.gallery.list-view {
  grid-template-columns: 1fr;
  gap: 0;
}

.gallery.list-view .gallery-item {
  aspect-ratio: auto;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 1rem;
  border-radius: 0;
  border-bottom: 1px solid var(--border);
  animation: none;
  opacity: 1;
}

.gallery.list-view .gallery-item::before {
  display: none;
}

.gallery.list-view .gallery-item:hover {
  background: var(--bg-elevated);
}

.gallery.list-view .gallery-item:hover img {
  transform: none;
}

.gallery.list-view .gallery-item img {
  width: 64px;
  height: 64px;
  border-radius: var(--radius);
  flex-shrink: 0;
}

.gallery.list-view .overlay {
  position: static;
  transform: none;
  opacity: 1;
  padding: 0;
  flex: 1;
}

.gallery.list-view .overlay-title {
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 6rem 2rem;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 4rem;
  opacity: 0.3;
  margin-bottom: 1.5rem;
}

.empty-state h3 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 400;
  color: var(--text);
  margin-bottom: 0.5rem;
}

/* ═══════════════════════════════════════
   LIGHTBOX
   ═══════════════════════════════════════ */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition);
}

.lightbox.active {
  opacity: 1;
  visibility: visible;
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
}

.lightbox-close {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  color: white;
  font-size: 1.75rem;
  cursor: pointer;
  transition: var(--transition-fast);
  z-index: 10;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.4);
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  color: white;
  font-size: 2rem;
  cursor: pointer;
  transition: var(--transition-fast);
  z-index: 10;
}

.lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.4);
}

.lightbox-prev {
  left: 1.5rem;
}

.lightbox-next {
  right: 1.5rem;
}

.lightbox-content {
  position: relative;
  max-width: 90vw;
  max-height: 85vh;
  z-index: 5;
}

.lightbox-content img {
  max-width: 100%;
  max-height: 85vh;
  object-fit: contain;
  border-radius: var(--radius);
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.5);
}

.lightbox-info {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  z-index: 10;
}

.lightbox-info h3 {
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 400;
  margin-bottom: 0.25rem;
}

.lightbox-info p {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.lightbox-counter {
  position: absolute;
  top: 1.5rem;
  left: 1.5rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  z-index: 10;
  font-variant-numeric: tabular-nums;
}

.lightbox-separator {
  margin: 0 0.25rem;
  opacity: 0.5;
}

/* ═══════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════ */

@media (max-width: 1024px) {
  :root {
    --sidebar-width: 240px;
  }

  .gallery {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
}

@media (max-width: 768px) {
  .menu-toggle {
    display: flex;
  }

  .sidebar {
    transform: translateX(-100%);
    width: 300px;
    background: var(--bg);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main {
    margin-left: 0;
  }

  .gallery-container {
    padding: 1.5rem;
  }

  .gallery {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.75rem;
  }

  .search-wrapper {
    display: none;
  }

  .gallery-title {
    font-size: 2rem;
  }

  .lightbox-nav {
    width: 44px;
    height: 44px;
  }

  .lightbox-prev {
    left: 0.75rem;
  }

  .lightbox-next {
    right: 0.75rem;
  }
}

@media (max-width: 480px) {
  .header-content {
    padding: 0 1rem;
    gap: 1rem;
  }

  .logo-divider,
  .logo-sub {
    display: none;
  }

  .image-count {
    display: none;
  }

  .gallery {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }

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

  .gallery-hero {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
  }

  .gallery-container {
    padding: 1rem;
  }
}

/* ═══════════════════════════════════════
   SCROLLBAR
   ═══════════════════════════════════════ */

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-light);
}

/* ═══════════════════════════════════════
   SELECTION
   ═══════════════════════════════════════ */

::selection {
  background: var(--accent-warm);
  color: var(--bg);
}
