/* ===== Lean brand tokens (Brand Guidelines) ===== */
@font-face { font-family: 'Cairo'; font-weight: 300; font-display: swap; src: url('/static/fonts/cairo-300.woff2') format('woff2'); }
@font-face { font-family: 'Cairo'; font-weight: 400; font-display: swap; src: url('/static/fonts/cairo-400.woff2') format('woff2'); }
@font-face { font-family: 'Cairo'; font-weight: 600; font-display: swap; src: url('/static/fonts/cairo-600.woff2') format('woff2'); }
@font-face { font-family: 'Cairo'; font-weight: 700; font-display: swap; src: url('/static/fonts/cairo-700.woff2') format('woff2'); }
@font-face { font-family: 'Cairo'; font-weight: 900; font-display: swap; src: url('/static/fonts/cairo-900.woff2') format('woff2'); }

:root {
  --blue: #263A8A;
  --navy: #222449;
  --off: #F3F3F2;
  --green: #22AE88;
  --gray: #54575B;
  --gray-l: #B3B4B3;
  --teal: #0081A5;
  --yellow: #F9B450;

  --line-soft: rgba(34, 36, 73, 0.14);
  --cell: 30px;
  --radius: 24px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Cairo', Helvetica, Arial, sans-serif;
  font-weight: 400;
  font-size: 17px;
  line-height: 1.7;
  color: var(--navy);
  background-color: var(--blue);
  /* the brand grid, as a quiet pattern */
  background-image:
    linear-gradient(rgba(243, 243, 242, .06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(243, 243, 242, .06) 1px, transparent 1px);
  background-size: var(--cell) var(--cell);
  background-position: center top;
  overflow-x: hidden;
}

img, svg { display: block; max-width: 100%; }
button, input, textarea { font: inherit; color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid var(--yellow); outline-offset: 3px; border-radius: 6px; }
.panel :focus-visible { outline-color: var(--teal); }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ===== shapes (line device: parallel lines, rounded ends) ===== */
.shape { display: block; flex: none; }
.shape svg { width: 100%; height: 100%; overflow: visible; }
.c-green { color: var(--green); }
.c-yellow { color: var(--yellow); }
.c-teal { color: var(--teal); }
.c-blue { color: var(--blue); }
.c-navy { color: var(--navy); }
.c-off { color: var(--off); }

/* ===== hero ===== */
.hero {
  position: relative;
  max-width: 1040px;
  margin: 0 auto;
  padding: 26px 22px 88px;
  color: var(--off);
}
.hero__top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; position: relative; z-index: 2; }
.logo { width: 52px; height: auto; }

.chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 16px 6px 10px;
  border: 2px solid rgba(243, 243, 242, .5);
  border-radius: 999px;
  font-weight: 600; font-size: 15px;
  animation: rise .6s var(--ease) both .2s;
}
.chip__dot { width: 10px; height: 10px; border-radius: 50%; background: var(--green); }

.hero__title {
  position: relative; z-index: 2;
  margin: 18px 0 6px;
  font-weight: 900;
  font-size: clamp(46px, 11vw, 96px);
  line-height: 1.15;
  letter-spacing: 0;
  animation: rise .7s var(--ease) both;
}
.hero__title .hl { color: var(--yellow); display: inline-block; animation: wiggle 4s ease-in-out 1.2s infinite; }
.hero__sub {
  position: relative; z-index: 2;
  margin: 0; max-width: 560px;
  font-weight: 600; font-size: clamp(17px, 3.4vw, 21px); line-height: 1.7;
  animation: rise .7s var(--ease) both .1s;
}
.hero--compact { padding-bottom: 72px; }
.hero--compact .hero__title { font-size: clamp(34px, 7vw, 56px); }

/* Shapes sit in free zones: top band and bottom band on phones, the left side on wide screens. */
.hero__deco { position: absolute; inset: 0; pointer-events: none; z-index: 0; }
.deco { position: absolute; animation: float 7s ease-in-out infinite; }
.deco--1 { width: 112px; height: 112px; left: 6%; bottom: -26px; animation-duration: 8s; }
.deco--2 { width: 74px; height: 74px; left: 40%; top: 6px; animation-delay: -2s; }
.deco--3 { width: 120px; height: 120px; right: 12%; bottom: -34px; animation-delay: -4s; animation-duration: 9s; }
.deco--4 { width: 54px; height: 54px; left: 46%; bottom: 34px; animation-delay: -1s; }
.deco--5 { display: none; }
@media (min-width: 900px) {
  .hero { padding-bottom: 72px; }
  .deco--1 { width: 170px; height: 170px; left: 2%; top: 150px; bottom: auto; }
  .deco--2 { width: 96px; height: 96px; left: 15%; top: 30px; }
  .deco--3 { width: 170px; height: 170px; left: 19%; right: auto; top: 160px; bottom: auto; }
  .deco--4 { width: 66px; height: 66px; left: 25%; top: 56px; bottom: auto; }
  .deco--5 { display: block; width: 66px; height: 66px; left: 4%; top: 40px; animation-delay: -5s; }
  .hero--compact .deco--1 { width: 120px; height: 120px; top: 70px; }
  .hero--compact .deco--2 { top: 20px; }
  .hero--compact .deco--3 { width: 130px; height: 130px; top: 90px; }
  .hero--compact .deco--4, .hero--compact .deco--5 { display: none; }
}

/* ===== panel (off-white sheet with the striped shadow device) ===== */
.panel {
  position: relative; z-index: 0;
  max-width: 760px;
  margin: -34px 18px 0;
  padding: 28px 20px 30px;
  border-radius: var(--radius);
  min-height: 260px;
}
@media (min-width: 820px) { .panel { margin: 0 auto; padding: 40px 44px 44px; } }
/* ::before = striped shadow, ::after = the off-white sheet on top of it */
.panel::before, .panel::after, .kid::before, .kid::after {
  content: ''; position: absolute; inset: 0; z-index: -1; border-radius: inherit;
}
.panel::before { transform: translate(-12px, 12px); background: repeating-linear-gradient(0deg, var(--green) 0 2.4px, transparent 2.4px 4.29px); }
.panel::after { background: var(--off); }
.panel--wide { max-width: 1100px; }

.view { animation: rise .5s var(--ease) both; }
.view:focus { outline: none; }
.h2 { margin: 0 0 4px; font-weight: 900; font-size: clamp(26px, 5vw, 34px); line-height: 1.35; }
.lead { margin: 0 0 22px; font-weight: 600; font-size: 18px; color: var(--gray); }
.muted { color: var(--gray); font-weight: 300; font-size: 14px; }

/* ===== steps ===== */
.steps { display: flex; list-style: none; margin: 0 0 28px; padding: 0; }
.steps li { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 600; font-size: 14px; color: var(--gray); }
.steps li:last-child { flex: none; }
.steps__n {
  flex: none; width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 900; font-size: 15px;
  border: 2px solid var(--gray-l); background: var(--off); color: var(--gray);
  transition: all .3s var(--ease);
}
.steps__t { white-space: nowrap; }
.steps__line { flex: 1; height: 4px; min-width: 14px; border-radius: 4px; background: var(--gray-l); opacity: .5; position: relative; overflow: hidden; margin-inline: 4px; }
.steps__line::after { content: ''; position: absolute; inset: 0; background: var(--green); transform: scaleX(0); transform-origin: right; transition: transform .45s var(--ease); }
.steps li.is-done .steps__n { background: var(--green); border-color: var(--green); color: var(--navy); }
.steps li.is-done .steps__line { opacity: 1; }
.steps li.is-done .steps__line::after { transform: scaleX(1); }
.steps li.is-now .steps__n { background: var(--blue); border-color: var(--blue); color: var(--off); transform: scale(1.12); }
.steps li.is-now .steps__t { color: var(--navy); font-weight: 900; }
@media (max-width: 520px) { .steps__t { display: none; } .steps li.is-now .steps__t { display: inline; } }

/* ===== kids ===== */
.kids { display: grid; gap: 14px; margin: 0 0 24px; padding: 0; list-style: none; }
@media (min-width: 640px) { .kids { grid-template-columns: 1fr 1fr; } }

.kid {
  position: relative; z-index: 0;
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px;
  padding: 16px 18px;
  border-radius: 20px;
  cursor: pointer; user-select: none;
  transition: transform .25s var(--ease);
}
.kid::before {
  transform: translate(-6px, 6px) scale(.98); opacity: 0;
  background: repeating-linear-gradient(0deg, var(--green) 0 2.4px, transparent 2.4px 4.29px);
  transition: all .3s var(--ease);
}
.kid::after { background: var(--off); box-shadow: inset 0 0 0 2px var(--line-soft); transition: box-shadow .2s; }
.kid:hover { transform: translateY(-2px); }
.kid:hover::after { box-shadow: inset 0 0 0 2px rgba(34, 36, 73, .35); }
.kid.is-on::after { box-shadow: inset 0 0 0 3px var(--green); }
.kid.is-on::before { opacity: 1; transform: translate(-6px, 6px); }
.kid:has(:focus-visible) { outline: 3px solid var(--teal); outline-offset: 4px; }
.kid__input { position: absolute; opacity: 0; pointer-events: none; }
.kid__avatar { width: 62px; height: 62px; transition: transform .4s var(--ease); }
.kid.is-on .kid__avatar { animation: pop .5s var(--ease); }
.kid__name { display: block; font-weight: 900; font-size: 19px; line-height: 1.4; overflow-wrap: anywhere; }
.kid__meta { display: block; font-weight: 600; font-size: 14px; color: var(--gray); }
.kid__check {
  width: 32px; height: 32px; border-radius: 50%;
  border: 2px solid var(--gray-l);
  display: grid; place-items: center;
  transition: all .25s var(--ease);
}
.kid__check svg { width: 18px; height: 18px; transform: scale(0); transition: transform .3s var(--ease); }
.kid.is-on .kid__check { background: var(--green); border-color: var(--green); }
.kid.is-on .kid__check svg { transform: scale(1); }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 14px; flex-wrap: wrap; }
.linkbtn { background: none; border: 0; padding: 6px 4px; cursor: pointer; font-weight: 700; font-size: 15px; color: var(--blue); text-decoration: underline; text-underline-offset: 4px; }
.count-pill { font-weight: 700; font-size: 14px; background: var(--navy); color: var(--off); padding: 2px 14px; border-radius: 999px; }

/* ===== buttons ===== */
.actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-top: 8px; }
.btn {
  appearance: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 54px; padding: 10px 30px;
  border: 0; border-radius: 999px;
  font-weight: 900; font-size: 18px; text-decoration: none;
  background: var(--green); color: var(--navy);
  box-shadow: 0 5px 0 var(--navy);
  transition: transform .15s var(--ease), box-shadow .15s var(--ease), opacity .2s;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 7px 0 var(--navy); }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--navy); }
.btn[disabled] { cursor: not-allowed; background: var(--gray-l); box-shadow: 0 5px 0 var(--gray); opacity: .75; transform: none; }
.btn--ghost { background: transparent; box-shadow: none; border: 2px solid var(--navy); font-weight: 700; padding: 8px 24px; }
.btn--ghost:hover { background: rgba(34, 36, 73, .08); box-shadow: none; }
.btn--yellow { background: var(--yellow); }
.btn.is-busy { pointer-events: none; opacity: .85; }
.btn svg { width: 22px; height: 22px; }
.btn__arrow { transform: scaleX(-1); } /* arrows point to the reading direction in RTL */

/* ===== letters (message step) ===== */
.letters { display: grid; gap: 18px; margin-bottom: 22px; }
.letter {
  position: relative;
  padding: 18px 18px 14px;
  border: 2px solid var(--line-soft);
  border-radius: 20px;
  animation: rise .5s var(--ease) both;
}
.letter__head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.letter__head .shape { width: 46px; height: 46px; }
.letter__to { font-weight: 600; font-size: 14px; color: var(--gray); line-height: 1.3; }
.letter__name { font-weight: 900; font-size: 20px; line-height: 1.3; overflow-wrap: anywhere; }
.field {
  width: 100%; min-height: 128px; resize: vertical;
  padding: 14px 16px;
  border: 2px solid var(--line-soft); border-radius: 16px;
  background: var(--off);
  font-size: 17px; line-height: 1.8;
  transition: border-color .2s, box-shadow .2s;
}
.field::placeholder { color: var(--gray); opacity: .7; font-weight: 300; }
.field:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 4px rgba(38, 58, 138, .15); }
.field.is-bad { border-color: var(--navy); box-shadow: 0 0 0 4px rgba(249, 180, 80, .55); }
.letter__foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 8px; min-height: 28px; }
.counter { font-weight: 700; font-size: 13px; padding: 1px 12px; border-radius: 999px; background: rgba(34, 36, 73, .08); transition: background .2s; }
.counter.is-warn { background: var(--yellow); }
.counter.is-max { background: var(--navy); color: var(--off); }
.hint { font-size: 14px; font-weight: 600; color: var(--gray); }

/* ===== recap ===== */
.recap { list-style: none; margin: 0 0 22px; padding: 0; display: grid; gap: 14px; }
.recap__item { display: grid; grid-template-columns: auto 1fr; gap: 14px; padding: 14px 16px; border: 2px solid var(--line-soft); border-radius: 20px; animation: rise .5s var(--ease) both; }
.recap__item .shape { width: 52px; height: 52px; }
.recap__name { font-weight: 900; font-size: 19px; line-height: 1.4; overflow-wrap: anywhere; }
.recap__meta { display: block; font-weight: 600; font-size: 14px; line-height: 1.4; color: var(--gray); margin-bottom: 4px; }
.counter { direction: ltr; unicode-bidi: isolate; }
.quote {
  margin: 6px 0 0; padding: 4px 14px;
  border-inline-start: 5px solid var(--green);
  border-radius: 3px;
  white-space: pre-wrap; overflow-wrap: anywhere;
  font-weight: 400; font-size: 16px; line-height: 1.8;
}
.warnbox {
  display: flex; gap: 12px; align-items: flex-start;
  margin: 0 0 22px; padding: 14px 16px;
  border-radius: 16px; background: var(--navy); color: var(--off);
  font-weight: 600; font-size: 15px; line-height: 1.7;
}
.warnbox .shape { width: 28px; height: 28px; margin-top: 2px; }
.errorbox { margin: 0 0 18px; padding: 12px 16px; border-radius: 14px; background: var(--yellow); font-weight: 700; font-size: 15px; }

/* ===== success / states ===== */
.center { text-align: center; }
.burst { width: 132px; height: 132px; margin: 0 auto 10px; position: relative; animation: pop .8s var(--ease) both; }
.burst > .shape { width: 100%; height: 100%; }
.burst .tick { position: absolute; inset: 0; display: grid; place-items: center; }
.burst .tick svg { width: 56px; height: 56px; }
.burst .tick path { stroke-dasharray: 60; stroke-dashoffset: 60; animation: draw .6s ease-out .5s forwards; }
.success-title { margin: 6px 0 4px; font-weight: 900; font-size: clamp(30px, 7vw, 44px); line-height: 1.3; }
.success-sub { margin: 0 0 26px; font-weight: 600; font-size: 19px; color: var(--gray); }
.recap--center { text-align: start; }
.state-shape { width: 120px; height: 120px; margin: 0 auto 8px; animation: float 6s ease-in-out infinite; }
.who { margin: 18px 0 0; font-size: 14px; }

#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 50; }

.loading { display: flex; gap: 14px; justify-content: center; align-items: center; min-height: 200px; }
.loading .shape { width: 40px; height: 40px; animation: bounce 1s ease-in-out infinite; }
.loading .shape:nth-child(2) { animation-delay: .15s; }
.loading .shape:nth-child(3) { animation-delay: .3s; }

/* ===== footer ===== */
.foot { max-width: 760px; margin: 0 auto; padding: 30px 22px 40px; text-align: center; color: var(--off); font-weight: 300; font-size: 14px; display: grid; gap: 4px; }
.foot a { font-weight: 600; text-underline-offset: 4px; }
.foot--wide { max-width: 1100px; }

/* ===== admin ===== */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-bottom: 22px; }
@media (min-width: 820px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { position: relative; padding: 16px 18px; border-radius: 20px; background: var(--blue); color: var(--off); overflow: hidden; }
.stat:nth-child(2) { background: var(--navy); }
.stat:nth-child(3) { background: var(--green); color: var(--navy); }
.stat:nth-child(4) { background: var(--teal); }
.stat__n { font-weight: 900; font-size: 42px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat__l { font-weight: 600; font-size: 14px; }
.progress { height: 14px; border-radius: 14px; background: rgba(34, 36, 73, .12); overflow: hidden; margin: 0 0 6px; }
.progress__bar { height: 100%; width: 0; border-radius: 14px; background: var(--green); transition: width 1s var(--ease); }
.card { padding: 20px; border: 2px solid var(--line-soft); border-radius: 20px; margin-bottom: 22px; }
.card h3 { margin: 0 0 4px; font-weight: 900; font-size: 22px; }
.drop {
  display: grid; place-items: center; gap: 6px; text-align: center;
  padding: 26px 16px; margin-top: 12px;
  border: 3px dashed var(--gray-l); border-radius: 20px;
  cursor: pointer; transition: all .2s;
  font-weight: 600;
}
.drop:hover, .drop.is-over { border-color: var(--green); background: rgba(34, 174, 136, .1); }
.drop .shape { width: 46px; height: 46px; }
.preview { margin-top: 16px; padding: 16px; border-radius: 16px; background: rgba(38, 58, 138, .08); }
.preview__nums { display: flex; flex-wrap: wrap; gap: 8px 22px; margin: 6px 0 12px; font-weight: 600; }
.preview__nums b { font-weight: 900; font-size: 22px; margin-inline-end: 4px; }
.warnlist { margin: 8px 0 14px; padding-inline-start: 20px; max-height: 180px; overflow: auto; font-size: 14px; color: var(--gray); font-weight: 600; }
.form { display: grid; gap: 16px; margin-top: 14px; }
@media (min-width: 700px) { .form { grid-template-columns: 1fr 1fr; } .form > .switch, .form > .actions, .form > #settingsMsg { grid-column: 1 / -1; } }
.fld { display: grid; gap: 6px; align-content: start; }
.fld--pair { grid-template-columns: 1fr 1fr; gap: 12px; }
.fld__l { font-weight: 700; font-size: 15px; }
.input { width: 100%; min-height: 48px; padding: 6px 16px; border: 2px solid var(--line-soft); border-radius: 14px; background: var(--off); font-size: 17px; }
.input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 4px rgba(38, 58, 138, .15); }
.input::placeholder { color: var(--gray); opacity: .7; font-weight: 300; }
.switch { display: flex; align-items: center; gap: 12px; font-weight: 600; cursor: pointer; }
.switch input { width: 24px; height: 24px; accent-color: var(--green); flex: none; cursor: pointer; }
.okbox { padding: 12px 16px; border-radius: 14px; background: var(--green); font-weight: 700; font-size: 15px; }
.search { width: 100%; max-width: 340px; min-height: 44px; padding: 6px 16px; border: 2px solid var(--line-soft); border-radius: 999px; background: var(--off); }
.search:focus { outline: none; border-color: var(--blue); }
.tablewrap { overflow-x: auto; border-radius: 16px; border: 2px solid var(--line-soft); margin-top: 12px; }
table { border-collapse: collapse; width: 100%; font-size: 15px; }
th { position: sticky; top: 0; background: var(--blue); color: var(--off); font-weight: 700; text-align: start; padding: 10px 14px; white-space: nowrap; }
td { padding: 10px 14px; vertical-align: top; border-top: 1px solid var(--line-soft); }
td.msg { min-width: 260px; max-width: 420px; white-space: pre-wrap; overflow-wrap: anywhere; }
.empty { padding: 26px; text-align: center; font-weight: 600; color: var(--gray); }

/* ===== dev login ===== */
.devbadge { display: inline-block; margin-bottom: 10px; padding: 2px 14px; border-radius: 999px; background: var(--yellow); font-weight: 900; font-size: 13px; }
.userlist { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 10px; max-height: 50vh; overflow: auto; }
.userlist button { width: 100%; text-align: start; padding: 12px 16px; border-radius: 16px; border: 2px solid var(--line-soft); background: var(--off); cursor: pointer; font-weight: 600; }
.userlist button:hover { border-color: var(--green); }
.userlist small { display: block; color: var(--gray); font-weight: 300; }

/* ===== motion ===== */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes float { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-14px) rotate(6deg); } }
@keyframes wiggle { 0%, 88%, 100% { transform: rotate(0); } 92% { transform: rotate(-4deg); } 96% { transform: rotate(3deg); } }
@keyframes pop { 0% { transform: scale(.6); } 60% { transform: scale(1.14); } 100% { transform: scale(1); } }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-16px); } }
@keyframes draw { to { stroke-dashoffset: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .burst .tick path { stroke-dashoffset: 0; }
}
