:root {
  --cream: #f7f3ea;
  --cream-2: #efe8d8;
  --green: #17614c;
  --green-dark: #0e3d30;
  --ink: #1d2a25;
  --muted: #63736c;
  --olive: #8a9a5b;
  --card: #ffffff;
  --line: #e4dccb;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Cairo', system-ui, sans-serif;
  background: var(--cream);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 18px; background: var(--green-dark);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark { width: 38px; height: 38px; border-radius: 10px; background: var(--cream); object-fit: cover; }
.brand-name { color: var(--cream); font-weight: 800; font-size: 20px; letter-spacing: .3px; }
.nav-actions { display: flex; gap: 8px; align-items: center; }
.nav-actions .who { color: var(--cream-2); font-size: 14px; margin-inline-end: 6px; }
.btn {
  display: inline-block; border: none; cursor: pointer; text-decoration: none;
  font-family: inherit; font-weight: 700; font-size: 15px;
  padding: 9px 18px; border-radius: 12px; transition: transform .08s ease, opacity .15s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { opacity: .92; }
.btn-ghost { background: transparent; color: var(--cream); border: 1.5px solid rgba(247,243,234,.45); }
.btn-ghost:hover { border-color: var(--cream); }
.btn-big { font-size: 17px; padding: 13px 30px; border-radius: 14px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: default; }
main { flex: 1; width: 100%; max-width: 920px; margin: 0 auto; padding: 24px 16px 48px; }
.hero { text-align: center; padding: 34px 10px 10px; }
.hero img { width: min(300px, 70vw); border-radius: 24px; box-shadow: 0 14px 40px rgba(14,61,48,.18); }
.hero h1 { font-size: clamp(26px, 5vw, 38px); margin: 22px 0 8px; color: var(--green-dark); font-weight: 800; }
.hero p { color: var(--muted); font-size: 17px; max-width: 560px; margin: 0 auto 22px; line-height: 1.8; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 34px 0; }
.feature { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px; text-align: center; }
.feature .fic { font-size: 26px; }
.feature h3 { margin: 8px 0 6px; color: var(--green-dark); font-size: 17px; }
.feature p { color: var(--muted); font-size: 14px; line-height: 1.7; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 22px; }
.auth-card { max-width: 440px; margin: 30px auto; }
.auth-card h2 { color: var(--green-dark); margin-bottom: 4px; }
.auth-card .sub { color: var(--muted); font-size: 14px; margin-bottom: 18px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 700; font-size: 14px; margin-bottom: 6px; color: var(--green-dark); }
.field input, .field select {
  width: 100%; padding: 11px 14px; border: 1.5px solid var(--line); border-radius: 12px;
  font-family: inherit; font-size: 15px; background: #fff; color: var(--ink);
}
.field input:focus, .field select:focus { outline: 2px solid var(--green); border-color: var(--green); }
.form-err { background: #fdecea; color: #a33; border-radius: 10px; padding: 10px 14px; font-size: 14px; margin-bottom: 12px; }
.form-note { text-align: center; margin-top: 14px; font-size: 14px; color: var(--muted); }
.form-note a { color: var(--green); font-weight: 700; }
.section-title { color: var(--green-dark); font-size: 22px; margin: 6px 0 4px; font-weight: 800; }
.section-sub { color: var(--muted); margin-bottom: 18px; font-size: 15px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.subject { text-align: right; text-decoration: none; color: inherit; display: block; }
.subject .card { height: 100%; transition: box-shadow .15s, transform .15s; }
.subject:hover .card { box-shadow: 0 8px 26px rgba(14,61,48,.12); transform: translateY(-2px); }
.subject h3 { color: var(--green-dark); font-size: 17px; }
.subject p { color: var(--muted); font-size: 13.5px; margin-top: 6px; line-height: 1.7; }
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; margin-top: 10px; }
.badge-ready { background: #e6f2ec; color: var(--green); }
.badge-soon { background: var(--cream-2); color: var(--muted); }
.chapter { margin-bottom: 14px; }
.chapter summary {
  cursor: pointer; list-style: none; background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 14px 18px; font-weight: 700; color: var(--green-dark); font-size: 16px;
}
.chapter summary::-webkit-details-marker { display: none; }
.chapter[open] summary { border-radius: 14px 14px 0 0; border-bottom: none; background: var(--cream-2); }
.chapter .body { background: var(--card); border: 1px solid var(--line); border-top: none; border-radius: 0 0 14px 14px; padding: 14px 20px; }
.chapter .body ul { padding-inline-start: 20px; }
.chapter .body li { margin-bottom: 8px; line-height: 1.85; font-size: 15px; }
.memorize { background: #fdf6e3; border: 1px solid #eadfae; border-radius: 16px; padding: 18px 20px; margin: 22px 0; line-height: 1.9; }
.memorize h3 { color: #8a6d1d; font-size: 16px; margin-bottom: 6px; }
.quiz-item { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 18px; margin-bottom: 10px; }
.quiz-item .q { font-weight: 700; color: var(--green-dark); }
.quiz-item .a { margin-top: 8px; color: var(--muted); display: none; line-height: 1.8; }
.quiz-item.open .a { display: block; }
.quiz-item .toggle { margin-top: 8px; background: none; border: none; color: var(--olive); font-family: inherit; font-weight: 700; cursor: pointer; font-size: 14px; padding: 0; }
.chat-wrap { max-width: 680px; margin: 0 auto; display: flex; flex-direction: column; height: calc(100vh - 180px); min-height: 420px; }
.chat-log { flex: 1; overflow-y: auto; padding: 10px 2px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 85%; padding: 12px 16px; border-radius: 16px; line-height: 1.85; font-size: 15px; white-space: pre-wrap; }
.msg.user { align-self: flex-start; background: var(--green); color: #fff; border-bottom-right-radius: 4px; }
.msg.bot { align-self: flex-end; background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.bot.typing { color: var(--muted); }
.chat-form { display: flex; gap: 8px; margin-top: 10px; }
.chat-form input { flex: 1; padding: 12px 16px; border: 1.5px solid var(--line); border-radius: 14px; font-family: inherit; font-size: 15px; }
.chat-form input:focus { outline: 2px solid var(--green); border-color: var(--green); }
.chat-hint { text-align: center; color: var(--muted); font-size: 12.5px; margin-top: 8px; }
.empty-note { text-align: center; color: var(--muted); padding: 40px 10px; line-height: 2; }
.footer { text-align: center; padding: 18px; color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); }
.flash { background: #e6f2ec; color: var(--green-dark); border-radius: 12px; padding: 12px 16px; margin-bottom: 16px; font-size: 14.5px; }

/* ===== animated hero (keyboard -> Z -> logo burst) ===== */
.hero2 {
  position: relative; overflow: hidden; text-align: center;
  margin: -24px calc(50% - 50vw) 0;
  padding: 0 16px 34px;
  background: radial-gradient(ellipse at 50% 28%, #16402f 0%, #0b221a 52%, #050f0c 100%);
  color: var(--cream);
}
.hero-stage { position: relative; height: 430px; max-width: 560px; margin: 0 auto; }
.plx { position: absolute; left: 50%; top: 0; will-change: transform; }

/* logo */
.mark-pop { transform: translateX(-50%); }
.mark-pop img { width: 300px; height: auto; display: block; filter: drop-shadow(0 18px 34px rgba(0,0,0,.45)); }

/* flash behind the logo on burst */
.hero-flash {
  position: absolute; left: 50%; top: 90px; width: 380px; height: 380px;
  margin-left: -190px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(190,255,150,.4) 0%, rgba(120,200,110,.14) 45%, transparent 70%);
  opacity: 0;
}

/* floating olives / leaves / sparks (CSS-drawn, no images) */
.flo { pointer-events: none; }
.floater { display: block; }
.olive {
  width: 26px; height: 33px; border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #c9d977 0%, #8a9a5b 45%, #5c6b35 100%);
  box-shadow: 0 4px 10px rgba(0,0,0,.35);
}
.olive.sm { width: 19px; height: 24px; }
.leaf {
  width: 34px; height: 13px; border-radius: 100% 4px 100% 4px;
  background: linear-gradient(135deg, #7d9070 0%, #42563c 100%);
  box-shadow: 0 3px 8px rgba(0,0,0,.3);
}
.leaf.flip { transform: scaleX(-1); }
.spark {
  width: 7px; height: 7px; border-radius: 50%;
  background: radial-gradient(circle, #e6ffb8 0%, rgba(160,220,120,.0) 75%);
  box-shadow: 0 0 12px 4px rgba(170,230,130,.5);
}
.o1w { left: 16%; top: 60px; }
.o2w { left: 82%; top: 130px; }
.o3w { left: 74%; top: 30px; }
.l1w { left: 10%; top: 170px; }
.l2w { left: 88%; top: 60px; }
.s1w { left: 28%; top: 40px; }
.s2w { left: 68%; top: 180px; }

/* keyboard */
.kb-plx { top: 236px; }
.kb-tilt { transform: translateX(-50%) perspective(750px) rotateX(46deg); transform-style: preserve-3d; }
.kb { display: inline-block; padding: 14px 16px; border-radius: 14px;
  background: linear-gradient(180deg, #101915 0%, #080f0c 100%);
  border: 1px solid rgba(255,255,255,.07);
  box-shadow: 0 24px 50px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.05);
  cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent;
}
.kb-row { display: flex; gap: 5px; margin-bottom: 5px; justify-content: center; }
.kb-row:last-child { margin-bottom: 0; }
.key {
  width: 30px; height: 30px; border-radius: 6px;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700; color: #4d5f55;
  background: linear-gradient(180deg, #1c2721 0%, #121a16 100%);
  border: 1px solid rgba(255,255,255,.05);
  box-shadow: 0 3px 0 #050907, 0 4px 6px rgba(0,0,0,.4);
}
.key.glow-dim { color: #7fa06a; box-shadow: 0 3px 0 #050907, 0 0 9px rgba(140,200,120,.28); }
.key.key-z {
  color: #e2f7c8; font-size: 13px; font-weight: 800;
  border-color: rgba(150,220,120,.55);
  background: linear-gradient(180deg, #233a24 0%, #14231a 100%);
  box-shadow: 0 3px 0 #050907, 0 0 16px rgba(140,220,110,.55);
}
.hero2.anim .key.key-z { animation: zPulse 2.2s ease-in-out infinite; }
.key.key-z.pressed {
  transform: translateY(3px);
  box-shadow: 0 0 0 #050907, 0 0 26px rgba(150,235,115,.9);
}
@keyframes zPulse {
  0%, 100% { box-shadow: 0 3px 0 #050907, 0 0 12px rgba(140,220,110,.45); }
  50% { box-shadow: 0 3px 0 #050907, 0 0 22px rgba(150,235,115,.85); }
}

/* headline + copy on dark */
.hero-title { font-size: clamp(30px, 7vw, 44px); font-weight: 800; margin: 4px 0 10px; color: var(--cream); }
.hero-title .w { display: inline-block; }
.hero-sub { color: #b3c2b8; font-size: 16px; max-width: 540px; margin: 0 auto 20px; line-height: 1.85; }
.hero-cta {
  background: #1e8a5f; color: #fff; font-size: 17px; font-weight: 800;
  padding: 13px 34px; border-radius: 14px; display: inline-block; text-decoration: none;
  box-shadow: 0 0 0 rgba(60,200,140,0), 0 10px 26px rgba(0,0,0,.35);
  animation: ctaGlow 2.6s ease-in-out 1.6s infinite;
}
.hero-cta:hover { background: #22a06d; }
@keyframes ctaGlow {
  0%, 100% { box-shadow: 0 0 14px rgba(60,200,140,.25), 0 10px 26px rgba(0,0,0,.35); }
  50% { box-shadow: 0 0 26px rgba(60,200,140,.55), 0 10px 26px rgba(0,0,0,.35); }
}

/* ===== burst choreography (only when motion allowed: .anim) ===== */
.hero2.anim .mark-pop { opacity: 0; transform: translateX(-50%) scale(.2) rotate(-20deg); }
.hero2.anim .floater { opacity: 0; }
.hero2.anim .hero-title .w,
.hero2.anim .hero-sub,
.hero2.anim .hero-cta { opacity: 0; transform: translateY(16px); }

.hero2.anim.burst .mark-pop { animation: markPop .75s cubic-bezier(.2,1.35,.4,1) both; }
.hero2.anim.burst .mark-bob { animation: bob 6s ease-in-out .8s infinite; }
.hero2.anim.burst .hero-flash { animation: flashOut .9s ease-out both; }
.hero2.anim.burst .floater { animation: floIn .7s var(--fd, .1s) both, floaty 6s ease-in-out calc(var(--fd, .1s) + .75s) infinite; }
.o1w .floater { --fd: .12s; } .o2w .floater { --fd: .22s; } .o3w .floater { --fd: .3s; }
.l1w .floater { --fd: .38s; } .l2w .floater { --fd: .45s; }
.s1w .floater { --fd: .05s; } .s2w .floater { --fd: .16s; }
.hero2.anim.burst .hero-title .w { animation: wordIn .55s both; }
.hero2.anim.burst .hero-title .w:nth-child(1) { animation-delay: .4s; }
.hero2.anim.burst .hero-title .w:nth-child(2) { animation-delay: .52s; }
.hero2.anim.burst .hero-title .w:nth-child(3) { animation-delay: .64s; }
.hero2.anim.burst .hero-sub { animation: wordIn .6s .85s both; }
.hero2.anim.burst .hero-cta { animation: wordIn .6s 1s both, ctaGlow 2.6s ease-in-out 2s infinite; }

@keyframes markPop {
  0% { opacity: 0; transform: translateX(-50%) scale(.2) rotate(-20deg); }
  60% { opacity: 1; transform: translateX(-50%) scale(1.09) rotate(3deg); }
  80% { transform: translateX(-50%) scale(.97) rotate(-1deg); }
  100% { opacity: 1; transform: translateX(-50%) scale(1) rotate(0); }
}
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes floIn { 0% { opacity: 0; transform: translateY(46px) scale(.2); } 100% { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes floaty { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }
@keyframes flashOut { 0% { opacity: .9; transform: scale(.35); } 100% { opacity: 0; transform: scale(1.5); } }
@keyframes wordIn { 0% { opacity: 0; transform: translateY(16px); } 100% { opacity: 1; transform: translateY(0); } }

@media (max-width: 480px) {
  .hero-stage { height: 372px; }
  .mark-pop img { width: 220px; }
  .kb-plx { top: 218px; }
  .key { width: 24px; height: 24px; font-size: 9.5px; border-radius: 5px; }
  .key.key-z { font-size: 11.5px; }
  .kb { padding: 11px 12px; }
  .hero-sub { font-size: 15px; }
}
