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

:root {
  --bg:        #0f0f11;
  --surface:   #18181c;
  --surface2:  #1f1f25;
  --border:    #2a2a32;
  --text:      #e8e8ee;
  --muted:     #6b6b7e;
  --accent:    #7c6df5;

  --amarelo:   #f5c842;
  --amarelo-bg:#f5c84218;
  --roxo:      #a865f5;
  --roxo-bg:   #a865f518;
  --rosa:      #f565a8;
  --rosa-bg:   #f565a818;

  --radius:    12px;
  --sidebar-w: 220px;
  --transition: 160ms ease;

  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  color: var(--text);
}

body {
  background: var(--bg);
  display: flex;
  min-height: 100vh;
}

/* ── SIDEBAR ────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  gap: 32px;
  position: fixed;
  top: 0; left: 0;
  z-index: 10;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 4px;
}
.logo-icon { font-size: 22px; }
.logo-text  { font-weight: 600; font-size: 15px; letter-spacing: -.3px; }

/* nav */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background var(--transition), color var(--transition);
  width: 100%;
}
.nav-item:hover  { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--surface2); color: var(--text); }
.nav-icon { font-size: 15px; }

/* block filters */
.sidebar-blocks {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sidebar-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 4px;
  margin-bottom: 2px;
}
.block-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background var(--transition), color var(--transition);
}
.block-filter:hover  { background: var(--surface2); color: var(--text); }
.block-filter.active { background: var(--surface2); color: var(--text); }

.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-amarelo { background: var(--amarelo); }
.dot-roxo    { background: var(--roxo); }
.dot-rosa    { background: var(--rosa); }

.sidebar-footer {
  margin-top: auto;
  padding: 0 4px;
}
#total-badge {
  font-size: 12px;
  color: var(--muted);
}

/* ── MAIN ───────────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* topbar */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 28px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
}

.search-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 14px;
  transition: border-color var(--transition);
}
.search-wrap:focus-within { border-color: var(--accent); }
.search-icon { font-size: 14px; }
#search-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
}
#search-input::placeholder { color: var(--muted); }

.btn-add-mobile {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

/* ── VIEWS ──────────────────────────────────────────────── */
.view { display: none; padding: 28px; }
.view.active { display: block; }

/* ── DIRECTORY ──────────────────────────────────────────── */
#blocks-container {
  display: flex;
  flex-direction: column;
  gap: 40px;
}

.block-section { }

.block-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.block-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -.1px;
}
.badge-amarelo { background: var(--amarelo-bg); color: var(--amarelo); border: 1px solid #f5c84230; }
.badge-roxo    { background: var(--roxo-bg);    color: var(--roxo);    border: 1px solid #a865f530; }
.badge-rosa    { background: var(--rosa-bg);     color: var(--rosa);    border: 1px solid #f565a830; }

.block-count {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.residents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}

.resident-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color var(--transition), transform var(--transition);
  cursor: default;
}
.resident-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.resident-name {
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.3;
}
.resident-apt {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}
.apt-num {
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.resident-note {
  font-size: 11.5px;
  color: var(--muted);
  font-style: italic;
  margin-top: 2px;
}

/* colored left border */
.resident-card.amarelo { border-left: 3px solid var(--amarelo); }
.resident-card.roxo    { border-left: 3px solid var(--roxo); }
.resident-card.rosa    { border-left: 3px solid var(--rosa); }

/* empty */
.empty-msg {
  text-align: center;
  color: var(--muted);
  margin-top: 60px;
  font-size: 14px;
}
.hidden { display: none !important; }

/* ── ADD FORM ───────────────────────────────────────────── */
.form-card {
  max-width: 560px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 40px;
}
.form-title    { font-size: 20px; font-weight: 600; margin-bottom: 6px; }
.form-subtitle { font-size: 13px; color: var(--muted); margin-bottom: 28px; line-height: 1.5; }

#add-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-row {
  display: flex;
  gap: 14px;
}
.field { display: flex; flex-direction: column; gap: 7px; flex: 1; }
.field-sm { max-width: 120px; }

label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
}
.optional { font-weight: 400; text-transform: none; letter-spacing: 0; }

input[type="text"] {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition);
}
input[type="text"]:focus { border-color: var(--accent); }
input[type="text"]::placeholder { color: var(--muted); }
input[type="text"].error { border-color: #f56565; }

.block-radio-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.block-radio {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: border-color var(--transition), background var(--transition);
}
.block-radio input[type="radio"] { display: none; }
.block-radio.amarelo:has(input:checked) { border-color: var(--amarelo); background: var(--amarelo-bg); color: var(--amarelo); }
.block-radio.roxo:has(input:checked)    { border-color: var(--roxo);    background: var(--roxo-bg);    color: var(--roxo); }
.block-radio.rosa:has(input:checked)    { border-color: var(--rosa);    background: var(--rosa-bg);    color: var(--rosa); }
.block-radio:hover { border-color: var(--muted); }

.block-radio-group.error .block-radio { border-color: #f56565; }

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 4px;
}

.btn-primary, .btn-secondary {
  padding: 10px 22px;
  border-radius: 8px;
  border: none;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--transition), transform var(--transition);
  font-family: inherit;
}
.btn-primary:hover, .btn-secondary:hover { opacity: .85; transform: translateY(-1px); }

.btn-primary   { background: var(--accent); color: #fff; }
.btn-secondary { background: var(--surface2); color: var(--muted); border: 1px solid var(--border); }

.form-success {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 32px;
  text-align: center;
  color: #6ee7b7;
  font-weight: 500;
  font-size: 14px;
}
.success-icon { font-size: 36px; }

/* ── TOPBAR RIGHT ────────────────────────────────────────── */
.topbar-right { display: flex; align-items: center; gap: 8px; }

/* ── INFO PAGES (Sobre / Evolução) ──────────────────────── */
.info-page {
  max-width: 820px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.info-skeleton {
  color: var(--muted);
  font-size: 13px;
  padding: 40px 0;
  text-align: center;
}

/* Cover image */
.info-cover {
  width: 100%;
  max-height: 340px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* Section card */
.info-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.info-card-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--muted);
}

.info-heading {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -.3px;
  line-height: 1.25;
}

.info-sub {
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 500;
}

.info-description {
  font-size: 13.5px;
  color: var(--text);
  line-height: 1.7;
  opacity: .88;
}

.info-description + .info-description { margin-top: -4px; }

/* Specs pills */
.specs-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.spec-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 5px 13px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
}

/* Ficha técnica */
.ficha-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.ficha-table tr:not(:last-child) td { border-bottom: 1px solid var(--border); }
.ficha-table td {
  padding: 9px 0;
  vertical-align: top;
}
.ficha-table td:first-child {
  color: var(--muted);
  width: 40%;
  font-weight: 500;
}
.ficha-table td:last-child {
  font-weight: 500;
  color: var(--text);
}

/* Update meta */
.update-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--muted);
}
.update-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #6ee7b7;
  flex-shrink: 0;
}
.update-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}
.update-link:hover { text-decoration: underline; }

/* ── EVOLUÇÃO DA OBRA ────────────────────────────────────── */
.evolucao-periodo {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}

.progress-modules {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.progress-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.progress-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.progress-label {
  font-size: 13px;
  font-weight: 500;
}
.progress-pct {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.progress-bar-bg {
  width: 100%;
  height: 6px;
  background: var(--surface2);
  border-radius: 100px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  border-radius: 100px;
  background: linear-gradient(90deg, var(--accent), #a89dff);
  transition: width .6s ease;
}

/* Fotos da obra */
.obra-photos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}
.obra-photo {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  transition: transform var(--transition), border-color var(--transition);
  cursor: zoom-in;
}
.obra-photo:hover {
  transform: scale(1.02);
  border-color: var(--accent);
}

/* Nota de dados vazios */
.empty-info {
  font-size: 13px;
  color: var(--muted);
  font-style: italic;
  padding: 16px 0;
}

/* ── GALLERY GRID ───────────────────────────────────────── */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}

.gallery-item {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 4/3;
  cursor: pointer;
  background: var(--surface2);
  border: 1px solid var(--border);
  transition: transform var(--transition), border-color var(--transition);
  outline: none;
}
.gallery-item:hover,
.gallery-item:focus-visible {
  transform: scale(1.02);
  border-color: var(--accent);
}
.gallery-item:active { transform: scale(.98); }

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: filter var(--transition);
}
.gallery-item:hover img { filter: brightness(.85); }

.gallery-caption {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,.72));
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  padding: 18px 8px 8px;
  line-height: 1.3;
  opacity: 0;
  transition: opacity var(--transition);
}
.gallery-item:hover .gallery-caption,
.gallery-item:focus-visible .gallery-caption { opacity: 1; }

/* Obra photo inside gallery-item */
.obra-item { aspect-ratio: 4/3; }
.obra-item .obra-photo {
  width: 100%; height: 100%;
  object-fit: cover;
  border: none;
  border-radius: 0;
}
.obra-item:hover .obra-photo { transform: none; }

/* ── PERIOD TABS ─────────────────────────────────────────── */
.period-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.period-tab {
  padding: 6px 16px;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.period-tab:hover  { border-color: var(--muted); color: var(--text); }
.period-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ── LIGHTBOX ────────────────────────────────────────────── */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: lb-in .2s ease;
}
.lightbox.open { display: flex; }

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

.lightbox-close {
  position: absolute;
  top: 16px; right: 16px;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.2);
  background: rgba(255,255,255,.1);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
  z-index: 1001;
}
.lightbox-close:hover { background: rgba(255,255,255,.22); }

.lightbox-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  max-width: min(90vw, 900px);
  max-height: 90vh;
}

#lightbox-img {
  max-width: 100%;
  max-height: calc(90vh - 60px);
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 8px 40px rgba(0,0,0,.6);
  animation: lb-zoom .22s ease;
}
@keyframes lb-zoom {
  from { transform: scale(.94); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.lightbox-caption {
  color: rgba(255,255,255,.75);
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  max-width: 560px;
  line-height: 1.5;
}


/* ── MOBILE BOTTOM NAV ──────────────────────────────────── */
.mobile-nav {
  display: none;
}

/* ── RESPONSIVE (≤ 768px) ───────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; --bottom-nav-h: 64px; }

  /* Hide desktop sidebar */
  .sidebar { display: none; }

  /* Main fills screen, padded for bottom nav */
  .main {
    margin-left: 0;
    padding-bottom: var(--bottom-nav-h);
  }

  /* ── BOTTOM NAVIGATION BAR ── */
  .mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--bottom-nav-h);
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 100;
    /* support iOS safe area */
    padding-bottom: env(safe-area-inset-bottom, 0px);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }

  .mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border: none;
    background: transparent;
    color: var(--muted);
    font-size: 10px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    padding: 8px 4px;
    transition: color var(--transition);
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-nav-item.active { color: var(--accent); }
  .mobile-nav-item:active  { opacity: .7; }

  .mobile-nav-icon {
    font-size: 20px;
    line-height: 1;
    transition: transform var(--transition);
  }
  .mobile-nav-item.active .mobile-nav-icon {
    transform: translateY(-1px);
  }
  .mobile-nav-label { letter-spacing: .2px; }

  /* Active indicator dot */
  .mobile-nav-item.active::after {
    content: '';
    position: absolute;
    bottom: calc(var(--bottom-nav-h) - 2px);
    width: 20px; height: 3px;
    background: var(--accent);
    border-radius: 2px 2px 0 0;
  }

  /* ── TOPBAR ── */
  .topbar {
    padding: 12px 16px;
    gap: 10px;
  }
  .search-wrap { padding: 9px 12px; }
  .btn-add-mobile { display: none; } /* replaced by bottom nav */

  /* ── VIEWS ── */
  .view {
    padding: 16px 14px;
    padding-bottom: 24px;
  }

  /* ── DIRECTORY ── */
  #blocks-container { gap: 28px; }

  /* Scrollable block filter chips — shown inline above cards on mobile */
  .mobile-block-filters {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 0 0 4px 0;
    margin-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }
  .mobile-block-filters::-webkit-scrollbar { display: none; }

  .mobile-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 100px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 500;
    font-family: inherit;
    white-space: nowrap;
    cursor: pointer;
    flex-shrink: 0;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-chip.active {
    background: var(--surface2);
    color: var(--text);
    border-color: var(--accent);
  }
  .mobile-chip:active { opacity: .7; }

  /* Resident cards — 2 columns on mobile */
  .residents-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .resident-card {
    padding: 12px 13px;
    gap: 4px;
  }
  .resident-name { font-size: 13px; }
  .resident-apt  { font-size: 11.5px; }

  .block-badge { font-size: 12.5px; padding: 4px 12px; }
  .block-count { font-size: 11.5px; }
  .block-header { margin-bottom: 12px; }

  /* ── INFO PAGES ── */
  .info-page { gap: 16px; }

  .info-cover {
    max-height: 200px;
    border-radius: 10px;
  }

  .info-card {
    padding: 16px 14px;
    gap: 12px;
    border-radius: 10px;
  }
  .info-heading { font-size: 19px; }
  .info-description { font-size: 13px; }

  .specs-grid { gap: 6px; }
  .spec-pill  { font-size: 12px; padding: 5px 11px; }

  .ficha-table { font-size: 12.5px; }
  .ficha-table td { padding: 8px 0; }

  .update-meta { font-size: 11px; flex-wrap: wrap; }

  /* Obra photos — 2 columns */
  .obra-photos {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  /* ── ADD FORM ── */
  .form-card {
    padding: 22px 16px;
    border-radius: 12px;
  }
  .form-title    { font-size: 18px; }
  .form-subtitle { font-size: 12.5px; margin-bottom: 20px; }
  .form-row      { flex-direction: column; }
  .field-sm      { max-width: 100%; }
  #add-form      { gap: 16px; }

  .block-radio-group { gap: 8px; }
  .block-radio {
    padding: 10px 14px;
    font-size: 12.5px;
    flex: 1;
    justify-content: center;
    text-align: center;
  }

  .form-actions { flex-direction: column-reverse; gap: 8px; }
  .btn-primary, .btn-secondary {
    width: 100%;
    padding: 13px;
    font-size: 14px;
  }
}

/* ── EXTRA SMALL (≤ 380px) ──────────────────────────────── */
@media (max-width: 380px) {
  .residents-grid { grid-template-columns: 1fr; }
  .obra-photos    { grid-template-columns: 1fr; }
  .info-heading   { font-size: 17px; }
  .gallery-grid   { grid-template-columns: repeat(2, 1fr); }
}

/* ── MOBILE: GALLERY & LIGHTBOX ─────────────────────────── */
@media (max-width: 768px) {
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  /* Always show caption on mobile (no hover) */
  .gallery-caption { opacity: 1; }

  /* Period tabs — scrollable row */
  .period-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }
  .period-tabs::-webkit-scrollbar { display: none; }
  .period-tab { flex-shrink: 0; font-size: 12px; padding: 6px 14px; }

  /* Lightbox — bottom sheet on mobile */
  .lightbox { padding: 0; align-items: flex-end; }
  .lightbox-content {
    width: 100%;
    max-width: 100%;
    max-height: 90vh;
    background: var(--surface);
    border-radius: 16px 16px 0 0;
    padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px));
    gap: 12px;
    animation: lb-slide .25s ease;
  }
  @keyframes lb-slide {
    from { transform: translateY(30px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
  }

  #lightbox-img {
    width: 100%;
    max-height: 55vh;
    border-radius: 8px;
  }

  .lightbox-close { top: 12px; right: 12px; width: 36px; height: 36px; font-size: 18px; }
  .lightbox-caption { font-size: 12.5px; }
}

#login-modal.open {
  display: flex !important;
}

#login-modal:not(.open) {
  display: none !important;
}

#login-modal .form-card {
  background: var(--surface);
  padding: 24px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  width: 100%;
  max-width: 320px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}
