/* QuranTarkeeb — bright, friendly design (Urdu, RTL) */
:root {
  --bg: #fff8ee;
  --surface: #ffffff;
  --surface-2: #fff2df;
  --text: #1d1b2f;
  --muted: #6c6782;
  --border: #f0e2cc;
  --accent: #0b7a6b;
  --accent-2: #12a37f;
  --accent-soft: #d9f5ec;
  --gold: #f5b301;
  --gold-soft: #fff1c2;
  --ism: #1e6fe0;
  --ism-soft: #e2eeff;
  --fil: #12a150;
  --fil-soft: #dcf7e7;
  --harf: #f05a3a;
  --harf-soft: #ffe4dc;
  --hl: #ffe680;
  --warn-bg: #fff3cf;
  --warn-text: #7a4b00;
  --lv0: #7c4dff; --lv1: #e91e8c; --lv2: #ff8f00; --lv3: #00a3c4; --lv4: #12a150; --lv5: #1e6fe0;
  --hero-1: #0b6e63; --hero-2: #12a37f; --hero-3: #1e88e5;
  --shadow: 0 6px 18px rgba(60, 40, 10, .10);
  --shadow-lg: 0 12px 30px rgba(60, 40, 10, .16);
  --radius: 18px;
  --ar: "Noto Naskh Arabic", "Amiri", serif;
  --quran: "Amiri Quran", "Noto Naskh Arabic", serif;
  --ur: "Noto Nastaliq Urdu", "Jameel Noori Nastaleeq", serif;
  --pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='72' height='72' viewBox='0 0 72 72'%3E%3Cg fill='none' stroke='%23e9d6b4' stroke-width='1'%3E%3Cpath d='M36 6l9 21 21 9-21 9-9 21-9-21-21-9 21-9z'/%3E%3Crect x='24' y='24' width='24' height='24' transform='rotate(45 36 36)'/%3E%3C/g%3E%3C/svg%3E");
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12111c; --surface: #1c1b2a; --surface-2: #26243a; --text: #f1eefc; --muted: #a9a3c4;
    --border: #34314d; --accent: #3fd0b0; --accent-2: #2bb894; --accent-soft: #163a35;
    --gold: #ffd23f; --gold-soft: #3b3215;
    --ism: #7fb2ff; --ism-soft: #1b2a47; --fil: #5fe39a; --fil-soft: #163524;
    --harf: #ff8f73; --harf-soft: #43231b; --hl: #5a4b10; --warn-bg: #3a2f12; --warn-text: #ffd98a;
    --lv0: #a98bff; --lv1: #ff5fb3; --lv2: #ffb340; --lv3: #3fd3f0; --lv4: #5fe39a; --lv5: #7fb2ff;
    --shadow: 0 6px 18px rgba(0, 0, 0, .35); --shadow-lg: 0 12px 30px rgba(0, 0, 0, .45);
    --pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='72' height='72' viewBox='0 0 72 72'%3E%3Cg fill='none' stroke='%232a2840' stroke-width='1'%3E%3Cpath d='M36 6l9 21 21 9-21 9-9 21-9-21-21-9 21-9z'/%3E%3Crect x='24' y='24' width='24' height='24' transform='rotate(45 36 36)'/%3E%3C/g%3E%3C/svg%3E");
  }
}
:root[data-theme="dark"] {
  --bg: #12111c; --surface: #1c1b2a; --surface-2: #26243a; --text: #f1eefc; --muted: #a9a3c4;
  --border: #34314d; --accent: #3fd0b0; --accent-2: #2bb894; --accent-soft: #163a35;
  --gold: #ffd23f; --gold-soft: #3b3215;
  --ism: #7fb2ff; --ism-soft: #1b2a47; --fil: #5fe39a; --fil-soft: #163524;
  --harf: #ff8f73; --harf-soft: #43231b; --hl: #5a4b10; --warn-bg: #3a2f12; --warn-text: #ffd98a;
  --lv0: #a98bff; --lv1: #ff5fb3; --lv2: #ffb340; --lv3: #3fd3f0; --lv4: #5fe39a; --lv5: #7fb2ff;
  --shadow: 0 6px 18px rgba(0, 0, 0, .35); --shadow-lg: 0 12px 30px rgba(0, 0, 0, .45);
  --pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='72' height='72' viewBox='0 0 72 72'%3E%3Cg fill='none' stroke='%232a2840' stroke-width='1'%3E%3Cpath d='M36 6l9 21 21 9-21 9-9 21-9-21-21-9 21-9z'/%3E%3Crect x='24' y='24' width='24' height='24' transform='rotate(45 36 36)'/%3E%3C/g%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background-color: var(--bg); background-image: var(--pattern); color: var(--text);
  font-family: var(--ur); font-size: 17px; line-height: 2.1;
}
a { color: var(--accent); }
.ar { font-family: var(--ar); line-height: 1.9; }
main { max-width: 1040px; margin: 0 auto; padding: 8px 16px 48px; }
h2 { font-size: 1.35rem; font-weight: 700; margin: 28px 0 6px; display: flex; align-items: center; gap: 8px; }
h2::before { content: ""; width: 10px; height: 22px; border-radius: 6px; background: linear-gradient(var(--gold), var(--harf)); }
h3 { font-size: 1.15rem; font-weight: 700; margin: 18px 0 6px; color: var(--accent); }
@keyframes pop { from { opacity: 0; transform: translateY(-6px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes bounce { 0%, 100% { transform: scale(1); } 40% { transform: scale(1.18); } 70% { transform: scale(.95); } }

/* ── Header band ── */
.topbar {
  background: linear-gradient(120deg, var(--hero-1), var(--hero-2) 55%, var(--hero-3));
  box-shadow: 0 4px 20px rgba(11, 110, 99, .3);
}
.site-header { display: flex; align-items: center; justify-content: space-between; max-width: 1040px; margin: 0 auto; padding: 10px 16px; }
.brand { text-decoration: none; color: #fff; display: flex; align-items: baseline; gap: 10px; }
.brand-ur { font-size: 1.6rem; font-weight: 700; text-shadow: 0 2px 0 rgba(0, 0, 0, .15); }
.brand-ur::before { content: "۞ "; color: var(--gold); }
.brand-en { font-family: system-ui, sans-serif; font-size: .85rem; color: rgba(255, 255, 255, .8); line-height: 1; letter-spacing: .04em; }
.header-btns { display: flex; gap: 8px; align-items: center; }
.icon-btn, .pill-btn {
  background: rgba(255, 255, 255, .18); border: 1px solid rgba(255, 255, 255, .45); color: #fff;
  border-radius: 999px; height: 40px; cursor: pointer; transition: background .2s, transform .2s;
}
.icon-btn { width: 40px; font-size: 1.1rem; }
.pill-btn { font-family: var(--ur); font-size: .9rem; padding: 0 14px; }
.icon-btn:hover, .pill-btn:hover { background: rgba(255, 255, 255, .32); transform: translateY(-1px); }
.pill-btn[aria-pressed="true"] { background: var(--gold); border-color: var(--gold); color: #3a2a00; font-weight: 700; }

.site-footer { max-width: 1040px; margin: 0 auto; padding: 16px; color: var(--muted); font-size: .85rem; border-top: 2px dashed var(--border); }
.site-footer p { margin: 4px 0; }

/* ── Home ── */
.hero {
  margin: 18px 0 8px; padding: 22px 24px; border-radius: 26px; color: #fff; text-align: center; position: relative; overflow: hidden;
  background: radial-gradient(circle at 15% 20%, rgba(255, 255, 255, .18) 0 60px, transparent 61px),
              radial-gradient(circle at 90% 85%, rgba(255, 210, 63, .25) 0 90px, transparent 91px),
              linear-gradient(135deg, #5b3cc4, #0b7a6b 60%, #12a37f);
  box-shadow: var(--shadow-lg);
}
.hero h1 { font-family: var(--quran); font-size: 2.8rem; font-weight: 400; margin: 0; line-height: 1.8; color: var(--gold); text-shadow: 0 3px 0 rgba(0, 0, 0, .2); }
.hero p { margin: 0; font-size: 1.1rem; color: #fff; opacity: .95; }
.hero .stats { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.hero .stat { background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .35); border-radius: 999px; padding: 0 14px; font-size: .9rem; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; margin: 14px 0 24px; }
.card {
  --c: var(--lv0);
  background: var(--surface); border: 0; border-radius: var(--radius); padding: 16px 18px 14px; text-decoration: none; color: var(--text);
  display: block; position: relative; overflow: hidden; box-shadow: var(--shadow); transition: transform .2s, box-shadow .2s;
  border-top: 6px solid var(--c);
}
.card:nth-child(4n+2) { --c: var(--lv1); }
.card:nth-child(4n+3) { --c: var(--lv2); }
.card:nth-child(4n+4) { --c: var(--lv3); }
a.card:hover { transform: translateY(-4px) rotate(-.4deg); box-shadow: var(--shadow-lg); }
.card .label { display: inline-block; font-size: .85rem; font-weight: 700; color: #fff; background: var(--c); border-radius: 999px; padding: 0 12px; }
.card .date { font-size: .78rem; color: var(--muted); }
.card .ayah-mini { font-family: var(--quran); font-size: 1.35rem; line-height: 1.9; }
.card .go { position: absolute; bottom: 10px; left: 14px; font-size: 1.3rem; color: var(--c); transition: transform .2s; }
a.card:hover .go { transform: translateX(-4px); }
.badge { display: inline-block; font-size: .72rem; padding: 0 8px; border-radius: 999px; background: var(--warn-bg); color: var(--warn-text); }
.how { background: var(--surface); border-radius: var(--radius); padding: 10px 20px; box-shadow: var(--shadow); }
.how ol { margin: 0; padding-inline-start: 20px; }
.how li::marker { color: var(--harf); font-weight: 700; }
.big-link { display: inline-block; text-decoration: none; background: linear-gradient(135deg, var(--lv0), var(--lv1)); color: #fff; padding: 4px 20px; border-radius: 999px; box-shadow: var(--shadow); font-weight: 700; }
.big-link:hover { transform: translateY(-2px); }

/* ── Lesson ── */
.crumbs { font-size: .85rem; color: var(--muted); margin-top: 8px; }
.crumbs a { text-decoration: none; font-weight: 600; }
.ayah-box {
  background: var(--surface); border-radius: 24px; padding: 14px 22px; margin: 8px 0 14px; text-align: center;
  box-shadow: var(--shadow); border: 3px solid transparent;
  background-image: linear-gradient(var(--surface), var(--surface)), linear-gradient(135deg, var(--gold), var(--lv1), var(--lv0), var(--accent-2));
  background-origin: border-box; background-clip: padding-box, border-box;
}
.ayah-text { font-family: var(--quran); font-size: 2.1rem; line-height: 2.3; }
.ayah-num { font-family: var(--ar); font-size: 1rem; color: var(--accent); margin: 0 4px; font-weight: 700; }
.draft { background: var(--warn-bg); color: var(--warn-text); border-radius: 12px; padding: 4px 12px; font-size: .88rem; margin: 8px 0; }

.tabs { display: flex; gap: 8px; overflow-x: auto; padding: 6px; margin: 10px 0 18px; background: var(--surface); border-radius: 999px; box-shadow: var(--shadow); }
.tab {
  flex: 1 0 auto; background: transparent; border: 0; color: var(--muted); border-radius: 999px;
  font-family: var(--ur); font-size: 1rem; padding: 2px 16px; cursor: pointer; white-space: nowrap; transition: background .2s, color .2s;
}
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab[aria-selected="true"] { color: #fff; font-weight: 700; background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 4px 12px rgba(18, 163, 127, .35); }
.hint { color: var(--muted); font-size: .9rem; margin: 0 0 8px; }

.translation { display: flex; flex-wrap: wrap; gap: 8px; font-size: 1.15rem; }
.chunk {
  background: var(--surface); border: 2px solid var(--border); border-radius: 14px; padding: 0 12px;
  cursor: pointer; font-family: var(--ur); font-size: 1.05rem; color: var(--text); box-shadow: var(--shadow); transition: transform .15s;
}
.chunk:hover { transform: translateY(-2px); }
.chunk.on { background: var(--hl); border-color: var(--gold); }

.tokens { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0; }
.tok {
  font-family: var(--ar); font-size: 1.6rem; line-height: 1.6; padding: 4px 16px; border-radius: 16px; cursor: pointer;
  border: 2px solid transparent; color: var(--text); box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s;
}
.tok:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.tok.ism { background: var(--ism-soft); border-color: var(--ism); }
.tok.fil { background: var(--fil-soft); border-color: var(--fil); }
.tok.harf { background: var(--harf-soft); border-color: var(--harf); }
.tok.on { background: var(--hl); }
.tok.sel { outline: 4px solid var(--gold); outline-offset: 2px; animation: bounce .4s; }

.legend { display: flex; gap: 16px; font-size: .9rem; color: var(--muted); flex-wrap: wrap; }
.legend span::before { content: ""; display: inline-block; width: 14px; height: 14px; border-radius: 50%; margin-inline-end: 6px; vertical-align: middle; }
.legend .l-ism::before { background: var(--ism); }
.legend .l-fil::before { background: var(--fil); }
.legend .l-harf::before { background: var(--harf); }

.word-card { background: var(--surface); border-radius: 22px; padding: 0 0 14px; box-shadow: var(--shadow-lg); overflow: hidden; animation: pop .3s ease; }
.word-card .wc-head { padding: 6px 20px; color: #fff; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.word-card .wc-head.ism { background: linear-gradient(135deg, var(--ism), #5aa2ff); }
.word-card .wc-head.fil { background: linear-gradient(135deg, var(--fil), #4fd18a); }
.word-card .wc-head.harf { background: linear-gradient(135deg, var(--harf), #ff9a63); }
.word-card .big { font-family: var(--ar); font-size: 2.6rem; line-height: 1.7; margin-inline-end: auto; }
.word-card .type-tag { background: rgba(255, 255, 255, .25); border-radius: 999px; padding: 0 14px; font-weight: 700; }
.word-card .wc-body { padding: 6px 20px 0; }
.word-card .controls { padding: 0 20px; }
.pill { display: inline-block; padding: 0 12px; border-radius: 999px; font-size: .9rem; font-weight: 700; }
.pill.ism { background: var(--ism-soft); color: var(--ism); }
.pill.fil { background: var(--fil-soft); color: var(--fil); }
.pill.harf { background: var(--harf-soft); color: var(--harf); }
dl.feats { display: grid; grid-template-columns: max-content 1fr; gap: 2px 16px; margin: 8px 0; }
dl.feats dt { color: #fff; background: var(--lv0); border-radius: 999px; padding: 0 10px; font-size: .8rem; align-self: center; text-align: center; }
dl.feats dt:nth-of-type(2) { background: var(--lv1); }
dl.feats dt:nth-of-type(n+3) { background: var(--muted); }
dl.feats dd { margin: 0; }
.role { font-weight: 700; color: var(--lv1); }
.note { background: var(--gold-soft); border-radius: 14px; padding: 4px 14px; margin-top: 10px; }
.note::before { content: "💡 "; }

/* ── Tree ── */
.tree-wrap { overflow-x: auto; background: var(--surface); border-radius: 22px; padding: 14px; box-shadow: var(--shadow); }
.tree { display: grid; gap: 4px 6px; min-width: max-content; }
.tree-caption {
  display: inline-block; font-weight: 700; color: #fff; margin-bottom: 6px; padding: 0 14px; border-radius: 999px;
  background: linear-gradient(135deg, var(--lv0), var(--lv1));
}
.tree .t-word { font-family: var(--ar); font-size: 1.5rem; text-align: center; line-height: 1.6; padding-inline: 10px; }
.tree .t-type, .tree .t-role { animation: pop .35s ease; display: flex; flex-direction: column; align-items: center; }
.tree .t-layer {
  align-self: start; margin-top: 10px; padding: 0 10px; border-radius: 999px; white-space: nowrap; color: #fff;
  background: var(--muted); font-size: .78rem; font-weight: 700; line-height: 1.9; animation: pop .35s ease;
}
.tree .t-layer.lv-w { background: var(--accent); }
.tree .t-layer.lv-a { background: var(--lv0); }
.tree .t-layer.lv-b { background: var(--lv1); }
.tree .t-layer.lvb0 { background: var(--lv2); } .tree .t-layer.lvb1 { background: var(--lv3); } .tree .t-layer.lvb2 { background: var(--lv4); }
.tree .t-layer.lvb3 { background: var(--lv5); } .tree .t-layer.lvb4 { background: var(--lv0); } .tree .t-layer.lvb5 { background: var(--lv1); }
.tree .t-type { text-align: center; font-size: .9rem; font-weight: 600; line-height: 1.6; }
.tree .t-type.ism { color: var(--ism); } .tree .t-type.fil { color: var(--fil); } .tree .t-type.harf { color: var(--harf); }
.tree .t-type .l1-main { padding: 0 10px; border-radius: 999px; }
.tree .t-type.ism .l1-main { background: var(--ism-soft); }
.tree .t-type.fil .l1-main { background: var(--fil-soft); }
.tree .t-type.harf .l1-main { background: var(--harf-soft); }
.tree .t-role { text-align: center; font-size: .9rem; font-weight: 700; color: var(--lv1); line-height: 1.9; max-width: 140px; justify-self: center; }
.l1-main { font-weight: 700; }
.l1-sub { font-weight: 400; color: var(--text); font-size: 1em; line-height: 2; }
.l1-sub::before { content: ""; display: block; width: 10px; height: 1px; background: var(--muted); margin: 0 auto; }
.word-card .l1-sub::before { display: none; }
.l1-add { text-decoration: underline dotted var(--muted); text-underline-offset: 6px; opacity: .85; }
.tree-key { font-size: .78rem; color: var(--muted); margin: 8px 0 0; }
.vline { display: block; width: 2px; height: 26px; background: var(--border); margin-bottom: 2px; }
.vline.short { height: 14px; }
.bracket { --c: var(--accent); text-align: center; margin-top: 4px; animation: pop .35s ease; min-width: 0; }
.bracket.lv0 { --c: var(--lv2); } .bracket.lv1 { --c: var(--lv3); } .bracket.lv2 { --c: var(--lv4); }
.bracket.lv3 { --c: var(--lv5); } .bracket.lv4 { --c: var(--lv0); } .bracket.lv5 { --c: var(--lv1); }
.bracket .line { border: 3px solid var(--c); border-top: 0; border-radius: 0 0 14px 14px; height: 14px; margin: 0 6px; }
.bracket .b-label { display: block; white-space: normal; overflow-wrap: break-word; font-size: .82rem; line-height: 1.9; padding: 0 4px; color: var(--c); font-weight: 700; }
.full-img { display: block; overflow-x: auto; border-radius: 22px; background: #fff; box-shadow: var(--shadow); }
.full-img img { display: block; width: 100%; min-width: 720px; height: auto; }
.gif { max-width: 100%; border-radius: 22px; display: block; box-shadow: var(--shadow); }

/* ── Buttons ── */
.controls { display: flex; gap: 10px; margin: 12px 0; flex-wrap: wrap; align-items: center; }
.btn {
  font-family: var(--ur); font-size: .95rem; padding: 2px 18px; border-radius: 999px; cursor: pointer; text-decoration: none;
  border: 0; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-weight: 700;
  box-shadow: 0 4px 12px rgba(18, 163, 127, .35); transition: transform .15s, box-shadow .15s;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: var(--surface); color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.btn.fun { background: linear-gradient(135deg, var(--lv0), var(--lv1)); box-shadow: 0 4px 12px rgba(124, 77, 255, .35); }
.btn:disabled { opacity: .35; cursor: default; transform: none; }
.step-count { color: #fff; background: var(--lv2); border-radius: 999px; padding: 0 12px; font-size: .9rem; font-weight: 700; }

.alert { background: var(--warn-bg); color: var(--warn-text); border-radius: 16px; padding: 8px 16px; margin: 10px 0; box-shadow: var(--shadow); border-inline-start: 6px solid var(--gold); }
.alert::before { content: "⚠️ "; }
.alert .ar { font-size: 1.15em; }

/* ── Concepts ── */
.concepts { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; margin-top: 14px; }
details.concept { --c: var(--lv0); background: var(--surface); border-radius: var(--radius); padding: 6px 16px; box-shadow: var(--shadow); border-inline-start: 6px solid var(--c); }
details.concept:nth-child(6n+2) { --c: var(--lv1); } details.concept:nth-child(6n+3) { --c: var(--lv2); }
details.concept:nth-child(6n+4) { --c: var(--lv3); } details.concept:nth-child(6n+5) { --c: var(--lv4); } details.concept:nth-child(6n+6) { --c: var(--lv5); }
details.concept summary { cursor: pointer; font-weight: 700; color: var(--c); }
details.concept[open] { box-shadow: var(--shadow-lg); }
details.concept table { border-collapse: collapse; width: 100%; font-size: .9rem; }
details.concept th { background: var(--surface-2); }
details.concept th, details.concept td { border: 1px solid var(--border); padding: 0 8px; text-align: center; }
details.concept td.ar { font-size: 1.1rem; }

/* ── Practice ── */
.q { background: var(--surface); border-radius: var(--radius); padding: 8px 16px; margin-bottom: 10px; display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; box-shadow: var(--shadow); }
.q .qw { font-family: var(--ar); font-size: 1.7rem; min-width: 110px; text-align: center; }
.choice { font-family: var(--ur); font-size: .95rem; padding: 0 16px; border-radius: 999px; border: 2px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; transition: transform .15s; }
.choice:hover { transform: translateY(-2px); }
.choice.right { background: var(--fil-soft); border-color: var(--fil); color: var(--fil); font-weight: 700; animation: bounce .4s; }
.choice.wrong { background: var(--harf-soft); border-color: var(--harf); color: var(--harf); }
select { font-family: var(--ur); font-size: .95rem; padding: 2px 8px; border-radius: 12px; border: 2px solid var(--border); background: var(--surface-2); color: var(--text); max-width: 100%; }
.score { display: inline-block; font-weight: 700; color: #fff; background: linear-gradient(135deg, var(--lv2), var(--lv1)); border-radius: 999px; padding: 0 16px; }
.score:empty { display: none; }
.mark { font-size: .9rem; }
.celebrate { position: fixed; inset: 0; pointer-events: none; z-index: 50; overflow: hidden; }
.celebrate span { position: absolute; top: -40px; font-size: 1.8rem; animation: fall 1.6s ease-in forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(360deg); opacity: .2; } }

/* ── Class mode: large text for a projector ── */
body.class-mode { font-size: 22px; }
body.class-mode main, body.class-mode .site-header { max-width: 1400px; }
body.class-mode .ayah-text { font-size: 3rem; }
body.class-mode .tok { font-size: 2.2rem; }
body.class-mode .tree .t-word { font-size: 2.1rem; }
body.class-mode .tree .t-type { font-size: 1rem; }
body.class-mode .tree .t-layer { font-size: .9rem; }
body.class-mode .tree .t-role { font-size: .95rem; max-width: 180px; }
body.class-mode .bracket .b-label { font-size: 1rem; }
body.class-mode .word-card .big { font-size: 3.4rem; }

@media (max-width: 600px) {
  body { font-size: 16px; }
  .ayah-text { font-size: 1.6rem; }
  .hero h1 { font-size: 2.1rem; }
  .tok { font-size: 1.35rem; padding: 2px 12px; }
  .brand-en { display: none; }
  .tabs { border-radius: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- surahs, weeks, Tafheem translation ---------- */
.surah-card .surah-ar { font-family: var(--quran); font-size: 2rem; line-height: 1.8; color: var(--c); }
.crumbs .when { color: var(--muted); font-weight: 400; }
.tafheem { background: var(--surface); border-radius: var(--radius); padding: 6px 18px; box-shadow: var(--shadow); border-inline-start: 6px solid var(--lv3); font-size: 1.15rem; line-height: 2.2; }
.tafheem p { margin: 6px 0; }
.tafheem .ayah-num { color: var(--lv3); font-size: .95rem; }
.tafheem .ref { font-size: .82rem; color: var(--muted); line-height: 1.9; border-top: 1px dashed var(--line, #ccc); padding-top: 6px; }
.tafheem .ref a { word-break: break-word; }
body.class-mode .tafheem { font-size: 1.5rem; }

/* ---------- back button, extra info ---------- */
.back-btn { display: inline-block; margin-top: 12px; text-decoration: none; font-weight: 700; color: #fff; background: linear-gradient(135deg, var(--lv3), var(--lv5)); padding: 2px 18px; border-radius: 999px; box-shadow: var(--shadow); }
.back-btn:hover, .back-btn:focus-visible { transform: translateX(3px); }
body.class-mode .back-btn { font-size: 1.1rem; }
.concept.extra { margin-top: 18px; }

/* ---------- language switch + English (LTR) mode ---------- */
/* Arabic always reads right to left, also inside the English page. */
.ayah-box, .tokens, .tree, .ayah-mini, .surah-ar, .q .qw, .word-card .big { direction: rtl; }
.lang-btn { font-family: "Nunito", system-ui, sans-serif; font-weight: 700; }
.lang-btn[lang="ur"] { font-family: var(--ur); }
.lang-big {
  margin-top: 12px; font: inherit; font-weight: 700; cursor: pointer; color: #3a2a00; background: var(--gold);
  border: 0; border-radius: 999px; padding: 2px 20px; box-shadow: 0 4px 12px rgba(0, 0, 0, .2); transition: transform .15s;
}
.lang-big:hover { transform: translateY(-2px); }
.lang-big[lang="ur"] { font-family: "Noto Nastaliq Urdu", serif; }
.lang-big[lang="en"] { font-family: "Nunito", system-ui, sans-serif; }

:root[lang="en"] { --ur: "Nunito", "Segoe UI", system-ui, sans-serif; }
:root[lang="en"] body { line-height: 1.65; }
:root[lang="en"] .hero h1:not(.hero-ar) { font-family: var(--ur); font-weight: 800; font-size: 2.4rem; line-height: 1.3; margin-bottom: 6px; }
:root[lang="en"] .brand-ur::before { content: "۞ "; }
:root[lang="en"] .brand-en { display: none; }
:root[lang="en"] .card .go { left: auto; right: 14px; }
:root[lang="en"] a.card:hover .go { transform: translateX(4px); }
:root[lang="en"] .back-btn:hover, :root[lang="en"] .back-btn:focus-visible { transform: translateX(-3px); }
:root[lang="en"] .tafheem { line-height: 1.8; }
:root[lang="en"] .tafheem .ayah-num { font-family: var(--ur); }
:root[lang="en"] .translation .chunk { line-height: 1.9; }
:root[lang="en"] .card .label, :root[lang="en"] .tab, :root[lang="en"] .btn { line-height: 2; }
:root[lang="en"] .note, :root[lang="en"] .alert { line-height: 1.75; }
:root[lang="en"] .alert .ar, :root[lang="en"] .note .ar, :root[lang="en"] details.concept .ar { font-size: 1.15em; }
/* Tree: grid runs right to left (Arabic order); English labels inside read left to right. */
:root[lang="en"] .tree .t-layer, :root[lang="en"] .tree .t-type > span, :root[lang="en"] .tree .t-role,
:root[lang="en"] .tree .b-label { direction: ltr; unicode-bidi: isolate; }
:root[lang="en"] .tree .t-type, :root[lang="en"] .tree .t-role, :root[lang="en"] .tree .b-label { line-height: 1.5; }
:root[lang="en"] .tree .t-type .l1-sub { line-height: 1.5; padding: 1px 0; }
:root[lang="en"] .tree .t-role { max-width: 150px; }
:root[lang="en"] .l1-add { text-underline-offset: 4px; }
