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

:root {
  color-scheme: light;
  --blue: #007aff;
  --blue-dark: #0066d6;
  --gray: #5f6368;
  --border: #e8eaed;
  --bg: #f8f9fa;
  --surface: #ffffff;
  --surface-muted: #f1f3f4;
  --header-bg: rgba(255,255,255,.96);
  --text: #202124;
  --text-secondary: #3c4043;
  --shadow: rgba(32,33,36,.16);
  --danger: #d93025;
  --radius: 12px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --blue: #0a84ff;
  --blue-dark: #0071e3;
  --gray: #bdc1c6;
  --border: #3c4043;
  --bg: #111315;
  --surface: #1f2023;
  --surface-muted: #292a2d;
  --header-bg: rgba(31,32,35,.96);
  --text: #e8eaed;
  --text-secondary: #bdc1c6;
  --shadow: rgba(0,0,0,.42);
  --danger: #f28b82;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }

/* Pinch-zoom is enabled app-wide (viewport allows it, for zooming into lightbox photos), but
   double-tap-to-zoom on a button/link is just an accidental-zoom hazard on a touch UI — this
   keeps taps registering immediately without disabling zoom on actual photo/video content. */
button, a { touch-action: manipulation; }

/* ── Login ── */

#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 24px;
}

.login-wrap {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.login-logo { margin-bottom: 4px; }

.login-wrap h1 { font-size: 26px; font-weight: 600; }

.subtitle { color: var(--gray); font-size: 15px; margin-bottom: 8px; }

#login-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#login-form input {
  padding: 15px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 16px;
  outline: none;
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s;
}

#login-form input:focus { border-color: var(--blue); }

.password-field { position: relative; }

.password-field input { width: 100%; padding-right: 48px; }

#password-toggle {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  padding: 0 14px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray);
}

#login-btn {
  padding: 15px;
  background: var(--blue);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s;
}

#login-btn:active { background: var(--blue-dark); }
#login-btn:disabled { opacity: .6; cursor: default; }

.error { color: var(--danger); font-size: 14px; text-align: center; }

.store-downloads {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
}

.store-download {
  display: block;
  border-radius: 6px;
}

.store-download:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--blue) 42%, transparent);
  outline-offset: 3px;
}

.store-download img {
  display: block;
  width: auto;
  height: 48px;
}

/* ── App layout ── */

#app-screen {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(16px);
}

header span { font-size: 17px; font-weight: 600; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.header-icon-button {
  width: 40px;
  height: 40px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray);
  display: grid;
  place-items: center;
  padding: 0;
}

#settings-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  overflow: auto;
  background: var(--bg);
  color: var(--text);
}

.settings-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
  padding: env(safe-area-inset-top) 18px 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.settings-header h2 {
  margin: 0;
  font-size: 20px;
}

.settings-content {
  width: min(100%, 680px);
  margin: 0 auto;
  padding: 20px 18px calc(32px + env(safe-area-inset-bottom));
}

.connection-list {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.connection-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.connection-details {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.connection-details span,
.connection-details small {
  overflow-wrap: anywhere;
  color: var(--gray);
}

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

.connection-actions button {
  border: 0;
  background: transparent;
  color: var(--blue);
  font: inherit;
  cursor: pointer;
}

.connection-actions button[data-action="remove"] {
  color: var(--danger);
}

.settings-add-button {
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  font: inherit;
  font-weight: 700;
}

.connection-form {
  display: grid;
  gap: 14px;
}

.connection-form label {
  display: grid;
  gap: 6px;
  color: var(--gray);
  font-size: 13px;
  font-weight: 600;
}

.connection-form input {
  width: 100%;
  min-height: 48px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.server-availability-warning {
  grid-column: 1 / -1;
  width: 100%;
  margin: 4px 0 12px;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--blue) 35%, var(--border));
  border-radius: 6px;
  background: color-mix(in srgb, var(--blue) 9%, var(--surface));
  color: var(--text);
  font-size: 13px;
}

@media (max-width: 560px) {
  .connection-row { flex-direction: column; }
  .connection-actions { justify-content: flex-start; }
}

/* ── Tabs ── */

.tab-pane {
  padding: 16px 16px 96px;
  flex: 1;
}

.section-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--gray);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 14px;
}

/* ── Album grid ── */

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

.album-card {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,.1);
  cursor: pointer;
  position: relative;
  aspect-ratio: 4/3;
  transition: transform .1s;
  -webkit-user-select: none;
  user-select: none;
}

.album-card:active { transform: scale(.96); }

.album-thumb {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.album-thumb-placeholder {
  position: absolute;
  inset: 0;
  background: var(--border);
}

.album-footer {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 24px 10px 8px;
  background: linear-gradient(transparent, rgba(0,0,0,.55));
  color: white;
}

.album-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.album-count { font-size: 12px; opacity: .85; margin-top: 1px; }
.album-last-upload { font-size: 11px; opacity: .75; margin-top: 2px; }

/* ── Upload source sheet ── */

#sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 110; /* above #lightbox (100) — this sheet also opens from inside the lightbox now */
  display: flex;
  align-items: flex-end;
}

#upload-sheet {
  width: 100%;
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  padding: 20px 16px calc(16px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sheet-title {
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  color: var(--gray);
  margin-bottom: 6px;
}

.sheet-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
}

.sheet-btn:active { background: var(--bg); }
.sheet-btn svg { flex-shrink: 0; color: var(--blue); }

.sheet-btn:disabled {
  opacity: .55;
  cursor: default;
  color: var(--gray);
}

.sheet-also-add {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 16px;
  margin-bottom: 4px;
}

.sheet-subtitle {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray);
  text-transform: uppercase;
  letter-spacing: .02em;
  padding: 6px 0;
}

.sheet-checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  font-size: 15px;
  color: var(--text);
  cursor: pointer;
}

.sheet-checkbox-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sheet-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 4px;
}

.sheet-field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray);
  text-transform: uppercase;
  letter-spacing: .02em;
}

.sheet-select {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  background: var(--surface);
  color: var(--text);
}

.sheet-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.sheet-actions .sheet-cancel {
  flex: 1;
  margin-top: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.sheet-primary-btn {
  flex: 1;
  padding: 14px;
  background: var(--blue);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}

.sheet-primary-btn:active { background: var(--blue-dark); }

.sheet-cancel {
  margin-top: 4px;
  padding: 14px;
  border: none;
  background: none;
  font-size: 15px;
  font-weight: 500;
  color: var(--gray);
  cursor: pointer;
}

.album-skeleton {
  aspect-ratio: 4/3;
  background: var(--border);
  border-radius: var(--radius);
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .5; }
}

/* ── Upload review ── */

#review-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: var(--surface);
  display: flex;
  flex-direction: column;
}

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

.review-title {
  font-size: 15px;
  font-weight: 600;
}

.review-cancel {
  background: none;
  border: none;
  font-size: 26px;
  line-height: 1;
  color: var(--gray);
  cursor: pointer;
  padding: 4px 8px;
}

.review-grid {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  overscroll-behavior: contain;
}

.review-grid-content {
  position: relative;
  width: 100%;
  min-height: 100%;
}

.review-cell {
  position: absolute;
  top: 0;
  left: 0;
  min-width: 0;
  min-height: 0;
  background: var(--border);
  border: 1px solid var(--surface);
  box-sizing: border-box;
  overflow: hidden;
  will-change: transform;
}

.review-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.review-video-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray);
  padding: 8px;
  text-align: center;
  font-size: 11px;
  overflow-wrap: anywhere;
}

.review-video-badge {
  position: absolute;
  left: 6px;
  bottom: 6px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: #fff;
  background: rgba(0,0,0,.58);
  font-size: 10px;
  pointer-events: none;
  z-index: 1;
}

.review-cell-duplicate .review-thumb,
.review-cell-duplicate .review-video-placeholder {
  opacity: .45;
}

.review-duplicate-badge {
  position: absolute;
  bottom: 4px;
  left: 4px;
  right: 26px;
  font-size: 10px;
  font-weight: 600;
  color: #fff;
  background: rgba(0,0,0,.6);
  padding: 2px 6px;
  border-radius: 10px;
  pointer-events: none;
  z-index: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.review-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,.55);
  color: #fff;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

/* Tap-to-tag while reviewing: arm an album via .review-tag-btn, then tap individual photos in
   the grid to include/exclude just those from it — see openReviewSheet in app.js. */
.review-tag-btn {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  margin-top: 6px;
}

.review-tag-btn:first-of-type { margin-top: 0; }

.review-tag-btn-active {
  border-color: var(--blue);
  background: color-mix(in srgb, var(--blue) 10%, transparent);
  color: var(--blue);
  font-weight: 600;
}

.review-grid-tag-mode .review-cell { cursor: pointer; }

.review-cell-tagged {
  outline: 2px solid var(--blue);
  outline-offset: -2px;
}

.review-tag-badges {
  position: absolute;
  top: 4px;
  left: 4px;
  display: flex;
  gap: 3px;
  z-index: 1;
  pointer-events: none;
}

.review-tag-badge {
  background: var(--blue);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 8px;
  white-space: nowrap;
}

.review-footer {
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
}

.review-preparation {
  margin: 0 0 10px;
  color: var(--gray);
  font-size: 12px;
}

.review-preparation-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 18px;
}

.review-preparation-count {
  font-variant-numeric: tabular-nums;
}

.review-preparation-progress {
  height: 3px;
  margin-top: 5px;
  overflow: hidden;
  background: var(--border);
  border-radius: 2px;
}

.review-preparation-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--blue);
  border-radius: inherit;
  transition: width .18s ease;
}

.review-preparation-progress-active span {
  animation: review-progress-pulse 1.2s ease-in-out infinite alternate;
}

.review-preparation-ready {
  display: none;
}

@keyframes review-progress-pulse {
  from { transform: translateX(0); }
  to { transform: translateX(185%); }
}

.review-upload-btn {
  width: 100%;
  padding: 14px;
  background: var(--blue);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.review-upload-btn:active { background: var(--blue-dark); }
.review-upload-btn:disabled { opacity: .5; cursor: default; }

.review-retry-btn {
  width: 100%;
  min-height: 44px;
  margin-bottom: 8px;
  border: 1px solid var(--blue);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--blue);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.review-retry-btn:disabled { opacity: .5; cursor: default; }

.duplicate-confirm {
  width: min(calc(100% - 32px), 420px);
  margin: auto;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 12px 36px rgba(0, 0, 0, .28);
}

.duplicate-confirm::backdrop {
  background: rgba(0, 0, 0, .58);
}

.duplicate-confirm h2 {
  margin: 0 0 8px;
  font-size: 20px;
}

.duplicate-confirm p {
  margin: 0 0 18px;
  color: var(--gray);
  line-height: 1.45;
}

.duplicate-confirm-actions {
  display: grid;
  gap: 8px;
}

.duplicate-confirm-actions button {
  min-height: 46px;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.duplicate-confirm .primary-button {
  border: 1px solid var(--blue);
  background: var(--blue);
  color: #fff;
}

.duplicate-confirm .secondary-button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

/* ── Google import duplicate review ── */
/* A Google Photos import auto-skips items that already match something in the target album by
   filename+taken-time (see app.js's googleItemKey) — the match is reliable enough that stopping
   the whole import to confirm every one up front would add friction to what's normally a
   correct, silent skip. Instead a dismissible notice (.dup-notice) appears after the import
   finishes; opening it shows side-by-side thumbnails so a rare false positive (coincidental
   filename collision) can be caught and imported on demand. */

.dup-notice {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.dup-notice span { flex: 1; color: var(--text); }

.dup-notice-review {
  background: none;
  border: none;
  color: var(--blue);
  font-size: 13px;
  font-weight: 600;
  padding: 0;
  cursor: pointer;
}

.dup-notice-dismiss {
  background: none;
  border: none;
  color: var(--gray);
  font-size: 18px;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
}

#dup-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: var(--surface);
  display: flex;
  flex-direction: column;
}

.dup-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.dup-title {
  font-size: 15px;
  font-weight: 600;
}

.dup-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px;
}

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

.dup-thumbs {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.dup-thumb {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--border);
  display: block;
}

.dup-vs {
  color: var(--gray);
  font-size: 11px;
  flex-shrink: 0;
}

.dup-info {
  flex: 1;
  min-width: 0;
}

.dup-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dup-sublabel {
  font-size: 12px;
  color: var(--gray);
  margin-top: 2px;
}

.dup-import-btn {
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--blue);
  color: var(--blue);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}

.dup-import-btn:disabled {
  border-color: var(--border);
  color: var(--gray);
  cursor: default;
}

.dup-footer {
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
}

.dup-continue-btn {
  width: 100%;
  padding: 14px;
  background: var(--blue);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.dup-continue-btn:active { background: var(--blue-dark); }

/* ── Upload progress ── */

#upload-status {
  margin-top: 20px;
  padding: 16px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0,0,0,.1);
}

.progress-wrap {
  background: var(--border);
  border-radius: 4px;
  height: 6px;
  overflow: hidden;
  margin-bottom: 10px;
}

#upload-bar {
  background: var(--blue);
  height: 100%;
  width: 0%;
  border-radius: 4px;
  transition: width .3s ease;
}

#upload-msg {
  font-size: 14px;
  color: var(--gray);
  text-align: center;
}

.upload-retry-btn {
  display: block;
  width: 100%;
  min-height: 44px;
  margin-top: 12px;
  border: 1px solid var(--blue);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--blue);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

#google-picker-link {
  display: block;
  margin-top: 14px;
  padding: 13px;
  background: var(--blue);
  color: white;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 500;
  text-align: center;
  text-decoration: none;
}

#google-picker-link:active { background: var(--blue-dark); }

/* ── Photo feed ── */

.feed-pane {
  padding: 0 0 96px !important;
  background: var(--bg);
}

#feed-grid {
  background: var(--bg);
}

#feed-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 16px;
  padding: 10px 16px 2px;
}

.feed-toolbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: none;
  background: none;
  color: var(--blue);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 2px;
}

.feed-toolbar-btn svg { width: 16px; height: 16px; flex: none; }

.sort-choice {
  width: 100%;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 2px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.sort-choice span { display: grid; gap: 4px; }
.sort-choice small { color: var(--gray); }
.sort-choice.selected { color: var(--blue); }
.sort-choice > svg { width: 20px; height: 20px; flex: none; }

.photo-select-mark {
  display: none;
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: rgba(0,0,0,.35);
  z-index: 2;
}

#feed-grid.select-mode .photo-select-mark { display: block; }

.photo-cell.selected .photo-select-mark {
  background: var(--blue);
  border-color: var(--blue);
}

.photo-cell.selected .photo-select-mark::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.photo-cell.selected {
  outline: 3px solid var(--blue);
  outline-offset: -3px;
}

#feed-batch-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 21;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

#feed-batch-cancel {
  border: none;
  background: none;
  color: var(--gray);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

#feed-batch-count {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

#feed-batch-add {
  border: none;
  background: var(--blue);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: var(--radius);
  cursor: pointer;
}

#feed-batch-add:disabled {
  background: var(--border);
  color: var(--gray);
  cursor: default;
}

.feed-section { margin-bottom: 4px; }

.feed-date {
  padding: 16px 16px 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  background: var(--bg);
  letter-spacing: .1px;
}

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

.photo-cell {
  aspect-ratio: 1;
  background: var(--border);
  overflow: hidden;
  cursor: pointer;
  position: relative;
}

.photo-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 22px;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,.6);
  pointer-events: none;
  z-index: 1;
}

.photo-owner {
  position: absolute;
  bottom: 5px;
  left: 5px;
  font-size: 10px;
  font-weight: 600;
  color: #fff;
  background: rgba(0,0,0,.45);
  padding: 2px 6px;
  border-radius: 10px;
  pointer-events: none;
  z-index: 1;
  text-shadow: 0 1px 2px rgba(0,0,0,.5);
}

.like-badge {
  position: absolute;
  bottom: 4px;
  right: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(0,0,0,.45);
  border: none;
  border-radius: 12px;
  padding: 6px 10px;
  cursor: pointer;
  z-index: 1;
}

.like-badge .heart {
  font-size: 15px;
  color: #fff;
  line-height: 1;
}

.like-badge.liked .heart { color: #ea4335; }

.like-badge .like-count {
  font-size: 11px;
  font-weight: 600;
  color: #fff;
}

.photo-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.feed-empty {
  padding: 64px 16px;
  text-align: center;
  color: var(--gray);
  font-size: 15px;
}

.feed-end {
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
  text-align: center;
  color: var(--gray);
  font-size: 13px;
}

.load-more-btn {
  padding: 12px 28px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  color: var(--blue);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.load-more-btn:active { background: var(--bg); }
.load-more-btn:disabled { opacity: .6; cursor: default; }

.activity-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.activity-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--gray);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.activity-text {
  flex: 1;
  font-size: 14px;
  color: var(--text);
}

.activity-time {
  font-size: 12px;
  color: var(--gray);
  flex-shrink: 0;
}

.activity-thumb {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}

/* Lightbox */
#lightbox {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

#lightbox-content { display: contents; }

#lightbox img,
#lightbox video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  /* pinch-zoom stays enabled (viewport allows it), but double-tap-zoom would fight with our
     own double-tap-to-like gesture on the same element, so only that's turned off here. */
  touch-action: manipulation;
}

#lightbox-prev,
#lightbox-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,.35);
  color: white;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}

#lightbox-prev { left: 12px; }
#lightbox-next { right: 12px; }

/* TikTok-style vertical action rail, right edge — replaces the old horizontal bottom bar */
#lightbox-rail {
  position: absolute;
  right: 10px;
  bottom: calc(90px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  z-index: 6;
}

#lightbox-rail.video-actions {
  bottom: calc(138px + env(safe-area-inset-bottom));
}

#lightbox-rail button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 0;
}

/* Flat, single-color line icons (TikTok-style) instead of platform emoji, which rendered
   inconsistently across devices and mixed colorful glyphs with the plain heart character. */
#lightbox-rail .rail-svg {
  filter: drop-shadow(0 1px 3px rgba(0,0,0,.5));
}

#lightbox-like-btn.liked .heart-icon { fill: #ea4335; stroke: #ea4335; }
#lightbox-delete-btn { color: #ff453a !important; }

#lightbox-rail .rail-count {
  font-size: 12px;
  font-weight: 600;
  text-shadow: 0 1px 3px rgba(0,0,0,.6);
}

/* Always-visible "Liked by …" text, bottom-left — mirrors the rail's bottom offset on the
   opposite side so it reads like a caption rather than competing with the action buttons. */
#lightbox-liked-by {
  position: absolute;
  left: 14px;
  right: 70px;
  bottom: calc(90px + env(safe-area-inset-bottom));
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  text-shadow: 0 1px 3px rgba(0,0,0,.6);
  z-index: 6;
}

/* Heart-burst on double-tap, TikTok/Instagram-style */
.heart-burst {
  position: absolute;
  transform: translate(-50%, -50%) scale(0);
  font-size: 90px;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0,0,0,.5);
  pointer-events: none;
  z-index: 7;
  animation: heart-burst .7s ease-out forwards;
}

@keyframes heart-burst {
  0% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
  15% { transform: translate(-50%, -50%) scale(1.15); opacity: 1; }
  30% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 0; }
}

/* Bottom-sheet comments drawer — slides up from off-screen instead of toggling display,
   dismissible by tapping the backdrop or dragging the handle down */
#lightbox-comments-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
  z-index: 5;
}

#lightbox-comments-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

#lightbox-comments-panel {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 60vh;
  background: rgba(20,20,20,.96);
  backdrop-filter: blur(6px);
  border-radius: 16px 16px 0 0;
  display: flex;
  flex-direction: column;
  padding: 0 16px calc(10px + env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform .25s ease;
  pointer-events: none;
  z-index: 6;
}

#lightbox-comments-panel.open {
  transform: translateY(0);
  pointer-events: auto;
}

.drawer-handle {
  width: 36px;
  height: 4px;
  background: rgba(255,255,255,.35);
  border-radius: 2px;
  margin: 10px auto;
  flex-shrink: 0;
}

#lightbox-comments-list {
  overflow-y: auto;
  flex: 1;
  min-height: 40px;
  margin-bottom: 10px;
}

.comment-item {
  display: flex;
  gap: 8px;
  padding: 6px 0;
  font-size: 14px;
  color: #fff;
}

.comment-author {
  font-weight: 600;
  flex-shrink: 0;
}

.comment-text {
  color: #e8eaed;
  word-break: break-word;
}

.comments-empty {
  color: rgba(255,255,255,.6);
  font-size: 14px;
  text-align: center;
  padding: 12px 0;
}

#lightbox-comment-form {
  display: flex;
  gap: 8px;
}

#lightbox-comment-form input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 20px;
  border: none;
  background: rgba(255,255,255,.15);
  color: #fff;
  font-size: 14px;
  outline: none;
}

#lightbox-comment-form input::placeholder { color: rgba(255,255,255,.5); }

#lightbox-comment-form button {
  padding: 0 16px;
  border-radius: 20px;
  border: none;
  background: var(--blue);
  color: #fff;
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
}

#lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  color: white;
  font-size: 32px;
  line-height: 1;
  cursor: pointer;
  padding: 8px;
  opacity: .8;
}

/* ── Bottom nav ── */

.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 20;
  padding-bottom: env(safe-area-inset-bottom);
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 0 11px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray);
  font-size: 11px;
  font-weight: 500;
  transition: color .15s;
}

.nav-btn.active { color: var(--blue); }
.nav-btn.active svg { stroke: var(--blue); }
