:root {
  --paper: #F5F5F2;
  --ink: #191B1D;
  --muted: #6E7377;
  --line: #DFE1DD;
  --accent: #3D5A4C;
  --ui: "Jost", "Helvetica Neue", Arial, sans-serif;
  --display: "Cormorant Garamond", Georgia, serif;
  --gap: 10px;
  --field: #FFFFFF;
  --bar: rgba(245,245,242,.94);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --paper:#141516; --ink:#ECEDEA; --muted:#9A9FA2; --line:#2E3133; --field:#1D1F20; --bar:rgba(20,21,22,.94); }
}
:root[data-theme="dark"] { --paper:#141516; --ink:#ECEDEA; --muted:#9A9FA2; --line:#2E3133; --field:#1D1F20; --bar:rgba(20,21,22,.94); }
:root { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 16px;
  line-height: 1.65;
}
img { max-width: 100%; display: block; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
[hidden] { display: none !important; }

/* buttons & fields */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  border: 1px solid var(--ink); background: var(--ink); color: var(--paper);
  padding: .7em 1.4em; border-radius: 2px; cursor: pointer; text-decoration: none;
  font-size: .95rem;
}
.btn:hover { background: var(--accent); border-color: var(--accent); }
.btn-quiet {
  border: 1px solid var(--line); background: transparent; color: var(--ink);
  padding: .45em 1em; border-radius: 2px; cursor: pointer; text-decoration: none;
  font-size: .9rem; white-space: nowrap;
}
.btn-quiet:hover { border-color: var(--ink); }
.btn-quiet[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.field { display: grid; gap: .3em; margin-bottom: 1.1em; }
.field label { font-size: .85rem; color: var(--muted); }
.field input {
  width: 100%; padding: .75em .9em; border: 1px solid var(--line); background: var(--field);
  border-radius: 2px; font-size: 1rem;
}
.field input:focus { border-color: var(--ink); outline: none; }
.error { color: #9B2C1E; font-size: .9rem; min-height: 1.5em; margin: 0 0 .8em; }

/* ---------- landing ---------- */
.landing {
  min-height: 100vh; display: grid; grid-template-columns: 1.2fr 1fr;
}
.landing-mark {
  background: #191B1D; color: #F5F5F2;
  padding: clamp(2rem, 6vw, 5rem); display: flex; flex-direction: column; justify-content: space-between;
}
.landing-mark h1 {
  font-family: var(--display); font-weight: 400; margin: 0;
  font-size: clamp(3rem, 8vw, 6.5rem); line-height: 1.15;
}
.landing-mark p { color: #B9BDBF; margin: 0; max-width: 32ch; }
.landing-form {
  padding: clamp(2rem, 6vw, 5rem); display: flex; flex-direction: column; justify-content: center;
  max-width: 460px; width: 100%; justify-self: center;
}
.landing-form h2 { font-weight: 500; font-size: 1.5rem; margin: 0 0 .3em; }
.landing-form > p { color: var(--muted); margin: 0 0 2em; }
.landing-form .btn { width: 100%; }
.contact { margin-top: 2.5em; font-size: .9rem; color: var(--muted); }
.contact a { color: var(--ink); }
@media (max-width: 760px) {
  .landing { grid-template-columns: 1fr; }
  .landing-mark { min-height: 42vh; gap: 2rem; }
}

/* ---------- gallery gate ---------- */
.gate {
  min-height: 100vh; display: grid; place-items: center; padding: 2rem;
}
.gate form { width: 100%; max-width: 380px; }
.gate .studio { color: var(--muted); font-size: .9rem; margin: 0 0 .5em; }
.gate h1 { font-family: var(--display); font-weight: 400; font-size: 2.6rem; margin: 0 0 1em; line-height: 1.2; }
.gate .btn { width: 100%; }

/* ---------- cover ---------- */
.cover {
  position: relative; height: 100vh; min-height: 520px; overflow: hidden; background: #2a2d2f; color: #fff;
}
.cover img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transition: opacity 1.2s ease;
}
.cover img.loaded { opacity: 1; }
.cover::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,.55), rgba(0,0,0,0) 55%);
}
.cover-text {
  position: absolute; z-index: 1; inset-inline: 0; bottom: 0;
  padding: clamp(1.5rem, 5vw, 4rem); text-align: center;
}
.cover-text .studio { margin: 0 0 .6em; font-size: .9rem; opacity: .85; }
.cover-text h1 {
  font-family: var(--display); font-weight: 400; margin: 0;
  font-size: clamp(3.2rem, 11vw, 8.5rem); line-height: 1.05;
  text-shadow: 0 2px 30px rgba(0,0,0,.25);
}
.cover-text .date { margin: .4em 0 1.6em; opacity: .9; }
.cover-text a {
  display: inline-block; color: #fff; text-decoration: none; border: 1px solid rgba(255,255,255,.7);
  padding: .6em 1.6em; border-radius: 2px;
}
.cover-text a:hover { background: #fff; color: var(--ink); }

/* ---------- bar ---------- */
.bar {
  position: sticky; top: 0; z-index: 10; background: var(--bar);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.bar-in {
  max-width: 1600px; margin: 0 auto; padding: .7rem clamp(1rem, 3vw, 2rem);
  display: flex; align-items: center; gap: 1.2rem;
}
.bar-title { font-family: var(--display); font-size: 1.35rem; white-space: nowrap; }
.sets { display: flex; gap: .2rem; overflow-x: auto; flex: 1; scrollbar-width: none; }
.sets::-webkit-scrollbar { display: none; }
.sets button {
  background: none; border: 0; padding: .4em .8em; cursor: pointer; color: var(--muted);
  white-space: nowrap; border-bottom: 1px solid transparent;
}
.sets button[aria-current="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.actions { display: flex; gap: .5rem; margin-inline-start: auto; }
@media (max-width: 640px) {
  .bar-in { flex-wrap: wrap; gap: .5rem 1rem; }
  .bar-title { flex: 1; }
  .sets { order: 3; flex-basis: 100%; }
}

/* ---------- grid ---------- */
main { max-width: 1600px; margin: 0 auto; padding: clamp(1rem, 3vw, 2rem); }
.grid { columns: 4 260px; column-gap: var(--gap); }
.tile { position: relative; margin: 0 0 var(--gap); break-inside: avoid; background: var(--line); }
.tile .open { all: unset; display: block; cursor: zoom-in; width: 100%; }
.tile .open:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tile img { width: 100%; height: auto; }
.heart {
  position: absolute; top: 8px; inset-inline-start: 8px; width: 36px; height: 36px;
  border-radius: 50%; border: 0; cursor: pointer; display: grid; place-items: center;
  background: rgba(255,255,255,.88); color: var(--ink); opacity: 0; transition: opacity .2s;
}
.tile:hover .heart, .heart:focus-visible, .heart[aria-pressed="true"] { opacity: 1; }
@media (hover: none) { .heart { opacity: 1; } }
.heart svg { width: 18px; height: 18px; }
.heart[aria-pressed="true"] svg path { fill: currentColor; }

.empty { text-align: center; color: var(--muted); padding: 5rem 1rem; max-width: 40ch; margin: 0 auto; }
.favtools {
  display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; justify-content: space-between;
  border: 1px solid var(--line); background: var(--field); padding: 1rem 1.2rem; margin-bottom: 1.2rem;
}
.favtools p { margin: 0; color: var(--muted); font-size: .92rem; }
.favtools div { display: flex; gap: .5rem; flex-wrap: wrap; }
footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 3rem 1rem; }

/* ---------- lightbox ---------- */
dialog.lb {
  width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
  background: #000; color: #fff;
}
dialog.lb::backdrop { background: #000; }
.lb-stage { position: absolute; inset: 56px 0 56px; display: grid; place-items: center; padding: 0 64px; }
.lb-stage img { max-width: 100%; max-height: 100%; object-fit: contain; user-select: none; }
.lb-top, .lb-bottom {
  position: absolute; inset-inline: 0; height: 56px; display: flex; align-items: center;
  justify-content: space-between; padding: 0 1rem; gap: 1rem;
}
.lb-top { top: 0; }
.lb-bottom { bottom: 0; justify-content: center; color: #9a9ea1; font-size: .85rem; }
.lb-name { font-size: .85rem; color: #9a9ea1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-tools { display: flex; gap: .4rem; }
.lb-btn {
  background: transparent; border: 0; color: #fff; width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer; text-decoration: none;
}
.lb-btn:hover { background: rgba(255,255,255,.12); }
.lb-btn svg { width: 22px; height: 22px; }
.lb-btn[aria-pressed="true"] svg path { fill: currentColor; }
.lb-btn[aria-disabled="true"] { opacity: .35; pointer-events: none; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); }
.lb-prev { inset-inline-start: 10px; }
.lb-next { inset-inline-end: 10px; }
@media (max-width: 640px) { .lb-stage { padding: 0; } .lb-nav { display: none; } }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 100;
  background: var(--ink); color: var(--paper); padding: .7em 1.2em; border-radius: 2px; font-size: .92rem;
  max-width: calc(100vw - 2rem); text-align: center;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .cover img, .heart { transition: none; }
}

/* =========================================================
   Dashboard
   ========================================================= */
.ad-top { background: var(--paper); border-bottom: 1px solid var(--line); }
.ad-top-in {
  max-width: 1400px; margin: 0 auto; padding: .8rem clamp(1rem, 3vw, 2rem);
  display: flex; align-items: center; gap: 2rem;
}
.ad-brand { font-family: var(--display); font-size: 1.5rem; color: var(--ink); text-decoration: none; white-space: nowrap; }
.ad-nav { display: flex; gap: .3rem; flex: 1; }
.ad-nav a { color: var(--muted); text-decoration: none; padding: .35em .8em; border-bottom: 1px solid transparent; }
.ad-nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--ink); }
.ad-banner {
  max-width: 1400px; margin: 1.2rem auto 0; padding: 1.1rem 1.4rem;
  display: flex; gap: 1.5rem; align-items: center; justify-content: space-between;
  background: var(--accent); color: #fff; width: calc(100% - 2 * clamp(1rem, 3vw, 2rem));
}
.ad-banner p { margin: .2em 0 0; opacity: .9; font-size: .92rem; max-width: 60ch; }
.ad-banner .btn { background: #fff; color: var(--ink); border-color: #fff; white-space: nowrap; }
.ad-main { max-width: 1400px; margin: 0 auto; padding: clamp(1rem, 3vw, 2rem); }
.ad-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.4rem; flex-wrap: wrap; }
.ad-head h1 { font-family: var(--display); font-weight: 400; font-size: clamp(2rem, 4vw, 2.8rem); margin: 0; line-height: 1.2; }
.ad-small { color: var(--muted); font-size: .86rem; margin: .3em 0 0; }

.ad-galleries { display: grid; border-top: 1px solid var(--line); }
.ad-row { display: grid; grid-template-columns: 96px 1fr auto; gap: 1.2rem; align-items: center; padding: .9rem 0; border-bottom: 1px solid var(--line); }
.ad-row-thumb { width: 96px; height: 72px; background: var(--line); display: block; overflow: hidden; }
.ad-row-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ad-row-title { font-family: var(--display); font-size: 1.45rem; color: var(--ink); text-decoration: none; line-height: 1.3; }
.ad-row-title:hover { color: var(--accent); }
@media (max-width: 560px) {
  .ad-row { grid-template-columns: 72px 1fr; }
  .ad-row-thumb { width: 72px; height: 56px; }
  .ad-row-actions { grid-column: 1 / -1; }
}

.ad-back { display: inline-block; color: var(--muted); text-decoration: none; margin-bottom: 1rem; font-size: .92rem; }
.ad-back:hover { color: var(--ink); }
.ad-edit-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 2.5rem; align-items: start; }
@media (max-width: 960px) { .ad-edit-grid { grid-template-columns: 1fr; } }
.ad-side { display: grid; gap: 1.2rem; position: sticky; top: 1rem; }
@media (max-width: 960px) { .ad-side { position: static; } }
.ad-card { background: var(--field); border: 1px solid var(--line); padding: 1.3rem; }
.ad-card h2 { font-size: 1.05rem; font-weight: 500; margin: 0 0 1rem; }
.ad-card .btn { width: 100%; }
.ad-copyrow { display: flex; gap: .5rem; }
.ad-copyrow input { flex: 1; min-width: 0; padding: .55em .7em; border: 1px solid var(--line); background: var(--paper); font-size: .88rem; border-radius: 2px; }
.ad-stack { display: grid; gap: .5rem; margin-top: 1rem; }
.ad-stack .btn-quiet { text-align: center; }
.ad-check { display: flex; gap: .6em; align-items: center; font-size: .92rem; margin: .3rem 0 1rem; cursor: pointer; }
.ad-check input { width: 18px; height: 18px; accent-color: var(--accent); }
.ad-link { background: none; border: 0; padding: .3em 0; cursor: pointer; color: var(--muted); font-size: .88rem; text-decoration: underline; text-underline-offset: 3px; }
.ad-link:hover { color: var(--ink); }
.ad-link-danger { color: #9B2C1E; }
.ad-link-danger:hover { color: #7a1f14; }
.ad-note { background: var(--field); border: 1px solid var(--line); padding: .9rem 1.1rem; color: var(--muted); font-size: .92rem; }

.ad-sets-row { display: flex; align-items: center; gap: 1rem; border-bottom: 1px solid var(--line); margin-bottom: .6rem; }
.ad-set-tools { display: flex; gap: 1.2rem; margin-bottom: 1rem; }
.ad-drop { position: relative;
  display: grid; place-items: center; text-align: center; gap: .2rem; padding: 2.2rem 1rem; margin-bottom: 1rem;
  border: 1px dashed var(--muted); cursor: pointer; background: var(--field);
}
.ad-drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.ad-drop strong { font-weight: 500; }
.ad-drop span { color: var(--muted); font-size: .88rem; }
.ad-drop:hover, .ad-drop.over { border-color: var(--accent); border-style: solid; }
.ad-drop:focus-within { outline: 2px solid var(--accent); outline-offset: 3px; }
.ad-queue { display: grid; gap: .4rem; margin-bottom: 1rem; }
.ad-qitem { display: grid; grid-template-columns: minmax(0, 1fr) 160px; gap: 1rem; align-items: center; font-size: .85rem; }
.ad-qname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ad-qbar { height: 4px; background: var(--line); }
.ad-qbar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.ad-qitem.failed .ad-qname { color: #9B2C1E; white-space: normal; }
.ad-qitem.failed .ad-qbar { display: none; }

.ad-grid { columns: auto; column-count: 4; }
@media (max-width: 900px) { .ad-grid { column-count: 3; } }
@media (max-width: 600px) { .ad-grid { column-count: 2; --gap: 6px; } }
.ad-tile .ad-badge {
  position: absolute; top: 8px; inset-inline-end: 8px; background: var(--accent); color: #fff; font-size: .75rem; padding: .2em .6em;
}
.ad-tile-tools {
  position: absolute; inset-inline: 0; bottom: 0; display: flex; gap: 1px; opacity: 0; transition: opacity .15s;
}
.ad-tile:hover .ad-tile-tools, .ad-tile:focus-within .ad-tile-tools { opacity: 1; }
@media (hover: none) { .ad-tile-tools { opacity: 1; } }
.ad-tile-tools button {
  flex: 1; border: 0; padding: .5em; cursor: pointer; font-size: .8rem;
  background: rgba(25,27,29,.82); color: #fff;
}
.ad-tile-tools button:hover { background: rgba(25,27,29,.95); }

.ad-settings { max-width: 560px; }
.ad-swatches { border: 0; padding: 0; margin: 0 0 1.1em; }
.ad-swatches legend { font-size: .85rem; color: var(--muted); margin-bottom: .5em; padding: 0; }
#ad-s-colors { display: flex; gap: .6rem; flex-wrap: wrap; }
.ad-swatch { position: relative; cursor: pointer; }
.ad-swatch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.ad-swatch span { display: block; width: 40px; height: 40px; border-radius: 50%; background: var(--c); border: 3px solid var(--field); box-shadow: 0 0 0 1px var(--line); }
.ad-swatch input:checked + span { box-shadow: 0 0 0 2px var(--ink); }
.ad-swatch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 3px; }

.ad-dialog { border: 1px solid var(--line); padding: 0; width: min(480px, calc(100vw - 2rem)); background: var(--paper); color: var(--ink); }
.ad-dialog::backdrop { background: rgba(0,0,0,.45); }
.ad-dialog form { padding: 1.6rem; }
.ad-dialog h2 { font-family: var(--display); font-weight: 400; font-size: 1.9rem; margin: 0 0 1rem; }
.ad-source { border: 0; padding: 0; }
.ad-source legend { font-size: .85rem; color: var(--muted); padding: 0; margin-bottom: .4em; }
.ad-source .ad-check { margin: .3rem 0; }
.ad-dialog-actions { display: flex; gap: .6rem; }
.ad-dialog-actions .btn { flex: 1; }
.field input[type="date"] { min-height: 2.9em; }

.btn:hover { filter: brightness(1.08); }
@media (max-width: 640px) {
  .ad-top-in { flex-wrap: wrap; gap: .4rem 1rem; }
  .ad-brand { flex: 1; font-size: 1.3rem; }
  .ad-nav { order: 3; flex-basis: 100%; }
  .ad-banner { flex-direction: column; align-items: stretch; }
}

.dl-progress {
  position: fixed; z-index: 60; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 20px);
  width: min(420px, calc(100vw - 2rem)); background: var(--ink); color: var(--paper);
  padding: .8em 1em; display: grid; gap: .5em; font-size: .9rem;
}
.dl-bar { height: 4px; background: rgba(255,255,255,.25); display: block; }
.dl-bar i { display: block; height: 100%; width: 0; background: var(--paper); transition: width .2s; }
.ad-banner .btn { background: #fff; color: #191B1D; border-color: #fff; white-space: nowrap; }
.ad-banner .btn:hover { background: #f0f0ee; color: #191B1D; }

/* =========================================================
   Gallery design options
   ========================================================= */
#app { --title-font: var(--display); --cols: 4; }
.cover-text h1, .bar-title { font-family: var(--title-font); }
#app[data-font="script"] .cover-text h1 { font-size: clamp(3.6rem, 12vw, 9.5rem); line-height: 1.15; }
#app[data-font="script"] .bar-title { font-size: 1.6rem; }
#app[data-font="modern"] .cover-text h1, #app[data-font="minimal"] .cover-text h1 {
  font-weight: 300; text-transform: uppercase; letter-spacing: .16em; font-size: clamp(2rem, 6.5vw, 5rem); line-height: 1.2;
}
#app[data-font="modern"] .bar-title, #app[data-font="minimal"] .bar-title { text-transform: uppercase; letter-spacing: .12em; font-size: 1rem; }
#app[data-font="roman"] .cover-text h1 { text-transform: uppercase; letter-spacing: .06em; font-size: clamp(2.4rem, 8vw, 6.5rem); }
#app[data-font="roman"] .bar-title { text-transform: uppercase; letter-spacing: .05em; font-size: 1.1rem; }

/* Cover: centered */
#app[data-cover="center"] .cover-text { top: 50%; bottom: auto; transform: translateY(-50%); }
#app[data-cover="center"] .cover::after { background: rgba(0,0,0,.32); }

/* Cover: split */
#app[data-cover="split"] .cover { display: grid; grid-template-columns: 1.35fr 1fr; background: var(--paper); color: var(--ink); }
#app[data-cover="split"] .cover img { position: relative; inset: auto; height: 100%; }
#app[data-cover="split"] .cover::after { display: none; }
#app[data-cover="split"] .cover-text { position: static; align-self: center; text-align: left; padding: clamp(2rem, 6vw, 5rem); }
#app[data-cover="split"] .cover-text h1 { text-shadow: none; font-size: clamp(2.6rem, 5.5vw, 5.5rem); }
#app[data-cover="split"][data-font="script"] .cover-text h1 { font-size: clamp(3rem, 6.5vw, 6.5rem); }
#app[data-cover="split"] .cover-text a { color: var(--ink); border-color: var(--ink); }
#app[data-cover="split"] .cover-text a:hover { background: var(--ink); color: var(--paper); }
@media (max-width: 760px) {
  #app[data-cover="split"] .cover { grid-template-columns: 1fr; grid-template-rows: 62svh auto; height: auto; }
  #app[data-cover="split"] .cover-text { text-align: center; padding: 2rem 1.25rem 2.5rem; }
}

/* Cover: framed */
#app[data-cover="frame"] .cover {
  height: auto; min-height: 0; background: var(--paper); color: var(--ink);
  padding: clamp(1rem, 4vw, 3rem) clamp(1rem, 4vw, 3rem) 0;
}
#app[data-cover="frame"] .cover img { position: relative; inset: auto; height: min(78svh, 900px); }
#app[data-cover="frame"] .cover::after { display: none; }
#app[data-cover="frame"] .cover-text { position: static; padding: clamp(1.5rem, 4vw, 3rem) 1rem clamp(1rem, 3vw, 2rem); }
#app[data-cover="frame"] .cover-text h1 { text-shadow: none; font-size: clamp(2.6rem, 8vw, 6.5rem); }
#app[data-cover="frame"] .cover-text a { color: var(--ink); border-color: var(--ink); }
#app[data-cover="frame"] .cover-text a:hover { background: var(--ink); color: var(--paper); }

/* Cover: no image */
#app[data-cover="minimal"] .cover { height: auto; min-height: 0; background: var(--paper); color: var(--ink); }
#app[data-cover="minimal"] .cover img, #app[data-cover="minimal"] .cover::after { display: none; }
#app[data-cover="minimal"] .cover-text { position: static; padding: clamp(4rem, 14vw, 9rem) 1.25rem clamp(2.5rem, 7vw, 4.5rem); }
#app[data-cover="minimal"] .cover-text h1 { text-shadow: none; }
#app[data-cover="minimal"] .cover-text a { color: var(--ink); border-color: var(--ink); }
#app[data-cover="minimal"] .cover-text a:hover { background: var(--ink); color: var(--paper); }

/* Photo grid: size and style */
#app[data-size="s"] { --cols: 5; }
#app[data-size="m"] { --cols: 4; }
#app[data-size="l"] { --cols: 3; }
@media (max-width: 900px) {
  #app[data-size="s"] { --cols: 4; }
  #app[data-size="m"] { --cols: 3; }
  #app[data-size="l"] { --cols: 2; }
}
@media (max-width: 600px) {
  #app { --gap: 4px; }
  #app[data-size="s"] { --cols: 3; }
  #app[data-size="m"] { --cols: 2; }
  #app[data-size="l"] { --cols: 1; }
  #app main { padding-inline: 4px; }
  #app .heart { width: 30px; height: 30px; top: 5px; inset-inline-start: 5px; }
  #app .heart svg { width: 15px; height: 15px; }
}
#app .grid { columns: auto; column-count: var(--cols); column-gap: var(--gap); }
#app[data-grid="square"] .grid { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: var(--gap); column-count: auto; }
#app[data-grid="square"] .tile { margin: 0; aspect-ratio: 1 / 1; overflow: hidden; }
#app[data-grid="square"] .tile .open, #app[data-grid="square"] .tile .open img { height: 100%; }
#app[data-grid="square"] .tile img { aspect-ratio: 1 / 1 !important; object-fit: cover; }

/* Dashboard: design card */
.ad-label { font-size: .85rem; color: var(--muted); margin: 1.1rem 0 .5rem; }
.ad-label:first-of-type { margin-top: 0; }
.ad-choices { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .4rem; }
.ad-choice { background: none; border: 1px solid transparent; padding: .3rem .2rem; cursor: pointer; display: grid; gap: .3rem; justify-items: center; color: var(--muted); font-size: .72rem; }
.ad-choice[aria-pressed="true"] { border-color: var(--ink); color: var(--ink); }
.ad-cv { position: relative; width: 44px; height: 32px; display: block; background: var(--line); overflow: hidden; }
.ad-cv i, .ad-cv b { position: absolute; display: block; }
.ad-cv-full i { inset: 0; background: var(--muted); }
.ad-cv-full b { left: 12px; right: 12px; bottom: 6px; height: 3px; background: var(--paper); }
.ad-cv-center i { inset: 0; background: var(--muted); }
.ad-cv-center b { left: 12px; right: 12px; top: 14px; height: 3px; background: var(--paper); }
.ad-cv-split i { left: 0; top: 0; bottom: 0; width: 58%; background: var(--muted); }
.ad-cv-split b { right: 4px; width: 12px; top: 14px; height: 3px; background: var(--ink); }
.ad-cv-frame i { left: 6px; right: 6px; top: 4px; height: 18px; background: var(--muted); }
.ad-cv-frame b { left: 14px; right: 14px; bottom: 4px; height: 3px; background: var(--ink); }
.ad-cv-minimal i { display: none; }
.ad-cv-minimal b { left: 10px; right: 10px; top: 14px; height: 3px; background: var(--ink); }
.ad-fonts { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; }
.ad-font { background: var(--paper); border: 1px solid var(--line); padding: .6rem .5rem; cursor: pointer; display: grid; gap: .1rem; text-align: center; color: var(--ink); min-width: 0; }
.ad-font[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.ad-font-sample { font-size: 1.1rem; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ad-font[data-font="script"] .ad-font-sample { font-size: 1.35rem; }
.ad-font[data-font="modern"] .ad-font-sample, .ad-font[data-font="minimal"] .ad-font-sample { text-transform: uppercase; letter-spacing: .06em; font-size: .78rem; font-weight: 300; line-height: 2.2; }
.ad-font[data-font="roman"] .ad-font-sample { text-transform: uppercase; font-size: .88rem; line-height: 2; }
.ad-font .ad-small { margin: 0; font-size: .75rem; }
.ad-seg { display: flex; border: 1px solid var(--line); }
.ad-seg button { flex: 1; background: none; border: 0; padding: .5em .4em; cursor: pointer; color: var(--muted); font-size: .88rem; }
.ad-seg button + button { border-inline-start: 1px solid var(--line); }
.ad-seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
#ad-d-hint { margin-top: .6rem; }

/* =========================================================
   Logo (colored by the surrounding text color)
   ========================================================= */
.logo {
  display: inline-block; vertical-align: middle; height: 1em; aspect-ratio: var(--logo-ratio, 1.86);
  background-color: currentColor;
  -webkit-mask: var(--logo) center / contain no-repeat; mask: var(--logo) center / contain no-repeat;
}
.landing-mark h1 .logo { height: clamp(110px, 18vw, 230px); }
.cover-text .studio .logo { height: clamp(40px, 7vw, 64px); }
.cover-text .studio:has(.logo) { opacity: 1; margin-bottom: 1.2em; }
.gate .studio .logo { height: 64px; }
.gate .studio:has(.logo) { margin-bottom: 1.5em; }
footer .logo { height: 46px; }
.ad-brand .logo { height: 36px; }
#ad-login h1 .logo { height: 84px; }
.ad-logo-preview { display: grid; grid-template-columns: 1fr 1fr; margin-bottom: .7rem; border: 1px solid var(--line); }
.ad-logo-preview > span { display: grid; place-items: center; padding: 1rem; min-height: 86px; }
.ad-logo-preview .logo { height: 52px; }
.ad-logo-on-light { background: #F5F5F2; color: #191B1D; }
.ad-logo-on-dark { background: #191B1D; color: #F5F5F2; }
.ad-logo-actions { display: flex; align-items: center; gap: 1rem; margin: .7rem 0 .4rem; }
.ad-logo-actions label { cursor: pointer; }
.ad-logo legend { font-size: .85rem; color: var(--muted); padding: 0; margin-bottom: .5em; }
.ad-logo { border: 0; padding: 0; }

/* =========================================================
   Gallery header, menu, set title
   ========================================================= */
.bar-in { flex-wrap: nowrap; padding-block: .55rem; }
.bar-id { display: grid; min-width: 0; flex: 1; line-height: 1.25; }
.bar-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 1.4rem; }
.bar-studio { font-size: .68rem; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.bar .actions { display: flex; align-items: center; gap: .15rem; margin-inline-start: auto; }
.icon-btn {
  position: relative; width: 44px; height: 44px; display: grid; place-items: center;
  background: none; border: 0; color: var(--ink); cursor: pointer; border-radius: 50%;
}
.icon-btn:hover { background: rgba(127,127,127,.12); }
.icon-btn svg { width: 24px; height: 24px; }
#favBtn[aria-pressed="true"] svg path { fill: currentColor; }
.badge {
  position: absolute; top: 5px; right: 2px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
  background: var(--accent); color: #fff; font-size: .62rem; display: grid; place-items: center; line-height: 1;
}
.menu-wrap { position: relative; }
.i-close { display: none; }
#menuBtn[aria-expanded="true"] .i-burger { display: none; }
#menuBtn[aria-expanded="true"] .i-close { display: block; }
.menu {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 30; min-width: 260px; padding: .35rem 0;
  background: var(--field); border: 1px solid var(--line); box-shadow: 0 14px 34px rgba(0,0,0,.14);
}
.menu > * {
  display: flex; align-items: center; gap: .85rem; width: 100%; padding: .9rem 1.25rem;
  background: none; border: 0; color: var(--ink); text-decoration: none; cursor: pointer; text-align: left;
  font-size: .86rem; letter-spacing: .08em; text-transform: uppercase;
}
.menu > *:hover, .menu > *:focus-visible { background: var(--paper); }
.menu svg { width: 20px; height: 20px; flex: none; }
.sets-bar { background: rgba(127,127,127,.12); }
.sets-bar .sets { max-width: 1600px; margin: 0 auto; padding: 0 clamp(.4rem, 3vw, 2rem); }
.sets-bar .sets button { text-transform: uppercase; letter-spacing: .08em; font-size: .8rem; padding: .8em .85em; }
@media (max-width: 640px) {
  .bar-in { flex-wrap: nowrap; }
  .bar-title { font-size: 1.15rem; }
}
.set-title {
  font-family: var(--title-font, var(--display)); font-weight: 400; text-align: center;
  font-size: clamp(1.7rem, 5vw, 2.6rem); margin: clamp(1.4rem, 5vw, 3rem) 0 clamp(1.1rem, 4vw, 2.4rem);
}
#app[data-font="modern"] .set-title, #app[data-font="minimal"] .set-title, #app[data-font="roman"] .set-title {
  text-transform: uppercase; letter-spacing: .12em; font-size: clamp(1.2rem, 3.5vw, 1.8rem);
}

/* Cover footer (chevron + studio) used by the Centered cover */
.cover-foot { display: none; }
#app[data-cover="center"] .cover-foot {
  position: absolute; z-index: 1; left: 0; right: 0; bottom: calc(env(safe-area-inset-bottom, 0px) + 1.4rem);
  display: grid; justify-items: center; gap: .35rem; color: #fff; text-decoration: none;
  font-size: .72rem; letter-spacing: .18em; text-transform: uppercase;
}
.cover-foot svg { width: 46px; height: 23px; animation: nudge 2.4s ease-in-out infinite; }
.cover-foot .logo { height: 30px; }
#app[data-cover="center"] .cover-btn, #app[data-cover="center"] .cover-text .studio { display: none; }
@keyframes nudge { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { .cover-foot svg { animation: none; } }

/* =========================================================
   Photo viewer (light)
   ========================================================= */
dialog.lb { background: var(--paper); color: var(--ink); }
dialog.lb::backdrop { background: var(--paper); }
.lb-btn { color: var(--ink); }
.lb-btn:hover { background: rgba(127,127,127,.12); }
.lb-top { top: env(safe-area-inset-top, 0px); height: 64px; justify-content: space-between; }
.lb-count { font-size: .8rem; color: var(--muted); letter-spacing: .08em; }
.lb-stage { inset: calc(env(safe-area-inset-top, 0px) + 64px) 0 calc(env(safe-area-inset-bottom, 0px) + 72px); padding: 0 64px; }
.lb-bottom {
  bottom: env(safe-area-inset-bottom, 0px); height: 72px; justify-content: space-between; gap: .5rem;
  color: var(--ink); font-size: inherit; padding: 0 .7rem;
}
.lb-bottom .lb-tools { display: flex; gap: .25rem; }
.lb-name { flex: 1; min-width: 0; text-align: center; color: var(--muted); font-size: .76rem; }
.lb-btn svg { width: 24px; height: 24px; }
.i-pause { display: none; }
#lbPlay[aria-pressed="true"] .i-play { display: none; }
#lbPlay[aria-pressed="true"] .i-pause { display: block; }
@media (max-width: 640px) { .lb-stage { padding: 0 .9rem; } }

/* =========================================================
   Welcome guide & sheets
   ========================================================= */
dialog.tour, dialog.sheet {
  width: min(440px, calc(100vw - 2rem)); border: 0; border-radius: 14px; background: var(--field); color: var(--ink);
}
dialog.tour { padding: 1.2rem 1.4rem 1rem; }
dialog.tour::backdrop, dialog.sheet::backdrop { background: rgba(0,0,0,.55); }
.tour-head {
  display: flex; justify-content: space-between; align-items: center; background: var(--paper);
  padding: .75rem .9rem; font-size: .7rem; letter-spacing: .22em; text-transform: uppercase; color: var(--muted);
}
.tour-dots { display: flex; gap: 6px; }
.tour-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--line); }
.tour-dots i.on { background: var(--accent); }
.tour-img { position: relative; aspect-ratio: 4 / 3; background: var(--line); overflow: hidden; }
.tour-img img { width: 100%; height: 100%; object-fit: cover; }
.tour-icon {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 74px; height: 74px; border-radius: 50%;
  background: rgba(255,255,255,.94); color: #191B1D; display: grid; place-items: center; box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.tour-icon svg { width: 34px; height: 34px; }
dialog.tour h2 { font-size: 1.2rem; font-weight: 500; margin: 1.15rem 0 .35rem; }
dialog.tour p { color: var(--muted); margin: 0 0 1.4rem; line-height: 1.6; }
.tour-actions { display: flex; align-items: center; gap: .6rem; }
.tour-actions .btn { margin-inline-start: auto; background: var(--accent); border-color: var(--accent); color: #fff; }
.tour-skip {
  display: block; margin: .7rem auto 0; padding: .5rem 1rem; background: none; border: 0; cursor: pointer;
  color: var(--muted); letter-spacing: .16em; text-transform: uppercase; font-size: .74rem;
}
dialog.sheet { padding: 1.7rem; }
dialog.sheet h2 { font-family: var(--display); font-weight: 400; font-size: 1.9rem; margin: 0 0 .8rem; }
dialog.sheet ol { padding-inline-start: 1.2rem; line-height: 1.9; margin: 0 0 1.4rem; }
.sheet-actions { display: flex; justify-content: flex-end; }

/* =========================================================
   Polish: native controls follow the theme (date picker icon)
   ========================================================= */
:root { color-scheme: light; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { color-scheme: dark; } }
:root[data-theme="dark"] { color-scheme: dark; }
input[type="date"]::-webkit-calendar-picker-indicator { cursor: pointer; opacity: 1; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(1) brightness(1.4); }
}
input[type="date"]:disabled { opacity: .45; cursor: not-allowed; }
.ad-check-under { margin: .7rem 0 0; }

/* Heart on photos: just the icon */
.heart {
  background: none; color: #fff; width: 40px; height: 40px;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,.6));
  transition: opacity .2s, transform .2s;
}
.heart:hover { transform: scale(1.12); }
.heart svg { width: 22px; height: 22px; }
.heart[aria-pressed="true"] { animation: pop-heart .35s ease; }
@keyframes pop-heart { 0% { transform: scale(1); } 45% { transform: scale(1.3); } 100% { transform: scale(1); } }

/* Animated chevron on the full-screen cover too */
#app[data-cover="full"] .cover-foot {
  position: absolute; z-index: 1; left: 0; right: 0; bottom: calc(env(safe-area-inset-bottom, 0px) + 1.2rem);
  display: grid; justify-items: center; color: #fff;
}
#app[data-cover="full"] .cover-foot span { display: none; }
#app[data-cover="full"] .cover-btn { display: none; }
#app[data-cover="full"] .cover-text { padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 5.5rem); }
.cover-foot { cursor: pointer; }

/* Gentle motion */
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
#app:not([hidden]) .cover-text > * { animation: rise .9s cubic-bezier(.2,.7,.2,1) both; }
#app:not([hidden]) .cover-text > :nth-child(2) { animation-delay: .12s; }
#app:not([hidden]) .cover-text > :nth-child(3) { animation-delay: .24s; }
#app:not([hidden]) .cover-text > :nth-child(4) { animation-delay: .36s; }
#app:not([hidden]) .cover-foot { animation: fade 1s .6s both; }
.cover img { transition: opacity 1.2s ease, transform 6s ease; transform: scale(1.04); }
.cover img.loaded { transform: scale(1); }
.tile { overflow: hidden; }
#app .tile img { opacity: 0; transition: opacity .6s ease, transform .6s ease; }
#app .tile img.in { opacity: 1; }
.tile .open:hover img { transform: scale(1.02); }
#lbImg { opacity: 0; transition: opacity .3s ease; }
#lbImg.in { opacity: 1; }
dialog.tour[open], dialog.sheet[open], .ad-dialog[open] { animation: pop .3s ease-out; }
.menu:not([hidden]) { animation: pop .18s ease-out; }
.gate form, .landing-form { animation: rise .7s cubic-bezier(.2,.7,.2,1) both; }
.set-title { animation: fade .5s ease both; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  #app .tile img, #lbImg { opacity: 1; }
}

/* =========================================================
   Dashboard: set buttons
   ========================================================= */
.ad-sets-row { padding-bottom: .2rem; }
.ad-setbtn {
  display: inline-flex; align-items: center; gap: .45rem; padding: .6em 1.1em; font-size: .95rem;
  background: transparent; color: var(--ink); border: 1px solid var(--line); cursor: pointer; white-space: nowrap;
}
.ad-setbtn svg { width: 18px; height: 18px; }
.ad-setbtn:hover { border-color: var(--ink); }
.ad-setbtn-main { background: var(--accent); border-color: var(--accent); color: #fff; }
.ad-setbtn-main:hover { filter: brightness(1.1); border-color: var(--accent); }
.ad-setbtn-danger { color: #C4473A; }
.ad-setbtn-danger:hover { border-color: #C4473A; }
.ad-set-tools { gap: .6rem; margin: .9rem 0 1.2rem; flex-wrap: wrap; }
.ad-sets-row .sets button { font-size: 1rem; padding: .7em 1em; }

/* Dashboard: cover preview */
.ad-pv-wrap { display: grid; justify-items: center; gap: .5rem; margin-top: 1rem; }
.ad-pv {
  position: relative; width: 190px; aspect-ratio: 9 / 17; overflow: hidden; border-radius: 22px;
  background: linear-gradient(160deg, #6c675f, #2c2e30); color: #fff;
  box-shadow: 0 0 0 6px #111, 0 14px 30px rgba(0,0,0,.3);
  --pv-font: var(--display);
}
.ad-pv img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ad-pv::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgba(0,0,0,.55), transparent 60%); }
.ad-pv-text { position: absolute; z-index: 1; left: 0; right: 0; bottom: 0; padding: 0 .8rem 1.4rem; display: grid; justify-items: center; gap: .25rem; text-align: center; }
.ad-pv-logo .logo { height: 18px; }
.ad-pv-logo { font-size: .55rem; }
.ad-pv b { font-family: var(--pv-font); font-weight: 400; font-size: 1.5rem; line-height: 1.1; }
.ad-pv i { font-style: normal; font-size: .6rem; opacity: .9; }
.ad-pv-btn { font-size: .55rem; border: 1px solid rgba(255,255,255,.7); padding: .35em .9em; margin-top: .35rem; }
.ad-pv-foot { display: none; position: absolute; z-index: 1; left: 0; right: 0; bottom: .7rem; justify-content: center; }
.ad-pv-foot svg { width: 26px; height: 13px; animation: nudge 2.4s ease-in-out infinite; }
.ad-pv[data-font="script"] b { font-size: 1.8rem; }
.ad-pv[data-font="modern"] b, .ad-pv[data-font="minimal"] b { text-transform: uppercase; letter-spacing: .14em; font-weight: 300; font-size: .95rem; }
.ad-pv[data-font="roman"] b { text-transform: uppercase; letter-spacing: .05em; font-size: 1.2rem; }
/* full: chevron instead of button */
.ad-pv[data-cover="full"] .ad-pv-btn { display: none; }
.ad-pv[data-cover="full"] .ad-pv-text { padding-bottom: 2.4rem; }
.ad-pv[data-cover="full"] .ad-pv-foot, .ad-pv[data-cover="center"] .ad-pv-foot { display: flex; }
/* centered */
.ad-pv[data-cover="center"]::after { background: rgba(0,0,0,.3); }
.ad-pv[data-cover="center"] .ad-pv-text { top: 50%; bottom: auto; transform: translateY(-50%); padding: 0 .8rem; }
.ad-pv[data-cover="center"] .ad-pv-btn, .ad-pv[data-cover="center"] .ad-pv-logo { display: none; }
/* split, framed, no image: light page */
.ad-pv[data-cover="split"], .ad-pv[data-cover="frame"], .ad-pv[data-cover="minimal"] { background: #F5F5F2; color: #191B1D; }
.ad-pv[data-cover="split"]::after, .ad-pv[data-cover="frame"]::after, .ad-pv[data-cover="minimal"]::after { display: none; }
.ad-pv[data-cover="split"] .ad-pv-btn, .ad-pv[data-cover="frame"] .ad-pv-btn, .ad-pv[data-cover="minimal"] .ad-pv-btn { border-color: #191B1D; }
.ad-pv[data-cover="split"] img { height: 58%; }
.ad-pv[data-cover="split"] .ad-pv-text { top: 58%; bottom: auto; padding-top: .8rem; }
.ad-pv[data-cover="frame"] img { inset: 10px 10px auto; width: calc(100% - 20px); height: 55%; }
.ad-pv[data-cover="frame"] .ad-pv-text { top: calc(55% + 10px); bottom: auto; padding-top: .8rem; }
.ad-pv[data-cover="minimal"] img { display: none; }
.ad-pv[data-cover="minimal"] .ad-pv-text { top: 28%; bottom: auto; }

/* =========================================================
   Photo tile icons (Pixieset style: thin white outlines)
   ========================================================= */
.tile-tools {
  position: absolute; left: 0; bottom: 0; display: flex; gap: .1rem; padding: .35rem;
  opacity: 0; transform: translateY(4px); transition: opacity .25s ease, transform .25s ease;
}
.tile:hover .tile-tools, .tile:focus-within .tile-tools { opacity: 1; transform: none; }
.tile-tools .heart, .tile-dl {
  position: static; opacity: 1; width: 42px; height: 42px; display: grid; place-items: center;
  background: none; border: 0; cursor: pointer; color: #fff; text-decoration: none;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.45));
}
.tile-tools .heart svg, .tile-dl svg { width: 27px; height: 27px; }
.tile-tools .heart svg path { stroke-width: 1.15; }
.tile-dl:hover, .tile-tools .heart:hover { transform: scale(1.1); }
/* A chosen favorite stays visible, filled */
.tile:has(.heart[aria-pressed="true"]) .tile-tools { opacity: 1; transform: none; }
.tile:has(.heart[aria-pressed="true"]) .tile-dl { opacity: 0; }
.tile:hover .tile-dl { opacity: 1; }
@media (hover: none) {
  .tile-tools { opacity: 1; transform: none; padding: .15rem; }
  .tile-dl { display: none; }
  .tile-tools .heart { width: 34px; height: 34px; }
  .tile-tools .heart svg { width: 21px; height: 21px; }
}
/* small tiles on phones */
@media (max-width: 600px) {
  #app[data-size="s"] .tile-tools .heart { width: 28px; height: 28px; }
  #app[data-size="s"] .tile-tools .heart svg { width: 17px; height: 17px; }
}

/* "View" circle on hover for the airy layouts */
.tile .open { position: relative; }
@media (hover: hover) {
  #app[data-grid="spaced"] .tile .open::after, #app[data-grid="stagger"] .tile .open::after, #app[data-grid="single"] .tile .open::after {
    content: "VIEW"; position: absolute; left: 50%; top: 50%; width: 74px; height: 74px; border-radius: 50%;
    background: #fff; color: #191B1D; display: grid; place-items: center; font-family: var(--display);
    font-size: .78rem; letter-spacing: .24em; text-indent: .24em;
    opacity: 0; transform: translate(-50%, -50%) scale(.8); transition: opacity .3s ease, transform .3s ease; pointer-events: none;
  }
  #app[data-grid="spaced"] .tile:hover .open::after, #app[data-grid="stagger"] .tile:hover .open::after, #app[data-grid="single"] .tile:hover .open::after {
    opacity: 1; transform: translate(-50%, -50%) scale(1);
  }
}

/* =========================================================
   New layouts
   ========================================================= */
/* Spaced: airy masonry */
#app[data-grid="spaced"] { --gap: clamp(14px, 3vw, 40px); }
#app[data-grid="spaced"] main, #app[data-grid="stagger"] main { padding-inline: clamp(.8rem, 5vw, 5rem); }
#app[data-grid="spaced"] .tile { margin-bottom: var(--gap); }

/* Staggered: columns with alternate offset (built by script) */
#app[data-grid="stagger"] { --gap: clamp(14px, 3vw, 40px); }
#app[data-grid="stagger"] .grid { display: flex; align-items: flex-start; gap: var(--gap); column-count: auto; }
.stag-col { flex: 1; min-width: 0; display: grid; gap: var(--gap); }
.stag-col:nth-child(odd):not(:only-child) { margin-top: clamp(30px, 8vw, 110px); }
#app[data-grid="stagger"] .tile { margin: 0; }

/* Rows: justified rows of equal height */
#app[data-size="s"] { --rowh: 170px; }
#app[data-size="m"] { --rowh: 250px; }
#app[data-size="l"] { --rowh: 360px; }
@media (max-width: 600px) {
  #app[data-size="s"] { --rowh: 80px; }
  #app[data-size="m"] { --rowh: 120px; }
  #app[data-size="l"] { --rowh: 190px; }
}
#app[data-grid="rows"] .grid { display: flex; flex-wrap: wrap; gap: var(--gap); column-count: auto; }
#app[data-grid="rows"] .grid::after { content: ""; flex-grow: 999999; }
#app[data-grid="rows"] .tile { margin: 0; flex-grow: var(--r); flex-basis: calc(var(--rowh) * var(--r)); }

/* Large: one photo per row */
#app[data-grid="single"] .grid { column-count: 1; max-width: 900px; margin: 0 auto; }
#app[data-grid="single"] { --gap: clamp(12px, 3vw, 36px); }

/* Dashboard: layout icons */
.ad-choices-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; }
.ad-gv { display: block; width: 64px; }
.ad-gv svg { display: block; width: 100%; height: auto; fill: var(--muted); }
.ad-choice[aria-pressed="true"] .ad-gv svg { fill: var(--ink); }
.ad-choices-3 .ad-choice { padding: .5rem .2rem; font-size: .75rem; }

/* =========================================================
   Icons always stand out from the background
   ========================================================= */
:root { --icon: #3D7A5C; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --icon: #9FD3B8; } }
:root[data-theme="dark"] { --icon: #9FD3B8; }

input[type="date"] { position: relative; }
input[type="date"]::-webkit-calendar-picker-indicator {
  filter: none !important; opacity: 1; cursor: pointer; width: 20px; height: 20px;
  background: none; color: transparent;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='3.5' y='5' width='17' height='15.5' rx='2' fill='none' stroke='black' stroke-width='1.8'/%3E%3Cpath d='M3.5 10h17M8 3v4M16 3v4' stroke='black' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='3.5' y='5' width='17' height='15.5' rx='2' fill='none' stroke='black' stroke-width='1.8'/%3E%3Cpath d='M3.5 10h17M8 3v4M16 3v4' stroke='black' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
  background-color: var(--icon);
}
input[type="date"]::-webkit-datetime-edit-fields-wrapper { color: var(--ink); }
.ad-check input, input[type="checkbox"], input[type="radio"] { accent-color: var(--icon); }
.ad-setbtn svg, .ad-stack svg, .ad-row-actions svg { color: var(--icon); }
.ad-setbtn-main svg { color: #fff; }
.ad-choice[aria-pressed="true"] .ad-gv svg { fill: var(--icon); }
.ad-choice[aria-pressed="true"] { border-color: var(--icon); color: var(--ink); }
.ad-font[aria-pressed="true"] { border-color: var(--icon); box-shadow: inset 0 0 0 1px var(--icon); }
.ad-seg button[aria-pressed="true"] { background: var(--icon); color: #141516; }
.ad-drop strong::before {
  content: ""; display: block; width: 34px; height: 34px; margin: 0 auto .5rem; background-color: var(--icon);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 16V4m0 0-4.5 4.5M12 4l4.5 4.5M4 15v3.5A1.5 1.5 0 0 0 5.5 20h13a1.5 1.5 0 0 0 1.5-1.5V15' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 16V4m0 0-4.5 4.5M12 4l4.5 4.5M4 15v3.5A1.5 1.5 0 0 0 5.5 20h13a1.5 1.5 0 0 0 1.5-1.5V15' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
.ad-drop { border-color: var(--icon); }

/* =========================================================
   Dashboard: photo layout preview (phone)
   ========================================================= */
.ad-gpv {
  width: 190px; aspect-ratio: 9 / 17; overflow: hidden; border-radius: 22px; background: var(--paper);
  box-shadow: 0 0 0 6px #111, 0 14px 30px rgba(0,0,0,.3); padding: 22px 6px 6px; position: relative;
  --g: 3px; --c: 2;
}
.ad-gpv::before { content: ""; position: absolute; top: 8px; left: 50%; width: 46px; height: 5px; border-radius: 3px; background: var(--line); transform: translateX(-50%); }
.ad-gpv[data-size="s"] { --c: 3; }
.ad-gpv[data-size="l"] { --c: 1; }
.ad-gpv .t { background: var(--line); overflow: hidden; }
.ad-gpv .t img { display: block; width: 100%; height: 100%; object-fit: cover; }
.ad-gpv-in { columns: var(--c); column-gap: var(--g); }
.ad-gpv-in .t { break-inside: avoid; margin-bottom: var(--g); aspect-ratio: var(--r); }
.ad-gpv[data-grid="square"] .ad-gpv-in { columns: auto; display: grid; grid-template-columns: repeat(var(--c), 1fr); gap: var(--g); }
.ad-gpv[data-grid="square"] .t { aspect-ratio: 1; margin: 0; }
.ad-gpv[data-grid="spaced"] { --g: 9px; padding-inline: 12px; }
.ad-gpv[data-grid="stagger"] { --g: 9px; padding-inline: 10px; }
.ad-gpv[data-grid="stagger"] .ad-gpv-in { columns: auto; display: flex; gap: var(--g); align-items: flex-start; }
.ad-gpv[data-grid="stagger"] .col { flex: 1; display: grid; gap: var(--g); }
.ad-gpv[data-grid="stagger"] .col:nth-child(odd):not(:only-child) { margin-top: 22px; }
.ad-gpv[data-grid="stagger"] .t { margin: 0; }
.ad-gpv[data-grid="rows"] .ad-gpv-in { columns: auto; display: flex; flex-wrap: wrap; gap: var(--g); }
.ad-gpv[data-grid="rows"] .ad-gpv-in::after { content: ""; flex-grow: 999; }
.ad-gpv[data-grid="rows"] .t { margin: 0; flex-grow: var(--r); flex-basis: calc(var(--rh, 44px) * var(--r)); }
.ad-gpv[data-grid="rows"][data-size="s"] { --rh: 30px; }
.ad-gpv[data-grid="rows"][data-size="l"] { --rh: 70px; }
.ad-gpv[data-grid="single"] { --c: 1; --g: 8px; }

/* =========================================================
   Photo viewer: always fits the visible screen (iPhone Safari too)
   ========================================================= */
dialog.lb {
  position: fixed; inset: 0; margin: 0; padding: 0;
  width: 100%; max-width: 100%;
  height: 100vh; height: 100dvh; max-height: 100vh; max-height: 100dvh;
  overflow: hidden; overscroll-behavior: contain;
}
dialog.lb:focus, dialog.lb:focus-visible { outline: none; }
.lb-btn:focus:not(:focus-visible) { outline: none; }
.lb-stage { overflow: hidden; touch-action: pan-y pinch-zoom; display: flex; align-items: center; justify-content: center; }
.lb-stage img {
  display: block; width: auto; height: auto; max-width: 100%; max-height: 100%;
  object-fit: contain; margin: auto;
}
.lb-count { font-size: .85rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink); opacity: .7; }
html.lb-lock, html.lb-lock body { overflow: hidden; overscroll-behavior: none; }
@media (max-width: 640px) {
  .lb-top { height: 56px; }
  .lb-stage { inset: calc(env(safe-area-inset-top, 0px) + 56px) 0 calc(env(safe-area-inset-bottom, 0px) + 64px); padding: 0 .75rem; }
  .lb-bottom { height: 64px; }
}

.save-bar { margin: -.6rem 0 1.4rem; background: var(--line); }
.save-bar i { background: var(--icon); }
dialog.sheet p { color: var(--muted); line-height: 1.6; }
.sheet-actions { gap: .6rem; }

/* =========================================================
   Password screen with the cover photo
   ========================================================= */
.gate { position: relative; overflow: hidden; min-height: 100svh; }
.gate-bg {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transform: scale(1.06); transition: opacity 1.2s ease, transform 8s ease;
}
.gate-bg.loaded { opacity: 1; transform: scale(1); }
.gate-bg:not([src]) { display: none; }
.gate.has-bg::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(to top, rgba(0,0,0,.85) 0%, rgba(0,0,0,.55) 40%, rgba(0,0,0,.15) 75%, rgba(0,0,0,.25) 100%);
}
.gate.has-bg { place-items: end center; padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 2.2rem); }
.gate.has-bg form { position: relative; z-index: 1; color: #fff; }
.gate.has-bg .studio { color: #fff; opacity: 1; }
.gate.has-bg h1 { font-family: var(--title-font, var(--display)); font-size: clamp(2.6rem, 10vw, 4.4rem); line-height: 1.1; margin: 0 0 .15em; }
.gate[data-font="script"] h1 { font-size: clamp(3rem, 12vw, 5rem); }
.gate[data-font="modern"] h1, .gate[data-font="minimal"] h1 { text-transform: uppercase; letter-spacing: .14em; font-weight: 300; font-size: clamp(1.8rem, 7vw, 3rem); }
.gate[data-font="roman"] h1 { text-transform: uppercase; letter-spacing: .05em; font-size: clamp(2.2rem, 8vw, 3.6rem); }
.gate-date { margin: 0 0 1.6rem; opacity: .85; }
.gate.has-bg label { color: rgba(255,255,255,.8); }
.gate.has-bg .field input {
  background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.45); color: #fff;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.gate.has-bg .field input:focus { border-color: #fff; }
.gate.has-bg .btn { background: #fff; color: #191B1D; border-color: #fff; }
.gate.has-bg .error { color: #FFB4A8; }
@media (min-width: 760px) { .gate.has-bg { place-items: center; padding-bottom: 2rem; } }

/* No system "save image" menu on the small previews; press-and-hold saves the original instead */
#app .tile img, #lbImg { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; -webkit-user-drag: none; }

/* Expired gallery */
.gate.is-expired .field, .gate.is-expired #gateBtn, .gate.is-expired #gateErr { display: none; }
.gate-expired p { line-height: 1.6; margin: 0 0 1.4rem; max-width: 34ch; }
.gate-expired .btn { width: 100%; text-decoration: none; }

/* =========================================================
   Dashboard: gallery list (search, months, row actions)
   ========================================================= */
.ad-filters { display: flex; flex-wrap: wrap; gap: .7rem; align-items: center; margin-bottom: 1.4rem; }
.ad-search { position: relative; flex: 1 1 260px; }
.ad-search svg { position: absolute; left: .85rem; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); color: var(--icon); pointer-events: none; }
.ad-search input, .ad-datefilter input {
  width: 100%; padding: .7em .9em; border: 1px solid var(--line); background: var(--field); color: var(--ink); font: inherit; border-radius: 2px;
}
.ad-search input { padding-left: 2.6rem; }
.ad-search input:focus, .ad-datefilter input:focus { outline: none; border-color: var(--icon); }
.ad-datefilter { display: flex; align-items: center; gap: .5rem; color: var(--muted); font-size: .88rem; }
.ad-datefilter input { width: auto; }
.ad-month {
  display: flex; align-items: baseline; justify-content: space-between; gap: 1rem;
  font-family: var(--display); font-weight: 400; font-size: 1.6rem; margin: 2rem 0 .2rem; padding-bottom: .4rem;
  border-bottom: 1px solid var(--line);
}
.ad-month:first-child { margin-top: .4rem; }
.ad-month small { font-family: var(--ui); font-size: .8rem; color: var(--muted); }
.ad-galleries { border-top: 0; }
.ad-row { transition: background .2s ease; padding-inline: .5rem; }
.ad-row:hover { background: rgba(127,127,127,.07); }
.ad-row-actions { display: flex; gap: .4rem; opacity: 0; transform: translateX(6px); transition: opacity .2s ease, transform .2s ease; }
.ad-row:hover .ad-row-actions, .ad-row:focus-within .ad-row-actions { opacity: 1; transform: none; }
@media (hover: none) { .ad-row-actions { opacity: 1; transform: none; } }
.ad-act {
  display: inline-flex; align-items: center; gap: .4rem; padding: .55em .9em; font-size: .88rem;
  background: var(--field); color: var(--ink); border: 1px solid var(--line); cursor: pointer; white-space: nowrap;
}
.ad-act svg { width: 17px; height: 17px; color: var(--icon); }
.ad-act:hover { border-color: var(--icon); }
.ad-act-danger { color: #E07A6E; }
.ad-act-danger svg { color: #E07A6E; }
.ad-act-danger:hover { border-color: #E07A6E; }
.ad-tag { display: inline-block; margin-left: .3rem; padding: .1em .6em; border-radius: 99px; font-size: .74rem; border: 1px solid var(--icon); color: var(--icon); }
.ad-tag-off { border-color: #E07A6E; color: #E07A6E; }
@media (max-width: 640px) {
  .ad-act span { display: none; }
  .ad-act { padding: .55em .65em; }
  .ad-row-actions { grid-column: 1 / -1; }
}

/* Recently deleted */
.ad-trash { margin-top: 2.5rem; border: 1px solid var(--line); background: var(--field); }
.ad-trash summary { cursor: pointer; padding: 1rem 1.2rem; font-size: .95rem; list-style: none; display: flex; align-items: center; gap: .5rem; }
.ad-trash summary::-webkit-details-marker { display: none; }
.ad-trash summary::before { content: "›"; color: var(--icon); font-size: 1.2rem; transition: transform .2s; }
.ad-trash[open] summary::before { transform: rotate(90deg); }
.ad-trash > .ad-small { padding: 0 1.2rem; margin: 0 0 .6rem; }
.ad-trash-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .8rem 1.2rem; border-top: 1px solid var(--line); }
.ad-trash-row strong { font-weight: 500; }
.ad-trash-row .ad-small { margin: .1rem 0 0; }
.ad-trash-acts { display: flex; gap: .4rem; }

/* Drive storage meter */
.ad-head-right { display: flex; align-items: center; gap: 1.2rem; flex-wrap: wrap; }
.ad-storage { min-width: 240px; display: grid; gap: .35rem; padding: .55rem .9rem; border: 1px solid var(--line); background: var(--field); }
.ad-st-top { display: flex; justify-content: space-between; align-items: center; gap: 1rem; font-size: .8rem; color: var(--muted); }
.ad-st-top span { display: inline-flex; align-items: center; gap: .35rem; }
.ad-st-top svg { width: 16px; height: 16px; color: var(--icon); }
.ad-st-top strong { font-weight: 500; color: var(--ink); }
.ad-st-bar { display: block; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.ad-st-bar i { display: block; height: 100%; width: 0; background: var(--icon); border-radius: 3px; transition: width .8s ease; }
.ad-storage[data-level="high"] .ad-st-bar i { background: #E3A04B; }
.ad-storage[data-level="full"] .ad-st-bar i { background: #E07A6E; }
.ad-storage small { font-size: .74rem; color: var(--muted); }
@media (max-width: 640px) { .ad-head-right { width: 100%; } .ad-storage { flex: 1; } }
