/* ── Variables ─────────────────────────────────────────────────────────────── */
:root {
  --ink: #1B365D;
  --accent: #487A7B;
  --accent-light: rgba(72, 122, 123, 0.10);
  --accent-hover: #3a6566;
  --muted: #707372;
  --prompt: #B2B4B2;
  --border: #dde1e7;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --imb-red: #B83A4B;
  --imb-teal: #009681;
  --imb-orange: #E87722;
  --success: #009681;
  --error: #B83A4B;

  --font-ui: 'Nunito Sans', 'Segoe UI', sans-serif;
  --font-body: 'Source Sans 3', 'Segoe UI', sans-serif;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.10);
}

/* ── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ─────────────────────────────────────────────────────────────────── */
.site-header {
  background: var(--ink);
  color: white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  justify-content: space-between;
  display: flex;
  align-items: center;
}
.logo-area {
  display: flex;
  align-items: center;
  gap: 14px;
}
.logo {
  height: 26px;
  width: auto;
  opacity: 0.95;
}
.title-block {
  display: flex;
  flex-direction: column;
  gap: 1px;
  border-left: 1px solid rgba(255,255,255,0.25);
  padding-left: 14px;
}
.app-name {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 1.05rem;
  color: white;
  line-height: 1.2;
}
.app-tagline {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.65);
  font-family: var(--font-ui);
  font-weight: 400;
  letter-spacing: 0.01em;
}

/* ── Tab Nav ─────────────────────────────────────────────────────────────────── */
.tab-nav {
  background: var(--surface);
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 60px;
  z-index: 90;
  box-shadow: var(--shadow);
}
.tab-nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  gap: 4px;
}
.tab-btn {
  font-family: var(--font-ui);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: none;
  padding: 14px 20px 12px;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
  display: flex;
  align-items: center;
  gap: 6px;
  letter-spacing: 0.01em;
}
.tab-btn:hover { color: var(--ink); }
.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.tab-icon { font-size: 1rem; }

/* ── Main Content ────────────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 28px 24px;
}

/* ── Panel Grid ──────────────────────────────────────────────────────────────── */
.panel-grid {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 24px;
  align-items: start;
}

/* ── Panel Inputs ────────────────────────────────────────────────────────────── */
.panel-inputs {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 116px;
}
.panel-inputs h2 {
  font-family: var(--font-ui);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 6px;
}
.panel-desc {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 20px;
}

/* ── Form Elements ───────────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 5px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.required { color: var(--imb-red); margin-left: 2px; }
.optional {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--prompt);
  font-size: 0.78rem;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--ink);
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
  resize: vertical;
}
.form-group input::placeholder,
.form-group textarea::placeholder { color: var(--prompt); }
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
  background: white;
}
.form-group select { cursor: pointer; }

/* ── Buttons ─────────────────────────────────────────────────────────────────── */
.btn-row { margin-top: 20px; }

.btn-primary {
  width: 100%;
  font-family: var(--font-ui);
  font-size: 0.9rem;
  font-weight: 700;
  color: white;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  padding: 11px 20px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 2px 6px rgba(72,122,123,0.3);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: 0 4px 10px rgba(72,122,123,0.35);
}
.btn-primary:active:not(:disabled) { transform: translateY(1px); }
.btn-primary:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.btn-ghost {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 12px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.btn-ghost:hover {
  color: var(--ink);
  border-color: var(--muted);
  background: var(--bg);
}

.btn-export {
  font-family: var(--font-ui);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-light);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius);
  padding: 5px 11px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  letter-spacing: 0.02em;
}
.btn-export:hover { background: var(--accent); color: white; }

.btn-accent {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 700;
  color: white;
  background: var(--ink);
  border: none;
  border-radius: var(--radius);
  padding: 6px 14px;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-accent:hover { background: #243f6e; }

/* ── Upload Zone ─────────────────────────────────────────────────────────────── */
/* ── Style Hint ──────────────────────────────────────────────────────────────── */
.style-hint {
  margin-top: 7px;
  padding: 10px 12px;
  background: var(--accent-light);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 0.8rem;
  color: var(--ink);
  line-height: 1.55;
  display: none;
}
.style-hint.visible { display: block; }
.style-hint strong {
  display: block;
  font-family: var(--font-ui);
  font-weight: 700;
  margin-bottom: 3px;
  color: var(--accent);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.divider-or {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0;
  color: var(--prompt);
  font-size: 0.8rem;
  font-family: var(--font-ui);
}
.divider-or::before,
.divider-or::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.upload-zone {
  background: var(--bg);
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.btn-upload {
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent);
  background: white;
  border: 1.5px solid var(--accent);
  border-radius: var(--radius);
  padding: 6px 14px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.btn-upload:hover { background: var(--accent); color: white; }
.upload-hint {
  font-size: 0.78rem;
  color: var(--prompt);
  font-family: var(--font-ui);
}
.selected-filename {
  font-size: 0.82rem;
  color: var(--accent);
  font-weight: 600;
  font-family: var(--font-ui);
  word-break: break-all;
}

/* ── Output Panel ────────────────────────────────────────────────────────────── */
.panel-output {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: 520px;
}
.output-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.output-label {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.output-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.output-area {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  max-height: 72vh;
}

/* ── Placeholder ─────────────────────────────────────────────────────────────── */
.output-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 300px;
  text-align: center;
  color: var(--prompt);
  gap: 10px;
}
.placeholder-cross {
  font-size: 2.2rem;
  opacity: 0.5;
  margin-bottom: 4px;
}
.output-placeholder p {
  font-size: 0.95rem;
  color: var(--muted);
}
.placeholder-hint {
  font-size: 0.82rem !important;
  color: var(--prompt) !important;
}

/* ── Streaming Indicator ─────────────────────────────────────────────────────── */
.streaming-dots {
  display: flex;
  gap: 5px;
  padding: 16px 0;
  align-items: center;
}
.streaming-dots .dot {
  width: 7px;
  height: 7px;
  background: var(--accent);
  border-radius: 50%;
  animation: pulse 1.2s ease-in-out infinite;
}
.streaming-dots .dot:nth-child(2) { animation-delay: 0.2s; }
.streaming-dots .dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes pulse {
  0%, 100% { opacity: 0.3; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.1); }
}

/* ── Spinner (button loading) ────────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Prose (markdown output) ─────────────────────────────────────────────────── */
.prose { line-height: 1.7; }
.prose h1, .prose h2, .prose h3, .prose h4 {
  font-family: var(--font-ui);
  color: var(--ink);
  margin-top: 1.4em;
  margin-bottom: 0.4em;
  line-height: 1.3;
}
.prose h1 { font-size: 1.4rem; font-weight: 800; }
.prose h2 { font-size: 1.15rem; font-weight: 700; border-bottom: 1.5px solid var(--border); padding-bottom: 6px; }
.prose h3 { font-size: 1rem; font-weight: 700; color: var(--accent); }
.prose h4 { font-size: 0.95rem; font-weight: 700; }
.prose p { margin-bottom: 0.85em; font-size: 0.95rem; }
.prose ul, .prose ol { padding-left: 1.5em; margin-bottom: 0.85em; }
.prose li { margin-bottom: 0.3em; font-size: 0.95rem; }
.prose strong { font-weight: 700; color: var(--ink); }
.prose em { font-style: italic; }
.prose blockquote {
  border-left: 3px solid var(--accent);
  background: var(--accent-light);
  padding: 10px 16px;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 1em 0;
  color: var(--ink);
  font-style: italic;
}
.prose code {
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.88rem;
  font-family: 'Menlo', 'Consolas', monospace;
  color: var(--imb-red);
}
.prose hr {
  border: none;
  border-top: 1.5px solid var(--border);
  margin: 1.5em 0;
}
.prose > *:first-child { margin-top: 0; }

/* ── Error Message ───────────────────────────────────────────────────────────── */
.error-msg {
  background: #fff0f0;
  border: 1.5px solid #ffd5d5;
  border-radius: var(--radius);
  padding: 14px 16px;
  color: var(--imb-red);
  font-size: 0.9rem;
  font-family: var(--font-ui);
}

/* ── Toast ───────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: white;
  font-family: var(--font-ui);
  font-size: 0.875rem;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 999px;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  white-space: nowrap;
  z-index: 999;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.success { background: var(--success); }
.toast.error { background: var(--error); }

/* ── Footer ──────────────────────────────────────────────────────────────────── */
.site-footer {
  text-align: center;
  padding: 16px 24px;
  font-size: 0.78rem;
  color: var(--prompt);
  font-family: var(--font-ui);
  border-top: 1px solid var(--border);
  background: var(--surface);
  margin-top: auto;
}

/* ── Responsive ──────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .panel-grid {
    grid-template-columns: 1fr;
  }
  .panel-inputs {
    position: static;
  }
  .output-area {
    max-height: 55vh;
  }
  .tab-btn {
    padding: 12px 14px 10px;
    font-size: 0.82rem;
  }
}
@media (max-width: 600px) {
  .main-content { padding: 16px; }
  .header-inner { padding: 0 16px; }
  .tab-nav-inner { padding: 0 16px; }
  .app-tagline { display: none; }
}

/* ── Auth Area ──────────────────────────────────────────────────────────────── */
.auth-area {
  display: flex;
  align-items: center;
  margin-left: auto;
}
.auth-user {
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.4);
}
.user-name {
  color: rgba(255,255,255,0.9);
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 600;
}
.btn-auth-in {
  background: rgba(255,255,255,0.12);
  color: white;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 999px;
  padding: 6px 16px;
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-auth-in:hover { background: rgba(255,255,255,0.22); }
.btn-auth-out {
  background: transparent;
  color: rgba(255,255,255,0.65);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 999px;
  padding: 4px 12px;
  font-family: var(--font-ui);
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-auth-out:hover { color: white; border-color: rgba(255,255,255,0.5); }

/* ── Step Progress ─────────────────────────────────────────────────────────── */
.step-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.step-dots {
  display: flex;
  gap: 6px;
}
.step-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.2s;
  display: inline-block;
}
.step-dot.active { background: var(--accent); box-shadow: 0 0 0 3px rgba(72,122,123,0.2); }
.step-dot.done { background: var(--imb-teal); }
.step-label {
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Step Controls ─────────────────────────────────────────────────────────── */
.step-controls {
  display: flex;
  gap: 10px;
  padding: 14px 0 4px;
  flex-wrap: wrap;
}

/* ── Research Complete Banner ───────────────────────────────────────────────── */
.research-complete {
  background: var(--accent-light);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 1.2rem 1.4rem;
  margin-top: 1rem;
}
.complete-title {
  font-family: var(--font-ui);
  font-weight: 800;
  font-size: 1rem;
  color: var(--ink);
  margin-bottom: 0.3rem;
}
.complete-desc {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 1rem;
}
.complete-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}
.btn-save {
  background: var(--ink);
  color: white;
  border: none;
  border-radius: 999px;
  padding: 8px 18px;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-save:hover { background: #254a7a; }
.btn-save:disabled { background: var(--muted); cursor: default; }

/* ── My Sermons Tab ─────────────────────────────────────────────────────────── */
.sermons-page {
  max-width: 860px;
  margin: 0 auto;
}
.sermons-page h2 {
  font-family: var(--font-ui);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--ink);
  margin-bottom: 0.4rem;
}
.sermons-list {
  margin-top: 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.sermon-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  cursor: pointer;
  transition: box-shadow 0.12s, border-color 0.12s;
}
.sermon-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--accent);
}
.sermon-card-title {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 1rem;
  color: var(--ink);
  margin-bottom: 0.3rem;
}
.sermon-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  font-size: 0.82rem;
  color: var(--muted);
}
.sermon-card-meta span::before { content: ''; }
.sermon-card-meta span + span::before { content: '·'; margin-right: 0.6rem; }
