:root {
  color-scheme: light;
  --paper: #f7f3ea;
  --paper-strong: #fffdf7;
  --paper-soft: #ece4d6;
  --ink: #13211b;
  --muted: #6f766d;
  --line: #ddd0bb;
  --green: #0f6b52;
  --green-deep: #084331;
  --green-soft: #dcece5;
  --gold: #bc8527;
  --rose: #9e455a;
  --blue: #2d697a;
  --shadow: 0 18px 60px rgba(30, 41, 34, 0.12);
  --radius: 8px;
  --arabic-size: 2.1rem;
}

[data-theme="dark"] {
  color-scheme: dark;
  --paper: #101815;
  --paper-strong: #17231e;
  --paper-soft: #23332d;
  --ink: #f4efe4;
  --muted: #abb7ad;
  --line: #34483f;
  --green: #61c6a0;
  --green-deep: #d5f4e4;
  --green-soft: #1d3a31;
  --gold: #e0b86c;
  --rose: #d97990;
  --blue: #86c4d4;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background:
    linear-gradient(135deg, rgba(15, 107, 82, 0.08), transparent 26rem),
    linear-gradient(180deg, var(--paper), var(--paper-soft));
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

.theme-transition,
.theme-transition *,
.theme-transition *::before,
.theme-transition *::after {
  transition:
    background-color 420ms ease,
    background 420ms ease,
    color 420ms ease,
    border-color 420ms ease,
    box-shadow 420ms ease,
    opacity 420ms ease;
}

.theme-transition body {
  animation: theme-crossfade 420ms ease;
}

@keyframes theme-crossfade {
  0% {
    opacity: 0.72;
  }
  100% {
    opacity: 1;
  }
}

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

button {
  cursor: pointer;
}

.noscript {
  max-width: 36rem;
  margin: 4rem auto;
  padding: 2rem;
}

.app-shell {
  display: grid;
  grid-template-columns: 19.5rem minmax(0, 1fr) 22rem;
  min-height: 100vh;
}

.rail,
.insight-panel {
  background: color-mix(in srgb, var(--paper-strong) 84%, transparent);
  backdrop-filter: blur(16px);
}

.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand {
  display: block;
  padding: 0.85rem;
  border-bottom: 1px solid var(--line);
}

.brand-logo {
  display: block;
  width: 100%;
  height: auto;
  max-height: 5.8rem;
  object-fit: contain;
  object-position: left center;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 10px 30px rgba(15, 107, 82, 0.1);
}

.brand-mark {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: var(--radius);
  object-fit: cover;
  box-shadow:
    0 8px 24px rgba(15, 107, 82, 0.18),
    inset 0 0 0 1px rgba(255, 255, 255, 0.16);
}

.brand-title {
  display: block;
  font-weight: 800;
  line-height: 1.1;
}

.brand-subtitle {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 0.15rem;
}

.rail-controls {
  padding: 0.9rem 1rem 0.6rem;
  border-bottom: 1px solid var(--line);
}

.rail-status {
  margin: 0;
  padding: 0.65rem 1rem;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  font-size: 0.82rem;
  line-height: 1.45;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.7rem 0.78rem;
}

.search-box span {
  color: var(--green);
  font-weight: 800;
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
}

.chapter-list {
  overflow: auto;
  padding: 0.8rem;
}

.chapter-row {
  position: relative;
  border-radius: var(--radius);
}

.chapter-row:hover,
.chapter-row.is-active {
  background: var(--green-soft);
}

.chapter-button {
  width: 100%;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  display: grid;
  grid-template-columns: 2.25rem minmax(0, 1fr);
  gap: 0.7rem;
  align-items: start;
  padding: 0.7rem 3.1rem 0.7rem 0.7rem;
  text-align: left;
}

.chapter-index {
  width: 2.25rem;
  height: 2.25rem;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  color: var(--green);
  font-weight: 800;
}

.chapter-name {
  display: block;
  font-weight: 800;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  line-height: 1.2;
}

.chapter-meta {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 0.2rem;
}

.chapter-arabic {
  display: block;
  color: var(--green);
  font-family: "Times New Roman", serif;
  font-size: 1.3rem;
  white-space: normal;
  line-height: 1.45;
  margin-top: 0.25rem;
  direction: rtl;
  text-align: right;
}

.chapter-copy {
  min-width: 0;
}

.chapter-share {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  width: 2.2rem;
  height: 2.2rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--green);
  font-weight: 900;
}

.chapter-share:hover {
  background: var(--green);
  color: #fff;
}

.workspace {
  min-width: 0;
  padding: 1.1rem;
  overflow: auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
}

.view-tabs {
  display: flex;
  align-items: center;
  flex: 1 1 22rem;
  gap: 0.4rem;
  background: var(--paper-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.25rem;
}

.view-tab,
.tool-button,
.icon-button,
.small-button {
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  min-height: 2.4rem;
}

.view-tab {
  padding: 0 0.95rem;
  min-width: 5.2rem;
  font-weight: 800;
}

.view-tab.is-active,
.tool-button.is-active,
.icon-button.is-active,
.small-button.is-active {
  background: var(--green);
  color: #fff;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex: 1 1 18rem;
  flex-wrap: wrap;
  gap: 0.45rem;
  min-width: 0;
}

.icon-button {
  width: 2.55rem;
  height: 2.55rem;
  display: grid;
  place-items: center;
  font-weight: 900;
  background: var(--paper-strong);
  border-color: var(--line);
}

.support-button,
.support-link {
  background: color-mix(in srgb, var(--gold) 18%, var(--paper));
  border-color: color-mix(in srgb, var(--gold) 55%, var(--line));
  color: color-mix(in srgb, var(--gold) 82%, var(--ink));
  white-space: nowrap;
}

.support-button:hover,
.support-link:hover {
  background: var(--gold);
  color: #fff;
}

.hero-panel {
  min-height: 13.5rem;
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, rgba(8, 67, 49, 0.9), rgba(8, 67, 49, 0.55) 52%, rgba(8, 67, 49, 0.08)),
    url("assets/reading-room.png") center / cover;
  color: #fff;
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(13rem, 0.7fr);
  gap: 1rem;
  align-items: end;
  padding: 1.35rem;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.hero-kicker {
  color: #f1d493;
  font-weight: 800;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

.hero-panel h1 {
  margin: 0.4rem 0 0.5rem;
  max-width: 37rem;
  font-size: clamp(2rem, 4vw, 3.8rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.hero-panel p {
  margin: 0;
  max-width: 39rem;
  color: rgba(255, 255, 255, 0.88);
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
}

.stat {
  min-height: 5.1rem;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 0.7rem;
}

.stat strong {
  display: block;
  font-size: 1.35rem;
}

.stat span {
  display: block;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.78rem;
  margin-top: 0.15rem;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
  margin-top: 1rem;
}

.reader-toolbar,
.audio-dock,
.memorization-panel,
.khatm-card,
.search-results,
.journey-panel,
.tafseer-panel {
  background: var(--paper-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 34px rgba(32, 38, 34, 0.06);
}

.memorization-panel {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.4fr);
  gap: 0.8rem;
  align-items: center;
  padding: 0.85rem;
  margin: 0.85rem 0;
}

.memorization-panel h3,
.memorization-panel p,
.khatm-card h4,
.khatm-card p {
  margin: 0;
}

.memorization-panel p,
.khatm-card p {
  color: var(--muted);
}

.memorization-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
}

.memorization-controls input,
.compact-select input {
  width: 5rem;
  min-height: 2.4rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  padding: 0 0.55rem;
}

.tajweed-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 0.85rem;
}

.tajweed-legend span,
.tajweed-ghunnah,
.tajweed-qalqalah,
.tajweed-madd {
  border-radius: 0.35rem;
  padding: 0.04rem 0.18rem;
}

.tajweed-ghunnah {
  background: color-mix(in srgb, var(--rose) 22%, transparent);
  color: color-mix(in srgb, var(--rose) 70%, var(--ink));
}

.tajweed-qalqalah {
  background: color-mix(in srgb, var(--blue) 22%, transparent);
  color: color-mix(in srgb, var(--blue) 78%, var(--ink));
}

.tajweed-madd {
  background: color-mix(in srgb, var(--gold) 25%, transparent);
  color: color-mix(in srgb, var(--gold) 80%, var(--ink));
}

.reader-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.8rem;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.tool-button,
.small-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0 0.8rem;
  background: var(--paper);
  border-color: var(--line);
  font-weight: 800;
}

.small-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.4rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  padding: 0 0.8rem;
  font-weight: 800;
  text-decoration: none;
}

.font-control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  font-weight: 800;
}

.font-control input {
  width: 7.5rem;
  accent-color: var(--green);
}

.select-control {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.4rem;
  color: var(--muted);
  font-weight: 800;
}

.select-control select {
  min-height: 2.4rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  padding: 0 0.65rem;
}

.reciter-control select {
  width: min(18rem, 100%);
}

.toolbar-note {
  margin: 0.55rem 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.45;
}

.surah-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.15rem 0.2rem 0.5rem;
}

.surah-header h2 {
  margin: 0;
  font-size: 2rem;
  letter-spacing: 0;
}

.surah-header p {
  margin: 0.35rem 0 0;
  color: var(--muted);
}

.surah-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--green);
  font-weight: 900;
}

.ayah-list {
  display: grid;
  gap: 0.85rem;
}

.ayah-card {
  position: relative;
  display: grid;
  grid-template-columns: 3.2rem minmax(0, 1fr);
  gap: 0.9rem;
  background: var(--paper-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: 0 10px 34px rgba(32, 38, 34, 0.06);
}

.ayah-card.is-selected {
  border-color: color-mix(in srgb, var(--green) 70%, var(--line));
  box-shadow: 0 14px 40px rgba(15, 107, 82, 0.13);
}

.ayah-card.is-playing {
  border-color: var(--gold);
  box-shadow: 0 18px 44px rgba(188, 133, 39, 0.18);
}

.ayah-card.is-playing::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 0.28rem;
  background: var(--gold);
  border-radius: var(--radius) 0 0 var(--radius);
}

.ayah-card.is-playing .ayah-number {
  background: var(--green);
  color: #fff;
}

.ayah-number {
  width: 3.2rem;
  height: 3.2rem;
  border-radius: var(--radius);
  background: var(--green-soft);
  color: var(--green);
  display: grid;
  place-items: center;
  font-weight: 900;
}

.ayah-main {
  min-width: 0;
}

.ayah-arabic {
  color: var(--ink);
  direction: rtl;
  text-align: right;
  font-family: "Traditional Arabic", "Scheherazade New", "Times New Roman", serif;
  font-size: var(--arabic-size);
  line-height: 2.05;
  margin: 0 0 0.8rem;
}

.transliteration {
  margin: 0 0 0.75rem;
  color: var(--blue);
  font-style: italic;
}

.meaning {
  margin: 0;
  color: color-mix(in srgb, var(--ink) 84%, var(--muted));
  line-height: 1.72;
}

.ayah-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.95rem;
}

.audio-dock {
  position: sticky;
  bottom: 1rem;
  z-index: 5;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.8rem;
  align-items: center;
  padding: 0.75rem;
  margin-top: 1rem;
}

.play-button {
  width: 3rem;
  height: 3rem;
  border-radius: var(--radius);
  border: 0;
  background: var(--green);
  color: #fff;
  font-weight: 900;
}

.audio-title {
  display: block;
  font-weight: 900;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.audio-subtitle {
  color: var(--muted);
  font-size: 0.82rem;
}

.audio-summary {
  min-width: 0;
}

.audio-notice,
.audio-resume {
  display: block;
  margin-top: 0.18rem;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.35;
}

.audio-notice {
  color: var(--blue);
  font-weight: 800;
}

.audio-dock select,
.insight-block select {
  min-height: 2.4rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  padding: 0 0.6rem;
}

.audio-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  min-width: 0;
}

.compact-select {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.compact-select select {
  width: auto;
  min-width: 4.8rem;
}

.search-results,
.journey-panel,
.tafseer-panel {
  padding: 1rem;
}

.search-results h3,
.journey-panel h3,
.tafseer-panel h3 {
  margin: 0 0 0.8rem;
}

.study-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.study-header h3 {
  margin: 0;
}

.study-header p {
  margin: 0.25rem 0 0;
  color: var(--muted);
}

.study-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}

.study-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  padding: 0.95rem;
  min-width: 0;
}

.study-card-wide {
  grid-column: 1 / -1;
}

.study-card h4 {
  margin: 0 0 0.7rem;
  font-size: 0.95rem;
}

.tafsir-text {
  margin: 0.75rem 0 0;
  color: color-mix(in srgb, var(--ink) 86%, var(--muted));
  line-height: 1.7;
}

.compact-note {
  min-height: 7rem;
}

.tafsir-control select {
  width: min(20rem, 100%);
}

.result-list,
.bookmark-list {
  display: grid;
  gap: 0.5rem;
}

.result-button,
.bookmark-button {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  padding: 0.7rem;
  text-align: left;
}

.result-button strong,
.bookmark-button strong {
  display: block;
}

.result-button span,
.bookmark-button span {
  display: block;
  color: var(--muted);
  font-size: 0.84rem;
  margin-top: 0.25rem;
}

.journey-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.journey-item {
  min-height: 7.2rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--paper);
  padding: 0.9rem;
}

.journey-item strong {
  display: block;
  font-size: 1.5rem;
}

.journey-item span {
  display: block;
  color: var(--muted);
  margin-top: 0.25rem;
}

.khatm-card {
  display: grid;
  gap: 0.75rem;
  margin-top: 0.85rem;
  padding: 0.9rem;
}

.khatm-progress {
  height: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  background: var(--paper);
}

.khatm-progress span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--gold));
}

.settings-panel {
  background: var(--paper-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: 0 10px 34px rgba(32, 38, 34, 0.06);
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.settings-header h3 {
  margin: 0;
}

.settings-header p,
.settings-card p,
.settings-muted {
  color: var(--muted);
  line-height: 1.55;
}

.settings-header p {
  margin: 0.25rem 0 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 0 0.75rem;
  font-weight: 900;
}

.status-pill.is-online {
  color: var(--green);
  background: var(--green-soft);
}

.status-pill.is-offline {
  color: var(--rose);
  background: color-mix(in srgb, var(--rose) 12%, var(--paper));
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}

.settings-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  padding: 0.95rem;
}

.support-card {
  border-color: color-mix(in srgb, var(--gold) 45%, var(--line));
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--gold) 10%, transparent), transparent 52%),
    var(--paper);
}

.settings-card-wide {
  grid-column: 1 / -1;
}

.settings-card h4 {
  margin: 0 0 0.75rem;
}

.sync-form {
  display: grid;
  gap: 0.75rem;
  margin-top: 0.85rem;
}

.activation-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
  margin-top: 0.85rem;
}

.activation-list span {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-strong);
  color: var(--muted);
  padding: 0.6rem;
  font-size: 0.86rem;
  font-weight: 800;
}

.activation-list .is-done {
  background: var(--green-soft);
  color: var(--green-deep);
}

.settings-card code {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper-soft);
  padding: 0.1rem 0.28rem;
  color: var(--green-deep);
  font-size: 0.86em;
}

.settings-field {
  display: grid;
  gap: 0.35rem;
  margin-top: 0.75rem;
  color: var(--muted);
  font-weight: 800;
}

.settings-field select,
.settings-card .tafsir-control select {
  width: 100%;
  min-height: 2.4rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-strong);
  color: var(--ink);
  padding: 0 0.65rem;
}

.settings-card .tafsir-control {
  display: grid;
  align-items: stretch;
  margin-top: 0.75rem;
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.85rem;
}

.storage-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.storage-grid span {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-strong);
  padding: 0.7rem;
  color: var(--muted);
}

.storage-grid strong {
  color: var(--ink);
}

.portal-vault-grid {
  display: grid;
  grid-template-columns: minmax(14rem, 0.8fr) minmax(0, 1.2fr);
  gap: 0.85rem;
  align-items: stretch;
}

.scanner-frame {
  position: relative;
  min-height: 13rem;
  overflow: hidden;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(15, 107, 82, 0.16), transparent),
    var(--paper-strong);
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 900;
}

.scanner-frame video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
}

.scanner-frame.is-active video {
  opacity: 1;
}

.scanner-frame.is-active span {
  position: absolute;
  inset: auto 0 0 0;
  background: rgba(8, 67, 49, 0.82);
  color: #fff;
  padding: 0.45rem 0.7rem;
  text-align: center;
}

.portal-vault-controls {
  min-width: 0;
}

.settings-field input {
  width: 100%;
  min-height: 2.4rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-strong);
  color: var(--ink);
  padding: 0 0.75rem;
}

.paired-list {
  display: grid;
  gap: 0.45rem;
  margin-top: 0.85rem;
}

.paired-item {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-strong);
  padding: 0.65rem 0.75rem;
}

.paired-item span {
  color: var(--muted);
  font-size: 0.85rem;
}

.danger-card {
  border-color: color-mix(in srgb, var(--rose) 40%, var(--line));
}

.settings-notice {
  margin: 0.9rem 0 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--green-soft);
  color: var(--green-deep);
  padding: 0.75rem;
  font-weight: 800;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.54;
}

.insight-panel {
  position: sticky;
  top: 0;
  height: 100vh;
  border-left: 1px solid var(--line);
  padding: 1rem;
  overflow: auto;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.9rem;
}

.panel-title h2 {
  margin: 0;
  font-size: 1.2rem;
}

.insight-block {
  background: var(--paper-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem;
  margin-bottom: 0.85rem;
}

.insight-block h3 {
  margin: 0 0 0.7rem;
  font-size: 0.96rem;
}

.selected-ayah {
  color: var(--muted);
  margin: 0 0 0.6rem;
}

.selected-arabic {
  direction: rtl;
  text-align: right;
  font-family: "Traditional Arabic", "Times New Roman", serif;
  font-size: 1.55rem;
  line-height: 1.8;
  margin: 0;
}

.note-area {
  width: 100%;
  min-height: 8.4rem;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  padding: 0.8rem;
  line-height: 1.55;
}

.lens-form {
  display: grid;
  gap: 0.55rem;
}

.lens-form input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  padding: 0.75rem;
}

.lens-answer {
  border-left: 3px solid var(--gold);
  padding-left: 0.8rem;
  color: color-mix(in srgb, var(--ink) 86%, var(--muted));
  line-height: 1.65;
}

.empty-state {
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 0.8rem;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--paper);
  padding: 0 0.7rem;
  font-size: 0.82rem;
  font-weight: 800;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 18.5rem minmax(0, 1fr);
  }

  .insight-panel {
    position: static;
    height: auto;
    grid-column: 2;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 820px) {
  .app-shell {
    display: block;
  }

  .rail,
  .insight-panel {
    position: static;
    height: auto;
  }

  .rail {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .chapter-list {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(17rem, 1fr);
    overflow-x: auto;
    overflow-y: hidden;
  }

  .chapter-row {
    min-width: 17rem;
  }

  .workspace {
    padding: 0.85rem;
  }

  .topbar,
  .reader-toolbar,
  .surah-header,
  .memorization-panel,
  .audio-dock {
    align-items: stretch;
    flex-direction: column;
  }

  .memorization-panel {
    grid-template-columns: 1fr;
  }

  .view-tabs,
  .top-actions,
  .toolbar-group {
    width: 100%;
  }

  .view-tab,
  .tool-button,
  .small-button {
    flex: 1 1 auto;
  }

  .select-control,
  .select-control select,
  .audio-controls,
  .audio-controls select {
    width: 100%;
  }

  .select-control,
  .audio-controls {
    align-items: stretch;
  }

  .compact-select {
    width: 100%;
    justify-content: space-between;
  }

  .compact-select select,
  .compact-select input {
    width: min(12rem, 65%);
  }

  .memorization-controls {
    justify-content: stretch;
  }

  .memorization-controls .small-button {
    width: 100%;
  }

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

  .study-grid {
    grid-template-columns: 1fr;
  }

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

  .settings-grid,
  .storage-grid,
  .portal-vault-grid,
  .activation-list {
    grid-template-columns: 1fr;
  }

  .settings-actions .tool-button,
  .settings-actions .small-button,
  .settings-actions .small-link {
    width: 100%;
  }

  .hero-panel {
    grid-template-columns: 1fr;
    min-height: 18rem;
  }

  .hero-stats,
  .journey-grid {
    grid-template-columns: 1fr;
  }

  .ayah-card {
    grid-template-columns: 1fr;
  }

  .ayah-number {
    width: 2.6rem;
    height: 2.6rem;
  }

  .audio-dock {
    display: flex;
    position: static;
  }

  .audio-controls {
    flex-direction: column;
  }
}

@media (max-width: 520px) {
  .hero-panel h1 {
    font-size: 2.35rem;
  }

  .hero-stats {
    gap: 0.45rem;
  }

  .stat {
    min-height: auto;
  }

  .top-actions {
    flex-wrap: wrap;
  }
}
