@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg: #F8F9FA;
  --bg-card: #FFFFFF;
  --bg-hover: #F1F3F5;
  --text: #1A1A1A;
  --text-2: #6C757D;
  --text-3: #ADB5BD;
  --border: #E9ECEF;
  --accent: #228BE6;
  --accent-hover: #1C7ED6;
  --accent-soft: #E7F5FF;
  --danger: #FA5252;
  --danger-soft: #FFF5F5;
  --success: #40C057;
  --success-soft: #EBFBEE;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.08);
}

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

body {
  font-family: 'Inter', -apple-system, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

/* ── Header ── */
.header {
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
}

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

.logo { font-size: 1rem; font-weight: 700; color: var(--text); letter-spacing: -0.02em; }

.upload-btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 7px 16px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.upload-btn:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 2px 8px rgba(34,139,230,0.3); }
.upload-btn:active { transform: translateY(0); }

/* ── Spaces ── */
.spaces {
  display: flex;
  gap: 4px;
  padding: 3px;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.space-btn {
  padding: 5px 14px;
  border: none;
  border-radius: 7px;
  background: transparent;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 5px;
}

.space-btn.active { background: white; color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.space-btn:not(.active):hover { color: var(--text); }
.space-btn.private-btn { display: none; }
.space-btn.private-btn.show { display: flex; }

.lock-icon {
  width: 12px;
  height: 12px;
  opacity: 0.5;
}

.space-btn.active .lock-icon { opacity: 0.8; }

/* ── Tab pills ── */
.tab-pill {
  padding: 4px 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-3);
  cursor: pointer;
  transition: all 0.15s;
}

.tab-pill.active { background: var(--accent-soft); color: var(--accent); }
.tab-pill:not(.active):hover { color: var(--text-2); }

/* ── Toolbar ── */
.toolbar {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 20px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.toolbar-right { display: flex; align-items: center; gap: 4px; }

.tool-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  border: none;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.15s;
}

.tool-btn:hover { background: var(--bg-hover); color: var(--text); }

.sort-select {
  appearance: none;
  background: white;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 5px 26px 5px 10px;
  font-family: inherit;
  font-size: 0.75rem;
  color: var(--text-2);
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%23ADB5BD' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

/* ── Search ── */
.search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 8px;
  color: var(--text-3);
  pointer-events: none;
}

.search-input {
  width: 0;
  padding: 5px 8px 5px 28px;
  border: 1px solid transparent;
  border-radius: 7px;
  font-family: inherit;
  font-size: 0.75rem;
  background: transparent;
  color: var(--text);
  outline: none;
  transition: all 0.2s;
  opacity: 0;
}

.search-wrapper:focus-within .search-input,
.search-input.has-value {
  width: 140px;
  border-color: var(--border);
  background: white;
  opacity: 1;
}

.search-wrapper:hover .search-input { width: 140px; opacity: 0.6; }
.search-wrapper:hover .search-input:focus { opacity: 1; }

@media (max-width: 640px) {
  .search-wrapper:focus-within .search-input,
  .search-input.has-value { width: 100px; }
  .search-wrapper:hover .search-input { width: 100px; }
}

/* ── Storage indicator ── */
.storage-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
}

.storage-bar {
  width: 48px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.storage-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.5s ease;
  min-width: 0;
}

.storage-fill.warn { background: #FAB005; }
.storage-fill.danger { background: var(--danger); }

.storage-text {
  font-size: 0.6875rem;
  color: var(--text-3);
  white-space: nowrap;
}

/* ── Folder stats ── */
.folder-stats {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px 4px;
  font-size: 0.8125rem;
  color: var(--text-2);
  min-height: 0;
}

.folder-stats:empty { display: none; }

/* ── Breadcrumbs ── */
.breadcrumbs {
  max-width: 1200px;
  margin: 0 auto;
  padding: 8px 20px;
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: 0.8125rem;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.breadcrumbs::-webkit-scrollbar { display: none; }

.bc-link {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 6px;
  transition: all 0.15s;
  white-space: nowrap;
  min-height: 32px;
  display: flex;
  align-items: center;
}

.bc-link:hover { color: var(--accent); background: var(--accent-soft); border-color: var(--accent); }
.bc-link:last-child { background: white; color: var(--text); border-color: #DEE2E6; }
.bc-sep { color: var(--text-3); user-select: none; font-size: 0.6875rem; margin: 0 2px; }

@media (max-width: 640px) {
  .breadcrumbs { padding: 4px 12px; gap: 2px; }
  /* was 0.6875rem/11px, below the point this is comfortably readable */
  .bc-link { padding: 5px 10px; font-size: 0.8125rem; min-height: 30px; }

  /* "23 photos · 7 videos · 521.4 MB" is bookkeeping, not something you browse
     photos by. It cost a row of an 852px screen at 11px type. Desktop keeps it. */
  .folder-stats { display: none; }
}

/* ── File Grid ── */
.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: 10px;
}

.file-list-view { display: flex; flex-direction: column; gap: 1px; }

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow);
  position: relative;
}

.card:hover { border-color: #DEE2E6; box-shadow: var(--shadow-md); transform: translateY(-2px); }
.card:active { transform: translateY(0); }
.card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

.card-check {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 5;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.8);
  background: rgba(0,0,0,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.card-check svg { width: 14px; height: 14px; opacity: 0; }
.card-check.checked { background: var(--accent); border-color: var(--accent); }
.card-check.checked svg { opacity: 1; }

.card-thumb {
  aspect-ratio: 1;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.card-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.3s ease; }
.card:hover .card-thumb img { transform: scale(1.05); }

.card-body { padding: 8px 10px; }
.card-name { font-size: 0.75rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-meta { font-size: 0.6875rem; color: var(--text-3); margin-top: 1px; }

.card.folder { background: #FAFAFA; border-style: dashed; border-color: #DEE2E6; }
.card.folder:hover { background: var(--accent-soft); border-color: var(--accent); }

.card-thumb.has-cover { background: #000; }

.folder-badge {
  position: absolute;
  bottom: 6px;
  left: 6px;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  color: white;
  border-radius: 6px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card.folder .card-thumb.has-cover + .card-body { background: var(--bg-card); }
.card.folder:has(.has-cover) { border-style: solid; background: var(--bg-card); }

/* ── Row (list view) ── */
.row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s;
  min-height: 44px;
}

.row:hover { background: var(--bg-hover); }
.row:active { background: #E9ECEF; }
.row.selected { background: var(--accent-soft); }

/* ── Empty state ── */
.empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 80px 20px;
  color: var(--text-2);
}

.empty svg { width: 56px; height: 56px; color: var(--text-3); margin: 0 auto 16px; }
.empty p:first-of-type { font-weight: 500; font-size: 1rem; }
.empty-sub { font-size: 0.8125rem; color: var(--text-3); margin-top: 4px; }

.empty-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 16px;
  padding: 8px 20px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.empty-action:hover { background: var(--accent-hover); }
.empty-action:active { transform: scale(0.97); }

.load-more-btn {
  grid-column: 1 / -1;
  padding: 12px 24px;
  margin: 8px auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--accent);
  cursor: pointer;
  transition: all 0.15s;
}
.load-more-btn:hover { background: var(--accent-soft); border-color: var(--accent); }

/* ── Selection bar ── */
.sel-bar {
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 8px 16px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  animation: slideDown 0.2s ease;
}

@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

.sel-bar .count { font-size: 0.8125rem; font-weight: 500; color: var(--accent); }
.sel-bar .del-btn { font-size: 0.8125rem; font-weight: 500; color: var(--danger); background: none; border: none; cursor: pointer; padding: 4px 8px; border-radius: 6px; transition: background 0.15s; }
.sel-bar .del-btn:hover { background: var(--danger-soft); }

/* ── Context menu (desktop) ── */
#context-menu {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.04);
  min-width: 190px;
  padding: 4px;
  animation: ctxPop 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes ctxPop { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }

.ctx-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 0.8125rem;
  color: var(--text);
  background: none;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s;
  min-height: 38px;
}

.ctx-item:hover { background: var(--bg-hover); }
.ctx-item.danger { color: var(--danger); }
.ctx-item.danger:hover { background: var(--danger-soft); }

.ctx-icon { width: 16px; height: 16px; flex-shrink: 0; display: flex; }
.ctx-icon svg { width: 16px; height: 16px; }

/* ── Bottom sheet (mobile context menu) ── */
.bottom-sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0,0,0,0);
  transition: background 0.25s;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.bottom-sheet-backdrop.show { background: rgba(0,0,0,0.4); }

.bottom-sheet {
  background: white;
  border-radius: 16px 16px 0 0;
  width: 100%;
  max-width: 500px;
  padding: 8px 0 env(safe-area-inset-bottom, 16px);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  box-shadow: 0 -8px 30px rgba(0,0,0,0.12);
}

.bottom-sheet-backdrop.show .bottom-sheet { transform: translateY(0); }

.bottom-sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--text-3);
  margin: 4px auto 12px;
}

.bottom-sheet-title {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-3);
  padding: 0 20px 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.bottom-sheet-items { padding: 0 8px; }

.bottom-sheet-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  font-family: inherit;
  font-size: 0.9375rem;
  color: var(--text);
  background: none;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.12s;
  min-height: 48px;
}

.bottom-sheet-item:active { background: var(--bg-hover); }
.bottom-sheet-item.danger { color: var(--danger); }
.bottom-sheet-item .ctx-icon { width: 20px; height: 20px; }
.bottom-sheet-item .ctx-icon svg { width: 20px; height: 20px; }

/* ── Upload panel ── */
#upload-list {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.upload-header { padding: 10px 14px; font-size: 0.75rem; font-weight: 600; color: var(--text-2); border-bottom: 1px solid var(--border); }
/* A failed batch has to be readable without scrolling a 208px box, so the count
   leads and the header sticks to the top of the list. */
.upload-header-bad { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--danger); background: var(--danger-soft); }
.upload-retry { font-size: 0.6875rem; font-weight: 600; color: #fff; background: var(--danger); border: none; border-radius: 6px; padding: 4px 10px; cursor: pointer; white-space: nowrap; }
.upload-retry:disabled { opacity: 0.5; cursor: default; }
.upload-item { padding: 10px 14px; border-bottom: 1px solid var(--border); }
.upload-item:last-child { border-bottom: none; }

.prog-track { width: 100%; background: var(--bg); border-radius: 3px; height: 4px; overflow: hidden; }
.prog-bar { height: 100%; border-radius: 3px; background: var(--accent); transition: width 0.3s ease; }
.prog-bar.done { background: var(--success); }
.prog-bar.fail { background: var(--danger); }

.upload-preparing {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-2);
}

.preparing-spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translate(-50%, 0);
  z-index: 55;
  background: var(--text);
  color: white;
  border-radius: 12px;
  padding: 10px 18px;
  font-size: 0.8125rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
  transition: opacity 0.2s, transform 0.2s;
  max-width: 90vw;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.hide { opacity: 0; transform: translate(-50%, 8px); }
.toast.hidden { display: none; }

.toast-success { background: #2B8A3E; }
.toast-error { background: #C92A2A; }

.toast-icon { width: 16px; height: 16px; flex-shrink: 0; }
.toast-icon svg { width: 16px; height: 16px; }

/* ── Drop zone ── */
#drop-zone { transition: all 0.2s; border: 2px dashed transparent; border-radius: var(--radius-lg); min-height: 50vh; }

/* ── Full-screen drop overlay ── */
.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 45;
  background: rgba(34, 139, 230, 0.06);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s ease;
}

.drop-overlay-inner {
  text-align: center;
  padding: 40px 60px;
  background: white;
  border: 2px dashed var(--accent);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(34,139,230,0.15);
}

/* ── Skeleton loading ── */
.skel-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.skel-thumb {
  aspect-ratio: 1;
  background: linear-gradient(110deg, #F1F3F5 30%, #E9ECEF 50%, #F1F3F5 70%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease infinite;
}

.skel-body { padding: 10px; }

.skel-line {
  height: 10px;
  border-radius: 4px;
  background: linear-gradient(110deg, #F1F3F5 30%, #E9ECEF 50%, #F1F3F5 70%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease infinite;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── FAB (mobile) ── */
.fab {
  position: fixed;
  bottom: 24px;
  right: 20px;
  z-index: 39;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 12px;
}

.fab-btn {
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 14px rgba(0,0,0,0.15);
}

.fab-main {
  width: 56px;
  height: 56px;
  background: var(--accent);
  color: white;
}

.fab-main:active { transform: scale(0.92); }
.fab-main.open { background: var(--text-2); transform: rotate(45deg); }

.fab-secondary {
  width: 44px;
  height: 44px;
  background: white;
  color: var(--text);
  box-shadow: 0 2px 10px rgba(0,0,0,0.12);
}

.fab-secondary:active { transform: scale(0.92); }

.fab-menu {
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 10px;
}

.fab-menu:not(.hidden) .fab-secondary {
  animation: fabPop 0.2s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}

.fab-menu:not(.hidden) .fab-secondary:nth-child(1) { animation-delay: 0s; }
.fab-menu:not(.hidden) .fab-secondary:nth-child(2) { animation-delay: 0.05s; }
.fab-menu:not(.hidden) .fab-secondary:nth-child(3) { animation-delay: 0.1s; }

@keyframes fabPop {
  from { opacity: 0; transform: scale(0.5) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── Modal ── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.15s ease;
}

.modal-card {
  background: white;
  border-radius: 16px;
  padding: 24px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  animation: modalSlide 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalSlide {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-title { font-size: 0.9375rem; font-weight: 600; color: var(--text); margin-bottom: 16px; }

.modal-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.875rem;
  margin-bottom: 20px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.modal-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

.modal-btn {
  padding: 8px 18px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
}

.modal-cancel { background: var(--bg); color: var(--text-2); }
.modal-cancel:hover { background: var(--bg-hover); }
.modal-ok { background: var(--accent); color: white; }
.modal-ok:hover { background: var(--accent-hover); }
.modal-ok.danger { background: var(--danger); }
.modal-ok.danger:hover { background: #E03131; }

/* ── Viewer ── */
/* PhotoSwipe owns the gestures. Everything here is chrome: the old lightbox let
   the page show through the top of the backdrop, and captioned every photo with
   its filename. */

.pswp {
  --pswp-bg: #0B0B0C;
  --pswp-placeholder-bg: #1A1A1C;
  --pswp-icon-color: #FFFFFF;
  --pswp-icon-color-secondary: #0B0B0C;
  --pswp-icon-stroke-width: 0;
  --pswp-error-text-color: rgba(255,255,255,0.6);
}

/* buttons: circular, glassy, thumb-sized */
.pswp__button {
  width: 44px;
  height: 44px;
  margin: 6px 4px;
  border-radius: 999px;
  background: rgba(255,255,255,0.12) !important;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: #fff;
  opacity: 1;
  transition: background 0.15s, transform 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pswp__button:hover { background: rgba(255,255,255,0.22) !important; transform: scale(1.04); }
.pswp__button:active { transform: scale(0.96); }
.pswp__button svg { width: 20px; height: 20px; }

.pswp__top-bar {
  padding: max(8px, env(safe-area-inset-top)) 8px 8px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.55), transparent);
}

/* the caption replaces the old filename line */
.pswp__fv-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 28px 20px max(18px, env(safe-area-inset-bottom));
  text-align: center;
  color: rgba(255,255,255,0.92);
  font-family: 'Inter', -apple-system, system-ui, sans-serif;
  font-size: 0.9375rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  pointer-events: none;
  background: linear-gradient(to top, rgba(0,0,0,0.6), transparent);
  z-index: 10;
}

.pswp--ui-visible .pswp__fv-caption { opacity: 1; transition: opacity 0.2s; }
.pswp--ui-hidden .pswp__fv-caption { opacity: 0; }

/* video slides */
.fv-video-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* fill the slide and letterbox internally, so the element is correctly sized
   before the video's own metadata arrives */
.fv-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  outline: none;
}

.fv-toast {
  position: fixed;
  bottom: 88px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255,255,255,0.16);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #fff;
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 0.875rem;
  z-index: 100000;
  animation: fadeIn 0.15s ease;
}

/* ── Gallery ── */
.gallery-container { }

.gallery-section { margin-bottom: 24px; }

.gallery-date-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 4px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
}

.gallery-count {
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-3);
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 10px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
}

@media (min-width: 640px) { .gallery-grid { grid-template-columns: repeat(4, 1fr); gap: 4px; } }
@media (min-width: 768px) { .gallery-grid { grid-template-columns: repeat(5, 1fr); gap: 4px; } }
@media (min-width: 1024px) { .gallery-grid { grid-template-columns: repeat(6, 1fr); gap: 4px; } }

.gallery-item {
  cursor: pointer;
  overflow: hidden;
  border-radius: 4px;
  transition: opacity 0.15s;
}

.gallery-item:active { opacity: 0.8; }

.gallery-item-inner {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  background: var(--bg);
}

.gallery-item-inner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* No thumbnail and not safe to load the original: keep the tile quiet instead
   of showing a broken image. The video badge still reads on top. */
.gallery-item-inner img.no-preview {
  display: none;
}

.gallery-item-inner:has(img.no-preview) {
  background: linear-gradient(160deg, #E9ECEF 0%, #DEE2E6 100%);
}

.gallery-video-badge {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.2);
}

.gallery-video-badge svg {
  width: 32px;
  height: 32px;
  color: white;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

/* ── Animations ── */
@keyframes slideUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.card, .row { animation: slideUp 0.2s ease backwards; }
.card:nth-child(n+2), .row:nth-child(n+2) { animation-delay: calc(var(--i, 0) * 0.03s); }

/* ── Responsive ── */
.desktop-only { display: flex; }
.mobile-only { display: none; }

@media (max-width: 640px) {
  .file-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .breadcrumbs { font-size: 0.75rem; padding: 8px 16px; }
  .header-inner { padding: 0 12px; height: 50px; }
  .toolbar { padding: 10px 16px 0; }
  .desktop-only { display: none !important; }
  .mobile-only { display: flex; }
  .sm-hide { display: none; }
  .card-body { padding: 6px 8px; }
  .card-name { font-size: 0.6875rem; }
  .toast { bottom: 80px; }
  .lb-nav { display: none; }
  .lb-filename { bottom: 40px; }
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-thumb { background: var(--text-3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-2); }

/* Touch: prevent highlight on tap */
button, .card, .row, .gallery-item { -webkit-tap-highlight-color: transparent; }

/* Utility */
.hidden { display: none !important; }


/* ═══════════════════════════════════════════════════════════════════
   Shell redesign. This app holds a child's photographs and looked like
   a Dropbox folder listing. Below: large title instead of breadcrumb
   chips, edge-to-edge grid, albums instead of cards, and the
   file-manager tools folded away on a phone.
   ═══════════════════════════════════════════════════════════════════ */

body { background: #FCFCFD; }

/* ── header: quieter, and it gets out of the way ── */
.header {
  background: rgba(252,252,253,0.72);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: none;
}

.header-inner { height: 48px; }

.logo { font-size: 0.9375rem; letter-spacing: -0.025em; }

/* the storage meter is bookkeeping; it does not belong beside the photos */
.storage-indicator { display: none; }

/* ── large title, replacing the breadcrumb chip row ── */
.breadcrumbs {
  display: block;
  overflow: visible;
  padding: 2px 20px 10px;
}

.nav-back {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: none;
  border: 0;
  padding: 4px 6px 4px 0;
  margin-bottom: 1px;
  color: var(--accent);
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 6px;
  min-height: 32px;
}

.nav-back svg { width: 17px; height: 17px; }
.nav-back:hover { opacity: 0.7; }
.nav-back:active { opacity: 0.5; }

.page-title {
  font-size: 1.9375rem;
  line-height: 1.12;
  font-weight: 700;
  letter-spacing: -0.032em;
  color: var(--text);
  margin: 0;
  overflow-wrap: anywhere;
}

/* ── toolbar: two controls on a phone, the rest folds away ── */
.toolbar { padding: 8px 20px 0; }

.tab-pill {
  font-size: 0.875rem;
  padding: 6px 14px;
  border-radius: 999px;
  color: var(--text-2);
}

.tab-pill.active {
  background: var(--text);
  color: #fff;
}

.tab-pill:not(.active):hover { background: var(--bg-hover); color: var(--text); }

/* ── albums ── */
.album { cursor: pointer; }

.album-cover {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 14px;
  overflow: hidden;
  background: #ECEDEF;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05), 0 6px 16px -8px rgba(0,0,0,0.18);
  transition: transform 0.18s cubic-bezier(.2,.7,.3,1);
}

.album:active .album-cover { transform: scale(0.965); }
@media (hover: hover) { .album:hover .album-cover { transform: translateY(-2px); } }

.album-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }

.album-cover.is-empty {
  display: flex;
  align-items: center;
  justify-content: center;
}

.album-cover.is-empty svg { width: 34px; height: 34px; color: #B9BDC4; }
.album-cover:not(.is-empty) svg { display: none; }

.album-name {
  margin-top: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.01em;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 2px;
}

/* file cards lose their box too, so a folder of mixed content reads evenly */
.card {
  background: transparent;
  border: none;
  box-shadow: none;
}

.card .card-thumb {
  border-radius: 14px;
  overflow: hidden;
  background: #ECEDEF;
}

.card .card-body { padding: 8px 2px 0; }
.card .card-name { font-size: 0.875rem; font-weight: 500; }
.card .card-meta { font-size: 0.8125rem; color: var(--text-2); }

.file-grid { gap: 18px 14px; }

/* ── gallery: edge to edge ── */
.gallery-grid { gap: 2px; }

.gallery-date-header {
  padding: 0 4px 8px;
  font-size: 1.0625rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--text);
}

.gallery-count { color: var(--text-3); font-weight: 500; font-size: 0.875rem; }
.gallery-section { margin-bottom: 30px; }

@media (max-width: 640px) {
  .header-inner { padding: 0 14px; height: 46px; }
  .breadcrumbs { padding: 0 16px 8px; }
  .page-title { font-size: 1.75rem; }
  .toolbar { padding: 6px 16px 0; }

  /* search, sort, view toggle and new-folder are desktop concerns. The FAB
     already covers creating things on a phone. */
  .toolbar-right .sort-select,
  .toolbar-right #view-toggle,
  .toolbar-right #new-folder-btn { display: none; }

  /* photos run to both edges, the way every photo app does it */
  #gallery-view { margin-left: -20px; margin-right: -20px; }
  .gallery-grid { gap: 2px; }
  .gallery-date-header { padding: 0 16px 8px; }

  .file-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 18px 12px;
  }

  .album-cover { border-radius: 12px; }
}

/* ── Icons ── */
/* One rule for every glyph. Sizing comes from the icon() call, never from a
   Tailwind class or an inline style, which is how the old set drifted to five
   stroke widths and four sizing mechanisms. */
.icon {
  display: block;
  flex-shrink: 0;
}

[data-icon] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Lucide's play glyph is an outline. A hollow triangle sitting over a child's
   face reads as a hole; a solid one reads as a button. */
.gallery-video-badge .icon {
  fill: currentColor;
  stroke: none;
  width: 26px;
  height: 26px;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.45));
}

/* ── Gallery density ── */
/* Headers used to occupy a row each. With a header every 5 photos that was
   4,890px, 19% of the scroll in Levy. They now float over the grid instead. */
.gallery-date-header {
  position: sticky;
  top: 46px;
  z-index: 5;
  padding: 8px 4px;
  margin-bottom: 2px;
  background: linear-gradient(to bottom,
    rgba(252,252,253,0.94) 65%, rgba(252,252,253,0));
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
}

.gallery-section { margin-bottom: 10px; }

/* pinch to trade density for size; 3 across by default */
.gallery-grid { grid-template-columns: repeat(3, 1fr); }
#gallery-grid[data-cols="2"] .gallery-grid { grid-template-columns: repeat(2, 1fr); }
#gallery-grid[data-cols="4"] .gallery-grid { grid-template-columns: repeat(4, 1fr); }

@media (min-width: 640px) {
  .gallery-date-header { top: 48px; }
  .gallery-grid { grid-template-columns: repeat(4, 1fr); }
  #gallery-grid[data-cols="2"] .gallery-grid { grid-template-columns: repeat(3, 1fr); }
  #gallery-grid[data-cols="4"] .gallery-grid { grid-template-columns: repeat(6, 1fr); }
}

@media (min-width: 1024px) {
  .gallery-grid { grid-template-columns: repeat(6, 1fr); }
  #gallery-grid[data-cols="2"] .gallery-grid { grid-template-columns: repeat(4, 1fr); }
  #gallery-grid[data-cols="4"] .gallery-grid { grid-template-columns: repeat(8, 1fr); }
}

/* ── Media filter ── */
.media-filter {
  display: flex;
  gap: 2px;
  padding: 2px;
  background: var(--bg-hover);
  border-radius: 999px;
}

.media-filter.hidden { display: none; }

.mf-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  border: 0;
  background: transparent;
  border-radius: 999px;
  padding: 5px 11px;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.mf-btn.active { background: var(--bg-card); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,0.08); }
.mf-btn:disabled { opacity: 0.38; cursor: default; }
.mf-btn:not(.active):not(:disabled):hover { color: var(--text); }

.mf-n { font-size: 0.75rem; font-weight: 500; color: var(--text-3); font-variant-numeric: tabular-nums; }
.mf-btn.active .mf-n { color: var(--text-2); }

@media (max-width: 640px) {
  /* Measured at 393px: Files, Gallery and three counted segments overflowed the
     row and pushed the search icon off screen. The counts are the least useful
     part, so they are what goes. */
  .mf-btn { padding: 5px 10px; }
  .mf-n { display: none; }
}

.search-wrapper.hidden { display: none; }

/* ── Undo affordance ── */
.toast-action {
  margin-left: 10px;
  border: 0;
  background: rgba(255,255,255,0.18);
  color: inherit;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
  flex-shrink: 0;
}

.toast-action:hover { background: rgba(255,255,255,0.3); }
.toast-action:active { transform: scale(0.96); }

/* ── Recently Deleted ── */
.trash-note { color: var(--text-2); font-size: 0.8125rem; padding: 0 2px 14px; }

.trash-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 2px;
  border-bottom: 1px solid var(--border);
}

.trash-thumb {
  width: 48px; height: 48px;
  border-radius: 8px;
  overflow: hidden;
  background: #ECEDEF;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3);
  flex-shrink: 0;
}

.trash-thumb img { width: 100%; height: 100%; object-fit: cover; }
.trash-meta { flex: 1; min-width: 0; }
.trash-name { font-size: 0.9375rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trash-sub { font-size: 0.8125rem; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.trash-restore {
  border: 0;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  flex-shrink: 0;
}

.trash-restore:hover { background: #D0EBFF; }
.trash-purge { color: var(--text-3); flex-shrink: 0; }
.trash-purge:hover { color: var(--danger); background: var(--danger-soft); }

/* ── Scrubber ── */
/* A narrow strip on the right edge. Narrow on purpose: an ordinary scroll over
   the photos must never land on it. */
.fv-scrub {
  position: fixed;
  top: 96px;
  right: 0;
  bottom: 96px;
  width: 34px;
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
  touch-action: none;
}

.fv-scrub.visible { opacity: 1; pointer-events: auto; }

.fv-scrub-thumb {
  position: absolute;
  right: 5px;
  width: 6px;
  height: 46px;
  border-radius: 999px;
  background: rgba(0,0,0,0.34);
  transition: background 0.15s, width 0.15s;
}

.fv-scrub.dragging .fv-scrub-thumb { width: 8px; background: rgba(0,0,0,0.62); }

.fv-scrub-bubble {
  position: absolute;
  right: 22px;
  height: 46px;
  display: none;
  align-items: center;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(24,24,26,0.92);
  backdrop-filter: blur(10px);
  color: #fff;
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  pointer-events: none;
}

.fv-scrub.dragging .fv-scrub-bubble { display: flex; }

@media (min-width: 640px) {
  .fv-scrub { width: 26px; }
}


/* ── Gallery selection ── */
.gallery-item { position: relative; }

#gallery-grid.selecting .gallery-item { cursor: pointer; }

.gallery-item.picked .gallery-item-inner {
  transform: scale(0.88);
  border-radius: 8px;
  overflow: hidden;
  transition: transform 0.14s cubic-bezier(.2,.7,.3,1);
}

.gallery-item.picked::after {
  content: '';
  position: absolute;
  right: 6px; bottom: 6px;
  width: 21px; height: 21px;
  border-radius: 999px;
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center/14px no-repeat;
  box-shadow: 0 0 0 2px #fff;
  pointer-events: none;
}

/* Floating, so it never covers the last row of photos the way a docked bar
   would. */
.gal-selbar {
  position: fixed;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 9px 10px 9px 18px;
  border-radius: 999px;
  background: rgba(24,24,26,0.94);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  box-shadow: 0 8px 28px -6px rgba(0,0,0,0.45);
  color: #fff;
  max-width: calc(100vw - 24px);
}

.gal-selbar.hidden { display: none; }
.gs-count { font-size: 0.875rem; font-weight: 600; white-space: nowrap; }
.gs-actions { display: flex; align-items: center; gap: 2px; }

.gs-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  border: 0;
  background: transparent;
  color: #fff;
  font-family: inherit;
  font-size: 0.6875rem;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 12px;
  cursor: pointer;
  min-width: 52px;
}

.gs-btn:hover { background: rgba(255,255,255,0.14); }
.gs-btn:active { transform: scale(0.94); }
.gs-danger { color: #FF8787; }
.gs-done { font-size: 0.875rem; font-weight: 600; color: var(--accent); min-width: auto; }

/* the selection bar owns the bottom while it is up */
body.has-selection .fab { display: none; }


/* ── FAB menu: words and colour ── */
/* Three identical white circles told you nothing about what they did. Each
   action now says its name and owns a colour, all drawn from the palette
   already used elsewhere in the app. */
.fab-row {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
}

.fab-label {
  background: rgba(24,24,26,0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  padding: 6px 12px;
  border-radius: 999px;
  white-space: nowrap;
  box-shadow: 0 2px 10px rgba(0,0,0,0.18);
}

/* the animation used to key off .fab-secondary, which is now nested a level
   deeper inside .fab-row */
.fab-menu:not(.hidden) .fab-row {
  animation: fabPop 0.2s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}

.fab-menu:not(.hidden) .fab-row:nth-child(1) { animation-delay: 0s; }
.fab-menu:not(.hidden) .fab-row:nth-child(2) { animation-delay: 0.05s; }
.fab-menu:not(.hidden) .fab-row:nth-child(3) { animation-delay: 0.1s; }

.fab-secondary { color: #fff; }

.fab-photos { background: #228BE6; }   /* the app accent */
.fab-camera { background: #845EF7; }   /* the purple already used for video */
.fab-folder { background: #F59F00; }   /* amber, distinct from both */

.fab-photos:hover { background: #1C7ED6; }
.fab-camera:hover { background: #7048E8; }
.fab-folder:hover { background: #E8590C; }

/* Rows are wider than the button now, so centre alignment would push the
   circles off the main FAB's axis. */
.fab, .fab-menu { align-items: flex-end; }

/* The 44px action circles sit inside rows that are wider than the 56px main
   button, so right-aligning the row left them 6px off its axis. Nudge the
   stack so every circle shares the main button's centre line. */
.fab-menu { padding-right: 6px; }


/* ── Motion on the photos ── */
/* The chrome already animated; the photographs did not. 387 thumbnails used to
   snap in as they decoded, and changing a filter swapped the grid in a frame.
   A tile only starts hidden when we are certain something will reveal it: load,
   error, or a 4s timeout, and a cached image skips the fade outright. */

.gallery-item {
  opacity: 0;
  transform: scale(0.985);
}

.gallery-item.shown {
  opacity: 1;
  transform: none;
  transition: opacity 0.26s ease, transform 0.26s cubic-bezier(.2,.7,.3,1);
  transition-delay: calc(var(--i, 0) * 14ms);
}

/* already in cache: no fade at all, or revisiting a folder flickers */
.gallery-item.instant { transition: none; transition-delay: 0s; }

/* the whole grid eases between filter, sort and density changes */
.gallery-container { transition: opacity 0.2s ease; }
.gallery-container.swapping { opacity: 0; }

/* sections settle rather than land */
.gallery-section { animation: sectionIn 0.34s cubic-bezier(.2,.7,.3,1) backwards; }

@keyframes sectionIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* albums and file cards get the same courtesy */
.album, .card { animation: sectionIn 0.3s cubic-bezier(.2,.7,.3,1) backwards; }

@media (prefers-reduced-motion: reduce) {
  .gallery-item,
  .gallery-item.shown,
  .gallery-container,
  .gallery-section,
  .album,
  .card {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
    animation: none !important;
  }
}


/* ── Password gate ── */
.gate {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #FCFCFD;
}

.gate.hidden { display: none; }

.gate-card {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  text-align: center;
}

.gate-mark {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}

.gate-sub { margin-top: 6px; color: var(--text-2); font-size: 0.9375rem; }

.gate-input {
  margin-top: 22px;
  padding: 14px 16px;
  font-family: inherit;
  font-size: 1.0625rem;          /* 17px: iOS will not zoom the page on focus */
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  outline: none;
  text-align: center;
}

.gate-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.gate-go {
  margin-top: 10px;
  padding: 14px 16px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.gate-go:active { transform: scale(0.985); }
.gate-msg { margin-top: 12px; min-height: 20px; color: var(--danger); font-size: 0.875rem; }

.gate-link {
  margin-top: 4px;
  border: 0;
  background: none;
  color: var(--text-3);
  font-family: inherit;
  font-size: 0.8125rem;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.gate-link:hover { color: var(--text-2); }


/* ── Gate: the album behind frosted glass ── */
/* The backgrounds are 32px pre-blurred derivatives generated server side. The
   CSS below is presentation only; it is never what keeps the photographs
   private, because this page is served to people without the password. */

.gate { overflow: hidden; }

.gate-bg {
  position: absolute;
  inset: -6%;
  z-index: 0;
}

.gate-slide {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0;
  transform: scale(1.04);
  transition: opacity 1.6s ease;
  will-change: opacity, transform;
}

.gate-slide.on {
  opacity: 1;
  animation: gateDrift 14s ease-in-out infinite alternate;
}

@keyframes gateDrift {
  from { transform: scale(1.04) translate3d(-1.2%, -0.8%, 0); }
  to   { transform: scale(1.12) translate3d(1.2%, 0.8%, 0); }
}

/* the frost, and enough scrim that the card stays readable over anything */
.gate-frost {
  position: absolute;
  inset: 0;
  z-index: 1;
  /* Lighter than it first was: at 34px blur over a 0.8 scrim the photographs
     vanished into a cream wash. The privacy comes from the 32px source, not
     from this, so the frost can be soft enough to let the colour move. */
  backdrop-filter: blur(14px) saturate(150%);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  background: linear-gradient(180deg,
    rgba(252,252,253,0.30) 0%,
    rgba(252,252,253,0.46) 42%,
    rgba(252,252,253,0.72) 78%,
    rgba(252,252,253,0.86) 100%);
}

.gate-card { position: relative; z-index: 2; }

.gate-mark { text-shadow: 0 1px 2px rgba(255,255,255,0.9); }
.gate-sub { text-shadow: 0 1px 2px rgba(255,255,255,0.85); }

/* the field needs its own surface once there is imagery behind it */
.gate-input {
  background: rgba(255,255,255,0.97);
  box-shadow: 0 2px 10px -2px rgba(0,0,0,0.12);
}

.gate-go { box-shadow: 0 4px 14px -4px rgba(34,139,230,0.55); }

@media (prefers-reduced-motion: reduce) {
  .gate-slide, .gate-slide.on {
    animation: none !important;
    transition: none !important;
    transform: none !important;
  }
}


/* sign-out lives in the header, quiet until you look for it */
#signout-btn { color: var(--text-3); }
#signout-btn:hover { color: var(--danger); background: var(--danger-soft); }


/* ── One row instead of three ── */
/* The place used to be named three times over: a switch with one setting, a
   page title, and the album itself. It lives in the header now. */
.header-title {
  font-size: 1.0625rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--text);
  display: none;
}

.header-title.on { display: inline; }

/* a space switch with a single option is furniture */
.spaces.solo { display: none; }

/* the title row collapses entirely when the header carries the name */
.breadcrumbs.empty { display: none; padding: 0; }
body.title-in-header .toolbar { padding-top: 10px; padding-bottom: 6px; }


/* ── Grid density ── */
/* Four across by default rather than three: 387 photos is a lot of scrolling,
   and a grid exists to show many at once. Pinch still trades density for size,
   now across four steps rather than three. */
#gallery-grid .gallery-grid,
#gallery-grid[data-cols="4"] .gallery-grid { grid-template-columns: repeat(4, 1fr); }
#gallery-grid[data-cols="5"] .gallery-grid { grid-template-columns: repeat(5, 1fr); }
#gallery-grid[data-cols="3"] .gallery-grid { grid-template-columns: repeat(3, 1fr); }
#gallery-grid[data-cols="2"] .gallery-grid { grid-template-columns: repeat(2, 1fr); }

@media (min-width: 640px) {
  #gallery-grid .gallery-grid,
  #gallery-grid[data-cols="4"] .gallery-grid { grid-template-columns: repeat(6, 1fr); }
  #gallery-grid[data-cols="5"] .gallery-grid { grid-template-columns: repeat(8, 1fr); }
  #gallery-grid[data-cols="3"] .gallery-grid { grid-template-columns: repeat(5, 1fr); }
  #gallery-grid[data-cols="2"] .gallery-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 1024px) {
  #gallery-grid .gallery-grid,
  #gallery-grid[data-cols="4"] .gallery-grid { grid-template-columns: repeat(8, 1fr); }
  #gallery-grid[data-cols="5"] .gallery-grid { grid-template-columns: repeat(10, 1fr); }
  #gallery-grid[data-cols="3"] .gallery-grid { grid-template-columns: repeat(6, 1fr); }
  #gallery-grid[data-cols="2"] .gallery-grid { grid-template-columns: repeat(4, 1fr); }
}

/* the play badge has to shrink with the tile or it swallows a 78px thumbnail */
#gallery-grid[data-cols="5"] .gallery-video-badge .icon { width: 18px; height: 18px; }
#gallery-grid[data-cols="4"] .gallery-video-badge .icon { width: 21px; height: 21px; }
