:root {
  --body: #f3ebe0;
  --body2: #e7dbca;
  --ink: #3a312a;
  --soft: #93857a;
  --coral: #ff7b54;
  --coral2: #e85d36;
  --lcd: #e8f6e4;
}
* { box-sizing: border-box; }
html, body {
  height: 100%; margin: 0; background: var(--body); color: var(--ink);
  font-family: "Futura", "Avenir Next", "Century Gothic", "Trebuchet MS", sans-serif;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none; overflow: hidden; touch-action: manipulation;
}
body { background: radial-gradient(120% 80% at 50% 0%, #f8f2ea 0%, var(--body) 55%, #ece1d2 100%); }
button { font: inherit; color: inherit; cursor: pointer; }

#app {
  height: 100vh; height: 100dvh; max-width: 480px; margin: 0 auto;
  display: flex; flex-direction: column;
  padding: calc(env(safe-area-inset-top) + 4px) 16px calc(env(safe-area-inset-bottom) + 8px);
}

/* header */
.top { display: flex; align-items: center; justify-content: space-between; height: 50px; flex: none; }
.brand { display: flex; align-items: baseline; gap: 7px; }
.brand b { font-size: 24px; font-weight: 700; letter-spacing: -.02em; font-style: italic; }
.brand b::after { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--coral); margin-left: 3px; box-shadow: 0 0 6px var(--coral); }
.brand i { font-style: normal; font-size: 10px; letter-spacing: .22em; text-transform: uppercase; color: var(--soft); }
.pills { display: flex; gap: 6px; }
.pill {
  border: none; border-radius: 999px; padding: 7px 11px 7px 10px; font-size: 10.5px; font-weight: 700; letter-spacing: .14em;
  background: rgba(58, 49, 42, .07); color: var(--soft); display: flex; align-items: center; gap: 6px;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #cbbcaa; transition: .2s; }
.pill.on { color: var(--ink); background: rgba(58, 49, 42, .1); }
.pill.on::before { background: #ff8a2a; box-shadow: 0 0 6px #ff8a2a, 0 0 2px #ffb070; }

/* viewfinder screen */
.screen {
  flex: 1; min-height: 0; position: relative; margin: 4px 0 2px;
  background: #1b1917; border-radius: 30px;
  box-shadow: inset 0 0 0 5px #2b2724, inset 0 3px 14px rgba(0,0,0,.7), 0 1px 0 rgba(255,255,255,.8), 0 14px 30px -10px rgba(90,62,40,.35);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
#video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; pointer-events: none; }
#view { display: block; border-radius: 16px; position: relative; }
.lcd {
  position: absolute; left: 22px; right: 22px; display: flex; justify-content: space-between; align-items: center;
  font-family: "Menlo", "SF Mono", "Courier New", monospace; font-size: 11px; font-weight: 600; letter-spacing: .1em;
  color: var(--lcd); text-shadow: 0 0 6px rgba(170, 255, 190, .55), 0 1px 2px rgba(0,0,0,.6); pointer-events: none; z-index: 2;
}
.lcd-top { top: 20px; } .lcd-bottom { bottom: 20px; }
#lcdName::before { content: "▶ "; font-size: 9px; }
.batt { width: 21px; height: 10px; border: 1.5px solid var(--lcd); border-radius: 2.5px; position: relative; padding: 1.5px; box-shadow: 0 0 5px rgba(170,255,190,.4); }
.batt::after { content: ""; position: absolute; right: -4px; top: 2px; width: 2px; height: 4px; background: var(--lcd); border-radius: 0 1px 1px 0; }
.batt i { display: block; height: 100%; width: 72%; background: var(--lcd); border-radius: 1px; }
.snap { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 3; }
.snap.go { animation: snap .38s ease-out; }
@keyframes snap { 0% { opacity: 0; } 12% { opacity: .95; background: #000; } 30% { opacity: .8; background: #fff; } 100% { opacity: 0; } }
.msg { position: absolute; inset: 0; z-index: 4; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 30px; text-align: center; color: #e9e1d6; font-size: 14px; line-height: 1.5; }
.msg.hidden { display: none; }
.msg-btn { border: none; border-radius: 999px; padding: 11px 20px; background: var(--coral); color: #fff; font-weight: 700; letter-spacing: .03em; }

/* film strip */
.strip {
  flex: none; display: flex; gap: 12px; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory;
  padding: 12px calc(50% - 31px) 4px; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.strip::-webkit-scrollbar { display: none; }
.chip { flex: none; width: 62px; border: none; background: none; padding: 0; scroll-snap-align: center; text-align: center; color: var(--soft); }
.chip canvas { width: 62px; height: 62px; border-radius: 18px; display: block; background: #dccfbe; box-shadow: 0 3px 8px -2px rgba(70,50,30,.3); transition: transform .2s; }
.chip span { display: block; font-size: 10px; margin-top: 7px; letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip.sel canvas { outline: 2.5px solid var(--ink); outline-offset: 3px; transform: scale(1.04); }
.chip.sel span { color: var(--ink); font-weight: 700; }
.desc { flex: none; margin: 4px 0 0; text-align: center; font-size: 11.5px; color: var(--soft); letter-spacing: .02em; min-height: 16px; }

.strength { flex: none; display: flex; align-items: center; gap: 12px; padding: 8px 6px 0; font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--soft); font-weight: 700; }
.strength input { flex: 1; -webkit-appearance: none; appearance: none; height: 4px; border-radius: 4px; background: rgba(58,49,42,.15); outline: none; }
.strength input::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%; background: var(--coral); box-shadow: 0 0 0 4px var(--body), 0 2px 6px rgba(0,0,0,.25); }
.strength input::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; border: none; background: var(--coral); }

/* controls */
.controls { flex: none; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; justify-items: center; height: 112px; }
.round {
  width: 52px; height: 52px; border-radius: 50%; border: none; background: var(--body2); display: grid; place-items: center;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.7), 0 3px 8px -3px rgba(70,50,30,.35);
}
.round:active { transform: scale(.92); }
.round svg, .save svg { width: 24px; height: 24px; fill: none; stroke: var(--ink); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.shutter {
  width: 80px; height: 80px; border-radius: 50%; border: none; padding: 0;
  background: linear-gradient(#fbf6ef, #d9cab6);
  box-shadow: 0 0 0 1px rgba(0,0,0,.06), 0 8px 18px -6px rgba(90,60,40,.45), inset 0 1px 0 #fff;
  display: grid; place-items: center;
}
.shutter span {
  width: 62px; height: 62px; border-radius: 50%;
  background: radial-gradient(circle at 36% 30%, #ffd5c2 0%, var(--coral) 52%, var(--coral2) 100%);
  box-shadow: inset 0 -4px 8px rgba(120,30,0,.25), 0 2px 4px rgba(200,70,30,.4); transition: transform .12s;
}
.shutter:active span { transform: scale(.9); }
.save {
  height: 58px; padding: 0 30px; border-radius: 999px; border: none; display: flex; align-items: center; gap: 9px;
  background: radial-gradient(circle at 30% 20%, #ffb89c, var(--coral) 60%, var(--coral2)); color: #fff; font-weight: 700; font-size: 16px; letter-spacing: .04em;
  box-shadow: 0 10px 20px -8px rgba(232,93,54,.7), inset 0 1px 0 rgba(255,255,255,.4);
}
.save svg { stroke: #fff; stroke-width: 2.2; }
.save:active { transform: scale(.96); }
.save.busy { opacity: .7; }

body:not(.editing) .edit-only, body.editing .cam-only { display: none !important; }
.hide { visibility: hidden; }

@media (max-width: 400px) { .brand i { display: none; } .pill { padding: 7px 9px 7px 8px; } }

/* phone turned sideways: viewfinder on the left, controls on the right */
@media (orientation: landscape) and (max-height: 540px) {
  #app {
    max-width: none; display: grid; grid-template-columns: 1fr 270px; grid-template-rows: auto 1fr auto auto auto auto 1fr;
    column-gap: 18px; padding: calc(env(safe-area-inset-top) + 8px) max(14px, env(safe-area-inset-right)) calc(env(safe-area-inset-bottom) + 8px) max(14px, env(safe-area-inset-left));
  }
  #app > * { grid-column: 2; }
  #app > .screen { grid-column: 1; grid-row: 1 / -1; margin: 0; min-height: 0; }
  #app > .top { grid-row: 1; height: 44px; }
  .brand { display: none; }
  #app > .top { justify-content: center; }
  #app > .strip { grid-row: 3; min-width: 0; padding-left: calc(50% - 31px); padding-right: calc(50% - 31px); }
  #app > .desc { grid-row: 4; font-size: 10.5px; }
  #app > .strength { grid-row: 5; }
  #app > .controls { grid-row: 6; height: 96px; }
  .toast { top: 16px; }
}

.toast {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 64px); transform: translate(-50%, -10px); opacity: 0;
  background: rgba(40,34,30,.88); color: #fff; padding: 9px 16px; border-radius: 999px; font-size: 13px; pointer-events: none; transition: .25s; z-index: 10; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
