:root {
  --paper: #fbf7ef;
  --card: #ffffff;
  --ink: #1b1a17;
  --muted: #6b6659;
  --teal: #0f766e;
  --teal-soft: #f0fdfa;
  --amber: #f59e0b;
  --amber-soft: #fff7ed;
  --red: #b91c1c;
  --red-soft: #fef2f2;
  --sent: #fef3c7;
  --word: #fbbf24;
  --line: #e7e0d2;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Segoe UI", "Noto Naskh Arabic", "Geeza Pro", "Tahoma", system-ui, -apple-system, sans-serif;
  font-size: 18px;
  line-height: 1.6;
  padding-bottom: calc(6.5rem + env(safe-area-inset-bottom));
}

.top {
  padding: 1.1rem 1.1rem 0.5rem;
  max-width: 46rem;
  margin: 0 auto;
}

.top h1 {
  font-size: 1.45rem;
  line-height: 1.35;
  margin: 0 0 0.4rem;
}

.lead {
  color: var(--muted);
  font-size: 1rem;
  margin: 0.2rem 0 0;
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding: 0.6rem 1.1rem;
  background: rgba(251, 247, 239, 0.96);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tabs a {
  flex: 0 0 auto;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  text-decoration: none;
  font-size: 0.95rem;
  white-space: nowrap;
}

.tabs a.on {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

main {
  max-width: 46rem;
  margin: 0 auto;
  padding: 0.6rem 1.1rem 1rem;
}

.g {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem 1rem 1.1rem;
  margin: 0 0 1rem;
}

.lbl {
  margin: 0;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  color: var(--teal);
  font-weight: 700;
}

.g h2 {
  font-size: 1.22rem;
  line-height: 1.4;
  margin: 0.15rem 0 0.6rem;
}

.s {
  font-size: 1.13rem;
  line-height: 1.95;
  margin: 0.65rem 0;
}

.s:first-of-type { margin-top: 0.3rem; }

.key {
  border-inline-start: 4px solid var(--teal);
  background: var(--teal-soft);
  border-radius: 10px;
  padding: 0.7rem 0.9rem;
  font-weight: 600;
}

.callout {
  border-radius: 12px;
  border-inline-start: 4px solid var(--amber);
  background: var(--amber-soft);
  padding: 0.7rem 0.9rem;
  margin: 0.9rem 0 0.2rem;
}

.callout.warning {
  border-inline-start-color: var(--red);
  background: var(--red-soft);
}

.callout h3 {
  font-size: 1rem;
  margin: 0 0 0.3rem;
}

.callout .s { margin: 0.2rem 0 0; font-size: 1.08rem; }

.lst {
  margin: 0.5rem 0;
  padding-inline-start: 1.4rem;
}

.lst li { margin: 0.45rem 0; }
.lst li.s { font-size: 1.11rem; }

.facts {
  display: grid;
  gap: 0.5rem;
  margin: 0.4rem 0 0.8rem;
}

.fact {
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
  border-bottom: 1px dashed var(--line);
  padding-bottom: 0.45rem;
}

.fl {
  flex: 0 0 5.5rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.fv { flex: 1 1 auto; font-size: 1.05rem; margin: 0; }

.rows { display: grid; gap: 0.7rem; margin-top: 0.4rem; }

.row {
  display: flex;
  gap: 0.7rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
}

.rn {
  flex: 0 0 1.9rem;
  height: 1.9rem;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 0.9rem;
  font-weight: 700;
}

.rb { flex: 1 1 auto; min-width: 0; }
.rt { font-weight: 700; font-size: 1.06rem; }
.rd { font-size: 1.03rem; line-height: 1.85; margin: 0.15rem 0 0; }
.rv { font-size: 0.92rem; color: var(--teal); margin-top: 0.2rem; }

.foot {
  color: var(--muted);
  font-size: 0.92rem;
  padding: 0.6rem 0.2rem 0;
}

.sent {
  scroll-margin-top: 4.5rem;
  scroll-margin-bottom: 8rem;
  border-radius: 6px;
  padding: 0.05em 0.1em;
  transition: background-color 0.15s ease;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.sent.cur {
  background: var(--sent);
  box-shadow: 0 0 0 2px var(--sent);
}

.w.cur { background: var(--word); border-radius: 4px; }

/* control bar */
.bar {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.9rem calc(0.6rem + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.97);
  border-top: 1px solid var(--line);
  box-shadow: 0 -6px 18px rgba(0, 0, 0, 0.06);
}

.ib {
  flex: 0 0 auto;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font-size: 1.3rem;
  line-height: 1;
  display: grid;
  place-items: center;
}

.pb {
  flex: 0 0 auto;
  width: 3.4rem;
  height: 3.4rem;
  border-radius: 50%;
  border: 0;
  background: var(--teal);
  color: #fff;
  font-size: 1.35rem;
  display: grid;
  place-items: center;
}

.pb:active, .ib:active { transform: scale(0.96); }

.pos {
  flex: 1 1 auto;
  text-align: center;
  font-size: 0.86rem;
  color: var(--muted);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel {
  position: fixed;
  inset-inline: 0;
  bottom: calc(4.6rem + env(safe-area-inset-bottom));
  z-index: 29;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding: 0.8rem 1.1rem 1rem;
  box-shadow: 0 -8px 20px rgba(0, 0, 0, 0.08);
}

.pr {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0.35rem 0;
  font-size: 0.95rem;
}

.pr select {
  flex: 1 1 auto;
  padding: 0.5rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--paper);
  font-size: 1rem;
  font-family: inherit;
}

.hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0.6rem 0 0;
  line-height: 1.7;
}

.tts-off .pb, .tts-off .ib { opacity: 0.5; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
