:root {
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ink: #192523;
  --muted: #60706b;
  --line: #d9dfd7;
  --paper: #fbfaf4;
  --panel: rgba(255, 255, 250, 0.88);
  --teal: #0f5b55;
  --teal-2: #123f3c;
  --gold: #b9893d;
  --rose: #8b4f57;
  --shadow: 0 18px 42px rgba(16, 31, 29, 0.14);
}



/* Learning entry points and compact full-screen readers */
.learning-entry-group {
  display: grid;
  flex: 1 1 360px;
  gap: 8px;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  min-width: 300px;
}

.learning-entry-group .icon-button {
  gap: 8px;
  height: 46px;
  justify-content: center;
  padding-inline: 14px;
  width: 100%;
}

.elifba-entry-button {
  background: #eef1e9;
  border-color: #cfd8cd;
  color: var(--teal-2);
}

.reader-shell {
  grid-template-rows: minmax(0, 1fr) auto;
}

.reader-header {
  box-shadow: none;
  margin: 0 auto;
  max-width: 940px;
  width: 100%;
}

.reader-scroll {
  min-height: 0;
}

.reader-download-button {
  max-width: 180px;
  min-width: 132px;
  overflow: visible;
}

.reader-download-button span {
  min-width: 0;
  overflow-wrap: anywhere;
  text-align: center;
}

.elifba-view {
  background:
    linear-gradient(180deg, rgba(251, 250, 244, 0.98), rgba(239, 242, 233, 0.98)),
    url("assets/geometric-pattern.png") center / cover fixed;
  inset: 0;
  position: fixed;
  z-index: 910;
}

.elifba-scroll {
  height: 100%;
  overflow: auto;
  overscroll-behavior: contain;
}

.elifba-header,
.elifba-lessons,
.elifba-content {
  margin-inline: auto;
  max-width: 940px;
  width: 100%;
}

.elifba-header {
  align-items: center;
  background: rgba(255, 255, 250, 0.96);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) 18px 12px;
}

.elifba-header h2 {
  font-size: 20px;
  margin: 0;
}

.elifba-header p {
  color: var(--muted);
  font-size: 13px;
  margin: 2px 0 0;
}

.elifba-progress {
  background: #dfe6dc;
  height: 4px;
}

.elifba-progress span {
  background: var(--gold);
  display: block;
  height: 100%;
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 180ms ease;
}

html[dir="rtl"] .elifba-progress span {
  transform-origin: right center;
}

.elifba-lessons {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 14px 18px 8px;
  scrollbar-width: thin;
}

.elifba-lesson-tab {
  align-items: center;
  background: #eef3ec;
  border: 1px solid #d5ded2;
  color: var(--teal-2);
  display: inline-flex;
  flex: 0 0 auto;
  gap: 7px;
  min-height: 42px;
  padding: 8px 12px;
}

.elifba-lesson-tab.active {
  background: var(--teal);
  border-color: var(--teal);
  color: white;
}

.elifba-lesson-tab.complete::before {
  content: "✓";
  font-weight: 800;
}

.elifba-content {
  background: rgba(255, 254, 248, 0.96);
  min-height: calc(100% - 150px);
  padding: 18px clamp(16px, 5vw, 54px) calc(44px + env(safe-area-inset-bottom));
}

.elifba-content-header {
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
  padding-bottom: 14px;
}

.elifba-content-header h3 {
  color: var(--teal-2);
  font-size: 24px;
  margin: 0 0 6px;
}

.elifba-content-header p {
  color: var(--muted);
  line-height: 1.55;
  margin: 0;
}

.elifba-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
}

.elifba-letter,
.elifba-example,
.elifba-answer {
  background: #fffdf7;
  border: 1px solid #d5ddd3;
  color: var(--ink);
}

.elifba-letter {
  align-items: center;
  display: grid;
  gap: 5px;
  justify-items: center;
  min-height: 116px;
  padding: 10px 8px;
}

.elifba-letter:hover,
.elifba-letter:focus-visible,
.elifba-answer:hover,
.elifba-answer:focus-visible {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(185, 137, 61, 0.16);
}

.elifba-glyph {
  color: #122321;
  direction: rtl;
  font-family: "Noto Naskh Arabic", "Amiri", "Scheherazade New", serif;
  font-size: 48px;
  line-height: 1.2;
}

.elifba-letter small {
  color: var(--muted);
  font-size: 12px;
}

.elifba-example-list {
  display: grid;
  gap: 10px;
}

.elifba-example {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(110px, 0.45fr) minmax(0, 1fr);
  padding: 14px;
  text-align: start;
}

.elifba-example .elifba-glyph {
  font-size: 42px;
  text-align: center;
}

.elifba-example strong,
.elifba-example span {
  display: block;
}

.elifba-example span {
  color: var(--muted);
  margin-top: 3px;
}

.elifba-tip {
  background: #eef3ec;
  border-inline-start: 4px solid var(--teal);
  line-height: 1.55;
  margin: 16px 0;
  padding: 12px 14px;
}

.elifba-quiz-prompt {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 12px;
}

.elifba-quiz-glyph {
  color: var(--teal-2);
  direction: rtl;
  font-family: "Noto Naskh Arabic", "Amiri", serif;
  font-size: 76px;
  line-height: 1.3;
  margin: 8px 0 18px;
  text-align: center;
}

.elifba-answers {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.elifba-answer {
  min-height: 52px;
  padding: 10px;
}

.elifba-answer.correct {
  background: #e3f2e5;
  border-color: #4e8b5a;
}

.elifba-answer.incorrect {
  background: #f6e7e7;
  border-color: var(--rose);
}

.elifba-feedback {
  font-weight: 700;
  min-height: 28px;
  padding-top: 10px;
}

.elifba-actions {
  display: grid;
  gap: 10px;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  margin-top: 22px;
}

.elifba-complete-button {
  justify-content: center;
}

@media (max-width: 640px) {
  .learning-entry-group {
    flex-basis: 100%;
    grid-column: 1 / -1;
    min-width: 0;
    order: -1;
    width: 100%;
  }

  .learning-entry-group .icon-button {
    font-size: 14px;
    height: 54px;
    min-width: 0;
    padding-inline: 8px;
  }

  .reader-entry-button {
    height: 54px;
    order: initial;
    width: 100%;
  }

  .reader-header {
    gap: 8px;
    padding: max(9px, env(safe-area-inset-top)) 10px 9px;
  }

  .reader-heading p {
    font-size: 11px;
  }

  .reader-controls {
    display: grid;
    gap: 8px;
    grid-template-areas:
      "modes modes modes modes modes modes"
      "prev select select ayah jump next"
      "font font font translate translate theme"
      "tafsir tafsir tafsir audio audio audio";
    grid-template-columns: repeat(6, minmax(0, 1fr));
    width: 100%;
  }

  .reader-modes {
    grid-area: modes;
  }

  #readerPrevButton {
    grid-area: prev;
  }

  .reader-surah-control,
  .reader-section-control {
    grid-area: select;
  }

  .reader-ayah-control {
    grid-area: ayah;
  }

  #readerJumpButton {
    grid-area: jump;
  }

  #readerNextButton {
    grid-area: next;
  }

  .reader-font-control {
    grid-area: font;
  }

  .reader-translation-toggle {
    grid-area: translate;
    justify-content: center;
    min-width: 0;
    padding-inline: 6px;
  }

  #readerThemeButton {
    grid-area: theme;
  }

  #readerDownloadTafsirButton {
    grid-area: tafsir;
  }

  #readerDownloadAudioButton {
    grid-area: audio;
  }

  .reader-download-button {
    font-size: 13px;
    max-width: none;
    min-width: 0;
    padding-inline: 7px;
    white-space: normal;
    width: 100%;
  }

  .reader-daily-progress {
    font-size: 11px;
  }

  .reader-book {
    min-height: auto;
    padding-top: 16px;
  }

  .elifba-header {
    padding-inline: 12px;
  }

  .elifba-lessons {
    padding-inline: 12px;
  }

  .elifba-content {
    padding: 16px 12px calc(36px + env(safe-area-inset-bottom));
  }

  .elifba-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .elifba-letter {
    min-height: 104px;
    padding-inline: 4px;
  }

  .elifba-glyph {
    font-size: 42px;
  }

  .elifba-example {
    grid-template-columns: 96px minmax(0, 1fr);
  }
}


.data-management-card {
  display: grid;
  gap: 12px;
}

.notification-toggle {
  width: fit-content;
  min-height: 42px;
}

.sync-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  gap: 8px;
  align-items: end;
}

.sync-control label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.sync-control input {
  width: 100%;
  min-width: 0;
}

.reader-download-button {
  min-height: 40px;
  white-space: nowrap;
}

.reader-download-status {
  margin: 7px 0 0;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 700;
}

.reader-download-status:empty {
  display: none;
}

@media (max-width: 720px) {
  .reader-download-button {
    flex: 1 1 calc(50% - 6px);
    justify-content: center;
  }

  .sync-control {
    grid-template-columns: minmax(0, 1fr) 44px;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(251, 250, 244, 0.86), rgba(236, 239, 231, 0.9)),
    url("/assets/geometric-pattern.png") center / cover fixed;
}

button,
textarea,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

html.language-selected .language-onboarding {
  display: none !important;
}

.language-onboarding {
  align-items: center;
  background: rgba(11, 39, 36, 0.82);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 20px;
  position: fixed;
  z-index: 1000;
  backdrop-filter: blur(12px);
}

.language-card {
  background: #fffef8;
  border: 1px solid rgba(185, 137, 61, 0.46);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(6, 28, 26, 0.34);
  max-width: 620px;
  padding: 30px;
  text-align: center;
  width: 100%;
}

.language-mark {
  align-items: center;
  background: var(--teal);
  border-radius: 8px;
  color: #fff9e9;
  display: inline-flex;
  font-family: Georgia, serif;
  font-size: 32px;
  height: 60px;
  justify-content: center;
  margin-bottom: 12px;
  width: 60px;
}

.language-kicker {
  color: var(--gold);
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 5px;
  text-transform: uppercase;
}

.language-card h2 {
  font-size: 25px;
  margin-bottom: 8px;
}

.language-card > p:not(.language-kicker) {
  color: var(--muted);
  line-height: 1.55;
}

.language-options {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 24px 0 16px;
}

.language-options button {
  background: #f5f7f1;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  display: grid;
  gap: 5px;
  min-height: 88px;
  padding: 14px 10px;
}

.language-options button:hover,
.language-options button:focus-visible {
  background: #eaf3ee;
  border-color: var(--teal);
  outline: none;
}

.language-options strong {
  color: var(--teal-2);
  font-size: 18px;
}

.language-options span,
.language-note {
  font-size: 12px;
}

html[dir="rtl"] .language-card,
html[dir="rtl"] .bubble,
html[dir="rtl"] .tab-panel {
  text-align: right;
}

.app-shell {
  min-height: 100vh;
  padding: 18px;
}

.topbar {
  align-items: center;
  background: rgba(255, 255, 250, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: flex;
  gap: 18px;
  justify-content: space-between;
  margin: 0 auto 14px;
  max-width: 1360px;
  padding: 14px 16px;
  backdrop-filter: blur(18px);
}

.brand {
  align-items: center;
  display: flex;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  align-items: center;
  background: var(--teal);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 8px;
  color: #fff9e9;
  display: grid;
  font-family: Georgia, serif;
  font-size: 26px;
  height: 48px;
  justify-items: center;
  width: 48px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  font-weight: 750;
}

.brand p,
.panel-header p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.toolbar {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.toggle,
.select-control {
  align-items: center;
  background: rgba(15, 91, 85, 0.08);
  border: 1px solid rgba(15, 91, 85, 0.18);
  border-radius: 8px;
  color: var(--teal-2);
  display: inline-flex;
  gap: 8px;
  padding: 9px 11px;
  white-space: nowrap;
}

.select-control span {
  color: var(--muted);
  font-size: 12px;
}

.select-control select {
  background: transparent;
  border: 0;
  color: var(--teal-2);
  min-width: 84px;
  outline: none;
}

.toggle input {
  accent-color: var(--teal);
}

.icon-button,
.send-button {
  align-items: center;
  border: 0;
  border-radius: 8px;
  display: inline-grid;
  height: 42px;
  justify-items: center;
  transition:
    transform 160ms ease,
    background 160ms ease,
    color 160ms ease;
  width: 42px;
}

.icon-button {
  background: #edf2ed;
  color: var(--teal-2);
}

.reader-entry-button {
  background: var(--teal);
  box-shadow: 0 8px 20px rgba(15, 91, 85, 0.2);
  color: #fffef8;
  display: inline-flex;
  font-weight: 800;
  gap: 9px;
  height: 50px;
  padding: 0 16px;
  white-space: nowrap;
  width: auto;
}

.reader-entry-button svg {
  height: 22px;
  width: 22px;
}

.reader-entry-button:hover {
  background: var(--teal-2);
}

.icon-button:hover,
.send-button:hover {
  transform: translateY(-1px);
}

.icon-button.copied {
  background: #e8f2cf;
  color: #45610e;
}

.workspace {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 1.3fr) minmax(360px, 0.7fr);
  margin: 0 auto;
  max-width: 1360px;
  min-height: calc(100vh - 110px);
}

.chat-panel,
.evidence-panel {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-height: 0;
  backdrop-filter: blur(18px);
}

.chat-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1 1 auto;
  overflow: auto;
  padding: 18px;
}

.message {
  align-items: flex-start;
  display: flex;
  gap: 10px;
  max-width: 900px;
}

.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.avatar {
  align-items: center;
  background: #ecf2ed;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--teal);
  display: grid;
  flex: 0 0 auto;
  height: 34px;
  justify-items: center;
  width: 34px;
}

.bubble {
  background: #fffdf7;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  line-height: 1.58;
  padding: 12px 13px;
}

.user .bubble {
  background: var(--teal);
  border-color: var(--teal);
  color: white;
}

.loading .bubble {
  background-image: linear-gradient(90deg, #fffdf7, #f4f1e7, #fffdf7);
  background-size: 180% 100%;
  animation: shimmer 1.4s linear infinite;
}

@keyframes shimmer {
  to {
    background-position: -180% 0;
  }
}

.prompt-chip {
  background: #eef3ec;
  border: 1px solid #d9e2d5;
  border-radius: 999px;
  color: var(--teal-2);
  display: inline-flex;
  margin: 8px 6px 0 0;
  padding: 7px 10px;
}

.composer {
  align-items: end;
  background: linear-gradient(180deg, rgba(255, 253, 247, 0.98), rgba(248, 243, 231, 0.96));
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr auto;
  order: -1;
  padding: 16px;
  position: sticky;
  top: 0;
  z-index: 5;
}

textarea {
  background: #fffdf7;
  border: 1px solid #cfd9cf;
  border-radius: 8px;
  color: var(--ink);
  font-size: 17px;
  line-height: 1.45;
  min-height: 92px;
  outline: none;
  padding: 15px;
  resize: vertical;
  width: 100%;
}

textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 91, 85, 0.14);
}

.send-button {
  background: var(--gold);
  color: white;
  height: 62px;
  width: 58px;
}

.evidence-panel {
  display: grid;
  grid-template-rows: auto auto 1fr;
  overflow: hidden;
}

.panel-header {
  align-items: start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 16px 16px 10px;
}

.panel-header h2 {
  font-size: 18px;
  margin-bottom: 4px;
}

.tabs {
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  padding: 0 12px;
}

.tab {
  background: transparent;
  border: 0;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  font-size: 13px;
  padding: 12px 8px 10px;
}

.tab.active {
  border-color: var(--gold);
  color: var(--teal-2);
  font-weight: 700;
}

.tab-panel {
  display: none;
  overflow: auto;
  padding: 14px;
}

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

.verse-card,
.tafsir-card,
.tool-card,
.timeline-card,
.concept-card,
.folder-card,
.note-card {
  background: #fffdf7;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 12px;
  padding: 12px;
}

.highlight-card {
  background: #fffaf0;
  border-color: rgba(185, 137, 61, 0.45);
}

.monetization-card {
  background: #fffaf0;
  border-color: rgba(15, 91, 85, 0.26);
}

.premium-active .monetization-card {
  background: #f1f8ef;
  border-color: rgba(69, 97, 14, 0.35);
}

.premium-active #premiumStatus {
  background: #e8f2cf;
  color: #45610e;
}

.verse-meta {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 12px;
  gap: 8px;
  justify-content: space-between;
  margin-bottom: 10px;
}

code {
  background: #eef2ea;
  border-radius: 6px;
  color: var(--teal-2);
  padding: 3px 7px;
}

.tag-row {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: -2px 0 10px;
}

.mini-tag {
  background: #edf2ed;
  border: 1px solid #d8e1d6;
  border-radius: 999px;
  color: var(--teal-2);
  font-size: 12px;
  padding: 4px 8px;
}

.chip-button,
.text-button,
.link-button,
.mini-icon {
  align-items: center;
  border: 0;
  display: inline-flex;
}

.chip-button {
  background: #f4efe3;
  border: 1px solid #e5dac4;
  border-radius: 999px;
  color: var(--rose);
  gap: 6px;
  padding: 5px 9px;
}

.text-button {
  background: var(--teal);
  border-radius: 8px;
  color: white;
  gap: 8px;
  min-height: 38px;
  padding: 9px 12px;
}

.text-button.subtle {
  background: #edf2ed;
  color: var(--teal-2);
}

.text-button.ghost {
  background: transparent;
  border: 1px solid #d7dfd3;
  color: var(--teal-2);
}

.text-button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.link-button {
  background: transparent;
  color: var(--rose);
  padding: 0;
  text-align: left;
}

.mini-icon {
  background: #edf2ed;
  border-radius: 8px;
  color: var(--muted);
  height: 30px;
  justify-content: center;
  width: 30px;
}

.arabic {
  color: #172422;
  font-family: "Times New Roman", serif;
  font-size: 23px;
  line-height: 1.9;
  margin-bottom: 8px;
  text-align: right;
}

.footnote {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  margin-top: 10px;
  padding-top: 10px;
}

.tafsir-card p,
.verse-card p,
.tool-card p,
.timeline-card p,
.concept-card p,
.note-card p {
  line-height: 1.55;
}

.tafsir-card a,
.source-list a {
  color: var(--rose);
  display: inline-flex;
  font-size: 13px;
  margin-top: 8px;
  text-decoration: none;
}

.tafsir-card a:hover,
.source-list a:hover {
  text-decoration: underline;
}

.muted {
  opacity: 0.68;
}

.empty {
  align-items: center;
  border: 1px dashed #cad4c8;
  border-radius: 8px;
  color: var(--muted);
  display: grid;
  min-height: 140px;
  padding: 18px;
  text-align: center;
}

.small-empty {
  min-height: 74px;
}

.tool-title {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 13px;
  gap: 8px;
  justify-content: space-between;
  margin-bottom: 10px;
}

.tool-title span {
  color: var(--ink);
  font-weight: 700;
}

.control-row {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 10px;
}

input[type="text"] {
  background: #fffdf7;
  border: 1px solid #cfd9cf;
  border-radius: 8px;
  color: var(--ink);
  min-height: 38px;
  min-width: 0;
  outline: none;
  padding: 9px 10px;
}

input[type="text"]:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 91, 85, 0.14);
}

.personal-panel textarea {
  min-height: 110px;
}

.stack-list {
  display: grid;
  gap: 8px;
}

.folder-card,
.note-card {
  background: #fbfaf4;
  margin-bottom: 0;
}

.saved-item {
  align-items: center;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 8px 0 0;
}

.saved-item + .saved-item {
  margin-top: 8px;
}

.timeline {
  display: grid;
  gap: 10px;
  position: relative;
}

.timeline-item {
  border-left: 3px solid rgba(185, 137, 61, 0.5);
  padding-left: 12px;
}

.timeline-item span {
  color: var(--gold);
  display: block;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 3px;
}

.timeline-item strong {
  display: block;
  margin-bottom: 4px;
}

.context-assessment {
  border-left: 4px solid var(--gold);
}

.context-assessment.high {
  border-left-color: #2f7d59;
}

.context-assessment.medium,
.context-assessment.context {
  border-left-color: var(--gold);
}

.context-assessment.limited,
.context-assessment.none {
  border-left-color: var(--rose);
}

.context-assessment h3 {
  font-size: 18px;
  margin: 12px 0 8px;
}

.context-distinction {
  background: #f4f7f1;
  border-left: 3px solid rgba(15, 91, 85, 0.35);
  color: var(--muted);
  padding: 9px 10px;
}

.context-source-list {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
}

.context-source-list a {
  border: 1px solid var(--line);
  color: var(--teal-2);
  display: grid;
  gap: 3px;
  padding: 9px 10px;
  text-decoration: none;
}

.context-source-list a:hover {
  border-color: var(--gold);
}

.context-source-list small,
.context-warning {
  color: var(--muted);
  font-size: 12px;
}

.context-background {
  border-top: 1px solid var(--line);
  margin-top: 12px;
  padding-top: 10px;
}

.context-background p {
  margin: 4px 0 0;
}

.context-background a {
  color: var(--rose);
  font-size: 13px;
  text-decoration: none;
}

.context-warning {
  margin: 8px 0 0;
}

.concept-grid {
  display: grid;
  gap: 10px;
}

.concept-card {
  background: #fbfaf4;
  margin-bottom: 0;
}

.locked-insight-card {
  background: #fff8eb;
  border-color: rgba(185, 137, 61, 0.42);
}

.premium-insight-card {
  background: #f2f8f5;
  border-color: rgba(15, 91, 85, 0.28);
}

.deep-insight-list {
  display: grid;
  gap: 8px;
}

.deep-insight-list p {
  margin: 0;
}

.microcopy {
  color: var(--muted);
  font-size: 12px;
  margin-top: 8px;
}

.source-list {
  display: none;
}

.source-list.active {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.reader-open {
  overflow: hidden;
}

.reader-view {
  background:
    linear-gradient(180deg, rgba(251, 250, 244, 0.98), rgba(239, 242, 233, 0.98)),
    url("/assets/geometric-pattern.png") center / cover fixed;
  inset: 0;
  position: fixed;
  z-index: 900;
}

.reader-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100%;
}

.reader-header {
  background: rgba(255, 255, 250, 0.96);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(16, 31, 29, 0.09);
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(220px, 1fr) auto;
  padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
  position: relative;
  z-index: 2;
}

.reader-heading,
.reader-controls {
  align-items: center;
  display: flex;
  gap: 10px;
}

.reader-heading {
  min-width: 0;
}

.reader-heading h2 {
  font-size: 19px;
}

.reader-heading p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.reader-controls {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.reader-modes {
  background: #edf2ed;
  border: 1px solid #d8e1d6;
  display: inline-grid;
  grid-template-columns: repeat(3, minmax(44px, 1fr));
  min-height: 38px;
}

.reader-mode {
  background: transparent;
  border: 0;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  padding: 0 10px;
}

.reader-mode + .reader-mode {
  border-inline-start: 1px solid #d8e1d6;
}

.reader-mode.active {
  background: var(--teal);
  color: white;
}

.reader-surah-control select {
  max-width: 190px;
  min-width: 140px;
}

.reader-ayah-control input,
.reader-section-control input {
  background: transparent;
  border: 0;
  color: var(--teal-2);
  min-width: 52px;
  outline: none;
  padding: 0;
  width: 64px;
}

.reader-font-control {
  align-items: center;
  color: var(--muted);
  display: inline-flex;
  gap: 6px;
}

.reader-font-control input {
  accent-color: var(--teal);
  width: 96px;
}

.reader-daily-progress {
  color: var(--muted);
  font-size: 12px;
  grid-column: 1 / -1;
  margin: 0;
  text-align: end;
}

.reader-progress {
  background: #e7ece4;
  bottom: 0;
  height: 3px;
  inset-inline: 0;
  overflow: hidden;
  position: absolute;
}

.reader-progress span {
  background: var(--gold);
  display: block;
  height: 100%;
  transform-origin: left center;
  transform: scaleX(0);
  transition: transform 100ms linear;
}

html[dir="rtl"] .reader-progress span {
  transform-origin: right center;
}

.reader-scroll {
  overflow: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}

.reader-book {
  background: rgba(255, 254, 248, 0.96);
  border-left: 1px solid rgba(185, 137, 61, 0.28);
  border-right: 1px solid rgba(185, 137, 61, 0.28);
  margin: 0 auto;
  max-width: 940px;
  min-height: 100%;
  padding: 28px clamp(18px, 5vw, 64px) 70px;
}

.reader-chapter-heading {
  border-bottom: 1px solid var(--line);
  margin-bottom: 2px;
  padding: 6px 0 24px;
  text-align: center;
}

.reader-chapter-heading h3 {
  color: var(--teal-2);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 28px;
  margin: 0 0 8px;
}

.reader-chapter-heading p {
  color: var(--muted);
  font-size: 13px;
}

.reader-verse {
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 14px;
  grid-template-columns: 42px minmax(0, 1fr);
  padding: 24px 0;
  scroll-margin-top: 18px;
}

.reader-verse-tools {
  align-items: center;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.reader-tafsir-button {
  align-items: center;
  align-self: start;
  background: #edf2ed;
  border: 1px solid #d8e1d6;
  border-radius: 8px;
  color: var(--teal-2);
  display: inline-grid;
  height: 40px;
  justify-items: center;
  width: 40px;
}

.reader-tool-button {
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--muted);
  display: inline-grid;
  height: 34px;
  justify-items: center;
  width: 34px;
}

.reader-tool-button:hover,
.reader-tool-button.active {
  background: #edf2ed;
  border-color: #d8e1d6;
  color: var(--teal-2);
}

.reader-verse.playing {
  background: rgba(209, 232, 220, 0.38);
  box-shadow: 0 0 0 12px rgba(209, 232, 220, 0.38);
}

.reader-tafsir-button:hover,
.reader-tafsir-button[aria-expanded="true"] {
  background: var(--teal);
  border-color: var(--teal);
  color: white;
}

.reader-verse-body {
  min-width: 0;
}

.reader-verse-meta {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 12px;
  gap: 8px;
  justify-content: space-between;
  margin-bottom: 8px;
}

.reader-arabic {
  color: #172422;
  font-family: "Times New Roman", "Noto Naskh Arabic", serif;
  font-size: var(--reader-arabic-size, 36px);
  line-height: 2.05;
  margin: 6px 0 12px;
  text-align: right;
}

.reader-translation {
  font-size: 16px;
  line-height: 1.72;
  margin: 0;
}

.reader-tafsir-panel {
  background: #f3f7f2;
  border-inline-start: 3px solid var(--gold);
  grid-column: 2;
  padding: 14px 16px;
}

.reader-tafsir-panel > strong {
  color: var(--teal-2);
  display: block;
  margin-bottom: 8px;
}

.reader-tafsir-source + .reader-tafsir-source {
  border-top: 1px solid var(--line);
  margin-top: 12px;
  padding-top: 12px;
}

.reader-tafsir-source h4 {
  font-size: 14px;
  margin: 0 0 6px;
}

.reader-tafsir-source p {
  line-height: 1.62;
  margin: 0;
}

.reader-tafsir-source a {
  color: var(--rose);
  display: inline-block;
  font-size: 12px;
  margin-top: 7px;
  text-decoration: none;
}

.reader-loading {
  color: var(--muted);
  display: grid;
  min-height: 42vh;
  place-items: center;
  text-align: center;
}

.reader-audio-bar {
  align-items: center;
  background: rgba(255, 255, 250, 0.98);
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 24px rgba(16, 31, 29, 0.09);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 9px max(16px, env(safe-area-inset-right)) max(9px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  z-index: 3;
}

.reader-audio-bar[hidden] {
  display: none;
}

.reader-audio-now,
.reader-audio-controls {
  align-items: center;
  display: flex;
  gap: 9px;
}

.reader-audio-now {
  min-width: 0;
}

.reader-audio-now strong {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reader-audio-controls .audio-primary {
  background: var(--teal);
  color: white;
}

.reader-speed-control {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 11px;
  gap: 6px;
}

.reader-speed-control select {
  background: white;
  border: 1px solid var(--line);
  color: var(--teal-2);
  min-height: 34px;
}

.reader-view.reader-hide-translation .reader-translation,
.reader-view.reader-hide-translation .reader-verse > .reader-verse-body > .footnote {
  display: none;
}

.reader-view.reader-night {
  background: #171b19;
}

.reader-view.reader-night .reader-header,
.reader-view.reader-night .reader-audio-bar,
.reader-view.reader-night .reader-book {
  background: #1f2522;
  border-color: #46504b;
  color: #eef3ef;
}

.reader-view.reader-night .reader-arabic,
.reader-view.reader-night .reader-translation {
  color: #f5f1e6;
}

.reader-view.reader-night .reader-verse,
.reader-view.reader-night .reader-chapter-heading {
  border-color: #46504b;
}

.reader-view.reader-night .reader-tafsir-panel,
.reader-view.reader-night .reader-tool-button:hover,
.reader-view.reader-night .reader-tool-button.active {
  background: #29322e;
  border-color: #52615a;
}

.reader-view.reader-night .select-control,
.reader-view.reader-night .toggle,
.reader-view.reader-night .reader-modes,
.reader-view.reader-night .reader-speed-control select {
  background: #29322e;
  border-color: #52615a;
  color: #eef3ef;
}

.reader-view.reader-night select,
.reader-view.reader-night input {
  color: #eef3ef;
}

svg {
  height: 19px;
  width: 19px;
}

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .evidence-panel {
    min-height: 560px;
  }

  .reader-header {
    grid-template-columns: 1fr;
  }

  .reader-controls {
    justify-content: flex-start;
  }

  .reader-daily-progress {
    text-align: start;
  }
}

@media (max-width: 640px) {
  .language-card {
    padding: 22px 16px;
  }

  .language-options {
    grid-template-columns: 1fr;
  }

  .language-options button {
    min-height: 68px;
  }

  .app-shell {
    padding: 10px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar {
    justify-content: flex-start;
  }

  .reader-entry-button {
    flex: 1 1 100%;
    height: 56px;
    justify-content: center;
    order: -1;
    width: 100%;
  }

  .toggle {
    white-space: normal;
  }

  .tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .tab {
    padding-left: 4px;
    padding-right: 4px;
  }

  .messages {
    padding: 12px;
  }

  .message,
  .message.user {
    align-self: stretch;
    flex-direction: row;
  }

  .bubble {
    width: 100%;
  }

  .composer {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  textarea {
    min-height: 104px;
  }

  .send-button {
    height: 54px;
    width: 100%;
  }

  .reader-header {
    padding: max(10px, env(safe-area-inset-top)) 10px 10px;
  }

  .reader-heading .icon-button {
    flex: 0 0 42px;
  }

  .reader-heading h2 {
    font-size: 17px;
  }

  .reader-controls {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) 84px 42px 42px;
  }

  .reader-modes {
    grid-column: 1 / -1;
    width: 100%;
  }

  #readerTopButton {
    display: none;
  }

  .reader-surah-control {
    min-width: 0;
  }

  .reader-surah-control span {
    display: none;
  }

  .reader-surah-control select {
    max-width: none;
    min-width: 0;
    width: 100%;
  }

  .reader-ayah-control {
    gap: 4px;
    min-width: 0;
    padding-inline: 8px;
  }

  .reader-ayah-control span {
    display: none;
  }

  .reader-ayah-control input {
    text-align: center;
    width: 100%;
  }

  .reader-section-control {
    min-width: 0;
  }

  .reader-section-control span {
    display: none;
  }

  .reader-section-control input {
    text-align: center;
    width: 100%;
  }

  .reader-font-control {
    grid-column: span 2;
    min-height: 42px;
  }

  .reader-font-control input {
    width: 100%;
  }

  .reader-translation-toggle {
    grid-column: span 2;
  }

  .reader-book {
    border: 0;
    padding: 20px 14px 60px;
  }

  .reader-chapter-heading h3 {
    font-size: 24px;
  }

  .reader-verse {
    gap: 10px;
    grid-template-columns: 40px minmax(0, 1fr);
    padding: 20px 0;
  }

  .reader-arabic {
    font-size: var(--reader-arabic-size, 34px);
    line-height: 1.95;
  }

  .reader-tafsir-panel {
    grid-column: 1 / -1;
  }

  .reader-audio-bar {
    align-items: stretch;
    flex-direction: column;
    gap: 6px;
    padding-block: 7px max(7px, env(safe-area-inset-bottom));
  }

  .reader-audio-now {
    justify-content: center;
  }

  .reader-audio-controls {
    justify-content: center;
  }

  .reader-speed-control span {
    display: none;
  }
}
+

/* Final responsive overrides: keep reader controls compact and fully visible. */
.reader-shell {
  grid-template-rows: minmax(0, 1fr) auto;
}

.reader-header {
  box-shadow: none;
  margin: 0 auto;
  max-width: 940px;
  width: 100%;
}

.reader-download-button {
  max-width: 180px;
  min-width: 132px;
  overflow: visible;
}

@media (max-width: 640px) {
  .learning-entry-group {
    flex-basis: 100%;
    min-width: 0;
    order: -1;
    width: 100%;
  }

  .reader-entry-button {
    height: 54px;
    order: initial;
    width: 100%;
  }

  .reader-header {
    gap: 8px;
    padding: max(9px, env(safe-area-inset-top)) 10px 9px;
  }

  .reader-controls {
    display: grid;
    gap: 8px;
    grid-template-areas:
      "modes modes modes modes modes modes"
      "prev select select ayah jump next"
      "font font font translate translate theme"
      "tafsir tafsir tafsir audio audio audio";
    grid-template-columns: repeat(6, minmax(0, 1fr));
    width: 100%;
  }

  .reader-modes { grid-area: modes; }
  #readerPrevButton { grid-area: prev; }
  .reader-surah-control,
  .reader-section-control { grid-area: select; }
  .reader-ayah-control { grid-area: ayah; }
  #readerJumpButton { grid-area: jump; }
  #readerNextButton { grid-area: next; }
  .reader-font-control { grid-area: font; }
  .reader-translation-toggle {
    grid-area: translate;
    justify-content: center;
    min-width: 0;
    padding-inline: 6px;
  }
  #readerThemeButton { grid-area: theme; }
  #readerDownloadTafsirButton { grid-area: tafsir; }
  #readerDownloadAudioButton { grid-area: audio; }

  .reader-download-button {
    font-size: 13px;
    max-width: none;
    min-width: 0;
    padding-inline: 7px;
    white-space: normal;
    width: 100%;
  }

  .reader-book {
    min-height: auto;
    padding-top: 16px;
  }
}
/* Keep only the slim progress indicators visible while lesson content scrolls. */
.elifba-progress,
.reader-progress {
  background: #dfe6dc;
  height: 4px;
  position: sticky;
  top: 0;
  width: 100%;
  z-index: 12;
}

.reader-progress {
  bottom: auto;
  inset-inline: auto;
}

.elifba-progress {
  box-shadow: 0 2px 6px rgba(16, 31, 29, 0.12);
}

.elifba-forms {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.elifba-form-card {
  background: #fffdf7;
  border: 1px solid #d5ddd3;
  border-radius: 6px;
  overflow: hidden;
}

.elifba-form-heading {
  align-items: center;
  background: #eef3ec;
  border-bottom: 1px solid #d5ddd3;
  display: flex;
  gap: 8px;
  justify-content: space-between;
  padding: 9px 11px;
}

.elifba-form-heading strong {
  color: var(--teal-2);
  font-size: 15px;
}

.elifba-form-heading span {
  color: var(--muted);
  font-size: 11px;
  text-align: end;
}

.elifba-form-grid {
  direction: ltr;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.elifba-form-cell {
  align-items: center;
  background: transparent;
  border: 0;
  color: var(--ink);
  display: grid;
  gap: 4px;
  justify-items: center;
  min-width: 0;
  padding: 8px 3px 10px;
}

.elifba-form-cell + .elifba-form-cell {
  border-inline-start: 1px solid #e3e7df;
}

.elifba-form-cell small {
  color: var(--muted);
  font-size: 10px;
  overflow-wrap: anywhere;
}

.elifba-form-cell .elifba-glyph {
  font-size: 38px;
  min-height: 48px;
}

.elifba-form-cell:hover,
.elifba-form-cell:focus-visible {
  background: #f7f0df;
  box-shadow: inset 0 0 0 2px rgba(185, 137, 61, 0.32);
}

@media (max-width: 640px) {
  .elifba-forms {
    grid-template-columns: 1fr;
  }

  .elifba-form-cell .elifba-glyph {
    font-size: 36px;
  }
}
