/* Minimal modern: neutral greys, one ink accent. Letter rail | letter header, 3D viewer with player. Phone: letters drawer, viewer. */
:root {
  --bg: #fafafa; --surface: #ffffff; --surface-2: #f4f4f5; --ink: #18181b; --muted: #71717a; --line: #e4e4e7; --line-2: #ececef;
  --accent: #18181b; --accent-soft: #f4f4f5; --accent-ink: #18181b;
  --vio-soft: #f3efff; --vio-ink: #5b3fc4;
  --font-ui: "Inter", "IBM Plex Sans Arabic", "Segoe UI", system-ui, sans-serif;
  --font-ar: "IBM Plex Sans Arabic", "Inter", system-ui, sans-serif;
  --font-letter: "Amiri", "Traditional Arabic", "Noto Naskh Arabic", serif;
  --r: 12px; color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { background: var(--bg); color: var(--ink); }
body { margin: 0; font-family: var(--font-ui); font-size: 15px; line-height: 1.5; padding-inline: 16px; padding-block: 16px 28px; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.app { max-width: 1320px; margin: 0 auto; display: grid; gap: 14px; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand h1 { font-size: 1rem; margin: 0; font-weight: 600; letter-spacing: -0.01em; }
.lettersBtn { display: none; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 12px; font-weight: 500; font-size: .85rem; cursor: pointer; align-items: center; gap: 7px; }
.lettersBtn svg { width: 15px; height: 15px; flex: none; color: var(--accent-ink); }

.layout { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 16px; align-items: start; }
.rail { background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r); padding: 14px; display: grid; gap: 16px; position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; }
.grp { display: grid; gap: 6px; }
.grp .row { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 4px; direction: rtl; }
.lt { font-family: var(--font-letter); font-size: 1.15rem; line-height: 1; min-width: 32px; height: 32px; padding: 0 5px 4px; display: grid; place-items: center; border-radius: 8px; border: 0; background: var(--surface-2); color: var(--ink); cursor: pointer; transition: background .12s, color .12s; }
.lt:hover { background: var(--line); }
.lt.on { background: var(--accent); color: #fff; }
/* similar letters, under the letters: each one shows what tells it apart */
.similar { border-top: 1px solid var(--line-2); padding-top: 12px; display: grid; gap: 4px; }
.simh { font-size: .74rem; font-weight: 500; color: var(--muted); }
.simit { display: grid; gap: 2px; text-align: left; background: none; border: 0; border-radius: 9px; padding: 8px 6px; cursor: pointer; }
.simit:hover { background: var(--surface-2); }
.simit + .simit { border-top: 1px dashed var(--line); border-radius: 0 0 9px 9px; }
.simtop { display: flex; align-items: center; gap: 7px; margin-bottom: 2px; }
.simtop b { font-size: .84rem; font-weight: 600; }
.simtile { font-family: var(--font-letter); font-size: 1.1rem; width: 28px; height: 28px; border-radius: 7px; background: var(--surface-2); display: grid; place-items: center; padding-bottom: 3px; }
/* the place in two lines, then the dot matrix: a row per quality, a filled dot under the letter that has it */
.simpl { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 0 6px; font-size: .76rem; line-height: 1.35; align-items: baseline; }
.simpl [lang="ar"], .simmx .h { font-family: var(--font-letter); font-size: 1rem; color: var(--muted); }
.simpl [lang="ar"] { text-align: center; }
.simmx { display: grid; grid-template-columns: minmax(0, 1fr) 26px 26px; gap: 3px 0; align-items: center; font-size: .76rem; margin-top: 4px; }
.simmx .h { text-align: center; line-height: 1; }
.simmx .l { color: #3f3f46; }
.sd { justify-self: center; width: 9px; height: 9px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px #d4d4d8; }
.sd.f { background: var(--ink); box-shadow: none; }
.sd.h { background: linear-gradient(90deg, var(--ink) 50%, transparent 50%); box-shadow: inset 0 0 0 1.5px var(--ink); }
.sd.v.f { background: var(--vio-ink); }
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .rail { display: none; }
  .lettersBtn { display: inline-flex; }
  #simPill { display: inline-flex; }   /* the similar letters were in the rail: the pill opens them in a sheet */
}
.drawer { position: fixed; inset: 0; z-index: 50; background: rgb(0 0 0 / .35); display: flex; align-items: flex-end; }
.drawer .sheet { background: var(--surface); width: 100%; max-height: 82vh; overflow-y: auto; border-radius: 16px 16px 0 0; padding: 12px 16px calc(18px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 14px; }
.drawer .bar { display: flex; justify-content: space-between; align-items: center; }
.drawer .bar b { font-size: 1rem; font-weight: 600; }
.drawer .close { width: 32px; height: 32px; display: grid; place-items: center; padding: 0; border: 0; background: var(--surface-2); color: var(--ink); border-radius: 50%; cursor: pointer; }
.drawer .close svg { width: 16px; height: 16px; }

.main { display: grid; gap: 14px; min-width: 0; }
.lhead { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 16px; align-items: center; padding: 2px 2px 0; }
.tile { width: 62px; height: 62px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); color: var(--ink); display: grid; place-items: center; font-family: var(--font-letter); font-size: 2.4rem; line-height: 1; padding-bottom: 6px; }
.lhead h2 { margin: 0; font-size: 1.15rem; font-weight: 600; line-height: 1.25; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; letter-spacing: -0.01em; }
.lhead h2 .area { font-size: .75rem; font-weight: 500; color: var(--muted); }
.lhead .where { margin: 2px 0 0; color: var(--muted); font-size: .9rem; max-width: 70ch; }
/* the book (and page) a description or a sifah's meaning comes from */
.srcnote { font-size: .68rem; color: #a1a1aa; }   /* in brackets at the end of the text (it breaks only after a comma) */
.srcnote .nw { white-space: nowrap; }
/* sifaat: on laptop a panel under the description; on phones a pill in the toolbar opens them in a sheet */
.sifrow { grid-column: 1 / -1; display: grid; gap: 6px; }
.sifpanel { border: 1px solid var(--line-2); background: var(--surface); border-radius: var(--r); }
.sphead { all: unset; box-sizing: border-box; width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 14px; cursor: pointer; border-radius: var(--r); }
.sphead:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* folded, the bar reads as a caption, a divider, then the letter's sifaat as plain chips */
.sphead .spt { font-size: .66rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.sphead .spt .ch { font-family: var(--font-letter); font-size: 1rem; letter-spacing: 0; color: var(--ink); }
.sphead .vr { width: 1px; height: 16px; background: var(--line); flex: none; }
.sphead .spsum { flex: 1; min-width: 0; display: flex; gap: 5px; flex-wrap: wrap; }
.spsum span { border: 1px solid var(--line); background: var(--surface-2); border-radius: 999px; padding: 1px 9px; font-size: .74rem; font-weight: 500; color: var(--ink); white-space: nowrap; }
.sphead .chev { width: 8px; height: 8px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: translateY(-2px) rotate(45deg); transition: transform .15s; margin: 0 2px 0 auto; }
.sifpanel.shut .chev { transform: translateY(2px) rotate(-135deg); }
.spbody { padding: 2px 14px 12px; }
.sifpanel.shut .spbody { display: none; }
/* phone: the pill looks like the toolbar's other switches */
.sifpill { display: none; align-items: center; height: 30px; padding: 0 12px; border: 0; border-radius: 999px; background: var(--seg-bg); color: var(--ink); font: inherit; font-size: .76rem; font-weight: 600; cursor: pointer; white-space: nowrap; }
.sifpill::after { content: "\203A"; margin-left: 5px; color: var(--muted); font-weight: 500; }
#sifDrawerTitle .ch, #simDrawerTitle .ch { font-family: var(--font-letter); font-weight: 400; }
#simDrawerBody { border-top: 0; padding-top: 0; overflow: visible; }
.sflist { display: grid; }
.sflist .spit { padding: 9px 0; border-top: 1px solid var(--line-2); }
.sflist .spit b { font-size: .9rem; }
.sflist .spit p { font-size: .84rem; color: #3f3f46; line-height: 1.4; }
.splist { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 48px; }
.spit { display: grid; grid-template-columns: 10px minmax(0, 1fr); gap: 0 8px; align-items: baseline; align-content: start; }
.spit i { width: 8px; height: 8px; border-radius: 50%; align-self: center; }
.spit i { background: #a1a1aa; }
.spit b { font-size: .82rem; font-weight: 600; }
.spit .sfname { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 6px; }
.spit .sfar { display: inline-flex; align-items: baseline; gap: 6px; white-space: nowrap; }
.spit .sfsep { color: var(--muted); font-weight: 400; }
.spit .ar { font-family: var(--font-ar); font-size: 1rem; font-weight: 400; color: var(--muted); }
.spit p { grid-column: 2 / -1; margin: 0; font-size: .76rem; color: var(--muted); line-height: 1.35; }
/* something that happens while saying a letter but is not its makhraj (ص س ز: the sides of the tongue on the back teeth) */
.asidenote { margin: 6px 0 0; padding: 2px 0 2px 9px; border-left: 2px dashed var(--accent); font-size: .78rem; color: var(--muted); line-height: 1.4; max-width: 70ch; }
.lbl.aside { outline: 1.5px dashed var(--st-lbl-sub); outline-offset: 2px; }
.lbl.aside .en { font-style: italic; }
@media (max-width: 760px) { .splist { grid-template-columns: 1fr; } }
@media (max-width: 720px) { .tile { width: 52px; height: 52px; font-size: 2rem; } }

/* viewer: stage + player (this block goes full screen) */
.viewer { display: grid; gap: 10px; }
.stage { position: relative; aspect-ratio: 16 / 9.4; max-width: 100%; border-radius: var(--r); overflow: hidden;
  /* C1, light studio */
  --st-bg: radial-gradient(90% 80% at 45% 40%, #ffffff, #e6e6ea); --st-ink: #18181b; --st-muted: #71717a;
  --st-chip: rgb(255 255 255 / .92); --st-chip-ink: #18181b; --st-chip-off: #52525b; --st-chip-hover: rgb(0 0 0 / .05);
  --st-line: #52525b; --st-dot: #ffffff; --st-dot-ring: #18181b;
  --st-lbl: #ffffff; --st-lbl-ink: #18181b; --st-lbl-sub: #71717a; --st-lbl-shadow: 0 2px 10px rgb(0 0 0 / .1);
  --st-cap: rgb(255 255 255 / .9); --st-cap-ink: #18181b; --st-cap-line: rgb(0 0 0 / .06);
  background: var(--st-bg); color: var(--st-ink); }
.viewer.fs { position: fixed; inset: 0; z-index: 40; background: var(--bg); padding: 10px; grid-template-rows: minmax(0, 1fr) auto; }
.viewer:fullscreen { background: var(--bg); padding: 10px; grid-template-rows: minmax(0, 1fr) auto; width: 100%; height: 100%; }
.viewer.fs .stage, .viewer:fullscreen .stage { aspect-ratio: auto; height: 100%; }
.view { position: absolute; inset: 0; touch-action: none; }
#canvasHost, #canvasHost canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#canvasHost canvas { cursor: grab; }
#canvasHost canvas:active { cursor: grabbing; }
#overlay { position: absolute; inset: 0; pointer-events: none; }
#leaders { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
#leaders line { stroke: var(--st-line); stroke-width: 1; }
#leaders circle { fill: var(--st-dot); stroke: var(--st-dot-ring); stroke-width: 1.5; }
/* key label whose point is behind tissue from this angle: dashed line, hollow dot */
#leaders g.behind line { stroke-dasharray: 3 4; opacity: .6; }
#leaders g.behind circle { fill: none; stroke: var(--st-line); }
.lbl.behind { opacity: .75; }
.lbl { position: absolute; transform: translate(-50%, -50%); background: var(--st-lbl); color: var(--st-lbl-ink); border-radius: 8px; padding: 4px 10px; text-align: center; pointer-events: auto; cursor: help; white-space: nowrap; box-shadow: var(--st-lbl-shadow); transition: box-shadow .15s; }
.lbl .ar { display: block; font-family: var(--font-ar); font-weight: 600; font-size: .84rem; line-height: 1.3; }
.lbl .en { display: block; font-size: .7rem; color: var(--st-lbl-sub); line-height: 1.25; }
.lbl:hover, .lbl.hl { box-shadow: 0 0 0 2px var(--accent), var(--st-lbl-shadow); }
@media (max-width: 560px) { .lbl { padding: 2px 6px 3px; } .lbl .ar { font-size: .74rem; } .lbl .en { font-size: .58rem; } }
.tip3d { position: absolute; transform: translate(14px, -50%); background: rgb(24 24 27 / .9); color: #fff; border-radius: 8px; padding: 4px 9px; pointer-events: none; white-space: nowrap; font-size: .78rem; font-weight: 500; line-height: 1.25; z-index: 3; }
.tip3d .ar { display: block; font-family: var(--font-ar); font-weight: 600; font-size: .84rem; }
.tip3d .en { display: block; color: #d4d4d8; font-size: .7rem; }
.viewtools { --bar: rgb(255 255 255 / .96); --bar-line: rgb(0 0 0 / .07); --seg-bg: rgb(0 0 0 / .05); --on-soft: #e4e4e7; --on-ink: #18181b;
  position: absolute; z-index: 4; top: 12px; right: 12px; width: max-content; max-width: calc(100% - 24px); display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; align-items: center;
  background: var(--bar); border: 1px solid var(--bar-line); border-radius: 16px; padding: 4px; box-shadow: 0 4px 18px rgb(0 0 0 / .08); backdrop-filter: blur(8px); }
.viewtools .sep { width: 1px; height: 22px; background: var(--bar-line); margin: 0 3px; }
.viewtools .pill[aria-pressed="true"] { background: var(--on-soft); color: var(--on-ink); }
.viewtools > * { pointer-events: auto; }
.pill { border: 0; background: transparent; color: var(--st-chip-off); border-radius: 999px; padding: 4px 10px; font-size: .76rem; font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; }
.pill:hover { background: var(--st-chip-hover); }
.pill.icon { width: 30px; height: 28px; padding: 0; justify-content: center; }
.pill.icon svg { width: 16px; height: 16px; }
.seg { display: inline-flex; gap: 2px; border-radius: 999px; padding: 2px; background: var(--seg-bg); }
.seg button { border: 0; background: transparent; padding: 4px 10px; border-radius: 999px; font-size: .76rem; font-weight: 500; cursor: pointer; color: var(--st-chip-off); }
.seg button:hover { background: var(--st-chip-hover); }
.seg button[aria-pressed="true"] { background: var(--st-chip); color: var(--st-chip-ink); box-shadow: 0 1px 2px rgb(0 0 0 / .08); }
.legend { position: absolute; left: 14px; bottom: 14px; display: flex; gap: 14px; flex-wrap: wrap; max-width: 46%; font-size: .74rem; color: var(--st-muted); pointer-events: none; }
.legend > span { display: flex; align-items: center; gap: 6px; }
.legend i { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.legend .l2 { background: #0aa392; }
.legend .l4 { background: #b9a4ff; }
.legend .l5 { background: #6a45e6; }
#lblBtn[aria-pressed="false"] { color: var(--st-muted); }
/* phone: the colours are the only key to the makhraj and the heavy parts, so the legend stays, smaller, in the view's top corner */
@media (max-width: 760px) { .stage .legend { left: 8px; top: 8px; gap: 3px; max-width: calc(100% - 16px); font-size: .68rem; padding: 5px 8px; border-radius: 8px; background: rgb(255 255 255 / .8); color: #52525b; } }
.loading { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; text-align: center; color: var(--st-muted); transition: opacity .5s ease; }
.loading.out { opacity: 0; pointer-events: none; }
/* the letter itself is the loading screen, with a ring that always draws the whole way round before the head comes in */
#ldSwarm { position: absolute; inset: 0; width: 100%; height: 100%; }
.loading .msg { font-weight: 500; font-size: .9rem; max-width: 30ch; }
/* the head fades in once it is ready */
#canvasHost, #overlay { opacity: 0; transition: opacity .8s ease; }
.stage.ready #canvasHost, .stage.ready #overlay { opacity: 1; }
/* the view controls and the player wait for the head */
.stage:not(.ready) .viewtools, .stage:not(.ready) .legend, .stage:not(.ready) .player { visibility: hidden; }
@media (prefers-reduced-motion: reduce) { .loading, #canvasHost, #overlay { transition: none; } }

.playbtn { display: inline-flex; align-items: center; gap: 8px; border: 0; background: var(--ink); color: var(--surface); border-radius: 999px; padding: 6px 14px 6px 8px; cursor: pointer; font-weight: 500; font-size: .85rem; white-space: nowrap; transition: opacity .12s; }
.playbtn:hover { opacity: .88; }
.playbtn:disabled { opacity: .45; cursor: wait; }
.playbtn .ico { width: 22px; height: 22px; display: grid; place-items: center; }
.playbtn .ico svg { width: 11px; height: 12px; }
#scrub { flex: 1 1 160px; min-width: 120px; margin: 0; -webkit-appearance: none; appearance: none; height: 4px; border-radius: 2px; background: var(--line-2); accent-color: var(--accent); }
#scrub::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); cursor: pointer; }
#scrub::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); cursor: pointer; }
#scrub::-moz-range-progress { background: var(--accent); height: 4px; border-radius: 2px; }
.pseg { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 2px; }
.pseg button { border: 0; background: transparent; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 500; cursor: pointer; color: var(--muted); }
.pseg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / .1); }
/* desktop: everything fits the window, the viewer takes the rest of the height */
@media (min-width: 901px) {
  html, body { height: 100%; overflow: hidden; }
  body { padding-block: 16px; }
  .app { height: 100%; grid-template-rows: auto minmax(0, 1fr); }
  .layout { min-height: 0; height: 100%; align-items: stretch; }
  .rail { position: static; max-height: none; min-height: 0; }
  .main { min-height: 0; grid-template-rows: auto minmax(0, 1fr); }
  .viewer { min-height: 0; }
  .stage { aspect-ratio: auto; height: 100%; }
}
/* the letters keep their height; the similar letters under them take what is left, and scroll if it runs short */
.rail { grid-template-rows: auto minmax(0, 1fr) auto; overflow: visible; }
.similar { min-height: 0; overflow-y: auto; overflow-x: hidden; align-content: start; }
.rail .railgroups { overflow: visible; }
.similar[hidden] + .railfoot { grid-row: 3; }
.railgroups { overflow-x: hidden; }
.railgroups { display: grid; gap: 16px; align-content: start; overflow-y: auto; min-height: 0; }
.railfoot { border-top: 1px solid var(--line-2); padding-top: 10px; }
.info { position: relative; display: inline-flex; align-items: center; gap: 6px; font-size: .74rem; color: var(--muted); cursor: help; }
.info svg { width: 15px; height: 15px; flex: none; }
.info:hover, .info:focus { color: var(--ink); outline: none; }
.info .tipbox { position: absolute; left: 0; bottom: calc(100% + 10px); width: 300px; display: grid; gap: 6px; background: #18181b; color: #a1a1aa; font-size: .74rem; line-height: 1.45; padding: 10px 12px; border-radius: 10px; opacity: 0; transform: translateY(4px); pointer-events: none; transition: opacity .15s, transform .15s; box-shadow: 0 8px 24px rgb(0 0 0 / .25); z-index: 30; }
/* the sources: two books, then the 3D model (dark in the tooltip, light under the phone's letter list) */
.srcs { display: grid; gap: 6px; }
.srcs > span { display: block; }
.srcs .h { margin-top: 4px; font-size: .62rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: #a1a1aa; }
.srcs .h:first-child { margin-top: 0; }
.srcs[hidden] { display: none; }
/* phone: a "Sources" row under the letters, like the laptop's; a tap opens the sources under it */
.srcfoot { display: grid; gap: 10px; border-top: 1px solid var(--line-2); padding-top: 10px; }
.srcbtn { all: unset; justify-self: start; display: inline-flex; align-items: center; gap: 6px; font-size: .74rem; color: var(--muted); cursor: pointer; }
.srcbtn svg { width: 15px; height: 15px; flex: none; }
.srcbtn[aria-expanded="true"], .srcbtn:focus-visible { color: var(--ink); }
.srcbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.srcs .bk { display: grid; }
.srcs .bk b { font-weight: 600; color: var(--ink); }
.info .tipbox.srcs { gap: 5px; padding: 12px 14px; }
.info .tipbox .h { color: #71717a; }
.info .tipbox .bk b { color: #f4f4f5; }
.info:hover .tipbox, .info:focus .tipbox { opacity: 1; transform: none; }
.note { font-size: .74rem; color: var(--muted); margin: 0; }
/* floating player */
.player { position: absolute; left: 50%; bottom: 54px; z-index: 3; display: flex; align-items: center; gap: 12px; width: min(560px, calc(100% - 32px));
  background: rgb(255 255 255 / .92); backdrop-filter: blur(10px); border: 1px solid rgb(0 0 0 / .06); border-radius: 999px; padding: 6px 8px 6px 6px;
  box-shadow: 0 8px 28px rgb(0 0 0 / .12); transform: translateX(-50%); transition: opacity .22s ease, transform .22s ease; }
.stage:not(.ctl) .player { opacity: 0; transform: translate(-50%, 14px); pointer-events: none; }
/* reached with the keyboard: it comes up while one of its controls has focus (a click doesn't keep it up) */
@media (min-width: 601px) { .stage .player:has(:focus-visible) { opacity: 1; transform: translateX(-50%); pointer-events: auto; } }
.player .playbtn { width: 38px; height: 38px; padding: 0; justify-content: center; background: #18181b; color: #fff; flex: none; }
.player .playbtn .ico { width: auto; height: auto; }
.player .playbtn .ico svg { width: 14px; height: 14px; }
.scrubwrap { --c: #2563eb; --c2: #60a5fa; --glow: rgb(37 99 235 / .45); position: relative; flex: 1 1 160px; min-width: 120px; height: 38px; display: flex; align-items: center; }
.scrubwrap #scrub { flex: 1; }
.scrubwrap #scrub::-webkit-slider-thumb { position: relative; z-index: 2; border-color: var(--c); }
.scrubwrap #scrub::-moz-range-thumb { border-color: var(--c); }
/* the stretch of the timeline where the letter is held at its makhraj: a lit segment, a bracket under it, and a pill below the bar */
.scrubwrap .cz { position: absolute; top: 50%; left: var(--cz-l, 50%); width: var(--cz-w, 10%); height: 6px; margin-top: -3px; border-radius: 3px; pointer-events: none;
  background: linear-gradient(90deg, var(--c2), var(--c)); box-shadow: 0 0 12px var(--glow); }
.scrubwrap .brk { position: absolute; left: var(--cz-l, 50%); width: var(--cz-w, 10%); top: calc(100% - 3px); height: 7px; border: 1.5px solid var(--c); border-top: 0; border-radius: 0 0 5px 5px; pointer-events: none; }
.scrubwrap .brk::after { content: ""; position: absolute; left: 50%; top: 100%; width: 1.5px; height: 11px; margin-left: -.75px; background: var(--c); }
.cztag { position: absolute; left: calc(var(--cz-l, 50%) + var(--cz-w, 10%) / 2); top: calc(100% + 15px); transform: translateX(-50%); white-space: nowrap; padding: 4px 12px; border: 0; border-radius: 999px;
  background: #18181b; color: #93c5fd; font-size: .72rem; font-weight: 600; cursor: pointer; box-shadow: 0 6px 16px rgb(0 0 0 / .25); transition: transform .15s ease; }
.cztag:hover { transform: translateX(-50%) translateY(-1px); }
.scrubwrap[hidden], .cz[hidden], .brk[hidden], .cztag[hidden] { display: none; }
.player #scrub { background: rgb(0 0 0 / .1); }
.player .pseg { background: rgb(0 0 0 / .05); }
.pseg[hidden] { display: none; }
.seg.form button { font-family: var(--font-letter); font-size: 1.2rem; line-height: 1; height: 34px; min-width: 44px; padding: 4px 12px 0;   /* room for hamza + fatha above and the tails of ج ح خ below */ display: inline-flex; align-items: center; justify-content: center; }
.seg.ico button { height: 26px; padding: 0 9px; display: inline-flex; align-items: center; }
.seg.ico svg { width: 16px; height: 16px; flex: none; }
.legend { top: 14px; bottom: auto; flex-direction: column; gap: 5px; flex-wrap: nowrap; }

@media (prefers-reduced-motion: reduce) { .playbtn, .lt { transition: none; } }

/* phone: the page is one screen. The letter's name and its whole description on top, then the tools in a row of their own,
   the view, and the player under it, always shown. Nothing sits on top of the view. */
@media (max-width: 600px) {
  body { padding: 0; }
  .app { position: relative; height: 100vh; height: 100dvh; padding: 12px 12px max(12px, env(safe-area-inset-bottom)); grid-template-rows: minmax(0, 1fr); gap: 0; }
  .top { position: absolute; top: 12px; right: 12px; z-index: 5; }
  .brand { display: none; }
  .layout { min-height: 0; height: 100%; }
  .main { min-height: 0; height: 100%; grid-template-rows: auto minmax(0, 1fr); gap: 10px; }
  .lhead { grid-template-columns: auto minmax(0, 1fr); gap: 8px 12px; padding: 0; }
  .lhead > div:nth-child(2) { display: contents; }
  .lhead h2 { padding-right: 104px; }   /* room for the Letters button */
  .lhead .where { grid-column: 1 / -1; margin: 0; max-width: none; color: #3f3f46; font-size: .88rem; line-height: 1.45; }
  .lhead .asidenote { grid-column: 1 / -1; margin: -2px 0 0; font-size: .76rem; }
  .sifrow { display: none; }
  .sifpill { display: inline-flex; }
  .tile { width: 44px; height: 44px; font-size: 1.7rem; padding-bottom: 5px; }
  .viewer { min-height: 0; height: 100%; }
  .stage { aspect-ratio: auto; height: 100%; display: flex; flex-direction: column; gap: 8px; overflow: visible; border-radius: 0; background: none; }
  .view { position: relative; inset: auto; flex: 1; min-height: 240px; border-radius: var(--r); overflow: hidden; background: var(--st-bg); }
  /* (on a narrow phone the tools scroll sideways rather than run off the screen) */
  .stage { min-width: 0; }   /* (else the row of tools sets the page's width and pushes it off the right edge) */
  .viewtools { overflow-x: auto; scrollbar-width: none; }
  .viewtools::-webkit-scrollbar { display: none; }
  .viewtools > * { flex: none; }
  .viewtools { position: static; width: auto; max-width: none; flex-wrap: nowrap; justify-content: space-between; gap: 2px; background: none; border: 0; box-shadow: none; padding: 0; backdrop-filter: none; }
  .viewtools .sep { display: none; }
  #fsBtn { display: none; }
  .player, .stage:not(.ctl) .player { position: relative; left: auto; bottom: auto; transform: none; opacity: 1; pointer-events: auto; width: auto; flex: none;
    border-radius: 18px; padding: 6px 10px 40px 6px; box-shadow: none; border-color: var(--line-2); background: var(--surface); }
}

/* a phone held sideways: the page is taller than the screen and the 3D view takes every touch, so a strip on its right
   is left for the finger to scroll the page. Touch screens only (pointer: coarse): a mouse can scroll anywhere */
@media (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
  .view { right: 44px; }
  .viewtools { right: 56px; }
  .stage::after { content: ''; position: absolute; top: 0; right: 0; bottom: 0; width: 44px; z-index: 2; background: #f4f4f5 center / 18px no-repeat
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%2371717a' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 2v12M5 5l3-3 3 3M5 11l3 3 3-3'/%3E%3C/svg%3E");
    border-left: 1px solid #e4e4e7; }
}
