/* Jarvis Mobile — tema, layout e estados do rosto.
   O rosto só anima transform e opacity; o brilho vem de gradientes radiais
   estáticos, sem filtros, porque a tela fica ligada por muito tempo. */

:root {
  color-scheme: dark;
  --bg: #000000;
  --face: #ffffff;
  --face-off: #666666;
  --text: #f5f5f5;
  --muted: #a3a3a3;
  --faint: #737373;
  --amber: #e5e5e5;
  --surface: #111111;
  --surface-2: #1c1c1c;
  --line: rgb(255 255 255 / 0.08);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overscroll-behavior: none;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--text);
}

button,
a,
select,
summary,
[role="button"],
[role="switch"] {
  touch-action: manipulation;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

input,
select,
textarea {
  font: inherit;
  font-size: 16px;
}

code {
  font-family: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  font-size: 0.92em;
}

:focus-visible {
  outline: 2px solid var(--face);
  outline-offset: 3px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Layout ---------- */

.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100vh;
  height: 100dvh;
  padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px 0 18px;
}

.topbar-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.conn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  min-width: 0;
}

#conn-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conn-dot { flex-shrink: 0; }

/* Espelho da área de trabalho: ocupa a tela e respeita teclado/safe areas. */
dialog.sheet.desktop-sheet {
  inset: 0;
  width: 100%;
  max-width: none;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  transform: none;
}
.desktop-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto auto minmax(80px, 1fr) auto auto;
  gap: 10px;
  height: 100%;
  padding: max(12px, var(--safe-top)) max(12px, var(--safe-right)) max(12px, var(--safe-bottom)) max(12px, var(--safe-left));
}
.desktop-inner .sheet-title { font-size: 22px; margin: 0; }
.desktop-inner .sheet-header { min-width: 0; margin-right: 0; }
.desktop-toolbar, .desktop-type, .desktop-keys { display: flex; align-items: center; gap: 8px; min-width: 0; }
.desktop-toolbar .field { width: auto; min-width: 0; padding: 9px; flex: 1; }
.desktop-control-label { display: flex; align-items: center; gap: 6px; font-size: 14px; white-space: nowrap; }
.desktop-control-label input { width: 20px; height: 20px; accent-color: var(--face); }
.desktop-status { min-height: 18px; margin: 0; font-size: 12px; color: var(--face); }
.desktop-status.is-error { color: var(--amber); }
.desktop-viewport { overflow: auto; min-width: 0; min-height: 0; background: #000; border: 1px solid var(--line); border-radius: 10px; overscroll-behavior: contain; }
#desktop-canvas { display: block; height: auto; margin: auto; touch-action: pan-x pan-y; }
#desktop-canvas[hidden] { display: none; }
#desktop-canvas[data-control="true"] { touch-action: none; cursor: crosshair; }
.desktop-empty { color: var(--muted); text-align: center; padding: 24px; font-size: 14px; }
.desktop-controls { border: 0; margin: 0; padding: 0; min-width: 0; }
.desktop-controls:disabled { opacity: 0.5; }
.desktop-keys { overflow-x: auto; padding-bottom: 8px; overscroll-behavior: contain; }
.desktop-keys > * { flex-shrink: 0; white-space: nowrap; }
.desktop-keys .field { width: auto; padding: 9px; }
.desktop-type .field { flex: 1; min-width: 0; }
.desktop-help { margin: 0; font-size: 11px; line-height: 1.4; color: var(--muted); }
@media (orientation: landscape) and (max-height: 500px) {
  .desktop-inner { gap: 5px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: auto auto minmax(80px, 1fr) auto; }
  .desktop-status, .desktop-viewport, .desktop-controls { grid-column: 1 / -1; }
  .desktop-help { display: none; }
  .desktop-controls { display: flex; gap: 8px; }
  .desktop-keys, .desktop-type { flex: 1; }
  .desktop-keys { padding-bottom: 0; }
}

.conn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--faint);
}

.conn[data-state="online"] .conn-dot {
  background: var(--face);
  box-shadow: 0 0 8px rgb(255 255 255 / 0.7);
}

.conn[data-state="offline"] .conn-dot,
.conn[data-state="auth"] .conn-dot,
.conn[data-state="error"] .conn-dot {
  background: var(--amber);
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  transition: transform 120ms var(--ease-out), background-color 120ms var(--ease-out), color 120ms var(--ease-out);
}

.icon-btn svg,
.send-btn svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-btn:active {
  transform: scale(0.94);
  background: var(--surface-2);
  color: var(--text);
}

.icon-btn[aria-expanded="true"] {
  color: var(--face);
}

.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(4px, 2.5dvh, 24px);
  min-width: 0;
  min-height: 0;
  padding: 0 16px;
}

.face-btn {
  display: block;
  width: min(100%, 520px, 66dvh);
  padding: 0;
  border: 0;
  border-radius: 28px;
  background: none;
  transition: transform 140ms var(--ease-out);
}

.face-btn:active {
  transform: scale(0.97);
}

.face-btn:focus-visible {
  outline-offset: -4px;
}

.caption {
  display: grid;
  gap: 8px;
  width: min(100%, 560px);
  text-align: center;
}

.heard {
  display: -webkit-box;
  min-height: 1.4em;
  margin: 0;
  overflow: hidden;
  font-size: 14px;
  line-height: 1.4;
  color: var(--muted);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow-wrap: anywhere;
}

.heard.is-live {
  color: #b8b8b8;
}

.reply {
  min-height: calc(1.4em * 3);
  max-height: calc(1.4em * 3);
  margin: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  font-size: clamp(17px, 4.6vw, 21px);
  line-height: 1.4;
  color: var(--text);
  overflow-wrap: anywhere;
  text-wrap: pretty;
  scrollbar-width: none;
}

.reply::-webkit-scrollbar {
  display: none;
}

.reply.is-overflowing {
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 1.2em);
  mask-image: linear-gradient(to bottom, transparent 0, #000 1.2em);
}

.reply.is-progress {
  color: #f5f5f5;
}

.reply.is-error {
  color: var(--amber);
}

.reply.is-info {
  color: #d4d4d4;
}

.reply.is-reminder {
  font-weight: 600;
  color: var(--text);
}

.reply .w {
  animation: word-in 220ms var(--ease-out) both;
}

@keyframes word-in {
  from {
    opacity: 0;
  }
}

.footer {
  display: grid;
  align-content: center;
  min-height: 64px;
  padding: 6px 16px 14px;
}

.hint {
  margin: 0;
  font-size: 14px;
  line-height: 1.4;
  text-align: center;
  color: var(--muted);
}

.hint.is-emphasis {
  color: var(--face);
  animation: hint-breathe 2.4s ease-in-out infinite;
}

@keyframes hint-breathe {
  50% {
    opacity: 0.55;
  }
}

.composer {
  display: flex;
  gap: 8px;
}

.composer[hidden] {
  display: none;
}

.composer .field {
  flex: 1;
  min-width: 0;
}

.send-btn {
  display: grid;
  flex: none;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: var(--face);
  color: #111111;
  transition: transform 120ms var(--ease-out);
}

.send-btn:active {
  transform: scale(0.95);
}

/* ---------- Form controls ---------- */

.field {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 16px;
  transition: border-color 120ms var(--ease-out);
}

.field:focus {
  border-color: rgb(255 255 255 / 0.55);
  outline: none;
}

.field::placeholder {
  color: var(--faint);
}

select.field {
  padding-right: 10px;
}

.field-label {
  display: block;
  margin: 14px 0 6px;
  font-size: 14px;
  color: var(--muted);
}

.field-help,
.field-error {
  margin: 8px 0 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
}

.field-error {
  min-height: 1.45em;
  color: var(--amber);
}

.field-help:empty {
  display: none;
}

.inline-field {
  display: flex;
  gap: 8px;
}

.btn {
  height: 50px;
  padding: 0 18px;
  border: 0;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 600;
  transition: transform 120ms var(--ease-out), background-color 120ms var(--ease-out), opacity 120ms var(--ease-out);
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.5;
  pointer-events: none;
}

.btn-primary {
  background: var(--face);
  color: #111111;
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
}

.btn-compact {
  flex: none;
  height: 48px;
}

.btn-block {
  width: 100%;
}

.link-btn {
  margin-top: 10px;
  padding: 6px 0;
  border: 0;
  background: none;
  font-size: 14px;
  color: var(--amber);
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 4px 0;
}

.switch-row strong {
  display: block;
  font-size: 15px;
  font-weight: 600;
}

.switch-row small {
  display: block;
  margin-top: 2px;
  font-size: 13px;
  color: var(--muted);
}

.switch {
  position: relative;
  flex: none;
  width: 48px;
  height: 28px;
  margin: 0;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  appearance: none;
  -webkit-appearance: none;
  transition: background-color 160ms var(--ease-out);
}

.switch::before {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--muted);
  content: "";
  transition: transform 160ms var(--ease-out), background-color 160ms var(--ease-out);
}

.switch:checked {
  background: rgb(255 255 255 / 0.3);
}

.switch:checked::before {
  background: var(--face);
  transform: translateX(20px);
}

@media (hover: hover) and (pointer: fine) {
  .icon-btn:hover {
    background: var(--surface);
    color: var(--text);
  }

  .btn-secondary:hover {
    background: #262626;
  }
}

/* ---------- Bottom sheets ---------- */

dialog.sheet {
  position: fixed;
  inset: auto 0 0;
  width: min(100%, 560px);
  max-width: 100%;
  max-height: min(88dvh, 760px);
  margin: 0 auto;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 22px 22px 0 0;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 -12px 40px rgb(0 0 0 / 0.55);
  transform: translateY(100%);
  transition: transform 280ms var(--ease-out);
  transition: transform 280ms var(--ease-out), overlay 280ms var(--ease-out) allow-discrete, display 280ms var(--ease-out) allow-discrete;
}

dialog.sheet[open] {
  transform: translateY(0);
}

@starting-style {
  dialog.sheet[open] {
    transform: translateY(100%);
  }
}

dialog.sheet::backdrop {
  background: rgb(0 0 0 / 0.6);
  opacity: 0;
  transition: opacity 280ms var(--ease-out);
  transition: opacity 280ms var(--ease-out), overlay 280ms var(--ease-out) allow-discrete, display 280ms var(--ease-out) allow-discrete;
}

dialog.sheet[open]::backdrop {
  opacity: 1;
}

@starting-style {
  dialog.sheet[open]::backdrop {
    opacity: 0;
  }
}

.sheet-inner {
  max-height: inherit;
  margin: 0;
  padding: 8px 20px calc(20px + var(--safe-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sheet-grabber {
  width: 38px;
  height: 4px;
  margin: 0 auto 14px;
  border-radius: 2px;
  background: rgb(255 255 255 / 0.18);
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-right: -10px;
}

.sheet-eyebrow {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--amber);
}

.sheet-title {
  margin: 0;
  font-size: 20px;
  font-weight: 650;
  line-height: 1.3;
}

.sheet-text,
.settings-text {
  margin: 10px 0 0;
  font-size: 14px;
  line-height: 1.5;
  color: #c2c2c2;
}

.sheet-meta {
  margin: 6px 0 0;
  font-size: 14px;
  color: var(--muted);
}

.sheet-note {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.sheet-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

.approval-summary {
  max-height: 32dvh;
  margin: 14px 0 0;
  padding: 12px 14px;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0a0a0a;
  font-family: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: #e5e5e5;
}

.settings-group {
  padding: 18px 0;
  border-top: 1px solid var(--line);
}

.settings-group:first-of-type {
  margin-top: 12px;
}

.settings-group h3 {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 600;
}

.settings-value {
  margin: 0;
  font-size: 14px;
  color: #c2c2c2;
  overflow-wrap: anywhere;
}

.face-colors {
  min-width: 0;
  margin: 14px 0 18px;
  padding: 0;
  border: 0;
}

.face-colors legend {
  margin-bottom: 10px;
  padding: 0;
  font-size: 14px;
  color: var(--muted);
}

.face-color-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.face-color-option {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 52px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  cursor: pointer;
}

.face-color-option input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.face-color-swatch {
  flex: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--swatch);
}

.face-color-name {
  font-size: 13px;
  color: var(--muted);
}

.face-color-option input:checked ~ .face-color-swatch {
  box-shadow: 0 0 0 3px var(--surface-2), 0 0 0 5px var(--swatch);
}

.face-color-option input:checked ~ .face-color-name {
  color: var(--text);
  font-weight: 600;
}

.face-color-option:focus-within {
  outline: 2px solid var(--swatch);
  outline-offset: 2px;
}

@media (max-width: 360px) {
  .face-color-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ---------- Histórico ---------- */

.history-list {
  display: grid;
  gap: 10px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

.history-item {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
}

.history-item[data-role="user"] {
  margin-left: 28px;
  background: transparent;
}

.history-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 4px;
  font-size: 12px;
  color: var(--muted);
}

.history-who {
  font-weight: 600;
}

.history-item[data-role="assistant"] .history-who {
  color: var(--face);
}

.history-item[data-role="error"] .history-who,
.history-item[data-role="error"] .history-text,
.history-item[data-role="reminder"] .history-who {
  color: var(--amber);
}

.history-text {
  margin: 0;
  font-size: 15px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.history-empty {
  margin: 18px 0 4px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
}

#history-clear {
  margin-top: 16px;
}

.history-list[hidden],
.history-empty[hidden],
#history-clear[hidden] {
  display: none;
}

/* ---------- O rosto ---------- */

.face {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  color: var(--face);
}

.face[data-state="offline"] {
  color: var(--face-off);
}

.face * {
  transform-box: fill-box;
  transform-origin: center;
}

.face stop {
  stop-color: currentColor;
}

.iris {
  fill: currentColor;
  transition: opacity 160ms var(--ease-out);
}

.eye-happy,
.mouth-smile,
.mouth-line,
.mouth-sad,
.mouth-o {
  fill: none;
  stroke: currentColor;
  stroke-width: 12;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.eye-happy {
  stroke-width: 13;
  opacity: 0;
  transition: opacity 160ms var(--ease-out);
}

.mouth-open {
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 7;
  stroke-linejoin: round;
  transform-origin: 50% 0%;
}

.gaze {
  transition: transform 700ms var(--ease-out);
}

.gaze.is-tracking {
  transition-duration: 140ms;
}

.eye {
  /* Mesmo brilho da boca; os estados mudam só o tamanho e o halo. */
  opacity: 1;
  transform: scale(0.94);
  transition: transform 280ms var(--ease-out), opacity 280ms var(--ease-out);
}

.lid {
  transition: transform 220ms var(--ease-out);
}

.halo {
  opacity: 0.35;
  transition: opacity 300ms var(--ease-out), transform 300ms var(--ease-out);
}

.mouth-glow {
  opacity: 0.6;
  transition: opacity 300ms var(--ease-out);
}

.mouth-shape {
  opacity: 0;
  transition: opacity 180ms var(--ease-out), transform 260ms var(--ease-out);
}

.mouth-smile {
  opacity: 1;
  transform: scale(0.78);
}

/* standby: espera a palavra "Jarvis" — respiração lenta */
.face[data-state="standby"] .face-root {
  animation: breathe 5.2s ease-in-out infinite;
}

@keyframes breathe {
  50% {
    transform: translateY(-4px) scale(1.025);
  }
}

.face[data-state="standby"] .halo {
  animation: idle-glow 5.2s ease-in-out infinite;
}

@keyframes idle-glow {
  50% { opacity: 0.55; }
}

/* Expressões breves e espaçadas, escolhidas por face.js apenas em repouso. */
.face[data-state="standby"][data-idle="curious"] .face-root {
  animation: idle-curious 3.2s ease-in-out both;
}

@keyframes idle-curious {
  0%, 100% { transform: rotate(0deg) translateY(0); }
  28%, 48% { transform: rotate(-6deg) translateY(-3px); }
  72% { transform: rotate(3deg) translateY(-2px); }
}

.face[data-state="standby"][data-idle="smile"] .iris {
  animation: idle-hide 3.2s ease-in-out both;
}

.face[data-state="standby"][data-idle="smile"] .eye-happy {
  animation: idle-show 3.2s ease-in-out both;
}

.face[data-state="standby"][data-idle="smile"] .mouth-smile,
.face[data-state="standby"][data-idle="wink"] .mouth-smile {
  animation: idle-grin 3.2s ease-in-out both;
}

@keyframes idle-hide {
  0%, 100% { opacity: 1; }
  22%, 72% { opacity: 0; }
}

@keyframes idle-show {
  0%, 100% { opacity: 0; }
  22%, 72% { opacity: 1; }
}

@keyframes idle-grin {
  0%, 100% { transform: scale(0.78); }
  30%, 65% { transform: scale(1.06); }
}

.face[data-state="standby"][data-idle="wink"] .eye:last-child .lid {
  animation: idle-wink 3.2s ease-in-out both;
}

@keyframes idle-wink {
  0%, 24%, 44%, 100% { transform: scaleY(1); }
  30%, 36% { transform: scaleY(0.08); }
}

.face[data-state="standby"][data-idle-animations="false"] * {
  animation: none !important;
}

.face.is-hidden * {
  animation-play-state: paused !important;
}

/* wake: ouviu "Jarvis" — olhos crescem com mola e acendem */
.face[data-state="wake"] .eye {
  opacity: 1;
  transform: scale(1.16);
  transition-duration: 300ms;
  transition-timing-function: var(--ease-spring);
}

.face[data-state="wake"] .halo {
  opacity: 0.85;
  animation: flare 600ms var(--ease-out) both;
}

.face[data-state="wake"] .mouth-smile {
  transform: scale(1);
}

@keyframes flare {
  0% {
    opacity: 0.35;
    transform: scale(0.85);
  }

  35% {
    opacity: 1;
    transform: scale(1.3);
  }

  100% {
    opacity: 0.85;
    transform: scale(1.08);
  }
}

/* listening: capturando o comando */
.face[data-state="listening"] .eye {
  opacity: 1;
  transform: scale(1.07);
}

.face[data-state="listening"] .halo {
  opacity: 0.8;
  animation: glow-pulse 1.5s ease-in-out infinite alternate;
}

.face[data-state="listening"] .mouth-smile {
  transform: scale(0.9);
}

@keyframes glow-pulse {
  from {
    opacity: 0.55;
    transform: scale(0.96);
  }

  to {
    opacity: 1;
    transform: scale(1.12);
  }
}

/* thinking: aguardando o servidor — olhar de lado a lado, boca em linha */
.face[data-state="thinking"] .eye {
  opacity: 1;
  transform: scale(0.98);
}

.face[data-state="thinking"] .scan {
  animation: scan 2s ease-in-out infinite;
}

.face[data-state="thinking"] .mouth-smile {
  opacity: 0;
  transform: scale(0.6);
}

.face[data-state="thinking"] .mouth-line {
  opacity: 1;
  transform: scaleX(0.7);
}

@keyframes scan {
  25% {
    transform: translateX(-15px);
  }

  75% {
    transform: translateX(15px);
  }
}

/* working: ferramenta rodando — olhos semicerrados, concentrado */
.face[data-state="working"] .eye {
  opacity: 1;
  transform: scale(1);
}

.face[data-state="working"] .lid {
  transform: scaleY(0.42);
}

.face[data-state="working"] .halo {
  opacity: 0.7;
  animation: glow-pulse 0.9s ease-in-out infinite alternate;
}

.face[data-state="working"] .mouth-smile {
  opacity: 0;
}

.face[data-state="working"] .mouth-line {
  opacity: 1;
  transform: scaleX(0.5);
}

/* speaking: resposta chegando — a boca abre a cada palavra (face.js) */
.face[data-state="speaking"] .eye {
  opacity: 1;
  transform: scale(1);
}

.face[data-state="speaking"] .mouth-smile {
  opacity: 0;
}

.face[data-state="speaking"] .mouth-open {
  opacity: 1;
  transform: scaleY(0.3);
}

.face[data-state="speaking"] .mouth-glow {
  opacity: 0.9;
}

/* success: olhos em arco, sorriso aberto */
.face[data-state="success"] .eye {
  opacity: 1;
  transform: scale(1.04);
}

.face[data-state="success"] .iris {
  opacity: 0;
}

.face[data-state="success"] .eye-happy {
  opacity: 1;
}

.face[data-state="success"] .halo {
  opacity: 0.7;
}

.face[data-state="success"] .mouth-smile {
  transform: scale(1.12);
}

/* approval: olhos arregalados enquanto espera "Permitir / Negar" */
.face[data-state="approval"] .eye {
  opacity: 1;
  transform: scale(1.26);
  transition-timing-function: var(--ease-spring);
}

.face[data-state="approval"] .halo {
  opacity: 0.9;
}

.face[data-state="approval"] .mouth-smile {
  opacity: 0;
}

.face[data-state="approval"] .mouth-o {
  opacity: 1;
}

/* reminder: um lembrete do PC chegou — olhos crescem e o brilho pulsa duas vezes */
.face[data-state="reminder"] .eye {
  opacity: 1;
  transform: scale(1.18);
  transition-duration: 300ms;
  transition-timing-function: var(--ease-spring);
}

.face[data-state="reminder"] .halo {
  opacity: 0.85;
  animation: nudge 900ms var(--ease-out) 2 both;
}

.face[data-state="reminder"] .mouth-smile {
  transform: scale(1.06);
}

@keyframes nudge {
  0%,
  100% {
    opacity: 0.6;
    transform: scale(1);
  }

  35% {
    opacity: 1;
    transform: scale(1.28);
  }
}

/* error: olhos menores, boca triste */
.face[data-state="error"] .eye {
  opacity: 1;
  transform: scale(0.72);
}

.face[data-state="error"] .halo {
  opacity: 0.2;
}

.face[data-state="error"] .mouth-smile {
  opacity: 0;
}

.face[data-state="error"] .mouth-sad {
  opacity: 1;
}

/* offline: olhos cinza, boca reta */
.face[data-state="offline"] .eye {
  opacity: 1;
  transform: scale(0.88);
}

.face[data-state="offline"] .halo,
.face[data-state="offline"] .mouth-glow,
.face[data-state="offline"] .mouth-smile {
  opacity: 0;
}

.face[data-state="offline"] .mouth-line {
  opacity: 1;
}

/* ---------- Movimento reduzido ---------- */

@media (prefers-reduced-motion: reduce) {
  .face *,
  .hint.is-emphasis,
  .reply .w {
    animation: none !important;
  }

  .eye,
  .lid,
  .halo,
  .gaze,
  .mouth-shape {
    transition-property: opacity;
    transition-duration: 150ms;
  }

  dialog.sheet,
  dialog.sheet::backdrop {
    transition: opacity 150ms linear;
  }

  dialog.sheet {
    transform: none;
  }

  @starting-style {
    dialog.sheet[open] {
      transform: none;
    }
  }
}
