/* ═══════════════════════════════════════════════════════
   EduSpark Teacher Portal — Main Stylesheet
   Imported by: teachers-portal.html and all page files
   ═══════════════════════════════════════════════════════ */


/* ═══════════════════════════════════════════
   MODULE 0: BASE
   Design tokens inherited from css/vars.css
═══════════════════════════════════════════ */

/* Scoped scrollbar for activity list */
.activity-list::-webkit-scrollbar       { width: 4px; }
.activity-list::-webkit-scrollbar-track { background: transparent; }
.activity-list::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
}
[data-theme="dark"] .activity-list::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
}
[data-theme="dark"] .activity-list::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.2);
}

body { font-family: var(--sans); background: var(--bg); color: var(--text); display: flex; min-height: 100vh; }

/* ═══════════════════════════════════════════
   MODULE 1: LOGIN SCREEN
═══════════════════════════════════════════ */
#login-screen {
  position: fixed; inset: 0; z-index: 9999;
  display: flex;
  background: var(--bg);
  overflow: hidden;
}

.login-left {
  flex: 1;
  background: linear-gradient(135deg, var(--accent) 0%, var(--purple) 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 4rem;
  position: relative;
  overflow: hidden;
}

.login-left::before {
  content: '';
  position: absolute;
  width: 500px; height: 500px;
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
  top: -150px; right: -150px;
}

.login-left::after {
  content: '';
  position: absolute;
  width: 300px; height: 300px;
  border-radius: 50%;
  background: rgba(255,255,255,0.04);
  bottom: -80px; left: -80px;
}

.login-brand {
  font-family: 'Syne', sans-serif;
  font-size: 2rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 3rem;
  letter-spacing: -0.02em;
}
.login-brand span { color: #93c5fd; }

.login-tagline {
  font-size: 2.5rem;
  font-weight: 700;
  font-family: 'Syne', sans-serif;
  color: #fff;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin-bottom: 1.5rem;
}

.login-sub { color: #93c5fd; font-size: 1rem; line-height: 1.7; max-width: 380px; }

.login-features {
  margin-top: 3rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.lf-item {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  color: #bfdbfe;
  font-size: 0.9rem;
}

.lf-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.08);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.login-right {
  width: 480px;
  background: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 4rem;
}

.login-title {
  font-family: 'Syne', sans-serif;
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
  letter-spacing: -0.02em;
}

.login-subtitle { color: var(--muted); font-size: 0.9rem; margin-bottom: 2rem; }

.role-selector {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 2rem;
  background: var(--bg);
  padding: 4px;
  border-radius: 10px;
}

.role-btn {
  flex: 1;
  padding: 0.6rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.2s;
}

.role-btn.active {
  background: #fff;
  color: var(--accent);
  box-shadow: var(--shadow);
}

.field-group { margin-bottom: 1.2rem; }

.field-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 0.95rem;
  color: var(--text);
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

.field-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.08);
}

.login-btn {
  width: 100%;
  padding: 0.85rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  margin-top: 0.5rem;
  transition: background 0.2s, transform 0.15s;
}

.login-btn:hover { background: var(--accent-hover); transform: translateY(-1px); }

.login-demo-note {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.8rem;
  color: var(--muted);
  background: var(--bg);
  padding: 0.7rem;
  border-radius: 8px;
}

.login-demo-note strong { color: var(--accent); }

/* ═══════════════════════════════════════════
   MODULE 2: LAYOUT — SIDEBAR + MAIN
═══════════════════════════════════════════ */
#app { display: none; width: 100%; }

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar);
  min-height: 100vh;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 50;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 1rem 1.5rem 0.75rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.brand-logo {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
  font-size: 0.9rem;
  color: #fff;
  font-family: 'Syne', sans-serif;
  flex-shrink: 0;
}

.brand-name {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  color: #fff;
  letter-spacing: -0.01em;
}

.brand-name span { color: #60a5fa; }

/* Role badge */
.role-badge {
  margin: 0.5rem 1.5rem 0.25rem;
  background: rgba(37,99,235,0.15);
  border: 1px solid rgba(37,99,235,0.25);
  color: #93c5fd;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.3rem 0.7rem;
  border-radius: 50px;
  display: inline-block;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Nav groups */
.nav-group { padding: 0.25rem 0; }
.nav-group-label {
  padding: 0.45rem 1.5rem 0.2rem;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.25);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.48rem 1.5rem;
  color: rgba(255,255,255,0.55);
  cursor: pointer;
  transition: all 0.15s;
  font-size: 0.85rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  margin: 0;
}

.nav-item:hover {
  color: rgba(255,255,255,0.9);
  background: rgba(255,255,255,0.04);
}

.nav-item.active {
  color: #fff;
  background: rgba(37,99,235,0.2);
  border-left-color: var(--accent);
}

.nav-icon {
  width: 24px;
  height: 20px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--card);
  color: inherit;
  font-family: "Segoe UI Emoji","Apple Color Emoji","Noto Color Emoji",var(--sans);
  font-size: 0.95rem;
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 50px;
}

.sidebar-footer {
  margin-top: auto;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex;
  flex-direction: column;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  cursor: pointer;
}

.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  color: #fff;
  flex-shrink: 0;
}

.user-name { font-size: 0.85rem; font-weight: 600; color: #fff; }
.user-role { font-size: 0.72rem; color: rgba(255,255,255,0.4); }

.logout-btn {
  width: 100%;
  margin-top: 0.75rem;
  padding: 0.55rem;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  font-family: inherit;
  display: block;
}
.logout-btn:hover {
  background: rgba(220,38,38,0.15);
  border-color: rgba(220,38,38,0.4);
  color: #fca5a5;
}
.logout-btn:hover { background: rgba(220,38,38,0.2); color: #f87171; }

/* MAIN CONTENT */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* TOP BAR */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  height: 64px;
  display: flex;
  align-items: center;
  position: relative;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar-title {
  font-family: 'Syne', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.topbar-right { display: flex; align-items: center; gap: 1rem; }

.topbar-search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.8rem;
}

.topbar-search input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 0.85rem;
  color: var(--text);
  width: 180px;
}
.topbar-search input::placeholder { color: var(--muted); }

.topbar-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  border: none;
  transition: all 0.15s;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-outline { background: var(--surface); border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }

.notif-btn {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  color: var(--muted);
  position: relative;
  cursor: pointer;
}

.notif-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--red);
  border: 1.5px solid #fff;
}

/* PAGE CONTENT */
.page-content { padding: 2rem; flex: 1; }
.page { display: none; }
.page.active { display: block; }

/* ═══════════════════════════════════════════
   MODULE 3: DASHBOARD PAGE
═══════════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.2rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.stat-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.8rem; }

.stat-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
}

.stat-change {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 50px;
}

.change-up { background: var(--green-light); color: var(--green); }
.change-down { background: var(--red-light); color: var(--red); }

.stat-value {
  font-family: 'Syne', sans-serif;
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  margin-bottom: 0.3rem;
}

.stat-label { font-size: 0.82rem; color: var(--muted); font-weight: 500; }

/* Charts row */
.charts-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.2rem;
  margin-bottom: 2rem;
  align-items: stretch;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  padding: 1.2rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
}

.card-body { padding: 1.5rem; }

/* Simple bar chart */
.bar-chart { display: flex; align-items: flex-end; gap: 0.6rem; height: 130px; }

.bar-group { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; flex: 1; gap: 0.3rem; }

.bar-col {
  width: 100%;
  border-radius: 6px 6px 0 0;
  min-height: 4px;
  transition: opacity 0.2s;
}
.bar-col:hover { opacity: 0.8; }

.bar-label { font-size: 0.7rem; color: var(--muted); }

/* Activity feed */
.activity-list { display: flex; flex-direction: column; gap: 0; max-height: 320px; overflow-y: auto; }

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
  padding: 0.9rem 1.5rem;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.activity-item:last-child { border-bottom: none; }
.activity-item:hover { background: var(--bg); }

.activity-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 5px;
}

.activity-text { font-size: 0.85rem; line-height: 1.4; flex: 1; }
.activity-text strong { font-weight: 600; }
.activity-time { font-size: 0.75rem; color: var(--muted); white-space: nowrap; }

/* Subject breakdown */
.subject-breakdown { display: flex; flex-direction: column; gap: 0.8rem; }

.subj-row { display: flex; flex-direction: column; gap: 0.3rem; }
.subj-meta { display: flex; justify-content: space-between; font-size: 0.82rem; }
.subj-name { font-weight: 500; }
.subj-pct { color: var(--muted); }
.progress-track {
  height: 6px;
  background: var(--bg);
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill { height: 100%; border-radius: 99px; }

/* ═══════════════════════════════════════════
   MODULE 4: PAPER LIST PAGE
═══════════════════════════════════════════ */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.page-title {
  font-family: 'Syne', sans-serif;
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.page-subtitle { font-size: 0.85rem; color: var(--muted); margin-top: 0.15rem; }

.filter-row {
  display: flex;
  gap: 0.7rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.filter-select {
  padding: 0.5rem 0.8rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 0.85rem;
  color: var(--text);
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
}
.filter-select:focus { border-color: var(--accent); }

.papers-table { width: 100%; }
.papers-table table { width: 100%; border-collapse: collapse; }
.papers-table th {
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 0.8rem 1.2rem;
  border-bottom: 1px solid var(--border);
}

.papers-table td {
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
  vertical-align: middle;
}

.papers-table tr:hover td { background: var(--bg); }
.papers-table tr:last-child td { border-bottom: none; }

.paper-title-cell { font-weight: 600; color: var(--text); }
.paper-meta { font-size: 0.75rem; color: var(--muted); margin-top: 0.1rem; }

.subject-tag {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 50px;
  font-size: 0.72rem;
  font-weight: 600;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.65rem;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-published { background: var(--green-light); color: var(--green); }
.status-draft { background: var(--yellow-light); color: var(--yellow); }
.status-archived { background: var(--border); color: var(--muted); }

.action-btn {
  padding: 0.3rem 0.6rem;
  border: none;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 500;
  transition: all 0.15s;
  margin-right: 0.3rem;
}

.btn-edit { background: var(--accent-light); color: var(--accent); }
.btn-edit:hover { background: var(--accent); color: #fff; }
.btn-stats { background: var(--violet-light); color: var(--violet); }
.btn-stats:hover { background: var(--violet); color: #fff; }
.btn-copy { background: var(--green-l,#dcfce7); color: var(--green,#16a34a); }
.btn-copy:hover { background: var(--green,#16a34a); color: #fff; }
.btn-del { background: var(--red-light); color: var(--red); }
.btn-del:hover { background: var(--red); color: #fff; }
.btn-unpublish { background: #fef9c3; color: #a16207; }
.btn-unpublish:hover { background: #fbbf24; color: #fff; }
.btn-archive { background: var(--border); color: var(--muted); }
.btn-archive:hover { background: #64748b; color: #fff; }
.btn-publish { background: var(--green-light); color: var(--green); }
.btn-publish:hover { background: var(--green); color: #fff; }
.btn-danger { background: var(--red-light); color: var(--red); }
.btn-danger:hover { background: var(--red); color: #fff; }

/* Status toggle in papers table */
.status-toggle-cell { display:flex; flex-direction:column; align-items:center; gap:0.3rem; }
.status-toggle { position:relative; width:42px; height:22px; background:var(--border);
  border-radius:11px; border:none; cursor:pointer; transition:background 0.2s; flex-shrink:0; }
.status-toggle.on { background:var(--green); }
.status-toggle::after { content:''; position:absolute; top:3px; left:3px; width:16px; height:16px;
  border-radius:50%; background:#fff; transition:left 0.2s; }
.status-toggle.on::after { left:23px; }
.status-toggle:disabled { opacity:0.5; cursor:default; }
.status-toggle-label { font-size:0.68rem; font-weight:600; letter-spacing:0.03em; color:var(--muted);
  text-transform:uppercase; }
.status-toggle-label.archived { color:#94a3b8; }
.status-toggle-label.published { color:var(--green); }
.status-toggle-label.draft { color:var(--accent); }
.papers-actions { display:flex; gap:0.3rem; flex-wrap:wrap; justify-content:center; }
.stat-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(130px,1fr)); gap:0.75rem; margin-bottom:1rem; }
.stat-tile { background:var(--bg); border:1px solid var(--border); border-radius:8px; padding:0.75rem 1rem; }
.stat-tile-val { font-size:1.4rem; font-weight:700; color:var(--text); }
.stat-tile-lbl { font-size:0.72rem; color:var(--muted); margin-top:0.15rem; }
.score-band-row { display:flex; align-items:center; gap:0.6rem; margin-bottom:0.35rem; font-size:0.82rem; }
.score-band-bar { flex:1; height:8px; background:var(--border); border-radius:4px; overflow:hidden; }
.score-band-fill { height:100%; border-radius:4px; background:var(--accent); transition:width 0.5s; }

/* ═══════════════════════════════════════════
   MODULE 5: CREATE/UPLOAD PAPER FORM
═══════════════════════════════════════════ */
/* ── Wizard ── */
.wiz-header { display:flex; justify-content:space-between; align-items:flex-start; margin-bottom:1.5rem; }
.wiz-steps {
  display: flex; align-items: center;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; padding: 1.25rem 2rem;
  margin-bottom: 2rem; gap: 0;
}
.wiz-step {
  display: flex; align-items: center; gap: 0.6rem;
  cursor: pointer; opacity: 0.4; transition: opacity 0.2s;
  white-space: nowrap;
}
.wiz-step.active  { opacity: 1; }
.wiz-step.done    { opacity: 0.7; }
.wstep-num {
  width: 2rem; height: 2rem; border-radius: 50%;
  background: var(--border); color: var(--text2);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 0.8rem; transition: all 0.2s; flex-shrink:0;
}
.wiz-step.active .wstep-num  { background: var(--accent); color: #fff; box-shadow: 0 0 0 4px rgba(249,115,22,0.2); }
.wiz-step.done .wstep-num    { background: #22c55e; color: #fff; }
.wstep-label { font-size: 0.82rem; font-weight: 600; color: var(--text2); }
.wiz-step.active .wstep-label { color: var(--accent); }
.wiz-connector { flex: 1; height: 2px; background: var(--border); margin: 0 0.75rem; min-width: 20px; }
.wiz-panel { display: none; }
.wiz-panel.active { display: block; animation: fadeSlideIn 0.3s ease; }
@keyframes fadeSlideIn { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }
.wiz-nav {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 1.5rem; padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.form-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1.5rem;
  align-items: start;
}

.form-section { margin-bottom: 2rem; }

.form-section-title {
  font-family: 'Syne', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
.form-row.three { grid-template-columns: 1fr 1fr 1fr; }
.form-full { margin-bottom: 1rem; }

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.req { color: var(--red); }

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.07);
}

.form-textarea { resize: vertical; min-height: 80px; }

.time-input-group { display: flex; align-items: center; gap: 0.5rem; }
.time-input-group .form-input { text-align: center; font-family: 'JetBrains Mono', monospace; font-weight: 500; }
.time-sep { color: var(--muted); font-weight: 700; }

/* Question editor */
.question-list { display: flex; flex-direction: column; gap: 1rem; margin-bottom: 1rem; }

.question-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.question-card:hover { border-color: #cbd5e1; box-shadow: var(--shadow); }
.question-card.q-has-error { border-color: #ef4444 !important; box-shadow: 0 0 0 3px rgba(239,68,68,0.15) !important; }
.q-error-banner {
  display: flex; align-items: center; gap: 0.5rem;
  background: #fef2f2; border-top: 1px solid #fecaca;
  color: #dc2626; font-size: 0.82rem; font-weight: 500;
  padding: 0.55rem 1rem;
}
.q-error-banner svg { flex-shrink: 0; }

.q-header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0.8rem 1.2rem;
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.q-num {
  width: 26px; height: 26px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-family: 'JetBrains Mono', monospace;
}

.q-type-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 50px;
  background: var(--accent-light);
  color: var(--accent);
}

.q-actions { margin-left: auto; display: flex; gap: 0.3rem; }

.q-action-btn {
  width: 26px; height: 26px;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem;
  transition: all 0.15s;
}

.q-action-btn:hover { background: var(--border); color: var(--text); }

.q-body { padding: 1.2rem; }

.q-text-area {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 0.7rem;
  font-size: 0.88rem;
  resize: none;
  min-height: 60px;
  background: var(--bg);
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
  color: var(--text);
}
.q-text-area:focus { border-color: var(--accent); background: var(--input-bg); color: var(--text); }

.q-image-zone {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
  margin-top: 0.7rem;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  font-size: 0.8rem;
  color: var(--muted);
}

.q-image-zone:hover { border-color: var(--accent); background: var(--accent-light); color: var(--accent); }

.choices-list { margin-top: 0.8rem; display: flex; flex-direction: column; gap: 0.5rem; }

.choice-row { display: flex; align-items: center; gap: 0.6rem; }

.choice-letter {
  width: 28px; height: 28px;
  border-radius: 6px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
  font-family: 'JetBrains Mono', monospace;
  transition: all 0.15s;
  cursor: pointer;
}

.choice-letter.correct-choice { background: var(--green-light); border-color: var(--green); color: var(--green); }

.choice-input {
  flex: 1;
  padding: 0.5rem 0.7rem;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s;
  background: var(--bg);
  color: var(--text);
  color: var(--text);
}
.choice-input:focus { border-color: var(--accent); background: var(--input-bg); color: var(--text); }

.choice-img-btn {
  width: 30px; height: 30px;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 0.85rem;
  transition: all 0.15s;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.choice-img-btn:hover { border-color: var(--accent); color: var(--accent); }

.choice-del-btn {
  width: 26px; height: 26px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 0.85rem;
  transition: all 0.15s;
}
.choice-del-btn:hover { background: var(--red-light); color: var(--red); }

.add-choice-btn, .add-q-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border: 1.5px dashed var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
  transition: all 0.2s;
}

.add-choice-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }
.add-q-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }

.q-type-single { background:#eff6ff; color:#2563eb; }
.q-type-multi  { background:#fef3c7; color:#d97706; }

.multi-toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 0.7rem 1rem;
  margin-bottom: 0.75rem;
}
.scoring-mode-row { margin-bottom: 0.75rem; }
.correct-hint { font-size: 0.75rem; color: var(--muted); margin-top: 0.4rem; font-style: italic; }

/* Sidebar settings panel */
.settings-panel { display: flex; flex-direction: column; gap: 1.2rem; }

.settings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.settings-card-title {
  padding: 0.9rem 1.2rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.settings-body { padding: 1rem 1.2rem; display: flex; flex-direction: column; gap: 0.8rem; }

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0;
}
.toggle-row + .toggle-row {
  border-top: 1px solid var(--border);
}

.toggle-label { font-size: 0.85rem; font-weight: 500; }
.toggle-sub { font-size: 0.75rem; color: var(--muted); margin-top: 0.15rem; }

.toggle {
  width: 40px; height: 22px;
  background: var(--border);
  border-radius: 99px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
  border: none;
}

.toggle.on { background: var(--accent); }
.toggle::after {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  top: 3px; left: 3px;
  transition: left 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle.on::after { left: 21px; }

/* ── Availability window ───────────────────────────────────── */
.avail-window {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.avail-window-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text2);
  margin: 0.75rem 0 0.3rem;
  transition: opacity 0.2s;
}
.avail-window-label:first-child { margin-top: 0; }

/* Disabled state — greyed out when Always Available is ON */
.avail-disabled .avail-window-label {
  opacity: 0.4;
}
.avail-disabled .avail-dt-input {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* datetime-local: whole input clickable, fix dark mode calendar icon */
input[type="datetime-local"].avail-dt-input {
  cursor: pointer;
  transition: opacity 0.2s;
}
input[type="datetime-local"].avail-dt-input::-webkit-calendar-picker-indicator {
  cursor: pointer;
  border-radius: 3px;
  padding: 2px;
  opacity: 0.7;
}
input[type="datetime-local"].avail-dt-input::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}
[data-theme="dark"] input[type="datetime-local"].avail-dt-input::-webkit-calendar-picker-indicator {
  filter: invert(1);
}

.score-display {
  background: var(--bg);
  border-radius: 8px;
  padding: 0.8rem;
  text-align: center;
}

.score-time {
  font-family: 'JetBrains Mono', monospace;
  font-size: 2rem;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: 0.05em;
}

.score-time-label { font-size: 0.72rem; color: var(--muted); margin-top: 0.2rem; }

.time-presets { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.5rem; }
.time-preset {
  padding: 0.25rem 0.6rem;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
}
.time-preset:hover, .time-preset.active { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }

.publish-btn {
  padding: 0.65rem 1.5rem;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 700;
  transition: all 0.2s;
  font-family: inherit;
  white-space: nowrap;
}
.publish-btn:hover { background: #15803d; transform: translateY(-1px); }

.draft-btn {
  padding: 0.65rem 1.25rem;
  background: transparent;
  color: var(--muted);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.2s;
  font-family: inherit;
  white-space: nowrap;
}
.draft-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ═══════════════════════════════════════════
   MODULE 6: STATISTICS PAGE
═══════════════════════════════════════════ */
.stats-paper-selector {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.stat-overview-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

.overview-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
  box-shadow: var(--shadow);
  text-align: center;
}

.ov-val {
  font-family: 'Syne', sans-serif;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 0.2rem;
}

.ov-label { font-size: 0.78rem; color: var(--muted); font-weight: 500; }

.score-dist { display: flex; flex-direction: column; gap: 0.6rem; }
.dist-row { display: flex; align-items: center; gap: 0.7rem; font-size: 0.82rem; }
.dist-range { width: 60px; color: var(--muted); text-align: right; }
.dist-bar-track { flex: 1; height: 8px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.dist-bar { height: 100%; border-radius: 99px; }
.dist-count { width: 30px; font-weight: 600; }

.student-attempts-table table { width: 100%; border-collapse: collapse; }
.student-attempts-table th {
  text-align: left;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}
.student-attempts-table td {
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.student-attempts-table tr:last-child td { border-bottom: none; }
.student-attempts-table tr:hover td { background: var(--bg); }

.score-pill {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 50px;
  font-size: 0.78rem;
  font-weight: 700;
}

.score-high { background: var(--green-light); color: var(--green); }
.score-mid { background: var(--yellow-light); color: var(--yellow); }
.score-low { background: var(--red-light); color: var(--red); }

/* Q difficulty */
.diff-bars { display: flex; flex-direction: column; gap: 0.7rem; }
.diff-row { display: flex; align-items: center; gap: 0.7rem; font-size: 0.8rem; }
.diff-q-num { width: 24px; font-family: 'JetBrains Mono', monospace; color: var(--muted); font-size: 0.72rem; }
.diff-track { flex: 1; height: 10px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.diff-fill { height: 100%; border-radius: 99px; }
.diff-pct { width: 36px; text-align: right; font-weight: 600; font-family: 'JetBrains Mono', monospace; font-size: 0.75rem; }

/* ═══════════════════════════════════════════
   MODULE 7: USERS PAGE
═══════════════════════════════════════════ */
.users-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.user-mgmt-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
  box-shadow: var(--shadow);
  transition: transform 0.2s;
}

.user-mgmt-card:hover { transform: translateY(-2px); }

.user-mgmt-top {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 0.9rem;
}

.um-avatar {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.um-name { font-weight: 600; font-size: 0.9rem; }
.um-email { font-size: 0.75rem; color: var(--muted); }

.um-role-badge {
  margin-left: auto;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 50px;
}

.role-admin { background: var(--violet-light); color: var(--violet); }
.role-teacher { background: var(--accent-light); color: var(--accent); }
.role-student { background: var(--green-light); color: var(--green); }

.um-stats { display: flex; gap: 1rem; padding: 0.7rem 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); margin-bottom: 0.8rem; }
.um-stat { text-align: center; flex: 1; }
.um-stat-val { font-weight: 700; font-size: 0.95rem; font-family: 'Syne', sans-serif; }
.um-stat-lbl { font-size: 0.68rem; color: var(--muted); }

.um-actions { display: flex; gap: 0.5rem; }

/* ═══════════════════════════════════════════
   MODULE 8: MODALS
═══════════════════════════════════════════ */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 500;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: 16px;
  width: 420px;
  max-width: 95vw;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: 1.2rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 1rem; }

.modal-close {
  width: 30px; height: 30px;
  border: none;
  border-radius: 6px;
  background: var(--bg);
  color: var(--muted);
  font-size: 1rem;
  transition: all 0.15s;
}
.modal-close:hover { background: var(--red-light); color: var(--red); }

.modal-body { padding: 1.5rem; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); display: flex; gap: 0.7rem; justify-content: flex-end; }

/* ═══════════════════════════════════════════
   UTILITY
═══════════════════════════════════════════ */
.text-muted { color: var(--muted); }
.text-sm { font-size: 0.82rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.ml-auto { margin-left: auto; }
.font-mono { font-family: 'JetBrains Mono', monospace; }

.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--muted);
}
.empty-icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-title { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 1.1rem; color: var(--text); margin-bottom: 0.4rem; }
.empty-sub { font-size: 0.88rem; }

/* ── Teacher Settings ── */
.ts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  max-width: 900px;
}
.ts-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem 1.5rem;
}
.ts-card-title {
  font-size: 0.95rem; font-weight: 700;
  color: var(--text); margin-bottom: 1.1rem;
}
.ts-fields  { display: flex; flex-direction: column; gap: 0.75rem; }
.ts-field   { display: flex; flex-direction: column; gap: 0.3rem; }
.ts-label   { font-size: 0.75rem; font-weight: 600; color: var(--muted); }
.ts-input   {
  background: var(--input-bg, var(--surface2));
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.8rem;
  font-size: 0.85rem;
  font-family: inherit;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}
.ts-input:focus  { border-color: var(--accent); }
.ts-textarea     { resize: vertical; min-height: 72px; }
.ts-save-btn {
  margin-top: 1.1rem; width: 100%;
  background: var(--accent); color: #fff;
  border: none; border-radius: 8px;
  padding: 0.65rem; font-size: 0.85rem;
  font-weight: 700; font-family: inherit;
  cursor: pointer; transition: background 0.15s, opacity 0.15s;
}
.ts-save-btn:hover    { background: var(--accent-hover); }
.ts-save-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.ts-msg {
  font-size: 0.78rem; padding: 0.5rem 0.8rem;
  border-radius: 8px; margin-bottom: 0.8rem; font-weight: 500;
}
.ts-msg.success { background: var(--green-light); color: var(--green); }
.ts-msg.error   { background: var(--red-light);   color: var(--red); }
.ts-pw-strength { height: 4px; background: var(--border); border-radius: 99px; overflow: hidden; margin-top: 4px; }
.ts-pw-fill     { height: 100%; border-radius: 99px; transition: width 0.3s, background 0.3s; }
.ts-av-preview  {
  width: 72px; height: 72px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #6366f1);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; margin: 0 auto;
  border: 3px solid var(--border);
}
.ts-avatar-grid {
  display: grid; grid-template-columns: repeat(6,1fr); gap: 0.5rem;
}
.ts-av-opt {
  aspect-ratio: 1; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; cursor: pointer;
  border: 2.5px solid var(--border);
  background: var(--surface2);
  transition: border-color 0.15s, transform 0.1s;
}
.ts-av-opt:hover    { border-color: var(--accent); transform: scale(1.08); }
.ts-av-opt.selected { border-color: var(--accent); background: var(--accent-light); }
.ts-theme-opts {
  display: grid; grid-template-columns: repeat(3,1fr); gap: 0.6rem;
}
.ts-theme-opt {
  border: 2px solid var(--border); border-radius: 10px;
  padding: 0.8rem 0.5rem; text-align: center;
  cursor: pointer; background: var(--surface2);
  transition: border-color 0.15s, background 0.15s;
}
.ts-theme-opt:hover  { border-color: var(--accent); }
.ts-theme-opt.active { border-color: var(--accent); background: var(--accent-light); }
.ts-theme-icon { font-size: 1.5rem; margin-bottom: 0.25rem; }
.ts-theme-name { font-size: 0.8rem; font-weight: 700; color: var(--text); }
.ts-theme-sub  { font-size: 0.65rem; color: var(--muted); margin-top: 1px; }
.ts-id-box {
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.8rem;
  font-size: 0.85rem;
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.05em;
  user-select: all;
}


/* ══ NEW SETTINGS — PROFILE VIEW & MODALS ══════════════════════════════ */

.ts-profile-view {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.4rem 1.6rem;
  display: flex;
  align-items: center;
  gap: 1.4rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  box-shadow: 0 1px 6px rgba(0,0,0,.06);
}
.ts-pv-avatar-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
  flex-shrink: 0;
}
.ts-pv-avatar {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #6366f1);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.9rem; color: #fff; font-weight: 800;
  border: 3px solid var(--border);
  overflow: hidden;
}
.ts-pv-avatar img { width: 100%; height: 100%; object-fit: cover; }
.ts-pv-edit-btn {
  font-size: .75rem; font-weight: 700;
  padding: .35rem .9rem; border-radius: 20px;
  border: 1.5px solid var(--accent); color: var(--accent);
  background: var(--accent-light); cursor: pointer;
  white-space: nowrap; transition: all .15s;
  font-family: inherit;
}
.ts-pv-edit-btn:hover { background: var(--accent); color: #fff; }
.ts-pv-info {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: .18rem;
}
.ts-pv-name  { font-size: 1.1rem; font-weight: 800; line-height: 1.3; }
.ts-pv-email { font-size: .82rem; color: var(--muted); }
.ts-pv-id    { font-family: monospace; font-size: .72rem; color: var(--muted); margin-top: .1rem; }
.ts-pv-chip  {
  font-size: .72rem; font-weight: 600;
  background: var(--surface2); border-radius: 20px;
  padding: .2rem .65rem;
}
.ts-pv-chip-accent { color: var(--accent); background: var(--accent-light); }
.ts-pv-chip:empty  { display: none; }
.ts-pw-trigger-btn {
  margin-left: auto; align-self: flex-start;
  font-size: .78rem; font-weight: 700;
  padding: .45rem 1.1rem; border-radius: 20px;
  border: 1.5px solid var(--border);
  color: var(--muted); background: transparent;
  cursor: pointer; white-space: nowrap;
  transition: all .15s; font-family: inherit;
}
.ts-pw-trigger-btn:hover { border-color: #dc2626; color: #dc2626; background: #fee2e2; }

.ts-section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.3rem 1.6rem;
  margin-bottom: 1rem;
}
.ts-section-title { font-size: .95rem; font-weight: 800; margin-bottom: 1rem; }

.ts-prefs-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 768px) { .ts-prefs-row { grid-template-columns: 1fr; } }

/* ── Modals ── */
.ts-modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 600;
  align-items: center; justify-content: center;
  padding: 1.5rem;
}
.ts-modal-overlay[style*="flex"] { display: flex !important; }
.ts-modal {
  background: var(--surface);
  border-radius: 20px;
  width: 100%; max-width: 540px;
  max-height: 90vh;
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  animation: tsFadeIn .25s ease;
}
@keyframes tsFadeIn {
  from { opacity: 0; transform: scale(.97) translateY(8px); }
  to   { opacity: 1; transform: scale(1)   translateY(0); }
}
.ts-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.4rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.ts-modal-title { font-size: 1rem; font-weight: 800; }
.ts-modal-back  {
  font-size: .8rem; font-weight: 600; color: var(--muted);
  background: none; border: none; cursor: pointer; padding: .3rem .5rem;
}
.ts-modal-back:hover { color: var(--accent); }
.ts-modal-done-btn {
  font-size: .8rem; font-weight: 700; color: var(--accent);
  background: var(--accent-light); border: 1.5px solid var(--accent);
  border-radius: 20px; padding: .3rem .8rem; cursor: pointer;
}
.ts-modal-fields {
  flex: 1; overflow-y: auto;
  padding: 1.2rem 1.5rem;
  display: flex; flex-direction: column; gap: .85rem;
}
.ts-modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.ts-modal-avatar-row {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: .6rem; padding: 1.3rem 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0; text-align: center;
}
.ts-modal-avatar-info { display: flex; flex-direction: column; align-items: center; gap: .4rem; }
.ts-modal-avatar-name { font-weight: 700; font-size: .95rem; }
.ts-av-preview {
  width: 64px; height: 64px; border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #6366f1);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.7rem; color: #fff; font-weight: 800;
  border: 3px solid var(--border); overflow: hidden; flex-shrink: 0;
}
.ts-av-preview img { width: 100%; height: 100%; object-fit: cover; }
.ts-change-av-btn {
  font-size: .78rem; font-weight: 700; padding: .35rem .85rem;
  border-radius: 20px; border: 1.5px solid var(--border);
  color: var(--muted); background: rgba(0,0,0,.04);
  cursor: pointer; transition: all .15s;
}
.ts-change-av-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }
.ts-upload-row {
  display: flex; align-items: center; gap: .8rem;
  padding: .9rem 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.ts-upload-btn {
  display: inline-flex; align-items: center; gap: .4rem;
  font-size: .8rem; font-weight: 700; cursor: pointer;
  padding: .45rem 1rem; border-radius: 20px;
  border: 1.5px dashed var(--border);
  color: var(--muted); background: rgba(0,0,0,.03);
  transition: all .15s;
}
.ts-upload-btn:hover { border-color: var(--accent); color: var(--accent); }
.ts-avatar-overlay { z-index: 650; }
.ts-av-opt {
  aspect-ratio: 1; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; cursor: pointer;
  border: 2.5px solid var(--border);
  background: rgba(0,0,0,.03); transition: all .15s;
}
.ts-av-opt:hover   { border-color: var(--accent); transform: scale(1.08); }
.ts-av-opt.selected{ border-color: var(--accent); background: var(--accent-light); }


/* ── Create Paper: inline validation errors ── */
/* .input-error on the <select>/<input> itself → red border only, never hides the element */
.input-error {
  border-color: var(--red) !important;
}
.field-error-msg {
  font-size: .72rem;
  color: var(--red);
  margin-top: .25rem;
  display: none;
}
.field-error-msg.show { display: block; }
.wiz-error-banner {
  background: var(--red-light);
  border: 1px solid var(--red);
  color: var(--red);
  border-radius: 10px;
  padding: .65rem 1rem;
  font-size: .83rem;
  font-weight: 600;
  margin-bottom: 1rem;
  display: none;
}
.wiz-error-banner.show { display: flex; align-items: center; gap: .5rem; }

/* ══ MOBILE RESPONSIVE ══ */
.ap-hamburger {
  display: none; flex-direction: column; justify-content: center;
  gap: 5px; background: none; border: none; cursor: pointer;
  padding: 6px; margin-right: .3rem; flex-shrink: 0;
}
.ap-hamburger span {
  display: block; width: 22px; height: 2px;
  background: var(--text, #f1f5f9); border-radius: 2px; transition: all .25s;
}
.ap-hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.ap-hamburger.open span:nth-child(2) { opacity: 0; }
.ap-hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
.mob-overlay { display:none; position:fixed; inset:0; background:rgba(0,0,0,.55); z-index:49; }
.mob-overlay.open { display:block; }

@media (max-width:768px) {
  body { --sidebar-w: 0px; }

  /* Hamburger & Sidebar */
  .ap-hamburger { display: flex; }
  .sidebar {
    width: 272px !important;
    transform: translateX(-100%);
    transition: transform .28s cubic-bezier(.4,0,.2,1);
    z-index: 50;
    box-shadow: 4px 0 24px rgba(0,0,0,.3);
  }
  .sidebar.open { transform: translateX(0); }

  /* Floating topbar */
  .topbar {
    position: fixed !important;
    top: 0; left: 0; right: 0;
    height: 54px; padding: 0 .8rem;
    gap: .3rem; z-index: 48;
    width: 100%; box-sizing: border-box;
  }
  .topbar-title  { font-size: .85rem; }
  .topbar-search { display: none; }
  .topbar-btn    { padding: .3rem .5rem; font-size: .72rem; }
  .topbar-right  { gap: .4rem; }

  /* Contain horizontal overflow at every level */
  html, body { overflow-x: hidden; }
  #app        { overflow-x: hidden; width: 100%; }
  .main       { margin-left: 0 !important; width: 100%; padding-top: 54px; overflow-x: hidden; }
  .page-content { padding: .9rem !important; box-sizing: border-box !important; overflow-x: hidden; }
  .ap-page    { box-sizing: border-box !important; overflow-x: hidden; }
  .page-header { flex-wrap: wrap; gap: .5rem; }

  /* Cards clip their own overflow */
  .card { overflow: hidden !important; max-width: 100% !important; box-sizing: border-box !important; }
  .card-header { padding: .8rem 1rem !important; flex-wrap: wrap; gap: .4rem; }
  .card-body   { padding: .8rem 1rem !important; }

  /* Table scroll: the .tbl-wrap div (added in HTML) scrolls */
  .tbl-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
  }
  .tbl-wrap table { min-width: 520px; }
  .papers-table .tbl-wrap table { min-width: 700px; }
  th, td { white-space: nowrap; font-size: .75rem !important; padding: .4rem .5rem !important; }

  /* Wizard steps */
  .wiz-steps {
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap !important; padding-bottom: .3rem;
  }

  /* KPI grids */
  .stats-grid, .stat-overview-grid { grid-template-columns: 1fr 1fr !important; gap: .6rem !important; margin-bottom: 1rem !important; }
  .stat-card  { padding: .85rem !important; }
  .charts-row { grid-template-columns: 1fr !important; gap: .8rem !important; }
  .three, .form-row, .step-row { grid-template-columns: 1fr !important; }
  .papers-grid, .users-grid { grid-template-columns: 1fr !important; }
  .filter-row, .filters-row { flex-wrap: wrap !important; gap: .4rem !important; }

  /* Settings */
  .ts-modal { max-width: calc(100vw - 2rem) !important; border-radius: 16px; }
  .ts-profile-view { flex-direction: column !important; align-items: stretch !important; padding: 1rem !important; gap: .75rem; }
  .ts-pv-avatar-wrap { flex-direction: row !important; align-items: center !important; gap: .8rem; }
  .ts-pv-info { min-width: 0; }
  .ts-pv-name { font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .ts-pv-email { font-size: .72rem; word-break: break-all; }
  .ts-pw-trigger-btn { margin-left: 0 !important; width: 100% !important; text-align: center; }
  .ts-section-card { padding: 1rem !important; }
}

@media (max-width:480px) {
  .stats-grid, .stat-overview-grid { grid-template-columns: 1fr !important; }
  .page-content { padding: .7rem !important; }
}

/* Math toolbar styles are injected by js/math-toolbar.js */

/* ═══════════════════════════════════════════
   MY ADVERTISEMENTS TAB
═══════════════════════════════════════════ */
.my-ads-card {
  padding: 1.1rem 1.3rem;
}
.my-ads-card-header {
  display: flex; align-items: center;
  justify-content: space-between; gap: 1rem;
  margin-bottom: .85rem;
}
.my-ads-meta {
  display: flex; flex-direction: column; gap: .4rem;
}
.my-ads-meta-item {
  display: flex; align-items: baseline; gap: .6rem;
  font-size: .83rem; color: var(--text);
}
.my-ads-meta-label {
  font-size: .72rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em;
  min-width: 90px; flex-shrink: 0;
}

/* ═══════════════════════════════════════════
   VISIBILITY STEP — WIZARD STEP 4
═══════════════════════════════════════════ */
.vis-cards {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.vis-card {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem 1.1rem;
  border: 2px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s, box-shadow 0.18s;
  position: relative;
}
.vis-card:hover {
  border-color: var(--accent);
  background: var(--accent-l, #eff6ff);
}
.vis-card.selected {
  border-color: var(--accent);
  background: var(--accent-l, #eff6ff);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

.vis-card-icon {
  font-size: 1.6rem;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.vis-card-body {
  flex: 1;
  min-width: 0;
}

.vis-card-title {
  font-family: var(--display);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.25rem;
}
.vis-card.selected .vis-card-title { color: var(--accent); }

.vis-card-desc {
  font-size: 0.82rem;
  color: var(--text2);
  line-height: 1.5;
}

.vis-card-check {
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  border: 2px solid var(--border2, #cbd5e1);
  flex-shrink: 0;
  margin-top: 0.25rem;
  transition: all 0.18s;
  background: transparent;
}
.vis-card.selected .vis-card-check {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: inset 0 0 0 3px #fff;
}

[data-theme="dark"] .vis-card:hover,
[data-theme="dark"] .vis-card.selected {
  background: rgba(37,99,235,0.12);
}

/* ═══════════════════════════════════════════
   CLASSROOMS PAGE
═══════════════════════════════════════════ */

/* Tier usage bar */
.cls-tier-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem 1.1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.cls-tier-info {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.83rem;
  color: var(--text2);
  flex-shrink: 0;
}
.cls-tier-track {
  flex: 1;
  min-width: 80px;
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.cls-tier-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.4s ease;
}
.cls-upgrade-link {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}
.cls-upgrade-link:hover { text-decoration: underline; }

/* Classroom cards grid */
.cls-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.cls-card {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  padding: 1.25rem;
  cursor: pointer;
  transition: border-color 0.18s, box-shadow 0.18s, transform 0.18s;
}
.cls-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 20px rgba(37,99,235,0.12);
  transform: translateY(-2px);
}

.cls-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.cls-card-name {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
  line-height: 1.3;
  flex: 1;
}

.cls-card-code {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--accent);
  background: var(--accent-l, #eff6ff);
  padding: 0.25rem 0.55rem;
  border-radius: 6px;
  cursor: copy;
  flex-shrink: 0;
  transition: background 0.15s;
}
.cls-card-code:hover { background: var(--accent); color: #fff; }

.cls-card-desc {
  font-size: 0.8rem;
  color: var(--text2);
  margin-bottom: 0.75rem;
  line-height: 1.4;
}

.cls-card-stats {
  display: flex;
  gap: 1.5rem;
  margin: 0.85rem 0 0.75rem;
}
.cls-card-stat { text-align: center; }
.cls-stat-val {
  font-family: var(--mono);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
.cls-stat-lbl {
  font-size: 0.68rem;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 0.2rem;
}

.cls-capacity-track {
  height: 4px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 0.3rem;
}
.cls-capacity-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.4s ease;
}
.cls-capacity-label {
  font-size: 0.7rem;
  color: var(--text3);
  text-align: right;
}

/* Empty state — spans all grid columns so it centres properly */
.cls-empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text2);
}
.cls-empty-icon  { font-size: 3rem; margin-bottom: 1rem; }
.cls-empty-title { font-family: var(--display); font-size: 1.1rem; font-weight: 700; color: var(--text); margin-bottom: 0.5rem; }
.cls-empty-desc  { font-size: 0.85rem; line-height: 1.5; }

/* Invite code chip in detail header */
.cls-code-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--accent-l, #eff6ff);
  border: 1.5px solid var(--accent);
  border-radius: 10px;
  padding: 0.4rem 0.85rem;
  cursor: pointer;
  transition: background 0.15s;
}
.cls-code-chip:hover { background: var(--accent); color: #fff; }
.cls-code-chip:hover .cls-code-label,
.cls-code-chip:hover .cls-code-val,
.cls-code-chip:hover .cls-code-copy { color: #fff; }
.cls-code-label { font-size: 0.7rem; color: var(--text2); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.cls-code-val   { font-family: var(--mono); font-size: 0.95rem; font-weight: 800; color: var(--accent); letter-spacing: 0.12em; }
.cls-code-copy  { font-size: 0.7rem; color: var(--accent); font-weight: 600; }

/* Classroom detail tabs */
.cls-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.5rem;
}
.cls-tab {
  padding: 0.65rem 1.4rem;
  font-size: 0.88rem;
  font-weight: 600;
  font-family: var(--display);
  color: var(--text2);
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.cls-tab:hover  { color: var(--text); }
.cls-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.cls-tab-panel { display: none; }
.cls-tab-panel.active { display: block; animation: fadeSlideIn 0.25s ease; }

.cls-member-count {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text2);
  background: var(--bg);
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  border: 1px solid var(--border);
}

/* Analytics grid table */
.cls-analytics-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.82rem;
}
.cls-analytics-table th,
.cls-analytics-table td {
  border: 1px solid var(--border);
  padding: 0.4rem 0.6rem;
}
.cls-analytics-table thead th {
  background: var(--bg);
  font-weight: 700;
  color: var(--text2);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.cls-analytics-table tbody tr:hover { background: var(--bg); }
