/* Tune Grid: a pentatonic grid sequencer in the Favabeans look (see ../APP_DESIGN.md, 2026 refresh).
   Light by default, dark when the system asks. Each mood (body[data-mood]) is its own place: page sky,
   board, accent, playhead and lit squares all change, gliding over about half a second.
   No dark green or dark teal. */

/* Registered so the mood colours can glide (gradients follow them frame by frame). */
@property --canvas { syntax: "<color>"; inherits: true; initial-value: #F7F6F2; }
@property --glow-a { syntax: "<color>"; inherits: true; initial-value: #FFD2B0; }
@property --glow-b { syntax: "<color>"; inherits: true; initial-value: #FFC6DE; }
@property --sky { syntax: "<color>"; inherits: true; initial-value: transparent; }
@property --board { syntax: "<color>"; inherits: true; initial-value: #FFFFFF; }
@property --board-2 { syntax: "<color>"; inherits: true; initial-value: #EFEDE6; }
@property --accent { syntax: "<color>"; inherits: true; initial-value: #C22C74; }
@property --accent-soft { syntax: "<color>"; inherits: true; initial-value: #FCE6F0; }
@property --accent-text { syntax: "<color>"; inherits: true; initial-value: #A3245F; }
@property --ph { syntax: "<color>"; inherits: true; initial-value: #C22C74; }
@property --lit { syntax: "<color>"; inherits: true; initial-value: #F5A41E; }
@property --lit2 { syntax: "<color>"; inherits: true; initial-value: #FFDE8C; }

: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(12px, 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;

  --accent: #C22C74;
  --accent-ink: #FFFFFF;
  --accent-soft: #FCE6F0;
  --accent-text: #A3245F;
  --focus: #C22C74;

  --cell-off: 13%;
  --cell-bar: 19%;
  --glow-a: #FFD2B0;
  --glow-b: #FFC6DE;
  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 -20px 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: #FF8FC4; --accent-ink: #2A0A1A; --accent-soft: #2E1A25; --accent-text: #FFB3D6; --focus: #FFA6CF;
    --cell-off: 8%; --cell-bar: 12%;
    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 -20px 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: #FF8FC4; --accent-ink: #2A0A1A; --accent-soft: #2E1A25; --accent-text: #FFB3D6; --focus: #FFA6CF;
  --cell-off: 8%; --cell-bar: 12%;
  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: rgb(127 127 127 / .45); --line-2: rgb(127 127 127 / .7); }

/* ---------- Moods: each one is a place ----------
   --sky: the band of colour at the top of the page; --board / --board-2: the tune board and its empty
   squares; --ph: the playhead. Light first, then the same tokens for dark. */
body[data-mood="sunny"] {
  --canvas: #FFF8EA; --glow-a: #FFD45E; --glow-b: #FFADCB; --sky: #FFE6A0;
  --board: #FFFDF7; --board-2: #FBF2E1;
  --accent: #F5B100; --accent-ink: #2B1D00; --accent-soft: #FFF0C2; --accent-text: #875800; --focus: #B36A00; --ph: #F5B100;
}
body[data-mood="moon"] {
  --canvas: #D8DAF0; --glow-a: #AEB4EE; --glow-b: #C9B6F4; --sky: #8890D2;
  --board: #1F2347; --board-2: #2B305C;
  --accent: #5552D4; --accent-ink: #FFFFFF; --accent-soft: #E6E6FA; --accent-text: #3F3CB0; --focus: #4A47C8; --ph: #B6B2FF;
}
body[data-mood="desert"] {
  --canvas: #F6E5CA; --glow-a: #FFC27E; --glow-b: #F5AB86; --sky: #F7CF98;
  --board: #FFF8EC; --board-2: #F4E6CF;
  --accent: #B5501A; --accent-ink: #FFFFFF; --accent-soft: #FBE5D1; --accent-text: #934112; --focus: #B5501A; --ph: #E58A3A;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) body[data-mood="sunny"] {
    --canvas: #16130E; --glow-a: #FFC63D; --glow-b: #FF86B4; --sky: #46291A;
    --board: #241D1E; --board-2: #322729;
    --accent: #FFCB47; --accent-ink: #2B1D00; --accent-soft: #3A3014; --accent-text: #FFD978; --focus: #FFD25E; --ph: #FFCB47;
  }
  :root:not([data-theme="light"]) body[data-mood="moon"] {
    --canvas: #0D0F22; --glow-a: #4E58C9; --glow-b: #7B5BD6; --sky: #1B2052;
    --board: #151935; --board-2: #21264B;
    --accent: #A9A6FF; --accent-ink: #14123A; --accent-soft: #23254A; --accent-text: #C4C2FF; --focus: #B8B5FF; --ph: #A9A6FF;
  }
  :root:not([data-theme="light"]) body[data-mood="desert"] {
    --canvas: #18110B; --glow-a: #FF9F4D; --glow-b: #E0704A; --sky: #3D2511;
    --board: #241A12; --board-2: #31251A;
    --accent: #FFA45C; --accent-ink: #2E1405; --accent-soft: #3A2416; --accent-text: #FFC08F; --focus: #FFB070; --ph: #FFA45C;
  }
}
:root[data-theme="dark"] body[data-mood="sunny"] {
  --canvas: #16130E; --glow-a: #FFC63D; --glow-b: #FF86B4; --sky: #46291A;
  --board: #241D1E; --board-2: #322729;
  --accent: #FFCB47; --accent-ink: #2B1D00; --accent-soft: #3A3014; --accent-text: #FFD978; --focus: #FFD25E; --ph: #FFCB47;
}
:root[data-theme="dark"] body[data-mood="moon"] {
  --canvas: #0D0F22; --glow-a: #4E58C9; --glow-b: #7B5BD6; --sky: #1B2052;
  --board: #151935; --board-2: #21264B;
  --accent: #A9A6FF; --accent-ink: #14123A; --accent-soft: #23254A; --accent-text: #C4C2FF; --focus: #B8B5FF; --ph: #A9A6FF;
}
:root[data-theme="dark"] body[data-mood="desert"] {
  --canvas: #18110B; --glow-a: #FF9F4D; --glow-b: #E0704A; --sky: #3D2511;
  --board: #241A12; --board-2: #31251A;
  --accent: #FFA45C; --accent-ink: #2E1405; --accent-soft: #3A2416; --accent-text: #FFC08F; --focus: #FFB070; --ph: #FFA45C;
}
/* Moonlight's header sits on the dusk sky: keep its small text dark enough to read in light mode */
body[data-mood="moon"] .top { --ink-2: #23233A; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) body[data-mood="moon"] .top { --ink-2: #C2C1BC; } }
:root[data-theme="dark"] body[data-mood="moon"] .top { --ink-2: #C2C1BC; }
/* Moonlight's board is night in both themes: light text, neutral tiles with a coloured lower edge */
body[data-mood="moon"] .board { --ink-2: #CFD1F5; --line: rgb(255 255 255 / .12); --line-2: rgb(255 255 255 / .32); --focus: #C9C6FF; --cell-off: 9%; --cell-bar: 14%; }
body[data-mood="moon"] .cell { --tint: var(--lit2); }
body[data-mood="moon"] .cell:not(.on) { box-shadow: inset 0 -3px 0 color-mix(in srgb, var(--lit2) 45%, transparent); }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 16px; }
html.fb-wait body > * { visibility: hidden; }
body {
  margin: 0; color: var(--ink);
  font: 400 1.0625rem/1.6 var(--font);
  -webkit-font-smoothing: antialiased; overflow-x: clip;
  background:
    linear-gradient(180deg, var(--sky), color-mix(in srgb, var(--sky) 0%, transparent) 440px),
    radial-gradient(900px 520px at 92% -10%, color-mix(in srgb, var(--glow-b) 75%, transparent), transparent 70%),
    radial-gradient(800px 500px at -8% 40%, color-mix(in srgb, var(--glow-a) 60%, transparent), transparent 70%),
    var(--canvas);
  background-attachment: fixed;
  transition: --canvas .6s var(--ease), --glow-a .6s var(--ease), --glow-b .6s var(--ease), --sky .6s var(--ease),
    --board .5s var(--ease), --board-2 .5s var(--ease), --accent .5s var(--ease), --accent-soft .5s var(--ease),
    --accent-text .5s var(--ease), --ph .5s var(--ease);
}
@media (prefers-color-scheme: dark) {
  :where(:root:not([data-theme="light"])) body {
    background:
      linear-gradient(180deg, var(--sky), color-mix(in srgb, var(--sky) 0%, transparent) 440px),
      radial-gradient(900px 520px at 92% -10%, color-mix(in srgb, var(--glow-b) 24%, transparent), transparent 70%),
      radial-gradient(800px 500px at -8% 40%, color-mix(in srgb, var(--glow-a) 17%, transparent), transparent 70%),
      var(--canvas);
    background-attachment: fixed;
  }
}
:where(:root[data-theme="dark"]) body {
  background:
    linear-gradient(180deg, var(--sky), color-mix(in srgb, var(--sky) 0%, transparent) 440px),
    radial-gradient(900px 520px at 92% -10%, color-mix(in srgb, var(--glow-b) 24%, transparent), transparent 70%),
    radial-gradient(800px 500px at -8% 40%, color-mix(in srgb, var(--glow-a) 17%, transparent), transparent 70%),
    var(--canvas);
  background-attachment: fixed;
}
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
a { color: inherit; text-underline-offset: 3px; }
h1, h2, h3 { font-weight: 700; letter-spacing: -0.02em; }
: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; }

/* Moonlight stars: soft dots that slowly brighten and dim (never flash); still with reduced motion */
.sky { position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: 0; transition: opacity .6s var(--ease); }
body[data-mood="moon"] .sky { opacity: 1; }
.sky i {
  position: absolute; left: var(--x); top: var(--y); width: var(--s); height: var(--s); border-radius: 50%;
  background: #FFFDF4; box-shadow: 0 0 6px 1px rgb(255 253 244 / .75);
  animation: twinkle var(--d) ease-in-out var(--dl) infinite alternate;
}
@keyframes twinkle { from { opacity: .95; } to { opacity: .4; } }

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

/* ---------- Header (same as the other refreshed apps) ---------- */
.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: 10px; padding: .34em .64em; border: 0; border-radius: 999px; box-shadow: none;
  font: 700 max(.66rem, 11px)/1.1 var(--font); font-style: normal; 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: 0 10px; border: 0; border-radius: 12px; background: none; color: var(--ink-2); font: 700 .875rem/1 var(--font); cursor: pointer; }
.fb-lang button:hover { color: var(--ink); }
.fb-lang button[lang="ar"] { font-family: 'IBM Plex Sans Arabic', system-ui, sans-serif; font-size: .95rem; }
.fb-lang button[aria-pressed="true"] { color: var(--ink); }
.fb-lang button[aria-pressed="false"] { font-weight: 500; }
.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); font-size: .875rem; 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); border-style: dashed; }
.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; }
@media (max-width: 1023px) { .top-in { padding-top: 12px; } }
@media (max-width: 640px) {
  .top-in { min-height: 64px; row-gap: 0; }
  .brand img { width: 38px; height: 38px; border-radius: 11px; }
  .brand h1 { font-size: 1.6rem; }
  .home-link { font-size: 0; padding: 0; width: 44px; }
  .home-link::before { content: "←"; font-size: 1.1rem; }
  :root[dir="rtl"] .home-link::before { content: "→"; }
}
@media (max-width: 440px) { .top-in { flex-wrap: wrap; } .brand { flex: 1 0 100%; padding-bottom: 4px; } }
:root[dir="rtl"] .brand h1 { font-family: var(--serif); }

/* ---------- Layout ---------- */
main { max-width: 1180px; margin: 0 auto; padding: 10px var(--gutter) 28px; }
.studio { display: grid; gap: 18px; justify-content: center; align-items: start; grid-template-columns: minmax(0, auto); }
@media (min-width: 900px) {
  .studio { grid-template-columns: auto minmax(320px, 360px); gap: 26px; }
}

/* ---------- The board ---------- */
.board {
  --gap: 5px; --bpad: 10px;
  --cell: clamp(26px, calc((100vw - 2 * var(--gutter) - 2 * var(--bpad) - 7 * var(--gap)) / 8), 60px);
  position: relative;
  background: var(--board); border-radius: var(--r-card); padding: 8px var(--bpad) var(--bpad);
  box-shadow: var(--shadow-1), inset 0 0 0 1px var(--line);
  justify-self: center;
}
/* Desert: a warm low sun setting behind the board (static: it only fades and sinks when the mood changes) */
.board::before {
  content: ""; position: absolute; z-index: -1; pointer-events: none;
  top: 0; inset-inline-end: clamp(0px, calc(50vw - 330px), 9%); width: clamp(118px, 30vw, 210px); aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, #FFE7B0 0, #FFC071 38%, #F79A4C 70%, #F08A45 100%);
  box-shadow: 0 0 70px 26px rgb(255 168 90 / .42);
  opacity: 0; transform: translateY(-20%);
  transition: opacity .6s var(--ease), transform .7s var(--ease);
}
body[data-mood="desert"] .board::before { opacity: 1; transform: translateY(-52%); }
@media (min-width: 600px) { .board { --gap: 7px; --bpad: 18px; } }
@media (min-width: 900px) { .board { --cell: clamp(40px, calc((100svh - 262px) / 10.9), 66px); } }
.hint {
  margin: 2px 4px 8px; min-height: 1.6em; text-align: center; color: var(--ink-2); font-size: .9375rem; font-weight: 600;
  transition: opacity .6s var(--ease);
}
.hint.gone { opacity: 0; }
.grid-wrap { position: relative; display: grid; gap: 0; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.grid { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(8, var(--cell)); grid-auto-rows: var(--cell); gap: var(--gap); }
.beat-line { height: 1px; margin: 9px 6px; background: var(--line); }
.fx { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 2; pointer-events: none; }

.cell {
  position: relative; padding: 0; border: 0; cursor: pointer;
  border-radius: calc(var(--cell) * .3);
  background: color-mix(in srgb, var(--tint, var(--lit)) var(--cell-off), var(--board-2));
  box-shadow: inset 0 -2px 0 rgb(0 0 0 / .035);
  transition: background-color .2s var(--ease), box-shadow .2s var(--ease), --lit .5s var(--ease), --lit2 .5s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.cell.bar { background: color-mix(in srgb, var(--tint, var(--lit)) var(--cell-bar), var(--board-2)); }
/* Dark: neutral tiles with a coloured lower edge (tinted dark tiles look murky) */
@media (prefers-color-scheme: dark) { :where(:root:not([data-theme="light"])) .cell { --tint: var(--lit2); } :where(:root:not([data-theme="light"])) .cell:not(.on) { box-shadow: inset 0 -3px 0 color-mix(in srgb, var(--lit2) 50%, transparent); } }
:where(:root[data-theme="dark"]) .cell { --tint: var(--lit2); }
:where(:root[data-theme="dark"]) .cell:not(.on) { box-shadow: inset 0 -3px 0 color-mix(in srgb, var(--lit2) 50%, transparent); }
.cell:hover { background: color-mix(in srgb, var(--lit) 32%, var(--board-2)); }
.cell.on {
  background: linear-gradient(155deg, var(--lit2) 0%, var(--lit) 92%);
  box-shadow: 0 7px 14px -8px var(--lit), inset 0 1.5px 0 rgb(255 255 255 / .6), inset 0 -3px 0 rgb(0 0 0 / .1);
}
.cell.on::after {
  content: ""; position: absolute; inset: 14% 44% 52% 14%; border-radius: 50%;
  background: radial-gradient(closest-side, rgb(255 255 255 / .8), rgb(255 255 255 / 0));
}
.cell:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; z-index: 3; }
.beats .cell { border-radius: 50%; }
.beats .cell:not(.on)::before {
  content: ""; position: absolute; inset: 38%; border-radius: 50%;
  background: color-mix(in srgb, var(--lit) 40%, transparent);
}
.beats .cell.on::after { inset: 16% 46% 50% 16%; }

/* Playhead: a soft lit column behind the tiles */
.playhead {
  position: absolute; z-index: 0; top: -5px; bottom: -5px; left: 0; width: 60px;
  border-radius: calc(var(--cell) * .38);
  background: linear-gradient(180deg, color-mix(in srgb, var(--ph) 24%, transparent), color-mix(in srgb, var(--ph) 12%, transparent));
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--ph) 55%, transparent);
  opacity: 0; transition: opacity .3s var(--ease), transform .09s linear;
}
.playing .playhead { opacity: 1; }

/* ---------- Controls panel ---------- */
.panel {
  display: grid; gap: 16px; align-content: start;
  background: var(--surface); border-radius: var(--r-card); padding: 18px;
  box-shadow: var(--shadow-1), inset 0 0 0 1px var(--line);
}
@media (max-width: 899px) { .panel { max-width: 560px; width: 100%; justify-self: center; } }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.group { display: grid; 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 { letter-spacing: normal; text-transform: none; font-size: .875rem; }

.play-btn {
  flex: 1 1 120px; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 56px; padding: 0 24px; border: 0; border-radius: 999px; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 1.0625rem;
  box-shadow: 0 14px 26px -14px var(--accent);
  transition: transform .2s var(--ease), filter .2s;
}
.play-btn:hover { filter: brightness(1.07); }
.play-btn:active { transform: scale(.97); }
.play-btn .ico { width: 24px; height: 24px; }
.play-btn .i-pause, .play-btn.is-playing .i-play { display: none; }
.play-btn.is-playing .i-pause { display: block; }

.chip {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border: 0; border-radius: 999px; cursor: pointer;
  background: var(--surface-2); color: var(--ink); font-weight: 700; font-size: .9375rem; white-space: nowrap;
  transition: background-color .2s, box-shadow .2s, transform .2s var(--ease);
}
.chip:hover { background: color-mix(in srgb, var(--ink) 7%, var(--surface-2)); }
.chip:active { transform: scale(.97); }
.chip[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-text); box-shadow: inset 0 0 0 1.5px var(--accent); }
.chip[aria-pressed="false"] .ico .f { fill: none; }
.chip.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 12px 24px -14px var(--accent); }
.chip.primary:hover { filter: brightness(1.07); }
#diceBtn { --c: #8467F2; flex: 0 1 auto; }
#clearBtn { --c: #F28A2E; }
.tools { justify-content: stretch; }
.tools .chip { flex: 1 1 auto; }

.pick { display: grid; grid-template-columns: repeat(var(--n, 4), minmax(0, 1fr)); gap: 6px; padding: 4px; border-radius: 22px; background: var(--surface-2); }
.pick.mood { --n: 3; }
.pick [role=radio] {
  display: grid; justify-items: center; gap: 4px; min-height: 66px; padding: 8px 4px 7px; border: 0; border-radius: 18px; cursor: pointer;
  background: transparent; color: var(--ink-2); font-size: .8125rem; font-weight: 600; line-height: 1.15; text-align: center;
  transition: background-color .2s var(--ease), color .2s, box-shadow .2s;
}
:root[lang="ar"] .pick [role=radio] { font-size: .875rem; }
.pick [role=radio]:hover { color: var(--ink); background: color-mix(in srgb, var(--surface) 60%, transparent); }
.pick-ico { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 12px; background: color-mix(in srgb, var(--c) 16%, var(--surface)); color: color-mix(in srgb, var(--c) 55%, var(--ink)); transition: transform .3s var(--ease); }
.pick [role=radio][aria-checked="true"] { background: var(--surface); color: var(--ink); font-weight: 700; box-shadow: 0 1px 2px rgb(0 0 0 / .07), 0 6px 16px -8px rgb(0 0 0 / .18), inset 0 0 0 2px color-mix(in srgb, var(--c) 70%, transparent); }
.pick [role=radio][aria-checked="true"] .pick-ico { background: linear-gradient(160deg, color-mix(in srgb, var(--c) 30%, var(--surface)), color-mix(in srgb, var(--c) 48%, var(--surface))); transform: scale(1.06); }
.pick [role=radio]:focus-visible { outline-offset: -2px; }
@media (prefers-color-scheme: dark) {
  :where(:root:not([data-theme="light"])) .pick [role=radio][aria-checked="true"] { background: var(--surface-3); }
  :where(:root:not([data-theme="light"])) .pick-ico { background: color-mix(in srgb, var(--c) 22%, var(--surface-2)); color: color-mix(in srgb, var(--c) 45%, var(--ink)); }
}
:where(:root[data-theme="dark"]) .pick [role=radio][aria-checked="true"] { background: var(--surface-3); }
:where(:root[data-theme="dark"]) .pick-ico { background: color-mix(in srgb, var(--c) 22%, var(--surface-2)); color: color-mix(in srgb, var(--c) 45%, var(--ink)); }

/* Tempo slider */
.tempo-row { display: flex; align-items: center; gap: 10px; }
.tempo-end { font-size: .8125rem; color: var(--ink-2); font-weight: 600; flex: none; }
#tempo {
  --p: 42%;
  flex: 1; min-width: 0; height: 44px; margin: 0; background: transparent; cursor: pointer;
  -webkit-appearance: none; appearance: none;
}
#tempo::-webkit-slider-runnable-track { height: 10px; border-radius: 999px; background: linear-gradient(to right, var(--accent) var(--p), var(--surface-3) var(--p)); }
#tempo::-moz-range-track { height: 10px; border-radius: 999px; background: var(--surface-3); }
#tempo::-moz-range-progress { height: 10px; border-radius: 999px; background: var(--accent); }
#tempo::-webkit-slider-thumb { -webkit-appearance: none; width: 28px; height: 28px; margin-top: -9px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 2px 8px rgb(0 0 0 / .25), inset 0 0 0 2px var(--accent); }
#tempo::-moz-range-thumb { width: 28px; height: 28px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 2px 8px rgb(0 0 0 / .25), inset 0 0 0 2px var(--accent); }
:root[dir="rtl"] #tempo::-webkit-slider-runnable-track { background: linear-gradient(to left, var(--accent) var(--p), var(--surface-3) var(--p)); }

/* Toast */
.toast {
  position: fixed; z-index: 40; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translate(-50%, 12px);
  display: flex; align-items: center; gap: 12px; max-width: calc(100vw - 32px); padding: 8px 8px 8px 20px; min-height: 52px;
  border-radius: 999px; background: var(--ink); color: var(--canvas); font-weight: 700; box-shadow: var(--shadow-2);
  opacity: 0; transition: opacity .25s var(--ease), transform .25s var(--ease);
}
:root[dir="rtl"] .toast { padding: 8px 20px 8px 8px; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast span:only-child { padding-inline-end: 12px; }
.toast button { min-height: 40px; padding: 0 16px; border: 0; border-radius: 999px; background: var(--canvas); color: var(--ink); font-weight: 700; cursor: pointer; }

/* ---------- About, FAQ, footer, feedback (matches the website) ---------- */
.fb-about { max-width: 46rem; margin: 12px auto 0; padding: 26px var(--gutter) 6px; color: var(--ink-2); }
.fb-about h2 { margin: 0 0 8px; 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: 22px 0 10px; color: var(--ink); font-size: 1rem; }
.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: 14px 20px 18px; 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 { 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-beta { color: var(--accent-text); background: var(--accent-soft); border: 0; box-shadow: none; font-family: var(--font); font-weight: 700; letter-spacing: .06em; }
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; }
body .fbk-star:focus-visible, body .fbk button:focus-visible, body .fbk textarea:focus-visible, body .fbk input:focus-visible { outline-color: var(--focus); }
.fb-suggest { max-width: 1180px; margin: 0 auto 12px; padding: 14px 18px; border-radius: 22px; background: var(--accent-soft); display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.fb-suggest p { margin: 0; display: grid; }
.fb-suggest [lang="ar"] { font-family: 'IBM Plex Sans Arabic', system-ui, sans-serif; font-weight: 600; }
.fb-suggest-acts { display: flex; gap: 8px; flex-wrap: wrap; }
.fb-suggest button { min-height: 44px; padding: 0 16px; border: 0; border-radius: 999px; background: var(--surface); font-weight: 700; cursor: pointer; }
.fb-suggest .fb-ar { background: var(--accent); color: var(--accent-ink); font-family: 'IBM Plex Sans Arabic', system-ui, sans-serif; }

/* ---------- Comfort: less motion ---------- */
:root[data-motion="reduce"] *, :root[data-motion="reduce"] *::before, :root[data-motion="reduce"] *::after { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } .sky i { animation: none !important; } }
:root[data-contrast="high"] .cell:not(.on) { box-shadow: inset 0 0 0 1.5px var(--line-2); }
