:root {
  color-scheme: dark;
  --bg: #101a1e;
  --panel: #172329;
  --line: #2c3b40;
  --text: #e6eeeb;
  --muted: #92a7aa;
  --accent: #b1d6b7;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font:
    14px/1.5 system-ui,
    sans-serif;
}
header {
  height: 76px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
}
.brand {
  font-size: 25px;
  font-weight: 800;
  color: var(--accent);
}
.brand span {
  font-size: 9px;
  letter-spacing: 2px;
  display: inline-block;
  width: 94px;
  line-height: 1.5;
  margin-left: 10px;
}
.project {
  margin: auto;
  font-size: 10px;
  letter-spacing: 3px;
  color: var(--muted);
}
.project b {
  display: block;
  color: var(--text);
  font-size: 15px;
  letter-spacing: 5px;
}
button,
.load {
  font: inherit;
  border: 1px solid #425452;
  color: var(--text);
  background: #233331;
  border-radius: 7px;
  padding: 9px 13px;
  cursor: pointer;
}
button:hover,
.load:hover {
  background: #344e43;
}
button[aria-pressed="true"],
.primary {
  background: var(--accent);
  color: #16251d;
}
.load {
  white-space: nowrap;
}
main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 350px;
  height: calc(100vh - 76px);
}
#stage {
  position: relative;
  min-height: 580px;
  overflow: hidden;
  background: radial-gradient(
    ellipse at 50% 55%,
    #344d4b 0,
    #19292d 52%,
    #101a1e 100%
  );
}
#view {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}
.stage-title {
  position: absolute;
  top: 27px;
  left: 30px;
  pointer-events: none;
  z-index: 1;
}
.eyebrow {
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--accent);
}
h1 {
  font:
    normal 30px/1.16 Georgia,
    serif;
  margin: 12px 0;
}
#status {
  font-size: 11px;
  color: var(--muted);
  max-width: 240px;
}
.view-tools {
  position: absolute;
  left: 25px;
  bottom: 49px;
  display: flex;
  gap: 7px;
}
.view-tools button {
  font-size: 12px;
  background: #152420da;
}
.hint {
  position: absolute;
  bottom: 21px;
  left: 28px;
  font-size: 9px;
  letter-spacing: 1.6px;
  color: var(--muted);
}
aside {
  padding: 25px 22px;
  overflow: auto;
  border-left: 1px solid var(--line);
  background: var(--panel);
}
h2 {
  font:
    normal 27px Georgia,
    serif;
  margin: 7px 0;
}
.panel-heading p {
  color: var(--muted);
  font-size: 12px;
  margin: 9px 0 24px;
}
.card {
  border-top: 1px solid var(--line);
  padding: 17px 0;
}
h3 {
  font-weight: 600;
  font-size: 14px;
  margin: 0 0 15px;
  display: flex;
  justify-content: space-between;
}
h3 span {
  font: 11px monospace;
  color: #76908a;
}
label {
  display: block;
  font-size: 12px;
  color: #c6d6d3;
  margin: 12px 0;
}
select {
  display: block;
  width: 100%;
  padding: 10px;
  margin-top: 6px;
  background: #101d21;
  color: var(--text);
  border: 1px solid #394c4b;
  border-radius: 6px;
  font: inherit;
}
.row {
  display: flex;
  gap: 8px;
}
.row button {
  flex: 1;
}
input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  display: block;
  margin: 10px 0 2px;
  cursor: pointer;
}
output {
  float: right;
  color: var(--accent);
  font: 12px monospace;
}
.small,
.footnote {
  font-size: 11px;
  color: var(--muted);
}
.footnote {
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
#error {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 110px;
  background: #512e29;
  border: 1px solid #b9896f;
  padding: 18px;
  border-radius: 9px;
}
button:disabled,
select:disabled,
input:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
:focus-visible {
  outline: 2px solid #d5e8bd;
  outline-offset: 3px;
}
@media (max-width: 800px) {
  header {
    padding: 0 16px;
    gap: 8px;
  }
  .brand span,
  .project {
    display: none;
  }
  .brand {
    margin-right: auto;
  }
  main {
    display: block;
    height: auto;
  }
  #stage {
    height: 66vh;
    min-height: 490px;
  }
  aside {
    overflow: visible;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
  .stage-title {
    left: 20px;
    top: 20px;
  }
  h1 {
    font-size: 24px;
  }
  .view-tools {
    left: 15px;
    gap: 5px;
  }
  .view-tools button {
    padding: 8px;
  }
  .hint {
    left: 18px;
    font-size: 8px;
  }
}

.view-tools button[aria-pressed="true"] {
  background: var(--accent);
  color: #16251d;
}

.contact-mode aside .card:not(:has(#physics-mode)),
.contact-mode .footnote {
  display: none;
}
.contact-mode #skeleton,
.contact-mode #wire {
  display: none;
}
#physics-sway {
  margin-top: 12px;
}

/* The art stage keeps only expressions and playback. Engineering controls are
   retained at ?studio=1 for regression work without cluttering the showcase. */
body:not(.studio) aside > .card:not(#acting-card),
body:not(.studio) aside > .footnote,
body:not(.studio) header .load,
body:not(.studio) #original,
body:not(.studio) #performer-model,
body:not(.studio) #skeleton,
body:not(.studio) #wire {
  display: none;
}
.animation-heading {
  margin-top: 32px;
}
#choreography-play {
  margin: 12px 0;
  width: 100%;
}
#acting-card button[aria-pressed="true"] {
  background: var(--accent);
  color: #16251d;
}

header a.brand { color: inherit; text-decoration: none; }

/* Minimal public stage. Full authoring controls remain available in studio mode. */
body:not(.studio) header,
body:not(.studio) .stage-title > .eyebrow,
body:not(.studio) .view-tools,
body:not(.studio) .hint,
body:not(.studio) .panel-heading,
body:not(.studio) #acting-card > .small,
body:not(.studio) .animation-heading,
body:not(.studio) label[for="choreography"],
body:not(.studio) #choreography,
body:not(.studio) #acting-card > .row:has(#act-stop),
body:not(.studio) #dp-analytics-choice {
  display: none;
}
body:not(.studio) #status {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
body:not(.studio) main { height: 100dvh; }
body:not(.studio) #acting-card { border-top: 0; padding-top: 0; }
body:not(.studio) #acting-card > .row { margin-bottom: 8px; }
body:not(.studio) #choreography-play { margin-top: 20px; }
@media (max-width: 800px) {
  body:not(.studio) main { height: auto; }
}

.magic-background {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
#view { position: relative; }
.magic-glyph {
  position: absolute;
  color: #a0d9bf;
  opacity: .3;
  filter: blur(2px);
  transform: translate(-50%, -50%);

}
.magic-glyph:nth-child(3n) { color: #c6bb8f; filter: blur(3px); opacity: .23; }
.magic-glyph svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.magic-glyph svg:first-child { animation: glyph-first var(--cycle) ease-in-out var(--delay) infinite; }
.magic-glyph svg:last-child { animation: glyph-next var(--cycle) ease-in-out var(--delay) infinite; }

@keyframes glyph-first {
  0%, 30%, 100% { opacity: 1; }
  48%, 82% { opacity: 0; }
}
@keyframes glyph-next {
  0%, 30%, 100% { opacity: 0; }
  48%, 82% { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .magic-glyph, .magic-glyph svg { animation: none !important; }
  .magic-glyph svg:last-child { opacity: 0; }
}

/* Ethereal expression arc: the full viewport belongs to the character. */
body:not(.studio) main { display: block; position: relative; }
body:not(.studio) #stage { height: 100dvh; min-height: 540px; }
body:not(.studio) aside {
  position: absolute; right: clamp(18px, 5vw, 90px); top: 50%;
  transform: translateY(-50%); width: 240px; height: 430px;
  padding: 0; overflow: visible; background: none; border: 0;
  pointer-events: none;
}
body:not(.studio) #acting-card { position: relative; height: 100%; padding: 0; }
body:not(.studio) #acting-card > h3,
body:not(.studio) #choreography-play { display: none; }
body:not(.studio) #acting-card > .row:not(:has(#act-stop)) { display: contents; }
body:not(.studio) #acting-card [id^="expression-"] {
  position: absolute; pointer-events: auto; width: 170px; min-height: 48px;
  padding: 8px; border: 0; background: transparent; color: #c4ded3;
  font: italic 22px/1.3 Georgia, serif; letter-spacing: .025em;
  text-shadow: 0 0 12px #a7dbbe66; transform: translate(-50%, -50%);
  animation: spectral-word 9s ease-in-out infinite;
}
body:not(.studio) #expression-Surprised { left: 23%; top: 5%; animation-delay: -1s; }
body:not(.studio) #expression-Angry { left: 53%; top: 23%; animation-delay: -5s; }
body:not(.studio) #expression-Squinty { left: 69%; top: 41%; animation-delay: -3s; }
body:not(.studio) #expression-Neutral { left: 69%; top: 59%; animation-delay: -7s; }
body:not(.studio) #expression-BrowRaise { left: 53%; top: 77%; animation-delay: -2s; }
body:not(.studio) #expression-Wink { left: 23%; top: 95%; animation-delay: -6s; }
@keyframes spectral-word {
  0%, 100% { opacity: .88; filter: blur(0); }
  50% { opacity: .46; filter: blur(1.2px); }
}
body:not(.studio) #acting-card [id^="expression-"]:is(:hover, :focus-visible, [aria-pressed="true"]) {
  animation: none; opacity: 1; filter: none; color: #edfff0;
  text-shadow: 0 0 18px #b7ffd0aa;
}
@media (max-width: 800px) {
  body:not(.studio) aside { right: 10px; width: 130px; height: 350px; top: 55%; }
  body:not(.studio) #acting-card [id^="expression-"] { width: 120px; font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  body:not(.studio) #acting-card [id^="expression-"] { animation: none; opacity: .85; filter: none; }
}

/* Five emotional intentions, each played by the face and all six arms. */
body:not(.studio) #acting-card #expression-Surprised,
body:not(.studio) #acting-card #expression-Squinty,
body:not(.studio) #acting-card #expression-Neutral,
body:not(.studio) #acting-card #expression-BrowRaise,
body:not(.studio) #acting-card #expression-Wink { display: none; }
body:not(.studio) #expression-Happy { left: 23%; top: 8%; animation-delay: -1s; }
body:not(.studio) #expression-Angry { left: 57%; top: 29%; animation-delay: -5s; }
body:not(.studio) #expression-Sad { left: 69%; top: 50%; animation-delay: -3s; }
body:not(.studio) #expression-Curious { left: 57%; top: 71%; animation-delay: -7s; }
body:not(.studio) #expression-Clever { left: 23%; top: 92%; animation-delay: -2s; }
