/* ---------- fonts of the search page : a brush pen for titles and what you find, a neat hand-print for the small text, a rounded, readable Arabic ---------- */
.sheet { --f-pen: "Kalam", "Baloo Bhaijaan 2", "Caveat", "Segoe Print", cursive; --f-input: "Kalam", "Baloo Bhaijaan 2", "Tajawal", "Segoe Print", cursive;
  --f-brush: "Caveat Brush", "Baloo Bhaijaan 2", "Caveat", "Segoe Print", cursive; --f-hand: "Patrick Hand", "Tajawal", "Segoe Print", system-ui, sans-serif;
  --f-ar: "Baloo Bhaijaan 2", "Tajawal", "Amiri", sans-serif; }
#engine .hw { font-family: var(--f-brush); font-weight: 400; }
[dir="rtl"] #engine .hw { font-family: var(--f-ar); font-weight: 700; }
#engine .hdr-note .sub { font-family: var(--f-hand); font-size: 1.05rem; }
/* Recap — search engine page (search-engine.html)
   Same notebook language as the rest of the site: ruled mint paper, washi tape, sticky notes, hand-drawn
   borders, Caveat headings, a twinkling ✦. The memorable thing here is the result: an index card filed
   under its subject, with the matched letters struck through with a highlighter. Everything else stays quiet. */

/* ---------- page background : layered waves along the bottom + sun rings in the top-right corner, drawn in the accent colour chosen in Réglages
   (no letters, no symbols). Everything uses var(--ink), so the whole drawing follows the colour and light/dark mode. ---------- */
.se-waves, .se-sun { position: absolute; z-index: 0; pointer-events: none; }
.se-waves { left: 0; right: 0; bottom: 0; width: 100%; height: 250px; }
.se-sun { top: 0; right: 0; width: 240px; height: 180px; }
.se-waves *, .se-sun * { vector-effect: non-scaling-stroke; }
#engine { padding-top: 84px; padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px)); --c: var(--accent); }
/* NOT positioned on purpose : the pen (position:absolute) measures its x/y against .screen, so .subject-body must not become its containing block */
#engine .subject-body { }

/* ---------- margin doodles : fixed on the desk behind the notebook page, very faint ---------- */

/* ---------- the dock : search card + subject tabs, stays under the thumb while results scroll ---------- */
.sx-dock { position: sticky; top: 0; z-index: 6; margin: 4px -20px 0; padding: 14px 20px 2px;
  transition: background .25s ease, box-shadow .25s ease; }
.sx-dock.stuck { background: color-mix(in srgb, var(--paper) 92%, transparent); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  box-shadow: 0 8px 14px -10px var(--sh, rgba(0, 0, 0, .3)); }
@keyframes sx-dock-in { from { opacity: 0; translate: 0 -18px; scale: .95; } }

/* ---------- staged arrival : only the header card (and the pen) at first. Once the pen has lifted (.sx-go), the search card drops in,
   the tabs slide in one by one, the status slip lands, its switch pops, and the results fade up — .sx-intro is removed afterwards
   so later re-renders (typing, filters) never replay it. ---------- */
#engine:not(.sx-go) .sx-dock, #engine:not(.sx-go) .sx-bar, #engine:not(.sx-go) #sx-out { opacity: 0; pointer-events: none; }
#engine.sx-intro .sx { animation: sx-in-card .8s cubic-bezier(.3, 1.4, .5, 1) .05s both; }
#engine.sx-intro .sx-tab { animation: sx-in-tab .6s cubic-bezier(.3, 1.5, .5, 1) calc(.32s + var(--ti, 0) * 75ms) both; }
#engine.sx-intro .sx-bar { --tb: 1.15s; animation: sx-in-bar .75s cubic-bezier(.3, 1.4, .5, 1) .95s both; }
#engine.sx-intro .sx-bar .sx-stat .l { animation: sx-in-fade .5s ease-out 1.2s both; }
#engine.sx-intro .sx-bar .sx-sw { animation: sx-in-sw .55s cubic-bezier(.3, 1.6, .5, 1) 1.3s both; }
#engine.sx-intro #sx-out { animation: sx-in-out .6s ease-out 1.3s both; }
@keyframes sx-in-card { from { opacity: 0; translate: 0 -24px; scale: .93; rotate: -3deg; } }
@keyframes sx-in-tab { from { opacity: 0; translate: 28px 0; scale: .7; rotate: 8deg; } }
@keyframes sx-in-bar { from { opacity: 0; translate: 0 26px; scale: .92; rotate: -2deg; } }
@keyframes sx-in-sw { from { opacity: 0; translate: 18px 0; scale: .6; } }
@keyframes sx-in-fade { from { opacity: 0; translate: 0 6px; } }
@keyframes sx-in-out { from { opacity: 0; translate: 0 16px; } }
.sx-tab .tn { font-variant-numeric: tabular-nums; }
.sx-tab .tn.bump { animation: sx-bump .55s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes sx-bump { 0% { scale: 1.45; } 100% { scale: 1; } }

.sx { --c: var(--accent); position: relative; display: flex; align-items: center; gap: 9px; margin: 8px 6px 4px; padding: 8px 8px 8px 10px;
  background: var(--card); border: 2.5px solid var(--c); border-radius: 22px 44px 22px 38px / 38px 22px 44px 22px;
  box-shadow: 3px 5px 0 color-mix(in srgb, var(--c) 35%, transparent); rotate: -.7deg;
  transition: box-shadow .2s ease, border-color .3s ease; }
.sx:focus-within { box-shadow: 3px 5px 0 color-mix(in srgb, var(--c) 55%, transparent), 0 0 0 4px color-mix(in srgb, var(--c) 18%, transparent); }
.sx-k { position: absolute; width: 16px; height: 16px; pointer-events: none; border: 0 solid var(--ink); }
.sx-k.tl { top: -9px; left: -9px; border-width: 3px 0 0 3px; border-top-left-radius: 7px; }
.sx-k.tr { top: -9px; right: -9px; border-width: 3px 3px 0 0; border-top-right-radius: 7px; }
.sx-k.bl { bottom: -9px; left: -9px; border-width: 0 0 3px 3px; border-bottom-left-radius: 7px; }
.sx-k.br { bottom: -9px; right: -9px; border-width: 0 3px 3px 0; border-bottom-right-radius: 7px; }
.sx::after { content: "\2726"; position: absolute; right: 36px; top: -15px; font-size: 1.05rem; color: var(--c);
  text-shadow: 0 0 8px color-mix(in srgb, var(--c) 70%, transparent); animation: sx-spark 2.8s ease-in-out infinite; pointer-events: none; }
@keyframes sx-spark { 0%, 100% { rotate: 14deg; scale: .8; opacity: .45; } 50% { rotate: 104deg; scale: 1.3; opacity: 1; } }

/* the magnifier : its ring takes the colour of the subject tab, its handle wiggles while you type */
.sx-ic { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border: 2px dashed var(--c); border-radius: 50%;
  background: color-mix(in srgb, var(--c) 12%, transparent); transition: border-color .3s ease, background .3s ease; }
.sx-ic svg { width: 21px; height: 21px; fill: none; stroke: var(--c); stroke-width: 2.3; stroke-linecap: round; stroke-linejoin: round; transform-origin: 40% 40%; transition: stroke .3s ease; }
.sx.typing .sx-ic svg { animation: sx-lens .5s ease-in-out; }
@keyframes sx-lens { 25% { rotate: -14deg; scale: 1.12; } 60% { rotate: 10deg; } }
.sx input { flex: 1; min-width: 0; padding: 7px 2px; background: none; border: 0; outline: none; color: var(--text); font: 400 1.05rem/1.3 var(--f-input); }
.sx input::placeholder { color: var(--muted); opacity: .85; }
.sx input::-webkit-search-cancel-button { display: none; }
.sx-x { flex: none; display: none; place-items: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 50%; cursor: pointer;
  color: var(--muted); background: color-mix(in srgb, var(--muted) 16%, transparent); transition: transform .12s ease; }
.sx.has .sx-x { display: grid; }
.sx-x:active { transform: scale(.86); }
.sx-x svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; }

/* ---------- subject tabs : sticky-note tags in a row ---------- */
.sx-tabs { display: flex; gap: 9px; margin: 0 -20px; padding: 30px 20px 10px; overflow-x: auto; overscroll-behavior-x: contain;
  scroll-snap-type: x proximity; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.sx-tabs::-webkit-scrollbar { display: none; }
.sx-tab { --c: var(--ink); position: relative; flex: none; display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 13px 0 9px; scroll-snap-align: center;
  font: inherit; font-family: var(--f-brush); font-weight: 400; font-size: 1.2rem; line-height: 1; white-space: nowrap; cursor: pointer;
  color: var(--text); border: 0; border-radius: 2px 2px 14px 2px; background: color-mix(in srgb, var(--c) 18%, var(--card));
  box-shadow: 0 4px 8px var(--sh, rgba(0, 0, 0, .18)); rotate: calc(var(--s, 1) * 1.6deg);
  transition: background .25s ease, color .25s ease, scale .25s cubic-bezier(.34, 1.4, .64, 1), rotate .25s ease; }
.sx-tab:nth-child(even) { --s: -1; }
.sx-tab::before { content: ""; position: absolute; top: -6px; left: 12px; width: 22px; height: 9px; rotate: -6deg;
  background: color-mix(in srgb, var(--c) 70%, transparent); box-shadow: 0 1px 2px rgba(0, 0, 0, .2); }
.sx-tab .ti { display: grid; place-items: center; width: 22px; height: 22px; border: 2px solid var(--c); border-radius: 50%; color: var(--c); transition: border-color .25s ease, color .25s ease; }
.sx-tab .ti svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.sx-tab .tn { min-width: 18px; padding: 2px 6px 1px; border-radius: 999px; font-family: var(--f-hand); font-size: .78rem; font-weight: 400; text-align: center;
  color: var(--text); background: color-mix(in srgb, var(--c) 22%, transparent); }
.sx-tab.zero:not(.on) { opacity: .5; }
.sx-tab.on { color: var(--on); background: var(--c); rotate: 0deg; scale: 1.06; box-shadow: 0 7px 14px var(--sh, rgba(0, 0, 0, .28)); }
.sx-tab.on::after { content: ""; position: absolute; top: -5px; right: 9px; width: 10px; height: 10px; border-radius: 50%; background: var(--red);
  box-shadow: inset -2px -2px 0 rgba(0, 0, 0, .25), 0 2px 3px rgba(0, 0, 0, .35); }
.sx-tab.on .ti { color: var(--on); border-color: var(--on); }
.sx-tab.on .tn { color: var(--c); background: var(--on); }
.sx-tab:active { scale: .94; }

/* ---------- status slip : a graduated ruler — big count, "fiches · N à réviser", the ready-only switch, and ruler ticks that fill with the ready ones ---------- */
.sx-bar { --c: var(--ink); position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; column-gap: 10px; row-gap: 5px; margin: 16px 6px 6px; padding: 9px 10px 7px 13px;
  background: var(--card); border: 2px solid color-mix(in srgb, var(--c) 65%, transparent); border-radius: 6px 18px 6px 18px; box-shadow: 2px 3px 0 color-mix(in srgb, var(--c) 25%, transparent);
  transition: background .3s ease, border-color .3s ease; }
.sx-bar.on { background: color-mix(in srgb, var(--c) 9%, var(--card)); border-color: var(--c); }
.sx-stat, .sx-stat .tx { display: contents; }
.sx-stat .n { grid-column: 1; grid-row: 1; min-width: calc(var(--d, 2) * .5em); transition: min-width .35s ease; transform-origin: 20% 70%; font-family: var(--f-brush); font-weight: 400; font-size: 2.1rem; line-height: .9; color: var(--c); }
.sx-stat .l { grid-column: 2; grid-row: 1; min-width: 0; font-family: var(--f-hand); font-size: 1rem; font-weight: 400; line-height: 1.1; color: var(--text); }
.sx-stat .l small { display: inline; margin-left: 3px; font-size: .84rem; font-weight: 400; color: var(--muted); }
.sx-stat .l small:not(:empty)::before { content: "\00b7  "; }
.sx-stat .mt { grid-column: 1 / -1; grid-row: 2; display: flex; justify-content: space-between; align-items: flex-end; height: 13px; padding: 0 1px; border-bottom: 2px solid color-mix(in srgb, var(--c) 40%, transparent); }
.sx-stat .mt i { width: 3px; height: 7px; border-radius: 2px 2px 0 0; background: color-mix(in srgb, var(--c) 18%, transparent); transform-origin: 50% 100%; transition: background .3s ease; animation: sx-tick .5s cubic-bezier(.3, 1.6, .5, 1) calc(var(--tb, 0s) + var(--i) * 35ms) backwards; }
.sx-stat .mt i:first-child, .sx-stat .mt i:last-child, .sx-stat .mt i:nth-child(5) { height: 12px; }
.sx-stat .mt i.f { background: var(--c); }
@keyframes sx-tick { from { scale: 1 0; } }
.sx-stat .n.roll { animation: sx-roll .65s cubic-bezier(.3, 1.4, .5, 1); }
@keyframes sx-roll { 0% { scale: 1.45; rotate: -6deg; } 55% { scale: .94; rotate: 2deg; } 100% { scale: 1; rotate: 0deg; } }
.sx-stat .rn { display: inline-block; min-width: 1ch; font-weight: 400; color: var(--c); }
.sx-bar.ping { animation: sx-ping .55s cubic-bezier(.3, 1.5, .5, 1); }
@keyframes sx-ping { 0% { scale: .975; } 45% { scale: 1.025; } 100% { scale: 1; } }
.sx-sw { grid-column: 3; grid-row: 1; display: flex; align-items: center; gap: 6px; padding: 4px 11px 4px 5px; font: inherit; color: var(--text); cursor: pointer; background: none;
  border: 2px solid color-mix(in srgb, var(--c) 55%, transparent); border-radius: 999px; transition: background .25s ease, border-color .25s ease; }
.sx-sw .st { position: relative; display: grid; place-items: center; width: 22px; height: 22px; border: 2px dashed var(--c); border-radius: 50%; color: var(--on);
  background: color-mix(in srgb, var(--c) 8%, transparent); transition: background .25s ease, border-color .25s ease, rotate .35s cubic-bezier(.3, 1.6, .5, 1); }
.sx-sw .st svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 24; stroke-dashoffset: 24; transition: stroke-dashoffset .3s ease .08s; }
.sx-sw .lb { font-family: var(--f-brush); font-weight: 400; font-size: .92rem; line-height: 1; white-space: nowrap; color: var(--muted); transition: color .25s ease; }
.sx-sw[aria-pressed="true"] { border-color: var(--c); background: color-mix(in srgb, var(--c) 14%, var(--card)); }
.sx-sw[aria-pressed="true"] .st { background: var(--c); border-style: solid; rotate: -12deg; animation: sx-stamp .45s cubic-bezier(.3, 1.5, .5, 1); }
.sx-sw[aria-pressed="true"] .st svg { stroke-dashoffset: 0; }
.sx-sw[aria-pressed="true"] .lb { color: var(--c); }
@keyframes sx-stamp { 0% { scale: 1.5; } 100% { scale: 1; } }
.sx-sw:active .st { scale: .88; }

/* ---------- results ---------- */
#sx-out { position: relative; padding: 2px 2px 8px; }
.sx-gh { display: flex; align-items: center; gap: 10px; margin: 20px 4px 14px; font-family: var(--f-brush); font-weight: 400; font-size: 1.5rem; line-height: 1; color: var(--c, var(--ink)); }
.sx-gh:first-child { margin-top: 8px; }
.sx-gh .gi { display: grid; place-items: center; width: 28px; height: 28px; border: 2px dashed var(--c); border-radius: 50%; background: color-mix(in srgb, var(--c) 12%, transparent); }
.sx-gh .gi svg { width: 15px; height: 15px; fill: none; stroke: var(--c); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.sx-gh em { margin-left: auto; font-style: normal; font-family: var(--f-hand); font-size: .82rem; font-weight: 400; padding: 3px 9px; border-radius: 999px; color: var(--text); background: color-mix(in srgb, var(--c) 18%, transparent); }
.sx-list { display: flex; flex-direction: column; gap: 17px; padding: 6px 2px 2px; }

.sr { --c: var(--teal); position: relative; display: flex; align-items: flex-start; gap: 12px; padding: 13px 13px 12px 12px; color: var(--text); text-decoration: none;
  background: var(--card); border: 2.2px solid color-mix(in srgb, var(--c) 72%, transparent); border-radius: 12px 28px 14px 26px / 26px 12px 28px 14px;
  box-shadow: 2px 4px 0 color-mix(in srgb, var(--c) 30%, transparent); rotate: var(--r, 0deg);
  transition: transform .12s ease, opacity .12s ease; -webkit-tap-highlight-color: transparent; }
.sx-list > :nth-child(3n+1) { --r: -.6deg; } .sx-list > :nth-child(3n+2) { --r: .7deg; } .sx-list > :nth-child(3n) { --r: -.2deg; }
.sr::before { content: ""; position: absolute; left: 12px; top: -7px; width: 40px; height: 12px; rotate: -4deg; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); pointer-events: none;
  background: repeating-linear-gradient(90deg, rgba(255, 255, 255, .5) 0 4px, transparent 4px 8px), color-mix(in srgb, var(--c) 58%, transparent); }
.sr:nth-child(even)::before { left: auto; right: 44px; rotate: 5deg; }
a.sr:active { transform: scale(.97); opacity: .78; }
a.sr:focus-visible { outline: 3px solid var(--c); outline-offset: 3px; }
.sr .ic { flex: none; display: grid; place-items: center; width: 42px; height: 42px; margin-top: 2px; border: 2px dashed var(--c); border-radius: 50%; background: color-mix(in srgb, var(--c) 12%, transparent); }
.sr .ic svg { width: 22px; height: 22px; fill: none; stroke: var(--c); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sr .bd { flex: 1; min-width: 0; }
.sr .tt { display: block; font-family: var(--f-pen); font-weight: 700; font-size: 1.1rem; line-height: 1.25; color: var(--c);
  /* a long lesson name stays on ONE line and scrolls sideways inside its card : soft fades show which side has more, a thin coloured scrollbar shows where you are */
  overflow-x: auto; overflow-y: hidden; white-space: nowrap; padding-bottom: 6px; margin-bottom: -2px; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch;
  scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--c) 60%, transparent) transparent; }
.sr .tt::-webkit-scrollbar { height: 3px; }
.sr .tt::-webkit-scrollbar-track { background: color-mix(in srgb, var(--c) 10%, transparent); border-radius: 3px; }
.sr .tt::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--c) 65%, transparent); border-radius: 3px; }
.sr .tt.fe:not(.fs) { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 30px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 30px), transparent); }
.sr .tt.fs:not(.fe) { -webkit-mask-image: linear-gradient(90deg, transparent, #000 30px); mask-image: linear-gradient(90deg, transparent, #000 30px); }
.sr .tt.fs.fe { -webkit-mask-image: linear-gradient(90deg, transparent, #000 30px, #000 calc(100% - 30px), transparent); mask-image: linear-gradient(90deg, transparent, #000 30px, #000 calc(100% - 30px), transparent); }
.sr .tt:dir(rtl).fe:not(.fs) { -webkit-mask-image: linear-gradient(270deg, #000 calc(100% - 30px), transparent); mask-image: linear-gradient(270deg, #000 calc(100% - 30px), transparent); }
.sr .tt:dir(rtl).fs:not(.fe) { -webkit-mask-image: linear-gradient(270deg, transparent, #000 30px); mask-image: linear-gradient(270deg, transparent, #000 30px); }
.sr .tt:dir(rtl).fs.fe { -webkit-mask-image: linear-gradient(270deg, transparent, #000 30px, #000 calc(100% - 30px), transparent); mask-image: linear-gradient(270deg, transparent, #000 30px, #000 calc(100% - 30px), transparent); }
.sr .tt.ar { font-family: var(--f-ar); font-weight: 700; font-size: 1.12rem; line-height: 1.7; padding-bottom: 4px; }
.sr .ds { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin: 4px 0 0; font-family: var(--f-hand); font-size: .92rem; line-height: 1.4; color: var(--muted); }
.sr .ds.ar { font-family: "Tajawal", system-ui, sans-serif; font-size: .8rem; line-height: 1.5; }
.sr .bc { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.sr .bc span { padding: 2px 9px; border-radius: 999px; font-family: var(--f-hand); font-size: .8rem; font-weight: 400; line-height: 1.45; color: var(--text); background: color-mix(in srgb, var(--c) 17%, transparent); }
.sr .go { flex: none; align-self: center; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; color: var(--on); background: var(--c); box-shadow: 1.5px 2px 0 color-mix(in srgb, var(--c) 45%, #000); }
.sr .go svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.8; stroke-linecap: round; stroke-linejoin: round; }
[dir="rtl"] .sr .go svg { scale: -1 1; }

/* not ready yet : dashed, a little paler, with a rubber stamp */
.sr.wip { border-style: dashed; box-shadow: none; background: color-mix(in srgb, var(--c) 5%, var(--card)); }
.sr.wip .ic, .sr.wip .tt { opacity: .68; }
.sr .stamp { flex: none; align-self: center; padding: 1px 8px 0; rotate: -7deg; border: 2px solid color-mix(in srgb, var(--red) 80%, transparent); border-radius: 6px;
  font-family: var(--f-brush); font-weight: 400; font-size: 1.12rem; line-height: 1.3; color: var(--red); opacity: .85; }

/* the highlighter : sweeps under the matched letters */
mark.hit { padding: 0 1px; color: inherit; background-color: transparent; border-radius: 2px; background-repeat: no-repeat; background-size: 100% 100%;
  background-image: linear-gradient(transparent 52%, color-mix(in srgb, var(--hl, var(--gold)) 46%, transparent) 52% 94%, transparent 94%); }
mark.hit:dir(rtl) { background-position: right; }
.sr .tt mark.hit { --hl: var(--c); }
.sr.fresh { animation: sx-file .6s cubic-bezier(.2, 1.2, .4, 1) calc(var(--k, 0) * 55ms) backwards; }
.sr.fresh mark.hit { animation: sx-mark .65s cubic-bezier(.4, .1, .2, 1) calc(var(--k, 0) * 55ms + .35s) backwards; }
.sr.fresh .ic { animation: sx-pop .5s cubic-bezier(.3, 1.6, .5, 1) calc(var(--k, 0) * 55ms + .12s) backwards; }
@keyframes sx-file { from { opacity: 0; translate: 0 18px; scale: .93; } }
@keyframes sx-mark { from { background-size: 0 100%; } }
@keyframes sx-pop { from { scale: .4; rotate: -24deg; opacity: 0; } }
/* subject switch (light) : one gentle fade-up per card, nothing else moves */
.sr.fresh.lite { animation: sx-lite .28s ease-out calc(var(--k, 0) * 35ms) backwards; }
.sr.fresh.lite mark.hit, .sr.fresh.lite .ic { animation: none; }
@keyframes sx-lite { from { opacity: 0; translate: 0 10px; } }
.sx-tab.just { animation: sx-tab-pop .32s cubic-bezier(.3, 1.5, .5, 1); }
@keyframes sx-tab-pop { 0% { scale: .9; } 60% { scale: 1.12; } 100% { scale: 1.06; } }

/* ---------- idle panel : suggestions, recent searches ---------- */
.sx-sec { margin: 10px 4px 0; }
.sx-sec + .sx-sec { margin-top: 22px; }
.sx-h { display: flex; align-items: center; gap: 11px; margin: 0 0 12px; font-family: var(--f-brush); font-weight: 400; font-size: 1.5rem; line-height: 1; color: var(--ink); }
.sx-h button { margin-left: auto; font: inherit; font-family: var(--f-hand); font-size: .84rem; font-weight: 400; color: var(--muted); background: none; border: 1.5px dashed color-mix(in srgb, var(--muted) 55%, transparent); border-radius: 999px; padding: 3px 11px; cursor: pointer; }
/* the search badge : a scalloped sticker (same family as the settings badge) that turns slowly, a magnifier that sweeps around, a twinkling star */
.sx-bd { position: relative; flex: none; display: grid; place-items: center; width: 34px; height: 34px; }
.sx-bd .sc { position: absolute; inset: -3px; width: 40px; height: 40px; overflow: visible; fill: color-mix(in srgb, var(--gold) 42%, var(--card)); stroke: var(--ink); stroke-width: 1.8; stroke-linejoin: round;
  animation: sx-turn 20s linear infinite; }
.sx-bd .mg { position: relative; width: 17px; height: 17px; fill: none; stroke: var(--ink); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; animation: sx-sweep 3.6s ease-in-out infinite; }
.sx-bd::after { content: "\2726"; position: absolute; top: -10px; right: -9px; font-size: .85rem; line-height: 1; color: var(--gold); text-shadow: 0 0 6px color-mix(in srgb, var(--gold) 70%, transparent); animation: sx-spark 2.8s ease-in-out infinite; }
.sx-sec + .sx-sec .sx-bd .sc { animation-delay: -7s; } .sx-sec + .sx-sec .sx-bd .mg { animation-delay: -1.4s; } .sx-sec + .sx-sec .sx-bd::after { animation-delay: -1.1s; }
@keyframes sx-turn { to { rotate: 360deg; } }
@keyframes sx-sweep { 0%, 100% { translate: 0 0; rotate: 0deg; } 25% { translate: 2px -2px; rotate: 14deg; } 50% { translate: 0 -3px; rotate: 0deg; } 75% { translate: -2px -1px; rotate: -14deg; } }
.sx-chips { display: flex; flex-wrap: wrap; gap: 14px 10px; padding: 4px 0 2px; }
.sx-chip { --c: var(--teal); position: relative; display: inline-flex; align-items: center; gap: 7px; min-height: 40px; padding: 0 14px 0 10px; font: inherit; cursor: pointer;
  font-family: var(--f-brush); font-weight: 400; font-size: 1.22rem; line-height: 1; color: var(--c);
  background: var(--card); border: 2.2px solid var(--c); border-radius: 14px 26px 16px 24px / 24px 14px 26px 16px; box-shadow: 2px 3px 0 color-mix(in srgb, var(--c) 30%, transparent); rotate: -1.2deg; }
.sx-chip:nth-child(even) { rotate: 1.3deg; border-radius: 24px 14px 22px 16px / 14px 24px 16px 22px; }
.sx-chip::before { content: ""; position: absolute; left: 8px; top: -6px; width: 30px; height: 10px; rotate: -24deg; box-shadow: 0 1px 2px rgba(0, 0, 0, .2);
  background: repeating-linear-gradient(90deg, rgba(255, 255, 255, .5) 0 4px, transparent 4px 8px), color-mix(in srgb, var(--c) 58%, transparent); }
.sx-chip svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.sx-chip:active { scale: .95; opacity: .75; }
.sx-chip:focus-visible, .sx-tab:focus-visible, .sx-sw:focus-visible, .sx-x:focus-visible, .sx-h button:focus-visible, .sx-rc button:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
.sx-rcs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; position: relative; }
.sx-rcs::before { content: ""; position: absolute; left: 20px; top: 14px; bottom: 14px; border-left: 2px dashed color-mix(in srgb, var(--muted) 50%, transparent); }
.sx-rc { position: relative; display: flex; align-items: center; gap: 4px; padding: 3px 4px 3px 4px; background: var(--card); border: 2px solid color-mix(in srgb, var(--ink) 40%, transparent);
  border-radius: 12px 24px 12px 22px / 22px 12px 24px 12px; box-shadow: 2px 3px 0 color-mix(in srgb, var(--ink) 18%, transparent); }
.sx-rc .rq { flex: 1; min-width: 0; display: flex; align-items: center; gap: 11px; padding: 5px 6px 5px 5px; font: inherit; font-family: var(--f-pen); font-size: .95rem; font-weight: 400; color: var(--text); text-align: start; background: none; border: 0; cursor: pointer; }
.sx-rc .rq i { position: relative; z-index: 1; flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; color: var(--on); background: var(--ink); box-shadow: 0 0 0 3px var(--card); }
.sx-rc .rq i svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.sx-rc .rq span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sx-rc .rd { flex: none; width: 34px; height: 34px; display: grid; place-items: center; padding: 0; color: var(--muted); background: none; border: 0; border-radius: 50%; cursor: pointer; }
.sx-rc .rd svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; }
.sx-tip { margin: 22px 8px 0; text-align: center; font-size: .78rem; line-height: 1.5; color: var(--muted); }

/* ---------- empty / short / loading states ---------- */
.sx-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 22px 18px 8px; text-align: center; }
.sx-empty h3 { margin: 4px 0 0; font-family: "Tajawal", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; font-weight: 700; font-size: 1.02rem; line-height: 1.35; color: var(--text); overflow-wrap: anywhere; }
.sx-empty p { margin: 0; max-width: 270px; font-family: "Tajawal", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; font-size: .8rem; line-height: 1.5; color: var(--muted); }
.sx-empty .pwa-go { margin-top: 10px; padding: 0 22px; }
/* a subject whose lessons are not written yet : its icon in a dashed ring */
.sx-empty.soon .soon-ic { display: grid; place-items: center; width: 108px; height: 108px; border: 3px dashed var(--c); border-radius: 50%; background: color-mix(in srgb, var(--c) 10%, transparent); animation: sx-pop .6s cubic-bezier(.3, 1.5, .5, 1) backwards; }
.sx-empty.soon .soon-ic svg { width: 52px; height: 52px; overflow: visible; fill: none; stroke: var(--c); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sx-empty.soon h3 { color: var(--c); }
.sx-empty.soon .pwa-go { display: inline-flex; align-items: center; text-decoration: none; background: var(--c); }
.sx-empty svg { animation: sx-sway 4.5s ease-in-out infinite; transform-origin: 50% 80%; }
@keyframes sx-sway { 0%, 100% { rotate: -3deg; } 50% { rotate: 3deg; } }
.sx-load { padding: 34px 0; text-align: center; font-family: var(--f-brush); font-size: 1.35rem; color: var(--muted); }

/* ---------- « nothing found » : the puzzled boy scratching his head (cut-out picture) + ground shadow drawn in CSS ---------- */
.sx-empty .sx-sloth { position: relative; width: min(150px, 44vw); margin: 0 auto 14px; padding-bottom: 8px; }
.sx-empty .sx-sloth .sx-sl { position: relative; z-index: 1; display: block; width: 100%; height: auto; user-select: none; -webkit-user-drag: none; pointer-events: none;
  transform-origin: 50% 100%; animation: sx-breathe 6.5s ease-in-out infinite;
  filter: drop-shadow(0 3px 2px rgba(40, 24, 10, .26)) drop-shadow(0 9px 7px rgba(40, 24, 10, .16)); }
/* ground shadow : soft wide ellipse + darker contact core, centred under the crossed legs */
.sx-empty .sx-sloth .sx-shadow { position: absolute; z-index: 0; left: -3%; right: -3%; bottom: 0; height: 18px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(ellipse at 50% 50%, rgba(40, 24, 10, .46) 0%, rgba(40, 24, 10, .26) 42%, transparent 72%); filter: blur(2.5px);
  animation: sx-shadow 6.5s ease-in-out infinite; }
.sx-empty .sx-sloth .sx-shadow::before { content: ""; position: absolute; left: 20%; right: 20%; top: 28%; bottom: 28%; border-radius: 50%;
  background: radial-gradient(ellipse at 50% 50%, rgba(40, 24, 10, .55) 0%, transparent 72%); }
:root[data-theme="dark"] .sx-empty .sx-sloth .sx-sl { filter: drop-shadow(0 3px 2px rgba(0, 0, 0, .5)) drop-shadow(0 9px 7px rgba(0, 0, 0, .35)); }
:root[data-theme="dark"] .sx-empty .sx-sloth .sx-shadow { background: radial-gradient(ellipse at 50% 50%, rgba(0, 0, 0, .72) 0%, rgba(0, 0, 0, .42) 42%, transparent 72%); }
:root[data-theme="dark"] .sx-empty .sx-sloth .sx-shadow::before { background: radial-gradient(ellipse at 50% 50%, rgba(0, 0, 0, .8) 0%, transparent 72%); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .sx-empty .sx-sloth .sx-sl { filter: drop-shadow(0 3px 2px rgba(0, 0, 0, .5)) drop-shadow(0 9px 7px rgba(0, 0, 0, .35)); }
  :root:not([data-theme="light"]) .sx-empty .sx-sloth .sx-shadow { background: radial-gradient(ellipse at 50% 50%, rgba(0, 0, 0, .72) 0%, rgba(0, 0, 0, .42) 42%, transparent 72%); }
  :root:not([data-theme="light"]) .sx-empty .sx-sloth .sx-shadow::before { background: radial-gradient(ellipse at 50% 50%, rgba(0, 0, 0, .8) 0%, transparent 72%); }
}
@keyframes sx-breathe { 0%, 100% { transform: scale(1, 1); } 50% { transform: scale(1.008, 1.016); } }
@keyframes sx-shadow { 0%, 100% { transform: scale(1, 1); opacity: 1; } 50% { transform: scale(1.03, 1.1); opacity: .92; } }
@media (prefers-reduced-motion: reduce) {
  .sx-empty .sx-sloth .sx-sl, .sx-empty .sx-sloth .sx-shadow { animation: none; }
}
@media (prefers-reduced-motion: reduce) {
  .sr.fresh.lite, .sx-tab.just, #engine.sx-intro .sx, #engine.sx-intro .sx-tab, #engine.sx-intro .sx-bar, #engine.sx-intro .sx-bar .sx-stat .l, #engine.sx-intro .sx-bar .sx-sw, #engine.sx-intro #sx-out, .sx-tab .tn.bump, .sx-dock, .sx-bd .sc, .sx-bd .mg, .sx-bd::after, .sx-sw .st, .sx-stat .mt i, .sx-stat .n.roll, .sx-bar.ping, .sx.typing .sx-ic svg, .sx::after, .sr.fresh, .sr.fresh mark.hit, .sr.fresh .ic, .sx-empty svg { animation: none !important; }
  .sx-tab, .sx-sw .st svg { transition: none; }
}
@media (min-width: 640px) {
  #engine .subject-body { max-width: 560px; margin-inline: auto; }
}


/* ---------- type filter (Cours · Séries · Devoirs) : small stickers under the subject tabs ---------- */
.sx-kinds { display: flex; gap: 5px; margin: 0 -20px; padding: 2px 20px 8px; overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain; }
.sx-kinds::-webkit-scrollbar { display: none; }
.sx-kind { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 29px; padding: 0 4px 0 7px; font: inherit; font-family: var(--f-hand); font-size: .95rem; font-weight: 400; line-height: 1;
  white-space: nowrap; cursor: pointer; color: var(--text); background: transparent; border: 1.5px dashed color-mix(in srgb, var(--ink) 45%, transparent); border-radius: 999px;
  transition: background .25s ease, color .25s ease, border-color .25s ease, scale .2s cubic-bezier(.34, 1.4, .64, 1); -webkit-tap-highlight-color: transparent; }
.sx-kind .ki { display: grid; place-items: center; width: 16px; height: 16px; }
.sx-kind .ki svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.sx-kind .kn { min-width: 17px; padding: 3px 5px 2px; border-radius: 999px; font-size: .78rem; text-align: center; background: color-mix(in srgb, var(--ink) 14%, transparent); }
.sx-kind.zero:not(.on) { opacity: .5; }
.sx-kind.on { color: var(--card); background: var(--ink); border: 1.5px solid var(--ink); }
.sx-kind.on .kn { color: var(--ink); background: var(--card); }
.sx-kind:active { scale: .94; }
.sx-kind:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }

/* the type chip on a result card */
.sr .bc .kd { font-weight: 400; color: var(--on, #fff); background: var(--c); }
.sr.wip .bc .kd { color: var(--text); background: color-mix(in srgb, var(--c) 28%, transparent); }
@media (prefers-reduced-motion: reduce) { .sx-kind { transition: none; } }
