/* ============ theme variables ============ */
:root,
html[data-theme="liquid-glass"] {
  --bg-grad: linear-gradient(135deg, #f3c6d3 0%, #c9b8e8 45%, #b7d8ea 100%);
  --glass-bg: rgba(255, 255, 255, 0.32);
  --glass-bg-strong: rgba(255, 255, 255, 0.5);
  --glass-border: rgba(255, 255, 255, 0.65);
  --glass-highlight: rgba(255, 255, 255, 0.9);
  --ink: #4a3b4f;
  --accent-a: #f3c6d3;
  --accent-b: #c9b8e8;
  --accent-c: #b7d8ea;
  --shadow-color: rgba(109, 75, 115, 0.22);
}

html[data-theme="midnight"] {
  --bg-grad: linear-gradient(135deg, #1b1030 0%, #3a2159 50%, #120a24 100%);
  --glass-bg: rgba(255, 255, 255, 0.08);
  --glass-bg-strong: rgba(255, 255, 255, 0.14);
  --glass-border: rgba(255, 255, 255, 0.22);
  --glass-highlight: rgba(255, 255, 255, 0.35);
  --ink: #ece6f5;
  --accent-a: #7b5fb0;
  --accent-b: #a084d6;
  --accent-c: #4d3a7a;
  --shadow-color: rgba(0, 0, 0, 0.55);
}

html[data-theme="sunset"] {
  --bg-grad: linear-gradient(135deg, #ff9a76 0%, #f0587a 55%, #7b2ff7 100%);
  --glass-bg: rgba(255, 255, 255, 0.28);
  --glass-bg-strong: rgba(255, 255, 255, 0.42);
  --glass-border: rgba(255, 255, 255, 0.6);
  --glass-highlight: rgba(255, 255, 255, 0.85);
  --ink: #4a2440;
  --accent-a: #ff9a76;
  --accent-b: #f0587a;
  --accent-c: #7b2ff7;
  --shadow-color: rgba(123, 47, 130, 0.3);
}

html[data-theme="mint"] {
  --bg-grad: linear-gradient(135deg, #b6e3d4 0%, #8fd9c4 50%, #c9f2e0 100%);
  --glass-bg: rgba(255, 255, 255, 0.35);
  --glass-bg-strong: rgba(255, 255, 255, 0.55);
  --glass-border: rgba(255, 255, 255, 0.7);
  --glass-highlight: rgba(255, 255, 255, 0.9);
  --ink: #204a3d;
  --accent-a: #8fd9c4;
  --accent-b: #6bc2a8;
  --accent-c: #b6e3d4;
  --shadow-color: rgba(32, 74, 61, 0.2);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; min-height: 100%;
  font-family: 'Quicksand', sans-serif;
  color: var(--ink);
  background: var(--bg-grad);
  background-attachment: fixed;
  overflow-x: hidden;
}

#bg-image {
  position: fixed; inset: 0; z-index: -1;
  background-size: cover; background-position: center;
  opacity: 0; transition: opacity 0.4s ease;
}
#bg-image.visible { opacity: 1; }
#bg-image.visible::after {
  content: ''; position: absolute; inset: 0;
  background: var(--bg-grad); opacity: 0.55;
}

.grain-overlay {
  position: fixed; inset: 0; pointer-events: none; z-index: 999;
  opacity: 0.05; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.hidden { display: none !important; }

.view {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
}

.logo {
  font-family: 'Caveat', cursive; font-size: 3rem; margin: 0 0 4px 0; text-align: center;
  color: var(--ink); text-shadow: 0 2px 12px rgba(255,255,255,0.5);
}
.logo.small { font-size: 1.8rem; margin: 0; }

.subtitle { text-align: center; margin: 0 0 24px 0; opacity: 0.75; font-size: 0.95rem; }

/* ============ enhanced liquid glass ============ */
.glass-card {
  position: relative;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border-radius: 28px;
  box-shadow:
    0 12px 40px var(--shadow-color),
    inset 0 1px 0 var(--glass-highlight),
    inset 0 -1px 12px rgba(0,0,0,0.03);
  padding: 40px;
  width: 100%; max-width: 460px;
  overflow: hidden;
  isolation: isolate;
}
/* diagonal light sheen for a real "liquid glass" feel */
.glass-card::before {
  content: '';
  position: absolute; top: -60%; left: -30%;
  width: 160%; height: 90%;
  background: linear-gradient(120deg, rgba(255,255,255,0.35) 0%, rgba(255,255,255,0) 55%);
  transform: rotate(-8deg);
  pointer-events: none;
  z-index: -1;
}
.glass-card::after {
  content: '';
  position: absolute; inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(160deg, var(--glass-highlight), transparent 40%, transparent 70%, var(--glass-highlight));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  opacity: 0.5;
}

.setup-card { max-width: 480px; }

.setup-profile {
  margin-bottom: 18px; padding: 14px 16px; border-radius: 18px;
  background: rgba(255,255,255,0.18); border: 1px solid var(--glass-border);
}
.setup-profile h3 { margin: 0 0 8px 0; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.08em; opacity: 0.6; }

input[type="text"], input[type="password"] {
  width: 100%; padding: 12px 16px; margin-bottom: 8px; border-radius: 14px;
  border: 1px solid var(--glass-border); background: rgba(255,255,255,0.4);
  font-family: 'Quicksand', sans-serif; font-size: 1rem; color: var(--ink);
  outline: none; transition: box-shadow 0.2s ease, background 0.2s ease;
}
input:focus { background: rgba(255,255,255,0.65); box-shadow: 0 0 0 3px rgba(201,184,232,0.4); }

.btn-main {
  display: inline-block; width: 100%; text-align: center; padding: 12px 20px; margin-top: 6px;
  border: none; border-radius: 999px;
  background: linear-gradient(135deg, var(--accent-a), var(--accent-b));
  color: var(--ink); font-family: 'Quicksand', sans-serif; font-weight: 600; font-size: 1rem;
  cursor: pointer; box-shadow: 0 6px 18px var(--shadow-color);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.btn-main:hover { transform: translateY(-2px); box-shadow: 0 10px 22px var(--shadow-color); }
.btn-main:active { transform: translateY(0); }
.btn-main.small { width: auto; padding: 8px 16px; font-size: 0.9rem; margin-top: 0; }

.btn-ghost {
  display: inline-block; width: 100%; text-align: center; padding: 10px 20px; margin-top: 8px;
  border: 1px solid var(--glass-border); border-radius: 999px; background: transparent;
  color: var(--ink); font-family: 'Quicksand', sans-serif; font-weight: 500; cursor: pointer; opacity: 0.8;
}
.btn-ghost:hover { opacity: 1; background: rgba(255,255,255,0.15); }
.btn-ghost.small { width: auto; padding: 8px 16px; font-size: 0.9rem; margin-top: 0; }

.file-btn { cursor: pointer; }

.error-msg { color: #e0607a; font-size: 0.85rem; min-height: 1.2em; margin: 4px 0; text-align: center; }

/* ============ theme drawer ============ */
.theme-toggle-btn {
  position: fixed; bottom: 22px; left: 22px; z-index: 500;
  width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--glass-border);
  background: var(--glass-bg); backdrop-filter: blur(14px);
  font-size: 1.3rem; cursor: pointer; box-shadow: 0 6px 18px var(--shadow-color);
}
.theme-drawer {
  position: fixed; inset: 0; z-index: 600;
  display: flex; align-items: flex-end; justify-content: flex-start; padding: 24px;
}
.theme-drawer::before {
  content: ''; position: absolute; inset: 0; background: rgba(0,0,0,0.15);
}
.theme-drawer-inner {
  position: relative; max-width: 280px; padding: 24px;
}
.theme-drawer-inner h3 { margin: 0 0 14px 0; font-family: 'Caveat', cursive; font-size: 1.5rem; }
.theme-options { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.theme-swatch {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 14px;
  border: 1px solid var(--glass-border); background: rgba(255,255,255,0.15); cursor: pointer;
  color: var(--ink); font-family: 'Quicksand', sans-serif; font-weight: 500;
}
.theme-swatch:hover { background: rgba(255,255,255,0.3); }
.theme-swatch.active { outline: 2px solid var(--accent-b); }
.theme-swatch .swatch { width: 26px; height: 26px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.6); display: inline-block; }

/* ============ login profile picker ============ */
.profile-picker { display: flex; justify-content: center; gap: 20px; flex-wrap: wrap; margin-bottom: 8px; }
.profile-avatar { display: flex; flex-direction: column; align-items: center; gap: 8px; cursor: pointer; background: none; border: none; font-family: 'Quicksand', sans-serif; }
.profile-avatar .circle {
  width: 76px; height: 76px; border-radius: 50%; border: 3px solid var(--glass-highlight);
  box-shadow: 0 6px 16px var(--shadow-color); display: flex; align-items: center; justify-content: center;
  font-family: 'Caveat', cursive; font-size: 1.8rem; color: var(--ink); transition: transform 0.15s ease;
  overflow: hidden; background-size: cover; background-position: center;
}
.profile-avatar .circle img { width: 100%; height: 100%; object-fit: cover; }
.profile-avatar:hover .circle { transform: scale(1.06) rotate(-3deg); }
.profile-avatar span.name { font-size: 0.9rem; color: var(--ink); }
.login-selected-name { text-align: center; font-family: 'Caveat', cursive; font-size: 1.6rem; margin: 0 0 12px 0; }

/* ============ admin panel ============ */
.modal { position: fixed; inset: 0; z-index: 800; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(20, 12, 30, 0.55); backdrop-filter: blur(4px); }
.admin-card { position: relative; max-width: 640px; max-height: 86vh; overflow-y: auto; }
.admin-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.admin-header h2 { font-family: 'Caveat', cursive; font-size: 2rem; margin: 0; }
.admin-section { margin: 22px 0; padding-top: 18px; border-top: 1px solid var(--glass-border); }
.admin-section:first-of-type { border-top: none; padding-top: 0; }
.admin-section h3 { margin: 0 0 6px 0; font-size: 1rem; }
.admin-hint { font-size: 0.82rem; opacity: 0.7; margin: 0 0 10px 0; }
.admin-row { display: flex; gap: 10px; flex-wrap: wrap; }
.admin-status { font-size: 0.82rem; opacity: 0.8; margin-top: 8px; }
.admin-profile-list { display: flex; flex-direction: column; gap: 12px; }
.admin-profile-card {
  display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 16px;
  background: rgba(255,255,255,0.15); border: 1px solid var(--glass-border); flex-wrap: wrap;
}
.admin-profile-card .circle { width: 46px; height: 46px; flex-shrink: 0; }
.admin-profile-card input[type="text"], .admin-profile-card input[type="password"] {
  width: auto; flex: 1 1 120px; margin-bottom: 0; padding: 8px 12px; font-size: 0.9rem;
}
.admin-inline-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.admin-inline-form input[type="text"], .admin-inline-form input[type="password"] { width: auto; flex: 1 1 140px; margin-bottom: 0; }

/* ============ gallery layout ============ */
#view-gallery { align-items: stretch; padding: 0; min-height: 100vh; display: flex; }

.sidebar {
  width: 240px; flex-shrink: 0; margin: 16px 0 16px 16px; border-radius: 24px;
  display: flex; flex-direction: column; padding: 22px 16px; height: calc(100vh - 32px);
  position: sticky; top: 16px;
}
.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 4px; margin-top: 18px; overflow-y: auto; }
.sidebar-item {
  text-align: left; padding: 10px 14px; border-radius: 14px; border: none; background: transparent;
  color: var(--ink); font-family: 'Quicksand', sans-serif; font-size: 0.95rem; cursor: pointer;
}
.sidebar-item:hover { background: rgba(255,255,255,0.25); }
.sidebar-item.active { background: rgba(255,255,255,0.4); font-weight: 600; }
.sidebar-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; opacity: 0.55; margin: 14px 6px 2px; }
.album-list { display: flex; flex-direction: column; gap: 2px; }
.sidebar-add { opacity: 0.7; font-style: italic; }
.sidebar-footer { border-top: 1px solid var(--glass-border); padding-top: 14px; display: flex; flex-direction: column; gap: 8px; }
#gallery-username { font-family: 'Caveat', cursive; font-size: 1.3rem; }

.gallery-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.gallery-header {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  padding: 20px 28px; background: var(--glass-bg); backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%); border-bottom: 1px solid var(--glass-border);
}
.gallery-header h2 { margin: 0; font-family: 'Caveat', cursive; font-size: 1.7rem; }
.gallery-header-right { display: flex; align-items: center; gap: 12px; }
.upload-btn { width: auto; padding: 10px 22px; margin: 0; }

.select-bar {
  display: flex; align-items: center; justify-content: space-between; padding: 10px 28px;
  background: rgba(255,255,255,0.2); border-bottom: 1px solid var(--glass-border);
}
.select-bar-actions { display: flex; gap: 10px; align-items: center; }
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; top: 110%; right: 0; min-width: 180px; z-index: 50;
  background: var(--glass-bg-strong); backdrop-filter: blur(20px); border: 1px solid var(--glass-border);
  border-radius: 14px; padding: 6px; box-shadow: 0 10px 24px var(--shadow-color);
}
.dropdown-menu button {
  display: block; width: 100%; text-align: left; padding: 8px 10px; border: none; background: none;
  border-radius: 10px; cursor: pointer; color: var(--ink); font-family: 'Quicksand', sans-serif;
}
.dropdown-menu button:hover { background: rgba(255,255,255,0.3); }

.upload-progress { text-align: center; padding: 10px; font-size: 0.9rem; opacity: 0.8; }

.photo-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 18px; padding: 28px;
}
.photo-tile {
  position: relative; border-radius: 16px; overflow: hidden; aspect-ratio: 1 / 1;
  background: rgba(255,255,255,0.25); border: 6px solid rgba(255,255,255,0.85);
  box-shadow: 0 8px 20px var(--shadow-color); cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  contain: layout paint;
}
.photo-tile:nth-child(3n+1) { transform: rotate(-1.5deg); }
.photo-tile:nth-child(3n+2) { transform: rotate(1deg); }
.photo-tile:nth-child(3n) { transform: rotate(-0.5deg); }
.photo-tile:hover { transform: scale(1.03) rotate(0deg) !important; box-shadow: 0 14px 28px var(--shadow-color); z-index: 2; }
.photo-tile img, .photo-tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-tile .video-badge {
  position: absolute; bottom: 8px; right: 8px; background: rgba(0,0,0,0.5); color: white;
  font-size: 0.75rem; padding: 2px 8px; border-radius: 999px;
}
.photo-tile .select-check {
  position: absolute; top: 8px; left: 8px; width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid white; background: rgba(0,0,0,0.25); display: flex; align-items: center; justify-content: center;
  color: white; font-size: 0.8rem;
}
.photo-tile.selected { outline: 3px solid var(--accent-b); }
.photo-tile.selected .select-check { background: var(--accent-b); }

#grid-sentinel { height: 1px; }

.empty-state { text-align: center; margin-top: 60px; font-family: 'Caveat', cursive; font-size: 1.6rem; opacity: 0.6; }

/* ============ drive / files ============ */
.drive-view { padding: 28px; }
.drive-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; gap: 10px; }
.drive-breadcrumb { font-size: 0.95rem; opacity: 0.85; }
.drive-breadcrumb button { background: none; border: none; color: var(--ink); text-decoration: underline; cursor: pointer; font-family: 'Quicksand', sans-serif; padding: 0 2px; }
.drive-toolbar-actions { display: flex; gap: 10px; }
.drive-list { display: flex; flex-direction: column; gap: 6px; }
.drive-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 14px;
  background: rgba(255,255,255,0.2); border: 1px solid var(--glass-border);
}
.drive-row .drive-icon { font-size: 1.4rem; }
.drive-row .drive-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.drive-row .drive-meta { font-size: 0.8rem; opacity: 0.65; white-space: nowrap; }
.drive-row .drive-actions { display: flex; gap: 6px; }
.drive-row button { border: none; background: rgba(255,255,255,0.3); border-radius: 10px; padding: 6px 10px; cursor: pointer; font-size: 0.85rem; }
.drive-row button:hover { background: rgba(255,255,255,0.5); }

/* ============ lightbox ============ */
.lightbox {
  position: fixed; inset: 0; z-index: 1000; background: rgba(20, 12, 30, 0.88); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
}
.lightbox-content { max-width: 88vw; max-height: 82vh; display: flex; align-items: center; justify-content: center; }
.lightbox-content img, .lightbox-content video { max-width: 88vw; max-height: 82vh; border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,0.5); }
.lightbox-close, .lightbox-delete {
  position: absolute; top: 20px; border: none; background: rgba(255,255,255,0.2); color: white;
  border-radius: 999px; cursor: pointer; font-family: 'Quicksand', sans-serif;
}
.lightbox-close { right: 20px; width: 44px; height: 44px; font-size: 1.6rem; line-height: 1; }
.lightbox-delete { left: 20px; padding: 10px 18px; font-size: 0.9rem; }
.lightbox-delete:hover { background: rgba(163, 67, 90, 0.6); }
.lightbox-nav {
  position: absolute; top: 50%; transform: translateY(-50%); border: none; background: rgba(255,255,255,0.2);
  color: white; width: 48px; height: 48px; border-radius: 50%; font-size: 1.2rem; cursor: pointer;
}
.lightbox-prev { left: 20px; } .lightbox-next { right: 20px; }
.lightbox-nav:hover, .lightbox-close:hover { background: rgba(255,255,255,0.35); }

@media (max-width: 900px) {
  #view-gallery { flex-direction: column; }
  .sidebar { width: auto; margin: 12px; height: auto; position: relative; top: 0; flex-direction: row; flex-wrap: wrap; }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; margin-top: 8px; }
  .sidebar-footer { flex-direction: row; justify-content: space-between; width: 100%; }
}
@media (max-width: 560px) {
  .glass-card { padding: 28px 20px; }
  .logo { font-size: 2.4rem; }
  .gallery-header { padding: 12px 16px; flex-wrap: wrap; gap: 10px; }
  .photo-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; padding: 16px; }
  .theme-toggle-btn { bottom: 14px; left: 14px; }
}
