/* IBM Plex Sans Arabic (SIL Open Font License, static/fonts/OFL.txt), served from this server. Each
   file covers one script, so a page loads only what its text uses; text shows at once in the phone's
   own font and switches when the file arrives (font-display: swap). */
@font-face { font-family: "Plex Arabic"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("fonts/ibm-plex-sans-arabic-arabic-400-normal.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E,
                 U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "Plex Arabic"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("fonts/ibm-plex-sans-arabic-arabic-700-normal.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E,
                 U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "Plex Arabic"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("fonts/ibm-plex-sans-arabic-latin-400-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
                 U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Plex Arabic"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("fonts/ibm-plex-sans-arabic-latin-700-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
                 U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

/* Colours: warm sand neutrals, a deep zellige green (#0b6650) for the brand and actions, a vivid cherry
   red (#e3173e) only for recording. */
:root {
  --bg: #f6f3ec;
  --surface: #ffffff;
  --text: #1e1c19;
  --muted: #67625a;
  --line: #e2dccf;
  --accent: #0b6650;
  --accent-strong: #084d3d;
  --accent-soft: #e3efe9;
  --accent-text: #ffffff;
  --rec: #e3173e;
  --rec-strong: #b30d2f;
  --rec-soft: rgb(227 23 62 / .2);
  --error: #b3261e;
  --radius: 16px;
  --shadow: 0 1px 2px rgb(40 30 10 / .06), 0 4px 14px rgb(40 30 10 / .06);
  --font: "Plex Arabic", system-ui, "Segoe UI", "Noto Sans Arabic", Tahoma, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121412;
    --surface: #1c1f1d;
    --text: #ecebe6;
    --muted: #a3a59f;
    --line: #303431;
    --accent: #46b993;
    --accent-strong: #6bd3ae;
    --accent-soft: rgb(70 185 147 / .14);
    --accent-text: #08201a;
    --rec: #ff3b5c;
    --rec-strong: #d61c42;
    --rec-soft: rgb(255 59 92 / .26);
    --error: #f28b82;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 4px 14px rgb(0 0 0 / .25);
  }
}

* { box-sizing: border-box; }
/* `hidden` must win over the display rules below (#capture and .tabs are flex containers). */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}

/* Only the block matching the current locale is shown. */
[data-locale-only] { display: none; }
html[data-locale="ary"] [data-locale-only="ary"],
html[data-locale="ar"] [data-locale-only="ar"],
html[data-locale="fr"] [data-locale-only="fr"],
html[data-locale="en"] [data-locale-only="en"] { display: revert; }

.bar {
  position: sticky; top: 0; z-index: 2;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px;
  padding: 10px 16px;
  background: var(--accent); color: var(--accent-text);
  box-shadow: 0 2px 10px rgb(0 0 0 / .12);
}
.brand { font-weight: 700; font-size: 1.15rem; white-space: nowrap; letter-spacing: .01em; }
/* The app's name with the main site under it: Sawt Darija is a DarijaLM project. */
.brand-block { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; }
.home-link { color: inherit; font-size: .72rem; opacity: .85; letter-spacing: .02em; white-space: nowrap;
             text-underline-offset: 2px; text-decoration-color: color-mix(in srgb, var(--accent-text) 45%, transparent); }
.home-link:hover, .home-link:focus-visible { opacity: 1; }
.tips-link { color: inherit; font-size: .9rem; margin-inline-start: auto; text-underline-offset: 3px; white-space: nowrap; }
/* The leaderboard, next to Tips (app.js startBoard); filled while its screen is open. */
.board-link { display: inline-flex; align-items: center; gap: 5px; margin-inline-start: auto; padding: 3px 10px;
              border: 1px solid color-mix(in srgb, var(--accent-text) 50%, transparent); border-radius: 999px;
              background: transparent; color: inherit; font: inherit; font-size: .88rem; cursor: pointer; white-space: nowrap; }
.board-link svg { width: 17px; height: 17px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.board-link[aria-current="page"] { background: var(--accent-text); color: var(--accent); }
.board-link:not([hidden]) + .tips-link { margin-inline-start: 0; }
.langs { display: flex; gap: 4px; }
.langs button {
  border: 1px solid color-mix(in srgb, var(--accent-text) 50%, transparent);
  background: transparent; color: inherit;
  border-radius: 999px; padding: 3px 9px; font: inherit; font-size: .85rem; cursor: pointer;
}
.langs button[aria-pressed="true"] { background: var(--accent-text); color: var(--accent); }

main { max-width: 560px; margin: 0 auto; padding: 16px 16px 48px; }
h1 { font-size: 1.5rem; margin: 8px 0; }
.lead { font-size: 1.1rem; color: var(--muted); }
.notice { background: var(--accent-soft); border-inline-start: 4px solid var(--accent); padding: 10px 14px; border-radius: 10px; }

.consent { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 16px; margin: 16px 0; }
.consent summary { cursor: pointer; font-weight: 600; padding: 8px 0; }
.consent-body { max-height: 45vh; overflow-y: auto; font-size: .95rem; }
.consent .version { color: var(--muted); font-size: .8rem; direction: ltr; text-align: end; }

form label, .inline { display: block; margin: 14px 0; }
form label > span:first-child, .inline > span { display: block; font-weight: 600; margin-bottom: 4px; }
select, input:not([type="checkbox"]) {
  width: 100%; font: inherit; color: var(--text);
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
}
select:focus-visible, input:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px;
}
label.check { display: flex; gap: 10px; align-items: flex-start; }
label.check input { width: 22px; height: 22px; margin-top: 3px; flex: none; accent-color: var(--accent); }
label.check span { font-weight: 400; }

button { font: inherit; cursor: pointer; }
button.primary, #rerecord {
  min-height: 50px; padding: 10px 20px; border-radius: 14px;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-text); font-weight: 700;
  transition: background .15s ease, transform .08s ease;
}
button.primary:active, #rerecord:active { transform: scale(.98); }
@media (hover: hover) { button.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); } }
#rerecord { background: transparent; color: var(--accent); }
#rerecord span, #rerecord small { white-space: nowrap; }  /* on a narrow screen: "Record again" / "(3 left)", never split inside */
button:disabled { opacity: .45; cursor: not-allowed; }
form .primary { width: 100%; margin-top: 8px; }
button.link { display: block; margin: 20px auto 0; background: none; border: 0; color: var(--muted); text-decoration: underline; }

.error { color: var(--error); min-height: 1.5em; }
.label { color: var(--muted); font-size: .9rem; margin: 18px 0 4px; }
#prompt {
  margin: 0; padding: 18px 20px;
  background: var(--surface); border: 1px solid var(--line); border-inline-start: 5px solid var(--accent);
  border-radius: var(--radius); box-shadow: var(--shadow);
  font-size: 1.6rem; line-height: 1.6; font-weight: 700;
  min-height: 3.5em;
}
.directive { font-weight: 600; }

/* The record button: a red disc with a microphone and one word, inside a ring in shades of red. Idle,
   the ring breathes slowly; recording, it grows with the voice (--level, 0-1, set by app.js) and a
   ripple runs outward. How to use the button is written underneath (#ptt-label). */
#capture { display: flex; flex-direction: column; align-items: center; gap: 12px; margin: 22px 0 6px; }
/* The record button and the review (player + Send) stacked in one grid cell: the hidden one keeps its room
   (visibility, not display), so the card is as tall in both states and what is below it never jumps. */
.stage { display: grid; }
.stage > * { grid-area: 1 / 1; min-width: 0; }
.stage > #capture[hidden] { display: flex !important; visibility: hidden; }
.stage > #review[hidden] { display: block !important; visibility: hidden; }
.stage > #review { align-self: center; }
.ptt-ring { --level: 0; position: relative; display: grid; place-items: center; padding: 16px; border-radius: 50%; }
.ptt-ring::before, .ptt-ring::after { content: ""; position: absolute; border-radius: 50%; pointer-events: none; }
.ptt-ring::before { inset: 0; background: var(--rec-soft); animation: ptt-breathe 2.8s ease-in-out infinite; }
.ptt-ring::after { inset: 6px; border: 3px solid color-mix(in srgb, var(--rec) 60%, transparent); opacity: 0; }
.ptt-ring.is-rec::before { animation: none; background: color-mix(in srgb, var(--rec) 34%, transparent);
                           transform: scale(calc(1 + .12 * var(--level))); transition: transform 90ms linear; }
.ptt-ring.is-rec::after { animation: ptt-ripple 1.5s ease-out infinite; }
@keyframes ptt-breathe { 50% { transform: scale(1.05); opacity: .65; } }
@keyframes ptt-ripple { from { transform: scale(.94); opacity: .9; } to { transform: scale(1.22); opacity: 0; } }
.ptt {
  position: relative; z-index: 1;
  width: min(54vw, 196px); aspect-ratio: 1; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  border: 0; padding: 18px; text-align: center; color: #fff; font-weight: 700;
  background: radial-gradient(circle at 34% 28%, color-mix(in srgb, var(--rec) 78%, #fff), var(--rec) 55%, var(--rec-strong));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--rec) 22%, transparent), 0 12px 32px color-mix(in srgb, var(--rec) 55%, transparent),
              inset 0 -4px 10px rgb(0 0 0 / .1);
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  transition: transform .1s ease, box-shadow .15s ease;
}
.ptt:active { transform: scale(.97); }
.ptt .mic { width: 46px; height: 46px; }
.ptt-short { font-size: 1.15rem; line-height: 1.2; }
.ptt[aria-pressed="true"] { background: var(--rec-strong); transform: scale(.97);
                            box-shadow: 0 6px 20px color-mix(in srgb, var(--rec) 45%, transparent); }
.ptt[aria-pressed="true"] .mic, .ptt[aria-pressed="true"] .ptt-short { display: none; }
.ptt-hint { margin: 0; max-width: 32ch; min-height: 3em; text-align: center; color: var(--muted); font-size: .92rem; line-height: 1.5; }
/* Live input level while recording (app.js meter). Idle bars are hidden. */
.waves { display: none; align-items: center; justify-content: center; gap: 3px; height: 44px; }
.ptt[aria-pressed="true"] .waves { display: flex; }
.waves i { display: block; width: 5px; height: 100%; border-radius: 3px; background: currentColor;
           transform: scaleY(.1); transition: transform 60ms linear; }
#timer { font-variant-numeric: tabular-nums; min-height: 1.4em; }
@media (prefers-reduced-motion: reduce) {
  .ptt, .waves i, .ptt-ring.is-rec::before { transition: none; }
  .ptt-ring::before, .ptt-ring.is-rec::after { animation: none; }
}

.tabs { display: flex; gap: 4px; margin: 6px 0 14px; padding: 4px; border-radius: 14px;
        background: color-mix(in srgb, var(--line) 55%, transparent); }
.tabs button {
  flex: 1; min-width: 0; padding: 7px 6px; border: 0; border-radius: 11px;
  display: flex; flex-direction: column; align-items: center; gap: 1px; line-height: 1.25;
  background: none; color: color-mix(in srgb, var(--text) 80%, transparent); font-weight: 700;
  transition: background .15s ease, color .15s ease;
}
.tabs button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tabs .tab-sub { font-size: 11px; font-weight: 400; color: var(--muted); }
.tabs button[aria-selected="true"] .tab-sub { color: inherit; opacity: .8; }
/* Beta goal rings in My stats (after Kokonut UI "Apple Activity Card", MIT): they fill when shown. */
.goal { display: flex; align-items: center; gap: 16px; padding: 14px 16px; margin-bottom: 14px; border-radius: 16px;
        background: var(--surface); box-shadow: var(--shadow); }
.goal-rings { width: 96px; height: 96px; flex: none; transform: rotate(-90deg); }
.goal-track { fill: none; stroke: var(--line); stroke-width: 11; }
.goal-arc { fill: none; stroke-width: 11; stroke-linecap: round; transition: stroke-dashoffset 1.1s cubic-bezier(.2, .8, .2, 1); }
.goal-arc.rec, .goal-dot.rec { stroke: var(--rec); background: var(--rec); }
.goal-arc.tr, .goal-dot.tr { stroke: var(--accent); background: var(--accent); }
.goal-text { display: grid; gap: 4px; }
.goal-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-inline-end: 6px; }
.goal-done { color: var(--accent); font-weight: 700; }
@media (prefers-reduced-motion: reduce) { .goal-arc { transition: none; } }
/* One-time hint after a few recordings: transcribing exists (Transcribe tab). Not .hint: that is the small helper text.
   Pinned to the bottom of the screen so it is seen whole without moving the sentence or the record button; the
   "thank you" overlay (.ack, z-index 5) stays above it. body.hint-open leaves room to scroll the page above it. */
.hint-box { position: fixed; z-index: 4; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px));
            max-width: 560px; margin: 0 auto; padding: 14px 16px; border-radius: 16px;
            background: linear-gradient(var(--accent-soft), var(--accent-soft)), var(--surface);
            border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); box-shadow: 0 10px 30px rgb(0 0 0 / .25);
            animation: hint-up .35s ease-out; }
@keyframes hint-up { from { transform: translateY(24px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .hint-box { animation: none; } }
body.hint-open main { padding-bottom: 170px; }
.hint-box p { margin: 0 0 10px; }
.hint-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.hint-go { border: 0; border-radius: 10px; padding: 8px 14px; background: var(--accent); color: var(--accent-text); font: inherit; font-weight: 700; }
.hint-close { border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; background: var(--surface); color: var(--text); font: inherit; }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--accent); box-shadow: var(--shadow); }
#clip { width: 100%; margin: 8px 0; }
#transcript {
  width: 100%; font: inherit; font-size: 1.2rem; color: var(--text); background: var(--surface);
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; resize: vertical; text-align: start;
}
/* پ ڭ ڤ inside the Transcribe box, in its bottom corner away from the resize handle; the box keeps room
   at the bottom so the text never runs under them. */
.box-with-letters { position: relative; }
.box-with-letters #transcript { display: block; padding-bottom: 56px; }
.letters { position: absolute; bottom: 9px; inset-inline-start: 9px; display: flex; gap: 6px; }
.letters button {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-width: 48px; min-height: 40px; padding: 0 8px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); font: inherit;
}
/* Arabic letters with dots above and below need a full line, or the dots stick out of the button. */
.letters .ar { font-size: 1.35rem; line-height: 1.6; }
.letters .lat { font-size: .8rem; line-height: 1; color: var(--muted); font-weight: 600; }
.letters button:active { border-color: var(--accent); background: var(--accent-soft); }
@media (hover: hover) { .letters button:hover { border-color: var(--accent); } }
.primary.wide { width: 100%; margin-top: 10px; }
.skips { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.skips button {
  min-height: 46px; padding: 8px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font-weight: 600;
}
@media (hover: hover) { .skips button:hover { border-color: var(--accent); color: var(--accent); } }

/* Next-item transition (app.js swapIn): the task card turns away, then the next one turns in. Measured on a
   Galaxy A04 (Helio P35), each choice removes a stall of 50-116 ms:
   - the card is its own layer from the start (will-change), and a 2000px perspective with a slight lift
     (scale .9) keeps its near edge from growing, so the phone does not redraw it at a larger size mid-turn;
   - it turns WITHOUT fading: a 3D turn and a fade at once make the GPU draw the card off-screen first;
     edge-on at 90 degrees it is invisible anyway;
   - behind the "thank you" circle it lies flat at 1% opacity (.parked, invisible), so the next item is drawn
     while the circle stands still rather than in the first frame of the turn back. */
.swappable {
  transform: none; transform-origin: center; will-change: transform, opacity;
  transition: transform .26s ease, opacity .26s ease; backface-visibility: hidden;
}
.swappable.flip-out { transform: perspective(2000px) rotateY(90deg) scale(.9); pointer-events: none; transition: transform .26s ease; }
.swappable.parked { opacity: .01; pointer-events: none; transition: height .22s ease; }  /* app.js glides it to the next item's height */
.swappable.flip-in-start { transform: perspective(2000px) rotateY(-90deg) scale(.9); transition: none; }
button.danger { min-height: 50px; padding: 10px 20px; border-radius: 14px; border: 1px solid var(--error);
                background: var(--error); color: #fff; font-weight: 700; }
button.wide { width: 100%; margin-top: 10px; }
.delete-link { text-align: center; margin-top: 28px; font-size: .9rem; }
.delete-link a { color: var(--muted); }

/* Another phone or browser (screen-link) and the typed delete phrase (screen-delete). */
#screen-link h2 { font-size: 1.1rem; margin: 24px 0 4px; }
#link-get { min-height: 48px; padding: 10px 20px; border-radius: 12px; border: 1px solid var(--accent);
            background: transparent; color: var(--accent); font-weight: 600; }
.code { font: 700 2rem/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .12em;
        text-align: center; margin: 16px 0 4px; user-select: all; -webkit-user-select: all; }
input.code-input { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 1.3rem;
                   letter-spacing: .1em; text-align: center; text-transform: uppercase; }
label.stack { display: block; margin: 16px 0; }
label.stack > span { display: block; font-weight: 600; margin-bottom: 6px; }
.phrase { display: inline-block; font: 600 1.05rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
          background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px;
          margin-bottom: 8px; }

/* My stats (screen-stats). Recordings take the accent colour, transcriptions a second hue; each
   column is a button so a tap shows that day's numbers in words below the chart. */
:root { --tr: #c9822b; }
@media (prefers-color-scheme: dark) { :root { --tr: #e0a458; } }
.stat-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 1.6rem; font-variant-numeric: tabular-nums; text-align: start; }
.stat span { color: var(--muted); font-size: .85rem; }
.legend-row { display: flex; gap: 16px; font-size: .85rem; color: var(--muted); margin: 0 0 6px; }
.legend-row > span { display: inline-flex; align-items: center; gap: 6px; }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.key.rec { background: var(--accent); }
.key.tr { background: var(--tr); }
.days { display: grid; grid-template-columns: repeat(14, 1fr); gap: 4px; align-items: end; height: 120px;
        border-bottom: 1px solid var(--line); }
.days button { height: 100%; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px;
               padding: 0; border: 0; background: none; border-radius: 4px 4px 0 0; cursor: pointer; }
.days button:hover, .days button[aria-pressed="true"] { background: color-mix(in srgb, var(--line) 50%, transparent); }
.days i { display: block; width: 100%; border-radius: 3px 3px 0 0; }
.days i.rec { background: var(--accent); }
.days i.tr { background: var(--tr); border-radius: 0; }
.days i.tr:first-child { border-radius: 3px 3px 0 0; }
.hint { color: var(--muted); font-size: .88rem; min-height: 1.4em; margin: 6px 0 0; }
.status-list { list-style: none; padding: 0; margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.status-list li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 14px; }
.status-list li + li { border-top: 1px solid var(--line); }
.status-list b { font-variant-numeric: tabular-nums; }

/* Circular acknowledgement shown on its own between two items (app.js swapIn). */
.ack {
  position: fixed; inset: 0; z-index: 5; display: flex; align-items: center; justify-content: center;
  pointer-events: none; opacity: 0; transition: opacity .26s ease;
}
.ack.is-shown { opacity: 1; }
.ack-circle {
  width: min(64vw, 230px); aspect-ratio: 1; border-radius: 50%; padding: 22px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background: var(--accent); color: var(--accent-text); text-align: center;
  font-weight: 600; font-size: 1rem; line-height: 1.35; box-shadow: 0 10px 30px rgb(0 0 0 / .25);
  transform: perspective(800px) rotateY(-90deg); transition: transform .3s ease-out;
}
.ack.is-shown .ack-circle { transform: perspective(800px) rotateY(0deg); }
.ack-check { font-size: 2.6rem; line-height: 1; }
.clip-no { margin: 6px 0 0; font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) {
  .swappable, .swappable.flip-out, .swappable.flip-in-start { transform: none; }
  .swappable, .swappable.flip-out { transition: opacity .26s ease; }
  .swappable.flip-out, .swappable.flip-in-start { opacity: 0; }   /* no turning: a plain fade out and in */
  .swappable.parked { transition: none; }
  .ack-circle { transition: none; transform: none; }
}

.tips { padding-inline-start: 1.2em; }
.tips li { margin: 0 0 14px; }
/* Tips: how contributions are checked (#checks). */
#qa { scroll-margin-top: 84px; }   /* below the sticky top bar when #checks jumps here */
.qa-steps { padding-inline-start: 1.4em; display: grid; gap: 10px; margin: 8px 0 12px; }
.qa-outro { font-weight: 600; }
/* My stats: what counts, and the validated row first. */
/* My stats: who you are to others (app.js renderIdentity). */
:root { --gold-ink: #8a6410; --founding-wash: linear-gradient(135deg, #fbf1d6 0%, #fffaf0 55%, var(--surface) 100%);
        --founding-line: rgb(201 151 28 / .45); }
@media (prefers-color-scheme: dark) {
  :root { --gold-ink: #e8c262; --founding-wash: linear-gradient(135deg, rgb(201 151 28 / .2) 0%, rgb(201 151 28 / .06) 55%, var(--surface) 100%);
          --founding-line: rgb(232 194 98 / .4); }
}
.identity { display: flex; align-items: center; gap: 12px; margin: 0 0 12px; padding: 12px 14px; border-radius: 16px;
            background: var(--surface); border: 1px solid var(--line); }
.identity-text { display: grid; gap: 1px; min-width: 0; }
.identity-label { font-size: .8rem; color: var(--muted); font-weight: 700; }
.identity-name { font-size: 1.15rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.identity-note { font-size: .82rem; color: var(--muted); }
/* Names typed in any script (PC262, أمل): their letters keep their own order, but they line up with the page. */
.identity-name, .board .who .name { unicode-bidi: isolate; text-align: start; }
.avatar.small { width: 26px; height: 26px; font-size: .8rem; border-width: 1px; }
.avatar.small.anon svg { width: 64%; height: 64%; }
/* The founding card: a warm wash and a gold hairline; a seal and the title lead; the rest is quiet. */
.identity.is-founding { display: block; padding: 16px 18px 12px; background: var(--founding-wash); border-color: var(--founding-line); }
.founding-head { display: flex; align-items: center; gap: 14px; }
.seal { flex: none; width: 50px; height: 50px; display: grid; place-items: center; border-radius: 50%; color: #fff; font-size: 1.45rem;
        line-height: 1; background: radial-gradient(circle at 35% 30%, #f4d684 0%, #d3a12b 55%, #a7790f 100%);
        box-shadow: 0 0 0 3px var(--surface), 0 0 0 4px var(--founding-line); }
.founding-words { display: grid; gap: 2px; min-width: 0; }
.founding-title { font-size: 1.35rem; font-weight: 800; line-height: 1.2; color: var(--gold-ink); }
.founding-why { font-size: .86rem; color: var(--muted); }
.founding-rule { display: block; height: 1px; margin: 14px 0 10px;
                 background: linear-gradient(to right, transparent, var(--founding-line) 20%, var(--founding-line) 80%, transparent); }
.founding-foot { display: flex; align-items: center; gap: 8px; min-width: 0; }
.founding-foot .identity-label { font-weight: 400; }
.founding-foot .identity-name { font-size: .92rem; font-weight: 700; }

.what-counts { margin: -4px 0 14px; color: var(--muted); font-size: .95rem; }
.what-counts a { color: var(--accent); white-space: nowrap; }
.status-list li.is-validated b { color: var(--accent); }
/* Welcome panel (after the beta): the pinned .hint-box, with the ranks. */
.welcome-title { font-weight: 700; font-size: 1.05rem; }
.welcome-ranks { margin: 0 0 8px; padding: 0; list-style: none; display: grid; gap: 2px; font-weight: 600; }
.welcome .welcome-link { margin: 0 0 10px; font-size: .9rem; }
.welcome .welcome-link a { color: var(--accent); }
#help-back { width: 100%; margin-top: 8px; }

#review audio { width: 100%; margin: 4px 0 12px; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }
.status { text-align: center; min-height: 1.6em; color: var(--muted); }
.status.is-error { color: var(--error); }
.count { text-align: center; color: var(--muted); font-size: .9rem; }
.env-row { display: flex; align-items: center; gap: 10px; margin-top: 18px; }
.env-row > span { margin: 0; flex: none; font-weight: 400; color: var(--muted); font-size: .9rem; }
.env-row select { flex: 1; padding: 6px 10px; }

/* Small phones (iPhone SE/mini, or any phone with Safari's toolbars showing): the sentence, the
   instruction and the record button fit on one screen without scrolling. */
@media (max-width: 480px), (max-height: 740px) {
  .bar { padding: 6px 12px; gap: 4px 8px; }
  .brand { font-size: 1rem; }
  .tips-link { font-size: .82rem; }
  .langs { gap: 3px; }
  .langs button { padding: 2px 7px; font-size: .78rem; }
  main { padding-top: 8px; }
  .tabs { margin-bottom: 6px; }
  .tabs button { padding: 7px 6px; }
  /* The leaderboard's button: the trophy alone on a phone (its name stays its label). */
  .board-link { padding: 3px 7px; }
  .board-link span { display: none; }
  .label { margin: 8px 0 4px; }
  #prompt { padding: 10px 14px; font-size: clamp(1.25rem, 5.4vw, 1.6rem); line-height: 1.5; min-height: 0; }
  .directive { font-size: .92rem; line-height: 1.45; margin: 8px 0; }
  #capture { margin: 10px 0 4px; }
  .ptt { width: min(46vw, 176px, 24vh); width: min(46vw, 176px, 24svh); padding: 12px; gap: 4px; font-size: .95rem; }
  .ptt-ring { padding: 12px; }
  .ptt .mic { width: 38px; height: 38px; }
  .ptt-hint { min-height: 2.6em; font-size: .86rem; }
  #capture { gap: 6px; }
  .waves { height: 32px; }
  #review audio { margin-bottom: 8px; }
  button.link { margin-top: 10px; }
}

#invite-row .hint { display: block; }

/* Leaderboards (Phase 5, sawt/community.py; app.js renderBoard), on a screen of their own opened from the
   trophy in the top bar: which board, what it counts, your place, then one list of places 1-10, the first
   three ringed gold, silver and bronze, yours tinted. Plain boxes: no shadows or 3D, light on low-end phones. */
:root { --gold: #c9971c; --silver: #8d97a3; --bronze: #b06f3a; }
.community { margin-top: 4px; }
.board-tabs { display: flex; gap: 6px; margin: 4px 0 6px; }
.board-tabs button { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 6px;
                     border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text);
                     font-weight: 600; font-size: .9rem; }
.board-tabs svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.board-tabs button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.board-what { margin: 2px 2px 10px; font-size: .88rem; line-height: 1.45; color: var(--muted); }
#board-zone, #board-inst { padding: 6px 10px; margin-bottom: 10px; }
.avatar { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: 50%; font-weight: 800;
          background: var(--accent-soft); color: var(--accent); border: 2px solid var(--line); }
.avatar.big { width: 52px; height: 52px; font-size: 1.3rem; }  /* My stats' identity card */
.avatar.anon svg { width: 60%; height: 60%; fill: currentColor; opacity: .75; }

/* Your place: "Your place: #3 of 17" with your score across, then what moves you up. */
.board-me { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 12px; margin: 0 0 12px;
            padding: 12px 16px; border: 1px solid var(--accent); border-radius: 14px; background: var(--accent-soft); }
.board-me .me-place { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 8px; min-width: 0; }
.board-me .me-label { flex-basis: 100%; font-size: .8rem; font-weight: 700; color: var(--muted); }
.board-me .me-rank { font-size: 2rem; font-weight: 800; line-height: 1.1; color: var(--accent); font-variant-numeric: tabular-nums; }
.board-me .me-of { font-weight: 700; color: var(--muted); }
.board-me .me-score { display: grid; justify-items: end; text-align: end; line-height: 1.15; }
.board-me .me-score .n { font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.board-me .me-score .u { font-size: .78rem; color: var(--muted); }
.board-me .me-next { grid-column: 1 / -1; margin: 8px 0 0; padding-top: 8px; font-size: .9rem; line-height: 1.45;
                     border-top: 1px solid color-mix(in srgb, var(--accent) 25%, transparent); }
.board-me .me-next:empty { display: none; }
.board-me .me-next:only-child { margin: 0; padding: 0; border: 0; }  /* not on this board yet: the message alone */
.board-me.is-first { border-color: var(--gold); background: color-mix(in srgb, var(--gold) 12%, var(--surface)); }
.board-me.is-first .me-rank { color: var(--gold-ink); }

/* The list */
.board { list-style: none; padding: 0; margin: 0; background: var(--surface); border: 1px solid var(--line);
         border-radius: 14px; overflow: hidden; }
.board li { display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 8px 12px; }
.board li + li { border-top: 1px solid var(--line); }
.board .rank { flex: none; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%;
               font-weight: 800; font-size: .9rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.board .top .rank { color: var(--text); box-shadow: inset 0 0 0 2px var(--line); }
.board .r1 .rank { color: var(--gold-ink); background: color-mix(in srgb, var(--gold) 20%, transparent); box-shadow: inset 0 0 0 2px var(--gold); }
.board .r2 .rank { background: color-mix(in srgb, var(--silver) 20%, transparent); box-shadow: inset 0 0 0 2px var(--silver); }
.board .r3 .rank { background: color-mix(in srgb, var(--bronze) 20%, transparent); box-shadow: inset 0 0 0 2px var(--bronze); }
.board .r1 .avatar { border-color: var(--gold); }
.board .r2 .avatar { border-color: var(--silver); }
.board .r3 .avatar { border-color: var(--bronze); }
.board .who { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; }
.board .who .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.board .value { flex: none; display: grid; justify-items: end; text-align: end; line-height: 1.15; }
.board .value .n { font-weight: 800; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.board .value .u { font-size: .72rem; color: var(--muted); }
.board li.me { background: var(--accent-soft); box-shadow: inset 4px 0 0 var(--accent); }
html[dir="rtl"] .board li.me { box-shadow: inset -4px 0 0 var(--accent); }
.you { flex: none; font-size: .72rem; font-weight: 800; color: var(--accent-text); background: var(--accent); border-radius: 999px; padding: 1px 8px; }
.board li.gap { justify-content: center; min-height: 30px; padding: 2px; color: var(--muted); letter-spacing: .2em; }
.board li.empty { flex-direction: column; gap: 6px; padding: 22px 14px; text-align: center; color: var(--muted); }
.board .empty-mark { font-size: 1.6rem; color: var(--gold); }

/* Browsers without color-mix() (Android WebView/Chrome before 111, iOS before 16.2, Samsung Internet before 22) drop
   any declaration that uses it. Plain colours for them here; browsers that support color-mix() skip this block. */
@supports not (color: color-mix(in srgb, red 50%, blue)) {
  .langs button { border: 1px solid currentColor; }
  select:focus-visible, input:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid var(--accent); }
  .ptt { background: var(--rec); box-shadow: 0 12px 32px rgb(0 0 0 / .22); }   /* the record button keeps its red */
  .ptt[aria-pressed="true"] { background: var(--rec-strong); box-shadow: 0 6px 20px rgb(0 0 0 / .2); }
  .ptt-ring::after { border: 3px solid var(--rec); }
  .ptt-ring.is-rec::before { background: var(--rec-soft); }
  .tabs { background: var(--line); }
  .tabs button { color: var(--text); }
  .hint-box { border: 1px solid var(--line); }
  .days button:hover, .days button[aria-pressed="true"] { background: var(--line); }
  .board-link { border: 1px solid currentColor; }
  .board-me .me-next { border-top: 1px solid var(--line); }
  .board-me.is-first { background: var(--surface); }
  .board .r1 .rank, .board .r2 .rank, .board .r3 .rank { background: var(--surface); }
}
