:root {
  --bg: #f5f7f5;
  --bg-accent: #edf2ed;
  --surface: #ffffff;
  --surface-soft: #f8faf8;
  --line: #d6dfd5;
  --ink: #1f2933;
  --ink-soft: #52606d;
  --ink-muted: #7b8794;
  --primary: #3d7a5f;
  --primary-strong: #2f634d;
  --danger-soft: #fff3ef;
  --danger-text: #8a3a2a;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  --shadow-xs: 0 1px 2px rgba(22, 34, 25, 0.06);
  --shadow-sm: 0 6px 18px rgba(22, 34, 25, 0.08);

  --font-sans: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-serif: "Source Serif 4", "Palatino Linotype", "Book Antiqua", serif;
}

@font-face {
  font-family: "KFGQPC Arabic Symbols 01";
  src: url("fonts/KFGQPC Arabic Symbols 01.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Adwaa Elsalaf";
  src: url("fonts/adwa-assalaf.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Adwaa Elsalaf";
  src: url("fonts/adwa-assalaf B.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Majalla";
  src: url("fonts/majalla.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Majalla";
  src: url("fonts/majallab.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  background:
    radial-gradient(1200px 500px at 10% -20%, #fdf5e5 0, transparent 68%),
    linear-gradient(180deg, var(--bg-accent) 0%, var(--bg) 35%, #fbfcfb 100%);
}

a {
  color: var(--primary-strong);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  color: var(--ink);
  line-height: 1.2;
  margin-top: 0;
}

h1 {
  font-size: clamp(1.45rem, 1.2rem + 1.1vw, 1.95rem);
  margin-bottom: 0.45rem;
}

h2 {
  font-size: clamp(1.05rem, 0.95rem + 0.45vw, 1.22rem);
  margin-bottom: 0.3rem;
}

p {
  margin-top: 0;
  margin-bottom: 0.6rem;
}

.text-secondary {
  color: var(--ink-soft);
}

.text-muted {
  color: var(--ink-muted);
}

.text-sm {
  font-size: 0.9rem;
}

.font-medium {
  font-weight: 600;
}

.container {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 1rem;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(6px);
  max-height: 84px;
  overflow: hidden;
  transition:
    transform 0.24s ease,
    max-height 0.24s ease,
    border-color 0.2s ease;
}

.init-topbar-collapsed .topbar[data-topbar] {
  transform: translateY(calc(-100% - 2px));
  max-height: 0;
  border-bottom-color: transparent;
}

.topbar.is-collapsed {
  transform: translateY(calc(-100% - 2px));
  max-height: 0;
  border-bottom-color: transparent;
}

.topbar .container {
  width: 100%;
  max-width: none;
  padding-left: 0;
  padding-right: 0.5rem;
}

.topbar-content {
  min-height: 46px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.45rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--primary-strong);
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.brand-logo {
  display: block;
  height: 28px;
  width: auto;
}

.brand:hover {
  text-decoration: none;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

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

.topbar-icon-btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbf8;
  color: var(--ink-soft);
  width: 30px;
  height: 28px;
  padding: 0;
  cursor: pointer;
}

.topbar-icon-btn:hover {
  color: var(--ink);
  border-color: #b9c6ba;
  text-decoration: none;
}

.topbar-icon-btn svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.page-shell {
  width: 80%;
  max-width: 960px;
  margin: 0 auto;
  padding-top: 0.45rem;
  padding-bottom: 2.4rem;
}

.page-ayah .page-shell {
  padding-bottom: 6.8rem;
}

.hero {
  margin-bottom: 0.9rem;
}

.hero--center {
  text-align: center;
}

.hero-logo {
  display: block;
  height: 84px;
  width: auto;
  margin: 0 auto 0.55rem;
}

.hero-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.55rem;
}

.hero--center .hero-metrics {
  justify-content: center;
}

.hero-counters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.8rem;
  margin-top: 0.9rem;
  width: min(860px, 100%);
}

.hero--center .hero-counters {
  margin-left: auto;
  margin-right: auto;
}

.hero-counter {
  background: #f5faf6;
  border: 1px solid #cfe0d3;
  border-radius: 16px;
  padding: 0.85rem 0.95rem;
  text-align: center;
  box-shadow: 0 12px 28px rgba(61, 122, 95, 0.08);
}

.hero-counter-value {
  display: block;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--primary-strong);
  letter-spacing: 0.01em;
}

.hero-counter-label {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.85rem;
  color: #4a625b;
}

.hero-metric {
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: #eef4ef;
  border: 1px solid #d7e1d7;
  color: #37524a;
  font-size: 0.78rem;
  font-weight: 600;
}

.feature-list {
  margin: 0.6rem 0 0;
  padding-left: 1.1rem;
  color: #3f5558;
  font-size: 0.9rem;
}

.hero--center .feature-list {
  max-width: 640px;
  margin: 0.75rem auto 0;
  text-align: left;
}

.feature-list li {
  margin: 0.18rem 0;
}

.section-title {
  margin: 0.8rem 0 0.6rem;
  font-size: 1.1rem;
  color: var(--ink);
}

.cta-row {
  margin-top: 1.1rem;
  display: flex;
  justify-content: center;
}

.btn-cta {
  font-size: 1rem;
  padding: 0.65rem 1.4rem;
  box-shadow: 0 10px 24px rgba(61, 122, 95, 0.18);
}

.ayah-toolbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.3rem;
}

.ayah-line-text {
  min-width: 0;
  margin: 0;
  font-size: 0.83rem;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  gap: 0.32rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ayah-line-text a {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ayah-line-text strong {
  color: var(--ink);
  font-size: 0.88rem;
}

.icon-btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fbf8;
  color: #4e6661;
  text-decoration: none;
}

.icon-btn:hover {
  border-color: #b9c6ba;
  color: #2f4e48;
  text-decoration: none;
}

.icon-btn svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ayah-toolbar-right {
  display: flex;
  justify-content: flex-end;
}

.nav-compact-link {
  color: #4b6264;
  border: 1px solid #d6dfd5;
  background: #fbfdfb;
  border-radius: 7px;
  padding: 0.2rem 0.46rem;
  font-size: 0.77rem;
  line-height: 1.2;
  text-decoration: none;
}

.nav-compact-link:hover {
  border-color: #b9c6ba;
  color: #2f4548;
  text-decoration: none;
}

.nav-compact-link.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.nav-compact-mid {
  background: #f3f7f3;
}

.edge-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  z-index: 20;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #ced9cf;
  color: #3e5550;
  border-radius: 999px;
  padding: 0.36rem 0.48rem;
  font-size: 0.75rem;
  line-height: 1.2;
  box-shadow: var(--shadow-sm);
}

.edge-nav:hover {
  text-decoration: none;
  color: #2d4640;
  border-color: #b7c8b8;
}

.edge-nav svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.edge-nav-prev {
  left: 10px;
}

.edge-nav-next {
  right: 10px;
}

.mobile-nav-inline {
  display: none;
  margin-bottom: 0.7rem;
}

.ayah-stage {
  margin-bottom: 0.72rem;
  padding: 0.72rem 0.8rem;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 12px;
  text-align: center;
}

.ayah-nash {
  font-family: "Amiri", "Noto Naskh Arabic", "Scheherazade New", "Traditional Arabic", serif;
  font-size: clamp(1.45rem, 1.2rem + 0.9vw, 1.9rem);
  line-height: 2.05;
  text-align: center;
  color: #2b3537;
}

.ayah-translation {
  margin-top: 0.55rem;
  margin-bottom: 0;
  color: #4e6163;
  font-size: 0.92rem;
  line-height: 1.65;
  text-align: center;
}

.ayah-latin {
  margin-top: 0.42rem;
  margin-bottom: 0;
  color: #617377;
  font-size: 0.9rem;
  line-height: 1.58;
  text-align: center;
  display: none;
}

.grid {
  display: grid;
  gap: 0.85rem;
}

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

@media (min-width: 700px) {
  .sm\:grid-cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .lg\:grid-cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.card,
.list-item,
.tafsir-card,
.settings-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
}

.card {
  display: block;
  padding: 0.9rem 1rem;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
}

.no-underline-on-hover:hover {
  text-decoration: none;
}

.list-group {
  display: grid;
  gap: 0.7rem;
}

.list-item {
  padding: 0.9rem 1rem;
}

.list-item-ayah {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.7rem;
}

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

@media (min-width: 760px) {
  .surah-grid,
  .ayah-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1120px) {
  .surah-grid,
  .ayah-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.compact-card {
  position: relative;
  padding: 0.55rem 0.62rem;
  min-height: 84px;
}

.compact-title {
  margin: 0 0 0.18rem;
  font-size: 0.86rem;
  line-height: 1.24;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.compact-meta {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.25;
  color: var(--ink-soft);
}

.compact-meta + .compact-meta {
  margin-top: 0.1rem;
}

.list-item-ayah-compact {
  display: block;
  padding-right: 1.9rem;
}

.source-card-link {
  position: absolute;
  top: 0.42rem;
  right: 0.42rem;
  width: 18px;
  height: 18px;
  border: 1px solid #c9d6cb;
  border-radius: 5px;
  background: #f6faf6;
  color: #476458;
  font-size: 0.64rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.source-card-link:hover {
  text-decoration: none;
  border-color: #aac0ae;
  color: #2f4f40;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  padding: 0.45rem 0.85rem;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.15s ease;
}

.btn:hover {
  text-decoration: none;
}

.btn-sm {
  padding: 0.36rem 0.72rem;
  font-size: 0.84rem;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-strong);
  border-color: var(--primary-strong);
  color: #fff;
}

.btn-outline {
  background: var(--surface-soft);
  border-color: var(--line);
  color: var(--ink-soft);
}

.btn-outline:hover {
  color: var(--ink);
  border-color: #b9c6ba;
}

.btn-ghost {
  color: var(--ink-soft);
  border-color: transparent;
  background: transparent;
}

.btn-ghost:hover {
  color: var(--ink);
  background: #edf2ee;
}

.btn.is-disabled {
  cursor: not-allowed;
  opacity: 0.45;
  pointer-events: none;
}

.reading-focus {
  max-width: 860px;
  margin: 0.9rem auto 0;
}

.tafsir-switcher {
  margin-top: 0.8rem;
}

.tafsir-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.22rem;
  margin-bottom: 0.3rem;
  width: 100%;
}

.tafsir-tabs-bottom {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 25;
  width: 100vw;
  margin: 0;
  padding: 0.32rem 0.36rem;
  border-top: 1px solid #86b59a;
  border-left: 0;
  border-right: 0;
  border-bottom: 0;
  border-radius: 0;
  background: linear-gradient(180deg, rgba(188, 226, 202, 0.98) 0%, rgba(164, 214, 185, 0.98) 100%);
  backdrop-filter: blur(6px);
  box-shadow: 0 -10px 24px rgba(40, 82, 58, 0.22);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.28rem;
  align-items: center;
  max-height: 76px;
  overflow: hidden;
  transition: transform 0.24s ease;
}

.init-tafsir-bottom-collapsed .tafsir-tabs-bottom[data-tafsir-bottom] {
  transform: translateY(calc(100% + 2px));
}

.tafsir-tabs-bottom.is-collapsed {
  transform: translateY(calc(100% + 2px));
}

.ui-preload .topbar,
.ui-preload .tafsir-tabs-bottom,
.ui-preload .panel-toggle {
  transition: none !important;
}

.panel-toggle {
  position: fixed;
  z-index: 35;
  border: 1px solid rgba(123, 154, 133, 0.5);
  border-radius: 8px;
  min-width: 30px;
  height: 30px;
  padding: 0 0.45rem;
  background: rgba(244, 250, 244, 0.72);
  color: rgba(57, 88, 72, 0.86);
  font-size: 0.9rem;
  line-height: 1;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-xs);
  backdrop-filter: blur(4px);
}

.panel-toggle:hover {
  background: rgba(232, 242, 232, 0.92);
  color: #2f4e3f;
}

.panel-toggle-top {
  top: 0.4rem;
  right: 0.5rem;
}

.panel-toggle-bottom {
  bottom: 0.34rem;
  right: 0.5rem;
  z-index: 27;
}

body.has-topbar:not(.topbar-collapsed) .panel-toggle-top {
  top: 3rem;
}

body.has-tafsir-bottom:not(.tafsir-bottom-collapsed) .panel-toggle-bottom {
  bottom: 4.5rem;
}

.tafsir-tabs-bottom-list {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  gap: 0.22rem;
  width: 100%;
  overflow: hidden;
}

.tafsir-tabs-bottom-list .tafsir-tab {
  white-space: nowrap;
  width: fit-content;
  max-width: none;
  overflow: visible;
  text-overflow: clip;
}

.tafsir-tabs-bottom-list .tafsir-tab.is-tab-page-hidden {
  display: none !important;
}

.tafsir-tabs-nav {
  border: 1px solid #b4c9b9;
  border-radius: 8px;
  min-width: 30px;
  height: 30px;
  padding: 0;
  background: #f4faf4;
  color: #3f5f4e;
  font-size: 0.92rem;
  line-height: 1;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tafsir-tabs-nav:hover:not(:disabled) {
  background: #e8f2e8;
}

.tafsir-tabs-nav:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.tafsir-tab {
  border: 1px solid #d1ddd2;
  border-radius: 6px;
  padding: 0.16rem 0.42rem;
  background: #f6faf6;
  color: #436052;
  cursor: pointer;
  font-size: 0.72rem;
  line-height: 1.15;
  font-weight: 600;
  transition: all 0.16s ease;
}

.tafsir-tab:hover {
  background: #eaf2ea;
}

.tafsir-tab.is-active {
  color: #fff;
  background: #3a6e57;
  border-color: #3a6e57;
}

.tafsir-panels {
  display: grid;
  gap: 0.7rem;
}

.tafsir-card {
  padding: 0.9rem;
}

.tafsir-headline {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.38rem;
  margin-bottom: 0.3rem;
  line-height: 1.3;
}

.tafsir-source-name {
  font-size: 0.96rem;
  font-weight: 700;
  color: #273538;
}

.tafsir-source-meta {
  font-size: 0.8rem;
  color: #5d6f72;
}

.tafsir-source-detail {
  font-size: 0.72rem;
  color: #4c6457;
  border: 1px solid #d6e3d6;
  border-radius: 999px;
  background: #f6fbf6;
  padding: 0.1rem 0.42rem;
}

.tafsir-text {
  margin-top: 0.45rem;
  white-space: normal;
  font-family: "IBM Plex Sans", "Noto Sans", "DejaVu Sans", "Adwaa Elsalaf",
    "KFGQPC Arabic Symbols 01", var(--font-sans);
  font-size: 1rem;
  line-height: 1.7;
  color: #2a3138;
  background: #f8fbf8;
  border: 1px solid #d8e3d8;
  border-radius: 10px;
  padding: 0.82rem;
}

.tafsir-text > :first-child {
  margin-top: 0;
}

.tafsir-text > :last-child {
  margin-bottom: 0;
}

.tafsir-text p {
  margin: 0 0 0.72rem;
}

.tafsir-text h2,
.tafsir-text h3,
.tafsir-text h4 {
  margin: 0.92rem 0 0.5rem;
  line-height: 1.35;
  color: #243536;
}

.tafsir-text h2 {
  font-size: 1rem;
}

.tafsir-text h3 {
  font-size: 0.94rem;
}

.tafsir-text h4 {
  font-size: 0.9rem;
}

.tafsir-text ul,
.tafsir-text ol {
  margin: 0 0 0.72rem;
  padding-left: 1.25rem;
}

.tafsir-text li {
  margin: 0.16rem 0;
}

.tafsir-text blockquote {
  margin: 0 0 0.72rem;
  padding: 0.5rem 0.7rem;
  border-left: 3px solid #b7ceb9;
  background: #f1f7f1;
  color: #34504d;
}

.tafsir-text code {
  font-family: "IBM Plex Mono", "Consolas", "Menlo", monospace;
  font-size: 0.9em;
  background: #edf3ed;
  border: 1px solid #d8e4d8;
  border-radius: 5px;
  padding: 0.08rem 0.3rem;
}

.tafsir-text pre {
  margin: 0 0 0.72rem;
  white-space: pre-wrap;
  word-break: break-word;
  background: #eef4ef;
  border: 1px solid #d6e1d6;
  border-radius: 8px;
  padding: 0.62rem;
}

.tafsir-text pre code {
  background: transparent;
  border: 0;
  padding: 0;
}

.tafsir-text-switch {
  margin-top: 0.45rem;
}

.tafsir-text-tabs-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.12rem;
  border: 1px solid #d6e0d6;
  border-radius: 8px;
  background: #f1f6f1;
  padding: 0.16rem;
}

.tafsir-lang-tab {
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #4e6763;
  font-size: 0.73rem;
  line-height: 1.2;
  font-weight: 700;
  min-width: 38px;
  padding: 0.18rem 0.42rem;
  cursor: pointer;
}

.tafsir-lang-tab:hover {
  background: #e8f1e8;
}

.tafsir-lang-tab.is-active {
  background: #3a6e57;
  color: #fff;
  border-color: #3a6e57;
}

.tafsir-text-switch .tafsir-text {
  margin-top: 0.34rem;
}

html.js .tafsir-text-switch {
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease;
}

html.js .tafsir-text-switch.is-ready {
  opacity: 1;
  pointer-events: auto;
}

.tafsir-text-arabic {
  margin-top: 0.46rem;
  white-space: pre-line;
  direction: rtl;
  text-align: right;
  font-family: "Adwaa Elsalaf", "Majalla", "KFGQPC Arabic Symbols 01",
    var(--font-qcf-stack), "Amiri", "Noto Naskh Arabic", "Scheherazade New",
    "Traditional Arabic", serif;
  font-size: 1.08rem;
  line-height: 2;
  color: #1f2d34;
  background: #eef4ef;
  border: 1px solid #cfdbcf;
  border-radius: 10px;
  padding: 0.84rem;
}

.tafsir-text-arabic--nafahat {
  font-family: "Adwaa Elsalaf", "Majalla", "KFGQPC Arabic Symbols 01",
    var(--font-qcf-stack), "Amiri", "Noto Naskh Arabic", "Scheherazade New",
    "Traditional Arabic", serif;
  line-height: 1.9;
}

.tafsir-text-arabic--nafahat p,
.tafsir-text-arabic--nafahat div {
  margin: 0 0 0.5rem;
}

.tafsir-arabic-note {
  margin-top: 0.34rem;
  margin-bottom: 0;
  font-size: 0.85rem;
  color: #4f676a;
  background: #f2f7f2;
  border: 1px solid #d8e3d8;
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
}

.tafsir-ar-word-notes {
  margin-top: 0.45rem;
  border: 1px solid #d2dfd2;
  border-radius: 9px;
  background: #f5faf5;
  padding: 0.52rem;
  display: grid;
  gap: 0.5rem;
}

.tafsir-ar-note-section {
  border: 1px solid #d7e4d7;
  border-radius: 8px;
  background: #f8fcf8;
  padding: 0.45rem;
}

.tafsir-ar-note-title {
  margin: 0 0 0.34rem;
  font-size: 0.79rem;
  font-weight: 700;
  color: #334f43;
}

.tafsir-ar-note-form {
  display: grid;
  grid-template-columns: 1fr 2fr auto;
  gap: 0.34rem;
  align-items: center;
}

.tafsir-ar-note-form input[type="text"] {
  width: 100%;
  min-width: 0;
  border: 1px solid #c7d7c7;
  border-radius: 7px;
  padding: 0.34rem 0.48rem;
  font-size: 0.82rem;
  font-family: "IBM Plex Sans", "Noto Sans", "DejaVu Sans", var(--font-sans);
}

.tafsir-ar-par-note-form {
  display: grid;
  gap: 0.34rem;
}

.tafsir-ar-par-key-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.34rem;
  align-items: center;
}

.tafsir-ar-par-note-form input[type="text"],
.tafsir-ar-par-note-form textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid #c7d7c7;
  border-radius: 7px;
  padding: 0.34rem 0.48rem;
  font-size: 0.82rem;
  font-family: "IBM Plex Sans", "Noto Sans", "DejaVu Sans", var(--font-sans);
  background: #ffffff;
  color: #2d3c3f;
}

.tafsir-ar-par-note-form input[type="text"][readonly] {
  background: #eef4ef;
  color: #476057;
}

.tafsir-ar-par-note-form textarea {
  resize: vertical;
  line-height: 1.35;
}

.tafsir-ar-note-help {
  margin: 0.45rem 0 0.2rem;
  font-size: 0.78rem;
  color: #4f676a;
}

.tafsir-ar-note-single {
  margin: 0.22rem 0 0;
  border: 1px solid #d4e2d4;
  border-radius: 7px;
  background: #ffffff;
  padding: 0.34rem 0.46rem;
  font-size: 0.81rem;
  line-height: 1.4;
  color: #2d3c3f;
}

.tafsir-ar-note-list {
  margin: 0.3rem 0 0;
  padding-left: 1rem;
}

.tafsir-ar-note-list li {
  margin: 0.2rem 0;
  font-size: 0.82rem;
  line-height: 1.45;
  color: #2d3c3f;
}

.tafsir-ar-note-token {
  font-weight: 700;
  direction: rtl;
  unicode-bidi: isolate;
}

.tafsir-ar-note-par-key {
  font-weight: 700;
}

.tafsir-ar-note-text {
  white-space: pre-wrap;
}

.tafsir-ar-note-delete {
  margin-left: 0.4rem;
  border: 0;
  background: transparent;
  color: #7a3f3f;
  cursor: pointer;
  font-size: 0.76rem;
  text-decoration: underline;
}

.tafsir-ar-hover-note {
  position: fixed;
  z-index: 80;
  max-width: min(380px, calc(100vw - 24px));
  border: 1px solid #b8cbb8;
  border-radius: 8px;
  background: #fffef3;
  color: #2d3c3f;
  box-shadow: 0 6px 16px rgba(23, 38, 28, 0.15);
  padding: 0.36rem 0.5rem;
  font-size: 0.8rem;
  line-height: 1.38;
  white-space: pre-wrap;
  direction: auto;
  pointer-events: none;
}

.tafsir-ar-word-mark {
  background: #fff2bd;
  border-radius: 4px;
  box-shadow: inset 0 -1px 0 #e7c75f;
  cursor: pointer;
  padding: 0 0.1em;
}

.tafsir-ar-word {
  cursor: pointer;
}

.tafsir-ar-par-note-btn {
  border: 1px solid #c9d7c9;
  border-radius: 6px;
  background: #f5faf5;
  color: #3e5d4f;
  font-size: 0.68rem;
  line-height: 1;
  padding: 0.16rem 0.34rem;
  cursor: pointer;
  vertical-align: middle;
}

.tafsir-ar-par-note-btn.is-noted {
  background: #fff2bd;
  border-color: #e3c35b;
  color: #6a5112;
}

.tafsir-ar-par-note-btn:hover {
  background: #e8f2e8;
}

.tafsir-ar-par-note-anchor {
  display: inline-flex;
  margin-inline-start: 0.35rem;
  vertical-align: middle;
}

.empty-note {
  margin: 0.45rem 0;
  background: #dce8de;
  border: 1px solid #b5c9b8;
  color: #2f4c3f;
  border-radius: 10px;
  padding: 0.6rem 0.72rem;
  font-family: "IBM Plex Sans", "Noto Sans", "DejaVu Sans", var(--font-sans);
  font-size: 0.88rem;
  line-height: 1.45;
}

.edit-toggle {
  margin-top: 0.72rem;
}

.editor-form {
  margin-top: 0.72rem;
  border-top: 1px dashed #cfdbcf;
  padding-top: 0.72rem;
}

.editor-form label,
.setting-label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.86rem;
  font-weight: 600;
  color: #3d5055;
}

textarea,
select {
  width: 100%;
  border: 1px solid #c7d5c7;
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 0.95rem;
  line-height: 1.6;
  padding: 0.62rem;
}

textarea {
  resize: vertical;
  min-height: 220px;
}

textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(61, 122, 95, 0.14);
}

.editor-actions {
  margin-top: 0.6rem;
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.editor-zone {
  margin-top: 0.72rem;
}

.settings-panel {
  margin: 0 auto 1rem;
  width: min(860px, 100%);
  padding: 0.82rem 0.95rem;
}

.settings-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.2rem;
  background: rgba(14, 24, 20, 0.42);
  backdrop-filter: blur(6px);
}

.settings-modal .settings-panel {
  margin: 0;
  width: min(520px, 100%);
  box-shadow: 0 24px 48px rgba(15, 32, 22, 0.2);
}

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

.settings-close {
  border-color: #d5e0d7;
  background: #f2f7f2;
  color: #3a5550;
}

.settings-close:hover {
  border-color: #b9c6ba;
  color: #1f2d34;
}

.settings-panel h2 {
  font-size: 1rem;
  margin-bottom: 0.6rem;
}

.setting-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.92rem;
  margin-bottom: 0.65rem;
}

.settings-note {
  margin-top: 0.35rem;
  margin-bottom: 0;
  font-size: 0.84rem;
  color: var(--ink-muted);
}

.is-hidden {
  display: none !important;
}

[data-source-link] {
  display: none !important;
}

body.show-source-links [data-source-link] {
  display: inline-flex !important;
}

[data-edit-control] {
  display: none !important;
}

body.show-edit-controls [data-edit-control] {
  display: block !important;
}

body.show-latin [data-latin-line] {
  display: block !important;
}

@media (max-width: 860px) {
  .page-shell {
    width: 100%;
    padding-top: 0.55rem;
    padding-bottom: 6.2rem;
  }

  .topbar-content {
    min-height: 42px;
    grid-template-columns: auto 1fr auto;
  }

  .brand {
    font-size: 0.94rem;
  }

  .list-item-ayah {
    flex-direction: column;
    align-items: flex-start;
  }

  .edge-nav {
    display: none;
  }

  .mobile-nav-inline {
    display: flex;
    align-items: center;
    gap: 0.3rem;
  }

  .nav-compact-link,
  .list-item-ayah .btn {
    width: 100%;
    justify-content: flex-start;
  }

  .tafsir-tab {
    width: auto;
    justify-content: center;
  }

  .ayah-toolbar {
    grid-template-columns: 1fr auto auto;
    gap: 0.2rem;
  }

  .ayah-line-text {
    font-size: 0.78rem;
  }

  .tafsir-text {
    font-size: 0.97rem;
  }

  .tafsir-ar-note-form {
    grid-template-columns: 1fr;
  }

  .tafsir-ar-note-form .btn {
    width: 100%;
    justify-content: center;
  }

  .tafsir-ar-par-key-row {
    grid-template-columns: 1fr;
  }

  .tafsir-ar-par-key-row .btn {
    width: 100%;
    justify-content: center;
  }

  .tafsir-tabs-bottom {
    bottom: 0;
    width: 100vw;
    max-height: 76px;
  }
}
