/* ══════════════════════════════════════════════════════════
   MyLucidFellow — Styles
   Dark earth. Interior space. A door that locks from the inside.
   (c) 2026 Resonant Catalyst. All rights reserved.
   ══════════════════════════════════════════════════════════ */

:root {
  --bg-deep: #09090b;
  --bg-surface: #0e0e12;
  --bg-card: rgba(14, 14, 18, 0.9);
  --text-primary: #c8c4bc;
  --text-soft: #7a776e;
  --text-whisper: #4a4840;
  --teal-clear: #5a9e8f;
  --teal-soft: #4a8577;
  --teal-glow: rgba(90, 158, 143, 0.12);
  --earth-dark: #1a1814;
  --earth-mid: #242018;
  --earth-warm: #2e2820;
  --input-bg: rgba(14, 14, 18, 0.95);
  --border-subtle: rgba(90, 158, 143, 0.06);
  --border-warm: rgba(90, 158, 143, 0.14);
  --radius: 16px;
  --radius-sm: 10px;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'Georgia', 'Times New Roman', serif;
  background: var(--bg-deep);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

/* ── Orbital Canvas ── */
#orbital-canvas {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 11;
  pointer-events: none;
}

/* ══════ AUTH SCREEN ══════ */
#auth-screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(90, 158, 143, 0.03) 0%, var(--bg-deep) 65%);
  gap: 20px;
}

.auth-title {
  font-size: 1.8rem;
  font-weight: 400;
  letter-spacing: 0.15em;
  color: var(--text-primary);
  text-shadow: 0 0 40px rgba(90, 158, 143, 0.08);
  position: relative;
  z-index: 1;
}

.accent-word {
  color: var(--teal-clear);
  text-shadow: 0 0 30px rgba(90, 158, 143, 0.25);
}

.auth-subtitle {
  font-size: 0.95rem;
  color: var(--text-soft);
  font-style: italic;
  letter-spacing: 0.05em;
  margin-top: -8px;
  position: relative;
  z-index: 1;
}

.auth-box {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 280px;
  margin-top: 16px;
  position: relative;
  z-index: 1;
}

.auth-box input {
  background: var(--input-bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.3s ease;
}

.auth-box input:focus {
  border-color: var(--border-warm);
}

.auth-box input::placeholder {
  color: var(--text-whisper);
}

#gate-btn {
  background: linear-gradient(135deg, var(--earth-mid), var(--earth-warm));
  border: 1px solid var(--border-warm);
  border-radius: var(--radius-sm);
  padding: 12px;
  color: var(--teal-clear);
  font-family: inherit;
  font-size: 0.9rem;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: all 0.3s ease;
}

#gate-btn:hover {
  background: linear-gradient(135deg, var(--earth-warm), var(--earth-mid));
  box-shadow: 0 0 20px rgba(90, 158, 143, 0.08);
}

#gate-error {
  color: #c47a7a;
  font-size: 0.8rem;
  text-align: center;
  min-height: 1.2em;
}

/* ══════ ONBOARDING ══════ */
#onboard-screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-deep);
  gap: 30px;
  padding: 40px;
}

#onboard-content {
  text-align: center;
  max-width: 400px;
}

.onboard-line {
  font-size: 1.05rem;
  line-height: 1.8;
  color: var(--text-primary);
  opacity: 0;
  animation: fadeInSlow 1.5s ease forwards;
  margin-bottom: 8px;
}

.onboard-line:nth-child(2) { animation-delay: 0.8s; }
.onboard-line:nth-child(3) { animation-delay: 1.6s; }

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

#onboard-btn {
  background: transparent;
  border: 1px solid var(--border-warm);
  border-radius: var(--radius-sm);
  padding: 10px 32px;
  color: var(--teal-soft);
  font-family: inherit;
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: all 0.3s ease;
}

#onboard-btn:hover {
  background: rgba(90, 158, 143, 0.05);
  color: var(--teal-clear);
}

/* ══════ MAIN APP ══════ */
#app-screen {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  background: var(--bg-deep);
}

/* ── Header ── */
#app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: rgba(9, 9, 11, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 6;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

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

.fellow-presence {
  display: flex;
  align-items: center;
  gap: 8px;
}

.presence-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--teal-clear);
  box-shadow: 0 0 8px rgba(90, 158, 143, 0.35);
  animation: presence-pulse 4s ease-in-out infinite;
}

@keyframes presence-pulse {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.15); }
}

.fellow-label {
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--teal-clear);
  letter-spacing: 0.05em;
}

.logout-btn {
  background: none;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 6px 16px;
  color: var(--text-soft);
  font-family: inherit;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 0.3s ease;
}

.logout-btn:hover {
  border-color: var(--border-warm);
  color: var(--text-primary);
}

/* ── Chat Area ── */
#chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
  scroll-behavior: smooth;
}

#chat-area::-webkit-scrollbar { width: 4px; }
#chat-area::-webkit-scrollbar-track { background: transparent; }
#chat-area::-webkit-scrollbar-thumb { background: var(--border-subtle); border-radius: 4px; }

#messages {
  max-width: 680px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── Messages ── */
.msg {
  padding: 16px 20px;
  border-radius: var(--radius);
  line-height: 1.7;
  font-size: 0.95rem;
  animation: msgFade 0.6s ease forwards;
  opacity: 0;
}

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

.msg-user {
  background: rgba(26, 24, 20, 0.7);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  align-self: flex-end;
  max-width: 85%;
}

.msg-fellow {
  background: rgba(14, 14, 18, 0.6);
  border: 1px solid rgba(90, 158, 143, 0.05);
  color: var(--text-primary);
  align-self: flex-start;
  max-width: 90%;
  border-left: 2px solid rgba(90, 158, 143, 0.12);
}

.msg-speak-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid rgba(90, 158, 143, 0.15);
  color: rgba(90, 158, 143, 0.4);
  border-radius: 4px;
  padding: 3px 5px;
  cursor: pointer;
  float: right;
  margin-top: 2px;
  transition: color 0.2s, border-color 0.2s;
}

.msg-speak-btn:hover {
  color: rgba(90, 158, 143, 0.8);
  border-color: rgba(90, 158, 143, 0.4);
}

.msg-fellow p {
  margin-bottom: 8px;
}

.msg-fellow p:last-child {
  margin-bottom: 0;
}

/* ── Streaming indicator ── */
.streaming .breathing-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--teal-soft);
  border-radius: 50%;
  animation: breatheDot 2.5s ease-in-out infinite;
}

@keyframes breatheDot {
  0%, 100% { opacity: 0.2; transform: scale(0.8); }
  50% { opacity: 0.7; transform: scale(1.2); }
}

/* ── Reply Zone ── */
#reply-zone {
  padding: 16px 20px 24px;
  background: rgba(9, 9, 11, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-subtle);
}

.input-wrap {
  max-width: 680px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--input-bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 8px 12px;
  transition: border-color 0.3s ease;
}

.input-wrap:focus-within {
  border-color: var(--border-warm);
  box-shadow: 0 0 20px rgba(90, 158, 143, 0.03);
}

#user-input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
  resize: none;
  outline: none;
  padding: 4px 0;
  max-height: 120px;
}

#user-input::placeholder {
  color: var(--text-whisper);
  font-style: italic;
}

#send-btn {
  background: none;
  border: none;
  color: var(--text-soft);
  cursor: pointer;
  padding: 4px;
  transition: color 0.3s ease, transform 0.2s ease;
  flex-shrink: 0;
}

#send-btn:hover {
  color: var(--teal-clear);
  transform: scale(1.1);
}

/* ══════ SPEAKER ══════ */
.speaker-btn {
  background: none;
  border: none;
  color: var(--text-soft);
  cursor: pointer;
  padding: 4px;
  transition: color 0.3s ease;
}

.speaker-btn:hover {
  color: var(--teal-clear);
}

/* ══════ UPLOAD / DOWNLOAD ══════ */
.upload-btn {
  background: none;
  border: none;
  color: var(--text-soft);
  cursor: pointer;
  padding: 4px;
  transition: color 0.3s ease, transform 0.2s ease;
  flex-shrink: 0;
}

.upload-btn:hover {
  color: var(--teal-clear);
  transform: scale(1.1);
}

.download-btn {
  background: none;
  border: none;
  color: var(--text-soft);
  cursor: pointer;
  padding: 4px;
  transition: color 0.3s ease;
  display: flex;
  align-items: center;
  margin-right: 8px;
}

.download-btn:hover {
  color: var(--teal-clear);
}

.pdf-context-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  background: rgba(90, 158, 143, 0.04);
  border-top: 1px solid rgba(90, 158, 143, 0.08);
  font-size: 0.8rem;
  color: var(--teal-soft);
}

.pdf-context-bar svg {
  flex-shrink: 0;
  opacity: 0.6;
}

#pdf-context-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pdf-context-clear {
  background: none;
  border: none;
  color: var(--text-soft);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.2s ease, background 0.2s ease;
}

.pdf-context-clear:hover {
  color: var(--teal-clear);
  background: rgba(90, 158, 143, 0.06);
}

/* ══════ VOICE ══════ */
.voice-btn {
  background: none;
  border: none;
  color: var(--text-soft);
  cursor: pointer;
  padding: 4px;
  transition: color 0.3s ease;
  flex-shrink: 0;
}

.voice-btn.active {
  color: #e57373;
  animation: pulse-mic 1.5s ease-in-out infinite;
}

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

.voice-bar {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  background: rgba(229, 115, 115, 0.06);
  font-size: 0.8rem;
  color: rgba(229, 115, 115, 0.7);
}

.voice-bar.visible {
  display: flex;
}

.voice-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e57373;
  animation: pulse-dot 1.5s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 0.4; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
}

/* ══════ VOICE GENDER TOGGLE ══════ */
.voice-gender-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 8px;
}

.voice-gender-btn {
  background: none;
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 2px 8px;
  font-family: inherit;
  font-size: 0.7rem;
  color: var(--text-whisper);
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: 0.05em;
}

.voice-gender-btn.active {
  border-color: var(--teal-soft);
  color: var(--teal-clear);
  background: rgba(90, 158, 143, 0.06);
}

/* ══════ RESPONSIVE ══════ */
@media (max-width: 600px) {
  .auth-title { font-size: 1.4rem; }
  .auth-subtitle { font-size: 0.85rem; }
  .auth-box { width: 260px; }

  #chat-area { padding: 16px 12px; }
  .msg { padding: 12px 16px; font-size: 0.9rem; }
  #messages { gap: 16px; }

  #reply-zone { padding: 12px 12px 20px; }
  .input-wrap { padding: 6px 10px; }
}

/* ══════ SELECTION ══════ */
::selection {
  background: rgba(90, 158, 143, 0.2);
  color: var(--text-primary);
}
