/* Layout — nav bar, home view, overlay positioning, responsive breakpoints. */

/* ===========================================================
   Body
   =========================================================== */
body {
  display: flex;
  flex-direction: column;
  min-height: 100svh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===========================================================
   Nav bar
   =========================================================== */
.pic-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: var(--pic-space-sm) var(--pic-space-md);
  background: var(--pic-header-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--pic-header-border);
  flex-shrink: 0;
}

/* ===========================================================
   Home view — centred hub
   =========================================================== */
.pic-home {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--pic-space-lg) var(--pic-space-md);
}

.pic-home__content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: 100%;
  max-width: 420px;
  gap: var(--pic-space-md);
}

/* Brand row — logo sits inline to the LEFT of the title (compact header,
   less top vertical space). */
.pic-home__brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.pic-home__logo {
  color: var(--pic-accent);
  opacity: 0.7;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}

.pic-home__title {
  font-size: var(--pic-font-2xl);
  font-weight: 300;
  letter-spacing: 0.08em;
  color: var(--pic-title);
  line-height: 1.2;
  margin: 0;
}

/* Version badge beside the app name (set per build from the edition config). */
.pic-home__version {
  align-self: center;
  margin-left: 8px;
  padding: 2px 8px;
  border: 1px solid var(--pic-border);
  border-radius: 999px;
  font-size: var(--pic-font-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--pic-muted);
  white-space: nowrap;
}

.pic-home__tagline {
  font-size: var(--pic-font-sm);
  color: var(--pic-subtle);
  max-width: 360px;
  line-height: 1.6;
}

.pic-home__tagline strong {
  color: var(--pic-text);
  font-weight: 600;
}

/* Privacy badge — reinforces the core "nothing is uploaded" promise. */
.pic-privacy-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 4px 12px;
  font-size: var(--pic-font-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--pic-success);
  background: var(--pic-input-bg);
  border: 1px solid var(--pic-border);
  border-radius: 999px;
}

.pic-privacy-badge__icon {
  flex-shrink: 0;
  color: var(--pic-success);
}

.pic-home__formats {
  font-size: var(--pic-font-xs);
  color: var(--pic-muted);
  letter-spacing: 0.04em;
  margin-top: var(--pic-space-sm);
}

/* App attribution footer — fixed credit at the bottom of the page. */
.pic-footer {
  padding: var(--pic-space-md);
  text-align: center;
  font-size: var(--pic-font-xs);
  line-height: 1.6;
  color: var(--pic-muted);
  border-top: 1px solid var(--pic-header-border);
}

.pic-footer a {
  color: var(--pic-subtle);
  text-decoration: none;
  font-weight: 500;
}

.pic-footer a:hover,
.pic-footer a:focus-visible {
  color: var(--pic-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.pic-footer__version {
  margin-top: var(--pic-space-xs);
  color: var(--pic-subtle);
  font-size: var(--pic-font-xs);
  letter-spacing: 0.02em;
}

/* ===========================================================
   Gallery overlay
   =========================================================== */
.pic-gallery-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--pic-overlay-bg);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.pic-gallery-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

.pic-gallery {
  display: flex;
  flex-direction: column;
  gap: var(--pic-space-md);
  width: 90vw;
  max-width: 1000px;
  height: 85vh;
  height: 85dvh; /* dynamic viewport: keep the header + bottom controls reachable
                    on mobile, where 85vh can sit behind the browser UI */
  overflow: hidden;
  padding: var(--pic-space-lg);
  background: var(--pic-panel-bg);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--pic-radius-lg);
}

.pic-gallery__header {
  display: flex;
  flex-wrap: wrap; /* never clip the close (×) off-screen on narrow phones */
  align-items: center;
  gap: var(--pic-space-sm);
  flex-shrink: 0;
}

.pic-gallery__grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px;
  flex: 1 1 0px;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.pic-gallery__grid::-webkit-scrollbar { width: 6px; }
.pic-gallery__grid::-webkit-scrollbar-track { background: transparent; }
.pic-gallery__grid::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

/* ===========================================================
   Export overlay
   =========================================================== */
.pic-export-overlay,
.pic-settings-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--pic-overlay-bg);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.pic-export-overlay.is-open,
.pic-settings-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

.pic-export,
.pic-settings {
  display: flex;
  flex-direction: column;
  gap: var(--pic-space-md);
  width: 90vw;
  max-width: 600px;
  max-height: 85vh;
  padding: var(--pic-space-lg);
  background: var(--pic-panel-bg);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--pic-radius-lg);
  overflow-y: auto;
}

.pic-export__header,
.pic-settings__header {
  display: flex;
  align-items: center;
  gap: var(--pic-space-sm);
  flex-shrink: 0;
}

.pic-export__body,
.pic-settings__body {
  display: flex;
  flex-direction: column;
  gap: var(--pic-space-lg);
}

.pic-export__group {
  display: flex;
  flex-direction: column;
  gap: var(--pic-space-xs);
}

.pic-export__social {
  border: none;
  padding: 0;
}

.pic-export__social legend {
  margin-bottom: var(--pic-space-xs);
}

.pic-export__social-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--pic-space-xs) var(--pic-space-md);
}

@media (max-width: 520px) {
  .pic-export__social-grid {
    grid-template-columns: 1fr;
  }
}

/* ===========================================================
   Rename modal — floats above gallery overlay
   =========================================================== */
.pic-rename-overlay {
  position: fixed;
  inset: 0;
  z-index: 250;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.pic-rename-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

.pic-rename {
  display: flex;
  flex-direction: column;
  gap: var(--pic-space-md);
  width: 90vw;
  max-width: 420px;
  padding: var(--pic-space-lg);
  background: var(--pic-panel-bg);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--pic-radius-lg);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}

/* ===========================================================
   Batch rename modal — floats above all overlays
   =========================================================== */
.pic-batch-rename-overlay {
  position: fixed;
  inset: 0;
  z-index: 260;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.pic-batch-rename-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

.pic-batch-rename {
  display: flex;
  flex-direction: column;
  gap: var(--pic-space-md);
  width: 90vw;
  max-width: 560px;
  max-height: 85vh;
  padding: var(--pic-space-lg);
  background: var(--pic-panel-bg);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--pic-radius-lg);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}

/* ===========================================================
   First-run onboarding
   =========================================================== */
.pic-onboarding-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.pic-onboarding-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

.pic-onboarding {
  display: flex;
  flex-direction: column;
  gap: var(--pic-space-lg);
  width: 90vw;
  max-width: 440px;
  padding: var(--pic-space-xl) var(--pic-space-lg) var(--pic-space-lg);
  background: var(--pic-panel-bg);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--pic-radius-lg);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  text-align: center;
}

/* ===========================================================
   Quick export options modal (Gallery library)
   =========================================================== */
.pic-export-options-overlay {
  position: fixed;
  inset: 0;
  z-index: 260;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.pic-export-options-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

.pic-export-options {
  display: flex;
  flex-direction: column;
  gap: var(--pic-space-md);
  width: 90vw;
  max-width: 460px;
  max-height: 85vh;
  padding: var(--pic-space-lg);
  background: var(--pic-panel-bg);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--pic-radius-lg);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}

/* ===========================================================
   Guided task wizard (Core Tasks) — mirrors the export-options modal
   =========================================================== */
.pic-wizard-overlay {
  position: fixed;
  inset: 0;
  z-index: 260;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}
.pic-wizard-overlay.is-open {
  opacity: 1;
  visibility: visible;
}
.pic-wizard {
  display: flex;
  flex-direction: column;
  gap: var(--pic-space-md);
  width: 92vw;
  max-width: 560px;
  height: 88vh;
  height: 88dvh; /* fit the visible area on mobile */
  padding: var(--pic-space-lg);
  background: var(--pic-panel-bg);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--pic-radius-lg);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}
.pic-wizard__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--pic-space-md);
  flex-shrink: 0;
}
.pic-wizard__title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--pic-text);
}
.pic-wizard__close {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  line-height: 1;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--pic-radius-sm);
  color: var(--pic-subtle);
  cursor: pointer;
}
.pic-wizard__close:hover {
  background: rgba(255, 255, 255, 0.16);
  color: var(--pic-text);
}
.pic-wizard__body {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--pic-space-md);
}
.pic-wizard__stepinfo {
  margin: 0;
  color: var(--pic-subtle);
  font-size: var(--pic-font-sm);
}
.pic-wizard__row {
  display: flex;
  flex-direction: column;
  gap: var(--pic-space-sm);
}
.pic-wizard__row + .pic-wizard__row {
  margin-top: var(--pic-space-md);
}
.pic-wizard__custom {
  display: flex;
  align-items: center;
  gap: var(--pic-space-sm);
  margin-top: var(--pic-space-xs);
}
.pic-wizard__custom .pic-input {
  width: 8rem;
}
.pic-wizard__summary {
  margin: 0;
  color: var(--pic-subtle);
}
.pic-wizard__footer {
  display: flex;
  gap: var(--pic-space-sm);
  justify-content: flex-end;
  flex-shrink: 0;
}
.pic-wizard__cancel {
  margin-right: auto;
}
.pic-radio__hint {
  display: block;
  margin-top: 2px;
  color: var(--pic-subtle);
  font-size: var(--pic-font-sm);
}

/* Exporting state — spinner + determinate bar so a big batch never looks hung */
.pic-wizard__working {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--pic-space-md);
  text-align: center;
  padding: var(--pic-space-lg) 0;
}
.pic-spinner {
  width: 44px;
  height: 44px;
  border: 4px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--pic-accent);
  border-radius: 50%;
  animation: pic-spin 0.8s linear infinite;
}
@keyframes pic-spin {
  to { transform: rotate(360deg); }
}
.pic-wizard__working-title {
  margin: 0;
  font-weight: 600;
  color: var(--pic-text);
}
.pic-wizard__bar {
  width: 100%;
  max-width: 320px;
  height: 10px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  overflow: hidden;
}
.pic-wizard__bar-fill {
  height: 100%;
  width: 0%;
  background: var(--pic-accent);
  border-radius: 999px;
  transition: width 0.2s ease;
}
.pic-wizard__working-text {
  margin: 0;
  color: var(--pic-text);
  font-size: var(--pic-font-sm);
}
.pic-wizard__working-hint {
  margin: 0;
  color: var(--pic-subtle);
  font-size: var(--pic-font-xs);
}
@media (prefers-reduced-motion: reduce) {
  .pic-spinner {
    animation: none;
    opacity: 0.85;
  }
}

/* Manual social crop queue — drag a ratio-locked box to choose what to keep */
.pic-wizard__crop-counter {
  margin: 0;
  text-align: center;
  color: var(--pic-subtle);
  font-size: var(--pic-font-sm);
}
.pic-wizard__crop-stage {
  position: relative;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
  background: rgba(0, 0, 0, 0.35);
  border-radius: var(--pic-radius-md);
  overflow: hidden;
  line-height: 0;
  touch-action: none;
  user-select: none;
}
.pic-wizard__crop-stage canvas {
  display: block;
}
.pic-wizard__crop-box {
  position: absolute;
  box-sizing: border-box;
  border: 2px solid #fff;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55);
  cursor: move;
  touch-action: none;
}
.pic-wizard__crop-hint {
  margin: 0;
  text-align: center;
  color: var(--pic-subtle);
  font-size: var(--pic-font-sm);
}
.pic-wizard__crop-controls {
  display: flex;
  gap: var(--pic-space-sm);
  justify-content: flex-end;
  flex-shrink: 0;
}
.pic-wizard__crop-back {
  margin-right: auto;
}

/* ===========================================================
   Shared export-progress overlay (Advanced tools) — spinner + bar
   =========================================================== */
.pic-export-progress-overlay {
  position: fixed;
  inset: 0;
  z-index: 300; /* above the tool panels, below the result modal (310) */
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}
.pic-export-progress-overlay.is-open {
  opacity: 1;
  visibility: visible;
}
.pic-export-progress {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--pic-space-md);
  width: 90vw;
  max-width: 360px;
  padding: var(--pic-space-lg);
  text-align: center;
  background: var(--pic-panel-bg);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--pic-radius-lg);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}
.pic-export-progress__title {
  margin: 0;
  font-weight: 600;
  color: var(--pic-text);
}
.pic-export-progress__bar {
  width: 100%;
  height: 10px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  overflow: hidden;
}
.pic-export-progress__fill {
  height: 100%;
  width: 0%;
  background: var(--pic-accent);
  border-radius: 999px;
  transition: width 0.2s ease;
}
.pic-export-progress__text {
  margin: 0;
  color: var(--pic-text);
  font-size: var(--pic-font-sm);
}
.pic-export-progress__hint {
  margin: 0;
  color: var(--pic-subtle);
  font-size: var(--pic-font-xs);
}

/* ===========================================================
   Export complete summary modal (locked; floats above tool panel)
   =========================================================== */
.pic-export-result-overlay {
  position: fixed;
  inset: 0;
  z-index: 310;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.65);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.pic-export-result-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

.pic-export-result {
  display: flex;
  flex-direction: column;
  gap: var(--pic-space-md);
  width: 90vw;
  max-width: 520px;
  max-height: 85vh;
  padding: var(--pic-space-lg);
  background: var(--pic-panel-bg);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--pic-radius-lg);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}

/* ===========================================================
   Confirm modal — floats above gallery overlay
   =========================================================== */
.pic-confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 250;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.pic-confirm-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

.pic-confirm {
  display: flex;
  flex-direction: column;
  gap: var(--pic-space-md);
  width: 90vw;
  max-width: 400px;
  padding: var(--pic-space-lg);
  background: var(--pic-panel-bg);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--pic-radius-lg);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}

/* ===========================================================
   Help overlay — Using the app + About image optimization
   =========================================================== */
.pic-help-overlay {
  position: fixed;
  inset: 0;
  z-index: 220;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--pic-overlay-bg);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.pic-help-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

.pic-help__panel {
  display: flex;
  flex-direction: column;
  width: 90vw;
  max-width: 880px;
  height: 88vh;
  background: var(--pic-panel-bg);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--pic-radius-lg);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.pic-help__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--pic-space-md) var(--pic-space-lg);
  border-bottom: 1px solid var(--pic-border);
  flex-shrink: 0;
}

.pic-help__tabs {
  display: flex;
  gap: 0;
  padding: 0 var(--pic-space-lg);
  border-bottom: 1px solid var(--pic-border);
  flex-shrink: 0;
}

.pic-help__body {
  flex: 1 1 0;
  overflow-y: auto;
  padding: var(--pic-space-lg) var(--pic-space-xl);
}

.pic-help__pane[hidden] {
  display: none;
}

/* ===========================================================
   Editor overlay — crop & rotate
   =========================================================== */
.pic-editor-overlay {
  position: fixed;
  inset: 0;
  z-index: 245;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.pic-editor-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

.pic-editor {
  position: relative; /* anchor the "?" help pop-up */
  display: flex;
  flex-direction: column;
  gap: var(--pic-space-sm);
  width: 96vw;
  height: 94vh;
  height: 94dvh; /* dynamic viewport: keep the toolbar/footer on-screen above mobile browser UI */
  padding: var(--pic-space-sm) var(--pic-space-md);
  background: var(--pic-panel-bg);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--pic-radius-lg);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}

.pic-editor__header {
  display: flex;
  align-items: center;
  gap: var(--pic-space-md);
  flex-shrink: 0;
}

.pic-editor__toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--pic-space-md);
  align-items: center;
  flex-shrink: 0;
}

.pic-editor__group {
  display: flex;
  align-items: center;
  gap: var(--pic-space-xs);
}

.pic-editor__group--aspect {
  flex-wrap: wrap;
}

.pic-editor__stage {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
  touch-action: none;
  cursor: crosshair;
}

.pic-editor__canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.pic-editor__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--pic-space-md);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.pic-editor__actions {
  display: flex;
  gap: var(--pic-space-sm);
}

/* ===========================================================
   Lightbox overlay — full-image viewer above gallery
   =========================================================== */
.pic-lightbox-overlay {
  position: fixed;
  inset: 0;
  z-index: 240;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.pic-lightbox-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

.pic-lightbox {
  display: flex;
  flex-direction: column;
  gap: var(--pic-space-sm);
  width: 96vw;
  max-width: 1600px;
  height: 94vh;
  padding: var(--pic-space-sm) var(--pic-space-md);
  background: var(--pic-panel-bg);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--pic-radius-lg);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}

.pic-lightbox__header {
  display: flex;
  align-items: center;
  gap: var(--pic-space-md);
  flex-shrink: 0;
}

.pic-lightbox__stage {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pic-lightbox__image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--pic-radius-md);
  background: rgba(0, 0, 0, 0.4);
}

.pic-lightbox__toolbar {
  display: flex;
  gap: var(--pic-space-sm);
  justify-content: flex-end;
  flex-shrink: 0;
}
/* Pushes Delete to the far left, keeping the other actions grouped on the
   right (so a stray Delete tap is well away from Play/Print/Close). */
.pic-lightbox__action--far {
  margin-right: auto;
}

/* ===========================================================
   Loading overlay — sits above main views, below batch-rename
   =========================================================== */
.pic-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 255;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, visibility 0.15s ease;
}

.pic-loading-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

.pic-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--pic-space-md);
  padding: var(--pic-space-lg) var(--pic-space-xl);
  background: var(--pic-panel-bg);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--pic-radius-lg);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  min-width: 220px;
  text-align: center;
}

/* ===========================================================
   Drop zone overlay (visible only when dragging files)
   =========================================================== */
.pic-drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: opacity 0.2s ease;
}

.pic-drop-overlay.hidden {
  display: none;
}

.pic-drop-overlay__content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 48px 64px;
  border: 3px dashed var(--pic-accent);
  border-radius: var(--pic-radius-xl);
  color: #fff;
  pointer-events: none;
  animation: pic-drop-pulse 1.5s ease-in-out infinite alternate;
}

.pic-drop-overlay__icon {
  font-size: 3.5rem;
  line-height: 1;
}

.pic-drop-overlay__label {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.pic-drop-overlay__hint {
  font-size: 0.8rem;
  color: var(--pic-muted);
}

@keyframes pic-drop-pulse {
  from {
    border-color: var(--pic-accent);
    box-shadow: 0 0 0 0 rgba(96, 165, 250, 0);
  }
  to {
    border-color: var(--pic-glow-border);
    box-shadow: 0 0 30px 4px rgba(96, 165, 250, 0.18);
  }
}

/* ===========================================================
   Toast area
   =========================================================== */
.pic-toast-area {
  position: fixed;
  bottom: var(--pic-space-lg);
  left: 50%;
  transform: translateX(-50%);
  z-index: 400;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--pic-space-sm);
  pointer-events: none;
  width: max-content;
  max-width: calc(100vw - 32px);
}

/* ===========================================================
   Responsive — Tablet
   =========================================================== */
@media (max-width: 768px) {
  .pic-home__title {
    font-size: var(--pic-font-xl);
    letter-spacing: 0.06em;
  }

  .pic-home {
    padding: var(--pic-space-md) var(--pic-space-sm);
  }

  .pic-gallery__grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
  }
}

/* ===========================================================
   Responsive — Mobile
   =========================================================== */
@media (max-width: 480px) {
  .pic-nav {
    gap: 2px;
    padding: 6px 8px;
  }

  .pic-home__title {
    font-size: var(--pic-font-lg);
    letter-spacing: 0.04em;
  }

  .pic-home__logo {
    width: 34px;
    height: 34px;
  }

  .pic-gallery {
    width: 95vw;
    padding: var(--pic-space-md);
  }

  .pic-gallery__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .pic-gallery__add-label {
    display: none;
  }

  .pic-gallery__close-bottom {
    align-self: stretch; /* full-width, easy to tap on a phone */
  }

  /* Header on phones: title + count + Add on the first row, with the × close
     pinned to the FAR right (margin-left:auto opens a clear gap so it's never
     mistaken for the Add button). "Delete All" drops to its own row. */
  /* Two classes to outrank components.css's .pic-gallery__count{flex:1}
     (equal specificity there would otherwise win by load order). */
  .pic-gallery__header .pic-gallery__count { flex: 0 1 auto; }
  .pic-gallery__add { order: 1; }
  .pic-gallery__close { order: 2; margin-left: auto; }
  .pic-gallery__clear { order: 3; }

  .pic-export {
    width: 95vw;
    padding: var(--pic-space-md);
  }

  .pic-drop-overlay__content {
    padding: 32px;
  }

  .pic-batch-rename {
    width: 95vw;
    padding: var(--pic-space-md);
  }
}

/* ===========================================================
   Responsive — Small mobile
   =========================================================== */
@media (max-width: 320px) {
  .pic-home__title {
    font-size: var(--pic-font-base);
  }
}
