:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #07080a;
}

* { box-sizing: border-box; }
html, body, #app { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { background: #07080a; }
button, input { font: inherit; }

#app {
  position: relative;
  isolation: isolate;
  background:
    radial-gradient(circle at 50% 42%, rgba(45, 48, 54, .7), transparent 48%),
    #07080a;
}

#stage {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(100vw, 66.6667vh);
  height: min(100vh, 150vw);
  aspect-ratio: 2 / 3;
  transform: translate(-50%, -50%);
  display: block;
  background: #090a0d;
  box-shadow: 0 0 0 1px rgba(255,255,255,.08), 0 28px 90px rgba(0,0,0,.48);
}
#camera, #idleLoop, #character { position: fixed; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.client-approval #operator,
.client-approval #revealUi {
  display: none;
}

.client-trigger {
  position: fixed;
  z-index: 24;
  left: 50%;
  bottom: max(22px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  min-width: 190px;
  padding: 13px 18px;
  border-color: rgba(239, 255, 50, .44);
  background: rgba(9, 10, 12, .80);
  box-shadow: 0 12px 44px rgba(0, 0, 0, .44), 0 0 28px rgba(225, 255, 0, .14);
  backdrop-filter: blur(18px);
}

.client-trigger[hidden] { display: none; }

.operator-ui { transition: opacity .25s ease, transform .25s ease; }
.ui-hidden .operator-panel,
.ui-hidden .reveal-ui {
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
}

.welcome {
  position: absolute;
  z-index: 20;
  inset: 50% auto auto 50%;
  width: min(470px, calc(100% - 36px));
  transform: translate(-50%, -50%);
  padding: 34px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 28px;
  background: rgba(9, 10, 12, .78);
  box-shadow: 0 30px 90px rgba(0,0,0,.45);
  backdrop-filter: blur(24px);
  text-align: center;
}

.welcome[hidden] { display: none; }
.eyebrow { display: flex; align-items: center; justify-content: center; gap: 9px; color: #cbd0d7; font-size: 11px; font-weight: 760; letter-spacing: .18em; }
.welcome h1 { margin: 18px 0 10px; color: #fff; font-size: clamp(54px, 9vw, 92px); font-weight: 950; letter-spacing: -.07em; line-height: .78; }
.welcome h1 span { color: #f8ff3a; text-shadow: 0 0 38px rgba(223,255,0,.22); }
.welcome p { max-width: 360px; margin: 24px auto; color: #b1b7c0; font-size: 14px; line-height: 1.5; }
.welcome small { display: block; margin-top: 13px; color: #7f858e; font-size: 10px; }
.welcome-actions { display: flex; justify-content: center; gap: 9px; flex-wrap: wrap; }

.dot { width: 13px; height: 13px; border-radius: 50%; background: #efff32; box-shadow: 0 0 24px rgba(225,255,0,.8); }
.brand { display: flex; align-items: center; gap: 10px; }
.brand div { display: grid; }
.brand strong { color: #f7f8f9; font-size: 12px; letter-spacing: .09em; }
.brand small { margin-top: 3px; color: #99a0aa; font-size: 10px; }

button, .file {
  appearance: none;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 11px;
  background: rgba(255,255,255,.06);
  color: #f4f5f6;
  padding: 10px 13px;
  font-size: 12px;
  cursor: pointer;
}
button:hover, button.active { border-color: rgba(239,255,50,.72); background: rgba(239,255,50,.12); }
button.primary { color: #090a0b; background: #efff32; border-color: #efff32; font-weight: 820; }
button.primary:hover { background: #f6ff77; }
button.large { min-width: 210px; padding: 14px 20px; border-radius: 14px; font-size: 14px; }
button:disabled { opacity: .45; cursor: default; }

.operator-panel {
  position: absolute;
  z-index: 10;
  top: 18px;
  right: 18px;
  width: min(330px, calc(100% - 36px));
  max-height: calc(100% - 36px);
  overflow: auto;
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 20px;
  background: rgba(9,10,12,.76);
  box-shadow: 0 24px 70px rgba(0,0,0,.34);
  backdrop-filter: blur(22px);
}
.operator-panel header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
#hideUi { width: 34px; height: 34px; padding: 0; font-size: 20px; line-height: 1; }
.actions { display: grid; grid-template-columns: 1fr 44px; gap: 8px; }

fieldset { min-width: 0; margin: 0; padding: 12px; border: 1px solid rgba(255,255,255,.09); border-radius: 14px; }
legend { padding: 0 6px; color: #8f96a0; font-size: 9px; font-weight: 760; letter-spacing: .14em; text-transform: uppercase; }
.segmented { display: flex; gap: 6px; }
.segmented button { flex: 1; padding-inline: 8px; }
.toggles { display: grid; gap: 10px; }
.toggles label { display: flex; align-items: center; gap: 9px; color: #cbd0d7; font-size: 11px; }
.toggles input { width: 16px; height: 16px; accent-color: #efff32; }
.sliders { display: grid; gap: 10px; }
.sliders label { display: grid; grid-template-columns: 82px 1fr; align-items: center; gap: 8px; color: #cbd0d7; font-size: 10px; }
.sliders input { width: 100%; accent-color: #efff32; }
.presence-calibration label { grid-template-columns: minmax(112px, 1fr) minmax(88px, 1.2fr) 42px; }
.presence-calibration label:last-child { grid-template-columns: auto 1fr; }
.presence-calibration output { color: #efff32; font-variant-numeric: tabular-nums; text-align: right; }
.file { display: block; text-align: center; }
.file input { display: none; }
#diagnostic { margin: 0; color: #9ba2ac; font-size: 10px; line-height: 1.45; }
.shortcuts { margin: -2px 0 0; color: #6f7680; font-size: 9px; line-height: 1.6; }
kbd { padding: 2px 5px; border: 1px solid rgba(255,255,255,.16); border-radius: 5px; background: rgba(255,255,255,.06); color: #bec4cc; font: inherit; }

.reveal-ui {
  position: absolute;
  right: 18px;
  bottom: 18px;
  width: 48px;
  height: 36px;
  padding: 0;
  opacity: .32;
}

#loading {
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  padding: 14px 18px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 13px;
  background: rgba(0,0,0,.82);
  box-shadow: 0 16px 50px rgba(0,0,0,.35);
  color: #f1f3f4;
  font-size: 12px;
}

#toast {
  position: absolute;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 18px);
  max-width: min(520px, calc(100% - 40px));
  padding: 9px 13px;
  border-radius: 10px;
  background: rgba(8,9,11,.72);
  color: #d8dce1;
  font-size: 10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
#toast.visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 700px) {
  .welcome { padding: 26px 20px; }
  .operator-panel { top: 10px; right: 10px; width: calc(100% - 20px); max-height: calc(100% - 20px); }
}
