/* ============================================================================
 * styles.css — AAC communication-core prototype
 * Themeable, accessibility-first. Two themes (Madagascar / Calm neutral),
 * high-contrast mode, reduced-motion mode, four target sizes.
 * Theme art is chrome only; communication tiles keep a clean high-contrast look.
 * ==========================================================================*/

:root {
  /* sizing (overridden by data-size) */
  --tile-min: 104px;
  --fs: 1;            /* font scale */
  --gap: 10px;
  --radius: 18px;

  /* ink = the colour of pictogram lines and tile labels */
  --ink: #15302a;

  /* surfaces */
  --app-bg: #f3ecdb;
  --panel: rgba(255, 252, 244, 0.86);
  --panel-solid: #fffdf7;
  --bar-bg: #fff8ea;
  --tab-bg: #ffffff;
  --hairline: rgba(40, 30, 10, 0.12);
  --shadow: 0 2px 7px rgba(60, 45, 15, 0.13);
  --shadow-lg: 0 14px 40px rgba(40, 30, 10, 0.30);

  /* action colours */
  --speak: #2f9e57;  --speak-ink: #ffffff;
  --neutral: #ece5d6; --neutral-ink: #3a3327;
  --express: #ef6a4b; --express-ink: #ffffff;

  /* modified Fitzgerald key */
  --cat-pron: #FFD23F;  /* people / pronouns - yellow  */
  --cat-verb: #86CC8C;  /* actions          - green   */
  --cat-desc: #82C6E8;  /* describing       - blue    */
  --cat-noun: #F4A259;  /* things           - orange  */
  --cat-soc:  #F3A0C0;  /* social           - pink    */
  --cat-q:    #C7A6E6;  /* questions        - purple  */
  --cat-neg:  #ED7A6B;  /* no / stop        - red     */
  --cat-misc: #DED8CA;  /* little words     - grey    */
}

/* ---- target sizes ---- */
[data-size="s"]  { --tile-min: 78px;  --fs: 0.9;  --gap: 8px;  }
[data-size="m"]  { --tile-min: 104px; --fs: 1.0;  --gap: 10px; }
[data-size="l"]  { --tile-min: 132px; --fs: 1.15; --gap: 12px; }
[data-size="xl"] { --tile-min: 168px; --fs: 1.35; --gap: 14px; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI",
    system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--app-bg);
  overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
  touch-action: manipulation;
}

/* background scene (Madagascar theme only) */
.bgscene { position: fixed; inset: 0; z-index: -2; background: var(--app-bg); }
.bgscene::after {
  content: ""; position: fixed; inset: 0; z-index: -1;
  background: linear-gradient(180deg, rgba(243,236,219,0.32) 0%,
    rgba(243,236,219,0.62) 48%, rgba(243,236,219,0.86) 100%);
}
[data-theme="madagascar"] .bgscene {
  background-image: url("../img/scene.webp");
  background-size: cover; background-position: center 18%;
}
[data-theme="calm"] { --app-bg: #eef1f5; --panel: #ffffff;
  --panel-solid: #ffffff; --bar-bg: #ffffff; }
[data-theme="calm"] .bgscene { background: var(--app-bg); }
[data-theme="calm"] .bgscene::after { display: none; }
/* Calm = genuinely low-stimulation: no decorative motion, gently softened colour. */
[data-theme="calm"] .express-fab { animation: none; }
[data-theme="calm"] .grid { filter: saturate(0.85); }
/* Madagascar: keep the board panel near-opaque so the photo can't bleed through tile gaps. */
[data-theme="madagascar"] .board-panel { background: rgba(255,252,244,0.95); }

/* ---------- app shell ---------- */
#app { display: flex; flex-direction: column; height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left); }

.appbar { display: flex; align-items: center; gap: 10px; padding: 8px 14px 6px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 18px; }
.brand .mark { width: 34px; height: 34px; border-radius: 9px; object-fit: cover;
  box-shadow: var(--shadow); background: #fff; }
.brand .wt { opacity: 0.55; font-weight: 700; font-size: 12px; margin-left: 2px;
  align-self: flex-end; padding-bottom: 2px; }
.spacer { flex: 1; }
.iconbtn { display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 48px; min-height: 48px; padding: 0 12px; border: none; border-radius: 14px;
  background: var(--panel); color: var(--ink); font-weight: 800; font-size: 15px;
  box-shadow: var(--shadow); cursor: pointer; }
.iconbtn svg { width: 22px; height: 22px; }

/* ---------- message bar ---------- */
.msgbar { display: flex; align-items: stretch; gap: 8px; margin: 4px 12px 0;
  padding: 8px; background: var(--bar-bg); border-radius: 16px; box-shadow: var(--shadow);
  border: 1px solid var(--hairline); }
.msg-scroll { flex: 1; display: flex; align-items: center; gap: 6px; overflow-x: auto;
  min-height: 66px; padding: 2px 4px; scrollbar-width: thin; }
.msg-scroll .placeholder { color: rgba(40,30,10,0.72); font-weight: 700; font-size: 15px; padding-left: 6px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
:focus-visible { outline: 4px solid #1b73e8; outline-offset: 2px; }
.msg-chip { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center;
  gap: 2px; padding: 5px 6px; background: var(--cat, #fff); border-radius: 12px;
  border: 1px solid var(--hairline); min-width: 54px; }
.msg-chip .sym { width: 34px; height: 34px; }
.msg-chip .lbl { font-size: 11px; font-weight: 800; max-width: 64px; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.msg-controls { display: flex; gap: 6px; align-items: stretch; }
.ctrl { display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; min-width: 60px; border: none; border-radius: 14px; font-weight: 800;
  font-size: 13px; cursor: pointer; box-shadow: var(--shadow); padding: 6px; }
.ctrl svg { width: 24px; height: 24px; }
.ctrl.back, .ctrl.clear { background: var(--neutral); color: var(--neutral-ink); }
.ctrl.speak { background: var(--speak); color: var(--speak-ink); min-width: 96px; font-size: 16px; }
.ctrl.speak svg { width: 30px; height: 30px; }
.ctrl:active { transform: scale(0.96); }
.ctrl[disabled] { opacity: 0.6; cursor: default; box-shadow: none; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 7px; overflow-x: auto; padding: 8px 12px 4px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 7px;
  min-height: 46px; padding: 6px 14px 6px 10px; border: 2px solid var(--hairline);
  border-radius: 999px; background: var(--tab-bg); color: var(--ink); font-weight: 800;
  font-size: 15px; cursor: pointer; box-shadow: var(--shadow); }
.tab .sym { width: 26px; height: 26px; }
.tab.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.tab.active .sym svg :where(path,line,polyline,polygon,circle,rect,ellipse) { stroke: #fff; }
.tab.active .sym svg .f { fill: #fff; }

/* ---------- board ---------- */
.board { flex: 1; overflow-y: auto; padding: 10px 12px 120px;
  -webkit-overflow-scrolling: touch; }
.board-panel { background: var(--panel); border-radius: 22px; padding: 12px;
  box-shadow: var(--shadow); border: 1px solid var(--hairline); }
.grid { display: grid; grid-template-columns: repeat(var(--cols, 6), minmax(0, 1fr)); gap: var(--gap); }
.board { overflow-x: hidden; }

.tile { position: relative; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 5px; min-height: var(--tile-min); padding: 9px 5px 7px;
  border-radius: var(--radius); background: var(--cat, #fff); color: var(--ink);
  border: 2px solid rgba(0,0,0,0.08); box-shadow: var(--shadow); cursor: pointer;
  transition: transform 0.08s ease, filter 0.08s ease; }
.tile .cat-strip { display: none; }
.tile .sym { width: 60%; max-width: 86px; aspect-ratio: 1 / 1; }
.tile .lbl { font-weight: 800; font-size: calc(15px * var(--fs)); line-height: 1.05;
  text-align: center; letter-spacing: 0.1px; }
.tile.armed { transform: scale(0.95); filter: brightness(1.06); }

/* category colours */
.tile[data-cat="pron"] { --cat: var(--cat-pron); }
.tile[data-cat="verb"] { --cat: var(--cat-verb); }
.tile[data-cat="desc"] { --cat: var(--cat-desc); }
.tile[data-cat="noun"] { --cat: var(--cat-noun); }
.tile[data-cat="soc"]  { --cat: var(--cat-soc); }
.tile[data-cat="q"]    { --cat: var(--cat-q); }
.tile[data-cat="neg"]  { --cat: var(--cat-neg); }
.tile[data-cat="misc"] { --cat: var(--cat-misc); }
.msg-chip[data-cat="pron"] { --cat: var(--cat-pron); }
.msg-chip[data-cat="verb"] { --cat: var(--cat-verb); }
.msg-chip[data-cat="desc"] { --cat: var(--cat-desc); }
.msg-chip[data-cat="noun"] { --cat: var(--cat-noun); }
.msg-chip[data-cat="soc"]  { --cat: var(--cat-soc); }
.msg-chip[data-cat="q"]    { --cat: var(--cat-q); }
.msg-chip[data-cat="neg"]  { --cat: var(--cat-neg); }
.msg-chip[data-cat="misc"] { --cat: var(--cat-misc); }

/* pictogram rendering — uniform style for ALL symbols */
.sym svg { width: 100%; height: 100%; display: block; }
.sym svg :where(path, line, polyline, polygon, circle, rect, ellipse) {
  fill: none; stroke: var(--ink); stroke-width: 3.3;
  stroke-linecap: round; stroke-linejoin: round; }
.sym svg .f { fill: var(--ink); stroke: none; }
.sym svg .f-text { fill: var(--ink); stroke: none; font-family: inherit; }

/* ---------- body map ---------- */
.bodywrap { display: flex; gap: 14px; flex-wrap: wrap; }
.bodymap { flex: 1 1 260px; min-width: 240px; display: flex; align-items: center; justify-content: center;
  background: #fff; border-radius: 18px; padding: 10px; box-shadow: var(--shadow); }
.bodymap svg { width: 100%; max-width: 320px; height: auto; }
.bodymap .region { fill: var(--cat-noun); stroke: var(--ink); stroke-width: 2.4; cursor: pointer;
  transition: fill 0.1s ease; opacity: 0.92; }
.bodymap .region:hover, .bodymap .region.armed { fill: #ef6a4b; }
.bodymap .region:focus-visible { outline: none; fill: #ef6a4b; stroke-width: 4; }
.bodymap .outline { fill: #fff; stroke: var(--ink); stroke-width: 2.6; }
.body-states { flex: 2 1 360px; }
.body-states h3, .bodyparts-hint { font-size: 14px; font-weight: 800; margin: 2px 0 8px; opacity: 0.7; }

/* ---------- express launcher + overlay ---------- */
.express-fab { position: fixed; z-index: 45;
  right: max(14px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom));
  display: inline-flex; align-items: center; gap: 9px; padding: 14px 20px 14px 16px;
  min-height: 66px; border: 3px solid #fff; border-radius: 999px; cursor: pointer;
  background: var(--express); color: var(--express-ink); font-weight: 800; font-size: 18px;
  box-shadow: 0 8px 22px rgba(0,0,0,0.30); animation: fabpulse 2.6s ease-in-out infinite; }
.express-fab .sym { width: 30px; height: 30px; }
.express-fab .sym svg :where(path,line,polyline,polygon,circle,rect,ellipse) { stroke: #fff; stroke-width: 3.6; }
@keyframes fabpulse { 0%,100% { box-shadow: 0 8px 22px rgba(0,0,0,0.30); }
  50% { box-shadow: 0 8px 22px rgba(0,0,0,0.30), 0 0 0 8px rgba(239,106,75,0.25); } }

.overlay { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center;
  justify-content: center; padding: 12px; background: rgba(25,18,6,0.46); }
.overlay.hidden { display: none; }
.sheet { background: var(--panel-solid); border-radius: 26px; box-shadow: var(--shadow-lg);
  width: min(960px, 100%); max-height: calc(100dvh - 24px); overflow: auto; padding: 16px 16px 20px; }
.sheet-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.sheet-head h2 { font-size: 22px; margin: 0; flex: 1; }
.close-btn { min-width: 56px; min-height: 56px; border: none; border-radius: 16px;
  background: var(--neutral); color: var(--neutral-ink); font-weight: 800; font-size: 22px;
  cursor: pointer; box-shadow: var(--shadow); }

.ex-group-label { font-weight: 800; font-size: 15px; opacity: 0.72; margin: 6px 2px 8px; }
.ex-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 14px; }
.ex-btn { display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 9px; min-height: 132px; border: 3px solid rgba(255,255,255,0.55); border-radius: 22px;
  color: #fff; font-weight: 800; font-size: 19px; text-align: center; cursor: pointer;
  padding: 12px 8px; box-shadow: var(--shadow); }
.ex-btn .sym { width: 46px; height: 46px; }
.ex-btn .sym svg :where(path,line,polyline,polygon,circle,rect,ellipse) { stroke: #fff; stroke-width: 3.4; }
.ex-btn .sym svg .f { fill: #fff; }
.ex-btn.urgent { background: #cf4631; }
.ex-btn.calm   { background: #2f828d; }
[data-contrast="high"] .ex-btn { border: 3px solid #000; }
[data-contrast="high"] .ex-said { color: #000; }
[data-contrast="high"] .ex-group-label { opacity: 1; color: #000; }
.ex-btn:active { transform: scale(0.97); }
.ex-said { text-align: center; font-size: 24px; font-weight: 800; min-height: 30px;
  margin: 2px 0 14px; color: var(--ink); }
.ex-said.show { animation: pop 0.3s ease; }
@keyframes pop { from { transform: scale(0.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- settings ---------- */
.set-row { display: flex; align-items: center; gap: 12px; padding: 12px 4px;
  border-bottom: 1px solid var(--hairline); flex-wrap: wrap; }
.set-row .label { flex: 1 1 180px; font-weight: 800; font-size: 16px; }
.set-row .hint { flex-basis: 100%; font-size: 13px; opacity: 0.6; font-weight: 600; }
.seg { display: inline-flex; gap: 4px; background: var(--neutral); border-radius: 12px; padding: 4px; flex-wrap: wrap; }
.seg button { min-width: 52px; min-height: 44px; border: none; border-radius: 9px; background: transparent;
  font-weight: 800; font-size: 14px; cursor: pointer; color: var(--neutral-ink); padding: 0 12px; }
.seg button.on { background: var(--ink); color: #fff; }
.toggle { position: relative; width: 64px; height: 38px; border-radius: 999px; border: none;
  background: #c9c2b3; cursor: pointer; transition: background 0.15s ease; flex: 0 0 auto; }
.toggle::after { content: ""; position: absolute; top: 4px; left: 4px; width: 30px; height: 30px;
  border-radius: 50%; background: #fff; transition: transform 0.15s ease; box-shadow: var(--shadow); }
.toggle.on { background: var(--speak); }
.toggle.on::after { transform: translateX(26px); }
.set-row select, .set-row input[type="range"] { flex: 1 1 200px; min-height: 44px; font-size: 15px;
  font-family: inherit; border-radius: 10px; border: 2px solid var(--hairline); padding: 4px 8px; background: #fff; }
.set-note { font-size: 12.5px; opacity: 0.62; line-height: 1.5; margin-top: 14px; font-weight: 600; }
.set-section { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.6px;
  opacity: 0.5; margin: 18px 2px 2px; }

/* ---------- onboarding ---------- */
.onb { text-align: center; padding: 22px 18px 24px; max-width: 520px; }
.onb img.hero { width: 168px; height: 168px; object-fit: contain;
  filter: drop-shadow(0 10px 18px rgba(0,0,0,0.18)); margin-bottom: 4px; }
.onb h1 { font-size: 28px; margin: 6px 0 2px; }
.onb .wt { font-size: 13px; opacity: 0.55; font-weight: 700; margin-bottom: 12px; }
.onb p { font-size: 16px; line-height: 1.5; opacity: 0.82; margin: 0 0 18px; }
.onb .start { min-height: 64px; padding: 0 40px; border: none; border-radius: 18px;
  background: var(--speak); color: #fff; font-weight: 800; font-size: 20px; cursor: pointer;
  box-shadow: var(--shadow-lg); }
.onb .skip { display: block; margin: 14px auto 0; background: none; border: none; font-size: 14px;
  opacity: 0.6; text-decoration: underline; cursor: pointer; font-weight: 700; color: var(--ink); }

/* ---------- celebration ---------- */
.celebrate { position: fixed; inset: 0; z-index: 70; pointer-events: none;
  display: flex; align-items: center; justify-content: center; }
.celebrate.hidden { display: none; }
.celebrate img { width: 150px; height: 150px; object-fit: contain; animation: cheer 1.1s ease; }
@keyframes cheer { 0% { transform: translateY(40px) scale(0.6); opacity: 0; }
  30% { transform: translateY(0) scale(1.08); opacity: 1; }
  75% { transform: translateY(0) scale(1); opacity: 1; }
  100% { transform: translateY(-10px) scale(0.95); opacity: 0; } }
.spark { position: absolute; width: 14px; height: 14px; border-radius: 50%; opacity: 0; }
.celebrate.go .spark { animation: spark 1s ease forwards; }
@keyframes spark { 0% { transform: translate(0,0) scale(0.4); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(1); opacity: 0; } }

/* ---------- switch scanning highlight ---------- */
.scan-active { outline: 6px solid #1b73e8 !important; outline-offset: -3px;
  box-shadow: 0 0 0 5px rgba(27,115,232,0.35) !important; z-index: 5; }
.scan-group { outline: 5px dashed #1b73e8 !important; outline-offset: -2px; }

/* ---------- high contrast ---------- */
[data-contrast="high"] { --ink: #000; --app-bg: #ffffff; --panel: #ffffff;
  --panel-solid: #ffffff; --bar-bg: #ffffff; --hairline: #000; --neutral: #eee; --neutral-ink: #000; }
[data-contrast="high"] .bgscene, [data-contrast="high"] .bgscene::after { background: #fff; }
[data-contrast="high"] .tile { background: #fff !important; border: 3px solid #000; }
[data-contrast="high"] .tile .cat-strip { display: block; position: absolute; top: 0; left: 0; right: 0;
  height: 12px; border-radius: var(--radius) var(--radius) 0 0; background: var(--cat); border-bottom: 2px solid #000; }
[data-contrast="high"] .tile .sym { margin-top: 8px; }
[data-contrast="high"] .tab { border-width: 3px; }
[data-contrast="high"] .board-panel, [data-contrast="high"] .msgbar { border: 2px solid #000; }
[data-contrast="high"] .iconbtn, [data-contrast="high"] .ctrl, [data-contrast="high"] .close-btn { border: 2px solid #000; }
[data-contrast="high"] .msg-chip { background: #fff !important; border: 2px solid #000; }
[data-contrast="high"] .msg-scroll .placeholder { color: #000; }

/* ---------- reduced motion ---------- */
[data-motion="reduced"] *, [data-motion="reduced"] *::before, [data-motion="reduced"] *::after {
  animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) {
  .express-fab { animation: none; }
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* phones */
@media (max-width: 560px) {
  .brand .wt { display: none; }
  .ctrl.speak { min-width: 76px; }
  .sheet { border-radius: 20px; }
}

/* ============================================================================
 * Splash / loading screen
 * ==========================================================================*/
.splash { position: fixed; inset: 0; z-index: 1000; overflow: hidden;
  display: flex; align-items: center; justify-content: center; background: #FBE7C6;
  transition: opacity 0.6s ease, visibility 0.6s ease; }
.splash.hide { opacity: 0; visibility: hidden; pointer-events: none; }
.splash[hidden] { display: none; }

/* responsive still background = poster + fallback (WebP with PNG fallback) */
.splash-bg { position: absolute; inset: 0; background: #FBE7C6 center / cover no-repeat;
  background-image: url("../assets/loading-bg-landscape-1.png"); }
@supports (background-image: image-set(url("a.webp") type("image/webp"))) {
  .splash-bg { background-image: image-set(
    url("../assets/loading-bg-landscape-1.webp") type("image/webp"),
    url("../assets/loading-bg-landscape-1.png") type("image/png")); }
}
@media (orientation: portrait) {
  .splash-bg { background-image: url("../assets/loading-bg-portrait.png"); }
  @supports (background-image: image-set(url("a.webp") type("image/webp"))) {
    .splash-bg { background-image: image-set(
      url("../assets/loading-bg-portrait.webp") type("image/webp"),
      url("../assets/loading-bg-portrait.png") type("image/png")); }
  }
}

/* ambient video: richer backdrop on top of the still, only revealed once playing */
.splash-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transition: opacity 1.2s ease; }
.splash-video.playing { opacity: 1; }

.splash-center { position: relative; z-index: 2; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: clamp(16px, 4.5vh, 44px);
  padding: 24px; text-align: center; }

.splash-wordmark { display: block; opacity: 0; animation: splashRise 0.9s ease 0.2s forwards; }
.splash-wordmark img { display: block; width: clamp(220px, 44vw, 460px); height: auto;
  filter: drop-shadow(0 6px 16px rgba(31, 56, 100, 0.18)); }
.splash-mascot { display: block; opacity: 0; animation: splashRise 0.9s ease 0.95s forwards; }
.splash-mascot img { display: block; width: clamp(150px, 30vw, 300px); height: auto;
  transform-origin: center bottom; filter: drop-shadow(0 14px 24px rgba(31, 56, 100, 0.22));
  animation: splashBob 4.5s ease-in-out 2s infinite; }

.splash-progress { position: relative; width: clamp(150px, 42vw, 250px); height: 8px;
  border-radius: 999px; background: rgba(31, 56, 100, 0.14); overflow: hidden;
  opacity: 0; animation: splashFadeIn 0.8s ease 1.5s forwards; }
.splash-progress span { position: absolute; top: 0; left: -45%; height: 100%; width: 45%;
  border-radius: 999px;
  background: linear-gradient(90deg, #2E9E5B, #0E9C8A, #F4B400, #F4673E);
  animation: splashSweep 1.9s ease-in-out infinite; }

@keyframes splashRise { from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); } }
@keyframes splashFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes splashBob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes splashSweep { 0% { left: -45%; } 100% { left: 100%; } }

/* Calm neutral theme: drop the tropical photo + ambient video, keep wordmark + mascot. */
[data-theme="calm"] .splash, [data-theme="calm"] .splash-bg { background: #eef1f5; }
[data-theme="calm"] .splash-bg { background-image: none; }
[data-theme="calm"] .splash-video { display: none; }
[data-theme="calm"] .splash-progress span { background: linear-gradient(90deg, #8aa0b6, #b9c6d3, #8aa0b6); }

/* Reduced motion (sensory accessibility): freeze video to still, static mascot, calm indicator. */
[data-motion="reduced"] .splash-video { display: none; }
[data-motion="reduced"] .splash-wordmark,
[data-motion="reduced"] .splash-mascot,
[data-motion="reduced"] .splash-progress { animation: none; opacity: 1; }
[data-motion="reduced"] .splash-mascot img { animation: none; }
[data-motion="reduced"] .splash-progress span { animation: none; left: 0; width: 100%; opacity: 0.55; }
@media (prefers-reduced-motion: reduce) {
  .splash-video { display: none; }
  .splash-wordmark, .splash-mascot, .splash-progress { animation: none; opacity: 1; }
  .splash-mascot img { animation: none; }
  .splash-progress span { animation: none; left: 0; width: 100%; opacity: 0.55; }
}

/* ---------- private profile avatar (local only, never branding) ---------- */
.avatar-btn { width: 48px; height: 48px; border-radius: 50%; border: 2px solid var(--hairline);
  background: var(--panel); box-shadow: var(--shadow); cursor: pointer; padding: 0; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center; color: var(--ink); flex: 0 0 auto; }
.avatar-btn img { width: 100%; height: 100%; object-fit: cover; display: none; }
.avatar-btn svg { width: 24px; height: 24px; }
.avatar-btn.has-photo img { display: block; }
.avatar-btn.has-photo svg { display: none; }
[data-contrast="high"] .avatar-btn { border: 2px solid #000; }

.avatar-preview { width: 84px; height: 84px; border-radius: 50%; object-fit: cover;
  border: 2px solid var(--hairline); background: var(--neutral); flex: 0 0 auto; }
.profile-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ============================================================================
 * Splash v2 — interactive, animated, HD + launch/config menu
 * ==========================================================================*/
/* floating leaves */
.splash-leaves { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 1; }
.splash-leaves span { position: absolute; bottom: -40px; width: 22px; height: 22px;
  border-radius: 0 100% 0 100%; background: linear-gradient(135deg, #6CC287, #2E9E5B);
  opacity: 0; animation: splashLeaf linear infinite; }
.splash-leaves span:nth-child(1) { left: 7%;  width: 18px; height: 18px; animation-duration: 12s; animation-delay: 0s; }
.splash-leaves span:nth-child(2) { left: 21%; width: 26px; height: 26px; animation-duration: 15s; animation-delay: 2s; }
.splash-leaves span:nth-child(3) { left: 35%; width: 14px; height: 14px; animation-duration: 10s; animation-delay: 4s; }
.splash-leaves span:nth-child(4) { left: 48%; width: 22px; height: 22px; animation-duration: 14s; animation-delay: 1s; }
.splash-leaves span:nth-child(5) { left: 62%; width: 16px; height: 16px; animation-duration: 13s; animation-delay: 5s; }
.splash-leaves span:nth-child(6) { left: 74%; width: 28px; height: 28px; animation-duration: 16s; animation-delay: 3s; }
.splash-leaves span:nth-child(7) { left: 86%; width: 18px; height: 18px; animation-duration: 11s; animation-delay: 6s; }
.splash-leaves span:nth-child(8) { left: 93%; width: 20px; height: 20px; animation-duration: 14s; animation-delay: 2.5s; }
@keyframes splashLeaf {
  0% { opacity: 0; transform: translateY(0) rotate(0deg); }
  12% { opacity: 0.7; } 88% { opacity: 0.5; }
  100% { opacity: 0; transform: translateY(-118vh) rotate(220deg); } }

/* quick toggles */
.splash-quick { position: absolute; z-index: 5; display: flex; gap: 8px;
  top: max(14px, env(safe-area-inset-top)); right: max(14px, env(safe-area-inset-right)); }
.splash-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px;
  border: none; border-radius: 999px; background: rgba(255, 255, 255, 0.8); color: #1f3864;
  font-weight: 800; font-size: 14px; cursor: pointer; box-shadow: var(--shadow); backdrop-filter: blur(4px); }
.splash-chip svg { width: 20px; height: 20px; }
.splash-chip[aria-pressed="false"] { opacity: 0.5; }

/* interactive mascot (now a button) */
.splash-mascot { background: none; border: none; padding: 0; cursor: pointer; }
.splash-mascot img { width: clamp(160px, 32vw, 320px); }
.splash-mascot.wave img { animation: splashWave 0.9s ease; }
@keyframes splashWave { 0%, 100% { transform: rotate(0deg); } 25% { transform: rotate(-6deg); }
  50% { transform: rotate(5deg); } 75% { transform: rotate(-3deg); } }

/* determinate progress (filled over time by JS) */
.splash-progress span { left: 0; width: 0; animation: none;
  background: linear-gradient(90deg, #2E9E5B, #0E9C8A, #F4B400, #F4673E); }
@keyframes splashLoad { from { width: 0; } to { width: 100%; } }

.splash-hint { margin: 2px 0 0; font-weight: 700; font-size: 15px; color: #1f3864; opacity: 0.85; }
.splash-continue { min-height: 56px; padding: 0 38px; border: none; border-radius: 16px;
  background: #2f9e57; color: #fff; font-weight: 800; font-size: 18px; cursor: pointer;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.22); opacity: 0; transform: translateY(8px);
  transition: opacity 0.4s ease, transform 0.4s ease; }
.splash-continue[hidden] { display: none; }
.splash-continue.show { opacity: 1; transform: translateY(0); animation: contPulse 2.2s ease-in-out 0.5s infinite; }
@keyframes contPulse { 0%, 100% { box-shadow: 0 8px 20px rgba(0,0,0,0.22); }
  50% { box-shadow: 0 8px 20px rgba(0,0,0,0.22), 0 0 0 8px rgba(47,158,87,0.22); } }
[data-theme="calm"] .splash-chip { background: rgba(255,255,255,0.92); }

/* ---------- launch / configuration menu ---------- */
.launch { position: fixed; inset: 0; z-index: 990; display: flex; align-items: safe center; justify-content: center;
  padding: 16px; overflow: auto; transition: opacity 0.5s ease, visibility 0.5s ease;
  background: linear-gradient(160deg, #FBE7C6 0%, #F4D6A8 55%, #AEDBBB 100%); }
.launch-grid .set-row { padding: 9px 4px; }
.launch-grid .set-row:first-child { border-top: 1px solid var(--hairline); }
[data-theme="calm"] .launch { background: linear-gradient(160deg, #eef1f5, #e3e8ee); }
.launch.hide { opacity: 0; visibility: hidden; pointer-events: none; }
.launch[hidden] { display: none; }
.launch-card { width: min(560px, 100%); max-height: calc(100dvh - 32px); overflow: auto;
  background: var(--panel-solid); border-radius: 26px; box-shadow: var(--shadow-lg);
  padding: 22px 20px 24px; animation: launchIn 0.5s ease; }
@keyframes launchIn { from { opacity: 0; transform: translateY(18px) scale(0.98); } to { opacity: 1; transform: none; } }
.launch-head { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; margin-bottom: 8px; }
.launch-head img { width: 76px; height: 76px; object-fit: contain; filter: drop-shadow(0 8px 14px rgba(31,56,100,0.16)); }
.launch-head h1 { margin: 4px 0 0; font-size: 24px; }
.launch-head p { margin: 0; font-size: 15px; opacity: 0.75; }
.launch-remember { display: flex; align-items: center; gap: 10px; padding: 14px 4px 4px; font-weight: 700; font-size: 15px; }
.launch-remember input { width: 22px; height: 22px; }
.launch-start { width: 100%; min-height: 66px; margin-top: 14px; border: none; border-radius: 18px;
  background: #2f9e57; color: #fff; font-weight: 800; font-size: 21px; cursor: pointer; box-shadow: var(--shadow-lg); }
.launch-start:active { transform: scale(0.99); }

/* reduced motion: calm everything on the loading flow */
[data-motion="reduced"] .splash-leaves { display: none; }
[data-motion="reduced"] .splash-mascot img { animation: none; }
[data-motion="reduced"] .splash-continue.show { animation: none; opacity: 1; transform: none; }
[data-motion="reduced"] .launch-card { animation: none; }
@media (prefers-reduced-motion: reduce) {
  .splash-leaves { display: none; }
  .splash-mascot img { animation: none; }
  .splash-continue.show { animation: none; opacity: 1; transform: none; }
  .launch-card { animation: none; }
}
