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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #0a0a0f;
  color: #e0e0e0;
  height: 100dvh;
  overflow: hidden;
}

/* --- App layout --- */

.voice-app {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
  position: relative;
  gap: 24px;
}

/* --- Header --- */

header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
}

header h1 {
  font-size: 1rem;
  font-weight: 600;
  color: #666;
}

.status {
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 500;
}

.status.connected {
  background: #0a2e1a;
  color: #34d399;
}

.status.disconnected {
  background: #2e0a0a;
  color: #f87171;
}

.status.reconnecting {
  background: #2e2a0a;
  color: #fbbf24;
}

/* --- Orb --- */

.orb-container {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.orb-container canvas {
  border-radius: 50%;
}

/* --- Subtitle area --- */

.subtitle-area {
  min-height: 60px;
  max-width: 600px;
  width: 100%;
  text-align: center;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.subtitle {
  font-size: 1rem;
  line-height: 1.5;
  opacity: 0;
  transition: opacity 0.3s ease;
  max-width: 100%;
  word-wrap: break-word;
}

.subtitle.visible {
  opacity: 1;
  transition: opacity 0.3s ease;
}

.subtitle.fading {
  opacity: 0;
  transition: opacity 1.5s ease;
}

.subtitle-user {
  color: #888;
  font-style: italic;
}

.subtitle-bot {
  color: #d4d4d8;
}

.subtitle-bot.error {
  color: #f87171;
}

/* --- Mic button --- */

.mic-btn {
  width: 72px;
  height: 72px;
  padding: 0;
  border: 2px solid #333;
  border-radius: 50%;
  background: #1a1a1a;
  color: #888;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.mic-btn:hover {
  border-color: #555;
  color: #bbb;
}

.mic-btn.active {
  background: #0a2e1a;
  border-color: #34d399;
  color: #34d399;
  box-shadow: 0 0 12px rgba(52, 211, 153, 0.2);
}

.mic-btn.loading {
  border-color: #fbbf24;
  color: #fbbf24;
  animation: pulse 1.2s ease-in-out infinite;
}

.mic-btn.listening {
  background: #0a2e1a;
  border-color: #34d399;
  color: #34d399;
  box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.2);
  animation: mic-listen-pulse 1s ease-in-out infinite;
}

.mic-btn.processing {
  background: #2e2a0a;
  border-color: #fbbf24;
  color: #fbbf24;
  animation: pulse 1.2s ease-in-out infinite;
}

.mic-btn.speaking {
  background: #0a1a2e;
  border-color: #60a5fa;
  color: #60a5fa;
  box-shadow: 0 0 12px rgba(96, 165, 250, 0.2);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes mic-listen-pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.2); }
  50% { box-shadow: 0 0 0 8px rgba(52, 211, 153, 0.1); }
}

/* --- Action bar --- */

.action-bar {
  display: flex;
  gap: 12px;
}

.text-toggle {
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid #333;
  border-radius: 50%;
  background: #1a1a1a;
  color: #666;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.text-toggle:hover {
  border-color: #555;
  color: #bbb;
}

.text-toggle.open {
  border-color: #60a5fa;
  color: #60a5fa;
}

/* --- Text input panel --- */

.text-input-panel {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  background: #111118;
  border-top: 1px solid #222;
  transform: translateY(0);
  transition: transform 0.25s ease;
}

.text-input-panel.collapsed {
  transform: translateY(100%);
}

.text-input-panel textarea {
  flex: 1;
  resize: none;
  border: 1px solid #333;
  border-radius: 12px;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 0.95rem;
  background: #1a1a1a;
  color: #e0e0e0;
  outline: none;
  max-height: 120px;
  line-height: 1.5;
}

.text-input-panel textarea:focus {
  border-color: #60a5fa;
}

.text-input-panel textarea:disabled {
  opacity: 0.5;
}

.text-input-panel #send-btn {
  align-self: flex-end;
  padding: 10px 20px;
  border: none;
  border-radius: 12px;
  background: #60a5fa;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  flex-shrink: 0;
}

.text-input-panel #send-btn:hover:not(:disabled) {
  background: #3b82f6;
}

.text-input-panel #send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* --- Header right group --- */

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid #333;
  border-radius: 50%;
  background: transparent;
  color: #666;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  border-color: #555;
  color: #bbb;
}

.icon-btn.danger {
  color: #555;
}

.icon-btn.danger:hover {
  border-color: #f87171;
  color: #f87171;
  background: rgba(248, 113, 113, 0.1);
}

/* --- Memory panel --- */

.memory-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 90;
}

.memory-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.memory-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 380px;
  max-width: 100vw;
  background: #111118;
  border-left: 1px solid #222;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  z-index: 100;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.memory-panel.open {
  transform: translateX(0);
}

.memory-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #222;
  flex-shrink: 0;
}

.memory-panel-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: #e0e0e0;
}

.memory-panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.memory-action-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid #333;
  border-radius: 8px;
  background: #1a1a1a;
  color: #888;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.memory-action-btn:hover {
  border-color: #555;
  color: #bbb;
}

.memory-close-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #666;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease;
}

.memory-close-btn:hover {
  color: #e0e0e0;
}

.memory-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 20px;
}

.memory-empty {
  color: #555;
  text-align: center;
  padding: 40px 0;
  font-size: 0.9rem;
}

.memory-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid #1a1a22;
}

.memory-item:last-child {
  border-bottom: none;
}

.memory-item-content {
  flex: 1;
  min-width: 0;
}

.memory-item-fact {
  font-size: 0.9rem;
  color: #d4d4d8;
  line-height: 1.4;
  word-break: break-word;
}

.memory-item-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  font-size: 0.75rem;
  color: #555;
}

.memory-category {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.memory-category.preference { background: #1a2e1a; color: #34d399; }
.memory-category.personal   { background: #1a1a2e; color: #60a5fa; }
.memory-category.emotional  { background: #2e1a2a; color: #f472b6; }
.memory-category.opinion    { background: #2e2a1a; color: #fbbf24; }
.memory-category.event      { background: #1a2e2e; color: #22d3ee; }
.memory-category.insight    { background: #2e1a2e; color: #c084fc; }

.memory-section-header {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #888;
  padding: 12px 0 6px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  margin-bottom: 4px;
}

.memory-section-header:first-child {
  padding-top: 0;
}

.reflection-item .memory-item-fact {
  font-style: italic;
  color: #c9c9c9;
}

.memory-delete-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #555;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.memory-delete-btn:hover {
  background: #2e0a0a;
  color: #f87171;
}

/* --- Auth pages --- */

.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: #111118;
  border: 1px solid #222;
  border-radius: 16px;
  padding: 32px 28px;
}

.auth-title {
  text-align: center;
  font-size: 1.4rem;
  font-weight: 600;
  color: #e0e0e0;
  margin-bottom: 24px;
}

.auth-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  background: #0a0a0f;
  border-radius: 10px;
  padding: 4px;
}

.auth-tab {
  flex: 1;
  padding: 8px 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #888;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.auth-tab.active {
  background: #1a1a22;
  color: #e0e0e0;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth-field label {
  font-size: 0.8rem;
  color: #888;
  font-weight: 500;
}

.auth-field input {
  padding: 10px 14px;
  border: 1px solid #333;
  border-radius: 10px;
  background: #1a1a1a;
  color: #e0e0e0;
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s ease;
}

.auth-field input:focus {
  border-color: #60a5fa;
}

.auth-error {
  color: #f87171;
  font-size: 0.85rem;
  min-height: 1.2em;
}

.auth-success {
  color: #34d399;
  font-size: 0.85rem;
  min-height: 1.2em;
}

.auth-submit {
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: #60a5fa;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease;
}

.auth-submit:hover {
  background: #3b82f6;
}

/* --- Responsive --- */

@media (max-height: 600px) {
  .orb-container canvas {
    width: 180px;
    height: 180px;
  }

  .mic-btn {
    width: 56px;
    height: 56px;
  }

  .voice-app {
    gap: 16px;
  }

  .subtitle-area {
    min-height: 40px;
  }
}

/* --- Conversation starters --- */

.starters-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding: 0 20px;
  max-width: 500px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}

.starters-container.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.starter-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #e0e0e0;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
  text-align: center;
}

.starter-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
}
