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

:root {
  --bg-top: #eef4ff;
  --bg-bottom: #dcefff;
  --card: #ffffff;
  --ink: #1b2a4a;
  --ink-soft: #5a6b8c;
  --primary: #5b6cff;
  --primary-2: #7c6cff;
  --cyan: #19c3e6;
  --pink: #ff4f9a;
  --orange: #ff8a3d;
  --green: #22c58b;
  --yellow: #ffc93d;
  --purple: #9b59f5;
  --teal: #14b8a6;
  --navy: #16233f;
  --radius: 26px;
  --shadow: 0 10px 30px rgba(27, 42, 74, 0.1);
  --shadow-lg: 0 18px 44px rgba(27, 42, 74, 0.16);
  --font-display: "Baloo 2", "Segoe UI", "Nirmala UI", system-ui, sans-serif;
  --font-body: "Nunito", "Segoe UI", "Nirmala UI", system-ui, sans-serif;
}

html,
body {
  height: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(600px 300px at 8% -5%, rgba(124, 108, 255, 0.16), transparent 70%),
    radial-gradient(500px 300px at 95% 0%, rgba(25, 195, 230, 0.16), transparent 70%),
    radial-gradient(700px 420px at 50% 115%, rgba(255, 79, 154, 0.1), transparent 70%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
  background-attachment: fixed;
  overflow-x: hidden;
}

h1, h2, h3, .brand, .tile .label, .page-title {
  font-family: var(--font-display);
}

/* floating decorations */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
}
.app-shell::before,
.app-shell::after {
  content: "✦";
  position: fixed;
  font-size: 1.4rem;
  color: rgba(91, 108, 255, 0.25);
  animation: float 7s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
}
.app-shell::before {
  top: 18%;
  left: 5%;
}
.app-shell::after {
  top: 60%;
  right: 6%;
  animation-delay: 2.5s;
  color: rgba(255, 79, 154, 0.25);
}
@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-18px) rotate(20deg); }
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 22px;
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(91, 108, 255, 0.12);
}
.topbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.35rem;
  text-decoration: none;
  color: var(--ink);
}
.topbar .brand .logo {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), var(--cyan));
  box-shadow: 0 6px 16px rgba(91, 108, 255, 0.35);
}
.topbar .spacer {
  flex: 1;
}
.topbar .clock {
  font-weight: 800;
  font-size: 1rem;
  color: var(--primary);
  background: rgba(91, 108, 255, 0.1);
  padding: 8px 16px;
  border-radius: 999px;
}
.lang-switch {
  display: flex;
  gap: 4px;
  background: rgba(91, 108, 255, 0.1);
  border-radius: 999px;
  padding: 4px;
}
.lang-switch button {
  border: none;
  background: transparent;
  padding: 7px 13px;
  border-radius: 999px;
  font-weight: 800;
  cursor: pointer;
  font-size: 0.92rem;
  color: var(--ink-soft);
  font-family: var(--font-body);
  transition: all 0.15s;
}
.lang-switch button.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  box-shadow: 0 4px 12px rgba(91, 108, 255, 0.4);
}

/* ---------- notification ticker ---------- */
.ticker {
  background: linear-gradient(90deg, rgba(255, 201, 61, 0.18), rgba(255, 138, 61, 0.18));
  border-bottom: 1px solid rgba(255, 169, 61, 0.35);
  overflow: hidden;
  white-space: nowrap;
  padding: 9px 0;
  font-weight: 800;
  color: #8a5a00;
  position: relative;
  z-index: 10;
}
.ticker.emergency {
  background: linear-gradient(90deg, rgba(255, 82, 82, 0.16), rgba(255, 82, 82, 0.28));
  border-color: #e53935;
  color: #b71c1c;
}
.ticker .scroll {
  display: inline-block;
  padding-left: 100%;
  animation: ticker 32s linear infinite;
}
@keyframes ticker {
  to { transform: translateX(-100%); }
}

/* ---------- dashboard ---------- */
.dashboard {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px 26px 46px;
  position: relative;
  z-index: 1;
}
.hero {
  display: flex;
  align-items: center;
  gap: 26px;
  margin: 4px 0 26px;
  flex-wrap: wrap;
  justify-content: center;
}
.hero .robot-wrap {
  position: relative;
  display: grid;
  place-items: center;
}
.hero .robot-wrap::before {
  content: "";
  position: absolute;
  width: 190px;
  height: 190px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(124, 108, 255, 0.28), transparent 65%);
  animation: breathe 3.5s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.12); opacity: 1; }
}
.greeting-banner {
  text-align: left;
  max-width: 560px;
}
.greeting-banner h1 {
  font-size: 2.1rem;
  line-height: 1.15;
  background: linear-gradient(90deg, var(--primary), var(--pink));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.greeting-banner p {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink-soft);
  margin-top: 6px;
}
.greeting-banner .hint {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--primary);
  background: rgba(91, 108, 255, 0.1);
  border: 1.5px dashed rgba(91, 108, 255, 0.45);
  padding: 8px 16px;
  border-radius: 999px;
}
@media (max-width: 760px) {
  .greeting-banner { text-align: center; }
  .greeting-banner h1 { font-size: 1.6rem; }
}

.tile-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 200px));
  gap: 20px;
  width: 100%;
  max-width: 1100px;
  justify-content: center;
}
@media (max-width: 1100px) {
  .tile-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 700px) {
  .tile-grid { grid-template-columns: repeat(2, 1fr); }
}
.tile {
  position: relative;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 12px 20px;
  text-align: center;
  text-decoration: none;
  color: var(--ink);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  overflow: hidden;
  border: 1px solid rgba(91, 108, 255, 0.08);
}
.tile::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 6px;
  background: linear-gradient(90deg, var(--tile-color, var(--primary)), color-mix(in srgb, var(--tile-color, var(--primary)) 55%, #ffffff));
}
.tile:hover {
  transform: translateY(-7px) scale(1.03);
  box-shadow: var(--shadow-lg);
}
.tile .icon {
  width: 74px;
  height: 74px;
  margin: 4px auto 12px;
  display: grid;
  place-items: center;
  font-size: 2.4rem;
  border-radius: 22px;
  background: color-mix(in srgb, var(--tile-color, var(--primary)) 14%, #ffffff);
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--tile-color, var(--primary)) 30%, transparent);
  transition: transform 0.18s;
}
.tile:hover .icon {
  transform: scale(1.12) rotate(-4deg);
}
.tile .label {
  font-weight: 800;
  font-size: 1.08rem;
}

/* ---------- generic page ---------- */
.page {
  flex: 1;
  padding: 18px 26px 56px;
  max-width: 1020px;
  margin: 0 auto;
  width: 100%;
  position: relative;
  z-index: 1;
}
.page h2.page-title {
  font-size: 1.9rem;
  margin: 4px 0 22px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
}
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1.5px solid rgba(91, 108, 255, 0.2);
  border-radius: 999px;
  padding: 10px 20px;
  font-weight: 800;
  font-size: 0.98rem;
  cursor: pointer;
  box-shadow: var(--shadow);
  color: var(--primary);
  text-decoration: none;
  font-family: var(--font-body);
  transition: all 0.15s;
}
.back-btn:hover {
  background: var(--primary);
  color: #fff;
}
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(91, 108, 255, 0.08);
  padding: 24px;
  margin-bottom: 18px;
  transition: transform 0.15s, box-shadow 0.15s;
}
.grid-2 .card:hover,
.learn-grid .card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}
.card h3 {
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 1.2rem;
}
.card .meta {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.card p {
  color: var(--ink-soft);
  font-weight: 600;
}
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 18px;
}
.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  background: rgba(91, 108, 255, 0.12);
  color: var(--primary);
  margin-right: 6px;
}
.badge.red {
  background: rgba(229, 57, 53, 0.12);
  color: #c62828;
}
.badge.green {
  background: rgba(34, 197, 139, 0.14);
  color: #14795a;
}

/* ---------- chat ---------- */
.chat-page {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 20px 24px;
  max-width: 920px;
  margin: 0 auto;
  width: 100%;
  position: relative;
  z-index: 1;
}
.chat-face {
  position: relative;
  margin: 2px 0 0;
  display: grid;
  place-items: center;
}
.chat-face::before {
  content: "";
  position: absolute;
  width: 170px;
  height: 170px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(124, 108, 255, 0.25), transparent 65%);
  animation: breathe 3.5s ease-in-out infinite;
}
.chat-status {
  font-weight: 800;
  min-height: 26px;
  color: var(--primary);
  background: rgba(91, 108, 255, 0.1);
  padding: 6px 18px;
  border-radius: 999px;
  margin-top: 4px;
}
.chat-status.offline {
  color: #b71c1c;
  background: rgba(229, 57, 53, 0.1);
}
.chat-window {
  width: 100%;
  flex: 1;
  min-height: 200px;
  max-height: 40vh;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(91, 108, 255, 0.12);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin: 14px 0 12px;
  scroll-behavior: smooth;
}
.bubble {
  max-width: 78%;
  padding: 12px 18px;
  border-radius: 20px;
  margin-bottom: 10px;
  font-size: 1.04rem;
  font-weight: 600;
  line-height: 1.5;
  white-space: pre-wrap;
  animation: pop-in 0.25s ease;
}
@keyframes pop-in {
  from { transform: translateY(8px) scale(0.97); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.bubble.user {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  margin-left: auto;
  border-bottom-right-radius: 6px;
  box-shadow: 0 6px 16px rgba(91, 108, 255, 0.3);
}
.bubble.bot {
  background: #f1f4fd;
  border: 1px solid rgba(91, 108, 255, 0.1);
  border-bottom-left-radius: 6px;
  color: var(--ink);
}
.bubble.bot .src {
  display: block;
  margin-top: 5px;
  font-size: 0.68rem;
  font-weight: 800;
  opacity: 0.5;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.chat-input-row {
  width: 100%;
  display: flex;
  gap: 10px;
  align-items: center;
}
.chat-input-row input {
  flex: 1;
  border: 1.5px solid rgba(91, 108, 255, 0.18);
  border-radius: 999px;
  padding: 16px 22px;
  font-size: 1.02rem;
  font-weight: 600;
  font-family: var(--font-body);
  box-shadow: var(--shadow);
  outline: none;
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.chat-input-row input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(91, 108, 255, 0.15);
}
.round-btn {
  border: none;
  border-radius: 50%;
  width: 58px;
  height: 58px;
  font-size: 1.4rem;
  cursor: pointer;
  box-shadow: var(--shadow);
  color: #fff;
  flex-shrink: 0;
  transition: transform 0.12s, box-shadow 0.12s;
  display: grid;
  place-items: center;
}
.round-btn:hover {
  transform: scale(1.1);
  box-shadow: var(--shadow-lg);
}
.round-btn.mic {
  background: linear-gradient(135deg, var(--pink), #ff7ab5);
  width: 72px;
  height: 72px;
  font-size: 1.8rem;
}
.round-btn.mic.listening {
  animation: pulse 1s infinite;
}
.round-btn.send {
  background: linear-gradient(135deg, var(--green), #3adfa9);
}
.round-btn.stop {
  background: linear-gradient(135deg, #e53935, #ff6f60);
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 79, 154, 0.55); }
  50% { box-shadow: 0 0 0 22px rgba(255, 79, 154, 0); }
}
.quick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 12px;
  justify-content: center;
}
.quick-chips button {
  border: 1.5px solid rgba(91, 108, 255, 0.3);
  background: rgba(255, 255, 255, 0.85);
  color: var(--primary);
  font-weight: 800;
  font-family: var(--font-body);
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
  transition: all 0.15s;
}
.quick-chips button:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ---------- learn / quiz ---------- */
.learn-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 18px;
}
.big-letter {
  font-size: 6.4rem;
  font-weight: 800;
  font-family: var(--font-display);
  background: linear-gradient(135deg, var(--primary), var(--cyan));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-align: center;
  line-height: 1.1;
}
.learn-item {
  cursor: pointer;
  user-select: none;
}
.learn-item:active {
  transform: scale(0.97);
}
.color-dot {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  margin: 0 auto 10px;
  border: 5px solid #fff;
  box-shadow: var(--shadow);
}
.quiz-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 15px 20px;
  margin-bottom: 10px;
  border-radius: 16px;
  border: 2px solid rgba(91, 108, 255, 0.15);
  background: #fff;
  font-size: 1.08rem;
  font-weight: 800;
  font-family: var(--font-body);
  cursor: pointer;
  color: var(--ink);
  transition: all 0.15s;
}
.quiz-option:hover {
  border-color: var(--primary);
  transform: translateX(4px);
}
.quiz-option.correct {
  border-color: var(--green);
  background: rgba(34, 197, 139, 0.12);
}
.quiz-option.wrong {
  border-color: #e53935;
  background: rgba(229, 57, 53, 0.1);
}

.quiz-image-wrap {
  text-align: center;
  margin: 0 0 18px;
}
.quiz-image {
  max-width: min(420px, 100%);
  max-height: 280px;
  border-radius: 20px;
  box-shadow: var(--shadow);
  border: 4px solid #fff;
  object-fit: contain;
  background: #fff;
  animation: pop-in 0.3s ease;
}

/* rich text from the admin HTML editor */
.rich-content {
  color: var(--ink-soft);
  font-weight: 600;
  line-height: 1.7;
}
.rich-content h2, .rich-content h3 {
  color: var(--ink);
  margin: 12px 0 6px;
  font-family: var(--font-display);
}
.rich-content ul, .rich-content ol {
  margin: 8px 0 8px 22px;
}
.rich-content img {
  max-width: 100%;
  border-radius: 14px;
  margin: 8px 0;
}
.rich-content a {
  color: var(--primary);
  font-weight: 800;
}

/* ---------- videos ---------- */
.video-frame {
  width: 100%;
  aspect-ratio: 16/9;
  border: none;
  border-radius: 18px;
  box-shadow: var(--shadow);
}

/* ---------- QR page ---------- */
.qr-row {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  justify-content: center;
}
.qr-card {
  text-align: center;
  padding: 28px;
}
.qr-card svg,
.qr-card canvas {
  border-radius: 14px;
  background: #fff;
  padding: 10px;
  box-shadow: inset 0 0 0 1.5px rgba(91, 108, 255, 0.15);
}

.robot-face {
  position: relative;
  z-index: 1;
  animation: robot-bob 4.5s ease-in-out infinite;
}
.robot-face.listening {
  filter: drop-shadow(0 0 22px rgba(255, 79, 154, 0.5));
}
.robot-face.speaking {
  filter: drop-shadow(0 0 22px rgba(77, 215, 254, 0.5));
  animation: none;
}
@keyframes robot-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}
.robot-arm {
  transform-box: fill-box;
  transform-origin: top center;
}
.robot-face.speaking .robot-arm.right {
  animation: arm-wave 1.1s ease-in-out infinite;
}
.robot-face.listening .robot-arm.left {
  animation: arm-wave 1.4s ease-in-out infinite reverse;
}
@keyframes arm-wave {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(-14deg); }
}

.loading {
  text-align: center;
  padding: 40px;
  font-weight: 800;
  font-size: 1.2rem;
  color: var(--ink-soft);
}

/* scrollbars */
::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}
::-webkit-scrollbar-thumb {
  background: rgba(91, 108, 255, 0.3);
  border-radius: 999px;
}
::-webkit-scrollbar-track {
  background: transparent;
}

/* ---------- mobile / small tablets ---------- */
@media (max-width: 640px) {
  .topbar {
    padding: 8px 10px;
    gap: 8px;
    flex-wrap: wrap;
  }
  .topbar .brand {
    font-size: 1.05rem;
    gap: 8px;
  }
  .topbar .brand .logo {
    width: 34px;
    height: 34px;
    font-size: 1.15rem;
    border-radius: 10px;
  }
  .topbar .clock {
    display: none;
  }
  .topbar .back-btn {
    padding: 7px 14px;
    font-size: 0.88rem;
  }
  .lang-switch {
    order: 3;
    width: 100%;
    justify-content: space-between;
    overflow-x: auto;
  }
  .lang-switch button {
    padding: 6px 10px;
    font-size: 0.85rem;
    flex: 1;
  }
  .dashboard {
    padding: 12px 14px 32px;
  }
  .hero {
    gap: 8px;
    margin-bottom: 16px;
    width: 100%;
  }
  .hero .robot-wrap::before {
    width: 140px;
    height: 140px;
  }
  .hero .robot-wrap svg {
    width: 150px;
    height: auto;
  }
  .greeting-banner {
    max-width: 100%;
    min-width: 0;
  }
  .greeting-banner h1 {
    font-size: 1.35rem;
    overflow-wrap: break-word;
  }
  .greeting-banner p {
    font-size: 0.95rem;
  }
  .greeting-banner .hint {
    font-size: 0.82rem;
    padding: 7px 12px;
  }
  .tile-grid {
    gap: 12px;
  }
  .tile {
    padding: 16px 8px 14px;
    border-radius: 20px;
  }
  .tile .icon {
    width: 56px;
    height: 56px;
    font-size: 1.8rem;
    border-radius: 16px;
    margin-bottom: 8px;
  }
  .tile .label {
    font-size: 0.92rem;
  }
  .page {
    padding: 12px 14px 40px;
  }
  .page h2.page-title {
    font-size: 1.45rem;
  }
  .card {
    padding: 16px;
    border-radius: 20px;
  }
  .chat-page {
    padding: 4px 12px 16px;
  }
  .chat-face svg {
    width: 150px;
    height: auto;
  }
  .chat-face::before {
    width: 120px;
    height: 120px;
  }
  .chat-window {
    max-height: 38vh;
    padding: 12px;
  }
  .bubble {
    max-width: 88%;
    font-size: 0.98rem;
    padding: 10px 14px;
  }
  .chat-input-row {
    gap: 8px;
  }
  .chat-input-row input {
    padding: 13px 16px;
    font-size: 0.95rem;
    min-width: 0;
  }
  .round-btn {
    width: 50px;
    height: 50px;
    font-size: 1.2rem;
  }
  .round-btn.mic {
    width: 62px;
    height: 62px;
    font-size: 1.5rem;
  }
  .quick-chips button {
    padding: 7px 12px;
    font-size: 0.85rem;
  }
  .grid-2 {
    grid-template-columns: 1fr;
  }
  .learn-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  .big-letter {
    font-size: 4rem;
  }
  .color-dot {
    width: 64px;
    height: 64px;
  }
  .quiz-option {
    padding: 12px 16px;
    font-size: 1rem;
  }
  .quiz-image {
    max-height: 200px;
  }
  .qr-card svg {
    width: 170px;
    height: 170px;
  }
}
