/* iOS 시스템 색·치수를 그대로 따른다. 카메라 화면은 항상 검정, 시트는 기기의 라이트/다크를 따른다. */
:root {
  --yellow: #ffd60a;          /* iOS 카메라의 선택 색 */
  --sheet: #f2f2f7;
  --cell: #ffffff;
  --sep: rgba(60, 60, 67, .29);
  --label: #000000;
  --label2: rgba(60, 60, 67, .6);
  --label3: rgba(60, 60, 67, .3);
  --blue: #007aff;
  --red: #ff3b30;
  --green: #34c759;
  --orange: #ff9500;
  --fill: rgba(118, 118, 128, .12);
  --seg-thumb: #ffffff;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --spring: cubic-bezier(.32, .72, 0, 1);
}
@media (prefers-color-scheme: dark) {
  :root {
    --sheet: #1c1c1e;
    --cell: #2c2c2e;
    --sep: rgba(84, 84, 88, .65);
    --label: #ffffff;
    --label2: rgba(235, 235, 245, .6);
    --label3: rgba(235, 235, 245, .3);
    --blue: #0a84ff;
    --red: #ff453a;
    --green: #30d158;
    --orange: #ff9f0a;
    --fill: rgba(118, 118, 128, .24);
    --seg-thumb: #636366;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  margin: 0; height: 100%; background: #000; color: #fff;
  font: 17px/1.3 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Apple SD Gothic Neo", "Pretendard", "Malgun Gothic", system-ui, sans-serif;
  letter-spacing: -.01em;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}
button { font: inherit; letter-spacing: inherit; color: inherit; border: 0; background: none; padding: 0; margin: 0; cursor: pointer; }
ul { list-style: none; margin: 0; padding: 0; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 2px solid var(--yellow); outline-offset: 2px; }

/* ================= 카메라 ================= */
#stage {
  position: fixed; inset: 0; background: #000;
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr);
}

#top {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; align-items: center; gap: 10px;
  padding: calc(var(--sat) + 8px) 16px 10px;
}

.glass {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(118, 118, 128, .28); color: #fff;
  transition: transform .2s var(--spring), background .2s;
}
.glass.big { width: 50px; height: 50px; }
.glass:active { transform: scale(.9); background: rgba(118, 118, 128, .5); }

#pill {
  justify-self: center; max-width: 100%; min-width: 0;
  display: flex; align-items: center; gap: 7px;
  height: 36px; padding: 0 14px 0 11px; border-radius: 18px;
  background: rgba(118, 118, 128, .28);
  font-size: 15px; font-weight: 600;
  transition: transform .2s var(--spring);
}
#pill:active { transform: scale(.96); }
#pill svg { width: 18px; height: 18px; color: var(--yellow); }
#folder-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
#pill-state { flex: none; font-size: 13px; font-weight: 500; color: rgba(235, 235, 245, .6); font-variant-numeric: tabular-nums; }
#pill-state:empty { display: none; }
#pill-state.busy { color: var(--yellow); }
#pill-state.busy::before {
  content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--yellow); margin: 0 6px 1px 0; animation: pulse 1.1s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .25; } }
#pill.unset { color: var(--yellow); }

#finder { position: relative; overflow: hidden; background: #000; }
#video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
#finder.blink #video { animation: blink .18s ease-out; }
@keyframes blink { 0%, 45% { opacity: 0; } 100% { opacity: 1; } }

#cam-off {
  position: absolute; inset: 0; background: #000;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  padding: 32px; text-align: center;
}
#cam-off > svg { width: 52px; height: 52px; stroke-width: 1.2; color: rgba(235, 235, 245, .3); }
#cam-off p { margin: 0 0 10px; max-width: 26ch; color: rgba(235, 235, 245, .6); font-size: 15px; line-height: 1.4; }

.filled, .tinted {
  min-width: 220px; height: 50px; padding: 0 20px; border-radius: 14px; font-weight: 600;
  transition: transform .2s var(--spring), opacity .2s;
}
.filled { background: #fff; color: #000; }
.tinted { background: rgba(118, 118, 128, .28); color: #fff; }
.filled:active, .tinted:active { transform: scale(.97); opacity: .8; }

/* 알림 카드: 지금 해야 할 일 한 가지 */
#banner {
  position: absolute; left: 12px; right: 12px; bottom: 12px;
  display: flex; align-items: center; gap: 10px; text-align: left;
  padding: 13px 12px 13px 14px; border-radius: 18px;
  background: rgba(40, 40, 42, .78); color: #fff;
  backdrop-filter: blur(24px) saturate(1.8); -webkit-backdrop-filter: blur(24px) saturate(1.8);
  font-size: 15px; font-weight: 500; line-height: 1.3;
  animation: drop .45s var(--spring);
}
@keyframes drop { from { transform: translateY(14px); opacity: 0; } }
#banner .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--yellow); flex: none; }
#banner.bad .dot { background: #ff453a; }
#banner-text { flex: 1; min-width: 0; }
#banner .chev { width: 16px; height: 16px; stroke-width: 2.4; color: rgba(235, 235, 245, .3); }
#banner.static .chev { display: none; }
#banner:active { background: rgba(70, 70, 74, .8); }

#toast {
  position: absolute; left: 50%; top: 12px; transform: translateX(-50%);
  max-width: calc(100% - 32px); padding: 7px 14px; border-radius: 16px;
  background: rgba(40, 40, 42, .72); color: #fff;
  backdrop-filter: blur(20px) saturate(1.8); -webkit-backdrop-filter: blur(20px) saturate(1.8);
  font-size: 13px; font-weight: 600; text-align: center; font-variant-numeric: tabular-nums;
  animation: pop .3s var(--spring);
}
@keyframes pop { from { transform: translateX(-50%) scale(.9); opacity: 0; } }

#bottom { padding: 6px 0 calc(var(--sab) + 18px); }

/* 해상도 다이얼: iOS 카메라의 모드 선택 줄과 같은 조작감 */
#dial {
  position: relative; display: flex; gap: 2px; overflow-x: auto; scroll-snap-type: x proximity;
  padding: 4px 50%; scrollbar-width: none;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 28%, #000 72%, transparent);
          mask-image: linear-gradient(90deg, transparent, #000 28%, #000 72%, transparent);
}
#dial::-webkit-scrollbar { display: none; }
#dial button {
  flex: none; scroll-snap-align: center;
  height: 34px; padding: 0 11px; border-radius: 17px;
  font-size: 13px; font-weight: 600; letter-spacing: .02em; font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, .78);
  transition: color .2s, background .2s;
}
#dial button[aria-pressed=true] { color: var(--yellow); background: rgba(118, 118, 128, .28); }

#controls {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 14px 30px 0;
}
#btn-last {
  justify-self: start; position: relative; width: 50px; height: 50px; border-radius: 10px;
  background: rgba(118, 118, 128, .28);
  transition: transform .2s var(--spring);
}
#btn-last:active { transform: scale(.92); }
#last-thumb { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; display: block; animation: thumb .4s var(--spring); }
@keyframes thumb { from { transform: scale(.6); opacity: 0; } }
#badge {
  position: absolute; top: -8px; right: -8px; min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 11px; background: #ff453a; color: #fff; box-shadow: 0 0 0 2px #000;
  font-size: 13px; font-weight: 600; line-height: 22px; text-align: center; font-variant-numeric: tabular-nums;
}
#btn-flip { justify-self: end; }
#btn-flip:active { transform: scale(.9) rotate(-90deg); }

#shutter {
  width: 78px; height: 78px; border-radius: 50%; padding: 6px;
  box-shadow: inset 0 0 0 4px #fff;
}
#shutter span {
  display: block; width: 100%; height: 100%; border-radius: 50%; background: #fff;
  transition: transform .25s var(--spring), background .15s;
}
#shutter:active span { transform: scale(.86); background: #d8d8dc; transition-duration: .08s; }

/* ================= 시트 ================= */
#scrim { position: fixed; inset: 0; z-index: 10; background: rgba(0, 0, 0, .45); animation: fade .25s; }
@keyframes fade { from { opacity: 0; } }

.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 11;
  height: calc(100% - var(--sat) - 12px);
  display: flex; flex-direction: column;
  background: var(--sheet); color: var(--label);
  border-radius: 14px 14px 0 0;
  animation: rise .5s var(--spring);
}
@keyframes rise { from { transform: translateY(100%); } }

.grabber { flex: none; width: 36px; height: 5px; border-radius: 3px; background: var(--label3); margin: 6px auto 0; }
.nav {
  flex: none; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  height: 48px; padding: 0 16px;
}
.nav h2 { margin: 0; font-size: 17px; font-weight: 600; }
.done { justify-self: end; color: var(--blue); font-weight: 600; height: 44px; padding: 0 0 0 16px; }
.done:active { opacity: .4; }

.sheet-body {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: 0 16px calc(var(--sab) + 40px);
}

.sheet h3 { margin: 26px 16px 7px; font-size: 13px; font-weight: 400; color: var(--label2); }
.sheet h3:first-child { margin-top: 12px; }
.foot { margin: 7px 16px 0; font-size: 13px; line-height: 1.38; color: var(--label2); }

.group { background: var(--cell); border-radius: 12px; overflow: hidden; }
.group.top { margin-top: 12px; }
.group:empty { display: none; }

.cell {
  position: relative; width: 100%; min-height: 44px; padding: 11px 16px;
  display: flex; align-items: center; gap: 12px; text-align: left;
}
.cell.stack { flex-direction: column; align-items: stretch; gap: 8px; }
/* 구분선: 첫 줄을 뺀 모든 줄 위에, 왼쪽 여백만큼 들여서 */
.group > * + * > .cell::before, .group > .cell + .cell::before, .group > * + .cell::before,
.group li + li::before, details > .cell + .cell::before, details[open] > summary + .cell::before {
  content: ""; position: absolute; top: 0; left: 16px; right: 0; height: .5px; background: var(--sep);
}
.group li { position: relative; }
.cell-main { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-sub { font-size: 13px; color: var(--label2); margin-top: 2px; white-space: normal; }
.value { color: var(--label2); flex: none; }
button.cell:active, summary.cell:active { background: var(--fill); }
.chev { width: 14px; height: 14px; stroke-width: 2.6; color: var(--label3); transition: transform .25s var(--spring); }
details[open] > summary .chev { transform: rotate(90deg); }
summary { list-style: none; cursor: pointer; }
summary::-webkit-details-marker { display: none; }
.check { width: 18px; height: 18px; stroke-width: 2.6; color: var(--blue); }

.link { color: var(--blue); flex: none; }
.link.danger { color: var(--red); }
.link:not(.cell) { min-height: 44px; margin: -11px 0; padding-left: 8px; }
.cell.stack .link { align-self: flex-start; margin: -6px 0 -8px; padding: 0; }
.link:active { opacity: .4; }
.link:disabled { opacity: .35; }

input[type=text] {
  font: inherit; letter-spacing: inherit; color: var(--label); width: 100%; min-width: 0;
  border: 0; background: var(--fill); border-radius: 10px; padding: 9px 12px;
  -webkit-user-select: text; user-select: text; caret-color: var(--blue);
}
input[type=text]::placeholder { color: var(--label3); }
input[type=text]:focus { outline: none; }
input.plain { background: none; padding: 0; border-radius: 0; flex: 1; }
input.right { text-align: right; color: var(--label2); }
#client-id { font-size: 14px; }
code {
  display: block; font: 13px/1.4 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  word-break: break-all; color: var(--label);
  -webkit-user-select: all; user-select: all;
}

/* iOS 세그먼트 컨트롤 */
.segmented { display: flex; padding: 2px; border-radius: 9px; background: var(--fill); }
.segmented button {
  flex: 1 1 0; height: 32px; border-radius: 7px; font-size: 13px; font-weight: 500; color: var(--label);
  transition: background .2s, box-shadow .2s;
}
.segmented button[aria-pressed=true] {
  background: var(--seg-thumb); font-weight: 600;
  box-shadow: 0 3px 8px rgba(0, 0, 0, .12), 0 3px 1px rgba(0, 0, 0, .04);
}

/* 업로드 내역 줄 */
.status { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; flex: none; color: #fff; }
.status svg { width: 13px; height: 13px; stroke-width: 3; }
.status.ok { background: var(--green); }
.status.wait { background: var(--orange); }
.status.err { background: var(--red); }
.cell .title { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cell .title + .cell-sub { margin-top: 1px; font-variant-numeric: tabular-nums; }

.empty { text-align: center; padding: 22vh 24px 0; color: var(--label2); font-size: 15px; line-height: 1.45; }
.empty svg { width: 56px; height: 56px; stroke-width: 1.1; color: var(--label3); }
.empty p { margin: 10px 0 0; }

/* 가로로 눕힌 폰: 셔터를 오른쪽 세로 줄로 */
@media (orientation: landscape) and (max-height: 520px) {
  #stage { grid-template-rows: auto minmax(0, 1fr); grid-template-columns: minmax(0, 1fr) auto; }
  #top { grid-column: 1; padding-top: 10px; padding-left: max(16px, env(safe-area-inset-left)); }
  #finder { grid-column: 1; }
  #bottom { grid-column: 2; grid-row: 1 / 3; display: flex; align-items: center; padding: 0 max(18px, env(safe-area-inset-right)) 0 18px; }
  #dial { display: none; }
  #controls { grid-template-columns: none; grid-template-rows: 1fr auto 1fr; height: 100%; padding: 20px 0; justify-items: center; }
  #btn-last { justify-self: center; align-self: end; order: 3; }
  #btn-flip { justify-self: center; align-self: start; order: 1; }
  #shutter { order: 2; margin: 22px 0; }
  .sheet { left: 50%; right: auto; width: min(100%, 560px); transform: translateX(-50%); }
  @keyframes rise { from { transform: translate(-50%, 100%); } }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
