:root {
  --bg: #f7f5ff;
  --surface: #ffffff;
  --surface-soft: #f0edff;
  --text: #211a36;
  --muted: #6e6680;
  --primary: #6d4aff;
  --primary-dark: #4b2fd1;
  --accent: #ff6fae;
  --border: #ded8f2;
  --success: #167a56;
  --warning: #9a5a00;
  --danger: #b4233c;
  --shadow: 0 14px 35px rgba(53, 34, 112, 0.10);
  --radius: 20px;
  font-family: Inter, ui-rounded, "SF Pro Rounded", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(circle at 10% -10%, rgba(255, 111, 174, 0.18), transparent 34rem),
    radial-gradient(circle at 100% 0%, rgba(109, 74, 255, 0.18), transparent 32rem),
    var(--bg);
  color: var(--text);
}
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--primary-dark); }
img { max-width: 100%; }
[hidden] { display: none !important; }

.center-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 1rem;
  padding: 2rem;
  text-align: center;
}

.brand-mark {
  width: 4rem;
  height: 4rem;
  display: grid;
  place-items: center;
  border-radius: 1.35rem;
  color: white;
  font-size: 2rem;
  font-weight: 900;
  background: linear-gradient(145deg, var(--primary), var(--accent));
  box-shadow: var(--shadow);
}

.auth-layout {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.25rem;
}

.auth-card {
  width: min(100%, 34rem);
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(222, 216, 242, 0.9);
  border-radius: 2rem;
  padding: clamp(1.4rem, 4vw, 2.3rem);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}
.auth-brand { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.4rem; }
.auth-brand h1 { margin: 0; font-size: 1.75rem; }
.auth-brand p { margin: .2rem 0 0; color: var(--muted); }

.app-shell { min-height: 100vh; min-height: 100dvh; padding-bottom: 6.5rem; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .85rem max(1rem, env(safe-area-inset-left));
  background: rgba(247, 245, 255, 0.88);
  border-bottom: 1px solid rgba(222, 216, 242, .85);
  backdrop-filter: blur(18px);
}
.topbar-brand { display: flex; align-items: center; gap: .75rem; min-width: 0; }
.topbar .brand-mark { width: 2.7rem; height: 2.7rem; border-radius: .95rem; font-size: 1.25rem; flex: 0 0 auto; }
.topbar h1 { margin: 0; font-size: 1.15rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar p { margin: .05rem 0 0; color: var(--muted); font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main-content { width: min(100% - 2rem, 76rem); margin: 1.25rem auto 0; }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.page-heading h2 { margin: 0; font-size: clamp(1.45rem, 4vw, 2rem); }
.page-heading p { margin: .3rem 0 0; color: var(--muted); }

.bottom-nav {
  position: fixed;
  z-index: 30;
  left: 50%;
  bottom: max(.75rem, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(calc(100% - 1.25rem), 44rem);
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: .3rem;
  padding: .4rem;
  border-radius: 1.4rem;
  border: 1px solid rgba(222, 216, 242, .95);
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 14px 40px rgba(53, 34, 112, .18);
  backdrop-filter: blur(18px);
}
.nav-button {
  border: 0;
  border-radius: 1rem;
  padding: .65rem .35rem;
  background: transparent;
  color: var(--muted);
  font-size: .75rem;
  font-weight: 750;
  cursor: pointer;
}
.nav-button span { display: block; font-size: 1.2rem; margin-bottom: .15rem; }
.nav-button.active { color: var(--primary-dark); background: var(--surface-soft); }

.grid { display: grid; gap: .75rem; align-content: start; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cards { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr)); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(53, 34, 112, .055);
  padding: .95rem;
}
.card h3 { margin: 0 0 .5rem; font-size: 1.08rem; }
.card p { line-height: 1.5; }
.card.soft { background: var(--surface-soft); }
.card.warning { border-color: #f2cf95; background: #fff9ed; }
.card.danger { border-color: #f1b6c0; background: #fff5f7; }

.stat-card { display: flex; align-items: center; justify-content: space-between; min-height: 6.5rem; }
.stat-value { font-size: 2rem; font-weight: 900; letter-spacing: -.04em; }
.stat-label { color: var(--muted); font-size: .9rem; }
.stat-icon { width: 2.9rem; height: 2.9rem; display: grid; place-items: center; border-radius: 1rem; background: var(--surface-soft); font-size: 1.35rem; }

.section { margin: 1.1rem 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .75rem; }
.section-head h3 { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

label { display: grid; gap: .38rem; color: var(--text); font-weight: 700; font-size: .88rem; }
input, select, textarea {
  width: 100%;
  min-height: 2.75rem;
  border: 1px solid var(--border);
  border-radius: .9rem;
  background: #fff;
  color: var(--text);
  padding: .7rem .8rem;
  outline: none;
}

input[type="checkbox"] {
  width: 1.2rem;
  min-height: 0;
  height: 1.2rem;
  padding: 0;
  border-radius: .3rem;
}
textarea { min-height: 6rem; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(109, 74, 255, .14); }
.form-row { display: grid; gap: .85rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-actions { display: flex; flex-wrap: wrap; gap: .65rem; margin-top: .9rem; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  min-height: 2.4rem;
  border: 0;
  border-radius: .9rem;
  padding: .55rem .85rem;
  background: var(--primary);
  color: white;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}
.button:hover { background: var(--primary-dark); }
.button.secondary { color: var(--primary-dark); background: var(--surface-soft); }
.button.ghost { color: var(--text); background: transparent; border: 1px solid var(--border); }
.button.danger { color: var(--danger); background: #fff0f3; }
.button.small { min-height: 2.2rem; padding: .45rem .7rem; font-size: .82rem; }
.button:disabled { opacity: .55; cursor: not-allowed; }
.icon-button { width: 2.65rem; height: 2.65rem; border-radius: .9rem; border: 1px solid var(--border); background: var(--surface); cursor: pointer; }

.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: .35rem; padding: .3rem; background: var(--surface-soft); border-radius: 1rem; margin-bottom: 1rem; }
.segmented button { border: 0; border-radius: .75rem; padding: .65rem; background: transparent; font-weight: 800; color: var(--muted); cursor: pointer; }
.segmented button.active { background: white; color: var(--primary-dark); box-shadow: 0 3px 10px rgba(53, 34, 112, .08); }

.badge { display: inline-flex; align-items: center; gap: .3rem; border-radius: 999px; padding: .27rem .6rem; background: var(--surface-soft); color: var(--primary-dark); font-size: .76rem; font-weight: 800; }
.badge.success { background: #e7f7f0; color: var(--success); }
.badge.warning { background: #fff1d8; color: var(--warning); }
.badge.danger { background: #ffe8ed; color: var(--danger); }
.badge.muted { background: #f0eef4; color: var(--muted); }

.video-list { display: grid; gap: 1rem; }
.video-card { display: grid; grid-template-columns: 11rem minmax(0, 1fr); gap: 1rem; padding: 1rem; }
.video-thumb { aspect-ratio: 16 / 9; width: 100%; object-fit: cover; border-radius: 1rem; background: var(--surface-soft); }
.video-title { margin: 0; font-size: 1.08rem; line-height: 1.3; }
.video-meta { display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; margin: .45rem 0; }
.video-actions { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: .75rem; }
.video-controls { display: grid; grid-template-columns: minmax(12rem, 1fr) minmax(12rem, 1fr); gap: .65rem; margin-top: .75rem; }
.reason-list { margin: .65rem 0 0; padding-left: 1.15rem; color: var(--muted); font-size: .86rem; }
.source-box { margin-top: .7rem; padding: .7rem; border-radius: .85rem; background: #faf9fd; color: var(--muted); font-size: .82rem; white-space: pre-wrap; overflow-wrap: anywhere; }

.child-course-tabs { display: flex; gap: .5rem; overflow-x: auto; padding: .2rem 0 .8rem; scrollbar-width: none; }
.child-course-tabs::-webkit-scrollbar { display: none; }
.chip { border: 1px solid var(--border); border-radius: 999px; padding: .55rem .85rem; background: var(--surface); color: var(--muted); white-space: nowrap; font-weight: 800; cursor: pointer; }
.chip.active { background: var(--primary); color: white; border-color: var(--primary); }
.child-video-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); gap: 1rem; }
.child-video-card { overflow: hidden; padding: 0; }
.child-video-card img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: var(--surface-soft); }
.child-video-body { padding: 1rem; }
.child-video-body h3 { margin: 0 0 .45rem; line-height: 1.3; }
.new-dot { display: inline-block; width: .55rem; height: .55rem; border-radius: 50%; background: var(--accent); margin-right: .35rem; }

.code-box { display: grid; place-items: center; min-height: 5rem; padding: 1rem; border: 2px dashed var(--primary); border-radius: 1rem; background: var(--surface-soft); font-size: 1.45rem; font-weight: 900; letter-spacing: .08em; }
.code-inline { display: block; padding: .65rem .75rem; border-radius: .75rem; background: #20183a; color: #f8f5ff; overflow-x: auto; white-space: nowrap; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .78rem; }
.steps { counter-reset: step; display: grid; gap: .7rem; padding: 0; list-style: none; }
.steps li { counter-increment: step; display: grid; grid-template-columns: 2rem 1fr; gap: .65rem; align-items: start; }
.steps li::before { content: counter(step); width: 2rem; height: 2rem; display: grid; place-items: center; border-radius: .7rem; background: var(--surface-soft); color: var(--primary-dark); font-weight: 900; }

.empty { text-align: center; padding: 2.5rem 1rem; border: 1px dashed var(--border); border-radius: var(--radius); color: var(--muted); }
.empty .emoji { display: block; font-size: 2.5rem; margin-bottom: .5rem; }

.toast {
  position: fixed;
  z-index: 100;
  left: 50%;
  bottom: calc(6.8rem + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(calc(100% - 2rem), 32rem);
  padding: .9rem 1rem;
  border-radius: 1rem;
  background: #211a36;
  color: white;
  box-shadow: var(--shadow);
  text-align: center;
  font-weight: 750;
}
.toast.error { background: var(--danger); }

.spinner { width: 1.4rem; height: 1.4rem; border: 3px solid rgba(109, 74, 255, .2); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 760px) {
  .grid.two, .grid.three, .form-row { grid-template-columns: 1fr; }
  .video-card { grid-template-columns: 1fr; }
  .video-thumb { max-height: 15rem; }
  .video-controls { grid-template-columns: 1fr; }
  .main-content { width: min(100% - 1.1rem, 76rem); margin-top: .8rem; }
  .card { padding: .9rem; }
}

@media (min-width: 900px) {
  .app-shell { padding-left: 15rem; padding-bottom: 2rem; }
  .topbar { padding-left: 16.2rem; }
  .bottom-nav {
    left: 1rem;
    top: 5.2rem;
    bottom: auto;
    transform: none;
    width: 13rem;
    grid-auto-flow: row;
    grid-auto-rows: auto;
    grid-auto-columns: initial;
    padding: .6rem;
  }
  .nav-button { display: grid; grid-template-columns: 1.7rem 1fr; align-items: center; text-align: left; padding: .7rem .8rem; font-size: .86rem; }
  .nav-button span { margin: 0; font-size: 1.1rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}


.settings-category {
  cursor: pointer;
  text-align: left;
  transition:
    transform .12s ease,
    box-shadow .12s ease,
    border-color .12s ease;
}

.settings-category:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: 0 10px 24px rgba(33, 20, 77, .08);
}

.settings-category:focus-visible {
  outline: 0;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(109, 74, 255, .16);
}

.settings-category h3 {
  margin-bottom: .35rem;
}


.notification-dialog {
  width: min(32rem, calc(100% - 2rem));
  margin: auto;
}

.notification-dialog::backdrop {
  background: rgba(30, 20, 55, .38);
}

.child-header-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: .45rem;
}

.child-header-buttons {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .5rem;
  flex-wrap: wrap;
}

.child-header-buttons .button {
  min-width: 7.5rem;
}

.child-refresh-meta {
  font-size: .78rem;
  color: var(--muted);
  text-align: right;
  line-height: 1.25;
}

.child-refresh-meta strong {
  color: var(--muted);
  font-weight: 600;
  margin-left: .2rem;
}

@media (max-width: 760px) {
  .child-header-actions {
    align-items: flex-start;
  }

  .child-header-buttons {
    justify-content: flex-start;
  }

  .child-refresh-meta {
    text-align: left;
  }
}
