:root {
  --bg: #f7faff;
  --bg-soft: #eaf3ff;
  --primary: #22d3ee;
  --gold: #f4b740;
  --purple: #8b5cf6;
  --text: #102a43;
  --muted: #64748b;
  --card: rgba(255, 255, 255, 0.72);
  --line: rgba(16, 42, 67, 0.12);
  --shadow: 0 24px 70px rgba(16, 42, 67, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: clamp(0.95rem, 1.4vw, 1.08rem);
  background: linear-gradient(135deg, var(--bg), var(--bg-soft));
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(120deg, rgba(34, 211, 238, 0.2), transparent 35%),
    linear-gradient(310deg, rgba(244, 183, 64, 0.16), transparent 42%),
    linear-gradient(40deg, rgba(139, 92, 246, 0.13), transparent 38%);
  z-index: -2;
}

#particles {
  position: fixed;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
}

img,
iframe {
  max-width: 100%;
}

button,
a,
input,
select,
textarea {
  font: inherit;
}

button,
a {
  cursor: pointer;
}

button,
input,
select,
textarea {
  min-height: 48px;
  border-radius: 8px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: clamp(0.8rem, 2vw, 1.1rem) clamp(1rem, 4vw, 4rem);
  border-bottom: 1px solid var(--line);
  background: rgba(247, 250, 255, 0.8);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 8px;
  color: var(--text);
  background: linear-gradient(135deg, var(--primary), var(--gold));
  font-weight: 800;
}

.brand small,
.muted {
  display: block;
  color: var(--muted);
}

.desktop-nav,
.mobile-drawer {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.desktop-nav button,
.desktop-nav a,
.mobile-drawer button,
.mobile-drawer a,
.secondary {
  display: inline-flex;
  min-width: 48px;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.62);
  text-decoration: none;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.desktop-nav button:hover,
.desktop-nav a:hover,
.mobile-drawer button:hover,
.mobile-drawer a:hover,
.secondary:hover,
.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(34, 211, 238, 0.22);
}

.menu-toggle {
  display: none;
  width: 48px;
  border: 1px solid var(--line);
  background: white;
}

.mobile-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 40;
  width: min(86vw, 360px);
  height: 100vh;
  padding: 5rem 1rem 1rem;
  flex-direction: column;
  align-items: stretch;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
  transform: translateX(105%);
  transition: transform 220ms ease;
}

.mobile-drawer.open {
  transform: translateX(0);
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 35;
  display: none;
  background: rgba(16, 42, 67, 0.28);
}

.drawer-backdrop.open {
  display: block;
}

main {
  width: min(100% - 2rem, 1480px);
  margin: 0 auto;
}

.tab {
  display: none;
  padding: clamp(1.4rem, 4vw, 4rem) 0;
}

.tab.active {
  display: block;
}

.hero {
  display: none;
  min-height: calc(100vh - 86px);
  grid-template-columns: minmax(0, 0.85fr) minmax(320px, 1.15fr);
  align-items: center;
  gap: clamp(1.4rem, 4vw, 3.5rem);
}

.hero.active {
  display: grid;
}

.hero h1,
.section-head h2,
.tab > h2 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 4.8rem);
  line-height: 1;
  letter-spacing: 0;
}

.section-head h2,
.tab > h2 {
  font-size: clamp(1.7rem, 3vw, 3rem);
}

.hero p,
footer p {
  line-height: 1.7;
}

.eyebrow {
  margin: 0 0 0.7rem;
  color: var(--purple);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.auth-grid,
.study-layout,
.history-grid,
.donation-grid,
.social-grid,
.admin-dashboard,
.form-grid {
  display: grid;
  gap: 1rem;
}

.auth-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.glass-card {
  padding: clamp(1rem, 3vw, 1.5rem);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.glass-card h2,
.glass-card h3 {
  margin-top: 0;
}

label {
  display: grid;
  gap: 0.4rem;
  margin-bottom: 1rem;
  color: var(--text);
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  padding: 0.8rem 0.9rem;
  color: var(--text);
  background: rgba(255, 255, 255, 0.82);
  outline: none;
}

textarea {
  min-height: 88px;
  resize: vertical;
}

.checkbox {
  grid-template-columns: auto 1fr;
  align-items: center;
  font-weight: 500;
}

.checkbox input {
  width: 22px;
  min-height: 22px;
}

.primary {
  display: inline-flex;
  min-width: 48px;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: 0;
  padding: 0.8rem 1rem;
  border-radius: 8px;
  color: #102a43;
  background: linear-gradient(135deg, var(--primary), var(--gold));
  font-weight: 800;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.journey {
  display: grid;
  gap: 0.5rem;
  margin-top: 1rem;
}

.progress {
  width: 100%;
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(16, 42, 67, 0.12);
}

.progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--purple), var(--gold));
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.status-pill {
  padding: 0.7rem 1rem;
  border-radius: 999px;
  background: rgba(34, 211, 238, 0.16);
  font-weight: 800;
}

.study-layout {
  grid-template-columns: minmax(260px, 0.36fr) minmax(0, 1fr);
}

.controls-panel {
  align-self: start;
}

.lesson-list {
  display: grid;
  gap: 0.5rem;
}

.lesson-item {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  padding: 0.6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.6);
}

.lesson-item input {
  width: 22px;
  min-height: 22px;
}

.chat-panel {
  display: grid;
  gap: 1rem;
}

.chips,
.material-grid,
.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chips button {
  min-height: 40px;
  border: 1px solid rgba(34, 211, 238, 0.45);
  padding: 0.5rem 0.75rem;
  background: rgba(34, 211, 238, 0.12);
  color: var(--text);
}

.chat-log {
  display: grid;
  align-content: start;
  gap: 0.8rem;
  height: min(54vh, 620px);
  min-height: 320px;
  overflow: auto;
  padding: 0.5rem;
  scrollbar-color: var(--primary) rgba(16, 42, 67, 0.1);
}

.message {
  max-width: min(760px, 92%);
  padding: 0.85rem 1rem;
  border-radius: 8px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.message.user {
  justify-self: end;
  background: rgba(34, 211, 238, 0.18);
}

.message.bot {
  justify-self: start;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 8px 20px rgba(16, 42, 67, 0.08);
}

.chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.6rem;
}

.material-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.material-grid button {
  min-height: 56px;
}

.ai-warning {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.history-grid,
.donation-grid,
.social-grid,
.admin-dashboard {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.upload-panel {
  margin: 1rem 0;
}

.form-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.social-grid a,
.donation-card,
.stat-card {
  display: grid;
  gap: 0.5rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.7);
  text-decoration: none;
}

.donation-card strong,
.stat-card strong {
  font-size: clamp(1.3rem, 3vw, 2rem);
}

table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: 8px;
  background: white;
}

th,
td {
  padding: 0.75rem;
  border: 1px solid var(--line);
  text-align: left;
}

th {
  color: white;
  background: var(--primary);
}

footer {
  width: min(100% - 2rem, 1480px);
  margin: 0 auto;
  padding: 2rem 0 3rem;
  color: var(--muted);
}

@keyframes confetti {
  from { transform: translateY(-12px) rotate(0deg); opacity: 1; }
  to { transform: translateY(80px) rotate(180deg); opacity: 0; }
}

.confetti {
  position: fixed;
  top: 12%;
  left: var(--x);
  z-index: 60;
  width: 10px;
  height: 16px;
  border-radius: 2px;
  background: var(--c);
  animation: confetti 900ms ease-out forwards;
  will-change: transform, opacity;
}

@media (min-width: 1920px) {
  main,
  footer {
    width: min(100% - 5rem, 1760px);
  }
}

@media (min-width: 1280px) and (max-width: 1919px) {
  .desktop-nav button,
  .desktop-nav a {
    padding-inline: 0.75rem;
  }
}

@media (min-width: 1024px) and (max-width: 1279px) {
  .desktop-nav {
    display: none;
  }
  .menu-toggle {
    display: inline-grid;
    place-items: center;
  }
  .material-grid,
  .history-grid,
  .donation-grid,
  .social-grid,
  .admin-dashboard,
  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .desktop-nav {
    display: none;
  }
  .menu-toggle {
    display: inline-grid;
    place-items: center;
  }
  .hero.active,
  .study-layout,
  .auth-grid {
    grid-template-columns: 1fr;
  }
  .material-grid,
  .history-grid,
  .donation-grid,
  .social-grid,
  .admin-dashboard {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 480px) and (max-width: 767px) {
  .desktop-nav {
    display: none;
  }
  .menu-toggle {
    display: inline-grid;
    place-items: center;
  }
  .hero.active,
  .study-layout,
  .auth-grid,
  .history-grid,
  .donation-grid,
  .social-grid,
  .admin-dashboard,
  .form-grid {
    grid-template-columns: 1fr;
  }
  .section-head,
  .chat-form {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }
  .material-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 479px) {
  main,
  footer {
    width: min(100% - 1rem, 1480px);
  }
  .site-header {
    padding-inline: 0.75rem;
  }
  .desktop-nav {
    display: none;
  }
  .brand small {
    display: none;
  }
  .menu-toggle {
    display: inline-grid;
    place-items: center;
  }
  .hero.active,
  .study-layout,
  .auth-grid,
  .history-grid,
  .donation-grid,
  .social-grid,
  .admin-dashboard,
  .form-grid,
  .material-grid {
    grid-template-columns: 1fr;
  }
  .section-head,
  .chat-form {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }
  .chat-log {
    height: 48vh;
  }
  .hero h1 {
    font-size: clamp(1.85rem, 12vw, 3rem);
  }
}
