/* Encrypted View UI. Dark navy, Cegeka cyan accent. */
:root {
  --bg: #02060b;
  --panel: #060d14;
  --panel-2: #0a141d;
  --line: #12222e;
  --line-2: #1a3140;
  --text: #cfe3ea;
  --muted: #7896a3;
  --faint: #4b6774;
  --accent: #00c7f9;
  --accent-deep: #0095bb;
  --accent-soft: rgba(0, 199, 249, 0.14);
  --coral: #f04b4c;
  --radius: 8px;
  --panel-w: 380px;
  --ui-font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', Consolas, Menlo, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 var(--ui-font);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ------------------------------------------------------------------ layout */
#view {
  position: absolute;
  inset: 0 var(--panel-w) 40px 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
#view canvas {
  display: block;
  border-radius: 4px;
  box-shadow: 0 0 0 1px var(--line), 0 20px 60px rgba(0, 0, 0, 0.6);
}

#status {
  position: absolute;
  left: 0;
  right: var(--panel-w);
  bottom: 0;
  height: 40px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid var(--line);
  font: 12px var(--mono);
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
}
.chip {
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 340px;
}
.chip.ok {
  color: var(--accent);
  border-color: rgba(0, 199, 249, 0.3);
}
.chip.off {
  color: var(--faint);
}
.chip.note {
  color: var(--text);
  background: var(--accent-soft);
  border-color: rgba(0, 199, 249, 0.35);
  flex-shrink: 1;
}

/* ------------------------------------------------------------------ empty state */
#empty {
  position: absolute;
  inset: 0 var(--panel-w) 40px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
#empty .card {
  pointer-events: auto;
  width: min(480px, 80%);
  padding: 40px 36px;
  border: 1.5px dashed var(--line-2);
  border-radius: 16px;
  text-align: center;
  background: rgba(6, 13, 20, 0.7);
}
#empty h2 {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 600;
}
#empty p {
  margin: 0 0 22px;
  color: var(--muted);
  line-height: 1.55;
}
#empty .glyphs {
  font: 700 22px var(--mono);
  letter-spacing: 6px;
  color: var(--accent);
  margin-bottom: 18px;
  opacity: 0.85;
}
#empty .ui-btn-row {
  justify-content: center;
}
body.has-image #empty {
  display: none;
}
body:not(.has-image) #view canvas {
  visibility: hidden;
}
body.drag #empty .card,
body.drag::after {
  border-color: var(--accent);
}
body.drag::after {
  content: 'Drop image, *_depth.png or *_mask.png';
  position: absolute;
  inset: 16px calc(var(--panel-w) + 16px) 56px 16px;
  border: 2px dashed var(--accent);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-size: 18px;
  font-weight: 500;
  background: rgba(0, 199, 249, 0.06);
  pointer-events: none;
  z-index: 5;
}

/* ------------------------------------------------------------------ side panel */
#panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--panel-w);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-left: 1px solid var(--line);
}
.panel-head {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.brand b {
  font-size: 16px;
  font-weight: 650;
  letter-spacing: 0.2px;
}
.brand span {
  font: 12px var(--mono);
  color: var(--accent);
}
.panel-head .ui-btn-row {
  margin-top: 14px;
  flex-wrap: nowrap;
}
.panel-head .ui-btn {
  padding: 9px 6px;
  font-size: 12.5px;
}
#controls {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0 20px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
}
.panel-foot {
  padding: 14px 20px 16px;
  border-top: 1px solid var(--line);
  background: var(--panel-2);
}
.panel-foot .ui-row {
  padding: 0 0 12px;
}

/* ------------------------------------------------------------------ sections */
.ui-section {
  border-bottom: 1px solid var(--line);
}
.ui-section-head {
  all: unset;
  box-sizing: border-box;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1.1px;
  text-transform: uppercase;
  color: var(--muted);
}
.ui-section-head:hover {
  color: var(--text);
}
.ui-section-head:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.ui-chev {
  width: 8px;
  height: 8px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s;
  margin-right: 2px;
}
.ui-section.open .ui-chev {
  transform: rotate(45deg) translate(-2px, -1px);
}
.ui-section-body {
  display: none;
  padding: 0 20px 16px;
}
.ui-section.open .ui-section-body {
  display: block;
}
.ui-section.open .ui-section-head {
  color: var(--text);
}
.ui-group.hidden {
  display: none;
}

/* ------------------------------------------------------------------ rows */
.ui-row {
  padding: 7px 0;
}
.ui-label {
  font-size: 13.5px;
  color: var(--text);
  user-select: none;
}
.ui-label.has-hint {
  cursor: help;
}
/* brief highlight when a control is reset by double-click */
.ui-row.ui-flash {
  animation: ui-flash 0.6s ease-out;
}
@keyframes ui-flash {
  0% {
    background: var(--accent-soft);
    box-shadow: -20px 0 0 var(--accent-soft), 20px 0 0 var(--accent-soft);
  }
  100% {
    background: transparent;
    box-shadow: -20px 0 0 transparent, 20px 0 0 transparent;
  }
}
.ui-toggle-row,
.ui-color-row,
.ui-select-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.ui-seg-row,
.ui-text-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ui-note {
  margin: 4px 0 8px;
  font-size: 12.5px;
  color: var(--faint);
  line-height: 1.5;
}

/* sliders */
.ui-slider-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.ui-value {
  width: 76px;
  padding: 3px 7px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--accent);
  font: 12.5px var(--mono);
  text-align: right;
  outline: none;
}
.ui-value:hover {
  border-color: var(--line-2);
}
.ui-value:focus {
  border-color: var(--accent);
  background: var(--panel-2);
  color: var(--text);
}
.ui-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  --p: 50%;
}
.ui-range:focus {
  outline: none;
}
.ui-range::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 4px;
  background: linear-gradient(to right, var(--accent) 0, var(--accent) var(--p), var(--line-2) var(--p));
}
.ui-range::-moz-range-track {
  height: 4px;
  border-radius: 4px;
  background: var(--line-2);
}
.ui-range::-moz-range-progress {
  height: 4px;
  border-radius: 4px;
  background: var(--accent);
}
.ui-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -6px;
  border-radius: 50%;
  background: #e8f8fd;
  border: 3px solid var(--accent);
  box-shadow: 0 0 0 4px rgba(0, 199, 249, 0);
  transition: box-shadow 0.12s, transform 0.12s;
}
.ui-range::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #e8f8fd;
  border: 3px solid var(--accent);
}
.ui-range:hover::-webkit-slider-thumb {
  box-shadow: 0 0 0 5px var(--accent-soft);
}
.ui-range:active::-webkit-slider-thumb {
  transform: scale(1.12);
  box-shadow: 0 0 0 7px var(--accent-soft);
}
.ui-range:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--accent);
}

/* switch */
.ui-switch {
  all: unset;
  flex: none;
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: var(--line-2);
  position: relative;
  cursor: pointer;
  transition: background 0.15s;
}
.ui-switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #9fb7c1;
  transition: transform 0.15s, background 0.15s;
}
.ui-switch.on {
  background: var(--accent-deep);
}
.ui-switch.on::after {
  transform: translateX(16px);
  background: #fff;
}
.ui-switch:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* segmented */
.ui-seg {
  display: flex;
  padding: 3px;
  gap: 3px;
  border-radius: var(--radius);
  background: var(--bg);
  border: 1px solid var(--line);
}
.ui-seg-btn {
  all: unset;
  flex: 1;
  text-align: center;
  padding: 7px 6px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.ui-seg-btn:hover {
  color: var(--text);
  background: var(--panel-2);
}
.ui-seg-btn.on {
  background: var(--line-2);
  color: var(--accent);
  font-weight: 600;
}
.ui-seg-btn:focus-visible {
  outline: 2px solid var(--accent);
}

/* select + text */
.ui-select,
.ui-text,
.ui-hex {
  border: 1px solid var(--line-2);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: 13px var(--ui-font);
  padding: 7px 10px;
  outline: none;
}
.ui-select:focus,
.ui-text:focus,
.ui-hex:focus {
  border-color: var(--accent);
}
.ui-text {
  width: 100%;
}
.ui-text.mono,
.ui-hex {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 1px;
}

/* colour */
.ui-color {
  display: flex;
  align-items: center;
  gap: 8px;
}
.ui-swatch {
  -webkit-appearance: none;
  appearance: none;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  background: none;
  cursor: pointer;
}
.ui-swatch::-webkit-color-swatch-wrapper {
  padding: 3px;
}
.ui-swatch::-webkit-color-swatch {
  border: none;
  border-radius: 4px;
}
.ui-hex {
  width: 96px;
  padding: 6px 8px;
}

/* buttons */
.ui-btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 6px 0;
}
.ui-btn {
  all: unset;
  flex: 1;
  min-width: 0;
  text-align: center;
  padding: 9px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line-2);
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s;
}
.ui-btn:hover {
  background: #0f1e29;
  border-color: #24465a;
}
.ui-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.ui-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #001820;
  font-weight: 650;
}
.ui-btn.primary:hover {
  background: #3fd6fb;
}
.ui-btn.ghost {
  background: transparent;
}
.ui-btn.busy {
  opacity: 0.6;
  pointer-events: none;
}

/* client edition: browser only, no live camera */
html[data-edition='client'] [data-action='startCamera'],
html[data-edition='client'] .studio-only,
html:not([data-edition='client']) .client-only {
  display: none;
}

/* ------------------------------------------------------------------ starter templates */
.examples {
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}
.examples .label {
  font-size: 12px;
  letter-spacing: 1.1px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
}
.examples .row {
  display: flex;
  gap: 12px;
}
.example {
  all: unset;
  flex: 1;
  cursor: pointer;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg);
  transition: border-color 0.12s, transform 0.12s;
  text-align: left;
}
.example:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.example:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.example img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}
.example span {
  display: block;
  padding: 9px 12px 10px;
  font-size: 13px;
  font-weight: 600;
}
.example small {
  display: block;
  font-weight: 400;
  color: var(--muted);
  margin-top: 2px;
}

/* ------------------------------------------------------------------ narrow screens */
@media (max-width: 900px) {
  :root {
    --panel-w: 320px;
  }
}
@media (max-width: 640px) {
  #view,
  #empty {
    inset: 0 0 45vh 0;
  }
  #status {
    display: none;
  }
  #panel {
    top: 55vh;
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--line);
  }
}
