:root {
  --bg: #000;
  --fg: #fff;
  --dim: #9e9e9e;
  --chip: #1e1e1e;
  --accent: #fcc94b;
  --sheet: #151515;
  --scrim: rgba(0, 0, 0, .6);
  --error: #ff8a80;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); overflow: hidden;
  font: 14px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
svg { width: 22px; height: 22px; fill: currentColor; }

#app { height: 100%; display: flex; flex-direction: column; max-width: 560px; margin: 0 auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
header { display: flex; align-items: center; gap: 10px; height: 56px; padding: 0 16px; flex: none; }
.title { flex: 1; min-width: 0; }
.name { font-weight: 600; font-size: 17px; }
.sub { color: #b0b0b0; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip { color: var(--accent); background: #222; border-radius: 12px; padding: 4px 10px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.chip.error { color: var(--error); }
.round { width: 52px; height: 52px; border-radius: 50%; background: #262626; display: grid; place-items: center; flex: none; }
.round.small { width: 40px; height: 40px; }

#progress { padding: 0 16px 4px; font-size: 11px; color: #ddd; flex: none; }
#progress .bar { height: 3px; background: #333; border-radius: 2px; margin-top: 3px; overflow: hidden; }
#progress-fill { height: 100%; width: 0; background: var(--accent); transition: width .2s; }

#viewfinder { position: relative; width: 100%; aspect-ratio: 3 / 4; max-height: 68vh; margin: 0 auto;
  background: #0a0a0a; overflow: hidden; flex: none; touch-action: none; }
#viewfinder.landscape { aspect-ratio: 4 / 3; }
#viewfinder video, #viewfinder canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#viewfinder video { object-fit: cover; }
#viewfinder.mirror video, #viewfinder.mirror canvas { transform: scaleX(-1); }
#depth { image-rendering: auto; transition: opacity .2s; }
#divider { position: absolute; top: 0; bottom: 0; width: 2px; background: #fff; transform: translateX(-1px); pointer-events: none; }
#divider .handle { position: absolute; top: 50%; left: -13px; width: 28px; height: 28px; margin-top: -14px;
  border-radius: 50%; border: 2px solid #fff; background: rgba(0, 0, 0, .6); }

.mark { position: absolute; transform: translate(-50%, -50%); pointer-events: none; }
.mark .ring { width: 36px; height: 36px; border: 1.5px solid #fff; border-radius: 50%;
  box-shadow: 0 0 0 1.5px rgba(0, 0, 0, .45); margin: 0 auto; position: relative; }
.mark .ring::after { content: ""; position: absolute; left: 50%; top: 50%; width: 4px; height: 4px; margin: -2px; background: #fff; border-radius: 50%; }
.mark.pin .ring { width: 14px; height: 14px; background: var(--accent); }
.mark.pin .ring::after { display: none; }
.mark .label { position: absolute; left: 50%; top: 100%; transform: translateX(-50%); margin-top: 4px; white-space: nowrap;
  background: var(--scrim); border-radius: 10px; padding: 2px 8px; font-weight: 600; font-size: 15px; }
.mark.pin .label { background: var(--accent); color: #000; font-size: 13px; }

#legend { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; align-items: center; gap: 4px; }
#legend span, .pill { font-size: 10px; background: var(--scrim); border-radius: 6px; padding: 1px 4px; }
#legend-bar { width: 8px; height: 140px; border-radius: 4px; }
#ms { position: absolute; left: 10px; bottom: 10px; font-size: 11px; }
#status { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background: var(--scrim);
  border-radius: 16px; padding: 16px 20px; text-align: center; max-width: 80%; font-size: 13px; }
#status.error .spinner { display: none; }
.spinner { width: 28px; height: 28px; margin: 0 auto 10px; border: 3px solid rgba(252, 201, 75, .25); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#start { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background: var(--accent); color: #000;
  font-weight: 600; padding: 12px 22px; border-radius: 22px; }

.grow { flex: 1; min-height: 8px; }
#chips { display: flex; gap: 8px; overflow-x: auto; padding: 6px 16px; flex: none; scrollbar-width: none; }
#chips::-webkit-scrollbar { display: none; }
#chips button { background: var(--chip); border-radius: 16px; padding: 7px 12px; font-size: 13px; white-space: nowrap; display: flex; gap: 6px; align-items: center; }
#chips button.selected { background: var(--accent); color: #000; }
#chips button.running { font-weight: 700; }
#chips .note { opacity: .6; font-size: 11px; }
#modes { display: flex; justify-content: center; padding-top: 4px; flex: none; }
#modes button { font-size: 13px; letter-spacing: 1.5px; color: #bdbdbd; font-weight: 500; padding: 8px 14px; border-radius: 14px; }
#modes button.active { color: var(--accent); font-weight: 700; }
#controls { display: flex; align-items: center; justify-content: space-between; padding: 14px 32px 18px; flex: none; }
#thumb { background-size: cover; background-position: center; border: 2px solid rgba(255, 255, 255, .8); }
#shutter { width: 78px; height: 78px; border-radius: 50%; border: 4px solid #fff; padding: 7px; }
#shutter span { display: block; width: 100%; height: 100%; border-radius: 50%; background: #fff; transition: transform .15s, background .15s; }
#shutter.busy span { transform: scale(.85); background: var(--accent); }

#sheet, #capture { position: fixed; inset: 0; background: rgba(0, 0, 0, .5); display: flex; align-items: flex-end; justify-content: center; z-index: 10; }
.sheet-body { background: var(--sheet); width: 100%; max-width: 560px; max-height: 85vh; overflow-y: auto; border-radius: 20px 20px 0 0;
  padding: 12px 20px calc(24px + env(safe-area-inset-bottom)); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; font-size: 16px; font-weight: 600; }
h3 { color: var(--accent); font-size: 12px; letter-spacing: 1.2px; text-transform: uppercase; margin: 18px 0 6px; }
.dim { color: var(--dim); font-size: 12px; }
.small { font-size: 11px; }
.line { font-size: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0; }
.row button { background: #222; border-radius: 8px; padding: 7px 12px; font-size: 13px; }
.row button.selected { background: var(--accent); color: #000; }
.primary { background: var(--accent); color: #000; font-weight: 600; border-radius: 20px; padding: 9px 18px; margin-top: 8px; }
.secondary { background: #2a2a2a; border-radius: 20px; padding: 9px 18px; margin-top: 8px; }
.model { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; cursor: pointer; }
.model.selected { background: #2a2618; }
.model .meta { flex: 1; min-width: 0; }
.model .n { font-size: 15px; font-weight: 500; }
.model .st { font-size: 12px; color: var(--dim); white-space: nowrap; }
.model .st.active { color: var(--accent); }
.model .err { color: var(--error); font-size: 11px; }
.shots { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.shots img { width: 100%; border-radius: 10px; background: #222; }

#toast { position: fixed; left: 50%; bottom: calc(140px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #323232;
  border-radius: 8px; padding: 10px 16px; font-size: 13px; z-index: 20; max-width: 90%; text-align: center; }
[hidden] { display: none !important; }
