:root {
  --bg: #0d0d0d;
  --surface: #1a1a1a;
  --surface-2: #161616;
  --border: #262626;
  --text: #f5f5f5;
  --muted: #8a8a8a;
  /* The intCount brand red, sampled from the official card wordmark. It is
     FLAT — the logo has no gradient. Do not reintroduce #e85a5a / #ff6b6b:
     those came from an old OTP email template that had drifted from the logo. */
  --accent: #e63946;
  --accent-light: #ef5b66;
  --green: #4ade80;
  --blue: #60a5fa;
  --amber: #fbbf24;
  --radius: 12px;
}

* { box-sizing: border-box; }

/* The [hidden] attribute is only enforced by the browser's own UA stylesheet
   at a class-level specificity (0,1,0). Any component rule that sets its own
   `display` at that same specificity — e.g. .login-wrap's `display: flex` —
   wins the tie, because author styles beat the UA stylesheet on equal
   specificity. That silently breaks `el.hidden = true`: the attribute is set
   correctly, JS sees it, but nothing visually changes. (This is exactly what
   broke the internal-admin unlock flow — #lock-screen carries .login-wrap's
   display:flex, so toggling .hidden on it had zero visual effect even though
   the fetch succeeded and the handler set the property correctly.) Force the
   win unconditionally rather than auditing every component for a `display`
   rule every time something reuses `hidden`. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

.wordmark {
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--accent);
}

/* ---------- buttons / inputs ---------- */

button, .btn {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 10px 16px;
  cursor: pointer;
  transition: border-color .15s, background .15s, opacity .15s;
}
button:hover, .btn:hover { border-color: #3a3a3a; }
button:disabled { opacity: .5; cursor: not-allowed; }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--accent);
  border: none;
  color: #17090a;
  font-weight: 700;
}
.btn-primary:hover { opacity: .92; }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-danger { color: var(--accent); }
.btn-danger:hover { border-color: var(--accent); }

input, select {
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 11px 13px;
  width: 100%;
}
input::placeholder { color: #5e5e5e; }
select { cursor: pointer; }
label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .04em;
  text-transform: uppercase;
  margin-bottom: 7px;
}

.field { margin-bottom: 16px; }
.muted { color: var(--muted); }
.error { color: var(--accent-light); font-size: 13px; min-height: 18px; margin-top: 10px; }

/* ---------- login ---------- */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 28px;
}
.login-card h1 { font-size: 30px; margin: 0 0 6px; }
.login-sub { color: var(--muted); font-size: 14px; margin: 0 0 26px; }

.code-input {
  text-align: center;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 10px;
  padding: 14px 10px;
  font-variant-numeric: tabular-nums;
}

.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: underline;
}
.link-btn:hover { color: var(--text); border: none; }

/* ---------- app shell ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
}
.topbar .brand { font-size: 21px; }
.school-name {
  font-size: 13px;
  color: var(--muted);
  padding-left: 14px;
  border-left: 1px solid var(--border);
  white-space: nowrap;
}
.topbar .spacer { flex: 1; }
.search { max-width: 260px; padding: 9px 12px; font-size: 13px; }

.nav-link {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 8px;
}
.nav-link:hover { color: var(--text); background: var(--surface); }
.nav-link.active { color: var(--text); background: var(--surface); }

/* EN | VI toggle — sits top-right of the nav on every page. On the two
   pages with no topbar (login/signup) it's fixed-positioned instead. */
.lang-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  flex-shrink: 0;
}
.lang-toggle-float {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 20;
}
.lang-btn {
  background: none;
  border: none;
  padding: 2px 3px;
  color: var(--muted);
  font-weight: 500;
  cursor: pointer;
  font-size: 13px;
}
.lang-btn:hover { color: var(--text); }
.lang-btn.active {
  color: var(--accent);
  font-weight: 700;
  text-decoration: underline;
}
.lang-sep { color: var(--border); font-size: 12px; }

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: #17090a;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

main { max-width: 900px; margin: 0 auto; padding: 26px 22px 60px; }
h2.page-title { font-size: 22px; font-weight: 700; margin: 0 0 20px; }

/* ---------- week tabs ---------- */

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 12px;
  margin-bottom: 8px;
}
.tab {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.tab.active { background: var(--accent); color: #17090a; border-color: transparent; }

/* ---------- lessons ---------- */

.day-group { margin-bottom: 26px; }
.day-head {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

.lesson {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  overflow: hidden;
}
.lesson-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
}
.file-icon {
  width: 40px;
  height: 40px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .04em;
  flex-shrink: 0;
}
.lesson-info { flex: 1; min-width: 0; }
.lesson-title {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lesson-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.class-tag { font-weight: 700; }

.children {
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  padding: 6px 16px 10px 70px;
}
.child-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid #202020;
  font-size: 13px;
}
.child-row:last-child { border-bottom: none; }
.child-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.empty {
  text-align: center;
  padding: 56px 20px;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* ---------- cards / admin ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
}
.card h3 { font-size: 15px; font-weight: 700; margin: 0 0 16px; }

.stat-row { display: flex; gap: 26px; flex-wrap: wrap; margin-bottom: 16px; }
.stat-label { font-size: 12px; color: var(--muted); }
.stat-value { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }

.bar {
  height: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.bar-fill { height: 100%; background: var(--accent); width: 0; transition: width .3s; }

.plan-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent);
  color: #17090a;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.teacher-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.teacher-row:last-child { border-bottom: none; }
.teacher-info { flex: 1; min-width: 0; }
.teacher-name { font-size: 14px; font-weight: 600; }
.teacher-email { font-size: 12px; color: var(--muted); }
.role-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
}
.role-badge.owner { color: var(--green); border-color: rgba(74, 222, 128, .35); }

.toggle { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); cursor: pointer; }
.toggle input { width: auto; }

.row-2 { display: flex; gap: 12px; flex-wrap: wrap; }
.row-2 > * { flex: 1; min-width: 140px; }

input[type="range"] { padding: 0; background: none; border: none; accent-color: var(--accent); }

/* ---------- landing page ---------- */

.landing { max-width: 960px; margin: 0 auto; padding: 0 22px 80px; }

.hero { padding: 72px 0 8px; text-align: center; }
.hero h1 {
  font-size: 46px;
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 0 0 18px;
  text-wrap: balance;
}
.hero-sub {
  font-size: 17px;
  line-height: 27px;
  color: var(--muted);
  max-width: 560px;
  margin: 0 auto 30px;
  font-weight: 300;
}
.hero-cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.btn-lg { padding: 14px 24px; font-size: 15px; }

/* Browser-chrome box so a visitor can see the real workspace before signing up */
.preview {
  margin: 56px 0 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  background: var(--surface-2);
}
.preview-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  background: #121212;
}
.preview-dot { width: 10px; height: 10px; border-radius: 50%; background: #2f2f2f; flex-shrink: 0; }
.preview-url {
  margin-left: 10px;
  font-size: 11px;
  color: #5e5e5e;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 10px;
}
.preview-body { padding: 18px; }
.preview-body .lesson { pointer-events: none; }
.preview-body .day-head { margin-top: 4px; }

.section-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
  margin: 72px 0 26px;
}

.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.feature { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.feature h3 { font-size: 16px; font-weight: 700; margin: 0 0 9px; }
.feature p { font-size: 14px; line-height: 22px; color: var(--muted); margin: 0; font-weight: 300; }

.pricing { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; align-items: start; }
.plan { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.plan.featured { border-color: var(--accent); }
.plan-name { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.plan-price { font-size: 34px; font-weight: 800; letter-spacing: -0.03em; margin: 10px 0 2px; }
.plan-price span { font-size: 14px; font-weight: 400; color: var(--muted); letter-spacing: 0; }
.plan-list { list-style: none; padding: 0; margin: 18px 0 22px; }
.plan-list li { font-size: 14px; color: var(--text); padding: 7px 0; border-bottom: 1px solid var(--border); font-weight: 300; }
.plan-list li:last-child { border-bottom: none; }
.plan .btn { display: block; width: 100%; text-align: center; }

.landing-footer {
  border-top: 1px solid var(--border);
  margin-top: 72px;
  padding-top: 26px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

@media (max-width: 760px) {
  .hero { padding-top: 48px; }
  .hero h1 { font-size: 34px; }
  .features, .pricing { grid-template-columns: 1fr; }
  .preview { margin-top: 40px; }
}

/* ---------- toast ---------- */

#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--green);
  border-radius: 10px;
  padding: 13px 18px;
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 100;
  max-width: 90vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { border-left-color: var(--accent); }

.status-line { font-size: 13px; color: var(--muted); margin-top: 12px; min-height: 18px; }

/* ---------- v2: verification, join requests, directory, comments ---------- */

.verified-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--blue);
  color: #0b1a2e;
  font-size: 11px;
  font-weight: 800;
  vertical-align: middle;
}

.join-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
}
.join-row:last-child { border-bottom: none; }
.join-info { flex: 1; min-width: 0; }
.join-name { font-size: 14px; font-weight: 600; }
.join-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.join-kids { font-size: 12px; color: var(--text); margin-top: 5px; }
.join-msg {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
  padding-left: 10px;
  border-left: 2px solid var(--border);
}
.join-actions { display: flex; gap: 7px; flex-shrink: 0; }

/* Directory cards stack rather than crowding onto one row, so each school
   gets its own block of breathing room however few of them there are. */
#schools { display: flex; flex-direction: column; gap: 16px; }
#schools .school-item { margin-bottom: 0; padding: 24px; }

.school-card { display: block; }
.school-card-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.school-card-name { font-size: 17px; font-weight: 600; min-width: 0; }
.school-card-slug { font-size: 12px; color: var(--muted); margin-top: 8px; font-weight: 400; }
.school-card-action { margin-top: 16px; }

.verified-pill {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--green);
  background: rgba(74, 222, 128, .10);
  border: 1px solid rgba(74, 222, 128, .35);
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

/* Three-state status pill for the internal verification review panel. */
.status-pill {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.status-pill.verified { color: var(--green); background: rgba(74, 222, 128, .10); border: 1px solid rgba(74, 222, 128, .35); }
.status-pill.pending { color: var(--amber); background: rgba(251, 191, 36, .10); border: 1px solid rgba(251, 191, 36, .35); }
.status-pill.none { color: var(--muted); background: rgba(138, 138, 138, .10); border: 1px solid var(--border); }

.join-form { border-top: 1px solid var(--border); margin-top: 16px; padding-top: 16px; }

.radio-row { display: flex; gap: 18px; }
.radio-opt {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  margin: 0;
}
.radio-opt input { width: auto; }
.kid-input-row { display: flex; gap: 8px; margin-bottom: 8px; }
.kid-input-row input { flex: 1; }

/* segmented toggle — used for the guardian's Family / Public choice */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.seg button {
  border: none;
  border-radius: 0;
  background: var(--surface-2);
  color: var(--muted);
  padding: 8px 15px;
  font-size: 13px;
}
.seg button.active { background: var(--accent); color: #17090a; }

.vis-tag {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid currentColor;
  white-space: nowrap;
}
.vis-staff_only { color: var(--accent); }
.vis-family { color: var(--amber); }
.vis-public { color: var(--green); }

.comments-panel {
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  padding: 12px 16px 14px 70px;
}
.comment { padding: 9px 0; border-bottom: 1px solid #202020; }
.comment:last-of-type { border-bottom: none; }
.comment-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.comment-author { font-size: 13px; font-weight: 600; }
.comment-role { font-size: 11px; }
.comment-date { font-size: 11px; margin-left: auto; }
.comment-body { font-size: 13px; line-height: 20px; margin-top: 4px; white-space: pre-wrap; word-break: break-word; }

textarea {
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 11px 13px;
  width: 100%;
  resize: vertical;
  min-height: 62px;
}
textarea::placeholder { color: #5e5e5e; }
textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.comment-composer { margin-top: 12px; }
.comment-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 9px;
  flex-wrap: wrap;
}
.comment-actions select { width: auto; min-width: 130px; padding: 8px 11px; font-size: 13px; }
.comment-actions .spacer-h { flex: 1; }

@media (max-width: 620px) {
  .comments-panel { padding-left: 20px; }
  .join-row { flex-wrap: wrap; }
}

@media (max-width: 620px) {
  .topbar { gap: 10px; padding: 12px 16px; }
  .school-name { display: none; }
  .search { max-width: 100%; order: 10; width: 100%; }
  main { padding: 20px 16px 50px; }
  .children { padding-left: 20px; }
}
