* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0; width: 100%; height: 100%;
  background: #000; color: #fff; overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 13px; letter-spacing: .07em;
  overscroll-behavior: none;
}
button, select, input { font: inherit; letter-spacing: inherit; color: #fff; }
button { cursor: pointer; }

#stage {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: #000; touch-action: none;
}
#view { display: block; touch-action: none; }

.hidden { display: none !important; }

.overlay {
  position: absolute; inset: 0; z-index: 5;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; padding: 32px; text-align: center;
  background: rgba(0,0,0,.9);
}

#start h1 { margin: 0; font-size: 16px; font-weight: 500; letter-spacing: .35em; }
#start p { margin: 0; max-width: 380px; line-height: 1.65; color: #aaa; letter-spacing: .03em; }
#start .note { font-size: 10px; color: #777; }
.start-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

.btn {
  background: transparent; border: 1px solid #555; border-radius: 2px;
  padding: 12px 20px; min-height: 44px; font-size: 11px; letter-spacing: .14em;
}
.btn:hover { border-color: #fff; }
.btn.primary { background: #fff; color: #000; border-color: #fff; }
.btn.tiny { padding: 7px 11px; font-size: 10px; border-color: #444; }

/* gallery */
#gallery { justify-content: flex-start; gap: 16px; padding-top: max(10vh, 70px); }
.gallery-head { width: min(760px, 92vw); display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: #bbb; }
.gallery-grid {
  width: min(760px, 92vw); max-height: 58vh; overflow-y: auto;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px;
}
.shot { padding: 0; border: 1px solid #222; background: #0a0a0a; overflow: hidden; }
.shot:hover { border-color: #fff; }
.shot img { display: block; width: 100%; height: auto; }

/* story */
#info { background: rgba(0,0,0,.92); }
.info-card {
  width: min(460px, 92vw); max-height: 76vh; overflow-y: auto;
  border: 1px solid #333; background: #050505; padding: 22px; text-align: left;
}
.info-head { display: flex; justify-content: space-between; align-items: center; font-size: 10px; color: #888; margin-bottom: 18px; }
.info-year { font-size: 11px; color: #888; margin-bottom: 12px; }
#infoBody p { font-size: 14px; line-height: 1.75; color: #eee; letter-spacing: .02em; margin: 0 0 20px; }
.info-specs { font-size: 10px; color: #aaa; border-top: 1px solid #222; padding-top: 14px; }
.info-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.info-tags span { border: 1px solid #444; padding: 5px 8px; font-size: 9px; color: #bbb; }

/* camera picker */
#picker { z-index: 7; background: rgba(0,0,0,.94); }
.picker-card {
  width: min(900px, 94vw); max-height: 82vh; display: flex; flex-direction: column; gap: 12px;
  background: #050505; border: 1px solid #333; padding: 18px; text-align: left;
}
.picker-head { display: flex; justify-content: space-between; align-items: center; font-size: 10px; color: #888; }
#pickerSearch {
  width: 100%; background: #000; border: 1px solid #444; color: #fff;
  padding: 13px 14px; font-size: 13px; border-radius: 2px;
}
.picker-grid {
  overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: 8px; padding-right: 4px;
}
.picker-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  min-height: 74px; padding: 12px; text-align: left;
  background: #0a0a0a; border: 1px solid #2a2a2a; border-radius: 2px;
}
.picker-item:hover { border-color: #777; }
.picker-item.active { border-color: #fff; background: #141414; }
.pi-name { font-size: 12px; }
.pi-year { font-size: 10px; color: #eee; }
.pi-type { font-size: 9px; color: #777; line-height: 1.4; }

/* developing print */
#develop { z-index: 9; gap: 22px; }
.develop-wrap { display: flex; flex-direction: column; align-items: center; gap: 14px; }
#developImg {
  display: block; max-width: min(90vw, 620px); max-height: 68vh;
  filter: sepia(1) hue-rotate(55deg) saturate(.35) brightness(1.3) contrast(.5);
  clip-path: inset(100% 0 0 0);
  transition: filter 4s ease-out, clip-path 4s ease-out;
}
#develop.go #developImg { filter: none; clip-path: inset(0 0 0 0); }
.develop-label { font-size: 10px; color: #888; letter-spacing: .3em; }
#develop.go .develop-label { opacity: 0; transition: opacity 1s; }

#countdown {
  position: absolute; z-index: 8; top: 50%; left: 50%; transform: translate(-50%,-50%);
  font-size: 84px; font-weight: 200; animation: tick 1s ease-out;
  text-shadow: 0 0 30px rgba(255,255,255,.4);
}
@keyframes tick { from { transform: translate(-50%,-50%) scale(1.5); opacity: .2; } to { transform: translate(-50%,-50%) scale(1); opacity: 1; } }

#zoomCtrl {
  position: absolute; z-index: 4; left: 18px; bottom: calc(152px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 2px;
  background: rgba(0,0,0,.6); border: 1px solid #444; border-radius: 26px; padding: 3px;
}
#zoomCtrl button {
  width: 42px; height: 42px; border: 0; border-radius: 50%;
  background: transparent; font-size: 22px; line-height: 1;
}
#zoomCtrl button:hover { background: #222; }
#zoomCtrl span { min-width: 46px; text-align: center; font-size: 11px; }
#zoomCtrl.zoomed { border-color: #fff; }

#reticle {
  position: absolute; z-index: 3; width: 58px; height: 58px;
  border: 1px solid #fff; border-radius: 50%; pointer-events: none;
  transform: translate(-50%,-50%) scale(1.4); opacity: 0;
}
#reticle::before, #reticle::after {
  content: ''; position: absolute; background: #fff;
}
#reticle::before { left: 50%; top: -6px; width: 1px; height: 10px; }
#reticle::after { top: 50%; left: -6px; height: 1px; width: 10px; }
#reticle.show { animation: focusPulse .8s ease-out; }
@keyframes focusPulse {
  0% { opacity: 0; transform: translate(-50%,-50%) scale(1.5); }
  25% { opacity: 1; transform: translate(-50%,-50%) scale(1); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%,-50%) scale(.9); }
}

/* top bar */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 4;
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: calc(16px + env(safe-area-inset-top)) 18px 24px;
  pointer-events: none;
  background: linear-gradient(rgba(0,0,0,.6), transparent);
}
#topbar > * { pointer-events: auto; }
#camName {
  font-size: 13px; font-weight: 600; background: transparent; border: 0;
  padding: 0; text-align: left; cursor: pointer;
}
#camName:hover { text-decoration: underline; }
.meta { font-size: 10px; color: #888; margin-top: 3px; }
.top-actions { display: flex; gap: 5px; align-items: center; }
.icon-btn, .wide-btn {
  height: 36px; border: 1px solid #444; border-radius: 50%;
  background: rgba(0,0,0,.35); display: flex; align-items: center; justify-content: center;
}
.icon-btn { width: 36px; font-size: 15px; }
.wide-btn { border-radius: 16px; padding: 0 9px; font-size: 9px; white-space: nowrap; }
.icon-btn:hover, .wide-btn:hover { border-color: #fff; }
.icon-btn.on, .wide-btn.on { border-color: #fff; }

/* settings */
.panel {
  position: fixed; top: calc(62px + env(safe-area-inset-top)); right: 12px; z-index: 6;
  width: min(260px, calc(100vw - 24px)); max-height: calc(100vh - 160px); overflow-y: auto;
  padding: 16px; background: rgba(0,0,0,.94); border: 1px solid #333;
  display: flex; flex-direction: column; gap: 13px;
}
.panel-head { display: flex; justify-content: space-between; align-items: center; font-size: 10px; color: #888; }
.panel label { font-size: 10px; color: #aaa; display: flex; flex-direction: column; gap: 5px; }
.panel label span { color: #fff; }
.panel input[type=range] { width: 100%; accent-color: #fff; }
.panel select {
  background: #000; border: 1px solid #444; padding: 7px; font-size: 11px; border-radius: 2px;
}
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; border-top: 1px solid #222; border-bottom: 1px solid #222; padding: 12px 0; }
.panel .check { flex-direction: row; align-items: center; gap: 7px; }
.panel .hint { font-size: 9px; line-height: 1.6; color: #666; margin: 0; }

/* bottom bar */
#bottombar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 4;
  padding: 18px 0 calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, rgba(0,0,0,.8));
}
.controls { display: flex; align-items: center; justify-content: center; gap: 28px; padding: 0 14px 12px; }
.side-btn { background: transparent; border: 0; font-size: 10px; color: #bbb; min-width: 62px; min-height: 44px; }
.side-btn:hover { color: #fff; }
.side-btn.arrow { font-size: 26px; min-width: 34px; line-height: 1; }
.shutter {
  width: 80px; height: 80px; border-radius: 50%; flex: 0 0 auto;
  border: 3px solid #fff; background: transparent; padding: 0;
  display: flex; align-items: center; justify-content: center;
}
.shutter::after { content: ''; width: 62px; height: 62px; border-radius: 50%; background: #fff; transition: transform .08s ease; }
.shutter:active::after { transform: scale(.88); }

.strip { display: flex; gap: 6px; overflow-x: auto; padding: 4px 18px 2px; scrollbar-width: none; }
.strip::-webkit-scrollbar { display: none; }
.cam-pill {
  flex: 0 0 auto; min-height: 44px; padding: 12px 14px; white-space: nowrap;
  border: 1px solid #333; border-radius: 2px; background: transparent; font-size: 10px; color: #999;
}
.cam-pill.all-pill { color: #fff; border-color: #666; }
.cam-pill:hover { color: #fff; border-color: #666; }
.cam-pill.active { color: #000; background: #fff; border-color: #fff; }

.toast {
  position: fixed; left: 50%; bottom: calc(140px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 8;
  background: rgba(20,20,20,.96); border: 1px solid #444; padding: 9px 15px;
  font-size: 10px; border-radius: 2px; white-space: nowrap;
}

@media (max-width: 600px) {
  #topbar { padding-left: 12px; padding-right: 12px; }
  #camName { font-size: 11px; }
  .meta { font-size: 9px; }
  .icon-btn { width: 34px; height: 34px; font-size: 13px; }
  .wide-btn { height: 34px; font-size: 8px; padding: 0 7px; }
  .top-actions { gap: 3px; }
  .controls { gap: 12px; }
  .shutter { width: 76px; height: 76px; }
  .shutter::after { width: 60px; height: 60px; }
  .cam-pill { font-size: 9px; padding: 12px 10px; }
  .side-btn { min-width: 54px; }
  #zoomCtrl { left: 12px; bottom: calc(150px + env(safe-area-inset-bottom)); }
  #zoomCtrl button { width: 44px; height: 44px; }
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
  .picker-grid { grid-template-columns: repeat(auto-fill, minmax(135px, 1fr)); }
  .panel { top: calc(56px + env(safe-area-inset-top)); }
}

/* landscape: controls become a thumb-friendly right-hand rail */
@media (orientation: landscape) and (max-height: 560px) {
  #topbar { padding: calc(8px + env(safe-area-inset-top)) 12px 20px; }
  .meta { display: none; }
  #camName { font-size: 11px; }
  .icon-btn { width: 32px; height: 32px; }
  .wide-btn { height: 32px; font-size: 8px; }

  #bottombar { padding: 0; background: transparent; }
  .controls {
    position: fixed; right: 0; top: 0; bottom: 0; width: 92px;
    flex-direction: column; justify-content: center; gap: 14px;
    padding: 0 max(10px, env(safe-area-inset-right)) 0 0;
    background: linear-gradient(90deg, transparent, rgba(0,0,0,.85));
  }
  .side-btn { width: 76px; min-width: 0; min-height: 42px; }
  .side-btn.arrow { font-size: 32px; }
  .shutter { width: 64px; height: 64px; }
  .shutter::after { width: 50px; height: 50px; }

  .strip {
    padding: 4px 100px calc(4px + env(safe-area-inset-bottom)) 12px;
    background: linear-gradient(transparent, rgba(0,0,0,.85));
  }
  .cam-pill { min-height: 40px; padding: 10px 12px; }
  #zoomCtrl { left: 12px; bottom: calc(66px + env(safe-area-inset-bottom)); }
  #zoomCtrl button { width: 40px; height: 40px; }
  .toast { bottom: calc(74px + env(safe-area-inset-bottom)); }
  .panel { top: calc(44px + env(safe-area-inset-top)); max-height: calc(100vh - 80px); }
  .picker-card { max-height: 86vh; }
}
