/* ProgPic — "Polaroids & craft / scrapbook" theme.
   Warm cream paper, kraft tan, sage + faded teal, dusty coral accents.
   Handwritten display type (Caveat / Patrick Hand) over Inter for body.
   Mobile-first: bottom nav on phones, top tabs on desktop. */

:root {
  /* paper + ink */
  --paper: #f6efe1;
  --paper-2: #efe5d2;
  --kraft: #cbab7e;
  --kraft-dark: #b08e5f;
  --card: #fffdf7;        /* polaroid white */
  --ink: #38322a;         /* warm near-black */
  --ink-soft: #6f6557;
  --line: #d9cab0;

  /* accents */
  --coral: #d96b5b;       /* dusty coral / red */
  --coral-dark: #c2543f;
  --sage: #8aa17c;
  --sage-dark: #6e8762;
  --teal: #5f9ea0;        /* faded teal */
  --teal-dark: #4d8587;
  --tape: rgba(224, 211, 168, 0.72);
  --tape-coral: rgba(217, 107, 91, 0.32);

  --shadow-paper: 0 1px 2px rgba(56, 50, 42, 0.12),
                  0 10px 22px rgba(56, 50, 42, 0.16);
  --shadow-soft: 0 6px 16px rgba(56, 50, 42, 0.12);

  --font-hand: "Caveat", "Patrick Hand", cursive;
  --font-marker: "Patrick Hand", "Caveat", cursive;
  --font-body: "Inter", "Space Grotesk", system-ui, sans-serif;

  /* mobile bottom-nav height incl. safe area */
  --bnav-h: 66px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

/* The `hidden` attribute must win over element display rules (e.g. the
   camera sheet/overlays use display:flex, which would otherwise override it). */
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  background-color: var(--paper);
  background-image:
    radial-gradient(circle at 12% 8%, rgba(255, 250, 236, 0.9), transparent 38%),
    radial-gradient(circle at 88% 0%, rgba(207, 171, 126, 0.18), transparent 34%),
    radial-gradient(circle at 50% 120%, rgba(138, 161, 124, 0.14), transparent 46%),
    linear-gradient(180deg, #f8f2e6 0%, #f3eadb 60%, #efe4d0 100%);
  overflow-x: hidden;
}

/* paper grain overlay */
.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
  background-image:
    radial-gradient(circle at 25% 30%, rgba(120, 100, 70, 0.05) 0 1px, transparent 1px),
    radial-gradient(circle at 70% 65%, rgba(120, 100, 70, 0.04) 0 1px, transparent 1px),
    radial-gradient(circle at 45% 85%, rgba(120, 100, 70, 0.05) 0 1px, transparent 1px);
  background-size: 7px 7px, 11px 11px, 9px 9px;
  mix-blend-mode: multiply;
}
.glow { display: none; }

.page {
  position: relative;
  z-index: 1;
  max-width: 1060px;
  margin: 0 auto;
  /* leave room for the fixed mobile bottom nav */
  padding: 1.1rem clamp(1rem, 4vw, 2.5rem) calc(var(--bnav-h) + var(--safe-b) + 1.5rem);
}

/* ---- topbar ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
  margin-bottom: 1.2rem;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--ink);
  font-family: var(--font-marker);
  font-weight: 400;
  font-size: 1.5rem;
}
.brand-badge {
  display: grid;
  place-items: center;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 0.5rem 0.7rem 0.55rem 0.65rem;
  background: var(--coral);
  color: var(--card);
  font-family: var(--font-marker);
  font-size: 1.2rem;
  transform: rotate(-5deg);
  box-shadow: var(--shadow-soft);
}
.back-link {
  color: var(--ink-soft);
  text-decoration: none;
  font-family: var(--font-body);
  font-size: 0.9rem;
  border-bottom: 1.5px dashed var(--kraft-dark);
  padding-bottom: 1px;
}
.back-link:hover { color: var(--coral-dark); border-color: var(--coral); }

/* ---- hero (home only) ---- */
.hero { margin-bottom: 1.4rem; }
.eyebrow {
  font-family: var(--font-marker);
  font-size: 1.05rem;
  letter-spacing: 0.06em;
  color: var(--teal-dark);
  margin: 0 0 0.2rem;
  transform: rotate(-1.5deg);
}
.hero h1 {
  font-family: var(--font-hand);
  font-weight: 700;
  font-size: clamp(2.6rem, 11vw, 4.6rem);
  line-height: 0.92;
  margin: 0 0 0.5rem;
  color: var(--ink);
}
.hero h1 span {
  color: var(--coral);
  position: relative;
  display: inline-block;
  transform: rotate(-2deg);
}
.hero h1 span::after {
  content: "";
  position: absolute;
  left: -2%;
  right: -2%;
  bottom: 0.08em;
  height: 0.12em;
  background: var(--sage);
  border-radius: 999px;
  transform: rotate(-1deg);
  opacity: 0.85;
}
.lead {
  max-width: 48ch;
  color: var(--ink-soft);
  font-size: 1.02rem;
  line-height: 1.6;
  margin: 0;
}
.home-count {
  margin: 0.9rem 0 0;
  font-family: var(--font-marker);
  font-size: 1.15rem;
  color: var(--coral-dark);
  transform: rotate(-0.8deg);
}

/* ---- home flow cards ---- */
.home-flows {
  display: grid;
  gap: 1.3rem;
  margin-top: 0.4rem;
}
.flow-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  text-align: left;
  width: 100%;
  border: 2px solid var(--line);
  border-radius: 1rem 1.2rem 1rem 1.15rem;
  background: var(--card);
  padding: 1.4rem 1.3rem 1.2rem;
  cursor: pointer;
  box-shadow: var(--shadow-paper);
  position: relative;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}
.flow-card::before {
  /* washi tape pinning the card */
  content: "";
  position: absolute;
  top: -11px;
  left: 1.8rem;
  width: 84px;
  height: 24px;
  transform: rotate(-3deg);
  background: var(--tape);
  box-shadow: 0 1px 3px rgba(56, 50, 42, 0.16);
}
.flow-card--gif::before { background: var(--tape-coral); transform: rotate(3deg); left: auto; right: 1.8rem; }
.flow-card:hover { transform: translateY(-3px); box-shadow: 0 16px 34px rgba(56, 50, 42, 0.22); border-color: var(--coral); }
.flow-card:focus-visible { outline: 3px solid var(--teal); outline-offset: 3px; }
.flow-icon {
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background: var(--sage);
  color: var(--card);
  font-size: 1.5rem;
  margin-bottom: 0.4rem;
  box-shadow: var(--shadow-soft);
  transform: rotate(-4deg);
}
.flow-card--gif .flow-icon { background: var(--coral); }
.flow-title {
  font-family: var(--font-hand);
  font-weight: 700;
  font-size: 1.9rem;
  line-height: 1;
  color: var(--ink);
}
.flow-sub {
  color: var(--ink-soft);
  font-size: 0.98rem;
  line-height: 1.45;
}
.flow-go {
  margin-top: 0.5rem;
  font-family: var(--font-body);
  font-weight: 700;
  color: var(--coral-dark);
  font-size: 0.95rem;
}

/* ---- desktop tabs (paper tags) ---- */
.tabs {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 1.6rem;
  flex-wrap: wrap;
}
.tab {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.55rem 1rem;
  border: 2px solid var(--line);
  border-radius: 0.7rem 0.9rem 0.7rem 0.85rem;
  background: var(--card);
  color: var(--ink-soft);
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  transition: transform 0.15s ease, color 0.15s ease,
              border-color 0.15s ease, background 0.15s ease;
}
.tab:nth-child(1) { transform: rotate(-1.5deg); }
.tab:nth-child(2) { transform: rotate(1deg); }
.tab:nth-child(3) { transform: rotate(-0.5deg); }
.tab:nth-child(4) { transform: rotate(1.4deg); }
.tab:hover { transform: translateY(-2px) rotate(0deg); color: var(--ink); }
.tab.is-active {
  color: var(--card);
  background: var(--coral);
  border-color: var(--coral-dark);
}
.tab.is-active:hover { color: var(--card); }
.tab:focus-visible,
.tab.is-active:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }

/* ---- panels ---- */
.panel { display: none; animation: fade 0.3s ease; }
.panel.is-active { display: block; }
@keyframes fade {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.panel-head { margin-bottom: 1.3rem; }
.panel-head.compact { margin-bottom: 0.9rem; }
.panel-head h2 {
  font-family: var(--font-hand);
  font-weight: 700;
  font-size: clamp(1.9rem, 6vw, 2.6rem);
  line-height: 1;
  margin: 0 0 0.3rem;
  color: var(--ink);
}
.panel-head.compact h2 { font-size: clamp(1.7rem, 6vw, 2.2rem); }
.panel-head p {
  margin: 0;
  color: var(--ink-soft);
  max-width: 58ch;
  line-height: 1.5;
  font-size: 0.96rem;
}

/* ---- dropzone (kraft paper pocket) ---- */
.dropzone {
  display: block;
  position: relative;
  border: 2.5px dashed var(--kraft-dark);
  border-radius: 1rem;
  background:
    repeating-linear-gradient(45deg,
      rgba(176, 142, 95, 0.06) 0 10px,
      rgba(176, 142, 95, 0) 10px 20px),
    var(--paper-2);
  padding: 2rem 1.3rem;
  cursor: pointer;
  text-align: center;
  box-shadow: inset 0 2px 8px rgba(56, 50, 42, 0.05);
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}
.dropzone::before {
  content: "";
  position: absolute;
  top: -10px;
  left: 50%;
  width: 110px;
  height: 26px;
  transform: translateX(-50%) rotate(-2deg);
  background: var(--tape-coral);
  border-left: 1px dashed rgba(255,255,255,0.35);
  border-right: 1px dashed rgba(255,255,255,0.35);
  box-shadow: 0 2px 4px rgba(56, 50, 42, 0.1);
}
.dropzone:hover,
.dropzone.is-over {
  border-color: var(--coral);
  background-color: #f7eddb;
  transform: translateY(-2px);
}
.dropzone:focus-within { outline: 3px solid var(--teal); outline-offset: 3px; }
.dropzone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
}
.dropzone-icon {
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background: var(--sage);
  color: var(--card);
  font-size: 2rem;
  font-weight: 400;
  font-family: var(--font-marker);
  margin-bottom: 0.4rem;
  box-shadow: var(--shadow-soft);
  transform: rotate(-4deg);
}
.dropzone-title {
  font-family: var(--font-marker);
  font-weight: 400;
  font-size: 1.35rem;
  color: var(--ink);
}
.dropzone-hint {
  color: var(--ink-soft);
  font-family: var(--font-body);
  font-size: 0.82rem;
}

/* ---- timeline toolbar ---- */
.timeline-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 1.3rem 0 0.6rem;
  flex-wrap: wrap;
  gap: 0.6rem;
}
.count-chip {
  font-family: var(--font-marker);
  font-size: 1.05rem;
  color: var(--ink-soft);
}
.count-chip strong { color: var(--coral-dark); font-size: 1.3rem; }
.toolbar-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ---- thumbnails as polaroids on a corkboard ---- */
.thumb-grid {
  list-style: none;
  margin: 0;
  padding: 0.6rem 0.3rem 0.3rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 1.4rem 1rem;
}
.thumb {
  position: relative;
  background: var(--card);
  padding: 0.6rem 0.6rem 1.9rem;
  border-radius: 3px;
  box-shadow: var(--shadow-paper);
  cursor: grab;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.thumb:nth-child(4n+1) { transform: rotate(-3deg); }
.thumb:nth-child(4n+2) { transform: rotate(2deg); }
.thumb:nth-child(4n+3) { transform: rotate(-1.5deg); }
.thumb:nth-child(4n+4) { transform: rotate(2.6deg); }
.thumb:hover {
  transform: rotate(0deg) translateY(-4px) scale(1.03);
  box-shadow: 0 14px 30px rgba(56, 50, 42, 0.24);
  z-index: 3;
}
.thumb::before {
  content: "";
  position: absolute;
  top: -9px;
  left: 50%;
  width: 58px;
  height: 20px;
  transform: translateX(-50%) rotate(-3deg);
  background: var(--tape);
  box-shadow: 0 1px 3px rgba(56, 50, 42, 0.18);
  z-index: 4;
}
.thumb:nth-child(even)::before { transform: translateX(-50%) rotate(4deg); background: var(--tape-coral); }
.thumb.dragging { opacity: 0.55; transform: rotate(4deg) scale(1.05); }
.thumb img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  background: #e8e0d0;
  filter: saturate(0.95) contrast(1.02);
}
.thumb-index {
  position: absolute;
  bottom: 0.35rem;
  left: 0;
  right: 0;
  text-align: center;
  color: var(--ink-soft);
  font-family: var(--font-hand);
  font-weight: 700;
  font-size: 1.25rem;
  line-height: 1;
}
.thumb-index::before { content: "#"; opacity: 0.6; }
.thumb-controls {
  position: absolute;
  inset: 0.6rem 0.6rem auto;
  display: flex;
  gap: 0.3rem;
  /* on touch devices controls are always shown; on hover devices they fade in */
  opacity: 1;
  transition: opacity 0.15s ease;
}
@media (hover: hover) {
  .thumb-controls { opacity: 0; }
  .thumb:hover .thumb-controls,
  .thumb:focus-within .thumb-controls { opacity: 1; }
}
.thumb-controls button {
  flex: 1;
  min-height: 34px;
  border: 1.5px solid rgba(255, 255, 255, 0.6);
  border-radius: 0.4rem;
  background: rgba(56, 50, 42, 0.74);
  color: #fff;
  padding: 0.2rem;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}
.thumb-controls button:hover { background: var(--coral); }
.thumb-controls button:focus-visible { outline: 2px solid var(--teal); outline-offset: 1px; }

.empty-note {
  color: var(--ink-soft);
  font-family: var(--font-marker);
  font-size: 1.15rem;
  margin-top: 1rem;
  transform: rotate(-0.6deg);
}

/* ---- buttons / fields shared ---- */
.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 44px;
  border: 2px solid var(--coral-dark);
  border-radius: 0.7rem 0.85rem 0.7rem 0.8rem;
  padding: 0.7rem 1.3rem;
  background: var(--coral);
  color: var(--card);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  text-decoration: none;
  box-shadow: var(--shadow-soft);
  transition: transform 0.15s ease, filter 0.15s ease, background 0.15s ease;
}
.primary-btn:hover { transform: translateY(-2px) rotate(-0.6deg); filter: brightness(1.04); }
.primary-btn:active { transform: translateY(0); }
.primary-btn:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }
.primary-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  filter: grayscale(0.3);
}
.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 2px dashed var(--kraft-dark);
  border-radius: 0.7rem 0.85rem 0.7rem 0.8rem;
  padding: 0.6rem 1.1rem;
  background: var(--card);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  text-decoration: none;
  box-shadow: var(--shadow-soft);
  transition: border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.ghost-btn:hover { border-color: var(--coral); color: var(--coral-dark); transform: translateY(-1px); }
.ghost-btn:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }
.ghost-btn.full { width: 100%; }

.field { margin-bottom: 1.1rem; }
.field label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.45rem;
  color: var(--ink);
}
.field label span {
  font-family: var(--font-hand);
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--teal-dark);
}
.field select,
.field input[type="range"] { width: 100%; }
.field select {
  appearance: none;
  min-height: 44px;
  border: 2px solid var(--line);
  border-radius: 0.6rem;
  background-color: var(--card);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23b08e5f' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
  color: var(--ink);
  padding: 0.7rem 2.2rem 0.7rem 0.9rem;
  font-family: var(--font-body);
  font-size: 0.95rem;
  cursor: pointer;
}
.field select:focus-visible { outline: 3px solid var(--teal); outline-offset: 1px; border-color: var(--teal); }

input[type="range"] {
  accent-color: var(--coral);
  height: 1.6rem;
  cursor: pointer;
}
input[type="range"]:focus-visible { outline: 3px solid var(--teal); outline-offset: 3px; border-radius: 4px; }

.switch {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 32px;
  font-size: 0.92rem;
  color: var(--ink);
  cursor: pointer;
}
.switch input {
  width: 1.2rem;
  height: 1.2rem;
  accent-color: var(--sage-dark);
}
.switch input:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.switch.standalone { margin: 0.2rem 0 1.2rem; }

/* ============================================================
   CAMERA / FLOW B — guide chooser, then immersive camera
   ============================================================ */
.cam-panel.is-active { display: block; }

/* ---- step 1: guide chooser ---- */
.guide-pick {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  max-width: 30rem;
}
.guide-option {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  text-align: left;
  width: 100%;
  padding: 1rem 1.1rem;
  border: 2px solid var(--line);
  border-radius: 1rem;
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.guide-option:hover { transform: translateY(-2px); border-color: var(--coral); }
.guide-option:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }
.guide-option--primary {
  background: var(--coral);
  border-color: var(--coral-dark);
  color: var(--card);
}
.guide-option--subtle { background: var(--paper-2); box-shadow: none; }
.guide-opt-icon {
  display: grid;
  place-items: center;
  width: 2.8rem;
  height: 2.8rem;
  flex: 0 0 auto;
  border-radius: 0.8rem;
  background: rgba(255, 255, 255, 0.22);
  font-size: 1.5rem;
}
.guide-option:not(.guide-option--primary) .guide-opt-icon {
  background: var(--paper-2);
  color: var(--coral-dark);
}
.guide-opt-text { display: flex; flex-direction: column; gap: 0.1rem; }
.guide-opt-title { font-family: var(--font-marker); font-size: 1.2rem; line-height: 1.1; }
.guide-opt-sub { font-size: 0.85rem; opacity: 0.85; }

/* ---- step 2: the camera stage (immersive when active) ---- */
.cam-stage { position: relative; }

.viewfinder {
  position: relative;
  width: 100%;
  max-width: 26rem;
  aspect-ratio: 3 / 4;
  margin: 0 auto;
  border-radius: 10px;
  overflow: hidden;
  background: #2a2620;
  box-shadow: var(--shadow-paper);
}
.viewfinder video,
.ghost-overlay,
.capture-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.ghost-overlay {
  pointer-events: none;
  opacity: 0.45;
  z-index: 1;
}
.capture-preview { z-index: 2; background: #2a2620; }
.viewfinder-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.3) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.3) 1px, transparent 1px);
  background-size: 33.33% 33.33%;
  opacity: 0.4;
}
.cam-error {
  position: absolute;
  inset: auto 0 4.5rem 0;
  padding: 0.8rem 1rem;
  background: var(--coral);
  color: var(--card);
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 6;
}
.viewfinder.flash::before {
  content: "";
  position: absolute;
  inset: 0;
  background: #fff;
  z-index: 8;
  animation: flash 0.22s ease;
}
@keyframes flash {
  from { opacity: 0.95; }
  to { opacity: 0; }
}

/* overlay control bars float over the feed */
.cam-overlay {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  z-index: 5;
}
.cam-overlay--top {
  top: 0;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 0.7rem) 0.8rem 1.4rem;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.45), transparent);
}
.cam-overlay--bottom {
  bottom: 0;
  justify-content: center;
  gap: 1.8rem;
  padding: 1.6rem 1rem calc(env(safe-area-inset-bottom, 0px) + 1.2rem);
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.5), transparent);
}
.cam-icon-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  color: #fff;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}
.cam-icon-btn:hover { background: rgba(255, 255, 255, 0.3); }
.cam-icon-btn:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.cam-icon-btn.dark { background: var(--paper-2); color: var(--ink); }
.cam-corner-spacer { width: 44px; flex: 0 0 auto; }
.cam-badge {
  font-family: var(--font-marker);
  font-size: 0.95rem;
  color: #fff;
  background: rgba(0, 0, 0, 0.35);
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
}

.shutter {
  width: 74px;
  height: 74px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.85);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  transition: transform 0.12s ease;
}
.shutter:hover { transform: scale(1.04); }
.shutter:active { transform: scale(0.92); }
.shutter:focus-visible { outline: 3px solid var(--teal); outline-offset: 4px; }

/* capture-result buttons (only shown after a snap) */
.result-row { gap: 0.7rem; flex-wrap: wrap; }
.result-btn {
  flex: 1 1 28%;
  min-width: 6rem;
  text-align: center;
  padding: 0.75rem 0.8rem;
  border-radius: 999px;
  border: 1.5px solid rgba(255, 255, 255, 0.55);
  background: rgba(0, 0, 0, 0.4);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  color: #fff;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
}
.result-btn:hover { background: rgba(0, 0, 0, 0.55); }
.result-btn:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.result-btn--primary { background: var(--coral); border-color: var(--coral-dark); }
.result-btn--primary:hover { background: var(--coral-dark); }

/* cogwheel settings as a bottom sheet over the camera */
.cam-sheet {
  position: absolute;
  inset: 0;
  z-index: 9;
  display: flex;
  align-items: flex-end;
  background: rgba(0, 0, 0, 0.45);
}
.cam-sheet-card {
  width: 100%;
  max-height: 85%;
  overflow: auto;
  background: var(--card);
  border-radius: 1.2rem 1.2rem 0 0;
  padding: 1rem 1.1rem calc(env(safe-area-inset-bottom, 0px) + 1.2rem);
  box-shadow: 0 -12px 30px rgba(0, 0, 0, 0.3);
  animation: sheet-up 0.22s ease;
}
@keyframes sheet-up {
  from { transform: translateY(18px); opacity: 0.4; }
  to { transform: translateY(0); opacity: 1; }
}
.cam-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.8rem;
  font-family: var(--font-marker);
  font-size: 1.3rem;
}
.cam-sheet-card .ghost-btn.full { margin-bottom: 1rem; }
.toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  padding: 0.7rem 0.8rem;
  background: var(--paper-2);
  border-radius: 0.6rem;
  border: 1.5px dashed var(--line);
}

/* ---- immersive mode: camera fills the screen ---- */
body.cam-immersive { overflow: hidden; }
body.cam-immersive .bottom-nav { display: none; }
body.cam-immersive #cam-stage {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* Fill the stage but keep the source's aspect ratio (--vf-r, set in JS), so the
   live feed and ghost overlay share one scale and line up. The width calc is a
   contain-fit: whichever of full width or (full height x ratio) is smaller, so
   the box never overflows and never distorts. The black stage letterboxes it. */
body.cam-immersive .viewfinder {
  width: min(100%, calc(100vh * var(--vf-r, 0.75)));
  width: min(100%, calc(100dvh * var(--vf-r, 0.75)));
  height: auto;
  aspect-ratio: var(--vf-r, 0.75);
  max-width: 100%;
  margin: 0;
  border-radius: 0;
}

/* ============================================================
   CREATE GIF
   ============================================================ */
.create-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.4rem;
  align-items: start;
}
.settings {
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 0.9rem;
  padding: 1.3rem;
  box-shadow: var(--shadow-soft);
}
.build-btn { width: 100%; margin-top: 0.4rem; }
.progress { margin-top: 1rem; }
.progress-bar {
  height: 0.55rem;
  border-radius: 999px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  overflow: hidden;
}
.progress-bar span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--sage), var(--teal));
  transition: width 0.1s linear;
}
.progress-label {
  display: block;
  margin-top: 0.5rem;
  font-family: var(--font-marker);
  font-size: 0.95rem;
  color: var(--ink-soft);
}

/* result presented as a freshly developed polaroid */
.result {
  background:
    repeating-linear-gradient(45deg,
      rgba(176, 142, 95, 0.05) 0 12px,
      rgba(176, 142, 95, 0) 12px 24px),
    var(--paper-2);
  border: 1.5px dashed var(--line);
  border-radius: 0.9rem;
  padding: 1.5rem;
  min-height: 16rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.result-empty { text-align: center; color: var(--ink-soft); }
.result-empty p { font-family: var(--font-marker); font-size: 1.2rem; margin: 0; }
.result-icon {
  display: grid;
  place-items: center;
  width: 3.4rem;
  height: 3.4rem;
  margin: 0 auto 0.8rem;
  border-radius: 50%;
  border: 2px dashed var(--kraft-dark);
  font-size: 1.3rem;
  color: var(--coral);
}
.result-ready {
  background: var(--card);
  padding: 0.9rem 0.9rem 0.4rem;
  border-radius: 3px;
  box-shadow: var(--shadow-paper);
  position: relative;
}
.result-ready::before {
  content: "";
  position: absolute;
  top: -11px;
  left: 50%;
  width: 90px;
  height: 24px;
  transform: translateX(-50%) rotate(2.5deg);
  background: var(--tape-coral);
  box-shadow: 0 1px 3px rgba(56, 50, 42, 0.16);
}
.result-ready img {
  width: 100%;
  background: #e8e0d0;
  display: block;
  margin-bottom: 0.6rem;
}
.result-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: stretch;
  padding-bottom: 0.6rem;
}
.result-meta {
  font-family: var(--font-marker);
  font-size: 0.95rem;
  color: var(--ink-soft);
  text-align: center;
}

.result-log {
  margin-top: 0.5rem;
  border-top: 1px dashed var(--line);
  padding-top: 0.5rem;
}
.result-log summary {
  cursor: pointer;
  font-family: var(--font-marker);
  font-size: 0.9rem;
  color: var(--ink-soft);
}
.log-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0.5rem 0;
}
.log-copied {
  font-size: 0.85rem;
  color: var(--coral-dark, var(--coral));
}
#log-text {
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 240px;
  overflow: auto;
  margin: 0;
  padding: 0.6rem;
  background: #2a2620;
  color: #e8e0d0;
  border-radius: 6px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.72rem;
  line-height: 1.4;
  -webkit-overflow-scrolling: touch;
}

/* ---- footer ---- */
.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 2.4rem;
  padding-top: 1.4rem;
  border-top: 2px dashed var(--line);
  color: var(--ink-soft);
  font-size: 0.9rem;
  flex-wrap: wrap;
  gap: 0.8rem;
}
.footer span { font-family: var(--font-marker); font-size: 1rem; }
.chip {
  border: 2px solid var(--line);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  text-decoration: none;
  color: var(--ink);
  background: var(--card);
  box-shadow: var(--shadow-soft);
}
.chip:hover { border-color: var(--sage); color: var(--sage-dark); }

/* ============================================================
   MOBILE BOTTOM NAV (sticky), hidden on desktop
   ============================================================ */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: flex;
  justify-content: space-around;
  align-items: stretch;
  height: calc(var(--bnav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: var(--card);
  border-top: 2px solid var(--line);
  box-shadow: 0 -6px 18px rgba(56, 50, 42, 0.12);
}
.bnav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  min-height: 44px;
  border: none;
  background: none;
  color: var(--ink-soft);
  cursor: pointer;
  font-family: var(--font-body);
  padding: 0.3rem 0.2rem;
}
.bnav-icon { font-size: 1.4rem; line-height: 1; }
.bnav-label { font-size: 0.72rem; font-weight: 600; }
.bnav-btn.is-active { color: var(--coral-dark); }
.bnav-btn.is-active .bnav-icon { transform: translateY(-1px) scale(1.08); }
.bnav-btn:focus-visible { outline: 3px solid var(--teal); outline-offset: -3px; border-radius: 0.5rem; }

/* ============================================================
   DESKTOP — top tabs, no bottom nav, two-column layouts
   ============================================================ */
@media (min-width: 761px) {
  :root { --bnav-h: 0px; --safe-b: 0px; }
  .page { padding-bottom: 4rem; }
  .bottom-nav { display: none; }
  .home-flows { grid-template-columns: 1fr 1fr; }
  .create-grid { grid-template-columns: 1fr 1.05fr; }
  .result-ready { transform: rotate(-1.5deg); }
}

/* hide desktop tabs on mobile, show bottom nav */
@media (max-width: 760px) {
  .tabs { display: none; }
  .back-link { font-size: 0.82rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; }
  .thumb, .tab, .primary-btn, .ghost-btn, .flow-card, .shutter { transition: none; }
}
