:root {
  --bg: #000000;
  --bg-2: #0a0a0a;
  --gold: #FFD700;
  --gold-2: #E6C200;
  --gold-dim: rgba(255, 215, 0, 0.14);
  --text: #ffffff;
  --muted: #9a9588;
  --danger: #ff5d5d;
  --warning: #e6c200;
  --font: "Urbanist", -apple-system, BlinkMacSystemFont, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overscroll-behavior: none;
  touch-action: manipulation;
}

.grain, .aurora {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.aurora {
  background:
    radial-gradient(ellipse 80% 50% at 50% 108%, rgba(255, 215, 0, 0.16), transparent 58%),
    radial-gradient(ellipse 40% 30% at 80% 8%, rgba(255, 215, 0, 0.06), transparent 50%),
    radial-gradient(ellipse 30% 24% at 12% 18%, rgba(230, 194, 0, 0.05), transparent 50%);
}

.grain {
  z-index: 8;
  opacity: 0.045;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.hidden { display: none !important; }

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

.screen {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 24px 8px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.setup-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 215, 0, 0.25);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.setup-btn:hover {
  background: rgba(255, 215, 0, 0.15);
  border-color: var(--gold);
  transform: scale(1.06);
}

.setup-btn:active {
  transform: scale(0.94);
}

.setup-icon {
  display: block;
  width: 20px;
  height: 20px;
  object-fit: contain;
  color: var(--gold);
  filter: drop-shadow(0 0 4px rgba(255, 215, 0, 0.4));
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  letter-spacing: 0.42em;
  font-size: 13px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  transition: background .3s, box-shadow .3s;
}
.dot.online { background: var(--gold); box-shadow: 0 0 10px var(--gold); }
.dot.offline { background: var(--warning); }
.dot.recording { background: var(--gold); box-shadow: 0 0 12px var(--gold); animation: blink 1s infinite; }

@keyframes blink { 50% { opacity: .28; } }

.queue-badge {
  background: var(--gold);
  color: #111;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.08em;
  border-radius: 999px;
  padding: 4px 12px;
}

.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 12px 24px 36px;
}

.status {
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
  min-height: 20px;
}

.talk-cluster {
  position: relative;
  width: 236px;
  height: 236px;
  display: grid;
  place-items: center;
}

.pulse-ring {
  position: absolute;
  inset: 18px;
  border-radius: 50%;
  border: 1px solid rgba(255, 215, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transform: scale(1);
}

.talk-btn {
  position: relative;
  z-index: 2;
  width: 196px;
  height: 196px;
  border-radius: 50%;
  border: 1px solid rgba(255, 215, 0, 0.55);
  cursor: pointer;
  color: #111;
  background:
    radial-gradient(circle at 32% 28%, #fff6a8 0%, var(--gold) 42%, var(--gold-2) 78%, #b89600 100%);
  box-shadow:
    0 18px 50px rgba(255, 215, 0, 0.22),
    0 0 0 10px rgba(255, 215, 0, 0.05),
    inset 0 -10px 18px rgba(0, 0, 0, 0.22),
    inset 0 8px 16px rgba(255, 255, 255, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .18s cubic-bezier(.2, .8, .2, 1), box-shadow .3s;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  will-change: transform;
}

.talk-spec {
  position: absolute;
  inset: 14%;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 24%, rgba(255,255,255,.55), transparent 42%);
  pointer-events: none;
}

.talk-btn:active,
body.state-recording .talk-btn {
  transform: scale(.94);
  box-shadow:
    0 10px 34px rgba(255, 215, 0, 0.38),
    0 0 0 14px rgba(255, 215, 0, 0.08),
    inset 0 -8px 16px rgba(0, 0, 0, 0.28);
}

body.state-recording .pulse-ring.r1 { animation: ring 1.6s ease-out infinite; }
body.state-recording .pulse-ring.r2 { animation: ring 1.6s ease-out .22s infinite; }
body.state-recording .pulse-ring.r3 { animation: ring 1.6s ease-out .44s infinite; }

@keyframes ring {
  0% { transform: scale(.92); opacity: .55; }
  100% { transform: scale(1.38); opacity: 0; }
}

body.state-waiting .talk-btn,
body.state-sending .talk-btn {
  animation: breathe 2.4s ease-in-out infinite;
}

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

.attach-btn {
  position: absolute;
  right: -4px;
  bottom: 18px;
  z-index: 3;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1px solid var(--gold);
  background: rgba(10, 10, 10, 0.72);
  color: var(--gold);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45), 0 0 16px rgba(255, 215, 0, 0.12);
  transition: transform .18s cubic-bezier(.2, .8, .2, 1), background .2s, color .2s;
}

.attach-btn:active { transform: scale(.92); background: var(--gold); color: #111; }

.transcript, .reply {
  width: 100%;
  max-width: 520px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 215, 0, 0.16);
  border-radius: 18px;
  padding: 16px 18px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.reply { border-color: rgba(255, 215, 0, 0.32); }

.transcript h3, .reply h3 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--gold);
  margin-bottom: 8px;
}

.transcript p, .reply p { font-size: 16px; line-height: 1.5; white-space: pre-wrap; font-weight: 400; }

.btn-ghost {
  margin-top: 12px;
  background: none;
  border: 1px solid rgba(255, 215, 0, 0.4);
  color: var(--gold);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  font-family: inherit;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

.footer {
  text-align: center;
  color: #5c584e;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 14px 16px 22px;
}

.pin-card {
  margin: auto;
  width: min(92vw, 360px);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 215, 0, 0.22);
  border-radius: 22px;
  padding: 42px 28px 32px;
  text-align: center;
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

.pin-kicker {
  color: var(--gold);
  font-size: 11px;
  letter-spacing: 0.38em;
  text-transform: uppercase;
  margin-bottom: 10px !important;
}

.pin-card h1 {
  font-size: 42px;
  font-weight: 800;
  letter-spacing: 0.46em;
  margin-bottom: 10px;
  padding-left: 0.46em;
}

.pin-card p { color: var(--muted); font-size: 14px; margin-bottom: 22px; }

#pinInput {
  width: 100%;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 215, 0, 0.22);
  color: var(--text);
  border-radius: 14px;
  padding: 14px;
  font-size: 22px;
  font-family: inherit;
  text-align: center;
  letter-spacing: 10px;
  margin-bottom: 14px;
}

#pinInput:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.15); }

.btn-primary {
  width: 100%;
  background: var(--gold);
  color: #111;
  font-family: inherit;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  border: none;
  border-radius: 14px;
  padding: 14px;
  cursor: pointer;
}

.pin-error { color: var(--danger); font-size: 13px; margin-top: 12px; min-height: 16px; }

/* Modal Setup Suite */
.setup-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #000000;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  animation: setupFadeIn .2s ease-out;
}

@keyframes setupFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.setup-modal-card {
  width: 100%;
  height: 100%;
  background: #000000;
  border: none;
  border-radius: 0;
  padding: 16px 16px 12px;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.setup-logs-area {
  flex: 2;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.setup-logs-titlebar {
  flex-shrink: 0;
}

.setup-terminal {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  background: #050505;
  border: 1px solid rgba(255, 215, 0, 0.2);
  border-radius: 12px;
  padding: 12px 14px;
  font-family: "SFMono-Regular", "Consolas", "Menlo", "DejaVu Sans Mono", monospace;
  font-size: 12px;
  line-height: 1.6;
  color: var(--gold);
  white-space: pre-wrap;
  word-break: break-word;
  -webkit-overflow-scrolling: touch;
}

.setup-log-entry {
  margin-bottom: 2px;
}

.setup-bottom-area {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 14px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.setup-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  margin-bottom: 14px;
  border-bottom: 1px solid rgba(255, 215, 0, 0.14);
  flex-shrink: 0;
}

.setup-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.setup-header-icon {
  width: 20px;
  height: 20px;
  filter: drop-shadow(0 0 3px rgba(255, 215, 0, 0.4));
}

.setup-modal-header h2 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 0;
}

.setup-close-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 8px;
  transition: all .2s;
}

.setup-close-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

.setup-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.setup-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--text);
}

.setup-suite-status {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.suite-status-indicator {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
  transition: all .3s;
  flex-shrink: 0;
}

.suite-status-indicator.running {
  background: #4ade80;
  box-shadow: 0 0 10px #4ade80;
  animation: blink 1.2s infinite;
}

.suite-status-indicator.idle {
  background: #64748b;
}

.suite-status-indicator.locked {
  background: #f59e0b;
  box-shadow: 0 0 10px #f59e0b;
}

.setup-controls-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.setup-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
  min-height: 44px;
}

.setup-action-btn:hover {
  transform: translateY(-1px);
}

.setup-action-btn:active {
  transform: translateY(1px);
}

.btn-play,
.btn-pause,
.btn-lock,
.btn-restart {
  color: var(--gold);
  border-color: rgba(255, 215, 0, 0.38);
}

.btn-play:hover,
.btn-pause:hover,
.btn-lock:hover,
.btn-restart:hover {
  background: rgba(255, 215, 0, 0.14);
  border-color: var(--gold);
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.18);
}

.btn-lock.is-locked {
  background: rgba(255, 215, 0, 0.2);
  border-color: var(--gold);
  box-shadow: 0 0 14px rgba(255, 215, 0, 0.3);
}

.setup-pin-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

#newPinInput {
  flex: 1;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 215, 0, 0.25);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 16px;
  font-family: inherit;
  letter-spacing: 2px;
}

#newPinInput:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(255, 215, 0, 0.15);
}

.btn-primary-small {
  background: var(--gold);
  color: #111;
  font-family: inherit;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: none;
  border-radius: 12px;
  padding: 0 18px;
  height: 46px;
  cursor: pointer;
  transition: opacity .2s, transform .2s;
}

.btn-primary-small:hover {
  opacity: 0.92;
}

.btn-primary-small:active {
  transform: scale(0.96);
}

.setup-feedback {
  font-size: 12px;
  min-height: 16px;
  margin-top: 4px;
  transition: opacity .2s;
}

.setup-feedback.success { color: #4ade80; }
.setup-feedback.error { color: var(--danger); }

@media (prefers-reduced-motion: reduce) {
  .dot.recording,
  body.state-recording .pulse-ring,
  body.state-waiting .talk-btn,
  body.state-sending .talk-btn {
    animation: none !important;
  }
  .talk-btn, .attach-btn { transition-duration: .01ms; }
}
