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

body {
  background: #ffffff;
  font-family: 'Lora', Georgia, 'Times New Roman', serif;
  -webkit-font-smoothing: antialiased;
}

/* Loading overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #ffffff;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 300ms ease;
}

.loading-content {
  text-align: center;
  max-width: 400px;
  padding: 40px;
}

.loading-title {
  font-family: 'Lora', Georgia, serif;
  font-size: 24px;
  font-weight: 400;
  color: #1a1a1a;
  margin-bottom: 32px;
  letter-spacing: 0.03em;
}

.loading-progress {
  width: 100%;
  height: 2px;
  background: #e8e2d8;
  border-radius: 1px;
  overflow: hidden;
  margin-bottom: 16px;
}

.loading-progress-fill {
  height: 100%;
  background: #1a1a1a;
  width: 0%;
  transition: width 200ms ease;
}

.loading-status {
  font-family: 'Lora', Georgia, serif;
  font-size: 13px;
  color: #888888;
  font-style: italic;
}

/* Background progress indicator (centered bottom) */
.bg-progress {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid #e8e2d8;
  border-radius: 8px;
  padding: 14px 28px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.06);
  z-index: 100;
  min-width: 240px;
  text-align: center;
}

.bg-progress-bar {
  width: 100%;
  height: 2px;
  background: #e8e2d8;
  border-radius: 1px;
  overflow: hidden;
  margin-bottom: 8px;
}

.bg-progress-fill {
  height: 100%;
  background: #666666;
  width: 0%;
  transition: width 200ms ease;
}

.bg-progress-status {
  font-family: 'Lora', Georgia, serif;
  font-size: 11px;
  color: #666666;
  text-align: center;
}

/* Navigation */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  padding: 28px 0 0 60px;
  z-index: 10;
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.book-select {
  font-family: 'Lora', Georgia, serif;
  font-size: 13px;
  color: #666666;
  border: none;
  background: none;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  cursor: pointer;
  padding-right: 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5' viewBox='0 0 8 5'%3E%3Cpath d='M0 0l4 5 4-5z' fill='%23999999'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0 center;
}

.book-select:focus {
  color: #1a1a1a;
}

.chapter-btn {
  font-family: 'Lora', Georgia, serif;
  font-size: 13px;
  color: #888888;
  border: none;
  background: none;
  outline: none;
  cursor: pointer;
  padding: 0 4px;
  transition: color 120ms;
}

.chapter-btn:hover {
  color: #1a1a1a;
}

.chapter-label {
  font-family: 'Lora', Georgia, serif;
  font-size: 13px;
  color: #666666;
  margin-left: 4px;
}

.translation-select {
  font-family: 'Lora', Georgia, serif;
  font-size: 13px;
  color: #666666;
  border: none;
  background: none;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  cursor: pointer;
  margin-left: 16px;
  padding-right: 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5' viewBox='0 0 8 5'%3E%3Cpath d='M0 0l4 5 4-5z' fill='%23999999'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0 center;
}

.translation-select:focus {
  color: #1a1a1a;
}

/* Panels */
.panels {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.bible-panel {
  flex: 1;
  padding: 80px 40px 40px 60px;
  overflow-y: auto;
  max-width: 50%;
}

.bible-text {
  max-width: 42ch;
  font-size: 18px;
  color: #1a1a1a;
  line-height: 1.9;
  animation: fadeIn 300ms ease;
}

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

/* Verse numbers */
.verse-num {
  display: inline;
  font-size: 10px;
  color: #aaaaaa;
  vertical-align: super;
  margin-right: 2px;
  user-select: none;
  -webkit-user-select: none;
}

/* Words */
.word {
  cursor: pointer;
  display: inline;
  transition: background-color 120ms;
}

.word:hover {
  background-color: #f5f0e8;
}

.word.active-word {
  background-color: #e8dfd0;
}

.word.active-verse {
  background-color: #f5f0e8;
}

/* Selection */
::selection {
  background: #f5f0e8;
}

/* Red-letter */
.red-letter {
  color: #c0392b;
}

/* Divider */
.divider {
  width: 1px;
  background: #e0d9ce;
  align-self: stretch;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 12%, black 88%, transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0%, black 12%, black 88%, transparent 100%);
}

/* Context panel */
.context-panel {
  flex: 1;
  padding: 40px 48px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.context-content {
  width: 100%;
  max-width: 440px;
  transition: opacity 180ms ease;
}

.placeholder {
  font-family: 'Lora', Georgia, serif;
  font-size: 14px;
  color: #bbbbbb;
  font-style: italic;
  margin-top: 40vh;
}

/* --- Tabbed research panel --- */
.research-header {
  margin-bottom: 20px;
}

.verse-ref {
  font-family: 'Lora', serif;
  font-size: 14px;
  font-variant: small-caps;
  letter-spacing: 0.08em;
  color: #777777;
}

.tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid #e8e2d8;
  margin-bottom: 20px;
}

.tab-btn {
  font-family: 'Lora', Georgia, serif;
  font-size: 13px;
  color: #999999;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 8px 14px 6px;
  cursor: pointer;
  transition: color 150ms, border-color 150ms;
  letter-spacing: 0.02em;
}

.tab-btn:hover {
  color: #555555;
}

.tab-btn.active {
  color: #1a1a1a;
  border-bottom-color: #1a1a1a;
}

.tab-btn .tab-count {
  font-size: 10px;
  color: #bbbbbb;
  margin-left: 3px;
}

.tab-btn.active .tab-count {
  color: #888888;
}

.tab-panel {
  display: none;
  opacity: 0;
  transition: opacity 180ms ease;
}

.tab-panel.active {
  display: block;
  opacity: 1;
}

/* --- Word tab (carousel) --- */
.word-carousel {
  max-height: calc(100vh - 200px);
  overflow-y: auto;
  position: relative;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 8%, black 92%, transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0%, black 8%, black 92%, transparent 100%);
  padding: 32px 0;
  scrollbar-width: none;
  scroll-behavior: smooth;
}

.word-carousel::-webkit-scrollbar {
  display: none;
}

.word-card {
  padding: 12px 0;
  border-bottom: 1px solid #f0ece4;
  opacity: 0.45;
  transition: opacity 200ms ease;
}

.word-card:last-child {
  border-bottom: none;
}

.word-card.highlighted {
  background: #f9f6f0;
  margin: 0 -12px;
  padding: 20px 12px;
  border-radius: 4px;
  opacity: 1;
}

.word-card.highlighted .word-original {
  font-size: 1.6rem;
}

.word-card.highlighted .word-english-inline {
  font-size: 18px;
}

.word-card.highlighted .word-def {
  font-size: 16px;
}

.word-card-header {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 4px;
}

.word-original {
  font-size: 1.35rem;
  color: #1a1a1a;
}

.word-arrow {
  font-size: 12px;
  color: #cccccc;
}

.word-english-inline {
  font-family: 'Lora', serif;
  font-size: 16px;
  color: #2a2a2a;
  font-weight: 700;
}

.word-meta {
  font-family: 'Lora', serif;
  font-style: italic;
  font-size: 12px;
  color: #888888;
  margin-bottom: 2px;
}

.word-def {
  font-family: 'Lora', serif;
  font-size: 15px;
  color: #2a2a2a;
  line-height: 1.75;
  margin-top: 6px;
}

.word-derivation {
  font-family: 'Lora', serif;
  font-size: 14px;
  color: #555555;
  line-height: 1.6;
  margin-top: 4px;
  font-style: italic;
}

/* --- Commentary tab --- */
.commentary-section {
  margin-bottom: 24px;
}

.commentary-source {
  font-variant: small-caps;
  color: #777777;
  font-size: 13px;
  margin-bottom: 8px;
  letter-spacing: 0.05em;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

.commentary-source::before {
  content: '\25BE';
  font-size: 10px;
  transition: transform 150ms;
}

.commentary-section.collapsed .commentary-source::before {
  transform: rotate(-90deg);
}

.commentary-body {
  font-family: 'Lora', Georgia, serif;
  font-size: 15px;
  line-height: 1.8;
  color: #2a2a2a;
}

.commentary-section.collapsed .commentary-body,
.commentary-section.collapsed .fathers-list {
  display: none;
}

/* --- Church Fathers tab --- */
.father-entry {
  margin-bottom: 16px;
  padding-left: 12px;
  border-left: 2px solid #e0d8cc;
}

.father-author {
  font-size: 13px;
  color: #777777;
  font-style: italic;
  margin-bottom: 4px;
}

.father-quote {
  font-family: 'Lora', Georgia, serif;
  font-size: 15px;
  line-height: 1.75;
  color: #333333;
}

.show-more-btn {
  font-family: 'Lora', Georgia, serif;
  font-size: 12px;
  color: #888888;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 0;
  font-style: italic;
  transition: color 150ms;
}

.show-more-btn:hover {
  color: #333333;
}

/* --- Synthesis tab --- */
.gemini-synthesis {
  font-family: 'Lora', Georgia, serif;
  font-size: 14px;
  line-height: 1.8;
  color: #2a2a2a;
}

.gemini-label {
  font-variant: small-caps;
  color: #777777;
  font-size: 12px;
  margin-bottom: 10px;
  letter-spacing: 0.05em;
}

.synthesis-text {
  font-family: 'Lora', Georgia, serif;
  font-size: 15px;
  line-height: 1.8;
  color: #2a2a2a;
  white-space: pre-wrap;
  animation: fadeIn 300ms ease;
}

/* Model loader */
.model-loader {
  padding: 20px 0;
}

.model-info {
  font-family: 'Lora', Georgia, serif;
  font-size: 14px;
  line-height: 1.7;
  color: #666666;
  margin-bottom: 12px;
}

.load-model-btn {
  font-family: 'Lora', Georgia, serif;
  font-size: 13px;
  color: #ffffff;
  background: #1a1a1a;
  border: none;
  padding: 10px 20px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 150ms;
}

.load-model-btn:hover:not(:disabled) {
  background: #333333;
}

.load-model-btn:disabled {
  background: #888888;
  cursor: not-allowed;
}

/* Commentary display */
.commentary-text {
  font-family: 'Lora', Georgia, serif;
  font-size: 14px;
  color: #2a2a2a;
  line-height: 1.8;
}

/* Loading cursor */
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.loading::after {
  content: '';
  display: inline-block;
  width: 1px;
  height: 1em;
  background: #1a1a1a;
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink 800ms step-end infinite;
}

/* Responsive */
@media (max-width: 768px) {
  .nav {
    padding: 20px 0 0 24px;
  }

  .panels {
    flex-direction: column;
    height: auto;
    min-height: 100vh;
  }

  .bible-panel {
    max-width: 100%;
    padding: 72px 24px 32px 24px;
  }

  .divider {
    width: auto;
    height: 1px;
    align-self: stretch;
    -webkit-mask-image: linear-gradient(to right, transparent 0%, black 12%, black 88%, transparent 100%);
    mask-image: linear-gradient(to right, transparent 0%, black 12%, black 88%, transparent 100%);
  }

  .context-panel {
    padding: 24px;
    align-items: flex-start;
  }

  .tab-btn {
    padding: 8px 10px 6px;
    font-size: 11px;
  }

  .bg-progress {
    bottom: 12px;
    min-width: 180px;
    padding: 12px 20px;
  }
}
