/* AubePhotos — minimaliste, deux themes : blanc et noir.
   Chaque theme decoule de --bg, --fg, --line. Pas de couleur. */

:root,
[data-theme="light"] {
  --bg:        #ffffff;
  --bg-2:      #fafafa;
  --bg-3:      #f4f4f4;
  --bg-4:      #ececec;
  --fg:        #000000;
  --fg-soft:   #5a5a5a;
  --fg-mute:   #9a9a9a;
  --line:      rgba(0, 0, 0, 0.10);
  --line-soft: rgba(0, 0, 0, 0.06);
  --accent:    #000000;
  --accent-fg: #ffffff;
  --shadow-1:  0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-2:  0 4px 16px rgba(0, 0, 0, 0.06);
  --overlay:   rgba(255, 255, 255, 0.92);
  --kbd-bg:    #f4f4f4;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg:        #000000;
  --bg-2:      #0a0a0a;
  --bg-3:      #141414;
  --bg-4:      #1f1f1f;
  --fg:        #ffffff;
  --fg-soft:   #a8a8a8;
  --fg-mute:   #6b6b6b;
  --line:      rgba(255, 255, 255, 0.12);
  --line-soft: rgba(255, 255, 255, 0.06);
  --accent:    #ffffff;
  --accent-fg: #000000;
  --shadow-1:  0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-2:  0 4px 16px rgba(0, 0, 0, 0.6);
  --overlay:   rgba(0, 0, 0, 0.92);
  --kbd-bg:    #1f1f1f;
  color-scheme: dark;
}

/* Si l'utilisateur n'a pas choisi: suit prefers-color-scheme */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg:        #000000;
    --bg-2:      #0a0a0a;
    --bg-3:      #141414;
    --bg-4:      #1f1f1f;
    --fg:        #ffffff;
    --fg-soft:   #a8a8a8;
    --fg-mute:   #6b6b6b;
    --line:      rgba(255, 255, 255, 0.12);
    --line-soft: rgba(255, 255, 255, 0.06);
    --accent:    #ffffff;
    --accent-fg: #000000;
    --shadow-1:  0 1px 2px rgba(0, 0, 0, 0.5);
    --shadow-2:  0 4px 16px rgba(0, 0, 0, 0.6);
    --overlay:   rgba(0, 0, 0, 0.92);
    --kbd-bg:    #1f1f1f;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', system-ui, sans-serif;
  color: var(--fg);
  background: var(--bg);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv11', 'ss01';
  transition: background 0.15s ease, color 0.15s ease;
}

.hidden { display: none !important; }
.muted { color: var(--fg-soft); }
.micro { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 11px; color: var(--fg-mute); letter-spacing: 0.02em; }
.error { color: #d33b3b; font-size: 13px; }

button { font-family: inherit; cursor: pointer; }
a { color: inherit; }

/* ============================================================
   LOGIN
   ============================================================ */
.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--bg);
  padding: 24px;
}
.login-card {
  background: var(--bg);
  padding: 48px 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  width: min(420px, 100%);
  text-align: center;
  box-shadow: var(--shadow-1);
}
.login-card img {
  display: block; margin: 0 auto 20px;
  color: var(--fg);
}

.login-card h1 {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', sans-serif;
  font-weight: 200;
  font-size: 30px;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
}
.eyebrow-mini {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--fg-mute);
  text-transform: uppercase;
  margin: 12px 0 28px;
}

.login-card form { display: grid; gap: 14px; margin-top: 8px; text-align: left; }
.login-card label {
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-soft);
  display: grid;
  gap: 6px;
  letter-spacing: 0.02em;
}
.login-card input {
  font-family: inherit; font-size: 15px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg);
  color: var(--fg);
  transition: border 0.15s;
}
.login-card input::placeholder { color: var(--fg-mute); }
.login-card input:focus {
  outline: none;
  border-color: var(--accent);
}
.login-card p.micro { margin: 14px 0 0; line-height: 1.5; }
.login-card p.micro strong { color: var(--fg); font-weight: 600; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-primary {
  background: var(--accent);
  color: var(--accent-fg);
  border: 0;
  padding: 12px 18px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: opacity 0.15s, transform 0.05s;
}
.btn-primary:hover { opacity: 0.85; }
.btn-primary:active { transform: scale(0.99); }

.btn-ghost {
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--line);
  padding: 9px 14px;
  border-radius: 4px;
  font-size: 13px;
  transition: border 0.15s, background 0.15s;
}
.btn-ghost:hover { border-color: var(--fg); background: var(--bg-2); }
.btn-ghost.sm { padding: 6px 12px; font-size: 12px; }

/* ============================================================
   APP SHELL
   ============================================================ */
.app-view { display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 18px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
  backdrop-filter: saturate(1.2);
}
.topbar .brand {
  display: flex; align-items: center; gap: 8px;
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', sans-serif;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.005em;
  color: var(--fg);
}
.topbar .brand img { color: var(--fg); }

.search-wrap { flex: 1; max-width: 540px; }
.search-wrap input {
  width: 100%;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-2);
  color: var(--fg);
  font-family: inherit;
  font-size: 14px;
  transition: background 0.15s, border 0.15s;
}
.search-wrap input::placeholder { color: var(--fg-mute); }
.search-wrap input:focus {
  outline: none;
  background: var(--bg);
  border-color: var(--fg);
}

.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.icon-btn {
  background: transparent;
  border: 0;
  padding: 8px;
  border-radius: 999px;
  color: var(--fg-soft);
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 0.12s, color 0.12s;
}
.icon-btn:hover { background: var(--bg-3); color: var(--fg); }
.menu-toggle { display: none; }

/* Theme toggle */
.theme-toggle {
  position: relative;
}
.theme-toggle .icon-sun { display: inline-flex; }
.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: inline-flex; }

.user-btn .avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--fg);
  color: var(--bg);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 500; font-size: 12px;
  letter-spacing: 0.02em;
}

/* ============================================================
   LAYOUT
   ============================================================ */
.layout { display: flex; flex: 1; min-height: 0; }

.sidebar {
  width: 220px;
  padding: 14px 10px;
  border-right: 1px solid var(--line);
  background: var(--bg);
  display: flex; flex-direction: column;
  position: sticky; top: 53px;
  height: calc(100vh - 53px);
}
.sidebar nav { display: flex; flex-direction: column; gap: 1px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px;
  border-radius: 4px;
  font-size: 13.5px;
  font-weight: 450;
  cursor: pointer;
  color: var(--fg-soft);
  transition: background 0.1s, color 0.1s;
}
.nav-item:hover { background: var(--bg-3); color: var(--fg); }
.nav-item.active { background: var(--bg-4); color: var(--fg); }
.nav-item svg { color: var(--fg-mute); flex-shrink: 0; }
.nav-item.active svg, .nav-item:hover svg { color: var(--fg); }
.nav-item .nav-count {
  margin-left: auto;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 10.5px;
  color: var(--fg-mute);
  letter-spacing: 0.02em;
  font-weight: 400;
}
.nav-item.active .nav-count, .nav-item:hover .nav-count { color: var(--fg-soft); }
.nav-sep {
  height: 1px;
  background: var(--line);
  margin: 12px 8px;
}

/* ============================================================
   PLANS PAGE
   ============================================================ */
.plans-intro {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 18px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.plans-intro p { margin: 0; max-width: 540px; font-size: 13.5px; line-height: 1.5; }
.current-plan {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
  min-width: 220px;
}
.current-plan-bar {
  flex: 1;
  height: 4px;
  background: var(--bg-3);
  border-radius: 999px;
  overflow: hidden;
}
.current-plan-bar span {
  display: block;
  height: 100%;
  background: var(--fg);
  transition: width 0.3s;
}

.plans-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.plan-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 24px 22px;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border 0.15s;
  position: relative;
}
.plan-card:hover { border-color: var(--fg); }
.plan-card.current {
  border-color: var(--fg);
  background: var(--bg-2);
}
.plan-card.current::before {
  content: 'Actuel';
  position: absolute;
  top: -10px; left: 22px;
  background: var(--fg); color: var(--bg);
  padding: 3px 12px;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  border-radius: 999px;
}
.plan-card.recommended::before {
  content: 'Recommande';
  position: absolute;
  top: -10px; left: 22px;
  background: var(--fg); color: var(--bg);
  padding: 3px 12px;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  border-radius: 999px;
}
.plan-card h3 {
  font-weight: 500;
  font-size: 16px;
  margin: 0;
  letter-spacing: -0.005em;
}
.plan-card .plan-quota {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 13px;
  color: var(--fg-soft);
  letter-spacing: 0.02em;
}
.plan-card .plan-price {
  font-weight: 200;
  font-size: 34px;
  letter-spacing: -0.02em;
  margin: 4px 0;
}
.plan-card .plan-price small {
  font-weight: 400;
  font-size: 13px;
  color: var(--fg-mute);
  margin-left: 4px;
}
.plan-card ul {
  list-style: none;
  padding: 0;
  margin: 8px 0 14px;
  font-size: 13px;
}
.plan-card ul li {
  padding: 5px 0;
  color: var(--fg-soft);
  border-bottom: 1px solid var(--line-soft);
}
.plan-card ul li::before {
  content: '+ ';
  color: var(--fg-mute);
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
}
.plan-card ul li:last-child { border-bottom: 0; }
.plan-card .plan-action {
  margin-top: auto;
}
.plan-card .btn-primary {
  width: 100%;
  padding: 10px 14px;
  font-size: 13.5px;
}
.plan-card .btn-ghost { width: 100%; padding: 10px 14px; font-size: 13.5px; }

.footnote {
  text-align: center;
  font-size: 12px;
  margin-top: 32px;
  padding-bottom: 24px;
}

/* Banner quota dans la sidebar */
.quota.over .quota-bar span { background: #d33b3b; }
.quota .btn-upgrade {
  margin-top: 8px;
  display: block;
  text-align: center;
  background: var(--accent);
  color: var(--accent-fg);
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 4px;
  border: 0;
  cursor: pointer;
  width: 100%;
}

.quota {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.quota-bar {
  height: 4px;
  background: var(--bg-3);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 8px;
}
.quota-bar span {
  display: block;
  height: 100%;
  background: var(--fg);
  transition: width 0.3s;
}

.content {
  flex: 1;
  padding: 28px 32px;
  min-width: 0;
  overflow-x: hidden;
  background: var(--bg);
}

.page-head {
  display: flex; align-items: center; gap: 16px;
  margin-bottom: 22px;
}
.page-head h1 {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', sans-serif;
  font-weight: 250;
  font-size: 28px;
  letter-spacing: -0.02em;
  margin: 0;
}
.page-head .count {
  color: var(--fg-mute);
  font-size: 13px;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
}
.page-head > button { margin-left: auto; }
.page-tools { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* Zoom control (grille) */
.zoom-control {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  background: var(--bg-2);
}
.zoom-btn {
  background: transparent;
  border: 0;
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--fg-mute);
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.zoom-btn:hover { color: var(--fg); }
.zoom-btn.active { background: var(--bg); color: var(--fg); box-shadow: var(--shadow-1); }

/* ============================================================
   TIMELINE
   ============================================================ */
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-bucket { padding-bottom: 28px; }
.timeline-bucket header {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 10px;
  padding: 12px 0 6px;
  color: var(--fg);
  letter-spacing: -0.005em;
  text-transform: capitalize;
  position: sticky;
  top: 53px;
  background: var(--bg);
  z-index: 5;
  border-bottom: 1px solid var(--line-soft);
}
.timeline-bucket header .bucket-count {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 11px;
  color: var(--fg-mute);
  font-weight: 400;
  margin-left: 8px;
  letter-spacing: 0.02em;
}

.thumbs-grid, .bucket-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 4px;
}

/* Niveaux de zoom timeline */
.timeline[data-zoom="lg"] .bucket-grid {
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 6px;
}
.timeline[data-zoom="sm"] .bucket-grid {
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 2px;
}
.thumb {
  position: relative;
  aspect-ratio: 1;
  background: var(--bg-3);
  overflow: hidden;
  border-radius: 2px;
  cursor: pointer;
  border: 0;
  padding: 0;
  transition: opacity 0.1s, transform 0.1s, outline 0.1s;
  outline: 0 solid transparent;
}
.thumb:hover { opacity: 0.94; }
.thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.3s ease-out;
}
.thumb img.loading { opacity: 0; }

/* Skeleton: fond couleur dominante visible pendant chargement */
.thumb::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(110deg, transparent 30%, var(--line-soft) 50%, transparent 70%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}
.thumb.skeleton::before { opacity: 1; }
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Selection multiple */
.thumb.selected {
  outline: 3px solid var(--fg);
  outline-offset: -3px;
}
.thumb .sel-mark {
  position: absolute;
  top: 6px; left: 6px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.35);
  border: 2px solid #fff;
  display: none;
  align-items: center; justify-content: center;
  color: #fff;
  font-size: 12px;
  z-index: 3;
  transition: background 0.12s;
}
body.selecting .thumb .sel-mark { display: inline-flex; }
.thumb.selected .sel-mark { background: var(--fg); border-color: var(--bg); color: var(--bg); }
.thumb.selected .sel-mark::after { content: '✓'; font-weight: 700; }
body.selecting .thumb:hover .sel-mark { background: rgba(0, 0, 0, 0.55); }

.thumb .badge {
  position: absolute;
  bottom: 6px; right: 6px;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  padding: 2px 6px;
  border-radius: 2px;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 10px;
  letter-spacing: 0.02em;
}
.thumb.is-fav::before {
  content: '';
  position: absolute;
  top: 8px; left: 8px;
  width: 8px; height: 8px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.5);
}
[data-theme="dark"] .thumb.is-fav::before {
  background: #fff;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.7);
}
.thumb.is-video::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 0; height: 0;
  border-left: 16px solid #fff;
  border-top: 11px solid transparent;
  border-bottom: 11px solid transparent;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.6));
}

.empty {
  text-align: center;
  padding: 80px 20px;
  color: var(--fg-mute);
  max-width: 480px;
  margin: 0 auto;
}
.empty-illustration {
  color: var(--fg-mute);
  margin-bottom: 24px;
  opacity: 0.5;
}
.empty h2 {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', sans-serif;
  font-weight: 250;
  font-size: 26px;
  margin: 0 0 12px;
  color: var(--fg);
  letter-spacing: -0.015em;
}
.empty p {
  font-size: 14.5px;
  color: var(--fg-soft);
  line-height: 1.55;
  margin: 0 0 24px;
}
.empty .btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  font-size: 14px;
  margin-bottom: 18px;
}
.empty .micro { font-size: 11.5px; }

/* ============================================================
   ALBUMS
   ============================================================ */
.albums-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.album-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  transition: border 0.12s, transform 0.12s;
}
.album-card:hover { border-color: var(--fg); transform: translateY(-1px); }
.album-card .cover {
  aspect-ratio: 4 / 3;
  background: var(--bg-3);
  display: grid; place-items: center;
  color: var(--fg-mute);
}
.album-card .cover img { width: 100%; height: 100%; object-fit: cover; }
.album-card .info { padding: 12px 14px; }
.album-card h3 {
  margin: 0 0 4px;
  font-weight: 500;
  font-size: 15px;
  color: var(--fg);
}
.album-card .micro { margin: 0; }

/* ============================================================
   MAP
   ============================================================ */
.map-canvas {
  width: 100%;
  height: calc(100vh - 200px);
  min-height: 480px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--bg-3);
}

/* ============================================================
   MEMORIES
   ============================================================ */
.memory-section {
  margin-bottom: 36px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}
.memory-section h2 {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', sans-serif;
  font-weight: 250;
  font-size: 22px;
  letter-spacing: -0.01em;
  margin: 0 0 16px;
  color: var(--fg);
}
.memory-section h2 em {
  font-style: normal;
  font-weight: 500;
  color: var(--fg);
}

/* ============================================================
   LIGHTBOX (toujours sombre — comme tous les viewers photo)
   ============================================================ */
.lightbox {
  position: fixed; inset: 0; z-index: 100;
  background: #000;
  display: flex; flex-direction: column;
  color: #fff;
}
.lb-top {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 18px;
  background: rgba(0, 0, 0, 0.4);
}
.lb-top .lb-meta { flex: 1; min-width: 0; }
.lb-top .lb-meta strong {
  display: block;
  font-size: 13px;
  font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: #fff;
}
.lb-top .lb-meta .micro { color: rgba(255, 255, 255, 0.55); }
.lb-actions { display: flex; gap: 2px; }
.lightbox .icon-btn { color: #fff; }
.lightbox .icon-btn:hover { background: rgba(255, 255, 255, 0.1); }

/* Boutons d'action lightbox (icone + libelle) */
.lb-btn {
  background: transparent; border: 0;
  color: #fff; cursor: pointer;
  width: 40px; height: 40px;
  border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 0.12s;
}
.lb-btn:hover { background: rgba(255, 255, 255, 0.12); }

.lb-action {
  background: transparent; border: 0;
  color: #fff; cursor: pointer;
  padding: 8px 10px;
  border-radius: 6px;
  display: inline-flex; flex-direction: column;
  align-items: center; gap: 4px;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: background 0.12s, color 0.12s;
  min-width: 64px;
}
.lb-action:hover { background: rgba(255, 255, 255, 0.12); }
.lb-action.active { color: #ff6b9b; }
.lb-action.active svg { fill: currentColor; }
.lb-action.danger:hover { background: rgba(211, 59, 59, 0.4); }
.lb-action span { white-space: nowrap; }

.lb-info-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.lb-info-head h3 { margin: 0; }

.lb-stage {
  flex: 1;
  display: grid; place-items: center;
  position: relative;
  overflow: hidden;
  padding: 16px;
}
.lb-stage img, .lb-stage video {
  max-width: 100%; max-height: 100%;
  object-fit: contain;
}
.lb-nav {
  position: absolute;
  top: 50%; transform: translateY(-50%);
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border: 0;
  font-size: 22px; line-height: 1;
  display: grid; place-items: center;
  z-index: 5;
  transition: background 0.12s;
}
.lb-prev { left: 20px; }
.lb-next { right: 20px; }
.lb-nav:hover { background: rgba(255, 255, 255, 0.18); }

.lb-info {
  position: absolute; right: 0; top: 60px; bottom: 0;
  width: 320px; max-width: 90vw;
  background: rgba(0, 0, 0, 0.95);
  padding: 24px;
  overflow-y: auto;
  border-left: 1px solid rgba(255, 255, 255, 0.1);
}
.lb-info h3 {
  font-weight: 250;
  font-size: 18px;
  margin: 0 0 16px;
  letter-spacing: -0.01em;
}
.lb-info dl {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 7px 12px;
  font-size: 12.5px;
}
.lb-info dt {
  color: rgba(255, 255, 255, 0.5);
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.lb-info dd { margin: 0; color: #fff; }

/* ============================================================
   MODAL
   ============================================================ */
.modal {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(0, 0, 0, 0.4);
  display: grid; place-items: center;
  padding: 20px;
}
[data-theme="dark"] .modal { background: rgba(0, 0, 0, 0.7); }

.modal-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  width: min(560px, 100%);
  max-height: 80vh;
  overflow: hidden;
  box-shadow: var(--shadow-2);
  display: flex; flex-direction: column;
}
.modal-card header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.modal-card header h2 {
  margin: 0;
  font-weight: 400;
  font-size: 17px;
  letter-spacing: -0.005em;
}
.modal-card #modal-body { padding: 20px; overflow-y: auto; }
.modal-card label {
  display: grid; gap: 6px;
  margin-bottom: 14px;
  font-size: 12px;
  color: var(--fg-soft);
  font-weight: 500;
}
.modal-card input,
.modal-card textarea {
  font-family: inherit; font-size: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg);
  color: var(--fg);
}

/* Aide */
.help h4 {
  font-weight: 500;
  font-size: 13px;
  margin: 16px 0 8px;
  color: var(--fg);
  letter-spacing: -0.005em;
}
.help h4:first-child { margin-top: 0; }
.help table { width: 100%; border-collapse: collapse; font-size: 13px; }
.help table tr td { padding: 6px 0; border-bottom: 1px solid var(--line-soft); }
.help table tr:last-child td { border-bottom: 0; }
.help td:first-child { width: 38%; }
.help kbd {
  display: inline-block;
  padding: 2px 7px;
  background: var(--kbd-bg);
  border: 1px solid var(--line);
  border-radius: 3px;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 11px;
  color: var(--fg);
  box-shadow: inset 0 -1px 0 var(--line);
}
.modal-card input:focus,
.modal-card textarea:focus {
  outline: none;
  border-color: var(--fg);
}

/* ============================================================
   TOASTS
   ============================================================ */
.toasts {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px;
  z-index: 200;
}
.toast {
  background: var(--fg);
  color: var(--bg);
  padding: 12px 18px;
  border-radius: 6px;
  font-size: 13.5px;
  box-shadow: var(--shadow-2);
  animation: slideUp 0.18s ease-out;
  letter-spacing: 0.005em;
  display: inline-flex;
  align-items: center;
  gap: 14px;
  max-width: 480px;
}
.toast.error { background: #d33b3b; color: #fff; }
.toast.success { background: var(--fg); color: var(--bg); }
.toast button {
  background: transparent;
  border: 1px solid currentColor;
  color: inherit;
  padding: 5px 12px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
}
.toast button:hover { opacity: 0.85; }
@keyframes slideUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0);   }
}

/* ============================================================
   SELECTION BAR
   ============================================================ */
.selection-bar {
  position: fixed;
  top: 53px; left: 0; right: 0;
  z-index: 35;
  background: var(--fg);
  color: var(--bg);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 20px;
  box-shadow: var(--shadow-2);
  animation: slideDown 0.16s ease-out;
}
.selection-bar .icon-btn { color: var(--bg); }
.selection-bar .icon-btn:hover { background: rgba(255, 255, 255, 0.15); }
.selection-bar strong {
  font-weight: 500;
  font-size: 13.5px;
  letter-spacing: -0.005em;
}
.sel-actions {
  margin-left: auto;
  display: flex;
  gap: 6px;
}
.selection-bar .btn-ghost {
  color: var(--bg);
  border-color: rgba(255, 255, 255, 0.25);
}
.selection-bar .btn-ghost:hover {
  border-color: var(--bg);
  background: rgba(255, 255, 255, 0.1);
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   UPLOAD PANEL (bas droit, persistant)
   ============================================================ */
.upload-panel {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 60;
  background: var(--bg);
  border: 1px solid var(--line-strong, var(--line));
  border-radius: 6px;
  width: 340px;
  max-height: 360px;
  box-shadow: var(--shadow-2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.upload-panel.minimized .upload-progress,
.upload-panel.minimized ul { display: none; }

.upload-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-2);
}
.upload-panel header strong {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.005em;
}
.upload-progress {
  height: 3px;
  background: var(--bg-3);
  position: relative;
  overflow: hidden;
}
.upload-progress span {
  display: block;
  height: 100%;
  background: var(--fg);
  width: 0%;
  transition: width 0.2s ease-out;
}

.upload-panel ul {
  list-style: none;
  margin: 0;
  padding: 6px 0;
  overflow-y: auto;
  max-height: 240px;
}
.upload-panel li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  font-size: 12.5px;
}
.upload-panel li .file-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--fg-soft);
}
.upload-panel li.done .file-name { color: var(--fg); }
.upload-panel li.error .file-name { color: #d33b3b; }
.upload-panel li .state {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 10px;
  color: var(--fg-mute);
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
.upload-panel li.done .state { color: var(--fg); }
.upload-panel li.error .state { color: #d33b3b; }

/* ============================================================
   DRAG OVERLAY
   ============================================================ */
.drag-overlay {
  position: fixed; inset: 0; z-index: 80;
  background: var(--overlay);
  border: 2px dashed var(--fg);
  display: grid; place-items: center;
  pointer-events: none;
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', sans-serif;
  font-weight: 250;
  font-size: 28px;
  color: var(--fg);
  letter-spacing: -0.01em;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 800px) {
  .menu-toggle { display: inline-flex; }
  .sidebar {
    position: fixed; top: 53px; left: 0; bottom: 0;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.2s;
    box-shadow: var(--shadow-2);
    width: 240px;
  }
  .sidebar.open { transform: translateX(0); }
  .topbar .brand span { display: none; }
  .content { padding: 16px; }
  .lb-info { width: 100%; }
  .thumbs-grid, .bucket-grid {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 3px;
  }
  .albums-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}
