:root {
  color-scheme: dark;
  --bg: #07080c;
  --fg: #e8e6e1;
  --muted: #8a8680;
  --accent: #c4a35a;
  --rain: #3d5a80;
  --danger: #8b3a3a;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
}

body {
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, #1a2233 0%, transparent 55%),
    linear-gradient(180deg, #0a0c12 0%, var(--bg) 100%);
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
}

.stage {
  max-width: 32rem;
  margin: 0 auto;
  padding: 2rem 1.25rem calc(2rem + env(safe-area-inset-bottom));
  text-align: center;
}

.tag {
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-size: 0.7rem;
  color: var(--accent);
  margin: 0 0 0.5rem;
}

h1 {
  font-weight: 500;
  font-size: 2.2rem;
  margin: 0 0 0.5rem;
  letter-spacing: 0.04em;
}

.blurb {
  color: var(--muted);
  line-height: 1.5;
  margin: 0 0 1.5rem;
  font-size: 0.95rem;
}

.orb {
  width: 8.5rem;
  height: 8.5rem;
  margin: 0 auto 1rem;
  border: 2px solid rgba(196, 163, 90, 0.35);
  border-radius: 50%;
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  position: relative;
  background: #0d1118;
  box-shadow:
    0 0 40px rgba(61, 90, 128, 0.45),
    inset 0 0 0 1px rgba(0, 0, 0, 0.4);
  transition: transform 0.15s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.orb-face {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 18%;
  display: block;
  pointer-events: none;
  user-select: none;
  /* Pivot near chin so motion feels like speech, not a sticker mouth */
  transform-origin: 50% 78%;
  will-change: transform;
}

.orb:active {
  transform: scale(0.96);
}

.orb.listening {
  border-color: rgba(196, 163, 90, 0.85);
  box-shadow: 0 0 50px rgba(196, 163, 90, 0.5);
  animation: pulse 1.6s ease-in-out infinite;
}

.orb.speaking {
  border-color: rgba(232, 230, 225, 0.7);
  box-shadow: 0 0 48px rgba(232, 230, 225, 0.28);
}

/* Subtle jaw / face motion only — no overlay blob */
.orb.talking.fallback-talk .orb-face {
  animation: jawSpeak 0.17s ease-in-out infinite alternate;
}

@keyframes jawSpeak {
  from {
    transform: scaleY(1) translateY(0);
  }
  to {
    transform: scaleY(1.035) translateY(1.2%);
  }
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.03);
  }
}

.status {
  color: var(--muted);
  font-size: 0.85rem;
  min-height: 1.25rem;
  margin: 0 0 1.25rem;
}

.row {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

button {
  border: 1px solid #2a3140;
  background: #12161f;
  color: var(--fg);
  padding: 0.85rem 1.4rem;
  border-radius: 999px;
  font-size: 1rem;
  cursor: pointer;
  min-height: 48px;
  min-width: 7rem;
}

button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

a.btn-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #2a3140;
  background: #12161f;
  color: var(--fg);
  padding: 0.85rem 1.4rem;
  border-radius: 999px;
  font-size: 1rem;
  text-decoration: none;
  min-height: 48px;
  min-width: 7rem;
  box-sizing: border-box;
}

a.btn-link:hover {
  border-color: var(--accent);
  color: var(--accent);
}

#micBtn.active {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 0 2px rgba(196, 163, 90, 0.25);
}

.hint {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
  margin: 0 auto 1rem;
  max-width: 24rem;
}

textarea {
  width: 100%;
  max-width: 24rem;
  margin: 0 auto 1rem;
  display: block;
  background: #12161f;
  color: var(--fg);
  border: 1px solid #2a3140;
  border-radius: 0.75rem;
  padding: 0.85rem;
  font: inherit;
  font-size: 16px; /* avoid iOS zoom */
  resize: vertical;
}

.log {
  text-align: left;
  max-height: 40vh;
  overflow-y: auto;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--muted);
  border-top: 1px solid #1c2230;
  padding-top: 1rem;
  -webkit-overflow-scrolling: touch;
}

.log .you {
  color: #9ab0c8;
}

.log .roy {
  color: #d4c4a0;
}

.log .sys {
  color: #5a6578;
  font-style: italic;
}

.install-hint {
  margin-top: 1.25rem;
  font-size: 0.75rem;
  color: #5a6578;
}

.play-roy {
  display: block;
  width: 100%;
  max-width: 24rem;
  margin: 0 auto 1rem;
  border: 1px solid #3d6b3d !important;
  background: linear-gradient(180deg, #2a4a2a, #1a2e1a) !important;
  color: #b8e0b8 !important;
  font-size: 1.05rem !important;
  font-weight: 600;
  min-height: 52px;
}

.play-roy.hidden {
  display: none !important;
}

.row-secondary button {
  min-width: auto;
  padding: 0.55rem 0.9rem;
  font-size: 0.85rem;
  min-height: 40px;
  opacity: 0.9;
}

.archive-panel {
  text-align: left;
  max-width: 24rem;
  margin: 0 auto 1rem;
  padding: 0.85rem;
  border: 1px solid #2a3140;
  border-radius: 0.75rem;
  background: #0d1118;
}

.archive-panel.hidden {
  display: none;
}

.archive-list {
  max-height: 12rem;
  overflow-y: auto;
  margin: 0.5rem 0 0.75rem;
}

.archive-item {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid #1c2230;
  font-size: 0.85rem;
}

.archive-item span {
  flex: 1 1 100%;
  color: var(--muted);
}

.archive-item strong {
  color: var(--fg);
  font-weight: 500;
}

.archive-item button {
  min-height: 36px;
  min-width: auto;
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
}

/* PIN gate */
.pin-gate {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.pin-gate.hidden {
  display: none;
}

.pin-card {
  background: #12161f;
  border: 1px solid #2a3140;
  border-radius: 1rem;
  padding: 1.5rem;
  max-width: 20rem;
  width: 100%;
  text-align: center;
}

.pin-card h2 {
  margin: 0 0 0.5rem;
  font-weight: 500;
}

.pin-card input {
  width: 100%;
  margin: 0.75rem 0;
  padding: 0.85rem;
  border-radius: 0.5rem;
  border: 1px solid #2a3140;
  background: #0a0c12;
  color: var(--fg);
  font-size: 1.25rem;
  text-align: center;
  letter-spacing: 0.2em;
}

.pin-err {
  color: #d4a0a0;
  min-height: 1.2rem;
  font-size: 0.85rem;
  margin: 0.5rem 0 0;
}

.pin-card code {
  color: #b8c0cc;
  font-size: 0.8rem;
}
