* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #08080f;
  --surface: #12121e;
  --border: #1e1e35;
  --text: #e8e8f0;
  --text-dim: #6b6b85;
  --accent: #7c5cfc;
  --accent-glow: rgba(124, 92, 252, 0.3);
  --listening: #7c5cfc;
  --thinking: #f0b429;
  --speaking: #10b981;
  --error: #ef4444;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro', 'Segoe UI', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  touch-action: manipulation;
}

.screen { display: none; height: 100vh; width: 100vw; }
.screen.active { display: flex; }

/* ─── PIN Screen ──────────────────────────── */
.pin-container {
  margin: auto;
  text-align: center;
  padding: 20px;
  max-width: 320px;
  width: 100%;
}

.logo {
  font-size: 56px;
  margin-bottom: 12px;
  filter: grayscale(0.2);
}

h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #7c5cfc, #c084fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: var(--text-dim);
  font-size: 14px;
  margin-top: 4px;
  margin-bottom: 32px;
}

.pin-dots {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-bottom: 12px;
}

.dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: transparent;
  transition: all 0.15s ease;
}

.dot.filled {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}

.dot.error {
  border-color: var(--error);
  animation: shake 0.4s ease;
}

.pin-error {
  color: var(--error);
  font-size: 13px;
  height: 20px;
  margin-bottom: 8px;
}

.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  max-width: 280px;
  margin: 0 auto;
}

.pin-key {
  width: 80px;
  height: 64px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 24px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.1s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  justify-self: center;
}

.pin-key:active {
  background: var(--accent);
  border-color: var(--accent);
  transform: scale(0.95);
}

.pin-key-empty {
  visibility: hidden;
}

.pin-key-delete {
  font-size: 20px;
  color: var(--text-dim);
}

/* ─── Voice Screen ────────────────────────── */
.voice-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
  padding: 40px 20px env(safe-area-inset-bottom, 20px);
  gap: 24px;
}

.status-area {
  text-align: center;
}

.status-text {
  font-size: 16px;
  color: var(--text-dim);
  font-weight: 500;
  letter-spacing: 0.3px;
  transition: color 0.3s ease;
}

.status-text.listening { color: var(--listening); }
.status-text.thinking { color: var(--thinking); }
.status-text.speaking { color: var(--speaking); }

/* Waveform */
#waveform {
  width: min(300px, 80vw);
  height: 60px;
  opacity: 0.6;
}

/* Mic Button */
.mic-area {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mic-button {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  border: none;
  background: var(--surface);
  border: 2px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  z-index: 2;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}

.mic-button svg {
  width: 36px;
  height: 36px;
}

.mic-button:active {
  transform: scale(0.95);
}

.mic-button.listening {
  background: var(--listening);
  border-color: var(--listening);
  color: white;
  box-shadow: 0 0 30px var(--accent-glow);
}

.mic-button.thinking {
  background: var(--thinking);
  border-color: var(--thinking);
  color: white;
  box-shadow: 0 0 30px rgba(240, 180, 41, 0.3);
}

.mic-button.speaking {
  background: var(--speaking);
  border-color: var(--speaking);
  color: white;
  box-shadow: 0 0 30px rgba(16, 185, 129, 0.3);
}

/* Pulse ring */
.mic-ring {
  position: absolute;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  opacity: 0;
  z-index: 1;
}

.mic-ring.pulse {
  animation: pulse 1.5s ease-out infinite;
}

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

/* Transcript */
.transcript-area {
  flex: 1;
  width: 100%;
  max-width: 500px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
  max-height: 30vh;
}

.transcript-placeholder {
  color: var(--text-dim);
  font-size: 13px;
  text-align: center;
  margin-top: 20px;
}

.msg {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  max-width: 85%;
  animation: fadeIn 0.2s ease;
}

.msg.user {
  background: var(--accent);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.msg.assistant {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* Mobile adjustments */
@media (max-height: 600px) {
  .voice-container { padding: 20px 16px; gap: 12px; }
  .mic-button { width: 80px; height: 80px; }
  .mic-button svg { width: 28px; height: 28px; }
  .mic-ring { width: 80px; height: 80px; }
  #waveform { height: 40px; }
}
