/* StickerBook — mobile-first, dark, solid colors only (PH convention) */
:root {
  --bg: #0d0d0f;
  --surface: #161618;
  --surface-2: #1e1e22;
  --border: #2a2a30;
  --text: #f2efe9;
  --muted: #9b978f;
  --accent: #b06ae8;      /* amethyst */
  --accent-2: #e8894a;    /* marigold */
  --danger: #e05555;
  --ok: #4fae6b;
  --radius: 14px;
  --font-body: 'Iowan Old Style', Palatino, Georgia, serif;
  --font-mono: 'SF Mono', ui-monospace, Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: var(--font-body); }
a { color: var(--accent-2); text-decoration: none; }
button { font-family: var(--font-mono); cursor: pointer; }

/* All page content lives in a stacking context BELOW the sticky header —
   without this, iOS promotes shadowed/rounded images (book hero cells) to
   their own compositing layers that can paint over the header mid-scroll. */
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px 60px; position: relative; z-index: 0; isolation: isolate; }

header.site {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg); z-index: 30;
  /* iOS Safari: a sticky header must be opaque, on its own compositing layer
     (translateZ) and isolated, or composited page content (images, shadows)
     paints OVER it during momentum scroll. Never add backdrop-filter or a
     transparent background here. Guarded by scripts/check-header.js. */
  transform: translateZ(0);
  isolation: isolate;
}
header.site .logo { font-size: 1.25rem; font-weight: 700; color: var(--text); }
header.site .logo span { color: var(--accent); }
header.site nav { display: flex; gap: 10px; align-items: center; }

.btn {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 14px; font-size: 0.85rem;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #14051f; font-weight: 700; }
.btn.warm { background: var(--accent-2); border-color: var(--accent-2); color: #251103; font-weight: 700; }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 0.75rem; }
.btn:disabled { opacity: 0.5; cursor: default; }

.hero { text-align: center; padding: 34px 10px 10px; }
.hero h1 { margin: 0 0 8px; font-size: 1.9rem; }
.hero p { color: var(--muted); margin: 0 auto 18px; max-width: 560px; }

/* Create panel */
.create-panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; margin: 16px 0 30px;
}
.create-panel textarea {
  width: 100%; min-height: 84px; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px; padding: 12px;
  font-family: var(--font-body); font-size: 1rem; resize: vertical;
}
.optrow { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.optrow label { font-family: var(--font-mono); font-size: 0.7rem; color: var(--muted); display: block; margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.06em; }
.optrow select {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font-family: var(--font-mono); font-size: 0.8rem;
}
.opt-col { flex: 1 1 150px; min-width: 150px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip {
  font-family: var(--font-mono); font-size: 0.72rem; padding: 6px 12px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2);
  color: var(--muted); cursor: pointer; user-select: none;
}
.chip.on { border-color: var(--accent); color: var(--text); background: #2a1f38; }
.create-actions { display: flex; align-items: center; gap: 12px; margin-top: 16px; flex-wrap: wrap; }

/* Photo upload */
.photo-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.photo-preview { position: relative; display: inline-block; }
.photo-preview img {
  height: 72px; max-width: 120px; object-fit: cover; border-radius: 8px;
  border: 1px solid var(--border); display: block;
}
.photo-remove {
  position: absolute; top: -8px; right: -8px; width: 22px; height: 22px;
  border-radius: 50%; border: 1px solid var(--border); background: var(--surface);
  color: var(--muted); font-size: 0.7rem; cursor: pointer; line-height: 1;
}
#photo-guide { margin-top: 12px; }
.photo-instructions {
  width: 100%; margin-top: 8px; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
  font-family: var(--font-mono); font-size: 0.8rem;
}
.hint { font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted); }

/* Gallery */
.tabs { display: flex; gap: 8px; margin: 10px 0 16px; }
.tab {
  font-family: var(--font-mono); font-size: 0.8rem; padding: 7px 16px; border-radius: 999px;
  border: 1px solid var(--border); background: transparent; color: var(--muted);
}
.tab.on { background: var(--surface-2); color: var(--text); border-color: var(--accent); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 14px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column; position: relative;
}
.card a.imglink { display: block; background: #fff; }
.card img { width: 100%; aspect-ratio: 3/4; object-fit: cover; display: block; }
.card .meta { padding: 10px 12px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card .title { font-size: 0.85rem; line-height: 1.25; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.card .gen { display: flex; align-items: center; justify-content: center; aspect-ratio: 3/4; color: var(--muted); font-family: var(--font-mono); font-size: 0.75rem; text-align: center; padding: 12px; }

.heart {
  display: inline-flex; align-items: center; gap: 5px; background: transparent;
  border: 1px solid var(--border); border-radius: 999px; padding: 4px 10px;
  color: var(--muted); font-family: var(--font-mono); font-size: 0.75rem;
}
.heart.on { color: #ff5f8f; border-color: #ff5f8f; }

/* Design page */
.design-view { display: flex; flex-direction: column; gap: 18px; margin-top: 20px; }
.design-view .sheet { background: #fff; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.design-view .sheet img { width: 100%; display: block; }
.design-side h1 { margin: 0 0 6px; font-size: 1.4rem; }
.design-side .prompt-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px; color: var(--muted); font-size: 0.9rem;
}
.design-actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 14px 0; align-items: center; }
.iterate-box textarea {
  width: 100%; min-height: 64px; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px; font-family: var(--font-body);
}
@media (min-width: 760px) {
  .design-view { flex-direction: row; }
  .design-view .sheet { flex: 1.1; align-self: flex-start; }
  .design-side { flex: 1; }
}

/* Modal */
.modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,0.72); z-index: 50;
  display: none; align-items: center; justify-content: center; padding: 16px;
}
.modal-bg.open { display: flex; }
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; width: 100%; max-width: 400px;
}
.modal h3 { margin: 0 0 12px; }
.modal input {
  width: 100%; background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; font-size: 0.95rem;
}
.modal .row { display: flex; gap: 10px; margin-top: 8px; }
.modal .note { font-size: 0.78rem; color: var(--muted); font-family: var(--font-mono); }
.modal .err { color: var(--danger); font-size: 0.8rem; min-height: 1.1em; margin: 4px 0; }

/* Admin */
.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin: 18px 0; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px; }
.stat .n { font-size: 1.6rem; font-weight: 700; color: var(--accent-2); font-family: var(--font-mono); }
.stat .l { font-size: 0.7rem; color: var(--muted); font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.05em; }
table.admin { width: 100%; border-collapse: collapse; font-size: 0.8rem; font-family: var(--font-mono); }
table.admin th, table.admin td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--border); }
table.admin th { color: var(--muted); font-weight: 400; text-transform: uppercase; font-size: 0.65rem; }
.md-doc { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; line-height: 1.55; }
.md-doc h1, .md-doc h2, .md-doc h3 { color: var(--accent-2); }
.md-doc code { font-family: var(--font-mono); font-size: 0.85em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.md-doc table { border-collapse: collapse; font-size: 0.85rem; }
.md-doc td, .md-doc th { border: 1px solid var(--border); padding: 6px 9px; }

/* Footer */
footer.ph {
  margin-top: 50px; padding: 24px 16px; border-top: 1px solid var(--border);
  text-align: center; color: var(--muted); font-family: var(--font-mono); font-size: 0.72rem; line-height: 1.7;
}
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--surface-2); border: 1px solid var(--accent); color: var(--text);
  border-radius: 10px; padding: 10px 18px; font-family: var(--font-mono); font-size: 0.8rem;
  z-index: 60; display: none;
}
.badge { font-family: var(--font-mono); font-size: 0.65rem; padding: 3px 8px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); }
.badge.ok { color: var(--ok); border-color: var(--ok); }
.badge.bad { color: var(--danger); border-color: var(--danger); }
.spin { animation: spin 1.2s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Discovery rails ────────────────────────────────────────────────────────
   Horizontal, scroll-snapping, mobile-first card rows (promo.js). The same
   markup works on the marketing homepage, the signed-in home, browse pages
   and detail pages — cards are fixed-width so the rhythm never changes. */
.rail { margin: 26px 0; }
.rail-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.rail-title { margin: 0; font-size: 1.05rem; font-weight: 700; }
.rail-sub { margin: 3px 0 0; font-family: var(--font-mono); font-size: 0.7rem; color: var(--muted); }
.rail-more { font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted); white-space: nowrap; }
.rail-more:hover { color: var(--accent); }
.rail-scroll {
  display: flex; gap: 12px; overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch;
  /* Negative margin + matching padding lets cards bleed to the screen edge on
     phones, which is the cue that the row scrolls. */
  padding: 4px 16px 12px; margin: -4px -16px 0;
  scrollbar-width: thin;
}
.rail-scroll::-webkit-scrollbar { height: 6px; }
.rail-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.rail-empty { padding: 10px 0; }
.railcard {
  flex: 0 0 auto; width: 148px; scroll-snap-align: start;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column;
}
.railcard .railcard-img { display: block; background: #fff; }
.railcard img { width: 100%; aspect-ratio: 3/4; object-fit: cover; display: block; }
.railcard .railcard-img.gen {
  aspect-ratio: 3/4; display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); color: var(--muted); font-size: 1.1rem;
}
.railcard-meta { padding: 8px 10px; display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.railcard-title {
  font-size: 0.76rem; line-height: 1.25; color: var(--text); overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.railcard-count { font-family: var(--font-mono); font-size: 0.65rem; color: var(--muted); }
.railcard.skeleton { height: 232px; background: var(--surface-2); border-color: transparent; animation: pulse 1.3s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 0.45; } 50% { opacity: 0.8; } }
@media (min-width: 700px) {
  .railcard { width: 178px; }
  .rail-scroll { padding-left: 4px; padding-right: 4px; margin-left: -4px; margin-right: -4px; }
  .railcard.skeleton { height: 272px; }
}

/* Category chips — same horizontal-scroll gesture as the rails */
.cat-strip {
  display: flex; gap: 8px; overflow-x: auto; -webkit-overflow-scrolling: touch;
  padding: 4px 16px 10px; margin: 0 -16px; scrollbar-width: none;
}
.cat-strip::-webkit-scrollbar { display: none; }
.cat-chip {
  flex: 0 0 auto; font-family: var(--font-mono); font-size: 0.74rem;
  padding: 7px 13px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--muted); white-space: nowrap;
}
.cat-chip:hover, .cat-chip.on { border-color: var(--accent); color: var(--text); background: var(--surface-2); }
.cat-n { color: var(--muted); opacity: 0.7; }
@media (min-width: 700px) { .cat-strip { padding-left: 0; padding-right: 0; margin: 0; flex-wrap: wrap; } }

/* ── Marketing homepage (logged out) ───────────────────────────────────────*/
.hero-big { text-align: center; padding: 40px 8px 6px; }
.hero-big h1 { margin: 0 0 10px; font-size: 2.1rem; line-height: 1.15; }
.hero-big .lede { color: var(--muted); max-width: 580px; margin: 0 auto 18px; font-size: 1.02rem; line-height: 1.5; }
.hero-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.hero-actions .btn { padding: 11px 20px; font-size: 0.9rem; }
.hero-trust { margin-top: 14px; font-family: var(--font-mono); font-size: 0.7rem; color: var(--muted); }
@media (min-width: 700px) { .hero-big h1 { font-size: 2.7rem; } }

.steps { display: grid; grid-template-columns: 1fr; gap: 12px; margin: 30px 0; }
.step { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.step .n { font-family: var(--font-mono); font-size: 0.68rem; color: var(--accent); letter-spacing: 0.1em; }
.step h3 { margin: 6px 0 6px; font-size: 1rem; }
.step p { margin: 0; color: var(--muted); font-size: 0.87rem; line-height: 1.5; }
@media (min-width: 700px) { .steps { grid-template-columns: repeat(3, 1fr); } }

.cta-band {
  background: var(--surface); border: 1px solid var(--accent); border-radius: var(--radius);
  padding: 22px 20px; text-align: center; margin: 34px 0;
}
.cta-band h2 { margin: 0 0 8px; font-size: 1.3rem; }
.cta-band p { margin: 0 0 16px; color: var(--muted); font-size: 0.92rem; }

.faq { margin: 30px 0; }
.faq h2 { font-size: 1.15rem; margin: 0 0 12px; }
.faq details {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; margin-bottom: 8px;
}
.faq summary { cursor: pointer; font-size: 0.92rem; }
.faq details p { color: var(--muted); font-size: 0.87rem; line-height: 1.55; margin: 8px 0 0; }

.section-sep { border: 0; border-top: 1px solid var(--border); margin: 34px 0; }

/* ── Share modal extras ────────────────────────────────────────────────────*/
.share-linkrow { display: flex; gap: 8px; align-items: center; }
.share-linkrow input {
  flex: 1; min-width: 0; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 10px;
  font-family: var(--font-mono); font-size: 0.72rem; margin: 0;
}
.share-targets { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 4px; }
.share-targets .btn { text-decoration: none; }

/* ── Rich footer ───────────────────────────────────────────────────────────*/
footer.promo-footer { text-align: left; }
.promo-footer .pf-cta {
  display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: space-between;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 28px; max-width: 1080px; margin-left: auto; margin-right: auto;
}
.promo-footer .pf-cta > div:first-child { flex: 1 1 240px; min-width: 0; }
.promo-footer .pf-cta strong { display: block; color: var(--text); font-size: 1rem; margin-bottom: 3px; }
.promo-footer .pf-cta .hint { display: block; line-height: 1.5; }
.promo-footer .pf-cta-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.promo-footer .pf-cols {
  display: grid; grid-template-columns: 1fr; gap: 22px;
  max-width: 1080px; margin: 0 auto 24px;
}
.promo-footer .pf-col h4 {
  margin: 0 0 8px; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text);
}
.promo-footer .pf-col a { display: block; color: var(--muted); padding: 3px 0; font-size: 0.76rem; }
.promo-footer .pf-col a:hover { color: var(--accent); }
.promo-footer .pf-base { text-align: center; border-top: 1px solid var(--border); padding-top: 16px; }
@media (min-width: 700px) { .promo-footer .pf-cols { grid-template-columns: repeat(3, 1fr); } }

/* Selects size to their longest option by default, which overflowed the
   create panel (and forced a horizontal scroll) on narrow phones. Let the
   flex column decide the width instead. */
.optrow select { width: 100%; max-width: 100%; }
