@font-face {
  font-family: "KFGQPC Uthmanic Script HAFS";
  /* Second URL is the copy already used by QuranMushaf, as a fallback if fonts/ is missing on the server */
  src: url("fonts/UthmanicHafs1Ver09.otf?v=2") format("opentype"),
       url("../../QuranMushaf/web/UthmanicHafs1Ver09.otf") format("opentype");
  font-display: swap;
}

:root {
  --bg: #f5f2ea;
  --panel: #fffdf9;
  --panel-strong: #f1e7d7;
  --primary: #234d3c;
  --primary-soft: #dfece6;
  --text: #1f1f1f;
  --muted: #5c5c5c;
  --shadow: rgba(35, 77, 60, 0.12);
  --border: #e6dcc8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  background: linear-gradient(180deg, #f8f4ee, #efe5d1);
  color: var(--text);
}

.app-shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: 100vh;
  height: 100vh;
}

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  box-shadow: 2px 0 8px var(--shadow);
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.sidebar h1 {
  margin: 0 0 12px;
  color: var(--primary);
  font-size: 2rem;
}

#surahSearch {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  margin-bottom: 14px;
  font-size: 0.95rem;
}

.surah-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.surah-item {
  width: 100%;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 10px;
  padding: 12px 14px;
  text-align: left;
  cursor: pointer;
  transition: 0.2s ease;
  color: var(--text);
}

.surah-item:hover,
.surah-item.active {
  background: var(--primary-soft);
  border-color: var(--primary);
}

.surah-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--muted);
}

.surah-arabic {
  font-family: "KFGQPC Uthmanic Script HAFS", "KFGQPC Uthmanic Script", "Noto Naskh Arabic", "Amiri", serif;
  font-size: 1.4rem;
  direction: rtl;
  text-align: right;
}

.content {
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 20px;
  gap: 16px;
}

.topbar {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px;
  box-shadow: 0 4px 10px var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.detail-launch-button {
  border: 1px solid var(--border);
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 10px;
  padding: 4px 10px;
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
}

.eyebrow {
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-size: 0.72rem;
}

.topbar h2 {
  margin: 0;
  color: var(--primary);
  font-size: 1.8rem;
  font-family: "KFGQPC Uthmanic Script HAFS", "KFGQPC Uthmanic Script", "Noto Naskh Arabic", "Amiri", serif;
}

.verse-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 4px 10px var(--shadow);
  padding: 18px;
  min-height: 320px;
}

.verse-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.verse-card {
  border: 1px solid var(--border);
  background: linear-gradient(180deg, #fff, #faf4eb);
  border-radius: 12px;
  padding: 14px;
  cursor: pointer;
  min-height: 110px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.verse-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(0,0,0,0.08);
}

.verse-number {
  display: inline-block;
  margin-bottom: 8px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 999px;
  padding: 4px 8px;
}

.verse-text {
  font-family: "KFGQPC Uthmanic Script HAFS", "KFGQPC Uthmanic Script", "Noto Naskh Arabic", "Amiri", serif;
  font-size: clamp(1.3rem, 2vw, 2rem);
  line-height: 1.9;
  direction: rtl;
  text-align: right;
  word-break: break-word;
}

.detail-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(22, 22, 22, 0.22);
  z-index: 10;
}

.detail-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(92vw, 1200px);
  max-height: 86vh;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 20px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.18);
  z-index: 20;
}

.detail-panel.hidden,
.detail-backdrop.hidden {
  display: none;
}

.detail-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.detail-panel h3 {
  margin: 0;
  color: var(--primary);
}

.close-button {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  width: 32px;
  height: 32px;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 10px 0 18px;
}

.detail-actions button,
.symbol-button {
  border: 1px solid var(--border);
  background: var(--panel-strong);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 12px;
  cursor: pointer;
  font-weight: 600;
}

.detail-actions button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.detail-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  transition: background 0.2s ease;
}

.detail-two-column {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: stretch;
}

.detail-two-column.single-column {
  grid-template-columns: 1fr;
}

.detail-column {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.detail-card .verse-text {
  font-family: "KFGQPC Uthmanic Script HAFS", "KFGQPC Uthmanic Script", "Noto Naskh Arabic", "Amiri", serif;
  font-size: 2.1rem;
  margin: 0 0 12px;
  flex: 1;
  min-height: 260px;
  height: 100%;
}

.detail-meta {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 8px;
}

.detail-raw,
.processed-textarea {
  width: 100%;
  min-height: 260px;
  height: 100%;
  font-family: "KFGQPC Uthmanic Script HAFS", "KFGQPC Uthmanic Script", "Noto Naskh Arabic", "Amiri", serif;
  font-size: 2.3rem;
  line-height: 2;
  direction: rtl;
  text-align: right;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  resize: vertical;
}

.processed-textarea {
  min-height: 260px;
  font-size: 2.5rem;
}

.symbol-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(54px, 1fr));
  gap: 8px;
  margin-top: 16px;
}

.symbol-button {
  min-height: 44px;
  font-size: 1.5rem;
  font-family: "KFGQPC Uthmanic Script HAFS", "KFGQPC Uthmanic Script", serif;
}

.verse-card.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(35, 77, 60, 0.12);
}

@media (max-width: 900px) {
  .detail-two-column {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
  }

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    height: 40vh;
  }
}
