@import url("tokens.css");
@import url("https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap");

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100dvh;
  font-family: var(--font-body, var(--font-en));
  color: var(--color-text);
  background:
    radial-gradient(90% 60% at 100% 0%, rgba(241, 89, 93, 0.12), transparent 50%),
    radial-gradient(80% 50% at 0% 10%, rgba(238, 212, 132, 0.28), transparent 45%),
    linear-gradient(180deg, var(--color-sky) 0%, var(--color-cream) 55%, #f4ebe0 100%);
  -webkit-font-smoothing: antialiased;
}

[dir="rtl"] body, [dir="rtl"] { font-family: var(--font-ar); }
[dir="ltr"] body, [dir="ltr"] { font-family: var(--font-en); }

img { max-width: 100%; height: auto; display: block; }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
code { font-size: 0.85em; }

.app-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
  animation: page-in 0.45s ease both;
}

@keyframes page-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.app-main {
  flex: 1;
  width: min(480px, 100%);
  margin: 0 auto;
  padding: var(--space-lg) var(--space-md);
  padding-bottom: calc(var(--nav-height) + var(--space-xl));
}

.app-main--auth {
  padding-bottom: var(--space-xl);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* —— Splash / welcome —— */
.welcome-hero {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(145deg, rgba(17, 44, 90, 0.92), rgba(17, 44, 90, 0.75)),
    url("/media/imgs/bg-school.jpg") center/cover;
  color: var(--color-white);
  padding: calc(var(--space-xl) + env(safe-area-inset-top)) var(--space-lg) calc(var(--space-xl) + 12px);
  text-align: center;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.welcome-hero::after {
  content: "";
  position: absolute;
  inset-inline: 18%;
  bottom: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--color-gold), transparent);
}

.welcome-hero__badge {
  display: inline-block;
  background: rgba(241, 89, 93, 0.95);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  margin-bottom: var(--space-md);
}

.welcome-hero__logo {
  width: 120px;
  margin: 0 auto var(--space-md);
  filter: drop-shadow(0 10px 20px rgba(0,0,0,0.3));
}

.welcome-hero--login {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 12px;
  padding: calc(36px + env(safe-area-inset-top)) var(--space-lg) 40px;
  min-height: 280px;
  background: var(--color-navy);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.welcome-hero--login::after {
  display: none;
}

.welcome-hero--login .welcome-hero__title {
  margin: 4px 0 0;
  color: #fff;
  font-size: 1.2rem;
}

.welcome-hero--login .welcome-hero__sub {
  margin: 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.9rem;
}

.login-logo {
  width: min(168px, 42vw);
  height: min(168px, 42vw);
  max-width: 180px;
  max-height: 180px;
  object-fit: contain;
  border-radius: 50%;
  display: block;
  margin: 0 auto;
  background: transparent;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.3);
}

/* —— Splash / loading screen —— */
.helalia-splash {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  background:
    radial-gradient(80% 60% at 50% 40%, rgba(238, 212, 132, 0.18), transparent 55%),
    linear-gradient(160deg, #0d2348 0%, #112c5a 45%, #1a3d7a 100%);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.45s ease, visibility 0.45s ease;
}

.helalia-splash.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.helalia-splash.is-leaving {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.helalia-splash__stage {
  position: relative;
  width: min(200px, 52vw);
  height: min(200px, 52vw);
  display: grid;
  place-items: center;
}

.helalia-splash__logo {
  width: 72%;
  height: 72%;
  object-fit: contain;
  border-radius: 50%;
  position: relative;
  z-index: 2;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  animation: splash-logo-in 0.7s ease both;
}

.helalia-splash__ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: var(--color-gold);
  border-right-color: rgba(241, 89, 93, 0.85);
  animation: splash-spin 0.9s linear infinite;
  z-index: 1;
}

.helalia-splash__ring--soft {
  inset: -10px;
  border-width: 2px;
  border-top-color: rgba(238, 212, 132, 0.35);
  border-right-color: transparent;
  border-bottom-color: rgba(241, 89, 93, 0.25);
  animation-duration: 1.4s;
  animation-direction: reverse;
}

.helalia-splash__text {
  margin: 0;
  color: #fff;
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.85rem;
  opacity: 0.9;
}

@keyframes splash-spin {
  to { transform: rotate(360deg); }
}

@keyframes splash-logo-in {
  from { opacity: 0; transform: scale(0.86); }
  to { opacity: 1; transform: scale(1); }
}

.welcome-hero__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: -0.02em;
}

.welcome-hero__sub {
  margin: var(--space-sm) 0 0;
  opacity: 0.9;
  font-size: 0.95rem;
}

.lang-grid {
  display: grid;
  gap: var(--space-md);
  margin-top: var(--space-xl);
}

.lang-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: 1.15rem 1.25rem;
  background: var(--color-white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  border: 1.5px solid transparent;
  min-height: 64px;
  transition: border-color 0.15s, transform 0.12s, box-shadow 0.15s;
}

.lang-card:active { transform: scale(0.985); }
.lang-card:hover, .lang-card:focus-visible {
  border-color: var(--color-coral);
  box-shadow: var(--shadow-md);
  outline: none;
}

.lang-card__label {
  font-size: 1.15rem;
  font-weight: 700;
}

.lang-card__chevron {
  color: var(--color-navy);
  font-size: 1.4rem;
  opacity: 0.5;
}

.demo-cta {
  display: block;
  margin-top: var(--space-lg);
  text-align: center;
  text-decoration: none;
  color: var(--color-navy);
  font-weight: 700;
  padding: 12px;
  border-radius: var(--radius-md);
  background: rgba(238, 212, 132, 0.35);
  border: 1px solid rgba(238, 212, 132, 0.8);
}

.demo-cta small {
  display: block;
  font-weight: 500;
  color: var(--color-text-muted);
  margin-top: 4px;
}

/* —— Auth card —— */
.auth-card {
  background: var(--color-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-lg);
  margin-top: -28px;
  position: relative;
  z-index: 1;
}

.auth-card__logo {
  width: 88px;
  margin: 0 auto var(--space-md);
}

.auth-card__title {
  text-align: center;
  margin: 0 0 var(--space-lg);
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--color-navy);
  letter-spacing: -0.02em;
}

.field {
  margin-bottom: var(--space-md);
}

.field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: 6px;
}

.field input[type="text"],
.field input[type="tel"],
.field input[type="number"],
.field input[type="password"],
.field input[type="email"],
.field textarea {
  width: 100%;
  min-height: var(--touch-min);
  padding: 0.75rem 0.9rem;
  border: 1.5px solid #d7e0ea;
  border-radius: var(--radius-sm);
  background: #fbfcfd;
  color: var(--color-text);
}

.field textarea {
  min-height: 110px;
  resize: vertical;
}

.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--color-navy);
  box-shadow: 0 0 0 3px rgba(17, 44, 90, 0.12);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: var(--space-sm) 0 var(--space-md);
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--touch-min);
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: var(--radius-pill);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  width: 100%;
  transition: transform 0.12s, box-shadow 0.15s;
}

.btn--primary {
  background: linear-gradient(135deg, var(--color-navy) 0%, var(--color-navy-soft) 100%);
  color: #fff;
  box-shadow: 0 10px 22px rgba(17, 44, 90, 0.28);
}

.btn--primary:active { transform: scale(0.98); }

.btn--coral {
  background: linear-gradient(135deg, var(--color-coral), #e8454a);
  color: #fff;
  box-shadow: 0 10px 22px rgba(241, 89, 93, 0.28);
}

.btn--ghost {
  background: transparent;
  color: var(--color-navy);
  border: 1.5px solid rgba(17, 44, 90, 0.2);
}

.auth-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 14px;
  margin-top: var(--space-lg);
  font-size: 0.9rem;
}

.auth-links a {
  color: var(--color-navy);
  text-decoration: none;
  font-weight: 600;
}

.auth-footer {
  text-align: center;
  margin-top: var(--space-lg);
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

/* —— Top / bottom bars —— */
.topbar {
  display: grid;
  grid-template-columns: 44px 1fr 56px;
  align-items: center;
  min-height: var(--header-height);
  padding: calc(8px + env(safe-area-inset-top)) var(--space-md) 8px;
  background: linear-gradient(120deg, var(--color-navy), var(--color-navy-soft));
  color: #fff;
  width: min(480px, 100%);
  margin: 0 auto;
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar__title {
  margin: 0;
  text-align: center;
  font-size: 1rem;
  font-weight: 700;
}

.topbar__back,
.topbar__spacer {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  color: #fff;
  text-decoration: none;
  font-size: 1.75rem;
  line-height: 1;
}

.demo-chip {
  justify-self: end;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--color-gold);
  color: var(--color-navy);
  padding: 4px 8px;
  border-radius: var(--radius-pill);
}

.bottom-nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 10px;
  width: min(440px, calc(100% - 20px));
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(17, 44, 90, 0.08);
  box-shadow: var(--shadow-nav);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  z-index: 50;
  border-radius: 22px;
}

.bottom-nav__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px;
  text-decoration: none;
  color: var(--color-text-muted);
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 16px;
  transition: background 0.15s, color 0.15s, transform 0.12s;
}

.bottom-nav__icon {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
}
.bottom-nav__icon svg { width: 20px; height: 20px; }

.bottom-nav__item.is-active {
  color: var(--color-navy);
  background: rgba(238, 212, 132, 0.35);
}

.bottom-nav__item:active { transform: scale(0.96); }

/* —— Cards / lists —— */
.page-intro {
  margin: 0 0 var(--space-md);
}

.page-intro h2 {
  margin: 0 0 4px;
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--color-navy);
  letter-spacing: -0.02em;
}

.page-intro p {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.kid-list,
.stack {
  display: grid;
  gap: var(--space-md);
}

.kid-card {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: var(--space-md);
  align-items: center;
  padding: var(--space-md);
  background: var(--color-white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  border: 1.5px solid transparent;
  transition: transform 0.12s, border-color 0.15s, box-shadow 0.15s;
}

.kid-card:active { transform: scale(0.99); }
.kid-card:hover { border-color: rgba(241, 89, 93, 0.45); box-shadow: var(--shadow-md); }

.kid-card__avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--color-gold);
  background: #fff;
}

.kid-card__name {
  margin: 0 0 4px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-navy);
}

.kid-card__meta {
  margin: 0;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.kid-card__chevron {
  font-size: 1.4rem;
  color: var(--color-navy);
  opacity: 0.35;
}

.hub-hero {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  background:
    linear-gradient(135deg, rgba(17, 44, 90, 0.96), rgba(26, 61, 122, 0.9)),
    url("/media/imgs/bg-school.jpg") center/cover;
  color: #fff;
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin-bottom: var(--space-lg);
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.hub-hero::after {
  content: "";
  position: absolute;
  inset-inline-end: -20px;
  top: -20px;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: rgba(238, 212, 132, 0.2);
}

.hub-hero__avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--color-gold);
  position: relative;
  z-index: 1;
}

.hub-hero__name { margin: 0 0 4px; font-size: 1.1rem; font-weight: 800; position: relative; z-index: 1; }
.hub-hero__meta { margin: 0; opacity: 0.9; font-size: 0.85rem; position: relative; z-index: 1; }

.quick-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: var(--space-lg);
}

.quick-item {
  text-align: center;
  text-decoration: none;
  background: var(--color-white);
  border-radius: var(--radius-sm);
  padding: 12px 4px;
  box-shadow: var(--shadow-sm);
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--color-text);
  position: relative;
  transition: transform 0.12s, box-shadow 0.15s;
}

.quick-item:active { transform: scale(0.96); }

.quick-item__icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin: 0 auto 6px;
  border-radius: 12px;
  background: rgba(17, 44, 90, 0.08);
  color: var(--color-navy);
}
.quick-item__icon svg { width: 18px; height: 18px; }

.quick-item__badge {
  position: absolute;
  top: 4px;
  inset-inline-end: 6px;
  background: var(--color-coral);
  color: #fff;
  border-radius: var(--radius-pill);
  font-size: 0.65rem;
  padding: 1px 6px;
  animation: badge-pulse 1.8s ease infinite;
}

@keyframes badge-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.feature-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

.feature-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 118px;
  padding: var(--space-md);
  background: var(--color-white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  border: 1.5px solid rgba(17, 44, 90, 0.05);
  text-align: center;
  position: relative;
  transition: transform 0.12s, box-shadow 0.15s;
}

.feature-card:active { transform: scale(0.97); }
.feature-card:hover { box-shadow: var(--shadow-md); }

.feature-card__icon {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, rgba(17, 44, 90, 0.1), rgba(241, 89, 93, 0.1));
  color: var(--color-navy);
}
.feature-card__icon svg { width: 24px; height: 24px; }

.feature-card__label {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--color-navy);
}

.empty-state {
  text-align: center;
  padding: var(--space-xl) var(--space-md);
  background: rgba(255,255,255,0.7);
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
}

.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-md);
  font-size: 0.9rem;
}

.alert--danger {
  background: #fdecea;
  color: #8a1c1c;
  border: 1px solid #f5c6c2;
}

.alert--warn {
  background: #fff6e5;
  color: #7a4d00;
  border: 1px solid #f0d7a0;
}

.alert--info {
  background: #e8f0fe;
  color: #112c5a;
  border: 1px solid #c5d6f5;
}

.alert--success {
  background: #e8f6ef;
  color: #1e5a3c;
  border: 1px solid #b7e0c8;
}

.muted { color: var(--color-text-muted); }
.center { text-align: center; }

.settings-list {
  display: grid;
  gap: 10px;
}

.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: #fff;
  border-radius: var(--radius-sm);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  font-weight: 600;
  color: var(--color-navy);
}

.settings-item--danger { color: var(--color-danger); }

.panel {
  background: #fff;
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
}

.profile-card {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: #fff;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-lg);
}

.profile-card__avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--color-gold);
}

.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: #fff;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  transition: transform 0.12s;
}

.list-row:active { transform: scale(0.99); }
.list-row.is-unread {
  border-inline-start: 4px solid var(--color-coral);
}

.list-row__body { flex: 1; min-width: 0; }
.list-row__title {
  margin: 0 0 4px;
  font-weight: 700;
  color: var(--color-navy);
  font-size: 0.95rem;
}
.list-row__meta {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-row__trail,
.list-row__chevron {
  color: var(--color-text-muted);
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 700;
  background: rgba(17, 44, 90, 0.08);
  color: var(--color-navy);
}
.chip--due { background: rgba(241, 89, 93, 0.12); color: #b83236; }
.chip--done { background: rgba(46, 125, 90, 0.12); color: var(--color-success); }
.chip--warn { background: rgba(196, 122, 0, 0.14); color: var(--color-warning); }

.subject-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: #fff;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
}
.subject-card__dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}
.subject-card__name {
  flex: 1;
  margin: 0;
  font-weight: 700;
  color: var(--color-navy);
}
.subject-card__count {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  font-weight: 600;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.stat-card {
  background: #fff;
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.stat-card__value {
  margin: 0 0 4px;
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--color-navy);
  letter-spacing: -0.03em;
}
.stat-card__label {
  margin: 0;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}
.stat-card.tone-good .stat-card__value { color: var(--color-success); }
.stat-card.tone-warn .stat-card__value { color: var(--color-warning); }
.stat-card.tone-info .stat-card__value { color: var(--color-navy-soft); }

.cal-row {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 12px;
  align-items: center;
  padding: 12px;
  background: #fff;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.cal-row__date {
  text-align: center;
  background: rgba(17, 44, 90, 0.06);
  border-radius: 14px;
  padding: 8px 4px;
}
.cal-row__day {
  display: block;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--color-navy);
  line-height: 1;
}
.cal-row__month {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--color-coral);
  text-transform: uppercase;
}
.cal-row__title { margin: 0 0 4px; font-weight: 700; color: var(--color-navy); }
.cal-row__meta { margin: 0; font-size: 0.8rem; color: var(--color-text-muted); }

.gallery-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.gallery-item {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  aspect-ratio: 1;
  box-shadow: var(--shadow-sm);
  background: #dde5ee;
}
.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.gallery-item__cap {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  padding: 8px 10px;
  background: linear-gradient(transparent, rgba(17,44,90,0.75));
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
}

.detail-card {
  background: #fff;
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
}
.detail-card h2 {
  margin: 0 0 8px;
  color: var(--color-navy);
  font-size: 1.2rem;
}
.detail-card p { margin: 0 0 12px; line-height: 1.55; color: var(--color-text); }

.section-label {
  margin: 0 0 10px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.teacher-hero {
  background: linear-gradient(135deg, var(--color-navy), #243f72);
  color: #fff;
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
  box-shadow: var(--shadow-md);
}
.teacher-hero h2 { margin: 0 0 6px; font-size: 1.25rem; }
.teacher-hero p { margin: 0; opacity: 0.85; }

.msg-bubble {
  padding: 12px 14px;
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--shadow-sm);
  margin-bottom: 10px;
}
.msg-bubble.is-mine {
  background: rgba(17, 44, 90, 0.08);
  margin-inline-start: 24px;
}
.msg-bubble__from {
  margin: 0 0 4px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-navy);
}
.msg-bubble__text { margin: 0; font-size: 0.9rem; }
.msg-bubble__time {
  margin: 6px 0 0;
  font-size: 0.7rem;
  color: var(--color-text-muted);
}

.score-badge {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: rgba(238, 212, 132, 0.45);
  color: var(--color-navy);
  font-weight: 800;
  font-size: 0.85rem;
  flex-shrink: 0;
}

/* —— Responsive: phones → tablets → large tablets —— */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

.app-body,
.app-shell {
  max-width: 100vw;
  overflow-x: hidden;
}

.app-main,
.topbar,
.bottom-nav,
.welcome-hero {
  max-width: 100%;
}

/* Small phones */
@media (max-width: 380px) {
  .app-main {
    padding-inline: 12px;
  }
  .quick-row {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .feature-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .feature-card {
    min-height: 100px;
  }
  .hub-hero__name {
    font-size: 1rem;
  }
  .welcome-hero__title {
    font-size: 1.2rem;
  }
  .stat-grid {
    grid-template-columns: 1fr;
  }
  .gallery-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* Standard phones already use width: min(480px, 100%) */

/* Large phones / small tablets (portrait) */
@media (min-width: 600px) {
  .app-main {
    width: min(640px, 100%);
    padding-inline: 24px;
  }
  .topbar,
  .bottom-nav {
    width: min(640px, 100%);
  }
  .welcome-hero {
    padding-inline: 32px;
  }
  .feature-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .quick-row {
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
  }
  .gallery-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Tablets (landscape / iPad) */
@media (min-width: 768px) {
  .app-main {
    width: min(720px, 100%);
    padding: 28px 28px calc(var(--nav-height) + 36px);
  }
  .topbar,
  .bottom-nav {
    width: min(720px, calc(100% - 24px));
  }
  .bottom-nav {
    bottom: 16px;
    border-radius: 24px;
  }
  .hub-hero {
    padding: 22px;
  }
  .feature-card {
    min-height: 132px;
  }
  .kid-card {
    padding: 18px;
  }
  .gallery-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  .control-grid,
  .stat-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Large tablets / small laptops viewing mobile UI */
@media (min-width: 1024px) {
  .app-main {
    width: min(820px, 100%);
  }
  .topbar,
  .bottom-nav {
    width: min(820px, calc(100% - 32px));
  }
  .feature-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
  }
}

/* Touch-friendly: avoid hover-only critical UI; keep tap targets */
@media (hover: none) and (pointer: coarse) {
  .btn,
  .feature-card,
  .kid-card,
  .quick-item,
  .list-row,
  .settings-item,
  .lang-card {
    min-height: var(--touch-min);
  }
}

/* Landscape phones: reduce vertical chrome a bit */
@media (max-height: 480px) and (orientation: landscape) {
  .welcome-hero {
    padding-top: 16px;
    padding-bottom: 20px;
  }
  .welcome-hero__logo {
    width: 72px;
  }
  .app-main--auth {
    justify-content: flex-start;
  }
}
