/* NEGA — magazine / minimal, light, cool neutrals, small radius */
:root {
  --bg: #F4F5F6;
  --paper: #FFFFFF;
  --ink: #111214;
  --sub: #5D6168;
  --faint: #9A9FA6;
  --line: #DDE0E4;
  --line-strong: #C4C8CE;
  --accent: #1F4FE0;
  --danger: #D23B3B;
  --r: 3px;
  --bar-h: 52px;
  --font: Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --st: env(safe-area-inset-top, 0px);
  --sb: env(safe-area-inset-bottom, 0px);
  --sl: env(safe-area-inset-left, 0px);
  --sr: env(safe-area-inset-right, 0px);
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
body { overflow: hidden; overscroll-behavior: none; }

button, input { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; touch-action: manipulation; }
button:disabled { cursor: default; opacity: .35; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
svg { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- screens ---------- */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  background: var(--bg);
  padding: var(--st) var(--sr) var(--sb) var(--sl);
}
.screen.active { display: flex; }

/* ---------- top bar ---------- */
.bar {
  flex: none;
  height: var(--bar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: 16px;
  border-bottom: 1px solid var(--ink);
  background: var(--bg);
}
.bar.grid3 { display: grid; grid-template-columns: 64px 1fr 64px; padding-left: 0; border-bottom-color: var(--line); }
.logo { font-weight: 800; font-size: 17px; letter-spacing: .16em; display: flex; align-items: baseline; gap: 8px; }
.logo small { font-size: 10px; letter-spacing: .14em; font-weight: 600; color: var(--faint); }
.bar-right { display: flex; }
.bar-title { text-align: center; font-weight: 700; font-size: 15px; letter-spacing: -0.01em; white-space: nowrap; }
.bar-title small { font-weight: 500; color: var(--faint); font-size: 12px; margin-left: 4px; }
.icon-btn { width: 52px; height: var(--bar-h); display: grid; place-items: center; }
.icon-btn svg { width: 22px; height: 22px; }
.text-btn { height: var(--bar-h); padding: 0 16px; font-weight: 700; font-size: 15px; white-space: nowrap; justify-self: end; }

/* ---------- camera ---------- */
.ctrl-row {
  flex: none;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  border-bottom: 1px solid var(--line);
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
}
.ctrl {
  height: 52px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px;
  line-height: 1.2;
}
.ctrl span { font-size: 10px; letter-spacing: .06em; color: var(--faint); font-weight: 600; }
.ctrl b { font-size: 13px; font-weight: 700; display: grid; place-items: center; height: 17px; }
.ctrl b svg { width: 18px; height: 18px; }
.ctrl.on b { color: var(--accent); }
.ctrl + .ctrl { border-left: 1px solid var(--line); }

.vf-wrap { flex: 1; min-height: 0; display: grid; place-items: center; }
.viewfinder {
  position: relative;
  overflow: hidden;
  background: #16171A;
  border-radius: 2px;
}
.viewfinder video, .viewfinder canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
}
.viewfinder video { object-fit: cover; }
.viewfinder canvas { display: block; }
.frame-mark { position: absolute; inset: 10px; pointer-events: none; }
.frame-mark i { position: absolute; width: 14px; height: 14px; border: 0 solid rgba(255,255,255,.7); }
.frame-mark i:nth-child(1) { left: 0; top: 0; border-left-width: 1.5px; border-top-width: 1.5px; }
.frame-mark i:nth-child(2) { right: 0; top: 0; border-right-width: 1.5px; border-top-width: 1.5px; }
.frame-mark i:nth-child(3) { left: 0; bottom: 0; border-left-width: 1.5px; border-bottom-width: 1.5px; }
.frame-mark i:nth-child(4) { right: 0; bottom: 0; border-right-width: 1.5px; border-bottom-width: 1.5px; }
.countdown {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  color: #fff;
  font-size: clamp(72px, 24vw, 160px);
  font-weight: 800;
  letter-spacing: -0.04em;
  text-shadow: 0 2px 24px rgba(0,0,0,.35);
  pointer-events: none;
}
.countdown.pop { animation: pop .9s ease-out; }
@keyframes pop { 0% { transform: scale(1.25); opacity: 0; } 15% { opacity: 1; } 100% { transform: scale(.92); opacity: .9; } }
.curtain { position: absolute; inset: 0; background: #000; opacity: 0; pointer-events: none; }
.curtain.go { animation: curtain .26s ease-out; }
@keyframes curtain { 0% { opacity: 1; } 35% { opacity: 1; } 100% { opacity: 0; } }
.cam-msg {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  gap: 14px; padding: 20px;
  background: var(--paper);
  text-align: center; color: var(--sub);
}
.cam-msg p { margin: 0; max-width: 22em; }

/* 필름 고르기 */
.stocks {
  flex: none;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 10px 16px;
  scroll-padding: 0 16px;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
}
.stocks::-webkit-scrollbar { display: none; }
.stock {
  flex: none;
  display: flex; align-items: center; gap: 8px;
  height: 46px;
  padding: 0 12px 0 8px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  background: var(--paper);
  text-align: left;
}
.stock.on { border-color: var(--ink); background: var(--ink); color: var(--paper); }
.st-t { display: flex; flex-direction: column; line-height: 1.15; }
.st-t b { font-size: 13px; font-weight: 800; letter-spacing: .04em; }
.st-t small { font-size: 11px; opacity: .7; white-space: nowrap; }
/* 필름 통 아이콘 */
.can { width: 14px; height: 26px; border-radius: 2px; position: relative; flex: none; background: var(--c1); box-shadow: inset 0 0 0 1px rgba(17,18,20,.18); }
.can::before { content: ""; position: absolute; left: 0; right: 0; top: 9px; height: 7px; background: var(--c2); }
.can::after { content: ""; position: absolute; left: 4px; right: 4px; top: -3px; height: 3px; background: #6E737B; border-radius: 1px 1px 0 0; }
.stock.on .can { box-shadow: inset 0 0 0 1px rgba(255,255,255,.35); }
.can-std { --c1: #E8EBEF; --c2: #1F4FE0; }
.can-slide { --c1: #1F4FE0; --c2: #E8EBEF; }
.can-tung { --c1: #1C2A4A; --c2: #7FA3E6; }
.can-fade { --c1: #DCE6E4; --c2: #8AA8A3; }
.can-cross { --c1: #0E6E6A; --c2: #BFE8E3; }
.can-mono { --c1: #17181B; --c2: #F4F5F6; }
.can-msoft { --c1: #9A9FA6; --c2: #F4F5F6; }

.cam-bottom {
  flex: none;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 6px 28px 18px;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
}
.gal-btn {
  justify-self: start;
  width: 50px; height: 50px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  background: var(--paper);
  position: relative;
  overflow: visible;
}
.gal-btn img { position: absolute; inset: 3px; width: calc(100% - 6px); height: calc(100% - 6px); object-fit: cover; border-radius: 1px; }
.gal-empty { position: absolute; inset: 14px; border: 1.5px solid var(--line-strong); border-radius: 1px; }
.gal-btn em {
  position: absolute; right: -7px; top: -7px;
  min-width: 20px; height: 20px; padding: 0 5px;
  background: var(--ink); color: var(--paper);
  font-style: normal; font-size: 11px; font-weight: 700; line-height: 20px;
  border-radius: 2px;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 0 0 1.5px var(--bg);
}
.gal-btn.bump { animation: bump .45s ease-out; }
@keyframes bump { 0% { transform: scale(.82); } 60% { transform: scale(1.06); } 100% { transform: scale(1); } }
.shutter {
  width: 76px; height: 76px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--paper);
}
.shutter span { width: 58px; height: 58px; background: var(--ink); border-radius: 50%; transition: transform .15s, background .15s; }
.shutter:active span { transform: scale(.9); }
.shutter.running span { width: 28px; height: 28px; border-radius: 3px; background: var(--accent); }
.round-btn {
  justify-self: end;
  width: 50px; height: 50px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--paper);
}
.round-btn svg { width: 22px; height: 22px; }

.screen-flash { position: fixed; inset: 0; z-index: 60; background: #fff; opacity: 0; pointer-events: none; transition: opacity .25s ease-out; }
.screen-flash.on { opacity: 1; transition: none; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 14px;
  border: 1px solid var(--ink);
  border-radius: var(--r);
  background: var(--paper);
  font-size: 14px; font-weight: 600;
  text-decoration: none; color: var(--ink);
  white-space: nowrap;
}
.btn.primary { background: var(--ink); color: var(--paper); }
.btn.ghost { border-color: var(--line-strong); color: var(--sub); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.big { min-height: 52px; font-size: 15px; width: 100%; }
.btn small { font-weight: 500; opacity: .6; font-size: 12px; font-variant-numeric: tabular-nums; }
.btn-row { display: flex; gap: 8px; }
.btn-row > .btn { flex: 1 1 0; }
.mini-btn { font-size: 13px; font-weight: 600; color: var(--sub); padding: 6px 0 6px 12px; }

/* ---------- gallery ---------- */
.gal-scroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.gal-inner { max-width: 960px; margin: 0 auto; padding: 0 0 24px; }
.import-row {
  width: 100%;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}
.import-row span { display: flex; flex-direction: column; }
.import-row b { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.import-row small { font-size: 13px; color: var(--sub); }
.import-row svg { width: 20px; height: 20px; color: var(--faint); flex: none; }
.gal-note { margin: 0; padding: 10px 16px 12px; font-size: 12px; color: var(--faint); }
.gal-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  padding: 0 2px;
}
.cell {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: #E6E8EB;
}
.cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.chk {
  display: none;
  position: absolute; right: 6px; top: 6px;
  width: 22px; height: 22px;
  border: 1.5px solid #fff;
  border-radius: 2px;
  background: rgba(17,18,20,.25);
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
.selecting .chk { display: block; }
.cell.sel .chk { background: var(--accent); border-color: #fff; }
.cell.sel .chk::after {
  content: ""; position: absolute; left: 6px; top: 2px; width: 6px; height: 11px;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.cell.sel img { opacity: .78; }
.gal-empty-msg { padding: 56px 16px; text-align: center; color: var(--sub); }
.gal-empty-msg p { margin: 0 0 14px; }
.sel-bar {
  flex: none;
  display: flex; gap: 8px;
  padding: 10px 16px 12px;
  border-top: 1px solid var(--line);
  background: var(--paper);
}
.sel-bar .btn { flex: 1; }

/* ---------- viewer ---------- */
.vw-stage {
  flex: 1; min-height: 0;
  position: relative;
  display: grid; place-items: center;
  padding: 16px;
  touch-action: pan-y;
  user-select: none; -webkit-user-select: none;
}
.vw-stage img {
  max-width: 100%; max-height: 100%;
  object-fit: contain;
  display: block;
  box-shadow: 0 1px 2px rgba(17,18,20,.08), 0 8px 28px rgba(17,18,20,.10);
  -webkit-touch-callout: default;
}
.vw-nav {
  position: absolute; top: 50%;
  width: 40px; height: 56px;
  transform: translateY(-50%);
  display: grid; place-items: center;
  color: var(--ink);
}
.vw-nav svg { width: 22px; height: 22px; }
.vw-nav.prev { left: 0; }
.vw-nav.next { right: 0; }
.vw-nav:disabled { opacity: 0; pointer-events: none; }
.vw-foot {
  flex: none;
  width: 100%; max-width: 560px; margin: 0 auto;
  padding: 0 16px 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.vw-meta { display: flex; gap: 12px; align-items: baseline; font-size: 13px; color: var(--sub); border-top: 1px solid var(--line); padding-top: 10px; flex-wrap: wrap; }
.vw-meta b { color: var(--ink); font-weight: 800; letter-spacing: .04em; }
.vw-meta span { font-variant-numeric: tabular-nums; color: var(--faint); }

/* ---------- develop ---------- */
.dv-work { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.dv-stage { flex: 1; min-height: 140px; display: grid; place-items: center; }
.dv-box { position: relative; }
.dv-box canvas {
  display: block; width: 100%; height: 100%;
  box-shadow: 0 1px 2px rgba(17,18,20,.08), 0 8px 28px rgba(17,18,20,.10);
}
.dv-panel {
  flex: none;
  background: var(--paper);
  border-top: 1px solid var(--line);
  display: flex; flex-direction: column;
  max-height: 52vh;
}
.dv-panel .stocks { padding-top: 12px; padding-bottom: 6px; max-width: none; }
.dv-thumbs {
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
  padding: 10px 16px 0;
}
.dv-thumbs::-webkit-scrollbar { display: none; }
.dv-th { flex: none; width: 46px; height: 46px; position: relative; border-radius: 2px; overflow: visible; }
.dv-th img { width: 100%; height: 100%; object-fit: cover; border-radius: 2px; display: block; opacity: .55; }
.dv-th.on img { opacity: 1; outline: 2px solid var(--ink); outline-offset: 1px; }
.dv-th i {
  position: absolute; right: -5px; top: -5px; width: 16px; height: 16px;
  background: var(--ink); border-radius: 2px; box-shadow: 0 0 0 1.5px var(--paper);
  display: none;
}
.dv-th.on i { display: block; }
.dv-th i::before, .dv-th i::after { content: ""; position: absolute; left: 4px; right: 4px; top: 7.25px; height: 1.5px; background: #fff; transform: rotate(45deg); }
.dv-th i::after { transform: rotate(-45deg); }
.dv-th i::before { box-shadow: none; }
.dv-body {
  overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: 6px 16px 8px;
  display: flex; flex-direction: column; gap: 6px;
}
.dv-action { padding: 8px 16px 12px; border-top: 1px solid var(--line); }

/* ---------- controls ---------- */
.seg { display: inline-flex; border: 1px solid var(--ink); border-radius: var(--r); overflow: hidden; }
.seg button { padding: 7px 14px; font-size: 13px; font-weight: 600; border-left: 1px solid var(--ink); white-space: nowrap; }
.seg button:first-child { border-left: 0; }
.seg button.on { background: var(--ink); color: var(--paper); }
.seg.small button { padding: 5px 11px; font-size: 12px; }

.k { font-size: 13px; font-weight: 600; color: var(--sub); }
.k small { font-weight: 500; color: var(--faint); margin-left: 4px; font-variant-numeric: tabular-nums; }
.kv { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 40px; }
.hint { margin: 0; font-size: 13px; color: var(--sub); }

.adjust { display: flex; flex-direction: column; }
.range { display: grid; grid-template-columns: 56px 1fr 40px; align-items: center; gap: 10px; min-height: 40px; }
.range output { text-align: right; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }

input[type=range] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 30px; margin: 0;
  background: transparent;
  --p: 50%;
  touch-action: pan-y;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 2px;
  background: linear-gradient(to right, var(--ink) 0 var(--p), var(--line) var(--p) 100%);
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px; margin-top: -9px;
  background: var(--paper);
  border: 1.5px solid var(--ink);
  border-radius: 2px;
}
input[type=range]::-moz-range-track { height: 2px; background: var(--line); }
input[type=range]::-moz-range-progress { height: 2px; background: var(--ink); }
input[type=range]::-moz-range-thumb { width: 18px; height: 18px; background: var(--paper); border: 1.5px solid var(--ink); border-radius: 2px; }

.switch-row { display: flex; justify-content: space-between; align-items: center; min-height: 40px; }
.switch {
  -webkit-appearance: none; appearance: none;
  width: 46px; height: 26px; margin: 0;
  border: 1.5px solid var(--ink);
  border-radius: var(--r);
  position: relative;
  background: var(--paper);
  cursor: pointer;
  flex: none;
}
.switch::before {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 17px; height: 17px; border-radius: 2px;
  background: var(--ink);
  transition: transform .15s;
}
.switch:checked { background: var(--ink); }
.switch:checked::before { background: var(--paper); transform: translateX(20px); }

/* ---------- sheets, dialog, toast ---------- */
.sheet {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(17,18,20,.45);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet.center { align-items: center; padding: 24px; z-index: 50; }
.sheet-card {
  width: 100%; max-width: 480px;
  background: var(--paper);
  border-radius: var(--r) var(--r) 0 0;
  padding: 6px 16px calc(14px + var(--sb));
  display: flex; flex-direction: column; gap: 4px;
  max-height: 88vh;
  overflow-y: auto;
}
.sheet-card > .btn { margin-top: 8px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; min-height: 48px; border-bottom: 1px solid var(--ink); margin-bottom: 6px; }
.sheet-head b { font-size: 16px; }
.sheet-head small { font-weight: 600; color: var(--faint); font-size: 12px; margin-left: 6px; letter-spacing: .02em; }
.dialog-card {
  width: 100%; max-width: 340px;
  background: var(--paper);
  border-radius: var(--r);
  padding: 20px 16px 16px;
}
.dialog-card p { margin: 0 0 18px; font-size: 15px; line-height: 1.55; }

.busy {
  position: fixed; inset: 0; z-index: 45;
  background: rgba(244,245,246,.82);
  display: grid; place-items: center;
}
.busy span {
  font-size: 14px; font-weight: 700;
  padding: 12px 18px;
  background: var(--ink); color: var(--paper);
  border-radius: var(--r);
  font-variant-numeric: tabular-nums;
}
.toast {
  position: fixed; left: 50%; top: calc(var(--st) + 64px); z-index: 70;
  transform: translate(-50%, -8px);
  max-width: calc(100% - 32px);
  padding: 10px 14px;
  background: var(--ink); color: var(--paper);
  font-size: 13px; font-weight: 600;
  border-radius: var(--r);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 넓은 화면: 현상 패널을 오른쪽으로 ---------- */
@media (min-width: 900px) {
  .dv-work { flex-direction: row; }
  .dv-panel { width: 380px; max-height: none; border-top: 0; border-left: 1px solid var(--line); }
  .dv-panel .stocks { flex-wrap: wrap; overflow: visible; }
  .dv-body { flex: 1; }
  .gal-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}

/* 마우스가 있는 기기에서만 호버 */
@media (hover: hover) and (pointer: fine) {
  .ctrl:hover, .icon-btn:hover, .import-row:hover { background: rgba(17,18,20,.04); }
  .stock:not(.on):hover { border-color: var(--ink); }
  .btn:hover { border-color: var(--ink); }
  .btn.primary:hover { background: #2A2C30; }
  .gal-btn:hover, .round-btn:hover { border-color: var(--ink); }
  .cell:hover img { opacity: .9; }
  .vw-nav:hover { background: rgba(17,18,20,.05); }
}
