:root {
  --bg: #faf8f5;
  --surface: #ffffff;
  --text: #2b2724;
  --muted: #8a827a;
  --border: #e8e3dc;
  --accent: #2b2724;
  --accent-text: #ffffff;
  --ok: #3f7d4e;
  --warn: #b7791f;
  --danger: #b4423a;
  --radius: 10px;
  --serif: 'Cormorant Garamond', Georgia, serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--sans); }
a { color: inherit; }
img { display: block; max-width: 100%; }
h1, h2 { font-family: var(--serif); font-weight: 500; margin: 0 0 .5rem; }
h1 { font-size: 2.2rem; line-height: 1.15; }
h2 { font-size: 1.6rem; margin-top: 2.5rem; }
small, .small { font-size: .82rem; }
.muted { color: var(--muted); }
.error { color: var(--danger); margin: 0; }
.notice { background: #eaf3ec; color: var(--ok); padding: .7rem 1rem; border-radius: var(--radius); }

/* Layout */
.container { max-width: 1120px; margin: 0 auto; padding: 1.5rem 16px 4rem; }
.container.narrow { max-width: 560px; }
.centered { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; }
.card.narrow { width: 100%; max-width: 400px; text-align: center; }
.stack { display: grid; gap: 1rem; text-align: left; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin: .5rem 0 1.5rem; }
.back { display: inline-block; color: var(--muted); text-decoration: none; margin-bottom: .5rem; }
.back:hover { color: var(--text); }
.brand { font-family: var(--serif); font-size: 1.5rem; text-decoration: none; letter-spacing: .02em; }
.brand-lg { font-size: 2.4rem; margin-bottom: .25rem; }
.eyebrow { text-transform: uppercase; letter-spacing: .18em; font-size: .72rem; color: var(--muted); margin: 0 0 .5rem; }

.topbar { display: flex; justify-content: space-between; align-items: center; padding: .9rem 16px; border-bottom: 1px solid var(--border); background: var(--surface); }
.topbar form { margin: 0; }

/* Forms */
label { display: grid; gap: .35rem; font-weight: 500; font-size: .9rem; }
label.check { display: flex; align-items: center; gap: .5rem; font-weight: 400; }
input[type=text], input[type=password], input[type=number], input[type=date], input:not([type]) {
  font: inherit; padding: .65rem .8rem; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text); width: 100%;
}
input:focus { outline: 2px solid var(--text); outline-offset: -1px; }
.form-grid { margin-top: 1rem; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font: 500 .9rem var(--sans); padding: .65rem 1.2rem; border-radius: 8px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-text); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { opacity: .88; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-light { background: #fff; color: #111; border-color: #fff; }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-link { background: none; border: 0; font: inherit; color: var(--muted); cursor: pointer; }
.icon-btn { border: 0; background: rgba(0,0,0,.6); color: #fff; width: 28px; height: 28px; border-radius: 50%; cursor: pointer; }

/* Badges & stats */
.badge { font-size: .75rem; padding: .2rem .6rem; border-radius: 99px; white-space: nowrap; font-weight: 500; }
.badge-lg { font-size: .85rem; padding: .35rem .8rem; }
.badge-active { background: #eaf3ec; color: var(--ok); }
.badge-warning { background: #fbf1df; color: var(--warn); }
.badge-expired { background: #f6e3e1; color: var(--danger); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; margin: 1rem 0; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; color: var(--muted); font-size: .82rem; }
.stat span { display: block; font-family: var(--sans); font-size: 1.6rem; font-weight: 500; color: var(--text); line-height: 1.25; font-variant-numeric: tabular-nums; }
.stat span.small { font-family: var(--sans); font-size: 1rem; padding: .55rem 0 .3rem; }

details.card summary { cursor: pointer; font-weight: 500; }

.share label { margin-bottom: .5rem; }
.share-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.share-row input { flex: 1 1 260px; }

/* Galleries list */
.gallery-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.gallery-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; text-decoration: none; transition: box-shadow .15s; }
.gallery-card:hover { box-shadow: 0 6px 24px rgba(0,0,0,.07); }
.gallery-card .cover { aspect-ratio: 3 / 2; background: #efebe5; display: grid; place-items: center; overflow: hidden; }
.gallery-card .cover img { width: 100%; height: 100%; object-fit: cover; }
.gallery-card .info { padding: 1rem; display: grid; gap: .25rem; }
.gallery-card .row { display: flex; justify-content: space-between; gap: .5rem; align-items: center; }
.gallery-card .meta { display: flex; flex-wrap: wrap; gap: .25rem .9rem; color: var(--muted); font-size: .8rem; margin-top: .35rem; }
.empty { text-align: center; padding: 4rem 1rem; border: 1px dashed var(--border); border-radius: var(--radius); }

/* Upload */
.dropzone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 2rem 1rem; text-align: center; background: var(--surface); transition: border-color .15s, background .15s; }
.dropzone.over { border-color: var(--text); background: #f3efe9; }
.dropzone p { margin: .3rem 0; }
.dropzone label { display: inline-flex; font-weight: 500; }
.upload-list { list-style: none; padding: 0; margin: .75rem 0; display: grid; gap: .35rem; }
.upload-list li { display: grid; grid-template-columns: 1fr 140px; gap: .75rem; align-items: center; font-size: .85rem; }
.upload-list li .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-list progress { width: 100%; }
.upload-list li.failed { color: var(--danger); }

.admin-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .75rem; margin-top: 1rem; }
.admin-photos figure { margin: 0; position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.admin-photos img { aspect-ratio: 1; width: 100%; object-fit: cover; }
.admin-photos figcaption { padding: .4rem .5rem; display: grid; font-size: .78rem; }
.admin-photos .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-photos form { position: absolute; top: 6px; right: 6px; margin: 0; }

/* Log */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.log { width: 100%; border-collapse: collapse; font-size: .85rem; }
.log th, .log td { text-align: left; padding: .6rem .8rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
.log th { font-weight: 500; color: var(--muted); background: #fbfaf8; }
.log tr:last-child td { border-bottom: 0; }
.log .ev-download td:nth-child(2) { color: var(--ok); font-weight: 500; }
.log .ev-login_failed td:nth-child(2), .log .ev-expired_view td:nth-child(2) { color: var(--danger); }

.danger { margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }

@media (max-width: 600px) {
  h1 { font-size: 1.8rem; }
  .upload-list li { grid-template-columns: 1fr 90px; }
}

/* Client gallery */
body.client { background: #fff; }
body.lb-open { overflow: hidden; }

.hero { position: relative; height: 100svh; min-height: 420px; display: grid; place-items: end center; color: #fff; overflow: hidden; background: #2b2724; }
.hero-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; animation: hero-in 1.2s ease both; }
.hero::after { content: ''; position: absolute; inset: 0; background: linear-gradient(to bottom, rgba(0,0,0,.05) 40%, rgba(0,0,0,.55)); }
.hero-content { position: relative; z-index: 1; text-align: center; padding: 0 24px calc(4.5rem + env(safe-area-inset-bottom)); max-width: 800px; }
.hero .eyebrow { color: rgba(255,255,255,.8); }
.hero h1 { font-size: clamp(2.4rem, 8vw, 4.5rem); font-weight: 400; margin-bottom: .25rem; text-shadow: 0 2px 20px rgba(0,0,0,.25); }
.client-name { font-family: var(--serif); font-size: clamp(1.2rem, 3.5vw, 1.6rem); font-style: italic; margin: 0 0 1.75rem; }
.hero-cta { display: inline-block; padding: .85rem 2.2rem; border: 1px solid rgba(255,255,255,.85); color: #fff; text-decoration: none; text-transform: uppercase; letter-spacing: .18em; font-size: .75rem; transition: background .2s, color .2s; }
.hero-cta:hover { background: #fff; color: #111; }
.hero-plain { height: auto; min-height: 0; padding: 5rem 0 1rem; place-items: center; }
.hero-plain::after { display: none; }
.hero-plain .hero-content { padding-bottom: 2rem; }
@keyframes hero-in { from { opacity: 0; transform: scale(1.04); } to { opacity: 1; transform: none; } }

.gallery-bar { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1rem 16px; background: rgba(255,255,255,.92); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid transparent; transition: border-color .2s; scroll-margin-top: 0; }
.gallery-bar.stuck { border-bottom-color: var(--border); }
.gallery-bar-title { font-family: var(--serif); font-size: 1.25rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gallery-bar-count { color: var(--muted); font-size: .8rem; white-space: nowrap; text-transform: uppercase; letter-spacing: .1em; }
.gallery-empty { text-align: center; padding: 3rem 16px; }

.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; max-width: 1400px; margin: 0 auto; }
.tile { margin: 0; position: relative; aspect-ratio: 1; overflow: hidden; background: #f2efea; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.tile img { width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .4s, transform .5s ease; }
.tile img.loaded { opacity: 1; }
.tile-download { position: absolute; right: 10px; bottom: 10px; width: 38px; height: 38px; border-radius: 50%; background: rgba(255,255,255,.95); color: #111; display: none; place-items: center; box-shadow: 0 2px 8px rgba(0,0,0,.15); }

.gallery-footer { text-align: center; padding: 3rem 24px calc(3rem + env(safe-area-inset-bottom)); line-height: 1.7; }
.gallery-footer p { margin: 0 0 .75rem; }

@media (min-width: 700px) {
  .grid { grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 0 6px; }
  .gallery-bar { padding: 1.1rem 24px; }
}
@media (min-width: 1100px) {
  .grid { grid-template-columns: repeat(5, 1fr); gap: 8px; padding: 0 8px; }
}
@media (hover: hover) {
  .tile-download { display: grid; opacity: 0; transition: opacity .2s; }
  .tile:hover .tile-download, .tile-download:focus { opacity: 1; }
  .tile:hover img { transform: scale(1.03); }
}

/* Lightbox */
.lightbox { position: fixed; inset: 0; z-index: 20; background: #0b0b0b; color: #fff; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; animation: lb-in .2s ease; }
.lightbox[hidden] { display: none; }
@keyframes lb-in { from { opacity: 0; } to { opacity: 1; } }
.lightbox button { background: none; border: 0; color: #fff; cursor: pointer; display: grid; place-items: center; }
.lb-top { display: flex; justify-content: space-between; align-items: center; padding: calc(.5rem + env(safe-area-inset-top)) 8px .5rem 20px; font-size: .85rem; color: rgba(255,255,255,.7); }
.lb-close { width: 48px; height: 48px; }
.lb-stage { position: relative; display: grid; place-items: center; min-height: 0; padding: 0 8px; touch-action: pan-y; }
.lb-stage { overflow: hidden; }
.lb-stage img { position: absolute; inset: 0; margin: auto; max-width: calc(100% - 16px); max-height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; transition: filter .3s; }
.lb-stage.loading img { filter: blur(6px); }
.lb-spinner { position: absolute; width: 28px; height: 28px; border: 2px solid rgba(255,255,255,.25); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; display: none; }
.lb-stage.loading .lb-spinner { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }
.lb-nav { display: none !important; position: absolute; top: 50%; transform: translateY(-50%); width: 64px; height: 96px; opacity: .6; transition: opacity .2s; }
.lb-nav:hover { opacity: 1; }
.lb-prev { left: 8px; }
.lb-next { right: 8px; }
.lb-bottom { display: flex; justify-content: center; padding: 1rem 16px calc(1rem + env(safe-area-inset-bottom)); }
.lb-download { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; width: 100%; max-width: 360px; padding: .95rem 1.5rem; background: #fff; color: #111; border-radius: 99px; text-decoration: none; font-weight: 500; font-size: .95rem; }
.lb-download:active { transform: scale(.98); }

@media (hover: hover) and (min-width: 700px) {
  .lb-nav { display: grid !important; }
  .lb-stage img { max-width: calc(100% - 160px); }
  .lb-download { width: auto; }
}

/* Configurações / Drive */
.topbar-links { display: flex; align-items: center; gap: 1.25rem; font-size: .9rem; }
.topbar-links a { color: var(--muted); text-decoration: none; }
.topbar-links a:hover { color: var(--text); }
.card-title { margin: 0; font-size: 1.5rem; }
.notice-warn { background: #fbf1df; color: var(--warn); }
.notice-error { background: #f6e3e1; color: var(--danger); }
.notice a { color: inherit; font-weight: 500; }
.drive-ok { color: var(--ok); }
code { font-size: .85em; background: #f1ede7; padding: .1rem .35rem; border-radius: 4px; word-break: break-all; }

/* Páginas de texto (política de privacidade) */
.legal { padding-top: 3rem; line-height: 1.7; }
.legal h2 { font-size: 1.4rem; margin-top: 2rem; }

/* Contador de armazenamento */
.storage { margin-bottom: 1.5rem; display: grid; gap: .6rem; }
.storage-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.storage-head > span { font-weight: 500; }
.storage-head strong { font-size: 1.25rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.storage-head strong .muted { font-family: var(--sans); font-size: .85rem; }
.storage-bar { height: 8px; border-radius: 99px; background: #efebe5; overflow: hidden; }
.storage-bar span { display: block; height: 100%; min-width: 2px; background: var(--ok); border-radius: inherit; transition: width .4s; }
.storage-warn .storage-bar span { background: var(--warn); }
.storage-over .storage-bar span { background: var(--danger); }
.storage p { margin: 0; }

/* Endereço do link */
.slug-field { display: flex; align-items: stretch; border: 1px solid var(--border); border-radius: 8px; background: #fff; overflow: hidden; }
.slug-field:focus-within { outline: 2px solid var(--text); outline-offset: -1px; }
.slug-prefix { display: flex; align-items: center; padding: 0 0 0 .8rem; color: var(--muted); font-weight: 400; white-space: nowrap; font-size: .9rem; }
.slug-field input { border: 0; padding-left: .1rem; min-width: 0; }
.slug-field input:focus { outline: none; }
.share-warn { margin: .75rem 0 0; color: var(--warn); font-size: .85rem; }
@media (max-width: 600px) { .slug-prefix { font-size: .78rem; } }
