/* Instant Cam - styles. One pastel look: mint camera body, lilac-white paper. */
@font-face {
  font-family: "MyAlphabet";
  src: url("fonts/MyAlphabet.ttf") format("truetype");
  font-display: swap;
}

:root {
  --mint: #CFEBDD;
  --mint-deep: #8FCCB1;
  --pink: #F9CCD8;
  --pink-deep: #EE9BB4;
  --butter: #FFE8A6;
  --lilac: #E5DBF6;
  --paper: #FFFDFC;
  --bg: #F6F2F7;
  --ink: #3A2E41;
  --muted: #7B6E84;
  --line: #E7DEEB;
  --danger: #C23E5B;
  --font: ui-rounded, "SF Pro Rounded", "Hiragino Maru Gothic ProN", "Nunito", "Quicksand", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--mint);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 3px solid var(--pink-deep); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.screen {
  position: fixed; inset: 0;
  display: none; flex-direction: column;
  padding-left: var(--safe-l); padding-right: var(--safe-r);
}
body[data-screen="camera"] #camera,
body[data-screen="gallery"] #gallery,
body[data-screen="settings"] #settings { display: flex; }

/* ---------- shared bits ---------- */
.icon-btn {
  width: 46px; height: 46px; flex: none;
  border-radius: 50%; border: 0;
  background: rgba(255, 255, 255, .62);
  display: grid; place-items: center;
}
.icon-btn.big { width: 56px; height: 56px; }
.icon-btn.big svg { width: 28px; height: 28px; }
.icon-btn.dark { background: rgba(255, 255, 255, .14); color: #fff; }
.icon-btn:active { transform: scale(.94); }

.pill {
  height: 34px; padding: 0 12px; border-radius: 999px; border: 0;
  font-size: 13px; font-weight: 700; white-space: nowrap;
}
.pill-warn { background: var(--butter); color: #6B4A00; }

.btn {
  min-height: 52px; padding: 0 20px;
  border-radius: 16px; border: 0;
  background: var(--ink); color: var(--paper);
  font-weight: 800; font-size: 16px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-align: center;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; }
.btn.small { min-height: 42px; font-size: 14.5px; padding: 0 16px; border-radius: 13px; }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 2px var(--line); }
.btn.soft { background: var(--pink); color: var(--ink); }
.btn.danger { background: var(--danger); color: #fff; }
.file-btn { width: 100%; }

.bar-head {
  display: flex; align-items: center; gap: 10px;
  padding: calc(var(--safe-t) + 10px) 14px 8px;
}
.head-title { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 10px; }
.head-title h1 { margin: 0; font-size: 26px; font-weight: 800; letter-spacing: -.01em; }
.head-title .sub { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.head-spacer { width: 46px; flex: none; }
.bar-head .icon-btn { background: var(--paper); box-shadow: 0 1px 3px rgba(58, 46, 65, .12); }

/* ---------- camera ---------- */
#camera { background: var(--mint); }
.cam-top {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(var(--safe-t) + 10px) 14px 4px;
}
.top-right { display: flex; align-items: center; gap: 8px; }
.ratios {
  display: flex; gap: 2px; padding: 4px;
  background: rgba(255, 255, 255, .55); border-radius: 999px;
}
.ratios button {
  min-width: 50px; height: 38px; padding: 0 10px;
  border: 0; border-radius: 999px; background: transparent;
  font-weight: 800; font-size: 13.5px; font-variant-numeric: tabular-nums;
}
.ratios button[aria-pressed="true"] { background: var(--paper); box-shadow: 0 1px 4px rgba(58, 46, 65, .18); }

.stage {
  flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 8px 18px;
}
.card {
  background: var(--paper);
  padding: 10px 10px 0;
  border-radius: 5px;
  box-shadow: 0 14px 34px rgba(58, 46, 65, .18), 0 2px 6px rgba(58, 46, 65, .08);
}
.vf {
  position: relative; overflow: hidden; isolation: isolate;
  width: 240px; height: 320px;
  background: #3A2E41;
}
.vf video {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; background: #3A2E41;
}
.vf video.mirror { transform: scaleX(-1); }
.tint, .vig, .stamp-prev, .flash { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.tint { opacity: 0; }
.flash { background: #fff; opacity: 0; }
.flash.go { animation: flash .45s ease-out; }
@keyframes flash { 0% { opacity: .95; } 100% { opacity: 0; } }
.card-foot {
  height: 36px; display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted);
}
.vf-msg {
  position: absolute; inset: 0; z-index: 2;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  padding: 22px; text-align: center;
  background: #3A2E41; color: #fff;
}
.vf-msg h2 { margin: 0; font-size: 19px; }
.vf-msg p { margin: 0; font-size: 14.5px; color: #E9DFF0; max-width: 30ch; }
.vf-msg .btn { background: var(--pink); color: var(--ink); min-height: 48px; }
.vf-msg .ico { width: 54px; height: 54px; border-radius: 50%; background: rgba(255,255,255,.12); display: grid; place-items: center; }
.vf-msg .ico svg { width: 28px; height: 28px; }

.chips {
  display: flex; gap: 8px; overflow-x: auto;
  padding: 6px 16px 8px; scrollbar-width: none;
  scroll-padding: 16px;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: flex; align-items: center; gap: 8px;
  height: 44px; padding: 0 15px 0 7px;
  border: 0; border-radius: 999px;
  background: rgba(255, 255, 255, .62);
  font-weight: 800; font-size: 14px; white-space: nowrap;
}
.chip .sw { width: 30px; height: 30px; border-radius: 50%; box-shadow: inset 0 0 0 2px rgba(255,255,255,.7); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

.controls {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 6px 26px calc(var(--safe-b) + 18px);
}
.thumb-btn {
  justify-self: start;
  width: 58px; height: 58px; padding: 0;
  border-radius: 14px; border: 3px solid var(--paper);
  background: var(--pink); overflow: hidden;
  box-shadow: 0 3px 10px rgba(58, 46, 65, .18);
}
.thumb-btn img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-btn.pop { animation: pop .5s ease-out; }
@keyframes pop { 40% { transform: scale(1.15); } }
#flip { justify-self: end; }
.shutter {
  width: 88px; height: 88px; padding: 0;
  border-radius: 50%; border: 0;
  background: var(--paper);
  box-shadow: 0 0 0 6px var(--pink-deep), 0 8px 20px rgba(58, 46, 65, .22);
  display: grid; place-items: center;
}
.shutter span { width: 66px; height: 66px; border-radius: 50%; background: var(--pink); transition: transform .12s; }
.shutter:active span { transform: scale(.88); }
.shutter:disabled { opacity: .55; }

/* ---------- developing photo ---------- */
.develop {
  position: fixed; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  background: rgba(58, 46, 65, .28);
  padding: 24px;
}
.dev-card {
  position: relative;
  background: var(--paper);
  padding: 12px 12px 52px;
  border-radius: 5px;
  box-shadow: 0 24px 50px rgba(58, 46, 65, .3);
  transform: rotate(-2.5deg);
  animation: eject .55s cubic-bezier(.2, .9, .3, 1.2);
}
@keyframes eject { from { transform: translateY(60px) rotate(0) scale(.85); opacity: 0; } }
.dev-photo { position: relative; overflow: hidden; background: #EEE7DC; }
.dev-photo img { width: 100%; height: 100%; display: block; opacity: 0; }
.dev-photo.go img { animation: develop 4.2s ease-out forwards; }
@keyframes develop {
  0% { opacity: 0; filter: brightness(1.7) saturate(0) contrast(.6); }
  30% { opacity: .5; }
  100% { opacity: 1; filter: none; }
}
.dev-cap {
  position: absolute; left: 0; right: 0; bottom: 0; height: 52px; margin: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; color: var(--muted);
}
.develop.fly .dev-card { transition: transform .45s ease-in, opacity .45s ease-in; transform: translate(-36vw, 44vh) scale(.12) rotate(-12deg); opacity: 0; }

/* ---------- gallery ---------- */
#gallery, #settings { background: var(--bg); }
.remind {
  margin: 4px 14px 8px; padding: 14px;
  background: var(--butter); border-radius: 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.remind p { margin: 0; font-size: 14.5px; }
.remind-btns { display: flex; gap: 8px; }
.g-wrap { position: relative; flex: 1; min-height: 0; }
.g-scroll {
  position: absolute; inset: 0;
  overflow-y: auto; overscroll-behavior: contain;
  scroll-behavior: smooth;
  padding: 0 70px calc(var(--safe-b) + 28px) 14px;
}
.year { position: relative; }
.year-h {
  position: sticky; top: 0; z-index: 3;
  height: 46px; margin: 0;
  display: flex; align-items: center; gap: 10px;
  background: var(--bg);
  font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums;
}
.month-h {
  position: sticky; top: 46px; z-index: 2;
  height: 36px; margin: 0;
  display: flex; align-items: center; gap: 8px;
  background: var(--bg);
  font-size: 15px; font-weight: 800; color: var(--muted);
}
.count-tag { font-size: 12.5px; font-weight: 700; color: var(--muted); background: var(--paper); border-radius: 999px; padding: 2px 8px; font-variant-numeric: tabular-nums; }
.month { content-visibility: auto; contain-intrinsic-size: auto 400px; }
.grid {
  display: grid; gap: 5px;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  padding-bottom: 14px;
}
.tile {
  aspect-ratio: 1; padding: 0; border: 0;
  border-radius: 10px; overflow: hidden;
  background: var(--line);
}
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity .25s; }
.tile img.shown { opacity: 1; }
.rail {
  position: absolute; top: 4px; right: 10px; bottom: calc(var(--safe-b) + 12px);
  width: 52px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.sort {
  display: flex; flex-direction: column; gap: 2px; padding: 4px;
  background: var(--paper); border-radius: 999px;
  box-shadow: 0 1px 4px rgba(58, 46, 65, .12);
}
.sort button {
  width: 44px; height: 58px; border: 0; border-radius: 999px; background: transparent;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 11.5px; font-weight: 800;
}
.sort button svg { width: 18px; height: 18px; }
.sort button[aria-pressed="true"] { background: var(--pink); }
.years { display: flex; flex-direction: column; gap: 4px; overflow-y: auto; scrollbar-width: none; }
.years button {
  width: 52px; min-height: 34px; border: 0; border-radius: 10px; background: transparent;
  font-size: 12.5px; font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums;
}
.years button:active { background: var(--paper); }

.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 14px;
  padding: 60px 10px;
}
.empty-card {
  width: 120px; height: 146px; background: var(--paper); border-radius: 4px;
  padding: 9px 9px 30px; box-shadow: 0 10px 24px rgba(58,46,65,.14); transform: rotate(-4deg);
}
.empty-card i { display: block; width: 100%; height: 100%; background: linear-gradient(160deg, var(--pink), var(--lilac) 55%, var(--mint)); }
.empty h2 { margin: 0; font-size: 20px; }
.empty p { margin: 0; color: var(--muted); max-width: 30ch; }

/* ---------- viewer ---------- */
.viewer {
  position: fixed; inset: 0; z-index: 20;
  display: flex; flex-direction: column;
  background: #221B26; color: #fff;
}
.v-top { display: flex; align-items: center; gap: 12px; padding: calc(var(--safe-t) + 10px) 14px 8px; }
.v-info { display: flex; flex-direction: column; min-width: 0; }
.v-info b { font-size: 16px; }
.v-info span { font-size: 13px; color: #CFC3D8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v-stage {
  position: relative; flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 8px; touch-action: pan-y; user-select: none; -webkit-user-select: none;
}
.v-stage img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; border-radius: 3px; -webkit-user-drag: none; }
.v-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 46px; height: 46px; border-radius: 50%; border: 0;
  background: rgba(255,255,255,.14); color: #fff; display: grid; place-items: center;
}
.v-nav.prev { left: 10px; } .v-nav.next { right: 10px; }
@media (hover: none) { .v-nav { display: none; } }
.v-actions { display: flex; justify-content: center; gap: 28px; padding: 10px 16px calc(var(--safe-b) + 14px); }
.v-act {
  min-width: 84px; min-height: 60px; border: 0; border-radius: 16px;
  background: rgba(255,255,255,.1); color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-size: 13px; font-weight: 700;
}
#vDelete { color: #FFB3C3; }

/* ---------- settings ---------- */
.s-scroll { flex: 1; overflow-y: auto; padding: 4px 16px calc(var(--safe-b) + 36px); overscroll-behavior: contain; }
.s-scroll > * { max-width: 560px; margin-left: auto; margin-right: auto; }
.s-h { margin: 24px auto 8px; padding: 0 4px; font-size: 13px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.s-card { background: var(--paper); border-radius: 20px; padding: 16px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 1px 3px rgba(58,46,65,.06); }
.label { font-size: 14px; font-weight: 800; margin-bottom: -6px; }
.stamp-demo { width: 100%; height: auto; border-radius: 12px; display: block; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg button {
  min-height: 50px; border-radius: 14px; border: 0;
  background: var(--bg); box-shadow: inset 0 0 0 2px var(--line);
  font-weight: 800; font-size: 14.5px;
}
.seg button[aria-pressed="true"] { background: var(--butter); box-shadow: inset 0 0 0 2px var(--ink); }
.corners {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  width: 200px; aspect-ratio: 4 / 3; padding: 8px;
  background: linear-gradient(160deg, var(--pink), var(--lilac) 55%, var(--mint));
  border-radius: 12px;
}
.corners button {
  border: 0; border-radius: 9px; background: rgba(255,255,255,.35);
  display: flex; padding: 9px;
}
.corners button i { width: 18px; height: 18px; border-radius: 50%; background: rgba(255,255,255,.85); }
.corners button[data-c="tl"] { align-items: flex-start; justify-content: flex-start; }
.corners button[data-c="tr"] { align-items: flex-start; justify-content: flex-end; }
.corners button[data-c="bl"] { align-items: flex-end; justify-content: flex-start; }
.corners button[data-c="br"] { align-items: flex-end; justify-content: flex-end; }
.corners button[aria-pressed="true"] { background: rgba(255,255,255,.75); }
.corners button[aria-pressed="true"] i { background: #FF8A2A; box-shadow: 0 0 10px #FF8A2A; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 48px; font-weight: 700; }
.row small { display: block; font-weight: 500; font-size: 13px; color: var(--muted); margin-top: 2px; }
.switch {
  appearance: none; -webkit-appearance: none; flex: none;
  width: 54px; height: 32px; border-radius: 999px; margin: 0;
  background: var(--line); position: relative; transition: background .2s;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 26px; height: 26px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .2s;
}
.switch:checked { background: var(--mint-deep); }
.switch:checked::after { transform: translateX(22px); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stats div { background: var(--bg); border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; }
.stats b { font-size: 24px; font-variant-numeric: tabular-nums; }
.stats span { font-size: 13px; color: var(--muted); }
.note { margin: 0; font-size: 14px; color: var(--muted); }
.note.bad { color: #8A5A00; background: #FFF1D3; border-radius: 12px; padding: 10px 12px; }
.note.good { color: #2F6B52; }
.plain { margin: 0; font-size: 15px; }
.progress { display: flex; flex-direction: column; gap: 8px; }
.bar { height: 12px; border-radius: 999px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--pink-deep), var(--mint-deep)); border-radius: 999px; transition: width .2s; }
.backup-ready { display: flex; flex-direction: column; gap: 10px; background: #EAF7F0; border-radius: 16px; padding: 14px; }
.backup-ready p { margin: 0; font-size: 14.5px; }
.backup-ready .btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.backup-ready .btn-row .btn { flex: 1 1 auto; }
.divider { height: 1px; background: var(--line); margin: 2px 0; }
.warn { margin-top: 10px; background: var(--butter); border-radius: 18px; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; font-size: 14.5px; }
.warn.calm { background: var(--lilac); }
.version { text-align: center; color: var(--muted); font-size: 13px; margin-top: 26px; }

/* ---------- sheets, dialog, toast ---------- */
.sheet-wrap {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(58, 46, 65, .4);
  padding: 12px 12px calc(var(--safe-b) + 12px);
}
.sheet {
  width: 100%; max-width: 460px;
  background: var(--paper); border-radius: 26px;
  padding: 22px 20px 18px;
  display: flex; flex-direction: column; gap: 14px;
  animation: up .28s ease-out;
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet h2 { margin: 0; font-size: 20px; }
.steps { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 12px; counter-reset: s; }
.steps li { display: flex; align-items: center; gap: 12px; font-size: 15px; }
.steps li > span:last-child { flex: 1; min-width: 0; }
.step-icon { width: 42px; height: 42px; flex: none; border-radius: 12px; background: var(--mint); display: grid; place-items: center; }
.dlg-btns { display: flex; gap: 10px; }
.dlg-btns .btn { flex: 1; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-b) + 24px); z-index: 60;
  transform: translate(-50%, 16px);
  display: flex; align-items: center; gap: 12px;
  max-width: min(92vw, 440px);
  background: var(--ink); color: var(--paper);
  padding: 12px 16px; border-radius: 16px;
  font-size: 14.5px; font-weight: 600;
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
  box-shadow: 0 10px 26px rgba(58,46,65,.3);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast button { border: 0; background: var(--pink); color: var(--ink); border-radius: 10px; min-height: 36px; padding: 0 12px; font-weight: 800; flex: none; }

@media (min-width: 760px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
  .g-scroll { padding-left: 24px; padding-right: 84px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .dev-photo.go img { animation: fade .8s ease-out forwards !important; }
  @keyframes fade { to { opacity: 1; } }
  .g-scroll { scroll-behavior: auto; }
}
