/* ReadThis Shorts: one short text per screen, in the Favabeans look (see ../APP_DESIGN.md).
   Accent: the ReadThis blue, two-tone (#4F8DF7 → #1D4ED8). Light by default, dark when asked. */
:root {
  --canvas: #F7F7F5;
  --surface: #FFFFFF;
  --surface-2: #F1F1EE;
  --surface-3: #E7E7E3;
  --ink: #1D1D1F;
  --ink-2: #57575F;
  --line: rgb(29 29 31 / .09);
  --line-2: rgb(29 29 31 / .17);
  --danger: #b3261e;
  --shadow-1: 0 1px 2px rgb(0 0 0 / .04), 0 8px 24px -14px rgb(0 0 0 / .12);
  --shadow-2: 0 2px 4px rgb(0 0 0 / .04), 0 24px 48px -22px rgb(0 0 0 / .22);
  --ease: cubic-bezier(.22, 1, .36, 1);
  --r-card: 26px;
  --r-md: 18px;
  --r-sm: 12px;
  --gutter: clamp(16px, 4vw, 40px);
  --font: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Newsreader", "Iowan Old Style", Georgia, serif;
  --ar-sans: "IBM Plex Sans Arabic", "Geist", system-ui, sans-serif;
  --ar-serif: "Amiri", "IBM Plex Sans Arabic", serif;

  /* This app's accent: the ReadThis blue */
  --accent: #2459D8;
  --accent-ink: #FFFFFF;
  --accent-soft: #E4EEF9;
  --accent-text: #1D4ED8;
  --focus: #2459D8;
  --blue-hi: #4F8DF7;
  --blue-lo: #1D4ED8;

  /* cards */
  --paper-hi: #FFFFFF;
  --paper-lo: #FBFBF9;
  --mix-hi: 44%;
  --mix-lo: 15%;
  --mix-3: 26%;
  --glow: 50%;
  --card-shadow: 0 1px 2px rgb(0 0 0 / .05), 0 30px 60px -34px rgb(30 50 110 / .35), inset 0 0 0 1px rgb(29 29 31 / .05);
  --rail-bg: color-mix(in srgb, var(--surface) 86%, transparent);
  --mark: #FBEBA9;
  --mark-ink: #1D1D1F;
  --scrim: rgb(20 22 30 / .32);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    --canvas: #0C0C0E;
    --surface: #161619;
    --surface-2: #202024;
    --surface-3: #2A2A2F;
    --ink: #F2F2F4;
    --ink-2: #ABABB5;
    --line: rgb(255 255 255 / .09);
    --line-2: rgb(255 255 255 / .17);
    --danger: #ffb4ab;
    --shadow-1: 0 1px 0 rgb(255 255 255 / .04) inset, 0 8px 24px -12px rgb(0 0 0 / .6);
    --shadow-2: 0 1px 0 rgb(255 255 255 / .05) inset, 0 28px 56px -22px rgb(0 0 0 / .8);
    --accent: #8DB2FF;
    --accent-ink: #0B1A3A;
    --accent-soft: #1B2330;
    --accent-text: #B3CCFF;
    --focus: #A9C6FF;
    --paper-hi: #18181C;
    --paper-lo: #111114;
    --mix-hi: 24%;
    --mix-lo: 9%;
    --mix-3: 13%;
    --glow: 22%;
    --card-shadow: 0 1px 0 rgb(255 255 255 / .05) inset, 0 30px 60px -30px rgb(0 0 0 / .9), inset 0 0 0 1px rgb(255 255 255 / .06);
    --mark: rgb(246 214 120 / .28);
    --mark-ink: #F2F2F4;
    --scrim: rgb(0 0 0 / .55);
    color-scheme: dark;
  }
}
:root:where([data-theme="dark"]) {
  --canvas: #0C0C0E;
  --surface: #161619;
  --surface-2: #202024;
  --surface-3: #2A2A2F;
  --ink: #F2F2F4;
  --ink-2: #ABABB5;
  --line: rgb(255 255 255 / .09);
  --line-2: rgb(255 255 255 / .17);
  --danger: #ffb4ab;
  --shadow-1: 0 1px 0 rgb(255 255 255 / .04) inset, 0 8px 24px -12px rgb(0 0 0 / .6);
  --shadow-2: 0 1px 0 rgb(255 255 255 / .05) inset, 0 28px 56px -22px rgb(0 0 0 / .8);
  --accent: #8DB2FF;
  --accent-ink: #0B1A3A;
  --accent-soft: #1B2330;
  --accent-text: #B3CCFF;
  --focus: #A9C6FF;
  --paper-hi: #18181C;
  --paper-lo: #111114;
  --mix-hi: 24%;
  --mix-lo: 9%;
  --mix-3: 13%;
  --glow: 22%;
  --card-shadow: 0 1px 0 rgb(255 255 255 / .05) inset, 0 30px 60px -30px rgb(0 0 0 / .9), inset 0 0 0 1px rgb(255 255 255 / .06);
  --mark: rgb(246 214 120 / .28);
  --mark-ink: #F2F2F4;
  --scrim: rgb(0 0 0 / .55);
  color-scheme: dark;
}
:root[data-text="large"] { font-size: 120%; }
:root[data-contrast="high"] { --ink-2: var(--ink); --line: rgb(29 29 31 / .4); --line-2: rgb(29 29 31 / .6); }
@media (prefers-color-scheme: dark) { :root[data-contrast="high"]:where(:not([data-theme="light"])) { --line: rgb(255 255 255 / .45); --line-2: rgb(255 255 255 / .6); } }
:root[data-contrast="high"]:where([data-theme="dark"]) { --line: rgb(255 255 255 / .45); --line-2: rgb(255 255 255 / .6); }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font: 400 1.0625rem/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-weight: 600; letter-spacing: -0.02em; }
a { color: var(--accent-text); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; margin: -1px; padding: 0; border: 0; }

/* ---------- Header: frosted bar + the pack chips ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--canvas) 78%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(18px); backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid var(--line);
}
.top-in { max-width: 1180px; margin: 0 auto; padding-inline: var(--gutter); min-height: 58px; display: flex; flex-wrap: wrap; align-items: center; gap: 0 14px; }
.brand { display: flex; align-items: center; gap: 10px; margin-inline-end: auto; min-width: 0; }
.brand img { width: 28px; height: 28px; border-radius: 7px; box-shadow: 0 1px 2px rgb(0 0 0 / .1); flex: none; }
.brand h1 { margin: 0; display: flex; align-items: center; font: 600 1.0625rem/1.2 var(--font); letter-spacing: -0.015em; white-space: nowrap; }
body .top .fbk-beta {
  margin-inline-start: 8px; padding: .32em .62em; border: 0; border-radius: 999px; box-shadow: none;
  font: 600 max(.66rem, 11px)/1.1 var(--font); letter-spacing: .05em;
  color: var(--accent-text); background: var(--accent-soft);
}
.fb-lang { display: flex; align-items: center; gap: 0; font-size: .875rem; color: var(--line-2); }
.fb-lang button { min-height: 44px; padding: 0 8px; border: 0; border-radius: 10px; background: none; box-shadow: none; color: var(--ink-2); font: 500 .875rem/1 var(--font); cursor: pointer; }
.fb-lang button:hover { color: var(--ink); }
.fb-lang button[lang="ar"] { font-family: var(--ar-sans); font-size: .95rem; }
.fb-lang button[aria-pressed="true"] { color: var(--ink); font-weight: 600; }
.fb-lang button:focus-visible { outline: 3px solid var(--focus); outline-offset: -2px; }
.home-link {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border-radius: 999px;
  color: var(--ink); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line);
  font: 500 .875rem/1 var(--font); text-decoration: none; white-space: nowrap;
  transition: box-shadow .2s;
}
.home-link:hover { box-shadow: inset 0 0 0 1px var(--line-2); }

.bar-in { max-width: 1180px; margin: 0 auto; padding: 0 var(--gutter) 8px; display: flex; align-items: center; gap: 8px; }
.chips {
  flex: 1; min-width: 0; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
  padding: 2px 2px 2px; margin: -2px -2px;
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
  mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
}
:root[dir="rtl"] .chips { -webkit-mask-image: linear-gradient(270deg, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(270deg, #000 calc(100% - 28px), transparent); }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 7px; min-height: 40px; padding: 0 14px 0 12px;
  border: 0; border-radius: 999px; cursor: pointer; white-space: nowrap;
  background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line);
  font: 500 .875rem/1 var(--font); transition: background-color .2s, box-shadow .2s;
}
.chip:last-child { margin-inline-end: 24px; }
.chip:hover { box-shadow: inset 0 0 0 1px var(--line-2); }
.chip[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; box-shadow: inset 0 0 0 1.5px var(--accent); }
.chip:focus-visible { outline-offset: 1px; }
.chip .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c2); flex: none; }
.chip-ico { display: inline-flex; width: 18px; height: 18px; }
.chip-ico svg, .ico svg { width: 100%; height: 100%; }
.chip-tag { font: 600 .6875rem/1 var(--font); padding: 3px 5px; border-radius: 6px; background: var(--surface-2); color: var(--ink-2); }
.chip-tag[lang="ar"] { font-family: var(--ar-sans); font-size: .75rem; }
:root[lang="ar"] .chip { font-family: var(--ar-sans); font-size: .9375rem; }

svg { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
svg .f { fill: color-mix(in srgb, currentColor 22%, transparent); }
svg .w { fill: var(--surface); }
.ico { display: inline-flex; width: 22px; height: 22px; flex: none; }

/* ---------- Buttons ---------- */
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border: 0; border-radius: 999px;
  background: var(--btn, var(--surface-2)); color: var(--ink);
  font: 500 .9375rem/1.2 var(--font); letter-spacing: -0.005em; cursor: pointer; text-decoration: none;
  transition: background-color .2s, box-shadow .2s, transform .2s var(--ease);
}
button:hover:not(:disabled), .btn:hover { background: color-mix(in srgb, var(--ink) 6%, var(--btn, var(--surface-2))); }
button:active:not(:disabled), .btn:active { transform: scale(.98); }
button:disabled { opacity: .4; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 8px 18px -12px color-mix(in srgb, var(--accent) 90%, transparent); }
button.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--ink) 12%, var(--accent)); }
button.ghost { background: transparent; color: var(--accent-text); }
button.ghost:hover:not(:disabled) { background: var(--accent-soft); }
button.danger { color: var(--danger); background: color-mix(in srgb, var(--danger) 9%, var(--surface)); }
.icon-btn { width: 44px; padding: 0; flex: none; }
.icon-btn svg { width: 22px; height: 22px; }
.file-btn { position: relative; }
.file-btn:focus-within { outline: 3px solid var(--focus); outline-offset: 3px; }
.settings-btn { --btn: var(--surface); box-shadow: inset 0 0 0 1px var(--line); width: 40px; min-height: 40px; }
:root[lang="ar"] button, :root[lang="ar"] .btn { font-family: var(--ar-sans); }

/* ---------- The stage and the feed ---------- */
main { display: block; }
.stage { position: relative; height: calc(100vh - var(--hdr, 112px)); height: calc(100dvh - var(--hdr, 112px)); min-height: 420px; }
.feed {
  position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden;
  scroll-snap-type: y mandatory; scrollbar-width: none; overscroll-behavior-y: auto;
}
.feed::-webkit-scrollbar { display: none; }
.feed:focus-visible { outline: none; }
.feed:focus-visible .slide .card { outline: 3px solid var(--focus); outline-offset: -3px; }
.slide {
  height: 100%; scroll-snap-align: start; scroll-snap-stop: always;
  display: grid; place-items: center; padding: 16px var(--gutter) 18px;
}
.card {
  --rail-room: 0px;
  --t1: var(--c1); --t3: var(--c3);
  container-type: inline-size;
  position: relative; width: min(560px, 100%); height: 100%; max-height: 920px;
  display: flex; flex-direction: column; overflow: hidden;
  padding: clamp(22px, 3.4vw, 38px) clamp(22px, 3.6vw, 40px) clamp(18px, 2.6vw, 26px);
  padding-inline-end: calc(clamp(22px, 3.6vw, 40px) + var(--rail-room));
  border-radius: var(--r-card);
  background:
    radial-gradient(110% 70% at 100% 0%, color-mix(in oklab, var(--t3) var(--glow), transparent), transparent 62%),
    radial-gradient(90% 60% at 0% 100%, color-mix(in oklab, var(--t1) calc(var(--glow) * .8), transparent), transparent 70%),
    linear-gradient(var(--ang, 160deg), color-mix(in oklab, var(--t1) var(--mix-hi), var(--paper-hi)), color-mix(in oklab, var(--t1) var(--mix-lo), var(--paper-lo)) 58%, color-mix(in oklab, var(--t3) var(--mix-3), var(--paper-lo)));
  box-shadow: var(--card-shadow);
  color: var(--ink);
}
.card-pack { margin: 0 0 6px; display: flex; align-items: center; gap: 8px; font: 500 .8125rem/1.2 var(--font); color: var(--ink-2); }
.card-pack .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c2) 22%, transparent); flex: none; }
.card-pack span:nth-child(2) { color: var(--ink); font-weight: 600; letter-spacing: -0.005em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-n { margin-inline-start: auto; font-variant-numeric: tabular-nums; }
.card-body {
  --base: clamp(1.28rem, 1.02rem + 1.15vw, 1.72rem);
  --fs: calc(var(--base) * var(--size, 1) * var(--fit, 1));
  flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: center;
  overflow: hidden; padding-block: 10px;
}
.card-body.scrolls { overflow-y: auto; justify-content: flex-start; overscroll-behavior: contain; }
.card-title { margin: 0 0 .7em; font: 600 calc(var(--fs) * .78)/1.25 var(--font); letter-spacing: -0.02em; color: var(--ink); text-wrap: balance; }
.card-text { font-size: var(--fs); line-height: 1.5; letter-spacing: -0.012em; text-wrap: pretty; }
.card-text p { margin: 0 0 .7em; }
.card-text p:last-child { margin-bottom: 0; }
.card-text .lead { font-weight: 500; font-size: 1.08em; letter-spacing: -0.02em; }
.card-text .lead ~ p { font-size: .8em; color: var(--ink-2); line-height: 1.55; }
.card-src { margin: 12px 0 0; font: 400 .8125rem/1.4 var(--font); color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Dark cards take the deep tone of each pair, so the tint still reads on a dark surface */
@media (prefers-color-scheme: dark) { :where(:root:not([data-theme="light"])) .card { --t1: var(--c2); --t3: #3A6FE6; } }
:where(:root[data-theme="dark"]) .card { --t1: var(--c2); --t3: #3A6FE6; }

/* Poems and quotes: Newsreader */
.face-serif .card-title { font-family: var(--serif); font-weight: 500; font-size: calc(var(--fs) * .86); letter-spacing: -0.01em; }
.face-serif .card-text { font-family: var(--serif); font-size: calc(var(--fs) * 1.08); line-height: 1.42; letter-spacing: -0.005em; }
.style-verse .card-text { line-height: 1.5; }
.stanza { margin: 0 0 .9em; }
.stanza .line { display: block; padding-inline-start: 1.1em; text-indent: -1.1em; }

/* Arabic cards */
.card[lang="ar"] .card-title { font-family: var(--ar-sans); letter-spacing: 0; line-height: 1.5; }
.card[lang="ar"] .card-text { font-family: var(--ar-sans); letter-spacing: 0; line-height: 1.85; font-size: calc(var(--fs) * 1.02); }
.card[lang="ar"].face-serif .card-text { font-family: var(--ar-serif); font-size: calc(var(--fs) * 1.14); line-height: 1.95; }
.card[lang="ar"].face-serif .card-title { font-family: var(--ar-serif); font-weight: 700; }
.card[lang="ar"] .card-text .lead ~ p { font-size: .82em; line-height: 1.8; }
.bayt { display: grid; grid-template-columns: 1fr; margin-bottom: .45em; }
.bayt .h:last-child { text-align: end; }
@container (min-width: 460px) {
  .bayt { grid-template-columns: 1fr 1fr; column-gap: 1.4em; }
  .bayt .h:first-child { text-align: start; }
  .bayt .h:last-child { text-align: end; }
}

/* The sentence being read */
.s { border-radius: .22em; transition: background-color .25s var(--ease), box-shadow .25s var(--ease); -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.s.reading { background: var(--mark); color: var(--mark-ink); box-shadow: 0 0 0 .12em var(--mark); }

/* Break, end and empty cards */
.pause-card { justify-content: center; text-align: center; padding-inline-end: clamp(22px, 3.6vw, 40px); }
.pause-in { display: grid; justify-items: center; gap: 6px; }
.pause-art { display: grid; place-items: center; width: 84px; height: 84px; margin-bottom: 14px; border-radius: 50%; color: var(--accent-text); background: color-mix(in srgb, var(--surface) 80%, transparent); box-shadow: var(--shadow-1); }
.pause-art svg { width: 40px; height: 40px; stroke-width: 1.5; }
.pause-title { margin: 0; font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.2rem); line-height: 1.2; letter-spacing: -0.025em; text-wrap: balance; }
.pause-title:focus { outline: none; }
.pause-q { margin: 4px 0 18px; font-size: 1.125rem; color: var(--ink-2); max-width: 26em; text-wrap: pretty; }
.pause-acts { --btn: var(--surface); display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.pause-acts button { min-height: 48px; padding: 0 22px; }
:root[lang="ar"] .pause-title { letter-spacing: 0; line-height: 1.5; font-family: var(--ar-sans); }

/* ---------- The rail: actions for the card on screen ---------- */
.rail {
  position: absolute; z-index: 5; bottom: 34px;
  inset-inline-start: calc(50% + min(280px, (100% - 2 * var(--gutter)) / 2) + 16px);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.rail-btn {
  flex-direction: column; gap: 5px; min-height: 0; padding: 0; width: 64px; background: none; border-radius: 16px;
  color: var(--ink); font: 500 .75rem/1.15 var(--font);
}
.rail-btn:hover:not(:disabled) { background: none; }
.rail-btn .ico {
  width: 50px; height: 50px; padding: 13px; border-radius: 50%;
  background: var(--rail-bg); box-shadow: var(--shadow-1), inset 0 0 0 1px var(--line);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  transition: background-color .2s, transform .2s var(--ease), color .2s;
}
.rail-btn:hover:not(:disabled) .ico { background: color-mix(in srgb, var(--ink) 6%, var(--surface)); }
.rail-btn:active:not(:disabled) { transform: none; }
.rail-btn:active:not(:disabled) .ico { transform: scale(.94); }
.rail-btn:focus-visible { outline: none; }
.rail-btn:focus-visible .ico { outline: 3px solid var(--focus); outline-offset: 2px; }
.rail-label { color: var(--ink-2); text-align: center; }
.rail-btn.listen .ico { background: var(--accent); color: var(--accent-ink); box-shadow: 0 10px 22px -12px color-mix(in srgb, var(--accent) 95%, transparent); }
.rail-btn.listen svg .f, .rail-btn.listen[aria-pressed="true"] svg .f { fill: currentColor; }
.rail-btn.listen:hover:not(:disabled) .ico { background: color-mix(in srgb, var(--ink) 12%, var(--accent)); }
.rail-btn[aria-pressed="true"]#saveBtn .ico { color: #E5508C; }
.rail-btn[aria-pressed="true"]#saveBtn svg .f { fill: currentColor; }
.rail-sep { width: 22px; height: 1px; background: var(--line-2); margin: 2px 0; }
.rail-btn.nav .ico { width: 44px; height: 44px; padding: 10px; }
.rail.off .rail-btn:not(.nav) { visibility: hidden; }
:root[lang="ar"] .rail-btn { font-family: var(--ar-sans); font-size: .8125rem; }

/* The deck name (with a way back to the library) */
.deck-pill {
  position: absolute; z-index: 6; top: 26px;
  inset-inline-start: calc(max(var(--gutter), 50% - 280px) + 14px);
  max-width: calc(min(560px, 100% - 2 * var(--gutter)) - 28px);
  min-height: 36px; padding: 0 14px 0 8px; gap: 4px;
  background: color-mix(in srgb, var(--surface) 88%, transparent); box-shadow: var(--shadow-1), inset 0 0 0 1px var(--line);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  font: 600 .8125rem/1.2 var(--font);
}
.deck-pill #deckPillName { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deck-pill .ico { width: 20px; height: 20px; }
:root[dir="rtl"] .deck-pill .ico { transform: scaleX(-1); }
.stage:has(.deck-pill:not([hidden])) .card-pack { visibility: hidden; }

/* ---------- My text: the library ---------- */
.library { position: absolute; inset: 0; overflow-y: auto; }
.lib-in { max-width: 760px; margin: 0 auto; padding: clamp(18px, 3vw, 34px) var(--gutter) 48px; }
.lib-head h2 { margin: 0 0 6px; font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem); line-height: 1.2; letter-spacing: -0.025em; }
.lib-lead { margin: 0 0 18px; color: var(--ink-2); max-width: 42em; }
.maker {
  display: grid; gap: 14px; padding: clamp(18px, 2.6vw, 26px); margin-bottom: 26px;
  background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow-1), inset 0 0 0 1px var(--line);
}
.field { display: grid; gap: 6px; font-weight: 500; font-size: .9375rem; }
.field input, .field textarea {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line-2); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink); font: 400 1rem/1.5 var(--font);
}
.field textarea { resize: vertical; min-height: 9em; }
.field input:focus-visible, .field textarea:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
:root[lang="ar"] .field input, :root[lang="ar"] .field textarea { font-family: var(--ar-sans); }
.maker-acts { display: flex; flex-wrap: wrap; gap: 10px; }
.hint { margin: 0; font-size: .875rem; color: var(--ink-2); }
.msg { margin: 0; min-height: 1.4em; font-size: .9375rem; color: var(--accent-text); font-weight: 500; }
.msg:empty { min-height: 0; }
.msg.bad { color: var(--danger); }
.decks-wrap h3 { margin: 0 0 10px; font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); }
:root[lang="ar"] .decks-wrap h3 { text-transform: none; letter-spacing: 0; font-size: .875rem; }
.decks { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.deck { display: flex; align-items: center; gap: 4px; padding: 6px; border-radius: 20px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); --btn: transparent; }
.deck-open { flex: 1; min-width: 0; justify-content: flex-start; gap: 12px; padding: 6px 10px 6px 6px; border-radius: 16px; text-align: start; min-height: 56px; }
.deck-ico { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; background: linear-gradient(150deg, #E4EEF9, #CFE0FF); color: var(--blue-lo); }
.deck-ico svg { width: 24px; height: 24px; }
.deck-text { display: grid; min-width: 0; gap: 2px; }
.deck-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deck-meta { font-size: .8125rem; color: var(--ink-2); }
.decks-empty { display: grid; justify-items: center; gap: 8px; padding: 28px 20px; border-radius: var(--r-md); background: var(--surface-2); color: var(--ink-2); text-align: center; }
.decks-empty p { margin: 0; max-width: 30em; }
.ico.big { width: 46px; height: 46px; padding: 10px; border-radius: 50%; background: var(--surface); color: var(--accent-text); }

/* ---------- About, footer ---------- */
.foot { max-width: 1180px; margin: 0 auto; padding: 18px var(--gutter) 28px; color: var(--ink-2); font-size: .875rem; }
.foot p { margin: 0 0 6px; }
.fb-about { max-width: 1180px; margin: 0 auto; padding: 34px var(--gutter) 6px; color: var(--ink-2); font-size: .9375rem; border-top: 1px solid var(--line); }
.fb-about h2 { margin: 0 0 8px; font-size: 1.0625rem; color: var(--ink); }
.fb-about > p { margin: 0 0 14px; max-width: 70ch; line-height: 1.6; }
.fb-faq { display: grid; gap: 8px; }
.fb-faq h3 { margin: 8px 0 4px; font-size: .9375rem; color: var(--ink); }
.fb-faq details { border-radius: 16px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.fb-faq summary { cursor: pointer; padding: 12px 16px; font-weight: 500; color: var(--ink); list-style-position: inside; }
.fb-faq summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 16px; }
.fb-faq details p { margin: 0; padding: 0 16px 14px; max-width: 70ch; line-height: 1.6; }

/* ---------- Sheets (settings, rename) ---------- */
.sheet {
  width: min(560px, calc(100% - 32px)); max-height: 88dvh; padding: 0; border: 0; border-radius: 22px;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-2); overflow: auto;
}
.sheet.small { width: min(420px, calc(100% - 32px)); }
.sheet::backdrop { background: var(--scrim); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.sheet-in { padding: 22px clamp(18px, 4vw, 28px) 24px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 4px; }
.sheet h2 { margin: 0; font-size: 1.375rem; line-height: 1.2; }
.sheet.small h2 { margin-bottom: 14px; }
.today { margin: 0 0 6px; padding: 10px 14px; border-radius: 14px; background: var(--accent-soft); color: var(--ink); font-size: .9375rem; }
.set { padding: 16px 0; border-top: 1px solid var(--line); display: grid; gap: 10px; }
.set:first-of-type { border-top: 0; }
.set h3 { margin: 0; font-size: .75rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); }
:root[lang="ar"] .set h3 { text-transform: none; letter-spacing: 0; font-size: .875rem; }
.seg { display: inline-flex; flex-wrap: wrap; justify-self: start; padding: 3px; gap: 2px; border-radius: 13px; background: var(--surface-2); }
.seg button { min-height: 40px; padding: 0 16px; border-radius: 10px; background: transparent; color: var(--ink-2); }
.seg button:hover:not(:disabled) { background: color-mix(in srgb, var(--ink) 5%, transparent); }
.seg button[aria-checked="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgb(0 0 0 / .08), 0 3px 10px -3px rgb(0 0 0 / .1); }
@media (prefers-color-scheme: dark) { :where(:root:not([data-theme="light"])) .seg button[aria-checked="true"] { background: var(--surface-3); box-shadow: 0 1px 2px rgb(0 0 0 / .4); } }
:where(:root[data-theme="dark"]) .seg button[aria-checked="true"] { background: var(--surface-3); box-shadow: 0 1px 2px rgb(0 0 0 / .4); }
.seg button[lang="ar"] { font-family: var(--ar-sans); }
.check, .opt { display: flex; align-items: flex-start; gap: 12px; min-height: 44px; cursor: pointer; }
.check input, .opt input { width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.check span, .opt span { display: grid; gap: 2px; }
.check small, .opt small { color: var(--ink-2); font-size: .875rem; }
.voice-choice { border: 0; margin: 0; padding: 0; display: grid; gap: 8px; }
.opt-more { display: grid; gap: 6px; padding-inline-start: 34px; margin-bottom: 6px; font-size: .9375rem; }
.opt-more select, .set select { min-height: 44px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--surface); max-width: 100%; }
.opt-more button { justify-self: start; }
.progress { height: 6px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.progress .bar { height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--blue-hi), var(--blue-lo)); transition: width .3s; }
.status { margin: 0; font-size: .875rem; color: var(--ink-2); }
.status:empty { display: none; }
.range { display: flex; align-items: center; gap: 12px; min-height: 44px; }
.range input { flex: 1; accent-color: var(--accent); }
.range output { min-width: 3em; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.set > button { justify-self: start; }
.row { display: flex; flex-wrap: wrap; gap: 10px; }
.row.end { justify-content: flex-end; margin-top: 16px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; z-index: 50; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px; max-width: calc(100% - 32px); padding: 6px 6px 6px 20px; min-height: 52px;
  border-radius: 999px; background: var(--ink); color: var(--canvas); box-shadow: var(--shadow-2); font-size: .9375rem;
}
:root[dir="rtl"] .toast { padding: 6px 20px 6px 6px; }
.toast:not(:has(.toast-btn:not([hidden]))) { padding-inline-end: 20px; }
.toast-btn { flex: none; min-height: 40px; padding: 0 16px; border-radius: 999px; background: var(--canvas); color: var(--ink); font-weight: 600; }
.toast-btn:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 14%, var(--canvas)); }

/* Language suggestion (lang.js) */
.suggest-slot:empty { display: none; }
.suggest-slot { max-width: 1180px; margin: 0 auto; padding: 0 var(--gutter) 10px; }
.fb-suggest { --btn: var(--surface); display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin: 0; padding: 10px 14px; border-radius: 20px; background: var(--surface); box-shadow: var(--shadow-1), inset 0 0 0 1px var(--line); }
.fb-suggest p { margin: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: baseline; }
.fb-suggest [lang="ar"] { font-family: var(--ar-sans); font-weight: 600; }
.fb-suggest [lang="en"] { color: var(--ink-2); }
.fb-suggest-acts { display: flex; flex-wrap: wrap; gap: 8px; }
.fb-suggest button { min-height: 40px; padding: 0 16px; }
.fb-suggest .fb-ar { background: var(--accent); color: var(--accent-ink); }

/* Feedback box from /assets/feedback.js, fitted to this page */
body .fbk {
  width: min(760px, calc(100% - 2 * var(--gutter)));
  margin: 24px auto 72px; padding: 24px 26px;
  background: var(--surface); border: 0; border-radius: var(--r-card);
  box-shadow: var(--shadow-1), inset 0 0 0 1px var(--line);
}
body .fbk-q { font-weight: 600; letter-spacing: -0.01em; }
body .fbk-q svg { stroke: var(--accent); }
body .fbk-hint { color: var(--accent-text); }
body .fbk-send { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
body .fbk textarea, body .fbk input[type=email] { background: var(--surface); border-color: var(--line-2); border-radius: var(--r-sm); }
body .fbk .fbk-beta { color: var(--accent-text); background: var(--accent-soft); border: 0; box-shadow: none; font-family: var(--font); font-weight: 600; letter-spacing: .05em; }
body .fbk-star:focus-visible, body .fbk button:focus-visible, body .fbk textarea:focus-visible, body .fbk input:focus-visible { outline-color: var(--focus); }
body .fbk .fbk-star { background: none; padding: 8px; border-radius: 8px; min-height: 0; }
body .fbk .fbk-star svg { fill: currentColor; stroke: none; }
body .fbk .fbk-link { background: none; min-height: 44px; padding: 4px 0; border-radius: 0; }
body .fbk .fbk-send { min-height: 44px; padding: 0 22px; border-radius: 999px; }

/* ---------- Arabic interface ---------- */
:root[lang="ar"] { --font: "Geist", "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", sans-serif; }
:root[lang="ar"] body { line-height: 1.7; }
:root[lang="ar"] h1, :root[lang="ar"] h2, :root[lang="ar"] h3 { letter-spacing: normal; }
:root[lang="ar"] .card-pack { font-family: var(--ar-sans); }
:root[dir="rtl"] .rail-btn.nav .ico svg { transform: none; }

/* ---------- Phones ---------- */
@media (max-width: 760px) {
  .slide { padding: 8px 10px 10px; }
  .card { width: 100%; max-height: none; border-radius: 24px; --rail-room: 50px; padding: 20px 18px 16px; padding-inline-end: calc(18px + var(--rail-room)); }
  .pause-card { padding-inline-end: 18px; }
  .rail { inset-inline-start: auto; inset-inline-end: 18px; bottom: 22px; gap: 8px; }
  .rail-btn { width: 50px; }
  .rail-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .rail-btn .ico { width: 46px; height: 46px; padding: 12px; }
  .rail-btn.nav .ico { width: 42px; height: 42px; padding: 10px; }
  .rail.off { display: flex; }
  .card-src { padding-inline-end: 0; }
  .deck-pill { top: 18px; inset-inline-start: 26px; max-width: calc(100% - 52px - 56px); }
}
@media (max-width: 600px) {
  .top-in { min-height: 54px; gap: 0 6px; }
  .home-link { width: 40px; padding: 0; justify-content: center; font-size: 0; }
  .home-link::before { content: '←'; font-size: 1.05rem; }
  :root[dir="rtl"] .home-link::before { content: '→'; }
  .fb-lang button { padding: 0 6px; }
  .sheet { width: 100%; max-width: 100%; margin: auto 0 0; max-height: 88dvh; border-radius: 26px 26px 0 0; }
  .sheet.small { width: 100%; }
  .sheet-in { padding: 24px 16px max(20px, env(safe-area-inset-bottom)); }
}
@media (max-width: 380px) {
  .brand h1 { font-size: .98rem; }
  .brand { gap: 8px; }
  body .top .fbk-beta { margin-inline-start: 6px; }
  .card { --rail-room: 46px; padding-inline: 16px; padding-inline-end: calc(14px + var(--rail-room)); }
  .rail { inset-inline-end: 14px; }
  .rail-btn, .rail-btn .ico { width: 44px; }
  .rail-btn .ico { height: 44px; padding: 11px; }
  .rail-btn.nav .ico { width: 40px; height: 40px; }
}
@media (max-width: 340px) {
  .fb-lang button { padding: 0 4px; font-size: .8125rem; }
  .top-in { gap: 0; padding-inline: 10px; }
  .bar-in { padding-inline: 10px; }
}
@media (max-height: 640px) and (max-width: 760px) {
  .rail-sep, .rail-btn.nav { display: none; }
}

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: no-preference) {
  :root:not([data-motion="reduce"]) .sheet[open] { animation: sh-in .28s var(--ease); }
  :root:not([data-motion="reduce"]) .toast:not([hidden]) { animation: sh-toast .3s var(--ease); }
}
@keyframes sh-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes sh-toast { from { opacity: 0; transform: translate(-50%, 8px); } }
:root[data-motion="reduce"] *, :root[data-motion="reduce"] *::before, :root[data-motion="reduce"] *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }

/* The app name stacks ("ReadThis" over "Shorts") on narrow phones so the header stays on one row */
.nm { display: inline; }
@media (max-width: 440px) {
  .nm { display: inline-grid; line-height: 1; }
  .nm-a { font-size: .6875rem; font-weight: 500; letter-spacing: .02em; color: var(--ink-2); }
  .nm-b { font-size: 1.0625rem; }
}

/* Once there are decks, they come first (the maker follows) */
.lib-in { display: flex; flex-direction: column; }
.lib-in:has(.decks li) .lib-head { order: -2; }
.lib-in:has(.decks li) .decks-wrap { order: -1; margin-bottom: 28px; }

/* Arabic is a joined script: any letter-spacing breaks its letter forms */
:root[lang="ar"] body *:not([lang="en"]), .card[lang="ar"] * { letter-spacing: normal; }
/* Arabic dots below the line need room inside boxes that clip (ellipsis, line clamp) */
.card-pack span:nth-child(2), .deck-name, .deck-pill #deckPillName { padding-block: .3em; margin-block: -.3em; }
.card[lang="ar"] .card-src, :root[lang="ar"] .card-src { line-height: 1.7; }
