/* Mirror Paint: a kaleidoscope to draw in, in the Favabeans look (see ../APP_DESIGN.md).
   Light by default, dark when the system asks (or the shared prefs force it). Accent: magenta pink.
   No dark green or dark teal anywhere. */
:root {
  --canvas: #F7F6F2;
  --surface: #FFFFFF;
  --surface-2: #EFEDE6;
  --surface-3: #E6E3DA;
  --ink: #18181B;
  --ink-2: #46464E;
  --line: rgb(24 24 27 / .09);
  --line-2: rgb(24 24 27 / .18);
  --shadow-1: 0 1px 2px rgb(0 0 0 / .04), 0 16px 36px -26px rgb(0 0 0 / .25);
  --shadow-2: 0 1px 2px rgb(0 0 0 / .05), 0 26px 50px -28px rgb(0 0 0 / .32);
  --ease: cubic-bezier(.22, 1, .36, 1);
  --r-card: 32px;
  --r-md: 20px;
  --r-sm: 14px;
  --gutter: clamp(16px, 4vw, 40px);
  --font: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", "IBM Plex Sans Arabic", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Instrument Serif", Georgia, serif;

  /* This app's accent: magenta pink #FF8CC0 → #B4307A */
  --accent: #B4307A;
  --accent-ink: #FFFFFF;
  --accent-soft: #FCE7F3;
  --accent-text: #9C2667;
  --focus: #B4307A;
  --stage-glow: rgb(110 50 170 / .45);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    --canvas: #121214;
    --surface: #1D1D21;
    --surface-2: #26262B;
    --surface-3: #303036;
    --ink: #F2F1EC;
    --ink-2: #C2C1BC;
    --line: rgb(255 255 255 / .10);
    --line-2: rgb(255 255 255 / .22);
    --shadow-1: 0 1px 0 rgb(255 255 255 / .04) inset, 0 16px 36px -22px rgb(0 0 0 / .7);
    --shadow-2: 0 1px 0 rgb(255 255 255 / .05) inset, 0 28px 56px -22px rgb(0 0 0 / .8);
    --accent: #F59AC8;
    --accent-ink: #2A0F1E;
    --accent-soft: #33202B;
    --accent-text: #F8BBD9;
    --focus: #F8B4D6;
    --stage-glow: rgb(150 90 255 / .35);
    color-scheme: dark;
  }
}
:root:where([data-theme="dark"]) {
  --canvas: #121214;
  --surface: #1D1D21;
  --surface-2: #26262B;
  --surface-3: #303036;
  --ink: #F2F1EC;
  --ink-2: #C2C1BC;
  --line: rgb(255 255 255 / .10);
  --line-2: rgb(255 255 255 / .22);
  --shadow-1: 0 1px 0 rgb(255 255 255 / .04) inset, 0 16px 36px -22px rgb(0 0 0 / .7);
  --shadow-2: 0 1px 0 rgb(255 255 255 / .05) inset, 0 28px 56px -22px rgb(0 0 0 / .8);
  --accent: #F59AC8;
  --accent-ink: #2A0F1E;
  --accent-soft: #33202B;
  --accent-text: #F8BBD9;
  --focus: #F8B4D6;
  --stage-glow: rgb(150 90 255 / .35);
  color-scheme: dark;
}
:root[lang="ar"] { --font: "Atkinson Hyperlegible Next", "IBM Plex Sans Arabic", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; }
:root[data-text="large"] { font-size: 120%; }
:root[data-contrast="high"] { --ink-2: var(--ink); --line: var(--line-2); }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 16px; }
body {
  margin: 0; color: var(--ink);
  font: 400 1.0625rem/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
  background:
    radial-gradient(1100px 520px at 88% -12%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%),
    radial-gradient(900px 480px at -10% 110%, color-mix(in srgb, #8a6cff 10%, transparent), transparent 70%),
    var(--canvas);
  background-attachment: fixed;
}
:root[lang="ar"] body { line-height: 1.7; }
:root[lang="ar"] body *:not(svg):not(svg *) { letter-spacing: normal !important; }
html.fb-wait body > * { visibility: hidden; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
a { color: inherit; text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Drawn icons: 24×24, round strokes, a soft fill */
.ico { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; overflow: visible; }
.ico .f { fill: color-mix(in srgb, var(--c, var(--accent)) 50%, transparent); }

/* ---------- Header ---------- */
.top { position: relative; z-index: 20; }
.top-in { max-width: 1180px; margin: 0 auto; padding-inline: var(--gutter); min-height: 88px; display: flex; flex-wrap: wrap; align-items: center; gap: 0 12px; }
.brand { display: flex; align-items: center; gap: 14px; margin-inline-end: auto; min-width: 0; }
.brand img { width: 52px; height: 52px; border-radius: 15px; transform: rotate(-6deg); box-shadow: 0 12px 24px -12px rgb(0 0 0 / .45); flex: none; }
.brand h1 { margin: 0; display: flex; align-items: center; font-family: var(--serif); font-style: italic; font-weight: 400; font-size: clamp(1.9rem, 4vw, 2.75rem); letter-spacing: -0.01em; line-height: 1; white-space: nowrap; }
body .top .fbk-beta { margin-inline-start: 8px; padding: .32em .62em; border: 0; border-radius: 999px; box-shadow: none; font: 700 max(.66rem, 11px)/1.1 var(--font); letter-spacing: .06em; color: var(--accent-text); background: var(--accent-soft); }
.fb-lang { display: flex; align-items: center; font-size: .875rem; color: var(--line-2); }
.fb-lang button { min-height: 44px; display: inline-flex; align-items: center; padding-inline: 10px; border: 0; border-radius: 12px; background: none; color: var(--ink-2); font: 700 .875rem/1 var(--font); cursor: pointer; }
.fb-lang button[lang="ar"] { font-family: 'IBM Plex Sans Arabic', system-ui, sans-serif; font-size: .95rem; }
.fb-lang button:hover, .fb-lang button[aria-pressed="true"] { color: var(--ink); }
.fb-lang button[aria-pressed="true"] { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 6px; }
.fb-lang button:focus-visible { outline-offset: -2px; }
.home-link, .fava-share-btn, .sound-btn { min-height: 44px; min-width: 44px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-weight: 700; text-decoration: none; cursor: pointer; }
.home-link { padding-inline: 18px; background: var(--ink); color: var(--canvas); border: 0; font-size: .9375rem; white-space: nowrap; }
.home-link:hover { filter: brightness(1.25); }
.fava-share-btn, .sound-btn { padding: 0; background: var(--surface); border: 1.5px solid var(--line-2); color: var(--ink); }
.fava-share-btn svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.sound-btn .snd-off { display: none; }
.sound-btn[data-on="false"] { color: var(--ink-2); }
.sound-btn[data-on="false"] .snd-on { display: none; }
.sound-btn[data-on="false"] .snd-off { display: inline; }
.sound-btn[data-on="false"] .ico .f { fill: none; }

/* ---------- Page ---------- */
main { max-width: 1180px; margin: 0 auto; padding: 4px var(--gutter) 8px; display: grid; gap: 16px; }
.lead { margin: 0; color: var(--ink-2); font-size: clamp(1rem, 1.4vw, 1.125rem); }
.studio { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr) 356px; align-items: start; }

/* The canvas */
.stage {
  position: relative; height: clamp(420px, calc(100vh - 210px), 680px);
  border-radius: var(--r-card); overflow: hidden; background: #1C1440;
  box-shadow: 0 30px 60px -34px var(--stage-glow), 0 0 0 1px rgb(255 255 255 / .06) inset;
  isolation: isolate;
}
.stage[data-bg="day"] { background: #FFF6EE; box-shadow: var(--shadow-2), inset 0 0 0 1px var(--line); }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.hint {
  position: absolute; inset-inline: 0; bottom: 18px; margin: 0 auto; width: max-content; max-width: calc(100% - 32px);
  padding: 10px 18px; border-radius: 999px; pointer-events: none; text-align: center;
  background: rgb(20 12 40 / .62); color: #fff; font-weight: 700; font-size: .9375rem; line-height: 1.35;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  opacity: 0; transform: translateY(6px); transition: opacity .5s var(--ease), transform .5s var(--ease);
}
.hint.on { opacity: 1; transform: none; }
.stage[data-bg="day"] .hint { background: rgb(40 20 60 / .78); }
.stage-acts { position: absolute; top: 12px; inset-inline-end: 12px; display: flex; gap: 8px; }
.round-btn {
  width: 46px; height: 46px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; cursor: pointer;
  color: #fff; background: rgb(255 255 255 / .14); box-shadow: inset 0 0 0 1px rgb(255 255 255 / .22);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); transition: background .2s, transform .15s, opacity .2s;
}
.round-btn .ico { --c: #fff; }
.round-btn:hover { background: rgb(255 255 255 / .24); }
.round-btn:active { transform: scale(.94); }
.round-btn:disabled { opacity: .4; cursor: default; }
.stage[data-bg="day"] .round-btn { color: #2A1838; background: rgb(255 255 255 / .75); box-shadow: inset 0 0 0 1px rgb(40 20 60 / .16), 0 6px 16px -10px rgb(40 20 60 / .4); }
.stage[data-bg="day"] .round-btn .ico { --c: #B4307A; }
:root[dir="rtl"] .round-btn .ico { transform: scaleX(-1); }

/* The tool panel */
.panel { display: grid; gap: 18px; padding: 22px; border-radius: var(--r-card); background: var(--surface); box-shadow: var(--shadow-1), inset 0 0 0 1px var(--line); }
.group { display: grid; gap: 10px; min-width: 0; transition: opacity .25s; }
.group.row { display: flex; flex-wrap: wrap; gap: 8px; }
.eyebrow { margin: 0; font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); }
:root[lang="ar"] .eyebrow { text-transform: none; font-size: .875rem; }

.brushes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.brushes button {
  min-height: 72px; display: grid; justify-items: center; align-content: center; gap: 6px; padding: 8px 4px;
  border: 0; border-radius: var(--r-md); background: var(--surface-2); cursor: pointer; font-weight: 700; font-size: .9375rem; line-height: 1.2;
  transition: background .2s, box-shadow .2s, transform .15s;
}
.brushes .ico { width: 28px; height: 28px; }
.brushes button:hover { background: color-mix(in srgb, var(--ink) 6%, var(--surface-2)); }
.brushes button:active { transform: scale(.97); }
.brushes button[aria-checked="true"] { background: var(--accent-soft); color: var(--accent-text); box-shadow: inset 0 0 0 2px var(--accent); }

.swatches { display: flex; flex-wrap: wrap; gap: 6px; justify-content: space-between; }
.swatch {
  width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; cursor: pointer;
  background: radial-gradient(circle at 35% 30%, #fff8 0 14%, transparent 42%), var(--sw);
  box-shadow: 0 6px 14px -8px var(--sw), inset 0 0 0 1px rgb(0 0 0 / .08);
  transition: transform .2s var(--ease), box-shadow .2s;
}
.swatch:hover { transform: scale(1.06); }
.swatch[aria-checked="true"] { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5.5px var(--ink); transform: scale(1.04); }
.group.dim .swatches { opacity: .45; }

.seg { display: flex; padding: 4px; gap: 3px; border-radius: 999px; background: var(--surface-2); }
.seg button { flex: 1; min-height: 44px; min-width: 44px; padding: 0 8px; border: 0; border-radius: 999px; background: transparent; color: var(--ink-2); font-weight: 700; font-size: 1rem; cursor: pointer; font-variant-numeric: tabular-nums; }
.seg button:hover { color: var(--ink); }
.seg button[aria-checked="true"] { background: var(--ink); color: var(--canvas); }

.chip {
  min-height: 44px; display: inline-flex; align-items: center; gap: 8px; padding: 0 16px 0 12px;
  border: 1.5px solid var(--line-2); border-radius: 999px; background: var(--surface); cursor: pointer; font-weight: 700; font-size: .9375rem;
  transition: background .2s, border-color .2s, transform .15s;
}
.chip:hover { background: var(--surface-2); }
.chip:active { transform: scale(.97); }
.chip[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent); }
#surpriseBtn { --c: #FFC93C; }
#bgBtn { --c: #A884FF; }

.btn {
  min-height: 48px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 20px;
  border: 1.5px solid var(--line-2); border-radius: 999px; background: var(--surface); cursor: pointer; font-weight: 700; font-size: .9375rem;
  transition: filter .2s, transform .15s, background .2s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; box-shadow: 0 12px 24px -14px var(--accent); }
.btn.primary .ico { --c: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); background: var(--accent); }
.save-row .btn { flex: 1 1 auto; }

/* Feedback box, About + FAQ, footer */
.fb-about { max-width: 46rem; margin: 28px auto 0; padding: 0 var(--gutter); color: var(--ink-2); }
.fb-about h2 { margin: 0 0 10px; color: var(--ink); font-family: var(--serif); font-style: italic; font-weight: 400; font-size: clamp(2rem, 3.6vw, 2.75rem); line-height: 1.05; letter-spacing: -0.01em; }
:root[dir="rtl"] .fb-about h2 { font-family: var(--font); font-style: normal; font-weight: 700; font-size: clamp(1.5rem, 2.6vw, 2rem); }
.fb-about > p { margin: 0 0 14px; font-size: 1.0625rem; line-height: 1.7; }
.fb-faq h3 { margin: 18px 0 6px; font-size: .9375rem; color: var(--ink); }
.fb-faq details { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; margin-block: 10px; }
.fb-faq summary { min-height: 56px; padding: 14px 20px; font-size: 1.0625rem; font-weight: 700; color: var(--ink); cursor: pointer; }
.fb-faq details[open] summary { border-bottom: 1px solid var(--line); }
.fb-faq details p { margin: 0; padding: 12px 20px 16px; line-height: 1.7; }
.foot { max-width: 1180px; margin: 0 auto; padding: 8px var(--gutter) 28px; color: var(--ink-2); font-size: .875rem; text-align: center; }
.foot p { margin: 0 auto 6px; max-width: 70ch; }
body .fbk { width: min(760px, calc(100% - 2 * var(--gutter))); margin: 28px auto 40px; padding: 24px 26px; border-radius: 30px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-1); }
body .fbk-q { font-family: var(--font); font-style: normal; font-weight: 700; font-size: 1.25rem; line-height: 1.3; }
body .fbk-q svg { stroke: var(--accent); }
body .fbk-hint { color: var(--accent-text); }
body .fbk-send { min-height: 44px; padding: 0 22px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-weight: 700; }
body .fbk textarea, body .fbk input[type=email] { background: var(--surface); border-color: var(--line-2); border-radius: var(--r-sm); }
body .fbk .fbk-star { min-width: 44px; min-height: 44px; background: none; padding: 8px; border-radius: 12px; }
body .fbk .fbk-link { background: none; min-height: 44px; padding: 4px 0; border-radius: 0; }

/* Arabic suggestion bar from lang.js */
.fb-suggest { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; padding: 12px 16px; 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; }
.fb-suggest [lang="ar"] { font-family: 'IBM Plex Sans Arabic', system-ui, sans-serif; font-weight: 600; }
.fb-suggest-acts { display: flex; flex-wrap: wrap; gap: 8px; }
.fb-suggest button { min-height: 44px; padding: 0 16px; border: 1.5px solid var(--line-2); border-radius: 999px; background: var(--surface); cursor: pointer; font-weight: 700; }
.fb-suggest .fb-ar { background: var(--accent); color: var(--accent-ink); border-color: transparent; }

/* ---------- Tablet and phone ---------- */
@media (max-width: 899px) {
  .studio { grid-template-columns: 1fr; }
  .stage { height: clamp(330px, 60vh, 560px); }
  .panel { grid-template-columns: 1fr 1fr; align-items: start; }
  .panel .group.row { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .top-in { min-height: 64px; padding-top: 10px; row-gap: 0; gap: 0 6px; }
  .brand { gap: 10px; }
  .brand img { width: 38px; height: 38px; border-radius: 11px; }
  .brand h1 { font-size: 1.6rem; }
  :root[dir="rtl"] .brand h1 { font-size: 1.35rem; }
  .home-link { font-size: 0; width: 44px; padding: 0; }
  .home-link::before { content: '←'; font-size: 1.1rem; line-height: 1; }
  :root[dir="rtl"] .home-link::before { content: '→'; }
  .fb-lang button { padding-inline: 6px; font-size: .8125rem; }
  main { gap: 12px; padding-top: 6px; }
  .lead { font-size: .9375rem; }
  .stage { border-radius: 26px; height: clamp(320px, 56vh, 520px); }
  .panel { grid-template-columns: 1fr; padding: 16px; gap: 16px; border-radius: 26px; }
  .brushes button { min-height: 64px; }
  .swatches { justify-content: space-between; }
  .chip { padding: 0 12px 0 10px; font-size: .875rem; }
  .group.row { gap: 6px; }
}
@media (max-width: 440px) {
  /* Speaker: still a 44px target, but borderless so the name and languages fit on the first row */
  .sound-btn { background: none; border: 0; margin-inline: -4px; }
  .hint { font-size: .875rem; padding: 9px 14px; bottom: 14px; }
}
@media (max-width: 379px) {
  .swatches { display: grid; grid-template-columns: repeat(3, 44px); justify-content: space-around; row-gap: 10px; }
  .round-btn { width: 44px; height: 44px; }
}

/* Less motion: nothing slides or scales (the canvas still works, and its spin is slower) */
:root[data-motion="reduce"] *, :root[data-motion="reduce"] *::before, :root[data-motion="reduce"] *::after { transition: none !important; animation: none !important; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; } }
