/* ===== RESET & BASE ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ===== DAY MODE — Pillar of Cloud ===== */
:root {
  --bg-main: #f5f5f8;
  --bg-secondary: #ffffff;
  --bg-bubble-user: #1a1a1a;
  --bg-bubble-bot: #ffffff;
  --text-primary: #1a1a1a;
  --text-muted: #666680;
  --accent: #1a1a1a;
  --gold: #2a2a2a;
  --border: #1a1a1a;
  --shadow-inward: inset 0 2px 6px rgba(0,0,0,0.15);
  --shadow-outer: 0 4px 20px rgba(0,0,0,0.14);
  --bubble-label: #444;
  --header-bg: linear-gradient(135deg, #e8e8f0, #ffffff);
  --input-bg: #ffffff;
  --send-btn: linear-gradient(135deg, #1a1a1a, #333333);
  --send-text: #ffffff;
  --smoke:
    radial-gradient(ellipse 600px 350px at 20% 25%,
      rgba(60,105,180,0.09) 0%, transparent 70%),
    radial-gradient(ellipse 550px 300px at 80% 20%,
      rgba(70,115,190,0.08) 0%, transparent 70%),
    radial-gradient(ellipse 700px 400px at 50% 85%,
      rgba(55,100,175,0.07) 0%, transparent 70%);
}

/* ===== NIGHT MODE — Pillar of Fire ===== */
[data-theme="night"] {
 --bg-main: #000000;
  --bg-secondary: #1f0f00;
  --bg-bubble-user: #7a2800;
  --bg-bubble-bot: #1a0e00;
  --text-primary: #fff5e6;
  --text-muted: #c4956a;
  --accent: #e87c2a;
  --gold: #f5a623;
  --border: #c45e00;
  --shadow-inward: inset 0 2px 8px rgba(255,100,0,0.2);
  --shadow-outer: 0 2px 20px rgba(255,80,0,0.15);
  --bubble-label: #f5a623;
  --header-bg: linear-gradient(135deg, #1a0800, #2d1200);
  --input-bg: #1a0e00;
  --send-btn: linear-gradient(135deg, #e87c2a, #c45e00);
  --send-text: #ffffff;
  --smoke:
    radial-gradient(ellipse 300px 600px at 50% 75%,
      rgba(255,140,30,0.22) 0%,
      rgba(255,100,0,0.12) 30%,
      transparent 65%),
    radial-gradient(ellipse 180px 350px at 47% 55%,
      rgba(255,180,60,0.18) 0%, transparent 60%),
    radial-gradient(ellipse 120px 200px at 53% 35%,
      rgba(255,200,100,0.15) 0%, transparent 55%),
    radial-gradient(ellipse 400px 150px at 50% 88%,
      rgba(255,90,0,0.10) 0%, transparent 70%);
}

html {
  height: 100%;
  height: -webkit-fill-available;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--bg-main);
  background-image: var(--smoke);
  color: var(--text-primary);
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: background-color 0.5s ease, color 0.5s ease;
}

/* ===== SUNDAY LOCK SCREEN ===== */
#sunday-lock {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  text-align: center;
}

#sunday-lock.hidden {
  display: none;
}

.lock-content h1 {
  font-size: 80px;
  margin-bottom: 20px;
}

.lock-content h2 {
  font-size: 32px;
  color: var(--gold);
  margin-bottom: 16px;
}

.lock-content p {
  font-size: 18px;
  color: var(--light);
  margin-bottom: 10px;
  max-width: 500px;
  line-height: 1.6;
}

#countdown {
  margin-top: 24px;
  font-size: 22px;
  color: var(--gold);
  font-weight: bold;
}

/* ===== MAIN APP ===== */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

/* ===== HEADER ===== */
header {
  background: var(--header-bg);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid var(--border);
  flex-shrink: 0;
  box-shadow: var(--shadow-outer);
}

.header-left .app-title {
  font-size: 22px;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 1px;
}

.header-left .tagline {
  font-size: 12px;
  color: var(--text-muted);
  display: block;
  margin-top: 2px;
}

.header-right select {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
  outline: none;
  box-shadow: var(--shadow-inward);
}

/* ===== CHAT WINDOW ===== */
#chat-window {
  flex: 1;
  overflow-y: auto;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

#chat-window::-webkit-scrollbar {
  width: 6px;
}

#chat-window::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 10px;
}

/* ===== WELCOME MESSAGE ===== */
.welcome-message {
  background: var(--bg-secondary);
  border: 1px solid var(--gold);
  border-radius: 16px;
  padding: 24px;
  text-align: center;
  max-width: 600px;
  margin: 0 auto;
  box-shadow: var(--shadow-outer), var(--shadow-inward);
}

.welcome-message h2 {
  color: var(--gold);
  font-size: 22px;
  margin-bottom: 12px;
}

.welcome-message p {
  color: var(--light);
  font-size: 14px;
  line-height: 1.7;
  margin-bottom: 8px;
}

.welcome-message em {
  color: var(--text-muted);
  font-size: 12px;
}

/* ===== CHAT BUBBLES ===== */
.chat-bubble.user {
  max-width: 75%;
  background: #3a3a4a;
  color: #ffffff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  border: 1px solid #4a4a5a;
  box-shadow: var(--shadow-outer);
  font-size: 15px;
  line-height: 1.7;
}

.chat-bubble.bot {
  max-width: 75%;
  background: var(--bg-bubble-bot);
  color: var(--text-primary);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  border-left: 3px solid var(--accent);
  box-shadow: var(--shadow-outer);
  font-size: 15px;
  line-height: 1.7;
}

[data-theme="night"] .chat-bubble.user {
  background: #7a2800;
  border-color: #a03800;
}

[data-theme="night"] .chat-bubble.bot {
  background: #1a0e00;
  border-left-color: var(--gold);
  color: #fff5e6;
}

.chat-bubble.bot .bubble-label {
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ===== TYPING INDICATOR ===== */
.typing-indicator {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 14px 18px;
  background: var(--bot-bubble);
  border-radius: 18px;
  border-left: 3px solid var(--gold);
  width: fit-content;
  align-self: flex-start;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--gold);
  border-radius: 50%;
  animation: bounce 1.2s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%           { transform: translateY(-8px); }
}

/* ===== INPUT AREA ===== */
#input-area {
  background: var(--secondary);
  border-top: 1px solid var(--border);
  padding: 14px 16px;
  flex-shrink: 0;
  /* Keeps input above keyboard on mobile */
  position: sticky;
  bottom: 0;
}

.input-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

#user-input {
  flex: 1;
  background: var(--input-bg);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 15px;
  resize: none;
  outline: none;
  font-family: inherit;
  max-height: 120px;
  overflow-y: auto;
  box-shadow: var(--shadow-inward);
  transition: border 0.2s;
  /* Prevent iOS zoom on focus */
  font-size: max(16px, 15px);
}

#user-input:focus {
  border-color: var(--accent);
}

#send-btn {
  background: var(--send-btn);
  color: var(--send-text);
  border: none;
  border-radius: 12px;
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.2s;
  white-space: nowrap;
  box-shadow: var(--shadow-outer);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
  header {
    padding: 10px 12px;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .header-left .app-title {
    font-size: 18px;
  }

  .header-left .tagline {
    font-size: 11px;
  }

  .header-right {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  .header-right select {
    flex: 1;
    min-width: 120px;
    font-size: 12px;
    padding: 5px 8px;
  }

  #theme-toggle,
  #edit-profile-btn {
    padding: 5px 8px;
    font-size: 14px;
  }

  #chat-window {
    padding: 12px 10px;
  }

  .chat-bubble {
    max-width: 88%;
    font-size: 14px;
    padding: 10px 14px;
  }

  .welcome-message {
    padding: 16px;
    margin: 0 4px;
  }

  .welcome-message h2 {
    font-size: 18px;
  }

  .welcome-message p {
    font-size: 13px;
  }

  #input-area {
    padding: 10px 10px;
  }

  #user-input {
    padding: 10px 12px;
  }

  #send-btn {
    padding: 10px 14px;
    font-size: 14px;
  }

  .input-note {
    font-size: 10px;
  }

  .message-counter {
    font-size: 10px;
  }

  .profile-card {
    padding: 24px 16px;
    margin: 16px;
  }

  .lock-content h1 {
    font-size: 60px;
  }

  .lock-content h2 {
    font-size: 24px;
  }

  .lock-content p {
    font-size: 15px;
  }
}

/* ===== MARKDOWN STYLES IN BUBBLES ===== */
.bubble-text h1, .bubble-text h2, .bubble-text h3 {
  color: var(--gold);
  margin: 12px 0 6px 0;
}

.bubble-text h1 { font-size: 18px; }
.bubble-text h2 { font-size: 16px; }
.bubble-text h3 { font-size: 14px; }

.bubble-text strong {
  color: var(--gold);
}

.bubble-text em {
  color: var(--text-muted);
  font-style: italic;
}

.bubble-text blockquote {
  border-left: 3px solid var(--gold);
  padding: 8px 12px;
  margin: 8px 0;
  background: rgba(226, 185, 111, 0.08);
  border-radius: 0 8px 8px 0;
  font-style: italic;
}

.bubble-text hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 12px 0;
}

.bubble-text ul {
  padding-left: 20px;
  margin: 8px 0;
}

.bubble-text li {
  margin: 4px 0;
  line-height: 1.6;
}

.bubble-text th {
  background: var(--accent);
  padding: 8px 12px;
  border: 1px solid var(--border);
  color: #ffffff;
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

[data-theme="night"] .bubble-text th {
  background: #c45e00;
  color: #ffffff;
  border-color: #e87c2a;
}

.bubble-text table {
  border-collapse: collapse;
  width: 100%;
  margin: 10px 0;
  display: table;
  overflow-x: auto;
}

.bubble-text td, .bubble-text th {
  padding: 8px 12px;
  border: 1px solid var(--border);
  text-align: left;
  white-space: normal;
  word-break: break-word;
}

.bubble-text tr:nth-child(even) {
  background: rgba(0,0,0,0.03);
}

#theme-toggle {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 16px;
  cursor: pointer;
  box-shadow: var(--shadow-inward);
  transition: all 0.3s;
}

#theme-toggle:hover {
  opacity: 0.8;
  transform: scale(1.05);
}

/* ===== PROFILE SCREEN ===== */
#profile-screen {
  position: fixed;
  inset: 0;
  background: var(--bg-main);
  background-image: var(--smoke);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
}

#profile-screen.hidden {
  display: none;
}

.profile-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px;
  max-width: 420px;
  width: 90%;
  text-align: center;
  box-shadow: var(--shadow-outer), var(--shadow-inward);
}

.profile-card h1 {
  font-size: 50px;
  margin-bottom: 10px;
}

.profile-card h2 {
  color: var(--accent);
  font-size: 22px;
  margin-bottom: 8px;
}

.profile-card > p {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 24px;
}

.profile-step.hidden {
  display: none;
}

.profile-btn {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  border: none;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 10px;
  transition: transform 0.1s, opacity 0.2s;
}

.profile-btn:hover {
  opacity: 0.9;
  transform: scale(1.02);
}

.profile-btn.primary {
  background: var(--send-btn);
  color: var(--send-text);
}

.profile-btn.secondary {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.profile-card input,
.profile-card select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text-primary);
  font-size: 14px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-inward);
  outline: none;
  font-family: inherit;
}

.profile-label {
  text-align: left;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.profile-error {
  color: #e53935;
  font-size: 13px;
  margin: -6px 0 14px 0;
  text-align: left;
}

.profile-error.hidden {
  display: none;
}

.profile-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

#edit-profile-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 16px;
  cursor: pointer;
  box-shadow: var(--shadow-inward);
}

/* ===== TEXT TO SPEECH ===== */
.tts-controls {
  margin-top: 10px;
  display: flex;
  gap: 8px;
}

.tts-btn, .tts-stop {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-primary);
  transition: all 0.2s;
}

.tts-btn:hover {
  background: var(--accent);
  color: var(--send-text);
}

.tts-stop {
  border-color: #e53935;
  color: #e53935;
}

.tts-stop.hidden {
  display: none;
}

/* ===== KIDZ CONSTRUCTION OVERLAY ===== */
#kidz-construction {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #fff9e6, #fff0f0, #e6f0ff);
  z-index: 9999;
  overflow: hidden;
}

#kidz-bounce {
  position: absolute;
  text-align: center;
  width: 280px;
  cursor: pointer;
}

#kidz-bounce img {
  width: 260px;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

#kidz-bounce p {
  font-size: 18px;
  font-weight: 700;
  color: #333;
  margin-top: 8px;
  font-family: 'Segoe UI', sans-serif;
}

#kidz-close-btn {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1a1a1a;
  color: white;
  border: none;
  border-radius: 12px;
  padding: 12px 28px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  z-index: 10000;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

#kidz-close-btn:hover {
  opacity: 0.85;
}

.message-counter {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 4px;
  transition: color 0.3s;
}

.bubble-text ol {
  padding-left: 20px;
  margin: 8px 0;
}

.bubble-text ol li {
  margin: 6px 0;
  line-height: 1.6;
  padding-left: 4px;
}
/* ===== SALVATION BUTTON — header ===== */
#salvation-btn {
  background: linear-gradient(135deg, #6a0dad, #9b30d0);
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 7px 14px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 2px 10px rgba(106,13,173,0.35);
  transition: all 0.2s ease;
  margin-right: 6px;
}
#salvation-btn:hover {
  background: linear-gradient(135deg, #7b1ab8, #a83de0);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(106,13,173,0.45);
}
[data-theme="night"] #salvation-btn {
  background: linear-gradient(135deg, #3d0070, #6a0dad);
  box-shadow: 0 2px 10px rgba(150,50,220,0.4);
}

/* ===== SALVATION OVERLAY ===== */
#salvation-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: salvFadeIn 0.3s ease;
}

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

#salvation-card {
  background: #fff;
  border-radius: 20px;
  padding: 32px 28px 24px;
  max-width: 420px;
  width: 100%;
  position: relative;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  animation: salvSlideUp 0.35s cubic-bezier(0.34,1.56,0.64,1);
}

[data-theme="night"] #salvation-card {
  background: #1a0a2e;
  color: #f0e6ff;
}

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

#salvation-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: #999;
  line-height: 1;
  padding: 4px;
}
#salvation-close:hover { color: #333; }
[data-theme="night"] #salvation-close:hover { color: #ccc; }

.salvation-step { display: none; }
.salvation-step.active { display: block; }

.salvation-cross {
  font-size: 2.8rem;
  margin-bottom: 10px;
}

#salvation-card h2 {
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 14px;
  color: #1a1a1a;
}
[data-theme="night"] #salvation-card h2 { color: #f0e6ff; }

.salvation-verse {
  font-style: italic;
  font-size: 0.92rem;
  line-height: 1.6;
  color: #444;
  margin-bottom: 4px;
  padding: 0 4px;
}
[data-theme="night"] .salvation-verse { color: #d4b8f0; }

.salvation-ref {
  font-size: 0.78rem;
  color: #888;
  margin-bottom: 14px;
  font-weight: 600;
}
[data-theme="night"] .salvation-ref { color: #a080c0; }

.salvation-body {
  font-size: 0.9rem;
  line-height: 1.6;
  color: #333;
  margin-bottom: 18px;
}
[data-theme="night"] .salvation-body { color: #e0d0f8; }

.salvation-prayer {
  background: #f9f3ff;
  border-left: 3px solid #9b30d0;
  border-radius: 10px;
  padding: 14px 16px;
  margin: 10px 0 20px;
  font-size: 0.9rem;
  line-height: 1.7;
  text-align: left;
  color: #2a0050;
}
[data-theme="night"] .salvation-prayer {
  background: #2a1040;
  color: #e8d5ff;
  border-left-color: #c060ff;
}

.salvation-next-steps {
  text-align: left;
  background: #f0fff4;
  border-radius: 10px;
  padding: 14px 16px;
  margin: 12px 0 20px;
  font-size: 0.88rem;
  line-height: 1.9;
  color: #1a4a2a;
}
[data-theme="night"] .salvation-next-steps {
  background: #0a2010;
  color: #90ee90;
}

.salvation-next-btn {
  display: block;
  width: 100%;
  padding: 13px;
  background: linear-gradient(135deg, #6a0dad, #9b30d0);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 4px;
}
.salvation-next-btn:hover {
  background: linear-gradient(135deg, #7b1ab8, #a83de0);
  transform: translateY(-1px);
}

.salvation-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 18px;
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ddd;
  transition: background 0.3s;
}
.dot.active { background: #9b30d0; }
[data-theme="night"] .dot { background: #444; }
[data-theme="night"] .dot.active { background: #c060ff; }

/* ===== STREAMING CURSOR ===== */
.streaming-text::after {
  content: '▌';
  animation: blink 0.7s step-end infinite;
  color: var(--accent, #b8860b);
  margin-left: 2px;
}
.streaming-text.done::after {
  display: none;
}
@keyframes blink {
  50% { opacity: 0; }
}

/* ===== CHAT HISTORY RESTORE NOTE ===== */
.history-restored-note {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted, #888);
  padding: 8px 0;
  margin: 4px 0 12px;
  font-style: italic;
  border-top: 1px dashed var(--border, rgba(0,0,0,0.1));
}
.history-clear-btn {
  background: none;
  border: none;
  color: var(--accent, #b8860b);
  font-size: 0.75rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
  font-family: inherit;
}

/* ===== SALVATION BUTTON — mobile ===== */
@media (max-width: 540px) {
  #salvation-btn {
    font-size: 0.7rem;
    padding: 6px 10px;
  }
}
@media (max-width: 380px) {
  #salvation-btn {
    font-size: 0;
    padding: 7px 10px;
  }
  #salvation-btn::before {
    content: '🕊️';
    font-size: 1rem;
  }
}
