body.robot-mode {
  color: #eef4f2;
  background: #101719 radial-gradient(ellipse at 50% 38%, #20332f 0%, #101719 68%);
}

#robot-app {
  --iris: #a5edce;
  --quiet: #b4c4c0;
  background: transparent;
  justify-content: space-between;
  width: min(1260px, 100%);
  min-height: 100svh;
  margin-inline: auto;
  padding-inline: clamp(18px, 4vw, 52px);
}
body[data-theme=violet] #robot-app { --iris: #d3c4fc; }
body[data-theme=amber] #robot-app { --iris: #ffdb9b; }
#robot-app[hidden], #robot-app [hidden] { display: none !important; }
#robot-app:fullscreen { width: 100%; max-width: none; background: #101719 radial-gradient(ellipse at 50% 40%, #20332f, #101719 70%); }
#robot-app.presentation { position: fixed; inset: 0; width: 100%; max-width: none; overflow: auto; background: #101719 radial-gradient(ellipse at 50% 40%, #20332f, #101719 70%); }
#robot-app.presentation .robot-header { flex-shrink: 0; }

#robot-app .robot-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  padding-block: clamp(12px, 3vh, 24px);
  border-bottom: 1px solid #ffffff16;
}
#robot-app .robot-header .brand { justify-self: start; }
#robot-app .connection-pill { border-color: #ffffff24; background: transparent; color: var(--quiet); font-size: 11px; white-space: nowrap; }
#robot-app .connection-pill.offline { color: #f1b8a7; }
.robot-header-actions { display: flex; align-items: center; gap: 14px; justify-self: end; }
#robot-app .subtle-link { color: var(--quiet); text-decoration: none; font-size: 12px; white-space: nowrap; }

#robot-app .robot-stage { min-height: 0; justify-content: center; gap: 8px; padding-block: 18px; }
.robot-portrait { position: relative; display: grid; place-items: center; min-width: 0; }
.robot-response { width: min(100%, 530px); min-width: 0; }
#robot-app .robot-response h1 { color: #eff7f4; font-size: clamp(24px, 5vw, 42px); font-weight: 650; letter-spacing: -.055em; margin: 8px 0 0; }
#robot-app #robot-status, #task-status { color: var(--quiet); font-size: 13px; min-height: 1.3em; margin: 5px 0 0; }
#robot-app :is(#robot-caption, #task-summary) { margin: 10px 0 0; color: #e6eeec; font-size: clamp(15px, 2vw, 20px); line-height: 1.48; overflow-wrap: anywhere; }
#robot-app :is(#robot-caption, #task-status, #task-summary):empty { display: none; }
#robot-results { display: flex; align-items: center; flex-wrap: wrap; justify-content: center; gap: 8px; }
#robot-results:not(:empty) { margin-top: 11px; }

#robot-app .face {
  position: relative;
  isolation: isolate;
  display: block;
  width: clamp(174px, min(46vw, 39svh), 338px);
  aspect-ratio: 1.08;
  height: auto;
  margin: 0;
  padding: 9px;
  border: 1px solid #6c8881;
  border-radius: 50%;
  background: linear-gradient(145deg, #61786f 3%, #263d37 37%, #192823 78%);
  box-shadow: 0 22px 45px #0005, 0 0 60px #89eabb1c, inset 0 2px 0 #d4e7df44;
  filter: none;
  transition: rotate .32s ease;
  --eye-height: 1;
  --gaze-x: 0px;
  --gaze-y: 0px;
  --mouth-open: .10;
  --mouth-width: .92;
}
.face-inner { position: relative; height: 100%; border-radius: 50%; border: 1px solid #8ab4a136; background: radial-gradient(ellipse at 48% 22%, #2d4840, #142923 65%, #10221d); box-shadow: inset 0 5px 15px #0309084d; }
.robot-ear { position: absolute; z-index: -1; top: 40%; width: 11%; height: 24%; background: linear-gradient(135deg, #658175, #293e37 77%); border: 1px solid #6c8881; border-radius: 45%; }
.robot-ear.left { left: -7%; rotate: -11deg; }
.robot-ear.right { right: -7%; rotate: 11deg; }

#robot-app .eye {
  position: absolute;
  top: 33%;
  width: 22%;
  height: 32%;
  display: grid;
  place-items: center;
  background: var(--iris);
  border-radius: 49% 49% 45% 45%;
  box-shadow: 0 0 25px #8bffcf34, inset 0 -7px 10px #479a8450;
  overflow: hidden;
  scale: 1 var(--eye-height);
  transition: scale .28s, border-radius .28s, rotate .3s;
  animation: aafu-blink 7s ease-in-out infinite;
}
#robot-app .eye.left { left: 23%; }
#robot-app .eye.right { right: 23%; }
#robot-app .eye i {
  position: relative;
  top: auto;
  left: auto;
  display: block;
  width: 45%;
  height: 55%;
  border-radius: 50%;
  opacity: 1;
  background: #1b4038;
  translate: var(--gaze-x) var(--gaze-y);
  transition: translate .18s ease-out, opacity .2s;
}
#robot-app .eye i::before, #robot-app .eye i::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  background: #eefcf7;
}
#robot-app .eye i::before { width: 31%; aspect-ratio: 1; top: 16%; left: 19%; }
#robot-app .eye i::after { width: 14%; aspect-ratio: 1; right: 19%; bottom: 22%; opacity: .74; }
#robot-app .brow { top: 23%; width: 19%; height: 4%; border-radius: 75%; background: var(--iris); opacity: .54; transition: translate .25s, rotate .25s, opacity .2s; }
#robot-app .brow.left { left: 24%; }
#robot-app .brow.right { right: 24%; }
#robot-app .cheek { position: absolute; bottom: 23%; width: 13%; height: 6%; border-radius: 50%; opacity: .55; background: #f1a69d; filter: blur(1.5px); transition: opacity .3s; }
#robot-app .cheek.left { left: 19%; }
#robot-app .cheek.right { right: 19%; }
#robot-app .mouth {
  bottom: 20%;
  left: 42%;
  width: 16%;
  height: 9%;
  background: transparent;
  border: 0;
  border-bottom: 3px solid var(--iris);
  border-radius: 0 0 65% 65%;
  animation: none;
  transition: scale .14s, border-radius .2s;
}
#robot-app [data-expression=listening] { --eye-height: 1.11; }
#robot-app [data-expression=listening] .brow { translate: 0 -4px; }
#robot-app [data-expression=warm] { --eye-height: .89; }
#robot-app [data-expression=warm] .cheek, #robot-app [data-expression=happy] .cheek { opacity: .75; }
#robot-app [data-expression=happy] { --eye-height: .72; }
#robot-app [data-expression=happy] .eye { border-radius: 50% 50% 28% 28%; }
#robot-app [data-expression=amused] { --eye-height: .48; rotate: -5deg; }
#robot-app [data-expression=amused] .eye.left { rotate: -13deg; }
#robot-app [data-expression=amused] .eye.right { rotate: 13deg; }
#robot-app [data-expression=amused] .cheek { opacity: .95; }
#robot-app [data-expression=excited] { --eye-height: 1.13; }
#robot-app [data-expression=excited] .brow { translate: 0 -8px; opacity: .78; }
#robot-app [data-expression=excited] .mouth, #robot-app [data-expression=amused] .mouth { background: var(--iris); border: 0; }
#robot-app [data-expression=curious] { rotate: 6deg; }
#robot-app [data-expression=curious] .eye.left { scale: 1 .67; }
#robot-app [data-expression=curious] .brow.right { translate: 0 -8px; rotate: -13deg; }
#robot-app [data-expression=surprised] { --eye-height: 1.16; }
#robot-app [data-expression=surprised] .brow { translate: 0 -10px; }
#robot-app [data-expression=surprised] .mouth { left: 45%; width: 10%; height: 10%; border: 2px solid var(--iris); border-radius: 50%; }
#robot-app [data-expression=concerned] { --eye-height: .75; }
#robot-app [data-expression=concerned] .brow.left { rotate: -18deg; }
#robot-app [data-expression=concerned] .brow.right { rotate: 18deg; }
#robot-app [data-expression=concerned] .mouth { border: 0; border-top: 3px solid var(--iris); border-radius: 60% 60% 0 0; }
#robot-app [data-expression=proud] { --eye-height: .78; rotate: -4deg; }
#robot-app [data-expression=proud] .mouth { scale: 1.24 1; }
#robot-app [data-expression=sleepy] { --eye-height: .23; rotate: 4deg; }
#robot-app [data-expression=sleepy] .eye i { opacity: .1; }
#robot-app [data-speaking=true] .mouth {
  width: 18%;
  left: 41%;
  height: 13%;
  border: 2px solid var(--iris);
  border-radius: 42% 42% 58% 58%;
  background: #0c1d18;
  box-shadow: inset 0 -4px #bd807866;
  scale: var(--mouth-width) var(--mouth-open);
  transition: none;
}
@keyframes aafu-blink { 0%, 44%, 47%, 100% { transform: scaleY(1); } 45.5% { transform: scaleY(.09); } }

#robot-app .robot-controls { width: min(100%, 550px); margin: 0 auto max(16px, env(safe-area-inset-bottom)); }
#robot-app .control-row, .camera-controls { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; margin: 0 0 10px; }
.camera-controls { margin: 6px 0 0; }
#robot-app :is(.mode-button, .quiet-control, .talk-button, #robot-setup) { font: inherit; font-size: 13px; font-weight: 600; border-radius: 999px; min-height: 40px; }
#robot-app :is(.mode-button, #robot-setup, .talk-button) { padding: 10px 17px; border: 1px solid #93baac55; }
#robot-app :is(.mode-button, #robot-setup) { background: #22332e; color: #e8f4ef; }
#robot-app .talk-button { background: #baedcf; color: #152922; }
#robot-app .talk-button[aria-pressed=true], #robot-app .mode-button[aria-pressed=true] { background: #315047; color: #effcf7; }
#robot-app #stop { display: block; margin-inline: auto; }
#robot-app .quiet-control { background: transparent; color: var(--quiet); padding: 7px 9px; }
#robot-app .quiet-control[aria-pressed=true] { color: #c8efda; }
#robot-app .text-command { border: 1px solid #91b5a450; background: #1b2b27; border-radius: 16px; }
#robot-app .robot-options { justify-content: space-between; margin: 5px 0 0; gap: 4px; }
#robot-app :is(button, a, input):focus-visible { outline: 2px solid #baf5d7; outline-offset: 3px; }

.camera-indicator { color: #c7efd9; font-size: 12px; }
.camera-indicator::before { content: ''; display: inline-block; width: 7px; height: 7px; margin-inline-end: 6px; border-radius: 50%; background: currentColor; }
.camera-capture { position: fixed; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.voice-sources { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 9px; }
.voice-sources a { max-width: 18rem; padding: 5px 9px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: 1px solid #608173; border-radius: 12px; color: #e8f6ef; font-size: 12px; }
.voice-sources a:hover { background: #375349; }

.desktop-view {
  position: fixed;
  z-index: 20;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  width: min(760px, calc(100% - 24px));
  max-height: calc(100svh - 24px);
  overflow: auto;
  border: 1px solid #58756a;
  border-radius: 16px;
  background: #16231f;
  box-shadow: 0 18px 60px #0009;
  animation: screenshot-enter .17s ease-out both;
}
.desktop-view-header { display: flex; align-items: center; gap: 8px; padding: 12px; }
.desktop-heading { flex: 1; min-width: 0; }
.desktop-heading h2 { margin: 0; font-size: 15px; font-weight: 650; }
#desktop-task-state { display: block; margin-top: 3px; color: #bad5c8; font-size: 12px; }
.desktop-toolbar { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
#robot-app .desktop-action { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 7px 12px; border: 1px solid transparent; border-radius: 9px; font-family: inherit; font-size: 13px; font-weight: 650; line-height: 1.2; text-decoration: none; cursor: pointer; }
#robot-app .desktop-action[hidden] { display: none; }
#robot-app .desktop-action:disabled { opacity: .5; cursor: default; }
#robot-app .desktop-action:focus-visible { outline: 2px solid #f4fff8; outline-offset: 2px; }
#robot-app .desktop-primary { background: #baf4d3; color: #143629; }
#robot-app .desktop-secondary { color: #ebf8f0; background: #243831; border-color: #577065; }
#robot-app .desktop-danger { margin-inline-start: auto; background: #3f2729; color: #ffdbdc; border-color: #805154; }
.desktop-correction-status, .desktop-task-result { margin: 0 12px 12px; color: #dfefe7; font-size: 13px; overflow-wrap: anywhere; }
.desktop-task-result p { margin: 0 0 8px; }
.desktop-command-form { padding: 0 12px 12px; }
.desktop-command-form label { display: block; margin-bottom: 4px; color: #dfefe7; font-size: 13px; }
.desktop-command-form > div { display: flex; align-items: flex-end; gap: 8px; }
.desktop-command-form textarea { min-width: 0; flex: 1; resize: vertical; }
#robot-app .inbox-dialog { width: min(92vw, 540px); overflow: auto; }
.inbox-form, .inbox-notes { display: grid; gap: 10px; padding: 14px 18px; }
.inbox-form textarea { inline-size: 100%; min-block-size: 6rem; }
.inbox-form button { justify-self: start; }
.inbox-status { margin: 0 18px; color: #c8efda; }
.inbox-note { margin: 0; padding: 10px; border: 1px solid #4e6960; border-radius: 10px; white-space: pre-wrap; overflow-wrap: anywhere; }
#desktop-frame { display: block; width: 100%; height: min(48svh, 420px); min-height: 120px; border: 0; background: #080e0c; }

#robot-app .screenshot-dialog { width: min(92vw, 1100px); max-width: none; max-height: 92svh; padding: 0; border: 1px solid #4e6960; border-radius: 18px; overflow: hidden; color: #eff7f4; background: #192824; }
.screenshot-dialog[open] { animation: screenshot-enter .17s ease-out both; }
.screenshot-dialog.closing { animation: screenshot-exit .17s ease-in both; }
.screenshot-dialog::backdrop { background: #050a09cc; }
.screenshot-header { display: flex; align-items: center; gap: 5px; padding: 7px 13px; }
.screenshot-header h2 { flex: 1; margin: 0; font-size: clamp(13px, 2vw, 19px); overflow-wrap: anywhere; }
#robot-app #screenshot-close { font-size: 22px; }
.screenshot-image { height: min(70svh, 720px); display: grid; place-items: center; overflow: auto; padding: 8px; background: #0a100e; }
.screenshot-image img { display: block; width: 100%; height: 100%; min-height: 0; object-fit: contain; }
.screenshot-dialog.zoomed .screenshot-image { display: block; }
.screenshot-dialog.zoomed .screenshot-image img { width: max(145%, 850px); height: auto; max-width: none; }
@keyframes screenshot-enter { from { opacity: 0; translate: 0 8px; } to { opacity: 1; translate: 0 0; } }
@keyframes screenshot-exit { from { opacity: 1; } to { opacity: 0; translate: 0 7px; } }

@media (max-width: 490px) {
  .desktop-view-header, .desktop-toolbar { padding: 8px; }
  #robot-app .desktop-action { padding-inline: 9px; }
  #robot-app .desktop-danger { margin-inline-start: 0; }
  #robot-app .robot-header { grid-template-columns: auto 1fr auto; gap: 6px; }
  #robot-app .connection-pill { justify-self: center; padding-inline: 7px; }
  .robot-header-actions { gap: 4px; }
  #robot-app .robot-header .quiet-control { font-size: 11px; padding-inline: 4px; }
  #robot-app .robot-header .subtle-link { font-size: 11px; }
}
@media (orientation: landscape) and (min-width: 600px) {
  #robot-app .robot-stage { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; justify-items: center; width: min(100%, 900px); align-self: center; }
  .robot-response { justify-self: start; text-align: left; }
  #robot-results { justify-content: start; }
  #robot-app .face { width: clamp(136px, min(32vw, 46svh), 338px); }
}
@media (orientation: landscape) and (max-height: 480px) {
  #robot-app .robot-stage { padding-block: 10px; }
  #robot-app .robot-header { padding-block: 7px; }
  #robot-app .control-row { margin-bottom: 4px; }
  #robot-app .robot-controls { margin-bottom: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  #robot-app .face, #robot-app .face *, .screenshot-dialog[open], .desktop-view { animation: none; transition: none; }
}
