/*
 * Smile and Speak — the whole visual system, hand-written.
 *
 * Palette lifted from the school's logo: a girl and a corgi in a hot-air
 * balloon, drifting through a cream sky. Warm, rounded, sunny.
 *
 * The feeling is Ghibli and DreamWorks — painted light, generous air, a
 * mascot with opinions. The discipline underneath is Apple — one type scale,
 * one spacing rhythm, three elevations, one focal point per screen, and
 * nothing decorative that is not earning its place.
 *
 * Full documentation, including the illustration style guide that also
 * governs artwork inside the generated games: docs/BRAND.md
 * Constitution §3 is the short version.
 *
 *  1. Tokens          7. Buttons          13. Notices
 *  2. Base            8. Cards + covers   14. Lists
 *  3. Sky             9. Chips            15. Plain pages
 *  4. Chrome         10. Progress         16. Illustration
 *  5. Panels         11. Empty states     17. Motion
 *  6. Chat           12. Inputs           18. Narrow screens
 */

/* ================================================================ 1. tokens */

:root {
  /* Brand — these names are load-bearing, see CONSTITUTION §3. */
  --ink:        #2F4A82;
  --ink-soft:   #5A79B0;
  --sky:        #7E9BD0;
  --sky-soft:   #AFC4E8;
  --cream:      #FCF6E9;
  --parchment:  #F5EAD2;
  --coral:      #E8734C;
  --sun:        #F8C748;
  --lavender:   #BBA9DE;
  --corgi:      #E5A45E;
  --green:      #4ECB71;

  /* The teacher. She is the only human in the brand, so she is the only thing
     that needs a skin and a hair tone; both are hers alone and neither may be
     used as a surface. Declared here per BRAND §10.1 — the values are repeated
     as literals inside shared/_teacher, the way every painted partial does it. */
  --skin:       #F6D2AC;
  --hair:       #A0682F;

  --white:      #FFFFFF;
  --ink-faint:  #8AA3CC;
  --line:       rgba(47, 74, 130, .11);
  --line-firm:  rgba(47, 74, 130, .20);

  /* Elevation — three levels, no more. Every shadow is navy-tinted and
     two-stop: a tight contact shadow plus a wide soft one. Never grey,
     never hard. */
  --shadow-sm:  0 1px 2px rgba(47, 74, 130, .06), 0 3px 10px rgba(47, 74, 130, .06);
  --shadow:     0 2px 4px rgba(47, 74, 130, .05), 0 12px 30px rgba(47, 74, 130, .10);
  --shadow-lg:  0 4px 8px rgba(47, 74, 130, .06), 0 26px 60px rgba(47, 74, 130, .16);

  /* Radii — generous, never sharp. */
  --r-sm:   12px;
  --r:      20px;
  --r-lg:   28px;
  --r-xl:   36px;
  --r-pill: 999px;

  /* Spacing rhythm — a 4px grid. Every gap in the app is one of these. */
  --s1: .25rem;  --s2: .5rem;   --s3: .75rem;  --s4: 1rem;
  --s5: 1.5rem;  --s6: 2rem;    --s7: 3rem;    --s8: 4rem;

  /* Type scale — six sizes, and that is the whole vocabulary. */
  --t-display: clamp(1.9rem, 1.15rem + 2.6vw, 2.6rem);
  --t-h1:      clamp(1.4rem, 1.12rem + 1.2vw, 1.85rem);
  --t-h2:      1.2rem;
  --t-h3:      1.02rem;
  --t-body:    .97rem;
  --t-small:   .855rem;
  --t-micro:   .735rem;

  /* Motion — things float, they never snap. */
  --ease:        cubic-bezier(.22, .8, .3, 1);
  --ease-spring: cubic-bezier(.34, 1.42, .64, 1);
  --fast: .16s;
  --mid:  .28s;
  --slow: .55s;

  --font: 'Nunito', system-ui, -apple-system, 'Segoe UI Rounded', 'SF Pro Rounded',
          'Segoe UI', Roboto, sans-serif;
}

/* ================================================================== 2. base */

* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  font-size: var(--t-body);
  color: var(--ink);
  background: var(--cream);
  line-height: 1.58;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--sky); text-decoration: none; transition: color var(--fast) var(--ease); }
a:hover { color: var(--ink); }

h1, h2, h3 { font-weight: 800; letter-spacing: -.021em; line-height: 1.16; text-wrap: balance; }
h1 { font-size: var(--t-h1); }
h2 { font-size: var(--t-h2); }
h3 { font-size: var(--t-h3); letter-spacing: -.015em; }

:focus-visible {
  outline: 3px solid var(--sky);
  outline-offset: 3px;
  border-radius: var(--r-sm);
}

.muted  { color: var(--ink-soft); }
.small  { font-size: var(--t-small); }
.stack  { display: flex; flex-direction: column; gap: var(--s4); }
.row    { display: flex; align-items: center; gap: var(--s3); }
.spacer { flex: 1; }

/* Long Ukrainian compounds must never push a container open. */
.card, .card *, .panel__body, .list__row, .list__row * , .bubble, .chip { min-width: 0; }

/* =================================================================== 3. sky */

/* The sky the balloon floats in: cool light up top, warm cream below, one
   sun off to the corner. Painted, not filled — no band ever ends on a hard
   edge. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    linear-gradient(180deg, rgba(139, 172, 222, .52) 0%, rgba(203, 220, 243, .30) 24%, rgba(252, 246, 233, 0) 56%),
    radial-gradient(620px 400px at 92% -4%, rgba(248, 199, 72, .34), transparent 64%),
    radial-gradient(700px 520px at 10% 100%, rgba(187, 169, 222, .22), transparent 68%),
    radial-gradient(560px 400px at 88% 96%, rgba(232, 115, 76, .12), transparent 66%);
}

/* Four soft clouds at two depths, drifting at different speeds. */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-repeat: no-repeat;
  background-image:
    radial-gradient(closest-side, rgba(255,255,255,.92), rgba(255,255,255,0)),
    radial-gradient(closest-side, rgba(255,255,255,.70), rgba(255,255,255,0)),
    radial-gradient(closest-side, rgba(255,255,255,.85), rgba(255,255,255,0)),
    radial-gradient(closest-side, rgba(255,255,255,.55), rgba(255,255,255,0));
  background-size: 300px 96px, 190px 64px, 240px 78px, 170px 58px;
  background-position: 5% 14%, 18% 11%, 73% 7%, 86% 13%;
  animation: drift 46s ease-in-out infinite alternate;
}

/* =============================================================== 4. chrome */

.topbar {
  display: flex;
  align-items: center;
  gap: var(--s4);
  padding: var(--s3) clamp(var(--s4), 3vw, var(--s6));
  background: rgba(255, 255, 255, .74);
  backdrop-filter: blur(16px) saturate(1.3);
  -webkit-backdrop-filter: blur(16px) saturate(1.3);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 40;
}

.brand { display: flex; align-items: center; gap: var(--s3); color: var(--ink); min-width: 0; }
.brand:hover { color: var(--ink); }
/* The logo is square artwork with white corners, so the mark is a circular
   crop of it. box-shadow rather than drop-shadow: the shadow must follow the
   circle, and a filter on a raster would shadow the square it is cut from. */
.brand__mark {
  width: 46px; height: 46px; flex: none;
  border-radius: 50%;
  object-fit: cover;
  background: var(--white);
  box-shadow: 0 2px 4px rgba(47, 74, 130, .10), 0 6px 14px rgba(47, 74, 130, .16);
  transition: transform var(--slow) var(--ease-spring);
}
.brand:hover .brand__mark { transform: translateY(-3px) rotate(-4deg); }
.brand__name { display: block; font-weight: 900; font-size: 1.1rem; line-height: 1.1; letter-spacing: -.028em; }
.brand__sub  {
  display: block; font-size: var(--t-micro); color: var(--ink-soft); font-weight: 800;
  text-transform: uppercase; letter-spacing: .13em; line-height: 1.4;
}

.nav { display: flex; align-items: center; gap: var(--s1); min-width: 0; }

.navlink {
  display: inline-flex; align-items: center; gap: var(--s2);
  font-weight: 800; font-size: var(--t-small); color: var(--ink-soft);
  padding: .62rem .95rem; border-radius: var(--r-pill);
  min-height: 44px; white-space: nowrap;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}
.navlink:hover { background: rgba(175, 196, 232, .40); color: var(--ink); }
.navlink.is-active { background: var(--sky-soft); color: var(--ink); }
.navlink .icon { width: 19px; height: 19px; flex: none; }

/* --- the language SHE reads the app in ----------------------------------
   A quiet ghost pill that sits with the other chrome, next to Sign out. It
   is styled and shaped like a button up here, while the *game* language
   picker is a globe down in the chat form where a game is being made. That
   difference is the point: one was mistaken for the other once. */
.uilang { display: flex; flex: none; min-width: 0; }
.uilang__pill {
  position: relative;
  display: inline-flex; align-items: center;
  min-height: 38px; padding-left: 1.95rem; padding-right: .3rem;
  border: 1.5px solid var(--line-firm); border-radius: var(--r-pill);
  background: var(--white); color: var(--ink-soft);
  cursor: pointer; min-width: 0;
  transition: border-color var(--fast) var(--ease), color var(--fast) var(--ease),
              background var(--fast) var(--ease);
}
.uilang__pill:hover { border-color: var(--sky-soft); color: var(--ink); background: rgba(175, 196, 232, .16); }
.uilang__pill:focus-within { border-color: var(--sky); box-shadow: 0 0 0 4px rgba(126, 155, 208, .22); }

.uilang__icon {
  position: absolute; left: .58rem; top: 50%; transform: translateY(-50%);
  display: flex; pointer-events: none;
}
.uilang__icon .icon { width: 17px; height: 17px; }

.uilang__select {
  appearance: none; -webkit-appearance: none;
  font: inherit; font-weight: 800; font-size: var(--t-micro);
  color: inherit; background: none; border: 0; outline: none;
  padding: 0 .4rem 0 0; cursor: pointer; min-width: 0;
  /* Narrow by default; the full name is there when the menu opens. */
  max-width: 6rem; text-overflow: ellipsis;
}
.uilang__select:focus-visible { outline: none; }

/* ================================================================ 5. panels */

.page { max-width: 1240px; margin: 0 auto; padding: clamp(var(--s4), 3vw, var(--s6)); }

.pagehead {
  display: flex; align-items: center; gap: var(--s3);
  flex-wrap: wrap;
  margin-bottom: var(--s5);
}
.pagehead__title { min-width: 0; }
.pagehead__title h1 { overflow-wrap: anywhere; }

.navlink--back { margin-left: -.7rem; }

.dashboard {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: clamp(var(--s4), 2vw, var(--s5));
  align-items: start;
}

.panel {
  position: relative;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel__head {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s4) var(--s5);
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(175, 196, 232, .20), rgba(255, 255, 255, 0));
}
.panel__head h2 { min-width: 0; overflow-wrap: anywhere; }
.panel__body { padding: var(--s5); }

/* A tinted disc behind a section's icon — the one piece of chrome that says
   "this is a section", used at exactly one size. */
.panel__badge {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  border-radius: 13px;
  background: var(--sky-soft); color: var(--ink);
}
.panel__badge .icon { width: 22px; height: 22px; }
.panel__badge--sun   { background: rgba(248, 199, 72, .48); }
.panel__badge--coral { background: rgba(232, 115, 76, .22); color: #A8431F; }
.panel__badge--lav   { background: rgba(187, 169, 222, .40); color: #4A3A72; }

.panel__title { display: flex; flex-direction: column; min-width: 0; }
.panel__title .small { line-height: 1.35; }

/* ================================================================== 6. chat */

.chat { display: flex; flex-direction: column; height: min(74dvh, 780px); }

.chat__scroll {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: var(--s5);
  display: flex; flex-direction: column; gap: var(--s3);
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--sky-soft) transparent;
}
.chat__scroll::-webkit-scrollbar { width: 8px; }
.chat__scroll::-webkit-scrollbar-thumb { background: var(--sky-soft); border-radius: var(--r-pill); }

/* A message is an avatar and a bubble; the teacher's own messages need no
   avatar because she knows who she is. */
.msg { display: flex; align-items: flex-end; gap: var(--s2); max-width: 94%; }
.msg--assistant { align-self: flex-start; }
.msg--teacher   { align-self: flex-end; flex-direction: row-reverse; }

.msg__avatar {
  width: 40px; height: 40px; flex: none;
  border-radius: 50%;
  background: var(--parchment);
  border: 1.5px solid rgba(47, 74, 130, .14);
  overflow: hidden;
  display: grid; place-items: center;
  box-shadow: var(--shadow-sm);
}
.msg__avatar svg { width: 132%; height: 132%; margin-bottom: -14%; }

.bubble {
  padding: .78rem 1.05rem;
  border-radius: var(--r);
  font-size: var(--t-body);
  overflow-wrap: anywhere;
  animation: rise var(--slow) var(--ease-spring) both;
}
.bubble p + p { margin-top: .45rem; }
.bubble--teacher {
  background: linear-gradient(150deg, #8AA6D6, #6B8AC6);
  color: var(--white);
  border-bottom-right-radius: 8px;
  box-shadow: 0 2px 4px rgba(47, 74, 130, .10), 0 8px 20px rgba(107, 138, 198, .26);
}
.bubble--assistant {
  background: var(--parchment);
  color: var(--ink);
  border-bottom-left-radius: 8px;
  box-shadow: var(--shadow-sm);
}
.bubble__time { display: block; margin-top: .35rem; font-size: var(--t-micro); opacity: .6; font-weight: 700; }
.bubble .btn { margin-top: .6rem; }

/* Thinking: three dots bobbing in sequence, with the corgi listening. */
.thinking { display: flex; align-items: flex-end; gap: var(--s2); align-self: flex-start; }
.thinking__dots {
  display: flex; gap: .34rem; align-items: center;
  padding: 1.05rem 1.15rem;
  background: var(--parchment);
  border-radius: var(--r); border-bottom-left-radius: 8px;
  box-shadow: var(--shadow-sm);
}
.thinking__dots span {
  width: 8px; height: 8px; border-radius: 50%; background: var(--sky);
  animation: bob 1.25s ease-in-out infinite;
}
.thinking__dots span:nth-child(2) { animation-delay: .16s; }
.thinking__dots span:nth-child(3) { animation-delay: .32s; }

.chat__hints { display: flex; flex-wrap: wrap; gap: var(--s2); padding: 0 var(--s5) var(--s4); }

.hint {
  font: inherit;
  font-size: var(--t-small); font-weight: 700; color: var(--ink-soft);
  background: var(--white); border: 1.5px solid var(--line-firm);
  padding: .48rem .9rem; border-radius: var(--r-pill);
  cursor: pointer; text-align: left;
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease),
              color var(--fast) var(--ease), transform var(--fast) var(--ease-spring);
}
.hint:hover {
  background: var(--sun); border-color: var(--sun); color: #6A4E06;
  transform: translateY(-2px);
}

/* Two rows: the game language above, the message box below. It used to be one
   row with the picker squeezed in unlabelled beside the input — which is
   precisely how it came to be mistaken for the language of the interface. It
   now carries its name in full, and the message box gets the whole width. */
.chat__form {
  display: flex; flex-direction: column; gap: var(--s3);
  padding: var(--s4) var(--s5);
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(252, 246, 233, .5), rgba(252, 246, 233, .9));
}
.chat__row { display: flex; gap: var(--s2); align-items: center; min-width: 0; }

/* The language the game speaks to the CHILD in — a globe, down here where a
   game is being made. The language SHE reads is a speech bubble up in the
   topbar. "Автоматично" is right almost every time; she only reaches for this
   when the class is taught in another language. */
.chat__lang {
  position: relative; flex: none; align-self: flex-start; max-width: 100%;
  display: inline-flex; align-items: center;
  height: 42px; padding-left: 2.1rem; padding-right: .3rem;
  border: 2px solid var(--sky-soft); border-radius: var(--r-pill);
  background: var(--white);
  color: var(--ink-soft);
  transition: border-color var(--fast) var(--ease), color var(--fast) var(--ease);
}
.chat__lang:hover { border-color: var(--sky); color: var(--ink); }
.chat__lang:focus-within { border-color: var(--sky); box-shadow: 0 0 0 4px rgba(126, 155, 208, .2); }

.chat__lang-icon {
  position: absolute; left: .62rem; top: 50%; transform: translateY(-50%);
  display: flex; pointer-events: none;
}
.chat__lang-icon .icon { width: 19px; height: 19px; }

/* Named, not implied. The label is the whole point of this control now. */
.chat__lang-label {
  font-weight: 800; font-size: var(--t-micro); color: var(--ink-soft);
  text-transform: uppercase; letter-spacing: .09em;
  white-space: nowrap; padding-right: .5rem; flex: none;
}
.chat__lang:hover .chat__lang-label { color: var(--ink); }

.chat__lang-select {
  appearance: none; -webkit-appearance: none;
  font: inherit; font-weight: 800; font-size: var(--t-small);
  color: inherit; background: none; border: 0; outline: none;
  padding: 0 .55rem 0 0; cursor: pointer; min-width: 0;
  /* It has a row to itself now, so it shows its value in full — "Автоматично"
     and "Автоматически" were both being clipped when this shared a line with
     the message box. Never wider than the panel, though. */
  max-width: 100%; text-overflow: ellipsis;
}
.chat__lang-select:focus-visible { outline: none; }

/* Available to screen readers, invisible to everyone else. */
.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* ============================================================ 7. buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  font: inherit; font-weight: 800; font-size: var(--t-small);
  padding: .7rem 1.3rem;
  min-height: 44px;
  border: none; border-radius: var(--r-pill);
  background: var(--sky); color: var(--white);
  cursor: pointer; white-space: nowrap;
  box-shadow: 0 2px 4px rgba(47, 74, 130, .10), 0 6px 16px rgba(126, 155, 208, .34);
  transition: transform var(--fast) var(--ease-spring), box-shadow var(--fast) var(--ease),
              background var(--fast) var(--ease), filter var(--fast) var(--ease);
}
.btn:hover  { transform: translateY(-2px); color: var(--white); filter: saturate(1.06); box-shadow: 0 4px 8px rgba(47,74,130,.10), 0 12px 26px rgba(126,155,208,.42); }
.btn:active { transform: translateY(0) scale(.975); }
.btn[disabled] { opacity: .48; cursor: not-allowed; transform: none; filter: saturate(.7); }
.btn .icon { width: 17px; height: 17px; flex: none; }

.btn--sun   { background: var(--sun); color: #6A4E06; box-shadow: 0 2px 4px rgba(47,74,130,.08), 0 6px 16px rgba(248,199,72,.44); }
.btn--sun:hover { color: #6A4E06; box-shadow: 0 4px 8px rgba(47,74,130,.08), 0 12px 26px rgba(248,199,72,.52); }
.btn--coral { background: var(--coral); box-shadow: 0 2px 4px rgba(47,74,130,.08), 0 6px 16px rgba(232,115,76,.38); }
.btn--ghost {
  background: var(--white); color: var(--ink-soft);
  border: 1.5px solid var(--line-firm); box-shadow: none;
}
.btn--ghost:hover { color: var(--ink); border-color: var(--sky-soft); background: rgba(175,196,232,.16); box-shadow: var(--shadow-sm); }
.btn--sm  { padding: .44rem .9rem; font-size: var(--t-micro); min-height: 38px; }
.btn--big { padding: .95rem 1.9rem; font-size: 1.02rem; min-height: 54px; }
.btn--big .icon { width: 20px; height: 20px; }
.btn--block { width: 100%; }
.btn--round { width: 48px; height: 48px; min-height: 48px; padding: 0; flex: none; }
.btn--round .icon { width: 21px; height: 21px; }

/* ======================================================= 8. cards + covers */

/* min() keeps the track from ever exceeding the container: without it a
   210px minimum overflows a 390px phone once padding is counted, and the
   whole page scrolls sideways. */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 236px), 1fr));
  gap: var(--s4);
}

.card {
  position: relative;
  display: flex; flex-direction: column;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform var(--mid) var(--ease-spring), box-shadow var(--mid) var(--ease);
  animation: rise .45s var(--ease-spring) both;
}
.card:hover, .card:focus-within { transform: translateY(-6px); box-shadow: var(--shadow-lg); }

/* The cover: the game's own gradient veiled with cream so it reads as
   painted light rather than a colour block, then clouds, then the motif. */
.cover {
  position: relative;
  aspect-ratio: 16 / 10;
  background: var(--cover-sky, linear-gradient(140deg, #7E9BD0, #BBA9DE));
  overflow: hidden;
}
.cover::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,.60), rgba(252,246,233,.24) 48%, rgba(47,74,130,.10));
}
.cover__art { position: relative; display: block; width: 100%; height: 100%; }
.cover__clouds { animation: cloud-slide 26s ease-in-out infinite alternate; }
.cover__fall   { animation: letters-fall 3.4s ease-in-out infinite; }
.cover__glyph  { font: 900 22px/1 var(--font); }
.cover__tile   { font: 900 13px/1 var(--font); letter-spacing: .01em; }

/* Clips the mascot so he can rise from behind the cover's lower edge. */
.card__cover { position: relative; overflow: hidden; }

.cover--hero { aspect-ratio: 16 / 6.4; border-radius: 0; }

/* He waits behind the cover and pops up when she looks at the card. */
.card__peek {
  position: absolute; left: 50%; bottom: 0;
  width: 60px; z-index: 2; pointer-events: none;
  transform: translate(-50%, 102%);
  transition: transform var(--slow) var(--ease-spring);
  filter: drop-shadow(0 -4px 10px rgba(47, 74, 130, .18));
}
.card:hover .card__peek, .card:focus-within .card__peek { transform: translate(-50%, 14%); }

/* When something is actually happening he stays out. */
.card__mascot {
  position: absolute; right: 8px; bottom: 0;
  width: 66px; z-index: 2; pointer-events: none;
  filter: drop-shadow(0 -4px 10px rgba(47, 74, 130, .16));
}

.card__body { padding: var(--s4) var(--s4) 1.1rem; display: flex; flex-direction: column; gap: var(--s3); flex: 1; }
.card__title {
  font-weight: 800; font-size: var(--t-h3); line-height: 1.3; letter-spacing: -.015em;
  overflow-wrap: anywhere; hyphens: auto;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card__meta { display: flex; flex-wrap: wrap; gap: var(--s1) .3rem; }
.card__actions { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: auto; padding-top: var(--s1); }
/* Two pills share the row when it fits and stack when it does not — a
   nowrap pill in a nowrap row is what used to burst the card open. The
   button_to helper wraps each button in a form, so the form has to flex too. */
.card__actions > * { flex: 1 1 7.5rem; min-width: 0; }
.card__actions form { display: flex; }
.card__actions .btn { width: 100%; max-width: 100%; overflow: hidden; }
.card__actions .btn > span,
.card__actions .btn { text-overflow: ellipsis; }
.card__note { font-size: var(--t-small); color: var(--ink-soft); overflow-wrap: anywhere; }

/* The technical reason a build stopped, folded away under the kind sentence.
   Quiet on purpose — it is there to be screenshotted, not to be read. */
.whydetails { margin-top: var(--s2); }
.whydetails__toggle {
  font-size: var(--t-micro); color: var(--ink-faint); font-weight: 800;
  cursor: pointer; list-style: none; user-select: none;
}
.whydetails__toggle::marker, .whydetails__toggle::-webkit-details-marker { display: none; }
.whydetails__toggle::before { content: "▸ "; }
.whydetails[open] .whydetails__toggle::before { content: "▾ "; }
.whydetails__toggle:hover { color: var(--ink-soft); }
.whydetails__body {
  display: block; margin-top: var(--s2);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: var(--t-micro); line-height: 1.5; color: var(--ink-soft);
  background: var(--cream); border-radius: var(--r-sm);
  padding: var(--s3); overflow-wrap: anywhere; white-space: pre-wrap;
}

.card--failed .cover { filter: saturate(.35) brightness(1.04); }

/* ================================================================ 9. chips */

.chip {
  font-size: var(--t-micro); font-weight: 800; line-height: 1.5;
  padding: .2rem .6rem; border-radius: var(--r-pill);
  background: var(--sky-soft); color: #24406F;
  overflow-wrap: anywhere;
}
.chip--lav   { background: var(--lavender); color: #3B2E5C; }
.chip--sun   { background: var(--sun); color: #6A4E06; }
.chip--corgi { background: var(--corgi); color: #5C3A11; }
.chip--green { background: #B6EDC7; color: #0C4A22; }
.chip--coral { background: var(--coral); color: var(--white); }
.chip--word  { background: var(--cream); color: var(--ink); border: 1.5px solid var(--line-firm); }
.chip--ready { display: inline-flex; align-items: center; gap: .28rem; }
.chip--ready .icon { width: 14px; height: 14px; }

/* ============================================================= 10. progress */

/* The build reads as a journey: a balloon climbing a dotted route, not a
   loading bar. She watches this for ninety seconds, so it has to be worth
   watching. */
.progress { display: flex; flex-direction: column; gap: var(--s2); }
.progress__line { display: flex; align-items: flex-start; gap: var(--s2); }
.progress__icon {
  width: 22px; height: 22px; flex: none; color: var(--sky);
  animation: nudge 1.9s ease-in-out infinite;
}
.progress__label {
  font-weight: 800; font-size: var(--t-small); color: var(--ink-soft);
  min-width: 0; overflow-wrap: anywhere; line-height: 1.4;
}
.progress__route { position: relative; margin: 1.7rem .9rem .15rem; }
/* The route ahead: a dotted line, not a ladder. Kept faint so the filled
   part and the balloon are what the eye actually lands on. */
.progress__track {
  height: 7px; border-radius: var(--r-pill);
  background:
    repeating-linear-gradient(90deg, rgba(47, 74, 130, .13) 0 2px, transparent 2px 9px),
    rgba(126, 155, 208, .16);
  overflow: hidden;
}
.progress__bar {
  height: 100%; border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--sun), var(--coral), var(--sun));
  background-size: 220% 100%;
  animation: slide 2.4s linear infinite;
  transition: width 1s var(--ease);
}
.progress__balloon {
  position: absolute; top: 4px; width: 30px; height: 30px;
  transform: translate(-50%, -78%);
  transition: left 1s var(--ease);
  animation: hover-bob 3s ease-in-out infinite;
  filter: drop-shadow(0 3px 6px rgba(47, 74, 130, .2));
}

/* The same thing, at the size she watches on the game's own page. The panel
   tint follows the crew: warm while the story is invented, coral while the
   artists draw, lavender while the composer writes. */
.build {
  display: flex; align-items: center; gap: var(--s4);
  padding: var(--s4) var(--s5);
  background: linear-gradient(140deg, rgba(248, 199, 72, .18), rgba(175, 196, 232, .22));
  border: 1.5px solid var(--line);
  border-radius: var(--r);
  transition: background var(--slow) var(--ease);
}
.build--art   { background: linear-gradient(140deg, rgba(232, 115, 76, .18), rgba(248, 199, 72, .22)); }
.build--music { background: linear-gradient(140deg, rgba(187, 169, 222, .26), rgba(175, 196, 232, .22)); }
.build--cheer { background: linear-gradient(140deg, rgba(78, 203, 113, .18), rgba(248, 199, 72, .22)); }
.build--sad   { background: linear-gradient(140deg, rgba(232, 115, 76, .12), rgba(175, 196, 232, .16)); }

.build__corgi { width: 88px; flex: none; animation: tilt 3.6s ease-in-out infinite; }
.build--music .build__corgi { animation: sway 1.6s ease-in-out infinite; }
.build__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--s2); }
.build__stage {
  display: flex; align-items: flex-start; gap: var(--s2);
  font-weight: 800; font-size: var(--t-h3); line-height: 1.32;
  letter-spacing: -.015em; overflow-wrap: anywhere;
}
/* Aligned to the first line's optical centre, not to a two-line block. */
.build__icon { display: inline-flex; flex: none; color: var(--sky); margin-top: .1em; }
.build__icon .icon { width: 20px; height: 20px; }
.build__after {
  display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap;
  margin-top: var(--s3);
}
.build__after p { min-width: 0; flex: 1 1 14rem; }

.corgi__notes { animation: rise-dots 2.2s ease-in-out infinite; }

/* ========================================================== 11. empty states */

.empty {
  display: flex; flex-direction: column; align-items: center; gap: var(--s3);
  padding: clamp(var(--s5), 5vw, var(--s7)) var(--s5);
  text-align: center; color: var(--ink-soft);
}
.empty__art { position: relative; width: 210px; max-width: 70%; margin-bottom: var(--s2); }
.empty__balloon { width: 100%; display: block; animation: float 5.5s ease-in-out infinite; }
.empty__corgi {
  position: absolute; right: -6%; bottom: -4%;
  width: 46%; animation: float 5.5s ease-in-out infinite .5s;
}
/* Her and the dog under their balloon — the school's logo, rebuilt. Each on
   its own clock: three things floating in step read as one machine. */
.empty__teacher {
  position: absolute; left: -7%; bottom: -7%;
  width: 45%; animation: float 5.5s ease-in-out infinite 1.1s;
}
.empty h3 { color: var(--ink); font-size: 1.15rem; }
.empty p { max-width: 34ch; }

/* =============================================================== 12. inputs */

.input, .select, .textarea {
  width: 100%;
  font: inherit; font-size: var(--t-body); color: var(--ink);
  background: var(--white);
  border: 2px solid var(--sky-soft);
  border-radius: var(--r-pill);
  padding: .74rem 1.15rem;
  min-height: 48px;
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease), background var(--fast) var(--ease);
}
.input:hover, .select:hover, .textarea:hover { border-color: #9BB4DF; }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--sky);
  box-shadow: 0 0 0 4px rgba(126, 155, 208, .22);
}
.input::placeholder, .textarea::placeholder { color: var(--ink-faint); }
.input[readonly] { background: var(--cream); color: var(--ink-soft); }
.select   { border-radius: var(--r-sm); padding: .72rem .95rem; }
.textarea { border-radius: var(--r); resize: vertical; line-height: 1.5; }

.field { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.label {
  font-weight: 800; font-size: var(--t-micro); color: var(--ink-soft);
  text-transform: uppercase; letter-spacing: .09em;
}

/* An input with a copy affordance sitting inside it. */
.field__inline { position: relative; display: flex; align-items: center; }
.field__inline .input { padding-right: 3rem; }
.field__inline .icon {
  position: absolute; right: 1.05rem; width: 18px; height: 18px;
  color: var(--ink-faint); pointer-events: none;
}

/* ============================================================== 13. notices */

.flash {
  display: flex; align-items: center; gap: var(--s3);
  padding: .8rem 1.15rem; margin-bottom: var(--s4);
  border-radius: var(--r);
  font-weight: 700; font-size: var(--t-small);
  background: var(--white); color: var(--ink);
  border: 1.5px solid var(--line-firm);
  box-shadow: var(--shadow-sm);
  animation: rise .4s var(--ease-spring) both;
  overflow-wrap: anywhere;
}
.flash__badge {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center; border-radius: 50%;
  background: rgba(248, 199, 72, .5); color: #8A6410;
}
.flash__badge .icon { width: 19px; height: 19px; }
.flash--alert { background: #FDF0EA; border-color: rgba(232, 115, 76, .35); color: #8E3417; }
.flash--alert .flash__badge { background: rgba(232, 115, 76, .22); color: #A8431F; }

/* ================================================================ 14. lists */

.list { display: flex; flex-direction: column; gap: var(--s2); }
.list__row {
  display: flex; align-items: center; gap: var(--s3);
  padding: .75rem .95rem;
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: var(--t-small);
  flex-wrap: wrap;
}
.list__row--dim { opacity: .58; }
.list__main { min-width: 0; flex: 1 1 11rem; }
.list__main strong { display: block; overflow-wrap: anywhere; }

.divider { border: none; border-top: 1px solid var(--line); margin: var(--s1) 0; }

/* ========================================================== 15. plain pages */

.plain {
  position: relative; z-index: 1;
  min-height: 100dvh;
  display: grid; place-items: center;
  padding: clamp(var(--s5), 6vw, var(--s7)) var(--s4);
}

.plain__card {
  position: relative;
  width: 100%;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  padding: clamp(1.9rem, 5vw, 2.7rem);
  text-align: center;
  animation: rise var(--slow) var(--ease-spring) both;
}

/* --- the login: her logo, badged onto the card --------------------------- */

.login {
  width: 100%; max-width: 452px;
  --login-emblem: clamp(168px, 52vw, 232px);
  /* How far the card is pushed down: two thirds of the emblem, leaving the
     other third lying over it. */
  --login-emblem-drop: calc(var(--login-emblem) * .66);
}

/* The emblem hangs above the card and sinks about a third of itself into it,
   so the two read as one object rather than a picture with a form under it.
   Both the push-down and the card's top padding are computed from the emblem,
   so resizing it can never leave the greeting tucked under her chin. */
.login__basket { position: relative; padding-top: var(--login-emblem-drop); }
.login__card {
  position: relative; z-index: 0; text-align: left;
  padding-top: calc(var(--login-emblem) - var(--login-emblem-drop) + var(--s4));
}

.login__emblem {
  position: absolute; z-index: 1;
  top: 0; left: 0; right: 0;
  /* Centred by auto margins, NOT by translateX(-50%): the float animation
     owns `transform`, and a keyframe replacing it threw the logo off to one
     side of the card. */
  margin-inline: auto;
  width: var(--login-emblem); height: var(--login-emblem);
  /* Square artwork with white corners — always clipped to its circle. */
  border-radius: 50%;
  object-fit: cover;
  background: var(--white);
  /* A cream ring lifts the circle off the white card without a hard border. */
  box-shadow: 0 0 0 7px var(--cream), 0 3px 6px rgba(47, 74, 130, .07),
              0 22px 44px rgba(47, 74, 130, .20);
  /* Rises and settles, but never tilts — the school's name is written across
     the banner inside it and a lettered mark that leans reads as a mistake. */
  animation: emblem-float 7s ease-in-out infinite;
}
@keyframes emblem-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }

.login__title { font-size: var(--t-display); line-height: 1.05; letter-spacing: -.035em; }
.login__sub { color: var(--ink-soft); font-weight: 700; margin-top: .3rem; }
.login__form { margin-top: var(--s5); display: flex; flex-direction: column; gap: var(--s3); }
.login__foot { margin-top: var(--s4); font-size: var(--t-micro); color: var(--ink-faint); text-align: center; }

.balloon__label { font: 900 5.4px/1 var(--font); letter-spacing: -.02em; }

/* --- what a parent sees when a link has run out -------------------------- */

.gate { max-width: 470px; }
.gate__art { position: relative; width: 210px; margin: 0 auto var(--s4); }
.gate__balloon { width: 100%; display: block; animation: float 6.5s ease-in-out infinite; }
.gate__corgi {
  position: absolute; right: -10%; bottom: -6%; width: 50%;
  animation: float 6.5s ease-in-out infinite .6s;
}
.gate h1 { font-size: clamp(1.35rem, 1.05rem + 1.4vw, 1.75rem); }
.gate__body { color: var(--ink-soft); margin: var(--s3) 0 0; font-size: 1.02rem; line-height: 1.6; }
.gate__aside { margin-top: var(--s4); padding-top: var(--s4); border-top: 1px solid var(--line); font-size: var(--t-small); color: var(--ink-faint); }

/* ========================================================= 16. illustration */

/* The ambient sky on the pages a family lands on. Parallax by speed: the
   far layers move slowly, the near ones a little faster. */
.sky { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.sky__sun {
  position: absolute; top: -3vh; right: -3vw;
  width: clamp(150px, 22vw, 260px);
  animation: spin-slow 90s linear infinite;
  opacity: .92;
}
.sky__cloud { position: absolute; opacity: .95; }
.sky__cloud--a { top: 12%; left: -6%;  width: clamp(180px, 26vw, 330px); animation: drift-x 44s ease-in-out infinite alternate; }
.sky__cloud--b { top: 5%;  left: 26%;  width: clamp(120px, 17vw, 220px); animation: drift-x 62s ease-in-out infinite alternate-reverse; }
.sky__cloud--c { bottom: 8%; right: -4%; width: clamp(170px, 24vw, 300px); animation: drift-x 52s ease-in-out infinite alternate-reverse; }
.sky__cloud--d { bottom: 24%; left: 4%; width: clamp(110px, 15vw, 190px); animation: drift-x 70s ease-in-out infinite alternate; }
.sky__abc {
  position: absolute; top: 22%; right: 8%;
  width: clamp(120px, 16vw, 190px);
  animation: float 9s ease-in-out infinite;
  opacity: .9;
}
.sky__sparkles { position: absolute; }
.sky__sparkles--a { top: 34%; left: 12%; width: 48px; animation: twinkle 5s ease-in-out infinite; }
.sky__sparkles--b { bottom: 18%; right: 20%; width: 36px; animation: twinkle 6.5s ease-in-out infinite 1.2s; }
.abc__glyph { font: 900 30px/1 var(--font); }

.sun__rays { transform-origin: 32px 32px; }
.corgi__spark { animation: twinkle 2.4s ease-in-out infinite; transform-origin: center; }
.teacher__spark { animation: twinkle 2.4s ease-in-out infinite; transform-origin: center; }
/* She actually waves. Slow, off everyone else's clock, and reduced-motion
   collapses it with everything else. */
.teacher__wave { animation: tilt 2.6s ease-in-out infinite; transform-origin: 48px 54px; }
.corgi--music .corgi__ears { animation: ear-bob 1.6s ease-in-out infinite; transform-origin: 32px 30px; }

/* Each star on its own clock — sparkles pulsing in unison read as a machine. */
.sparkles__a { animation: twinkle 3.1s ease-in-out infinite;      transform-origin: 16px 17px; }
.sparkles__b { animation: twinkle 4.3s ease-in-out infinite .7s;  transform-origin: 35px 31px; }
.sparkles__c { animation: twinkle 2.6s ease-in-out infinite 1.4s; transform-origin: 38px 12px; }
.corgi__think { animation: rise-dots 2.6s ease-in-out infinite; }

/* =============================================================== 17. motion */

@keyframes rise      { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes bob       { 0%, 60%, 100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-7px); opacity: 1; } }
@keyframes float     { 0%, 100% { transform: translateY(0) rotate(-1.6deg); } 50% { transform: translateY(-13px) rotate(1.6deg); } }
@keyframes hover-bob { 0%, 100% { transform: translate(-50%, -78%) rotate(-4deg); } 50% { transform: translate(-50%, -94%) rotate(4deg); } }
@keyframes nudge     { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@keyframes tilt      { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg); } }
@keyframes ear-bob   { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } }
@keyframes sway      { 0%, 100% { transform: rotate(-7deg) translateY(0); } 50% { transform: rotate(7deg) translateY(-3px); } }
@keyframes slide     { from { background-position: 220% 0; } to { background-position: 0 0; } }
@keyframes spin-slow { to { transform: rotate(360deg); } }
@keyframes twinkle   { 0%, 100% { opacity: .35; transform: scale(.85); } 50% { opacity: 1; transform: scale(1.08); } }
@keyframes rise-dots { 0%, 100% { opacity: .35; transform: translateY(2px); } 50% { opacity: 1; transform: translateY(-2px); } }
@keyframes cloud-slide { from { transform: translateX(-3px); } to { transform: translateX(5px); } }
@keyframes letters-fall { 0%, 100% { transform: translateY(-2px); } 50% { transform: translateY(4px); } }
@keyframes drift-x   { from { transform: translateX(0); } to { transform: translateX(5vw); } }
@keyframes drift     {
  from { background-position: 5% 14%, 18% 11%, 73% 7%, 86% 13%; }
  to   { background-position: 11% 12%, 12% 14%, 67% 10%, 91% 9%; }
}

/* ======================================================== 18. narrow screens */

@media (max-width: 940px) {
  .dashboard { grid-template-columns: 1fr; }
  .chat { height: min(66dvh, 560px); }
}

@media (max-width: 620px) {
  .topbar { gap: var(--s2); padding: var(--s2) var(--s4); }
  .brand__mark { width: 40px; height: 40px; }
  /* The wordmark yields before the controls do, and can never push the
     header wider than the screen. */
  .brand { min-width: 0; }
  .brand > span { min-width: 0; overflow: hidden; }
  .brand__name { font-size: .98rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .brand__sub { display: none; }
  .nav { flex: none; }
  .navlink { padding: .55rem .7rem; }
  .navlink span { display: none; }
  .navlink .icon { width: 21px; height: 21px; }
  .panel__body, .panel__head { padding: var(--s4); }
  .chat__scroll { padding: var(--s4); }
  .chat__hints { padding: 0 var(--s4) var(--s3); }
  .chat__form { padding: var(--s3) var(--s4); }
  .msg { max-width: 100%; }
  /* A thinner ring: at phone width the emblem is most of the card's width and
     a 7px cream halo starts to read as a border. */
  .login__emblem { box-shadow: 0 0 0 5px var(--cream), 0 16px 32px rgba(47, 74, 130, .18); }
}

/* On a genuinely small phone the mark carries the brand on its own — it is
   the school's actual logo, and the controls matter more than the wordmark. */
@media (max-width: 470px) {
  .brand__name { display: none; }
}

/* A child touches these, and a child's aim is worse than an adult's. */
@media (pointer: coarse) {
  .btn, .navlink, .input, .select { min-height: 48px; }
  .btn--big { min-height: 64px; padding: 1.05rem 2rem; }
  .hint { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}
