* {
  box-sizing: border-box;
}

:root {
  color-scheme: dark;
  --background: #050916;
  --ink: #e9f7ff;
  --muted: #a8bfce;
  --cyan: #83e3f7;
  --warning: #ffce9e;
  --stroke: #496078;
  --surface: #0b1724;
}

html,
body,
main {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--background);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

[hidden] {
  display: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.hud {
  position: absolute;
  inset: clamp(20px, 5vh, 50px) 16px auto clamp(16px, 5vw, 72px);
  pointer-events: none;
}

.brand {
  font-size: 1.0625rem;
  font-weight: 800;
  letter-spacing: .32em;
}

.brand span,
.hud #status {
  color: var(--cyan);
}

.subtitle,
.hud #status {
  margin-top: 9px;
  font-size: .8125rem;
}

.subtitle {
  color: var(--muted);
}

.hud #status {
  margin-top: 20px;
}

.controls {
  position: absolute;
  left: 50%;
  bottom: max(clamp(12px, 5vh, 56px), env(safe-area-inset-bottom));
  width: min(760px, calc(100% - 24px));
  padding: 4px;
  max-height: 68%;
  overflow: auto;
  transform: translateX(-50%);
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

button,
input {
  font: inherit;
}

button {
  min-height: 44px;
  padding: 8px 13px;
  border: 1px solid var(--stroke);
  border-radius: 10px;
  background: #142439;
  color: var(--ink);
  cursor: pointer;
}

button:not(:disabled):hover {
  border-color: var(--cyan);
  background: #244463;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

.suggestions button {
  background: #101e30ee;
  font-size: .8125rem;
}

.command-panel {
  border: 1px solid var(--stroke);
  border-radius: 16px;
  background: #0b1724f2;
  box-shadow: 0 8px 24px #0005;
}

#prompt {
  display: flex;
  align-items: stretch;
  gap: 8px;
  padding: 8px;
}

#command {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid #3a5369;
  border-radius: 10px;
  background: #070f1b;
  color: var(--ink);
  font-size: 1rem;
}

#command::placeholder {
  color: var(--muted);
}

.send {
  border-color: #417e91;
  background: #18384b;
  font-weight: 650;
  white-space: nowrap;
}

.send span {
  color: var(--cyan);
}

.mic-control {
  position: relative;
  display: grid;
}

#mic {
  width: 48px;
  min-width: 44px;
  padding: 0;
  font-size: 0;
}

#mic[data-voice-state="listening"] {
  border-color: var(--cyan);
  color: #c9f8ff;
  background: #1b475b;
}

#mic[data-voice-state="error"] {
  border-color: #af7958;
  color: var(--warning);
  background: #362536;
}

#mic:disabled {
  color: #9aabba;
  background: var(--surface);
  cursor: default;
}

.mic-icon {
  position: absolute;
  inset: 50% auto auto 50%;
  width: 18px;
  height: 20px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  color: var(--cyan);
  background: linear-gradient(currentColor, currentColor) center bottom / 2px 4px no-repeat;
}

.mic-icon::before,
.mic-icon::after {
  position: absolute;
  content: "";
}

.mic-icon::before {
  inset: 0 5px 7px;
  border: 2px solid currentColor;
  border-radius: 5px;
}

.mic-icon::after {
  inset: 7px 2px 3px;
  border: 2px solid currentColor;
  border-top: 0;
  border-radius: 0 0 8px 8px;
}

#mic[data-voice-state="listening"] + .mic-icon,
#mic[data-voice-state="error"] + .mic-icon {
  background: none;
}

#mic[data-voice-state="listening"] + .mic-icon::before {
  inset: 4px 3px;
  border-radius: 3px;
  background: currentColor;
}

#mic[data-voice-state="listening"] + .mic-icon::after,
#mic[data-voice-state="error"] + .mic-icon::after {
  content: none;
}

#mic[data-voice-state="error"] + .mic-icon::before {
  inset: 1px 0;
  border: 0;
  color: var(--warning);
  content: "!";
  text-align: center;
  font-size: 1rem;
  font-weight: 800;
}

#mic:disabled + .mic-icon {
  color: #9aabba;
  background:
    linear-gradient(45deg, transparent 45%, currentColor 46% 54%, transparent 55%),
    linear-gradient(currentColor, currentColor) center bottom / 2px 4px no-repeat;
}

.voice-feedback {
  padding: 0 12px 10px;
  color: var(--muted);
  font-size: .8125rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.voice-feedback p {
  margin: 0;
}

#voice-interim:not([hidden]),
#voice-final:not(:empty) {
  margin-top: 4px;
}

#voice-final {
  color: var(--ink);
}

.command-panel:has(#mic[data-voice-state="listening"]) #voice-status {
  color: var(--cyan);
}

.command-panel:has(#mic[data-voice-state="error"]) #voice-status {
  color: var(--warning);
}

.camera-help {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  text-align: center;
  font-size: .75rem;
}

@media (max-width: 550px) {
  .brand {
    font-size: .875rem;
  }

  .suggestions {
    gap: 6px;
    margin-bottom: 8px;
  }

  .suggestions button,
  .send {
    padding-inline: 9px;
  }

  .send span {
    display: none;
  }

  #prompt {
    gap: 6px;
  }
}

@media (forced-colors: active) {
  button:focus-visible,
  input:focus-visible {
    outline-color: Highlight;
  }

  .mic-icon {
    forced-color-adjust: none;
    color: ButtonText;
  }

  #mic:disabled + .mic-icon {
    color: GrayText;
  }

  #mic[data-voice-state="error"] + .mic-icon::before {
    color: ButtonText;
  }
}
