/* Live Camera Studio — dark theme. Contrast: --muted 9.4:1, --faint 6.6:1 on --surface (WCAG AA). */
:root {
  --bg: #0b0d11;
  --bg-2: #11141a;
  --surface: #161a22;
  --surface-2: #1d222c;
  --line: #262c38;
  --line-2: #343c4b;
  --text: #f1f4f9;
  --muted: #b6bfcc;
  --faint: #95a0b1;
  --accent: #8aa6ff;
  --accent-ink: #0b0d11;
  --ok: #3ccf8e;
  --warn: #f5b84a;
  --danger: #ff7b7b;
  --manual: #fb923c;
  --radius: 14px;
  --radius-sm: 10px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  -webkit-font-smoothing: antialiased;
}
html:lang(ko) body { word-break: keep-all; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- shell ---------- */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 24px; border-bottom: 1px solid var(--line); background: var(--bg-2);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; letter-spacing: -.01em; font-size: 16px; white-space: nowrap; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px; flex: none; display: grid; place-items: center;
  background: conic-gradient(from 210deg, #8aa6ff, #a78bfa, #3ccf8e, #8aa6ff);
}
.brand-mark::after { content: ""; width: 12px; height: 12px; border-radius: 50%; background: var(--bg-2); }
.tabs, .lang { display: flex; gap: 2px; padding: 3px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.tabs button, .lang button {
  border: 0; background: transparent; padding: 6px 14px; border-radius: 7px; cursor: pointer;
  color: var(--muted); font-weight: 600; font-size: 14px; white-space: nowrap;
}
.lang button { padding: 5px 10px; font-size: 13px; }
.tabs button[aria-selected="true"], .lang button[aria-pressed="true"] { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.privacy-pill {
  display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted);
  padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; white-space: nowrap;
}
.privacy-pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px rgba(60,207,142,.15); flex: none; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 368px; gap: 24px; padding: 24px; max-width: 1440px; margin: 0 auto; }

/* ---------- camera stage ---------- */
.stage-col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.stage {
  position: relative; aspect-ratio: 16 / 9; width: 100%;
  border-radius: var(--radius); overflow: hidden; background: #07090c; border: 1px solid var(--line); isolation: isolate;
}
.source-video { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.cam-canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.cam-canvas.mirrored { transform: scaleX(-1); }
.hud { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; flex-wrap: wrap; gap: 8px; z-index: 4; pointer-events: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; padding: 5px 10px; border-radius: 999px;
  background: rgba(11, 13, 17, .78); border: 1px solid rgba(255,255,255,.1); white-space: nowrap; font-variant-numeric: tabular-nums;
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--danger); animation: pulse 1.6s infinite; }
.chip.right { margin-left: auto; color: var(--muted); }
.chip.warn { color: var(--warn); border-color: rgba(245,184,74,.4); }
@keyframes pulse { 50% { opacity: .35; } }

.overlay-state {
  position: absolute; inset: 0; z-index: 6; display: grid; place-items: center; padding: 24px; text-align: center;
  background: radial-gradient(ellipse at 50% 40%, #161b26 0%, #07090c 72%);
}
.overlay-state.cover { z-index: 3; } /* under the HUD and the mobile dock */
.overlay-card { max-width: 460px; display: grid; justify-items: center; gap: 12px; }
.overlay-card h2 { margin: 4px 0 0; font-size: 20px; letter-spacing: -.015em; font-weight: 650; }
.overlay-card p { margin: 0; color: var(--muted); font-size: 15px; }
.overlay-card .paused { color: var(--warn); }
.overlay-card .actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 6px; }
.overlay-card ol { text-align: left; margin: 0; padding-left: 20px; color: var(--muted); font-size: 14.5px; }
.state-icon { width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line-2); }
.state-icon.danger { color: var(--danger); background: rgba(255,123,123,.08); border-color: rgba(255,123,123,.35); }
.state-icon.warn { color: var(--warn); background: rgba(245,184,74,.08); border-color: rgba(245,184,74,.35); }
.state-icon svg { width: 30px; height: 30px; }
.fineprint { font-size: 13px; color: var(--faint); margin: 0; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line-2); border-top-color: var(--accent); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.steps { list-style: none; padding: 0; margin: 6px 0 0; display: grid; gap: 8px; text-align: left; font-size: 14.5px; }
.steps li { display: flex; gap: 10px; align-items: center; color: var(--faint); }
.steps li::before { content: ""; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line-2); flex: none; }
.steps li.done { color: var(--text); }
.steps li.done::before { background: var(--ok); border-color: var(--ok); }
.steps li.now { color: var(--text); }
.steps li.now::before { border-color: var(--accent); border-top-color: transparent; animation: spin .9s linear infinite; }
.prompt-arrow { position: absolute; top: 14px; left: 18px; z-index: 7; display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--accent); }

/* ---------- controls ---------- */
.controlbar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 10px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px;
  border-radius: var(--radius-sm); border: 1px solid var(--line-2); background: var(--surface-2); color: inherit;
  font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn svg { width: 18px; height: 18px; flex: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger-soft { color: var(--danger); border-color: rgba(255,123,123,.4); background: rgba(255,123,123,.08); }
.btn.ghost { background: transparent; }
.btn.icon { width: 44px; height: 44px; padding: 0; }
.btn.round { width: 60px; height: 60px; border-radius: 50%; }
.btn.round svg { width: 24px; height: 24px; }
.btn[aria-pressed="true"]#draw-mode { background: rgba(251,146,60,.14); border-color: var(--manual); color: #fdba74; }
.btn[aria-disabled="true"] { opacity: .45; pointer-events: none; }
.btn:focus-visible, .tabs button:focus-visible, .lang button:focus-visible, .seg button:focus-visible,
.pill:focus-visible, .switch input:focus-visible + span, input[type="range"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.controlbar .spacer { flex: 1; }
.meta { font-size: 13px; color: var(--faint); font-variant-numeric: tabular-nums; }

.notice {
  display: flex; gap: 10px; align-items: flex-start; margin: 0; padding: 12px 14px; border-radius: var(--radius-sm); font-size: 14px;
  background: rgba(245,184,74,.07); border: 1px solid rgba(245,184,74,.32); color: #f6e4b8;
}
.notice svg { flex: none; width: 18px; height: 18px; margin-top: 2px; color: var(--warn); }
.notice strong { color: #ffe7a8; }

/* ---------- side panel ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; min-width: 0; align-self: start; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; margin: 12px; padding: 3px; border-radius: 11px; background: var(--bg-2); border: 1px solid var(--line); }
.seg button { border: 0; background: transparent; border-radius: 8px; padding: 8px 6px; cursor: pointer; display: grid; justify-items: center; gap: 2px; color: var(--muted); font-size: 13.5px; font-weight: 600; }
.seg button svg { width: 18px; height: 18px; }
.seg button[aria-selected="true"] { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }
.panel-body { padding: 4px 16px 16px; display: grid; gap: 18px; }
.panel h3 { margin: 0; font-size: 12.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }
.field { display: grid; gap: 8px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row.top { align-items: flex-start; }
.label { font-weight: 600; font-size: 14.5px; }
.sub { display: block; font-weight: 400; font-size: 13px; line-height: 1.45; color: var(--faint); margin-top: 2px; }
.warn-line { margin: -8px 0 0; font-size: 13px; color: var(--warn); }
.switch { position: relative; flex: none; display: inline-block; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { display: block; width: 40px; height: 24px; border-radius: 999px; background: var(--line-2); transition: background .2s; position: relative; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(16px); }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { border: 1px solid var(--line-2); background: var(--bg-2); border-radius: 8px; padding: 7px 11px; font-size: 13.5px; font-weight: 600; cursor: pointer; color: var(--muted); }
.pill[aria-pressed="true"] { color: var(--text); border-color: var(--accent); background: rgba(138,166,255,.12); }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 650; white-space: nowrap; padding: 2px 8px; border-radius: 6px; background: var(--bg-2); border: 1px solid var(--line-2); color: var(--muted); }
.tag.ok { color: var(--ok); border-color: rgba(60,207,142,.4); background: rgba(60,207,142,.08); }
.tag.later { color: #cdbfff; border-color: rgba(167,139,250,.4); background: rgba(167,139,250,.1); }
.tag.auto { color: var(--ok); border-color: rgba(60,207,142,.4); }
.tag.manual { color: #fdba74; border-color: rgba(251,146,60,.45); }
.hr { height: 1px; background: var(--line); margin: 0 -16px; }

/* ---------- photo upload ---------- */
.upload-view { padding: 24px; max-width: 960px; margin: 0 auto; display: grid; gap: 16px; }
.dropzone { border: 1.5px dashed var(--line-2); border-radius: var(--radius); padding: 56px 24px; display: grid; justify-items: center; gap: 10px; text-align: center; background: var(--surface); }
.dropzone h2 { margin: 0; font-size: 20px; }
.dropzone p { margin: 0; color: var(--muted); }
.dropzone.error { border-style: solid; border-color: rgba(255,123,123,.45); background: rgba(255,123,123,.04); }
.dropzone .code { font: 12.5px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--faint); }
.status-line { margin: 0; min-height: 1.5em; color: var(--muted); font-size: 14.5px; }
.status-line.ok { color: var(--ok); }
.status-line.error { color: var(--danger); }
.editor { display: grid; gap: 14px; }
.editor h3 { margin: 4px 0 0; font-size: 12.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }
.toolbar .count { font-weight: 650; margin-right: auto; }
.toolbar .toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); cursor: pointer; }
.hint { margin: 0; font-size: 13.5px; color: #fdba74; }
.photo { position: relative; width: 100%; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: #07090c; line-height: 0; }
.photo img { display: block; width: 100%; height: auto; user-select: none; -webkit-user-drag: none; }
.photo-overlay { position: absolute; inset: 0; }
.photo-overlay.drawing { cursor: crosshair; touch-action: none; }
.photo-overlay.hide-boxes .box:not(.draft) { display: none; }
.box { position: absolute; border: 2px solid var(--ok); border-radius: 4px; box-shadow: 0 0 0 1px rgba(0,0,0,.4); pointer-events: none; line-height: 1.4; }
.box.manual, .box.draft { border-color: var(--manual); }
.box.draft { border-style: dashed; }
.box span { position: absolute; left: -2px; top: -2px; padding: 0 6px; font-size: 12px; font-weight: 700; background: var(--ok); color: #05130c; border-radius: 3px 0 4px 0; }
.box.manual span { background: var(--manual); color: #1c0d02; }
.regions { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.regions li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 14px; }
.regions li .what { flex: 1; color: var(--muted); font-variant-numeric: tabular-nums; }
.regions li.empty { color: var(--faint); }
.regions .btn { height: 32px; padding: 0 10px; font-size: 13px; }

/* ---------- mobile ---------- */
.mobile-dock { display: none; }
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; padding: 12px 16px 24px; gap: 12px; }
  .topbar { padding: 10px 16px; gap: 10px; flex-wrap: wrap; }
  .tabs { order: 3; width: 100%; }
  .tabs button { flex: 1; }
  .privacy-pill { display: none; }
  .stage { aspect-ratio: 4 / 5; max-height: 64svh; }
  .controlbar.desktop .btn:not(#cam-toggle), .controlbar.desktop .meta { display: none; }
  .controlbar.desktop .spacer { display: none; }
  .controlbar.desktop #cam-toggle { flex: 1; }
  .mobile-dock:not([hidden]) {
    display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
    position: absolute; left: 0; right: 0; bottom: 0; z-index: 5; padding: 12px 14px 14px;
    background: linear-gradient(transparent, rgba(0,0,0,.7));
  }
  .mobile-dock .right { justify-self: end; }
  .mobile-dock .btn { background: rgba(11,13,17,.75); border-color: rgba(255,255,255,.14); }
  .mobile-dock .btn.danger-soft { color: var(--danger); }
  .hud .chip.right { margin-left: 0; }
  .overlay-card h2 { font-size: 18px; }
  .overlay-card p, .overlay-card ol { font-size: 14px; }
  .notice { font-size: 13.5px; }
  .upload-view { padding: 12px 16px 24px; }
  .toolbar { display: grid; grid-template-columns: 1fr 1fr; }
  .toolbar .count, .toolbar .toggle, .toolbar .btn.primary { grid-column: 1 / -1; }
  .dropzone { padding: 40px 16px; }
}
@media (max-width: 900px) {
  /* While streaming, the dock over the preview replaces the control bar. */
  .stage-col:has(.mobile-dock:not([hidden])) .controlbar.desktop { display: none; }
}

/* ---------- 2-batch: snapshots and effects ---------- */
.shutter {
  width: 60px; height: 60px; border-radius: 50%; border: 3px solid var(--text);
  background: transparent; display: grid; place-items: center; cursor: pointer; padding: 0;
}
.shutter::after { content: ""; width: 46px; height: 46px; border-radius: 50%; background: var(--text); }
.shutter:disabled { opacity: .35; cursor: not-allowed; }
.shutter:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.small { height: 34px; padding: 0 12px; font-size: 13px; }
.flash { position: absolute; inset: 0; z-index: 8; background: #fff; opacity: 0; pointer-events: none; animation: flash .45s ease-out; }
@keyframes flash { 0% { opacity: .5; } 100% { opacity: 0; } }
.toast {
  position: absolute; right: 16px; bottom: 16px; z-index: 7; display: flex; align-items: center; gap: 12px;
  padding: 8px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line-2); box-shadow: 0 12px 32px rgba(0,0,0,.45);
}
.toast .thumb { width: 64px; height: 36px; border-radius: 6px; object-fit: cover; background: var(--bg-2); flex: none; }
.toast b { display: block; font-size: 14px; }
.toast small { color: var(--muted); font-size: 12.5px; }
.status-note { margin: -8px 0 0; font-size: 13px; color: var(--muted); }
.status-note.error { color: var(--warn); }
.shots-section { padding-top: 0; }
.shots { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.shots li { position: relative; aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; border: 1px solid var(--line-2); background: var(--bg-2); }
.shots img { width: 100%; height: 100%; object-fit: cover; display: block; }
.shots .shot-actions { position: absolute; right: 4px; bottom: 4px; display: flex; gap: 4px; }
.shots .shot-actions a, .shots .shot-actions button {
  width: 28px; height: 28px; border-radius: 6px; border: 0; background: rgba(11,13,17,.82); color: var(--text);
  display: grid; place-items: center; cursor: pointer; padding: 0;
}
.shots .shot-actions svg { width: 15px; height: 15px; }
@media (max-width: 900px) {
  .mobile-dock .left { justify-self: start; }
  .toast { left: 12px; right: 12px; bottom: 92px; }
}
.effect-alert {
  display: flex; align-items: center; gap: 10px; margin: 0 12px 12px; padding: 10px 12px; border-radius: var(--radius-sm);
  background: rgba(245,184,74,.08); border: 1px solid rgba(245,184,74,.35); color: #f6e4b8; font-size: 13.5px;
}
.effect-alert span { flex: 1; }
.effect-alert[hidden] { display: none !important; }
