/* ── Design Tokens ──
   The palette is theme-driven. The default `:root` set is the dark theme.
   Light values live in the two blocks below: one applied when the OS asks for
   a light scheme (and the user hasn't pinned a theme), one applied when the
   user explicitly picks light via the toggle (`data-theme="light"`).
   A `data-theme="dark"` on <html> pins dark even under an OS light scheme. */
:root {
  color-scheme: dark;
  --bg: #0b0b0c;
  --bg-soft: #0f0f11;
  --surface: #141417;
  --surface-2: #1a1a1e;
  --border: #232328;
  --border-soft: #1a1a1e;
  --text: #ececed;
  --text-strong: #ffffff;
  --text-dim: #9a9aa2;
  --text-faint: #66666e;
  --accent: #d8a657;
  --accent-bright: #e9bd7a;
  --accent-soft: rgba(216, 166, 87, 0.14);
  --input-bg: #111111;
  --input-border: #2a2a2a;
  --input-border-focus: #444444;
  --scrollbar-thumb: #2a2a30;
  --scrollbar-thumb-hover: #3a3a42;
  --btn-primary-bg: #e8e8e8;
  --btn-primary-bg-hover: #ffffff;
  --btn-primary-text: #0a0a0a;
  --success: #7cb3a3;
  --success-bright: #a0d8c8;
  --danger: #e06c75;
  --header-bg: rgba(11, 11, 12, 0.72);
  --header-fade-top: rgba(8, 8, 9, 0.55);
  --radius: 14px;
  --radius-sm: 10px;
  --header-h: 66px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
}

/* Light palette — shared by the OS-light fallback and the explicit toggle. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #f6f6f4;
    --bg-soft: #fbfbf9;
    --surface: #ffffff;
    --surface-2: #f0f0ec;
    --border: #e3e3dd;
    --border-soft: #ebebe6;
    --text: #1c1c20;
    --text-strong: #0a0a0c;
    --text-dim: #5c5c64;
    --text-faint: #8c8c94;
    --accent: #b97e26;
    --accent-bright: #a86f1c;
    --accent-soft: rgba(185, 126, 38, 0.12);
    --input-bg: #ffffff;
    --input-border: #d9d9d2;
    --input-border-focus: #b6b6ad;
    --scrollbar-thumb: #d0d0c9;
    --scrollbar-thumb-hover: #bcbcb4;
    --btn-primary-bg: #1c1c20;
    --btn-primary-bg-hover: #000000;
    --btn-primary-text: #ffffff;
    --success: #2f8a73;
    --success-bright: #1f6d59;
    --danger: #c4434f;
    --header-bg: rgba(250, 250, 248, 0.82);
    --header-fade-top: rgba(255, 255, 255, 0.72);
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.10);
  }
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f6f4;
  --bg-soft: #fbfbf9;
  --surface: #ffffff;
  --surface-2: #f0f0ec;
  --border: #e3e3dd;
  --border-soft: #ebebe6;
  --text: #1c1c20;
  --text-strong: #0a0a0c;
  --text-dim: #5c5c64;
  --text-faint: #8c8c94;
  --accent: #b97e26;
  --accent-bright: #a86f1c;
  --accent-soft: rgba(185, 126, 38, 0.12);
  --input-bg: #ffffff;
  --input-border: #d9d9d2;
  --input-border-focus: #b6b6ad;
  --scrollbar-thumb: #d0d0c9;
  --scrollbar-thumb-hover: #bcbcb4;
  --btn-primary-bg: #1c1c20;
  --btn-primary-bg-hover: #000000;
  --btn-primary-text: #ffffff;
  --success: #2f8a73;
  --success-bright: #1f6d59;
  --danger: #c4434f;
  --header-bg: rgba(250, 250, 248, 0.82);
  --header-fade-top: rgba(255, 255, 255, 0.72);
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.10);
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--bg);
}

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-hover); }

body {
  font-family: var(--font-sans);
  background:
    radial-gradient(1200px 600px at 50% -200px, rgba(216,166,87,0.05), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  letter-spacing: -0.011em;
}

a {
  color: var(--text);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--text-strong);
}

::selection {
  background: var(--accent-soft);
  color: var(--text-strong);
}

img {
  display: block;
  max-width: 100%;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input, textarea {
  font-family: inherit;
  font-size: inherit;
}

/* ── Site Header ── */
/* Floats over the gallery; idles translucent, solidifies on hover/focus. */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: linear-gradient(to bottom, var(--header-fade-top), transparent);
  transition: background 0.25s ease, backdrop-filter 0.25s ease;
}

.site-header::after {
  /* invisible hover catch-zone so the bar wakes up near the top edge */
  content: '';
  position: absolute;
  inset: 0 0 -24px 0;
  pointer-events: none;
}

.site-header:hover,
.site-header:focus-within {
  background: var(--header-bg);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
}

/* Header icons idle dim, brighten when the bar is active. */
.site-header .site-logo,
.site-header nav a { opacity: 0.65; transition: opacity 0.2s ease, color 0.15s ease, background 0.15s ease, border-color 0.15s ease; }
.site-header:hover .site-logo,
.site-header:hover nav a,
.site-header:focus-within .site-logo,
.site-header:focus-within nav a { opacity: 1; }

.site-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  color: var(--text-strong);
  border-radius: 10px;
  transition: opacity 0.15s ease;
}

.site-logo svg { width: 23px; height: 23px; }
.site-logo:hover { opacity: 0.8; }

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

.site-header nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  color: var(--text-dim);
  border: 1px solid transparent;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.site-header nav a svg {
  width: 19px;
  height: 19px;
}

.site-header nav a:hover {
  color: var(--text-strong);
  background: var(--surface);
  border-color: var(--border);
}

/* Login / logout control matches the nav icon buttons. */
.site-header nav .nav-auth { display: inline-flex; margin: 0; padding: 0; }
.site-header nav .nav-auth-link,
.site-header nav .nav-auth-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  color: var(--text-dim);
  border: 1px solid transparent;
  background: none;
  cursor: pointer;
  opacity: 0.65;
  transition: opacity 0.2s ease, color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.site-header:hover nav .nav-auth-link,
.site-header:hover nav .nav-auth-btn,
.site-header:focus-within nav .nav-auth-link,
.site-header:focus-within nav .nav-auth-btn { opacity: 1; }
.site-header nav .nav-auth-link svg,
.site-header nav .nav-auth-btn svg { width: 19px; height: 19px; }
.site-header nav .nav-auth-link:hover,
.site-header nav .nav-auth-btn:hover {
  color: var(--text-strong);
  background: var(--surface);
  border-color: var(--border);
}

/* Generic nav icon button (e.g. "manage posts" toggle). */
.site-header nav .nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  color: var(--text-dim);
  border: 1px solid transparent;
  background: none;
  cursor: pointer;
  opacity: 0.65;
  transition: opacity 0.2s ease, color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.site-header:hover nav .nav-btn,
.site-header:focus-within nav .nav-btn { opacity: 1; }
.site-header nav .nav-btn svg { width: 19px; height: 19px; }
.site-header nav .nav-btn:hover {
  color: var(--text-strong);
  background: var(--surface);
  border-color: var(--border);
}
.site-header nav .nav-btn[aria-pressed="true"] {
  opacity: 1;
  color: var(--accent, var(--text-strong));
  background: var(--surface);
  border-color: var(--border);
}

/* Bartender-style overflow: admin tools tuck behind a "…" until revealed.
   The items collapse to zero width and fade out; clicking the toggle slides
   them back in. */
.nav-overflow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.nav-overflow-items {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 0;
  overflow: hidden;
  opacity: 0;
  /* Pull the toggle flush against the preceding icon while collapsed. */
  margin-right: -6px;
  transition: max-width 0.28s ease, opacity 0.2s ease, margin-right 0.28s ease;
}
.nav-overflow.open .nav-overflow-items {
  max-width: 240px;
  opacity: 1;
  margin-right: 0;
}
.nav-overflow-toggle svg { width: 19px; height: 19px; }
.nav-overflow.open .nav-overflow-toggle {
  color: var(--text-strong);
  background: var(--surface);
  border-color: var(--border);
}

/* Theme toggle — styled like the other nav icon buttons. */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  color: var(--text-dim);
  border: 1px solid transparent;
  background: none;
  cursor: pointer;
  opacity: 0.65;
  transition: opacity 0.2s ease, color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.site-header:hover .theme-toggle,
.site-header:focus-within .theme-toggle { opacity: 1; }
.theme-toggle:hover {
  color: var(--text-strong);
  background: var(--surface);
  border-color: var(--border);
}
.theme-toggle svg { width: 19px; height: 19px; }
@media (hover: none) { .theme-toggle { opacity: 1; } }

/* Show the icon for the theme you'd switch TO: moon in light, sun in dark.
   Default (dark) shows the sun; light shows the moon. */
.theme-toggle .theme-icon-moon { display: none; }
.theme-toggle .theme-icon-sun { display: block; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .theme-toggle .theme-icon-sun { display: none; }
  :root:not([data-theme="dark"]) .theme-toggle .theme-icon-moon { display: block; }
}
:root[data-theme="light"] .theme-toggle .theme-icon-sun { display: none; }
:root[data-theme="light"] .theme-toggle .theme-icon-moon { display: block; }
:root[data-theme="dark"] .theme-toggle .theme-icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .theme-icon-moon { display: none; }

/* ── Main Container ── */
/* All content clears the fixed header so nothing (photos or controls)
   hides beneath it. */
main {
  max-width: 1600px;
  margin: 0 auto;
  padding: calc(var(--header-h) + 6px) 28px 100px;
}

/* Narrower column for text-centric pages (new, settings). */
.new-post,
.settings-page {
  max-width: 640px;
  margin: 0 auto;
}

/* ── Masonry Grid (feed / tag) ── */
.grid {
  column-count: 4;
  column-gap: 14px;
}

@media (max-width: 1280px) { .grid { column-count: 3; } }
@media (max-width: 860px)  { .grid { column-count: 2; column-gap: 10px; } }
@media (max-width: 520px)  { .grid { column-count: 1; } }

.grid-item {
  display: block;
  break-inside: avoid;
  /* Spacing lives inside the box (padding, not margin): Safari carries a
     trailing margin across a column break to the top of the next column,
     misaligning the first tile there. Padding can't leak past the break
     because break-inside keeps the whole box together. */
  padding-bottom: 14px;
}

@media (max-width: 860px) { .grid-item { padding-bottom: 10px; } }

.grid-thumb {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(255,255,255,0.02);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  /* Safari: keep a stable compositing layer. Without this, WebKit tears
     down the hover transform's layer after the transition ends and
     repaints the clipped (overflow:hidden + radius) subtree black. */
  transform: translateZ(0);
  isolation: isolate;
}

.grid-thumb img {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 0.4s ease;
  transform: translateZ(0);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.grid-item:hover .grid-thumb {
  transform: translateZ(0) translateY(-3px);
  box-shadow: var(--shadow);
}

.grid-item:hover .grid-thumb img {
  transform: translateZ(0) scale(1.03);
}

/* Album stacked-page badge */
.grid-stack {
  position: absolute;
  top: 10px;
  right: 10px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px 4px 6px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #fff;
  background: rgba(12, 12, 13, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 999px;
}

.grid-stack svg { width: 13px; height: 13px; }

/* Hover caption overlay */
.grid-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 4px;
  padding: 14px;
  background: linear-gradient(to top, rgba(8,8,9,0.78) 0%, rgba(8,8,9,0.18) 38%, transparent 62%);
  opacity: 0;
  transition: opacity 0.22s ease;
}

.grid-item:hover .grid-overlay { opacity: 1; }

.grid-caption {
  font-family: var(--font-display);
  font-size: 1rem;
  line-height: 1.3;
  color: #fff;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.grid-date {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.7);
}

/* ── Feed ── */
.feed {
  display: flex;
  flex-direction: column;
}

/* ── Post Card ── */
.post {
  padding: 0 0 32px;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--border-soft);
}

.post:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

/* ── Caption ── */
.post-caption {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: -0.005em;
  color: var(--text-strong);
  padding: 18px 2px 0;
  white-space: pre-wrap;
}

.post-caption-wrap {
  padding: 18px 0 0;
}

/* ── Tags ── */
.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 0 0;
}

.tag-pill {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--text-dim);
  padding: 4px 11px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.tag-pill::before {
  content: '#';
  color: var(--text-faint);
  margin-right: 1px;
}

.tag-pill:hover {
  color: var(--text-strong);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.tag-pill:hover::before { color: var(--accent); }

/* ── Post Meta ── */
.post-meta {
  padding: 10px 0 0;
}

.post-date {
  font-size: 0.74rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-faint);
  transition: color 0.15s ease;
}

.post-date:hover {
  color: var(--text-dim);
}

/* ── EXIF Row ── */
.exif-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: baseline;
  padding: 10px 0 0;
  font-size: 0.78rem;
  color: var(--text-faint);
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

.exif-line {
  white-space: nowrap;
}

.exif-date,
.exif-software {
  color: var(--text-faint);
}

.exif-gps {
  color: var(--text-dim);
  transition: color 0.15s ease;
}

.exif-gps:hover {
  color: var(--accent);
}

/* ── Post Actions (detail page) ── */
.post-actions {
  display: flex;
  gap: 12px;
  padding: 16px 0 0;
}

.btn-subtle {
  font-size: 0.8rem;
  color: var(--text-faint);
  padding: 4px 0;
  transition: color 0.15s ease;
}

.btn-subtle:hover {
  color: var(--text-strong);
}

.btn-danger:hover {
  color: var(--danger);
}

/* ── Edit Mode ── */
.caption-edit-area {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.65;
  padding: 10px 12px;
  resize: vertical;
  min-height: 60px;
  outline: none;
}

.caption-edit-area:focus {
  border-color: var(--input-border-focus);
}

.edit-date-field {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0 0;
}

.edit-date-field label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.date-edit-input {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--text);
  font-size: 0.85rem;
  font-family: inherit;
  padding: 5px 8px;
  border-radius: 6px;
  outline: none;
}

.date-edit-input:focus {
  border-color: var(--input-border-focus);
}

.edit-actions {
  display: flex;
  gap: 10px;
  padding: 8px 0 0;
}

.btn-save {
  font-size: 0.8rem;
  color: var(--success);
  padding: 4px 0;
  transition: color 0.15s ease;
}

.btn-save:hover {
  color: var(--success-bright);
}

.btn-cancel {
  font-size: 0.8rem;
  color: var(--text-faint);
  padding: 4px 0;
  transition: color 0.15s ease;
}

.btn-cancel:hover {
  color: var(--text-dim);
}

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 100px 20px;
  color: var(--text-faint);
}

.empty-state p {
  font-family: var(--font-display);
  font-size: 1.3rem;
  color: var(--text-dim);
  margin-bottom: 20px;
}

.empty-cta {
  display: inline-block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--bg);
  background: var(--accent);
  padding: 10px 20px;
  border-radius: 999px;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.empty-cta:hover {
  color: var(--bg);
  opacity: 0.9;
  transform: translateY(-1px);
}

/* ── Tags Page ── */
.tags-page { max-width: 640px; margin: 0 auto; }
.tags-page h1,
.tag-header h1 {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin-bottom: 24px;
}

.tag-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 24px;
}

.tag-post-count {
  font-size: 0.8rem;
  color: var(--text-faint);
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-pill-lg {
  font-size: 0.9rem;
  padding: 8px 16px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.tag-count {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-faint);
  background: var(--bg);
  padding: 1px 7px;
  border-radius: 999px;
}

.tag-pill-lg:hover .tag-count { color: var(--accent); }

/* ── New Post Page ── */
.new-post h1 {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin-bottom: 28px;
}

.drop-zone {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  padding: 56px 20px;
  text-align: center;
  background: var(--bg-soft);
  transition: border-color 0.2s ease, background 0.2s ease;
  cursor: pointer;
}

.drop-zone:hover { border-color: var(--text-faint); }

.drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.drop-zone-inner {
  pointer-events: none;
}

.drop-icon {
  font-size: 2rem;
  display: block;
  margin-bottom: 8px;
  opacity: 0.5;
}

.drop-zone p {
  font-size: 0.9rem;
  color: var(--text-dim);
}

.browse-link {
  color: var(--accent);
  font-weight: 500;
  cursor: pointer;
  pointer-events: auto;
}

.browse-link:hover {
  color: var(--accent-bright);
}

/* ── Preview Grid ── */
.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
  padding: 16px 0 0;
}

.preview-grid:empty {
  display: none;
}

.preview-item {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  color: #ccc;
  font-size: 0.7rem;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.preview-item:hover .preview-remove {
  opacity: 1;
}

/* ── Caption Input ── */
.caption-input {
  display: block;
  width: 100%;
  margin-top: 20px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.caption-input::placeholder {
  color: var(--text-faint);
}

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

/* ── Tag Input ── */
.tag-input-wrap {
  position: relative;
  margin-top: 14px;
}

.tag-input {
  display: block;
  width: 100%;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.tag-input::placeholder {
  color: var(--text-faint);
}

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

/* Row pairing the tag input with the AI Suggest button. */
.tag-input-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.tag-input-row .tag-input,
.tag-input-row .tag-edit-input {
  flex: 1 1 auto;
  min-width: 0;
}

.btn-autotag {
  flex: 0 0 auto;
  white-space: nowrap;
  padding: 0 14px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease;
}
.btn-autotag:hover:not(:disabled) {
  background: var(--accent);
  color: var(--btn-primary-text);
}
.btn-autotag:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Suggested-tag chips returned by the LLM. */
.autotag-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 12px 0 2px;
}
.autotag-label {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-right: 2px;
}
.autotag-status {
  font-size: 0.8rem;
  color: var(--text-dim);
}
.autotag-error { color: var(--danger); }

.autotag-chip {
  font-size: 0.78rem;
  color: var(--text);
  padding: 4px 11px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.12s ease;
}
.autotag-chip::before {
  content: '+ ';
  color: var(--accent);
}
.autotag-chip:hover {
  border-color: var(--accent);
}
.autotag-chip.added {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.autotag-chip.added::before {
  content: '✓ ';
}
.autotag-addall {
  font-size: 0.75rem;
  color: var(--text-dim);
  background: none;
  border: none;
  border-bottom: 1px dashed var(--text-faint);
  cursor: pointer;
  padding: 2px 0;
  margin-left: 4px;
}
.autotag-addall:hover { color: var(--accent); }

/* Tag field inside the post-detail inline editor. */
.edit-tag-field {
  margin-top: 12px;
}
.edit-tag-field label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.tag-edit-input {
  display: block;
  width: 100%;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
}
.tag-edit-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.tag-suggestions {
  display: none;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 0 0;
}

.tag-suggestions.visible {
  display: flex;
}

.tag-suggestion {
  font-size: 0.75rem;
  color: var(--text-dim);
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.tag-suggestion:hover {
  color: var(--text-strong);
  border-color: var(--text-faint);
}

.tag-suggestion.used {
  opacity: 0.3;
  pointer-events: none;
}

/* ── Form Actions ── */
.form-actions {
  margin-top: 24px;
}

.btn-post {
  display: inline-block;
  padding: 10px 32px;
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.btn-post:hover {
  background: var(--btn-primary-bg-hover);
}

.btn-post:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

/* ── Upload Progress ── */
.upload-progress {
  margin-top: 20px;
}

.upload-progress:empty {
  display: none;
}

.progress-item {
  margin-bottom: 8px;
}

.progress-name {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.progress-bar {
  width: 100%;
  height: 3px;
  background: var(--surface-2);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--success);
  transition: width 0.2s ease;
}

/* Touch devices can't hover: keep the bar legible and icons fully visible. */
@media (hover: none) {
  .site-header {
    background: var(--header-bg);
    backdrop-filter: blur(18px) saturate(1.4);
    -webkit-backdrop-filter: blur(18px) saturate(1.4);
  }
  .site-header .site-logo,
  .site-header nav a { opacity: 1; }
}

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

  /* On narrow screens the icon row can outgrow the available width once the
     overflow group is expanded. Let the nav scroll horizontally instead of
     wrapping or clipping. The logo stays put; only the nav scrolls. */
  .site-header nav {
    flex: 1 1 auto;
    min-width: 0;
    justify-content: flex-end;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .site-header nav::-webkit-scrollbar { display: none; }
  /* Keep icons from shrinking so they stay tappable while scrolling. */
  .site-header nav > * { flex: 0 0 auto; }

  main {
    padding: calc(var(--header-h) + 6px) 16px 60px;
  }

  .post {
    padding: 24px 0;
  }

  .drop-zone {
    padding: 36px 16px;
  }

}

/* ── Settings Page ── */
.settings-page h1 {
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 24px;
}

.settings-saved {
  font-size: 0.85rem;
  color: var(--success);
  margin-bottom: 20px;
  padding: 8px 12px;
  background: var(--accent-soft);
  border: 1px solid var(--border);
}

.settings-form label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.settings-input {
  display: block;
  width: 100%;
  padding: 10px 14px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s ease;
}

.settings-input:focus {
  border-color: var(--input-border-focus);
}

.settings-form .form-actions {
  margin-top: 20px;
}

/* ── Settings accordion (collapsible section) ── */
.settings-accordion {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
}

.settings-accordion > summary {
  display: flex;
  align-items: center;
  gap: 4px 12px;
  flex-wrap: wrap;
  padding: 14px 18px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.settings-accordion > summary::-webkit-details-marker { display: none; }
.settings-accordion > summary:hover { background: var(--surface-2); }

.settings-accordion .accordion-title {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

.settings-accordion .accordion-sub {
  font-size: 0.85rem;
  color: var(--text-dim);
}

.settings-accordion .accordion-chevron {
  width: 18px;
  height: 18px;
  margin-left: auto;
  color: var(--text-dim);
  flex-shrink: 0;
  transition: transform 0.2s ease;
}
.settings-accordion[open] .accordion-chevron { transform: rotate(180deg); }

.settings-accordion .accordion-body {
  padding: 4px 18px 18px;
  border-top: 1px solid var(--border);
}
.settings-accordion .accordion-body > label:first-child { margin-top: 14px; }

/* ── Gallery Wall view ── */
.photo-count { color: var(--text-dim); }

/* HTML `hidden` must win over display:grid/flex */
[hidden] { display: none !important; }

/* Post detail breaks out of the 620px feed column and lays out as
   sidebar + content. Wall view fills the content column.
   Sidebar is collapsible via data-sidebar="open|closed" on .post-detail. */
.post-detail {
  position: relative;
  left: 50%;
  transform: translateX(-50%);
  width: min(100vw - 32px, 1500px);
  box-sizing: border-box;
  display: grid;
  grid-template-columns: 1fr 240px;
  gap: 32px;
  padding: 0;
  border-bottom: none;
}
.post-detail[data-sidebar="closed"] {
  grid-template-columns: 1fr;
  gap: 0;
}
.post-detail[data-sidebar="closed"] .post-sidebar { display: none; }
.post-detail .post-content { grid-column: 1; grid-row: 1; min-width: 0; }
.post-detail .post-sidebar { grid-column: 2; grid-row: 1; }

/* Info-panel toggle. Lives in the header nav (relocated there by JS) so it
   matches the other nav icons and never overlaps the photos. */
.sidebar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
  cursor: pointer;
  opacity: 0.65;
  transition: opacity 0.2s ease, color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.site-header:hover .sidebar-toggle,
.site-header:focus-within .sidebar-toggle { opacity: 1; }
.sidebar-toggle:hover {
  color: #fff;
  background: var(--surface);
  border-color: var(--border);
}
.sidebar-toggle svg { width: 19px; height: 19px; }
.post-detail[data-sidebar="open"] .sidebar-toggle,
.sidebar-toggle[aria-expanded="true"] { color: #fff; opacity: 1; }

/* Constrain stream/carousel width when sidebar is collapsed so photos
   don't blow up to full viewport width. */
.post-content .post-images { max-width: 900px; margin-left: auto; margin-right: auto; }
.post-content .exif-row { max-width: 900px; margin-left: auto; margin-right: auto; }
.post-sidebar {
  align-self: start;
  position: sticky;
  top: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.post-sidebar .post-caption-wrap { padding: 0; }
.post-sidebar .post-caption { padding: 0; font-size: 1.1rem; color: var(--text); }
.post-sidebar .post-tags { padding: 0; }
.post-sidebar .post-meta { padding: 0; display: flex; gap: 4px; align-items: baseline; flex-wrap: wrap; }
.post-sidebar .post-meta .photo-count { color: var(--text-faint); font-size: .75rem; }
.post-sidebar .post-actions { padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }

.post-content { min-width: 0; }

/* Wall — justified-row layout (Flickr/Unsplash style) */
.post-wall {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 24px;
}

@media (max-width: 900px) {
  .post-detail,
  .post-detail[data-sidebar="open"] {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  /* Single column: stack the sidebar above the photos. Without resetting the
     explicit column/row placement the sidebar lands in a phantom second
     column and squeezes .post-content to 0 width (sidebar never appears). */
  .post-detail .post-content,
  .post-detail .post-sidebar {
    grid-column: 1;
    grid-row: auto;
  }
  .post-sidebar { position: static; }
}
.wall-tile {
  position: relative;
  overflow: hidden;
  border-radius: 6px;
  background: #111;
  cursor: zoom-in;
  flex-shrink: 0;
  transition: box-shadow .15s ease;
}
.wall-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .3s ease, filter .2s ease;
}
.wall-tile::after {
  content: '';
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease;
}
.wall-tile:hover { box-shadow: 0 6px 24px rgba(0,0,0,.55); z-index: 2; }
.wall-tile:hover::after { opacity: .08; }

/* ── Lightbox ── */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.93);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 32px;
}
.lightbox[hidden] { display: none; }
/* Swipeable gallery: a native horizontal scroll-snap track. iOS provides the
   momentum + snapping for free, which feels natural and avoids the layout/tap
   bugs of a hand-rolled transform carousel. */
.lightbox .lb-scroller {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 0;
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-width: none;
}
.lightbox .lb-scroller::-webkit-scrollbar { display: none; }
/* Controls must sit above the scroller, which covers the whole lightbox and
   would otherwise swallow taps on the close/nav/meta buttons. */
.lightbox .lb-close,
.lightbox .lb-nav,
.lightbox .lb-cover,
.lightbox .lb-meta { z-index: 2; }
.lightbox .lb-slide {
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  scroll-snap-align: center;
  scroll-snap-stop: always;
  position: relative;
}
.lightbox .lb-slide img {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 12px 40px rgba(0,0,0,.6);
  user-select: none;
  -webkit-user-drag: none;
}
.lightbox .lb-close {
  position: absolute;
  top: 18px;
  right: 24px;
  background: none;
  border: none;
  color: #fff;
  font-size: 28px;
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
  opacity: .8;
}
.lightbox .lb-close:hover { opacity: 1; }
.lightbox .lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,.08);
  border: none;
  color: #fff;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox .lb-nav:hover { background: rgba(255,255,255,.15); }
.lightbox .lb-prev { left: 18px; }
.lightbox .lb-next { right: 18px; }
.lightbox .lb-cover {
  position: absolute;
  top: 18px;
  left: 24px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--bg);
  background: var(--accent);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition: opacity 0.15s ease;
}
.lightbox .lb-cover:hover { opacity: 0.9; }
.lightbox .lb-cover:disabled { opacity: 0.6; cursor: default; }
/* Film-credit scrim: metadata sits on a bottom gradient fade instead of a
   floating pill. The container ignores pointer events so swipes/taps in the
   gradient still reach the scroller; content rows re-enable them. */
.lightbox .lb-meta {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 72px 28px 18px;
  color: #ccc;
  font-size: 13px;
  background: linear-gradient(to top, rgba(0,0,0,.78) 0%, rgba(0,0,0,.45) 45%, transparent 100%);
  pointer-events: none;
}
.lightbox .lb-meta > * { pointer-events: auto; }
.lightbox .lb-counter {
  font-family: var(--font-mono, ui-monospace, 'SF Mono', Menlo, monospace);
  font-size: 11.5px;
  color: rgba(255,255,255,.55);
  background: rgba(0,0,0,.4);
  padding: 3px 9px;
  border-radius: 999px;
  backdrop-filter: blur(6px);
}
.lightbox .lb-headline {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}
.lightbox .lb-cam {
  font-weight: 600;
  font-size: 14px;
  letter-spacing: .01em;
  color: #fff;
}
.lightbox .lb-lens {
  font-size: 12.5px;
  color: rgba(255,255,255,.55);
}
.lightbox .lb-headline:not(:has(.lb-cam:not(:empty), .lb-lens:not(:empty))) { display: none; }
/* Settings row: labelled monospace specs left, date/map right. */
.lightbox .lb-info-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 16px;
  flex-wrap: wrap;
  width: 100%;
}
.lightbox .lb-specs {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  font-family: var(--font-mono, ui-monospace, 'SF Mono', Menlo, monospace);
  font-size: 12.5px;
  color: rgba(255,255,255,.85);
}
.lightbox .lb-spec b {
  color: rgba(255,255,255,.45);
  font-weight: 400;
  margin-right: 4px;
  font-family: var(--font-sans);
  font-size: 11px;
}
.lightbox .lb-when {
  display: flex;
  gap: 14px;
  align-items: baseline;
  margin-left: auto;
  font-size: 12.5px;
  color: rgba(255,255,255,.6);
}
.lightbox .lb-social-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  flex-wrap: wrap;
  width: 100%;
}
.lightbox .lb-social-row:not(:has(.lb-tags > *, .lb-reactions > *)) { display: none; }
/* Unadorned view: tap metadata/image to hide overlay chrome. */
.lightbox.chrome-hidden .lb-meta,
.lightbox.chrome-hidden .lb-cover { opacity: 0; pointer-events: none; }
.lightbox .lb-meta { transition: opacity .2s ease; }
.lightbox .lb-meta .lb-gps { color: #8ecdf7; text-decoration: none; }
.lightbox .lb-meta .lb-gps:hover { text-decoration: underline; }
.lightbox .lb-info-row :empty { display: none; }
.lightbox .lb-info-row:not(:has(.lb-specs > *, .lb-exif:not(:empty), .lb-date:not(:empty), .lb-gps:not([hidden]))) { display: none; }

/* Per-photo reaction bar inside the lightbox. */
.lightbox .lb-reactions {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 4px;
}
.lightbox .lb-reactions:empty { display: none; }

/* "+" button that reveals the full emoji palette. */
.lightbox .lb-react-add .reaction-emoji {
  font-size: 1.1rem;
  font-weight: 600;
  filter: none;
  color: var(--text-dim);
}
.lightbox .lb-react-add.open {
  background: var(--accent-soft);
  border-color: var(--accent);
}

/* The full-palette picker, floating just above the reaction bar. An explicit
   width (rather than max-width) keeps it from shrink-to-fit collapsing into a
   single column inside its narrow positioning parent. */
.lightbox .lb-react-picker {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
  width: 264px;
  max-width: 90vw;
  padding: 8px;
  background: rgba(20, 20, 23, 0.96);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  z-index: 3;
}

/* Per-photo tags row inside the lightbox. */
.lightbox .lb-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.lightbox .lb-tags:empty { display: none; }
/* The lightbox is always dark regardless of site theme, so tags/reactions
   get theme-independent frosted-glass styling on the scrim. */
.lightbox .lb-tags .tag-pill {
  color: rgba(255,255,255,.8);
  background: rgba(255,255,255,.12);
  border-color: transparent;
  backdrop-filter: blur(4px);
}
.lightbox .lb-tags .tag-pill::before { color: rgba(255,255,255,.45); }
.lightbox .lb-tags .tag-pill:hover {
  color: #fff;
  background: rgba(255,255,255,.2);
}
.lightbox .lb-reactions .reaction {
  color: rgba(255,255,255,.75);
  background: rgba(255,255,255,.1);
  border-color: transparent;
  backdrop-filter: blur(4px);
}
.lightbox .lb-reactions .reaction:hover:not(:disabled) {
  background: rgba(255,255,255,.18);
  border-color: transparent;
}
.lightbox .lb-reactions .reaction .reaction-count { color: rgba(255,255,255,.6); }
.lightbox .lb-reactions .reaction.has-count .reaction-count { color: #fff; }
.lightbox .lb-reactions .reaction.mine {
  background: rgba(216,166,87,.28);
  border-color: rgba(233,189,122,.6);
}
.lightbox .lb-tag-editbtn {
  background: none;
  border: 1px dashed rgba(255,255,255,.35);
  color: rgba(255,255,255,.6);
  font-size: .72rem;
  padding: 3px 10px;
  border-radius: 999px;
  cursor: pointer;
}
.lightbox .lb-tag-editbtn:hover { color: var(--accent-bright); border-color: var(--accent); }

/* Per-photo tag editor (admin). */
.lightbox .lb-tag-edit {
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.lightbox .lb-tag-edit .lb-tag-input {
  width: 100%;
  min-width: 220px;
}
.lightbox .lb-tag-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.lightbox .lb-tag-edit .autotag-chips { padding: 0; }
@media (max-width: 600px) {
  .lightbox { padding: 8px; }
  .lightbox .lb-nav { width: 38px; height: 38px; }
  /* Tighter scrim on small screens; stack the settings/date rows. */
  .lightbox .lb-meta {
    padding: 56px 16px 12px;
    gap: 8px;
    font-size: 12px;
  }
  .lightbox .lb-specs { gap: 14px; }
  .lightbox .lb-when { margin-left: 0; }
}

/* ── Bulk photo management (admin) ── */
body.select-mode .wall-tile { cursor: pointer; }

.wall-check {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.85);
  background: rgba(0, 0, 0, 0.35);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  display: none;
  z-index: 3;
  pointer-events: none;
}
body.select-mode .wall-check { display: block; }

.wall-tile.selected { box-shadow: 0 0 0 3px var(--accent); z-index: 2; }
.wall-tile.selected img { filter: brightness(0.78); }
.wall-tile.selected .wall-check {
  background: var(--accent);
  border-color: var(--accent);
}
.wall-tile.selected .wall-check::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #1a1a1e;
  font-size: 15px;
  font-weight: 700;
}

.bulk-bar {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow);
  z-index: 50;
}
.bulk-bar .bulk-count {
  font-size: 0.85rem;
  color: var(--text-dim);
  padding-right: 4px;
}
.bulk-bar #bulk-n { color: var(--text); font-weight: 600; }

/* Move-destination modal */
.move-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
  padding: 20px;
}
.move-panel {
  width: min(440px, 100%);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.move-panel h3 { margin: 0 0 12px; font-size: 1rem; font-weight: 600; }
.move-panel #move-filter {
  width: 100%;
  padding: 9px 12px;
  margin-bottom: 10px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
}
.move-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
}
.move-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .12s ease;
}
.move-item:hover { background: var(--accent-soft); }
.move-item .move-cap {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.move-item .move-date { color: var(--text-faint); font-size: 0.8rem; flex-shrink: 0; }
.move-empty { padding: 12px; color: var(--text-faint); text-align: center; }
.move-actions { margin-top: 12px; display: flex; justify-content: flex-end; }

/* ── Feed post bulk management ── */
.grid-check {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.85);
  background: rgba(0, 0, 0, 0.35);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  display: none;
  z-index: 3;
  pointer-events: none;
}
body.post-select-mode .grid-check { display: block; }
body.post-select-mode .grid-item { cursor: pointer; }
body.post-select-mode .grid-overlay { opacity: 0 !important; }
.grid-item.selected .grid-thumb { box-shadow: 0 0 0 3px var(--accent); }
.grid-item.selected .grid-thumb img { filter: brightness(0.78); }
.grid-item.selected .grid-check { background: var(--accent); border-color: var(--accent); }
.grid-item.selected .grid-check::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #1a1a1e;
  font-size: 15px;
  font-weight: 700;
}

/* ── Drag-to-reorder ── */
body.reorder-mode .wall-tile { cursor: grab; }
body.reorder-mode .wall-tile img { pointer-events: none; }
.wall-tile.dragging { opacity: 0.45; outline: 2px dashed var(--accent); }
body.reorder-mode #btn-reorder { color: var(--accent); }

/* Feed reorder mode: drop the masonry columns for a predictable uniform grid
   so drag-and-drop insertion maps cleanly to left-to-right, top-to-bottom
   order. */
body.feed-reorder-mode #feed-grid {
  column-count: unset;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
@media (max-width: 1280px) { body.feed-reorder-mode #feed-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 860px)  { body.feed-reorder-mode #feed-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; } }
@media (max-width: 520px)  { body.feed-reorder-mode #feed-grid { grid-template-columns: 1fr; } }
body.feed-reorder-mode #feed-grid .grid-item { margin-bottom: 0; cursor: grab; }
body.feed-reorder-mode .grid-item img { pointer-events: none; }
body.feed-reorder-mode .grid-overlay { pointer-events: none; }
.grid-item.dragging { opacity: 0.45; outline: 2px dashed var(--accent); border-radius: var(--radius-sm); }
body.feed-reorder-mode #feed-reorder { color: var(--accent); }
body.feed-reorder-mode #feed-sentinel { display: none; }

/* Infinite-scroll loading / retry states */
#feed-sentinel { min-height: 1px; text-align: center; padding: 8px 0 24px; }
#feed-sentinel.loading::after {
  content: '';
  display: inline-block;
  width: 22px; height: 22px;
  border: 2px solid var(--accent-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: feed-spin 0.8s linear infinite;
}
@keyframes feed-spin { to { transform: rotate(360deg); } }
.feed-retry {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 8px 18px;
  cursor: pointer;
  font: inherit;
}

/* ── Photo map ── */
.map-wrap {
  position: relative;
  /* Break out of <main>'s max-width + padding for an edge-to-edge map. */
  width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-top: -6px;
  margin-bottom: -100px; /* cancel main's bottom padding */
  height: calc(100vh - var(--header-h) - 6px);
  height: calc(100dvh - var(--header-h) - 6px); /* stable on iOS URL-bar show/hide */
  min-height: 420px;
  overflow: hidden;
  border-top: 1px solid var(--border);
}
#photo-map { width: 100%; height: 100%; background: var(--bg-soft); }
.map-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text-dim);
}
.map-empty-icon { color: var(--accent); opacity: 0.85; margin-bottom: 4px; }
.map-empty-sub { color: var(--text-faint); font-size: 0.85rem; }

/* Tone the basemap to sit under the UI chrome */
.map-wrap .leaflet-container { background: var(--bg-soft); }
.map-wrap .leaflet-control-attribution {
  background: var(--header-bg);
  color: var(--text-faint);
  backdrop-filter: blur(4px);
}
.map-wrap .leaflet-control-attribution a { color: var(--text-dim); }
.map-wrap .leaflet-bar a {
  background: var(--surface-2);
  color: var(--text);
  border-bottom-color: var(--border);
}
.map-wrap .leaflet-bar a:hover { background: var(--surface); color: var(--accent); }
.map-wrap .leaflet-bar { border: 1px solid var(--border); box-shadow: var(--shadow); }
.map-wrap .map-reset a { display: flex; align-items: center; justify-content: center; }

/* Circular photo-thumbnail markers */
.photo-pin { background: none; border: none; }
.photo-pin-img {
  display: block;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  background-color: var(--surface-2);
  border: 2px solid var(--text);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(0, 0, 0, 0.4);
  position: relative;
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.photo-pin-img::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -8px;
  transform: translateX(-50%);
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 8px solid var(--text);
}
.leaflet-marker-icon.photo-pin:hover .photo-pin-img {
  transform: scale(1.12);
  border-color: var(--accent);
  z-index: 1000;
}
.leaflet-marker-icon.photo-pin:hover .photo-pin-img::after { border-top-color: var(--accent); }

/* Cluster bubbles (extra specificity to beat .leaflet-marker-icon) */
.leaflet-marker-icon.photo-cluster {
  display: flex !important;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--accent-soft);
  border: 2px solid var(--accent);
  color: var(--text);
  font-weight: 700;
  font-size: 0.82rem;
  line-height: 1;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
}
.leaflet-marker-icon.photo-cluster span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72%;
  height: 72%;
  border-radius: 50%;
  background: rgba(216, 166, 87, 0.22);
  line-height: 1;
}

/* Leaflet popup theming */
.map-popup .leaflet-popup-content-wrapper {
  background: var(--surface-2);
  color: var(--text);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
  padding: 0;
}
.map-popup .leaflet-popup-tip { background: var(--surface-2); border: 1px solid var(--border); }
.map-popup .leaflet-popup-content { margin: 0; }
.map-pop, .map-pop:hover, .map-pop:visited { display: block; text-decoration: none; color: var(--text); }
.map-pop img {
  width: 100%;
  height: 130px;
  object-fit: cover;
  display: block;
  transition: transform 0.25s ease;
}
.map-pop:hover img { transform: scale(1.04); }
.map-pop-cap { padding: 9px 11px 2px; font-weight: 600; font-size: 0.88rem; color: var(--text); }
.map-pop-date { padding: 0 11px 9px; color: var(--text-faint); font-size: 0.78rem; }
.map-pop-cap + .map-pop-date { padding-top: 0; }

/* ── Visibility & access ── */
.post-visibility { margin-top: 10px; }
.post-visibility label { display: block; font-size: 0.75rem; color: var(--text-faint); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.04em; }
.post-visibility select, .new-visibility select {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
}
.new-visibility { margin: 14px 0; }
.new-visibility label { display: block; font-size: 0.85rem; color: var(--text-dim); margin-bottom: 6px; }

.vis-badge {
  display: inline-block;
  margin-top: 8px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.vis-badge.vis-public { display: none; }
.vis-badge.vis-unlisted { color: var(--accent); border-color: var(--accent); }
.vis-badge.vis-private { color: var(--danger); border-color: var(--danger); }

.viewer-add { display: flex; gap: 8px; margin: 12px 0; flex-wrap: wrap; }
.viewer-list { list-style: none; padding: 0; margin: 12px 0; }
.viewer-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-soft);
}
.viewer-email { font-weight: 600; }
.viewer-note { color: var(--text-faint); font-size: 0.85rem; }
.viewer-item form { margin-left: auto; }

.access-page { max-width: 520px; margin: 12vh auto; text-align: center; padding: 0 20px; }
.access-page h1 { font-family: var(--font-display); margin-bottom: 12px; }
.access-page p { color: var(--text-dim); }
.access-sub { font-size: 0.9rem; color: var(--text-faint); margin-top: 8px; }
.access-cta {
  margin: 18px 0 6px;
  padding: 11px 22px;
  background: var(--accent);
  color: #1a1a1e;
  border: none;
  border-radius: 999px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.access-home { margin-top: 24px; }
.access-home a { color: var(--text-dim); }

/* ── Emoji reactions ───────────────────────────────────────────────── */
.reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 16px;
}
.reaction {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  font: inherit;
  font-size: 0.95rem;
  line-height: 1;
  color: var(--text-dim);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.08s ease;
}
.reaction:hover:not(:disabled) {
  background: var(--surface);
  border-color: var(--text-faint);
}
.reaction:active:not(:disabled) { transform: scale(0.94); }
.reaction:disabled { cursor: default; }
.reaction .reaction-emoji {
  font-size: 1.05rem;
  filter: saturate(0.85);
  transition: filter 0.12s ease;
}
.reaction.has-count .reaction-emoji,
.reaction.mine .reaction-emoji { filter: none; }
.reaction .reaction-count {
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
  min-width: 0;
}
.reaction.has-count .reaction-count { color: var(--text); }
.reaction.mine {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text);
}
.reaction.mine .reaction-count { color: var(--accent); }
.reactions-hint {
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--text-faint);
}
.reactions-hint a { color: var(--text-dim); }

/* Small helper hints (sidebar note, form field note). */
.sidebar-hint {
  margin-top: 4px;
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--text-faint);
}
.field-hint {
  margin-top: 6px;
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--text-faint);
}
