:root {
  color-scheme: dark;
  --bg: #000000;
  --surface: #121212;
  --surface-raised: #1a1a1a;
  --ink: #f5f5f4;
  --muted: #a8a29e;
  --accent: #e7e5e4;
  --accent-hover: #ffffff;
  --border: #2a2a2a;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  font-family: "Sofia Pro", Helvetica, Arial, sans-serif;
}

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

html {
  font-size: 106%;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
}

/* Programmatic focus after route (app.js); avoid default focus ring for sighted users. */
#app-main:focus:not(:focus-visible) {
  outline: none;
}

h1,
h2,
.app-header__title {
  font-family: "Sofia Pro", Helvetica, Arial, sans-serif;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover {
  color: var(--accent-hover);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 1.25rem;
}

.app-header__inner {
  max-width: 72rem;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.app-header__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  width: 100%;
}

.app-header__title {
  margin: 0;
  font-size: 1.35rem;
  flex: 1 1 auto;
  min-width: 0;
}

.app-header__tools {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.app-header__icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-raised);
  color: var(--ink);
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    background 0.15s ease,
    color 0.15s ease;
}

.app-header__icon-btn:hover {
  border-color: var(--muted);
  background: var(--surface);
  color: var(--accent-hover);
}

.app-header__icon-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.app-header__icon-btn svg {
  width: 1.15rem;
  height: 1.15rem;
  flex-shrink: 0;
}

.app-header__icon-btn--danger {
  border-color: rgba(180, 80, 80, 0.45);
  background: rgba(60, 24, 24, 0.35);
  color: #fecaca;
}

.app-header__icon-btn--danger:hover {
  border-color: #8b3a3a;
  background: #3d2020;
  color: #fde8e8;
}

.app-header__crumb {
  font-size: 0.95rem;
  color: var(--muted);
  font-family: "Sofia Pro", Helvetica, Arial, sans-serif;
}

.app-header__crumb a {
  color: var(--muted);
}

.app-header__crumb a:hover {
  color: var(--accent-hover);
}

main {
  max-width: 72rem;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

.msg {
  padding: 1rem 1.25rem;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: var(--shadow);
}

.msg--error {
  border-color: #7f1d1d;
  background: #1c0a0a;
  color: #fecaca;
}

.slice-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.slice-list a,
.album-list a {
  display: block;
  padding: 1rem 1.15rem;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.slice-list a:hover,
.album-list a:hover {
  border-color: #404040;
  transform: translateY(-1px);
}

.slice-list__meta {
  display: block;
  font-size: 0.88rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.album-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.6rem;
}

/* Home: year-folder collage — same track sizing as `.browse-grid` (min 140px / 160px), square cells */
.home-year-collage {
  margin: 0 0 1.5rem;
  padding-bottom: 1.15rem;
  border-bottom: 1px solid var(--border);
}

.home-year-collage__viewport {
  display: grid;
  grid-template-rows: auto;
  grid-template-columns: repeat(var(--home-collage-cols, 3), minmax(140px, 1fr));
  gap: 0.65rem;
  overflow: hidden;
  width: 100%;
  height: auto;
}

@media (min-width: 480px) {
  .home-year-collage__viewport {
    grid-template-columns: repeat(var(--home-collage-cols, 3), minmax(160px, 1fr));
    gap: 0.85rem;
  }
}

.home-year-collage__slot {
  position: relative;
  aspect-ratio: 1;
  width: 100%;
  min-width: 0;
  overflow: hidden;
}

/* Fill the square slot (same visual model as `.browse-tile__inner` + cover img). */
.home-year-collage__layer {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.home-year-collage__album-link {
  position: absolute;
  inset: 0;
  display: block;
  text-decoration: none;
  color: inherit;
  outline: none;
  pointer-events: auto;
}

.home-year-collage__album-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
  z-index: 1;
}

.home-year-collage__layer img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  user-select: none;
  pointer-events: none;
}

/* Slice / folder browser: same rhythm as album photo grid */
.browse-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.65rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

@media (min-width: 480px) {
  .browse-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.85rem;
  }
}

.browse-tile {
  aspect-ratio: 1;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
  text-decoration: none;
  color: var(--ink);
  box-shadow: var(--shadow);
  display: block;
  width: 100%;
  position: relative;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.browse-tile:hover {
  border-color: #404040;
  transform: translateY(-1px);
  color: var(--ink);
}

.browse-tile:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.browse-tile__inner {
  display: block;
  width: 100%;
  height: 100%;
  position: relative;
}

.browse-tile--album .browse-tile__inner,
.browse-tile--slice .browse-tile__inner {
  min-height: 0;
}

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

.browse-tile--folder .browse-tile__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  padding: 0.75rem;
  background: linear-gradient(155deg, var(--surface-raised) 0%, #0d0d0d 100%);
}

.browse-tile__folder-icon {
  width: 44px;
  height: 36px;
  border-radius: 6px 6px 4px 4px;
  background: linear-gradient(180deg, #3f3f46 0%, #27272a 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  position: relative;
}

.browse-tile__folder-icon::before {
  content: "";
  position: absolute;
  left: 0;
  top: -6px;
  width: 52%;
  height: 10px;
  background: #52525b;
  border-radius: 4px 4px 0 0;
}

.browse-tile__label {
  font-size: 0.82rem;
  line-height: 1.25;
  text-align: center;
  word-break: break-word;
  font-weight: 600;
  color: var(--muted);
}

.browse-tile--folder .browse-tile__label {
  color: var(--ink);
}

.browse-tile__label--overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 1.5rem 0.4rem 0.35rem;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: #fafaf9;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.82));
  word-break: break-word;
}

.browse-tile__label-stack {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 1.5rem 0.4rem 0.35rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.12rem;
  text-align: center;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.82));
  word-break: break-word;
}

.browse-tile__label-stack .browse-tile__label--overlay {
  position: static;
  padding: 0;
  background: none;
}

.browse-tile__label-stack--center {
  position: static;
  flex: 1;
  justify-content: center;
  padding: 0.75rem;
  background: none;
}

.browse-tile__slice-meta {
  font-size: 0.68rem;
  font-weight: 500;
  color: #d6d3d1;
  line-height: 1.2;
}

.browse-tile__slice-meta--plain {
  color: var(--muted);
  font-size: 0.8rem;
}

.browse-tile--album:hover .browse-tile__label--overlay,
.browse-tile--slice:hover .browse-tile__label--overlay {
  color: #ffffff;
}

.browse-tile--slice:hover .browse-tile__slice-meta {
  color: #e7e5e4;
}

.browse-tile--fallback .browse-tile__inner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
}

.browse-tile--fallback .browse-tile__label {
  color: var(--ink);
  font-size: 0.88rem;
}

.browse-tile .video-badge {
  bottom: 6px;
  right: 6px;
}

.section-title {
  font-family: "Sofia Pro", Helvetica, Arial, sans-serif;
  font-size: 1.15rem;
  margin: 0 0 1rem;
  color: var(--muted);
  font-weight: 600;
}

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

@media (min-width: 480px) {
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.85rem;
  }
}

.grid__cell {
  aspect-ratio: 1;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  padding: 0;
  display: block;
  width: 100%;
  position: relative;
}

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

.grid__cell:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Native MP4 uploads may have no poster (Option A); show a clear play affordance. */
.grid__cell--video-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #1a1a1f 0%, #2d2d36 100%);
}

.grid__cell-video-placeholder-inner {
  font-size: clamp(2rem, 12vw, 3.25rem);
  line-height: 1;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

.video-badge {
  position: absolute;
  bottom: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 14px;
  line-height: 28px;
  text-align: center;
  pointer-events: none;
}

/* Full-screen lightbox: media uses full viewport; controls overlay */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #000;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: stretch;
  padding: 0;
  animation: lb-in 0.2s ease;
}

@keyframes lb-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.lightbox__close {
  position: absolute;
  top: max(0.75rem, env(safe-area-inset-top));
  right: max(0.75rem, env(safe-area-inset-right));
  z-index: 102;
  width: 44px;
  height: 44px;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #f5f5f4;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  appearance: none;
  -webkit-appearance: none;
}

.lightbox__close:hover {
  background: rgba(255, 255, 255, 0.22);
}

.lightbox__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 101;
  width: 48px;
  height: 48px;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: #f5f5f4;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  appearance: none;
  -webkit-appearance: none;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.lightbox__nav:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.2);
}

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

.lightbox__nav--prev {
  left: max(0.5rem, env(safe-area-inset-left));
}

.lightbox__nav--next {
  right: max(0.5rem, env(safe-area-inset-right));
}

.lightbox__body {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.lightbox__stage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom)
    env(safe-area-inset-left);
  touch-action: manipulation;
}

.lightbox__stage img,
.lightbox__stage video {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 0;
  background: #000;
}

.lightbox__actions {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 102;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding-top: 0.75rem;
  padding-right: max(1rem, env(safe-area-inset-right));
  padding-bottom: max(0.85rem, calc(0.35rem + env(safe-area-inset-bottom)));
  padding-left: max(1rem, env(safe-area-inset-left));
  pointer-events: none;
}

.lightbox__actions > * {
  pointer-events: auto;
}

.lightbox__actions-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: center;
}

.lightbox__download,
.lightbox__share,
.lightbox__info,
.lightbox__unmute,
.lightbox__delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.45);
  color: #f5f5f4;
  cursor: pointer;
  text-decoration: none;
  backdrop-filter: blur(8px);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.lightbox__delete {
  border-color: rgba(248, 113, 113, 0.45);
  color: #fecaca;
}

.lightbox__download:hover,
.lightbox__share:hover:not(:disabled),
.lightbox__info:hover,
.lightbox__unmute:hover,
.lightbox__delete:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.35);
  color: #ffffff;
}

.lightbox__delete:hover:not(:disabled) {
  background: rgba(185, 28, 28, 0.55);
  border-color: rgba(254, 202, 202, 0.55);
}

.lightbox__share:disabled {
  opacity: 0.55;
  cursor: wait;
}

.lightbox__icon {
  display: block;
  flex-shrink: 0;
}

/* Image metadata (operator-only): above lightbox (z-index 100) */
.image-info-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right))
    max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  box-sizing: border-box;
}

.image-info-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
}

.image-info-modal__panel {
  position: relative;
  z-index: 1;
  width: min(42rem, 100%);
  max-height: min(85vh, 100%);
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: #141413;
  color: #e7e5e4;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.65);
}

.image-info-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem 0.65rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.image-info-modal__title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.image-info-modal__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #f5f5f4;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.image-info-modal__close:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.image-info-modal__body {
  padding: 0.75rem 1rem 1rem;
  overflow: auto;
  flex: 1;
  min-height: 0;
}

.image-info-modal__loading {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted, #a8a29e);
}

.image-info-modal__summary-wrap {
  margin: 0;
}

.image-info-modal__summary-title {
  margin: 0 0 0.5rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted, #a8a29e);
}

.image-info-modal__warn-list {
  margin: 0 0 0.75rem;
  padding-left: 1.1rem;
  font-size: 0.8rem;
  line-height: 1.35;
}

.image-info-modal__dl {
  display: grid;
  grid-template-columns: minmax(8rem, 11.5rem) 1fr;
  gap: 0.4rem 0.85rem;
  margin: 0 0 1rem;
  font-size: 0.82rem;
  line-height: 1.45;
}

.image-info-modal__dl dt {
  margin: 0;
  color: var(--muted, #a8a29e);
  font-weight: 500;
}

.image-info-modal__dd {
  margin: 0;
  word-break: break-word;
  color: #e7e5e4;
}

.image-info-modal__dd a {
  color: #93c5fd;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.image-info-modal__dd a:hover {
  color: #bfdbfe;
}

.image-info-modal__raw {
  margin: 0;
  padding-top: 0.65rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.image-info-modal__raw-summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--muted, #a8a29e);
  list-style: none;
}

.image-info-modal__raw summary::-webkit-details-marker {
  display: none;
}

.image-info-modal__raw-summary:hover,
.image-info-modal__raw-summary:focus-visible {
  color: #d6d3d1;
  outline: none;
}

.image-info-modal__pre--raw {
  margin-top: 0.5rem;
  max-height: min(38vh, 280px);
}

.image-info-modal__section {
  margin-bottom: 1.1rem;
}

.image-info-modal__section:last-child {
  margin-bottom: 0;
}

.image-info-modal__section-title {
  margin: 0 0 0.45rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted, #a8a29e);
}

.image-info-modal__pre {
  margin: 0;
  padding: 0.65rem 0.75rem;
  font-size: 0.7rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #d6d3d1;
  max-height: 40vh;
  overflow: auto;
}

.image-info-modal__empty,
.image-info-modal__error {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.4;
  color: var(--muted, #a8a29e);
}

.image-info-modal__error {
  color: #fca5a5;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* View counts: fixed bottom-right when browsing; in lightbox, pinned to the bar’s right edge (download stays centered) */
.analytics-stats {
  position: fixed;
  right: max(0.65rem, env(safe-area-inset-right));
  bottom: max(0.65rem, calc(0.35rem + env(safe-area-inset-bottom)));
  z-index: 110;
  width: max-content;
  max-width: min(15.5rem, calc(100vw - 1.35rem));
  margin: 0;
  padding: 0.45rem 0.6rem 0.55rem;
  font-size: 0.65rem;
  line-height: 1.32;
  letter-spacing: 0.01em;
  color: var(--muted);
  background: rgba(10, 10, 10, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 7px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(10px);
  pointer-events: none;
}

/* In-flow under the control buttons so tall content doesn’t overflow below the viewport
   (absolute + top:50% was centered in ~48px-tall row only). */
.analytics-stats--in-lightbox {
  position: static;
  top: auto;
  right: auto;
  bottom: auto;
  left: auto;
  transform: none;
  z-index: 1;
  align-self: flex-end;
  max-width: min(18rem, calc(100vw - 5.5rem));
  flex-shrink: 0;
  margin: 0;
}

.analytics-stats__body {
  margin: 0;
  padding: 0;
}

.analytics-stats__user {
  margin: 0 0 0.45rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.68rem;
  line-height: 1.35;
  color: var(--muted);
}

.analytics-stats__user strong {
  color: var(--ink);
  font-weight: 600;
}

.analytics-stats__lines {
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
}

.analytics-stats__line {
  margin: 0;
  font-size: 0.65rem;
  line-height: 1.3;
  color: var(--muted);
}

.analytics-stats__line strong {
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  font-weight: 600;
}

.analytics-stats__line .analytics-stats__na {
  font-size: 0.68rem;
  color: var(--muted);
  font-weight: 500;
}

.analytics-stats__empty {
  margin: 0;
  font-size: inherit;
  color: var(--muted);
}

/* Family gate (gate.js) */
body.family-gate-open {
  overflow: hidden;
}

.family-gate {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: max(0.65rem, env(safe-area-inset-top)) 1.15rem max(0.65rem, env(safe-area-inset-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(14px);
}

.family-gate__panel {
  width: 100%;
  max-width: 22rem;
  flex-shrink: 0;
  margin-top: auto;
  margin-bottom: auto;
  padding: 1.25rem 1.2rem;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.family-gate__title {
  margin: 0 0 0.2rem;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.family-gate__lead {
  margin: 0 0 0.85rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.family-gate__error {
  margin: 0 0 0.65rem;
  padding: 0.5rem 0.65rem;
  font-size: 0.88rem;
  color: #fecaca;
  background: #1c0a0a;
  border: 1px solid #7f1d1d;
  border-radius: 6px;
}

.family-gate__form {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.family-gate__label {
  font-size: 0.85rem;
  color: var(--muted);
}

.family-gate__input {
  width: 100%;
  padding: 0.55rem 0.65rem;
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.family-gate__input:focus {
  outline: none;
  border-color: #404040;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14);
}

.family-gate__submit {
  margin-top: 0.1rem;
  padding: 0.55rem 0.9rem;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}

.family-gate__submit:hover {
  background: var(--surface-raised);
  border-color: #3f3f3f;
  color: var(--accent-hover);
}

.family-gate__or {
  margin: 0.75rem 0;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
  position: relative;
}

.family-gate__or span {
  position: relative;
  padding: 0 0.5rem;
  background: var(--surface-raised);
}

.family-gate__or::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background: var(--border);
}

.family-gate__google-wrap {
  display: flex;
  flex-direction: column;
  width: 100%;
  align-items: stretch;
  gap: 0;
}

.family-gate__google-shell {
  width: 100%;
  box-sizing: border-box;
  padding: 0.3rem 0.45rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 46px;
}

.family-gate__google-btn {
  display: flex;
  justify-content: center;
  align-items: center;
  line-height: 0;
  width: 100%;
}

.family-gate__google-btn > div {
  background: transparent !important;
}

.family-gate__google-btn iframe {
  color-scheme: light;
}

/* Album upload (operators — planning/UI_UPLOAD_NEW_FOLDER.md) */
.upload-panel {
  margin-top: 2rem;
  padding: 1.25rem 1rem;
  max-width: 42rem;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.upload-panel__title {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  font-weight: 600;
}

.upload-panel__hint {
  margin: 0 0 1rem;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.4;
}

.upload-panel__drop {
  padding: 1.25rem 1rem;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-raised);
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    background 0.15s ease;
}

.upload-panel__drop:hover,
.upload-panel__drop:focus {
  outline: none;
  border-color: var(--muted);
}

.upload-panel__drop--active {
  border-color: var(--accent);
  background: rgba(231, 229, 228, 0.06);
}

.upload-panel__drop-label {
  font-size: 0.95rem;
  color: var(--ink);
}

.upload-panel__list {
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}

.upload-panel__item {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}

.upload-panel__item:last-child {
  border-bottom: none;
}

.upload-panel__item-name {
  word-break: break-word;
  color: var(--ink);
}

.upload-panel__item-state {
  color: var(--muted);
  flex-shrink: 0;
}

.upload-panel__status {
  margin: 0.75rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.upload-panel--delete {
  border-color: rgba(180, 80, 80, 0.45);
  background: rgba(60, 24, 24, 0.12);
}

.upload-panel__delete-btn {
  font: inherit;
  padding: 0.55rem 1rem;
  border-radius: 8px;
  border: 1px solid #8b3a3a;
  background: #3d2020;
  color: #fde8e8;
  cursor: pointer;
}

.upload-panel__delete-btn:hover:not(:disabled) {
  background: #4a2828;
}

.upload-panel__delete-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.create-folder-panel__form {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  max-width: 24rem;
}

.create-folder-panel__label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
}

.create-folder-panel__input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.45rem 0.55rem;
  font-size: 0.95rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-raised);
  color: var(--ink);
}

.create-folder-panel__actions {
  margin-top: 0.35rem;
}

.create-folder-panel__submit {
  padding: 0.45rem 1rem;
  font-size: 0.92rem;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--accent);
  color: var(--surface);
  cursor: pointer;
}

.create-folder-panel__submit:hover:not(:disabled) {
  filter: brightness(1.06);
}

.create-folder-panel__submit:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.create-tree-panel__subtitle {
  margin: 1.25rem 0 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
}

.create-tree-panel .create-tree-panel__subtitle:first-of-type {
  margin-top: 0.5rem;
}

.create-folder-panel__submit--secondary {
  background: var(--surface-raised);
  color: var(--ink);
  border-color: var(--border);
}

.create-folder-panel__submit--secondary:hover:not(:disabled) {
  filter: none;
  border-color: var(--muted);
  background: var(--surface);
}

/* Toast: site-tree create success / error (persists across route() re-render) */
.gallery-tree-toast {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%) translateY(-120%);
  z-index: 10050;
  max-width: min(32rem, calc(100vw - 2rem));
  padding: 0.75rem 1.1rem;
  font-size: 0.92rem;
  line-height: 1.35;
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
  transition: transform 0.28s ease, opacity 0.28s ease;
  opacity: 0;
  pointer-events: none;
}

.gallery-tree-toast--visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.gallery-tree-toast--ok {
  background: var(--surface-raised);
  color: var(--ink);
  border: 1px solid var(--border);
}

.gallery-tree-toast--error {
  background: #3d2020;
  color: #fde8e8;
  border: 1px solid #8b3a3a;
}

/* Operator modals (create album/folder, delete album) — opened from header icons */
.gallery-modal {
  margin: auto;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  max-width: min(36rem, calc(100vw - 2rem));
  box-shadow: var(--shadow);
}

.gallery-modal--upload {
  max-width: min(42rem, calc(100vw - 2rem));
}

.gallery-modal::backdrop {
  background: rgba(0, 0, 0, 0.65);
}

.gallery-modal__inner {
  position: relative;
  padding: 1.35rem 1.1rem 1.1rem;
}

.gallery-modal__close {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.gallery-modal__close:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
}

.upload-panel--in-modal {
  margin-top: 0;
  padding: 0;
  max-width: none;
  border: none;
  background: transparent;
}

.upload-panel--in-modal .upload-panel__title {
  padding-right: 2rem;
}

.upload-panel.upload-panel--in-modal.upload-panel--delete {
  margin-top: 0;
  padding: 0.85rem 0.9rem 0.95rem;
  border-radius: 8px;
  border: 1px solid rgba(180, 80, 80, 0.35);
  background: rgba(60, 24, 24, 0.12);
}
