/* ============================================
   Teacher — Modern UI v2
   ============================================ */

:root {
  /* surfaces — clean, bright off-white with a hint of warmth (premium) */
  --bg: #f8f8fb;
  --bg-soft: #fcfcfe;
  --surface: #ffffff;
  --surface-2: #f4f5f8;
  --surface-3: #ebedf2;
  --link: #6366f1;

  /* borders — light, clean hairlines used sparingly */
  --border: #e8e9ef;
  --border-strong: #d6d8e1;

  /* text — crisp near-black with a clear muted hierarchy */
  --text: #1c1e26;
  --text-soft: #444751;
  --muted: #6c6f7a;
  --muted-soft: #9a9da8;

  /* brand — modern indigo / violet accent */
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-soft: #eef0fe;
  --primary-deep: #4338ca;
  --accent: #8b5cf6;

  /* feedback */
  --success: #16a34a;
  --success-soft: #dcfce7;
  --warning: #f59e0b;
  --warning-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --info: #0ea5e9;
  --info-soft: #e0f2fe;

  /* sidebar — refined neutral dark slate (not navy) */
  --sidebar-bg: #15161b;
  --sidebar-bg-2: #1a1c22;
  --sidebar-fg: #b3b5be;
  --sidebar-fg-active: #ffffff;
  --sidebar-accent: #818cf8;

  /* effects */
  --shadow-xs: 0 1px 1px rgba(15, 23, 42, 0.025);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.035), 0 1px 2px rgba(15, 23, 42, 0.02);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.05), 0 2px 4px rgba(15, 23, 42, 0.025);
  --shadow-lg: 0 16px 44px rgba(15, 23, 42, 0.09), 0 6px 12px rgba(15, 23, 42, 0.035);
  --shadow-xl: 0 24px 64px rgba(15, 23, 42, 0.12);
  --ring: 0 0 0 4px rgba(99, 102, 241, 0.12);

  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  --t-fast: 0.12s ease;
  --t-base: 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

* { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

html, body {
  background: var(--bg);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  color: var(--text);
  letter-spacing: -0.005em;
  line-height: 1.55;
}

body { font-feature-settings: "cv11", "ss01", "ss03"; }

h1, h2, h3, h4, h5, h6 {
  letter-spacing: -0.022em;
  font-weight: 700;
  color: var(--text);
}

a { color: var(--primary); text-decoration: none; transition: color var(--t-fast); }
a:hover { color: var(--primary-hover); text-decoration: none; }

pre { font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; word-wrap: break-word; font-size: 0.85em; }
code { font-family: "JetBrains Mono", ui-monospace, monospace; background: var(--surface-3); padding: 0.1em 0.35em; border-radius: var(--radius-xs); font-size: 0.88em; }

::selection { background: var(--primary); color: #fff; }

/* ---------- Layout ---------- */

.layout {
  display: grid;
  grid-template-columns: 256px 1fr;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */

.sidebar {
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-2) 100%);
  color: var(--sidebar-fg);
  display: flex;
  flex-direction: column;
  padding: 1.1rem 0.7rem 0.9rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid rgba(255,255,255,0.04);
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.07); border-radius: 4px; }

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 700;
  font-size: 1.15rem;
  color: #fff;
  padding: 0.2rem 0.7rem 1rem 0.7rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  margin-bottom: 0.75rem;
  letter-spacing: -0.02em;
}
.sidebar .brand i {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  border-radius: 10px;
  color: #fff;
  font-size: 1.1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 10px rgba(99, 102, 241, 0.3);
}

.sidebar-search {
  position: relative;
  margin: 0 0.25rem 0.85rem 0.25rem;
}
.sidebar-search i {
  position: absolute;
  left: 0.8rem;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(255,255,255,0.38);
  font-size: 0.85rem;
  pointer-events: none;
}
.sidebar-search input {
  width: 100%;
  padding: 0.65rem 0.85rem 0.65rem 2.4rem;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 9px;
  color: #fff;
  font-size: 0.95rem;
  outline: none;
  transition: all var(--t-fast);
}
.sidebar-search i { font-size: 0.95rem; }
.sidebar-search input::placeholder { color: rgba(255,255,255,0.36); }
.sidebar-search input:hover { background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.1); }
.sidebar-search input:focus {
  background: rgba(255,255,255,0.08);
  border-color: var(--sidebar-accent);
  box-shadow: 0 0 0 3px rgba(129,140,248,0.18);
}

.sidebar .nav-link {
  color: var(--sidebar-fg);
  padding: 0.5rem 0.7rem;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  font-size: 0.9rem;
  font-weight: 500;
  margin: 0.1rem 0.2rem;
  transition: background var(--t-fast), color var(--t-fast);
  position: relative;
}
.sidebar .nav-link i { font-size: 1.02rem; opacity: 0.7; transition: opacity var(--t-fast); }
.sidebar .nav-link:hover {
  background: rgba(255,255,255,0.05);
  color: #fff;
}
.sidebar .nav-link:hover i { opacity: 1; }
.sidebar .nav-link.active {
  background: rgba(129,140,248,0.14);
  color: #fff;
  font-weight: 600;
}
.sidebar .nav-link.active::before {
  content: "";
  position: absolute;
  left: -0.2rem;
  top: 22%;
  bottom: 22%;
  width: 3px;
  background: var(--sidebar-accent);
  border-radius: 0 3px 3px 0;
}
.sidebar .nav-link.active i { color: #c7d2fe; opacity: 1; }

.sidebar-sublist {
  margin: 0.15rem 0 0.55rem 0.85rem;
  padding-left: 0.85rem;
  border-left: 1px solid rgba(255,255,255,0.07);
}
.sidebar-substudent {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.45rem 0.7rem;
  border-radius: 8px;
  color: rgba(255,255,255,0.62);
  font-size: 0.92rem;
  line-height: 1.25;
  transition: all var(--t-fast);
}
.sidebar-substudent:hover {
  background: rgba(255,255,255,0.05);
  color: #fff;
}
.sidebar-substudent .name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-footer {
  margin-top: auto;
  padding: 0.75rem 0.5rem 0.25rem;
  border-top: 1px solid rgba(255,255,255,0.05);
}
.me-name { color: #fff; font-weight: 600; font-size: 1rem; }
.me-role { color: rgba(255,255,255,0.42); font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 0.75rem; font-weight: 700; }
.sidebar .btn-outline-light {
  border-color: rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.85);
  font-weight: 500;
  font-size: 0.92rem;
  padding: 0.5rem 0.8rem;
}
.sidebar .btn-outline-light:hover { background: rgba(255,255,255,0.08); color: #fff; border-color: rgba(255,255,255,0.2); }

/* ---------- Content area ---------- */

.content {
  padding: 2.25rem 2.85rem 4rem;
  max-width: 1600px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 0.85rem;
}
.page-header h1 {
  font-size: 1.5rem;
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.page-header .subtitle { color: var(--muted); font-size: 0.9rem; margin-top: 0.2rem; font-weight: 500; }

/* ---------- Cards ---------- */

.card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  /* Gentle "float" — premium depth without heaviness */
  box-shadow: 0 1px 2px rgba(17, 18, 28, 0.03), 0 6px 20px rgba(17, 18, 28, 0.05);
  transition: box-shadow var(--t-base), border-color var(--t-base);
}
.card-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.95rem 1.3rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.card-header i { color: var(--muted); font-size: 1rem; }
.card-header .header-action { margin-left: auto; }
.card-header .header-action.small a, .card-header .header-action.small button { font-size: 0.88rem; color: var(--muted); font-weight: 500; }
.card-header .header-action.small a:hover, .card-header .header-action.small button:hover { color: var(--primary); }
.card-body { padding: 1.4rem; }

.card-section-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 0.75rem;
}

/* ---------- Stat cards ---------- */

.stat-card {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 1.4rem 1.55rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  box-shadow: var(--shadow-sm);
  transition: all var(--t-base);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top right, rgba(99,102,241,0.05), transparent 60%);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--t-base);
}
.stat-card:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); transform: translateY(-2px); }
.stat-card:hover::before { opacity: 1; }
.stat-label {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 700;
}
.stat-value {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1.1;
}
.stat-sub { color: var(--muted); font-size: 0.88rem; margin-top: 0.2rem; font-weight: 500; }

/* ---------- Buttons ---------- */

.btn {
  font-weight: 500;
  font-size: 0.98rem;
  padding: 0.6rem 1.1rem;
  border-radius: 9px;
  letter-spacing: -0.005em;
  transition: all var(--t-fast);
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid transparent;
}
.btn-sm { padding: 0.42rem 0.8rem; font-size: 0.9rem; border-radius: 7px; }
.btn i { font-size: 0.95em; }

.btn-primary {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.28);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #5558e3 0%, #7c4ef0 100%);
  border-color: transparent;
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 5px 16px rgba(99, 102, 241, 0.42);
}
.btn-primary:active { transform: translateY(0); }
.btn-primary:focus, .btn-primary:focus-visible { box-shadow: var(--ring); }

.btn-outline-secondary {
  border-color: var(--border-strong);
  color: var(--text);
  background: var(--surface);
}
.btn-outline-secondary:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-strong);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn-soft {
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid transparent;
}
.btn-soft:hover { background: #dde0fc; color: var(--primary-hover); }

.btn-link { color: var(--muted); padding: 0.3rem 0.5rem; font-size: 0.95rem; }
.btn-link:hover { color: var(--primary); text-decoration: none; }
.btn-link.text-danger { color: var(--danger); }
.btn-link.text-danger:hover { color: var(--danger); }

.btn-success {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
  box-shadow: 0 1px 2px rgba(22,163,74,0.18);
}
.btn-success:hover { background: #15803d; color: #fff; border-color: #15803d; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(22,163,74,0.22); }

.btn-outline-danger { color: var(--danger); border-color: var(--danger); }
.btn-outline-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

/* ---------- Badges ---------- */

.badge {
  font-weight: 600;
  font-size: 0.8rem;
  padding: 0.32em 0.7em;
  border-radius: 6px;
  letter-spacing: 0.01em;
}
.badge-status-scheduled { background: var(--info); color: #fff; }
.badge-status-completed { background: var(--success); color: #fff; }
.badge-status-cancelled { background: var(--danger); color: #fff; }
.badge-status-rescheduled { background: var(--warning); color: #fff; }
.badge-status-assigned { background: var(--muted); color: #fff; }
.badge-status-submitted { background: var(--warning); color: #fff; }
.badge-status-reviewed { background: var(--success); color: #fff; }
.badge-status-overdue { background: var(--danger); color: #fff; }

/* Homework status pills */
.badge-hw { font-weight: 600; padding: 0.25em 0.6em; border-radius: 999px; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.04em; }
.badge-hw-not_sent { background: var(--surface-3); color: var(--muted); }
.badge-hw-sent { background: rgba(14,165,233,0.15); color: #075985; }
.badge-hw-received { background: rgba(245,158,11,0.18); color: #78350f; }
.badge-hw-reviewed { background: rgba(34,197,94,0.18); color: #166534; }
.badge-hw-overdue { background: rgba(220,38,38,0.18); color: #7f1d1d; }
.badge-hw-needs_revision { background: rgba(217,70,239,0.16); color: #86198f; }
[data-theme="dark"] .badge-hw-sent { color: #7dd3fc; }
[data-theme="dark"] .badge-hw-received { color: #fcd34d; }
[data-theme="dark"] .badge-hw-reviewed { color: #86efac; }
[data-theme="dark"] .badge-hw-overdue { color: #fca5a5; }
[data-theme="dark"] .badge-hw-needs_revision { color: #f0abfc; }

/* Drag-drop file area */
.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 1.6rem;
  text-align: center;
  background: var(--surface-2);
  transition: all 0.15s;
  cursor: pointer;
}
.dropzone:hover { border-color: var(--primary); }
.dropzone.is-dragging { border-color: var(--primary); background: var(--primary-soft); }
.dropzone i { font-size: 1.8rem; color: var(--muted); display: block; margin-bottom: 0.4rem; }
.dropzone .hint { color: var(--muted); font-size: 0.92rem; }
.dropzone input[type=file] { display: none; }

.badge-lang { background: var(--primary-soft); color: var(--primary-deep); font-weight: 600; }
.badge-level { background: var(--surface-3); color: var(--text-soft); font-weight: 600; }

/* ---------- Tabs ---------- */

.nav-tabs {
  border-bottom: 1px solid var(--border);
  gap: 0.15rem;
}
.nav-tabs .nav-link {
  border: none;
  color: var(--muted);
  font-weight: 500;
  font-size: 1rem;
  padding: 0.85rem 1.25rem;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  transition: all var(--t-fast);
  border-radius: 0;
}
.nav-tabs .nav-link:hover {
  border-bottom-color: var(--border-strong);
  color: var(--text);
  background: var(--surface-2);
}
.nav-tabs .nav-link.active {
  color: var(--primary);
  background: transparent;
  border-bottom-color: var(--primary);
  font-weight: 600;
}

/* ---------- Forms ---------- */

.form-label { font-weight: 500; font-size: 0.95rem; color: var(--text); margin-bottom: 0.4rem; }
.form-label.small { font-size: 0.82rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }

.form-control, .form-select {
  border-color: var(--border);
  background: var(--surface);
  font-size: 1rem;
  padding: 0.65rem 0.9rem;
  border-radius: 9px;
  transition: all var(--t-fast);
  color: var(--text);
}
.form-control:hover, .form-select:hover { border-color: var(--border-strong); }
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: var(--ring);
  background: var(--surface);
}
.form-control::placeholder { color: var(--muted-soft); }
.form-control-sm, .form-select-sm { padding: 0.45rem 0.7rem; font-size: 0.92rem; border-radius: 7px; }
textarea.form-control { line-height: 1.5; }
.form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }
.form-check-input:focus { box-shadow: var(--ring); border-color: var(--primary); }

.filter-bar {
  background: transparent;
  border: none;
  border-radius: var(--radius);
  padding: 0.4rem 0;
  box-shadow: none;
}
.filter-bar .row { --bs-gutter-y: 0.5rem; }
/* Quieter, smaller field labels in filter bars (they dominate otherwise) */
.filter-bar .form-label, .filter-bar .form-label.small {
  font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted-soft); font-weight: 700; margin-bottom: 0.15rem;
}
.filter-bar .form-control, .filter-bar .form-select { background: var(--surface); }

/* ---------- Tables ---------- */

.table { color: var(--text); margin-bottom: 0; font-size: 0.98rem; }
.table > thead { font-size: 0.82rem; }
.table > thead th {
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  font-weight: 700;
  background: var(--surface-2) !important;
  border-bottom-color: var(--border);
  border-top: none;
  padding: 0.85rem 1.2rem;
}
.table > tbody > tr > td { padding: 0.95rem 1.2rem; vertical-align: middle; border-color: var(--border); }
.table > tbody > tr { transition: background var(--t-fast); }
.table > tbody > tr:hover { background: var(--surface-2); }
.table > tbody > tr:last-child > td { border-bottom: none; }

/* ---------- List groups ---------- */

.list-group-item {
  padding: 1rem 1.4rem;
  border-color: var(--border);
  transition: background var(--t-fast);
  font-size: 0.98rem;
}
.list-group-item:first-child { border-top: none; }
.list-group-item:last-child { border-bottom: none; }
.list-group-item:hover { background: var(--surface-2); }
.list-group-item a { color: var(--text); font-weight: 500; }
.list-group-item a:hover { color: var(--primary); }
.list-group-item .meta { color: var(--muted); font-size: 0.88rem; margin-top: 0.2rem; font-weight: 400; }
.list-group-item .secondary { font-size: 0.88rem; color: var(--muted); font-weight: 400; }

/* ---------- Timeline ---------- */

.timeline { position: relative; padding-left: 1.85rem; }
.timeline::before {
  content: "";
  position: absolute;
  top: 0.65rem; bottom: 0.65rem;
  left: 0.5rem;
  width: 2px;
  background: linear-gradient(180deg, var(--border) 0%, transparent 100%);
}
.tl-item { position: relative; padding: 0 0 1.15rem 0; }
.tl-item::before {
  content: "";
  position: absolute;
  left: -1.55rem;
  top: 0.5rem;
  width: 11px; height: 11px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--primary);
  box-shadow: 0 0 0 4px var(--bg);
}
.tl-item.session::before { border-color: var(--success); }
.tl-item.note::before { border-color: var(--info); }
.tl-item.todo::before { border-color: var(--warning); }
.tl-item.material::before { border-color: var(--muted); }
.tl-kind {
  display: inline-block;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 0.15rem;
}
.tl-title { font-weight: 600; font-size: 1.05rem; }
.tl-date { color: var(--muted-soft); font-size: 0.88rem; margin-top: 0.1rem; }
.tl-body { color: var(--muted); font-size: 0.95rem; margin-top: 0.35rem; }

/* Compact one-line timeline rows */
.timeline-list { padding: 0; }
.tl-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
}
.tl-row:last-child { border-bottom: none; }
.tl-row:hover { background: var(--surface-2); }
.tl-row .tl-date {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
  min-width: 130px;
  margin-top: 0;
}
.tl-row .tl-kind {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  background: var(--surface-3);
  color: var(--muted);
  margin: 0;
  min-width: 70px;
  text-align: center;
}
.tl-row.session .tl-kind { background: rgba(34,197,94,0.15); color: #166534; }
.tl-row.note .tl-kind { background: rgba(14,165,233,0.15); color: #0c4a6e; }
.tl-row.todo .tl-kind { background: rgba(245,158,11,0.15); color: #78350f; }
.tl-row.material .tl-kind { background: var(--surface-3); }
.tl-row.homework .tl-kind { background: rgba(99,102,241,0.15); color: #3730a3; }
.tl-row.homework-file .tl-kind { background: rgba(99,102,241,0.10); color: #4338ca; }
.tl-row.homework-overdue .tl-kind { background: rgba(220,38,38,0.18); color: #7f1d1d; }
.tl-row.progress .tl-kind { background: rgba(139, 92, 246, 0.15); color: #5b21b6; }
.tl-row.progress-teacher .tl-kind { background: rgba(34,197,94,0.15); color: #166534; }
.tl-row.progress-ai .tl-kind { background: rgba(14,165,233,0.18); color: #0c4a6e; }
.tl-row.progress-manual .tl-kind { background: rgba(245,158,11,0.18); color: #78350f; }
.tl-row.started .tl-kind { background: linear-gradient(90deg, var(--primary) 0%, var(--accent) 100%); color: #fff; }
[data-theme="dark"] .tl-row.started .tl-kind { color: #fff; }
[data-theme="dark"] .tl-row.progress .tl-kind { color: #c4b5fd; }
[data-theme="dark"] .tl-row.progress-teacher .tl-kind { color: #86efac; }
[data-theme="dark"] .tl-row.progress-ai .tl-kind { color: #7dd3fc; }
[data-theme="dark"] .tl-row.progress-manual .tl-kind { color: #fcd34d; }
[data-theme="dark"] .tl-row.homework .tl-kind { color: #c7d2fe; }
[data-theme="dark"] .tl-row.homework-file .tl-kind { color: #a5b4fc; }
[data-theme="dark"] .tl-row.homework-overdue .tl-kind { color: #fca5a5; }
[data-theme="dark"] .tl-row.session .tl-kind { color: #86efac; }
[data-theme="dark"] .tl-row.note .tl-kind { color: #7dd3fc; }
[data-theme="dark"] .tl-row.todo .tl-kind { color: #fcd34d; }
.tl-row .tl-title { font-weight: 500; color: var(--text); text-overflow: ellipsis; overflow: hidden; }
.tl-row .tl-title:hover { color: var(--primary); }
.tl-row .tl-body { flex: 1; overflow: hidden; text-overflow: ellipsis; font-size: 0.9rem; margin-top: 0; }

/* ---------- Login ---------- */

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 10%, rgba(139, 92, 246, 0.35) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(99, 102, 241, 0.3) 0%, transparent 55%),
    linear-gradient(135deg, #0f1424 0%, #1e1b4b 100%);
  padding: 2rem;
}
.login-card {
  background: #fff;
  border-radius: var(--radius-xl);
  padding: 3rem 3.25rem;
  width: 100%;
  max-width: 500px;
  box-shadow: 0 32px 72px rgba(15, 15, 50, 0.45);
}
.login-card h1 {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 0.45rem;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.login-card .sub { color: var(--muted); margin-bottom: 2.1rem; font-size: 1.05rem; }

/* ---------- Empty states ---------- */

.empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
  font-size: 1rem;
}
.empty i {
  font-size: 2.3rem;
  display: block;
  margin-bottom: 0.65rem;
  color: var(--muted-soft);
  opacity: 0.6;
}
.empty-inline { padding: 1.2rem; color: var(--muted); font-size: 0.95rem; text-align: center; }

/* ---------- Definition list ---------- */

.dl-grid {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 0.75rem 1.4rem;
}
.dl-grid dt { color: var(--muted); font-weight: 500; font-size: 0.95rem; padding-top: 0.1rem; }
.dl-grid dd { margin: 0; font-size: 1rem; color: var(--text); }

/* Custom student fields wrap at ~30 characters wide and break long unbreakable strings. */
.custom-field-value {
  max-width: 30ch;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  font-size: 0.92rem;
  font-family: inherit;
  margin: 0;
}

/* ---------- Chip / avatar ---------- */

.chip-list { display: flex; flex-wrap: wrap; gap: 0.55rem; }
.chip-student {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 1rem 0.55rem 0.55rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.95rem;
  color: var(--text);
  font-weight: 500;
  transition: all var(--t-fast);
  box-shadow: var(--shadow-xs);
}
.chip-student:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.chip-student .avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.chip-student .lang { font-size: 0.74rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; }
.chip-student .flag-img { width: 22px; height: 14px; border-radius: 2px; }

/* ---------- Flags ---------- */

.flag-img { width: 26px; height: 17px; border-radius: 2px; vertical-align: middle; box-shadow: 0 0 0 1px rgba(0,0,0,0.08); object-fit: cover; }
.flag-img-lg { width: 48px; height: 30px; border-radius: 4px; box-shadow: 0 0 0 1px rgba(0,0,0,0.08); object-fit: cover; }
.sidebar-substudent .flag-img { width: 20px; height: 13px; box-shadow: 0 0 0 1px rgba(255,255,255,0.12); }

/* ---------- Todo list ---------- */

.todo-list { padding: 0; margin: 0; }
.todo-item {
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  transition: background var(--t-fast);
}
.todo-item:last-child { border-bottom: none; }
.todo-item:hover { background: var(--surface-2); }
.todo-item.done .todo-title { text-decoration: line-through; color: var(--muted-soft); }
.todo-handle { cursor: grab; color: #d4d7e0; user-select: none; padding-top: 0.2rem; font-size: 1.3rem; transition: color var(--t-fast); }
.todo-handle:hover { color: var(--primary); }
.todo-handle:active { cursor: grabbing; }
.todo-check .btn-check-toggle {
  background: none; border: none; padding: 0;
  font-size: 1.4rem; cursor: pointer;
  transition: transform var(--t-fast);
}
.todo-check .btn-check-toggle:hover { transform: scale(1.1); }
.todo-body { flex: 1; min-width: 0; }
.todo-title { font-weight: 500; word-break: break-word; font-size: 1rem; }
.todo-desc { color: var(--muted); font-size: 0.95rem; margin-top: 0.25rem; white-space: pre-wrap; }
.todo-meta { font-size: 0.88rem; color: var(--muted); margin-top: 0.5rem; display: flex; gap: 1rem; flex-wrap: wrap; }
.todo-meta a, .todo-meta span { color: var(--muted); text-decoration: none; font-weight: 500; }
.todo-meta a:hover { color: var(--primary); }
.todo-actions { display: flex; gap: 0; }
.todo-actions .btn { padding: 0.15rem 0.45rem; }
.todo-ghost { opacity: 0.4; background: var(--primary-soft) !important; }

/* Reminders pad CSS removed — feature deleted */
.btn-check-toggle { background: none; border: none; padding: 0; font-size: 1.3rem; cursor: pointer; }

/* ---------- Alerts ---------- */

.alert {
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 1rem 1.35rem;
  font-size: 1rem;
  font-weight: 500;
}
.alert-success { background: var(--success-soft); color: #14532d; border-color: #86efac; }
.alert-danger { background: var(--danger-soft); color: #7f1d1d; border-color: #fca5a5; }
.alert-warning { background: var(--warning-soft); color: #78350f; border-color: #fcd34d; }

/* ---------- Modals ---------- */

.modal-content {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
}
.modal-dialog { max-width: 600px; }
.modal-header {
  border-bottom-color: var(--border);
  padding: 1.2rem 1.4rem;
}
.modal-title { font-size: 1.15rem; font-weight: 700; }
.modal-body { padding: 1.4rem; }
.modal-footer { padding: 1.05rem 1.4rem; border-top-color: var(--border); gap: 0.5rem; }

/* ---------- Misc ---------- */

.text-dim { color: var(--muted); }
.row-tight { --bs-gutter-y: 0.85rem; }
hr { background-color: var(--border); opacity: 1; height: 1px; border: 0; }

/* Scrollbar polish */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--muted-soft); }

/* ---------- Dark mode ---------- */

[data-theme="dark"] {
  /* Neutral charcoal — modern (Linear / GitHub), not navy, not pure black.
     Surfaces step up in lightness to give a clear elevation hierarchy. */
  --bg: #0f1012;
  --bg-soft: #141518;
  --surface: #17181c;
  --surface-2: #1d1f24;
  --surface-3: #25272d;

  --border: #292b31;
  --border-strong: #383b43;

  --text: #e8e8ec;
  --text-soft: #bcbec6;
  --muted: #8c8f99;
  --muted-soft: #6a6d76;

  --primary: #818cf8;
  --primary-hover: #a5b4fc;
  --primary-soft: rgba(129, 140, 248, 0.16);
  --primary-deep: #6366f1;
  --accent: #a78bfa;

  --success-soft: rgba(34, 197, 94, 0.16);
  --danger-soft: rgba(239, 68, 68, 0.16);
  --warning-soft: rgba(245, 158, 11, 0.18);

  --sidebar-bg: #0b0c0e;
  --sidebar-bg-2: #101114;

  --shadow-xs: 0 1px 1px rgba(0, 0, 0, 0.25);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.55);
  --shadow-xl: 0 24px 64px rgba(0, 0, 0, 0.6);
  --ring: 0 0 0 4px rgba(129, 140, 248, 0.22);
}
[data-theme="dark"] body { background: var(--bg); color: var(--text); }
[data-theme="dark"] .login-page {
  background:
    radial-gradient(circle at 18% 12%, rgba(129, 140, 248, 0.14) 0%, transparent 50%),
    radial-gradient(circle at 82% 85%, rgba(139, 92, 246, 0.10) 0%, transparent 55%),
    linear-gradient(150deg, #0d0e11 0%, #14131c 100%);
}
[data-theme="dark"] .login-card {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 32px 72px rgba(0, 0, 0, 0.55);
}
[data-theme="dark"] .table > thead th { background: var(--surface-2) !important; color: var(--muted); border-bottom-color: var(--border); }
[data-theme="dark"] .form-control, [data-theme="dark"] .form-select {
  background: var(--surface-2); color: var(--text); border-color: var(--border);
}
[data-theme="dark"] .form-control:hover, [data-theme="dark"] .form-select:hover { border-color: var(--border-strong); }
[data-theme="dark"] .form-control:focus, [data-theme="dark"] .form-select:focus {
  background: var(--surface); border-color: var(--primary);
  box-shadow: var(--ring);
}
[data-theme="dark"] .form-control::placeholder { color: var(--muted-soft); }
[data-theme="dark"] .form-control:disabled, [data-theme="dark"] .form-select:disabled { background: var(--surface-3); color: var(--muted); }
[data-theme="dark"] .list-group, [data-theme="dark"] .list-group-item {
  background: var(--surface); color: var(--text); border-color: var(--border);
}
[data-theme="dark"] .list-group-item:hover { background: var(--surface-2); }
[data-theme="dark"] .list-group-item a { color: var(--text); }
[data-theme="dark"] .list-group-item a:hover { color: var(--primary); }
[data-theme="dark"] .alert-success { background: var(--success-soft); color: #86efac; border-color: rgba(34,197,94,0.3); }
[data-theme="dark"] .alert-danger { background: var(--danger-soft); color: #fca5a5; border-color: rgba(239,68,68,0.3); }
[data-theme="dark"] .alert-warning { background: var(--warning-soft); color: #fcd34d; border-color: rgba(245,158,11,0.3); }
[data-theme="dark"] .badge-lang { background: rgba(129, 140, 248, 0.15); color: #a5b4fc; }
[data-theme="dark"] .badge-level { background: var(--surface-3); color: var(--text-soft); }
[data-theme="dark"] .nav-tabs { border-bottom-color: var(--border); }
[data-theme="dark"] .nav-tabs .nav-link { color: var(--muted); }
[data-theme="dark"] .nav-tabs .nav-link:hover { background: var(--surface-2); color: var(--text); border-bottom-color: var(--border-strong); }
[data-theme="dark"] .table > tbody > tr:hover { background: var(--surface-2); }
[data-theme="dark"] .btn-outline-secondary { color: var(--text); border-color: var(--border-strong); background: var(--surface); }
[data-theme="dark"] .btn-outline-secondary:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
[data-theme="dark"] .modal-content { background: var(--surface); color: var(--text); border-color: var(--border); }
[data-theme="dark"] .btn-close { filter: invert(1) opacity(0.65); }
[data-theme="dark"] .chip-student { background: var(--surface); border-color: var(--border); color: var(--text); }
[data-theme="dark"] .chip-student:hover { background: rgba(129,140,248,0.12); border-color: var(--primary); color: var(--primary); }
/* Reminder dark-theme overrides removed — feature deleted */
[data-theme="dark"] .todo-item { background: var(--surface); border-bottom-color: var(--border); }
[data-theme="dark"] .todo-item:hover { background: var(--surface-2); }
[data-theme="dark"] .filter-bar { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .card-header { background: var(--surface); border-bottom-color: var(--border); }
[data-theme="dark"] pre, [data-theme="dark"] code { color: var(--text); background: var(--surface-2); }
[data-theme="dark"] .text-dim, [data-theme="dark"] .meta, [data-theme="dark"] .stat-sub, [data-theme="dark"] .secondary { color: var(--muted); }
[data-theme="dark"] hr { background-color: var(--border); }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: var(--border-strong); border-color: var(--bg); }
[data-theme="dark"] .table > tbody > tr > td { border-color: var(--border); color: var(--text); }
[data-theme="dark"] .login-card .sub { color: var(--muted); }
[data-theme="dark"] .stat-card::before { background: radial-gradient(circle at top right, rgba(129,140,248,0.08), transparent 60%); }

/* ---------- Theme toggle ---------- */

.theme-toggle {
  width: 100%;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  color: var(--sidebar-fg);
  padding: 0.55rem 0.7rem;
  border-radius: 9px;
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  cursor: pointer;
  margin-top: 0.6rem;
  transition: all var(--t-fast);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.theme-toggle:hover { background: rgba(255,255,255,0.07); color: #fff; border-color: rgba(255,255,255,0.12); }
.theme-toggle .bi-sun-fill { display: none; }
[data-theme="dark"] .theme-toggle .bi-moon-fill { display: none; }
[data-theme="dark"] .theme-toggle .bi-sun-fill { display: inline-block; }
.theme-toggle .theme-label::before { content: "Dark"; }
[data-theme="dark"] .theme-toggle .theme-label::before { content: "Light"; }

/* ---------- Animations ---------- */

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.card, .stat-card, .chip-student, .alert { animation: fadeUp 0.32s var(--t-base) both; }

/* ---------- Responsive ---------- */

@media (max-width: 992px) {
  html, body { font-size: 15px; }
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .content { padding: 1.25rem; }
  .dl-grid { grid-template-columns: 1fr; }
  .page-header h1 { font-size: 1.3rem; }
  .stat-value { font-size: 1.9rem; }
}

/* Small-screen safety net: stack the page header, tighten cards, and make
   sure wide tables scroll inside their card instead of breaking the layout. */
@media (max-width: 575.98px) {
  .content { padding: 1rem 0.9rem 2rem; }
  .page-header { align-items: flex-start; }
  .page-header h1 { font-size: 1.2rem; }
  .card-body { padding: 1rem; }
  .table-responsive { -webkit-overflow-scrolling: touch; }
  .table > tbody > tr > td, .table > thead th { padding: 0.7rem 0.8rem; }
}


/* ============================================================
   v17 — Z-index, dropdown clipping, polish
   ============================================================ */

/* Bootstrap defaults stack: dropdown=1000, modal-backdrop=1040, modal=1050,
   tooltip=1080. We bump dropdowns above sticky headers and modals above
   dropdowns so menus open over cards / Kanban grids reliably. */
:root {
  --z-sticky-bar: 50;
  --z-dropdown: 1100;
  --z-popover: 1110;
  --z-modal-backdrop: 1140;
  --z-modal: 1150;
  --z-tooltip: 1200;
  --z-toast: 1300;
}

.dropdown-menu        { z-index: var(--z-dropdown) !important; }
.popover              { z-index: var(--z-popover) !important; }
.modal-backdrop       { z-index: var(--z-modal-backdrop) !important; }
.modal                { z-index: var(--z-modal) !important; }
.tooltip              { z-index: var(--z-tooltip) !important; }
.toast, .toast-container { z-index: var(--z-toast) !important; }

/* Bootstrap appends modals to <body>, so they're never clipped by parent
   overflow. Dropdowns inside cards CAN be clipped, though — fix by using
   Popper's `boundary` fix and never letting cards hide overflow on the y axis
   when they contain dropdowns. */
.card, .session-card, .mini-card, .detail-card { overflow: visible; }

/* Bootstrap puts ".dropdown-menu" relative to its toggle — make sure
   transformed/sticky ancestors can't trap it inside their stacking context. */
.dropdown { position: relative; }
.dropdown-menu.show {
  /* Force a new stacking context above the page-header */
  isolation: isolate;
}

/* Quill bubble toolbar — keep above the sticky session bar */
.ql-bubble.ql-toolbar { z-index: 1090 !important; }
.ql-snow .ql-tooltip,
.ql-bubble .ql-tooltip { z-index: 1090 !important; }


/* ============================================================
   Polished cards + status pills
   ============================================================ */

.card {
  transition: box-shadow 0.16s, transform 0.16s;
}

/* Soft surface for empty states with subtle brand tint */
.empty {
  background: linear-gradient(180deg, var(--surface-2) 0%, var(--surface) 100%);
  border: 1px dashed var(--border);
  color: var(--muted);
  padding: 1.4rem 1.1rem;
  text-align: center;
  border-radius: var(--radius);
}
.empty i { font-size: 1.8rem; color: var(--primary); opacity: 0.6; display: block; margin-bottom: 0.4rem; }
.empty strong { color: var(--text); }

/* Vibrant homework status pills (already defined, refine contrast) */
.badge-hw-not_sent  { background: #e2e8f0; color: #475569; }
.badge-hw-sent      { background: #dbeafe; color: #1e40af; }
.badge-hw-received  { background: #fef3c7; color: #92400e; }
.badge-hw-reviewed  { background: #dcfce7; color: #166534; }
.badge-hw-overdue   { background: #fee2e2; color: #991b1b; }
[data-theme="dark"] .badge-hw-not_sent  { background: rgba(148,163,184,0.18); color: #cbd5e1; }
[data-theme="dark"] .badge-hw-sent      { background: rgba(59,130,246,0.18);  color: #93c5fd; }
[data-theme="dark"] .badge-hw-received  { background: rgba(245,158,11,0.18);  color: #fcd34d; }
[data-theme="dark"] .badge-hw-reviewed  { background: rgba(34,197,94,0.18);   color: #86efac; }
[data-theme="dark"] .badge-hw-overdue   { background: rgba(220,38,38,0.18);   color: #fca5a5; }

/* Subtle hover on table rows */
.table tbody tr:hover {
  background: var(--surface-2);
}

/* Nicer page-header spacing */
.page-header {
  margin-bottom: 1.1rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--border);
}
.page-header h1 { letter-spacing: -0.02em; }


/* ============================================================
   Sidebar "Recently visited" sub-list
   ============================================================ */

.sidebar-sublist {
  margin: 0.15rem 0 0.55rem 0.55rem;
  padding-left: 0.6rem;
  border-left: 2px solid var(--border);
}
.sidebar-sublist-label {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-soft);
  margin: 0.25rem 0 0.2rem;
}
.sidebar-substudent {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.45rem;
  border-radius: 6px;
  color: var(--text-soft);
  text-decoration: none;
  font-size: 0.88rem;
  transition: background 0.12s, color 0.12s;
}
.sidebar-substudent:hover {
  background: var(--surface-2);
  color: var(--text);
}
.sidebar-substudent .name {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sidebar-substudent .lvl {
  font-size: 0.68rem; font-weight: 600;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.05rem 0.4rem;
}

/* Sidebar search has been removed — keep .sidebar-search invisible if any
   old cached HTML still includes it */
.sidebar-search { display: none !important; }


/* ============================================================
   Searchable multi-select with chips (chip-picker.js)
   ============================================================ */
.chip-picker {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.35rem 0.45rem;
  min-height: 40px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem;
}
.chip-picker:focus-within { border-color: var(--primary); box-shadow: var(--ring); }
.chip-picker-chips { display: contents; }
.chip-picker-chip {
  display: inline-flex; align-items: center; gap: 0.3rem;
  background: var(--primary); color: #fff;
  padding: 0.15rem 0.5rem;
  border-radius: 999px; font-size: 0.84rem; font-weight: 600;
}
.chip-picker-chip .chip-x {
  background: transparent; border: 0; color: #fff;
  font-size: 1.05rem; line-height: 1; padding: 0 0.1rem; cursor: pointer;
  opacity: 0.85;
}
.chip-picker-chip .chip-x:hover { opacity: 1; }
.chip-picker input[data-role="search"] {
  flex: 1; min-width: 120px;
  border: 0; outline: 0; background: transparent;
  font: inherit; color: var(--text); padding: 0.2rem 0.3rem;
}
.chip-picker-list {
  position: absolute; left: 0; top: calc(100% + 4px); right: 0;
  z-index: 1100;
  list-style: none; margin: 0; padding: 0.25rem;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  max-height: 220px; overflow-y: auto;
}
.chip-picker-list li {
  padding: 0.45rem 0.65rem;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text);
  font-size: 0.92rem;
}
.chip-picker-list li:hover { background: var(--surface-2); }


/* ============================================================
   Auto-applying filter bars (data-autofilter attribute)
   ============================================================ */
.filter-bar form[data-autofilter] .auto-hidden { display: none !important; }


/* ============================================================
   v19 — Overlay stability & polish (modals/dropdowns/popovers)
   ============================================================ */

/* --- Body scroll-lock recovery -------------------------------------- */
/* If Bootstrap leaves <body class="modal-open"> orphaned, the page can't
   scroll. Our overlay-stability.js removes the class on `hidden.bs.modal`,
   but as a final safety net we also stop Bootstrap from injecting an inline
   padding-right that shifts the layout when scrollbars vanish. */
body.modal-open {
  /* Don't pad the body — keep layout stable */
  padding-right: 0 !important;
}

/* --- Stacking order (final word) ----------------------------------- */
/* Bootstrap defaults: dropdown 1000, sticky 1020, fixed 1030,
   backdrop 1040, modal 1050, popover 1070, tooltip 1080.
   We bump everything above page-internal sticky elements so menus/modals
   never get trapped behind cards or toolbars. */
.modal-backdrop                 { z-index: 1140 !important; }
.modal                          { z-index: 1150 !important; }
.dropdown-menu                  { z-index: 1100 !important; }
.popover                        { z-index: 1110 !important; }
.tooltip                        { z-index: 1200 !important; }
.toast, .toast-container        { z-index: 1300 !important; }
.ql-bubble.ql-toolbar           { z-index: 1090 !important; }


/* --- Modal polish -------------------------------------------------- */
.modal-content {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 50px -20px rgba(15, 23, 42, 0.45);
  overflow: hidden;     /* clip header/footer corners */
}
.modal-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 1.1rem;
}
.modal-header .modal-title { font-size: 1rem; font-weight: 600; letter-spacing: -0.005em; }
.modal-body { padding: 1rem 1.1rem; }
.modal-footer {
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  padding: 0.65rem 1.1rem;
}
.modal-dialog-scrollable .modal-body { overflow-y: auto; max-height: calc(90vh - 9rem); }

/* Backdrop — subtle blur + dim */
.modal-backdrop.show {
  opacity: 0.55;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
[data-theme="dark"] .modal-backdrop.show { opacity: 0.7; }

/* Smooth open/close (Bootstrap uses 0.15s transform — make it feel a touch
   more polished without slowing down) */
.modal.fade .modal-dialog {
  transition: transform 0.18s ease-out, opacity 0.18s ease-out;
}

/* Avoid horizontal compression of the underlying page when the scrollbar
   disappears — we force padding-right to 0 above, here we hide the body
   scrollbar but keep its width using `scrollbar-gutter` so nothing jumps. */
html { scrollbar-gutter: stable; }


/* --- Dropdown polish ----------------------------------------------- */
.dropdown-menu {
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: 0 12px 30px -12px rgba(15, 23, 42, 0.25);
  padding: 0.35rem;
  min-width: 12rem;
}
.dropdown-item {
  border-radius: 6px;
  padding: 0.4rem 0.65rem;
  font-size: 0.9rem;
}
.dropdown-item:hover, .dropdown-item:focus { background: var(--surface-2); color: var(--text); }
.dropdown-item.text-danger:hover { background: rgba(220, 38, 38, 0.08); color: #b91c1c; }


/* --- Form spacing inside modals ------------------------------------ */
.modal-body .form-label { font-weight: 500; }
.modal-body .form-control,
.modal-body .form-select { font-size: 0.93rem; }
.modal-body label.small,
.modal-body .form-label.small { color: var(--muted); font-weight: 500; }


/* --- Cards default to visible overflow so dropdowns can escape ----- */
/* Some prior `overflow: hidden` rules clip dropdowns rendered inside cards.
   This rule is duplicated from earlier passes — keep it explicit and last so
   nothing accidentally overrides it. */
.card, .session-card, .mini-card, .detail-card, .path-card { overflow: visible !important; }

/* Tables: hover state slightly stronger so it doesn't look broken next to
   the new modal/dropdown polish. */
.table tbody tr { transition: background-color 0.12s; }
.table tbody tr:hover { background: var(--surface-2); }


/* ============================================================
   v20 — Searchable single-select (searchable-select.js)
   ============================================================ */

.searchable-select {
  position: relative;
}
.searchable-select .ss-control {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex; align-items: center;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.searchable-select.ss-open .ss-control,
.searchable-select .ss-control:focus-within {
  border-color: var(--primary);
  box-shadow: var(--ring);
}
.searchable-select .ss-control input[data-role="search"] {
  flex: 1; min-width: 0;
  border: 0; outline: 0; background: transparent;
  font: inherit; color: var(--text);
  padding: 0.42rem 2rem 0.42rem 0.7rem;
}
.searchable-select .ss-control [data-role="clear"] {
  position: absolute; right: 0.3rem;
  background: transparent; border: 0; color: var(--muted-soft);
  font-size: 1.1rem; line-height: 1; padding: 0.2rem 0.4rem; cursor: pointer;
  border-radius: 4px;
}
.searchable-select .ss-control [data-role="clear"]:hover { color: var(--text); background: var(--surface-2); }

.searchable-select .ss-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px);
  z-index: 1100;
  list-style: none; margin: 0; padding: 0.25rem;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  box-shadow: 0 12px 30px -12px rgba(15, 23, 42, 0.25);
  max-height: 260px; overflow-y: auto;
}
.searchable-select .ss-list li {
  padding: 0.45rem 0.65rem;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text);
  font-size: 0.92rem;
}
.searchable-select .ss-list li:hover,
.searchable-select .ss-list li.ss-focus { background: var(--surface-2); }
.searchable-select .ss-list li.is-active { background: var(--primary-soft); color: var(--primary); font-weight: 500; }
.searchable-select .ss-list .ss-empty { color: var(--muted); font-style: italic; cursor: default; }
.searchable-select .ss-list .ss-empty:hover { background: transparent; }


/* Session "next plan" timeline kind */
.tl-row.session-next .tl-kind { background: rgba(99, 102, 241, 0.15); color: #4338ca; }
[data-theme="dark"] .tl-row.session-next .tl-kind { color: #a5b4fc; }


/* ============================================================
   v23 — Mobile shell (hamburger + slide-in sidebar)
   ============================================================ */

.mobile-nav-toggle {
  display: none;
  position: fixed;
  top: 12px; left: 12px;
  z-index: 60;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  width: 40px; height: 40px;
  font-size: 1.4rem; color: var(--text);
  box-shadow: var(--shadow-sm);
}
.sidebar-close {
  display: none;
  margin-left: auto;
  background: transparent; border: 0;
  color: var(--text-soft); font-size: 1rem;
  padding: 0.2rem 0.4rem; border-radius: 6px;
}
.sidebar-close:hover { background: rgba(255,255,255,0.08); color: white; }

.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 70;
}

@media (max-width: 900px) {
  /* Hide the desktop layout and replace with a slide-in pattern */
  .layout { display: block; }
  .layout > .content { margin-left: 0 !important; padding: 4.2rem 1rem 2rem !important; max-width: 100% !important; }
  .mobile-nav-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .sidebar-close { display: inline-flex; align-items: center; justify-content: center; }

  .layout > .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 270px; max-width: 80vw;
    transform: translateX(-105%);
    transition: transform 0.22s ease-out;
    z-index: 80;
    box-shadow: 12px 0 30px rgba(15,23,42,0.25);
  }
  body.sidebar-open .layout > .sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-backdrop { display: block; }

  /* Stack page-header on mobile so action buttons don't crowd */
  .page-header { flex-wrap: wrap; gap: 0.5rem; }
  .page-header h1 { font-size: 1.3rem; }
}

/* In reader mode, hide the hamburger too */
body.reader-mode .mobile-nav-toggle,
body.reader-mode .sidebar-backdrop { display: none !important; }

/* Plain bottom-action row inside a form (no sticky — that was covering
   other buttons). Creation/editing now happens in modals; see
   homework_list.html and students_list.html for the patterns. */
.sticky-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 1rem;
  padding-top: 0.8rem;
  border-top: 1px solid var(--border, #e5e7eb);
}
.sticky-actions .sa-spacer { flex: 1; }
.has-sticky-actions { /* no-op now — kept for backward-compat */ }

/* After the one-shot HTML scrub (scripts/clean_html_in_db.py), some
   rich-text fields are stored as plain text with newlines. These selectors
   preserve those newlines so paragraph breaks remain visible. They also
   stay compatible with any remaining HTML structure (since pre-wrap only
   affects inline text, not block descendants like <p> or <li>). */
.rich-block,
.note-body,
.ses-content { white-space: pre-wrap; }

/* ============================================================
   Hairline separators between list records — applied app-wide
   so every record list reads consistently (same as the classes
   list). Vertical content-row lists only; grids, data tables
   (which already have row borders) and form rows are excluded.
   ============================================================ */
.rec:not(:last-child),
.hw-rec:not(:last-child),
.td-row:not(:last-child),
.word-rec:not(:last-child),
.trash-rec:not(:last-child),
.set-row:not(:last-child),
.nx-row:not(:last-child),
.path-rec:not(:last-child),
.cl-row:not(:last-child),
.hw-row:not(:last-child),
.nt-row:not(:last-child),
.mt-row:not(:last-child),
.tpl-row:not(:last-child) {
  border-bottom: 1px solid var(--border);
}
/* Library: list view only — grid cards stay borderless */
.lib2-view-list .lib2-row:not(:last-child) {
  border-bottom: 1px solid var(--lib-border);
}

/* ============================================================
   LIGHT MODE — clean, readable, professional & minimal.
   A calm near-white canvas with ONE restrained indigo accent
   for icon tiles. Functional color stays (status badges, material
   types, primary button); no rainbow / no loud backgrounds.
   Scoped to html:not([data-theme="dark"]) — dark mode untouched.
   ============================================================ */

/* Calm, minimal page background (no gradient) */
html:not([data-theme="dark"]) body { background: #f7f8fb; }

/* Uniform, refined indigo icon tiles across every record list —
   consistent and quiet (replaces the rainbow rotation). Typed tiles
   (.rec-ico-*) and homework status tiles keep their functional color. */
html:not([data-theme="dark"]) :is(.sess-ico,.rec-ico:not([class*='rec-ico-']),.nx-ico,.cl-ico,.nt-ico,.mt-ico,.tpl-ico,.word-ico,.trash-ico,.set-ico) {
  background: #eef0fe;
  color: #5b56e8;
}

/* Sidebar: clean monochrome icons with a single indigo active accent
   (minimal). One muted resting tone, accent only on the active item. */
html:not([data-theme="dark"]) .sidebar .nav-link i { color: #aeb0bd; opacity: 1; }
html:not([data-theme="dark"]) .sidebar .nav-link:hover i { color: #fff; }
html:not([data-theme="dark"]) .sidebar .nav-link.active i { color: var(--sidebar-accent); }

/* ============================================================
   Class / Session — reading workspace, timeline feed, editor
   A calm, content-first teaching log (Notion / Linear feel).
   ============================================================ */

/* —— Detail: read-first session workspace —— */
.ses-wrap { max-width: 760px; margin: 0 auto; }
.ses-back {
  display: inline-flex; align-items: center; gap: .35rem;
  font-size: .82rem; color: var(--muted); text-decoration: none; margin-bottom: 1rem;
}
.ses-back:hover { color: var(--primary); }

.ses-head { display: flex; align-items: flex-start; gap: 1rem; }
.ses-head-main { flex: 1; min-width: 0; }
.ses-title {
  font-size: 1.6rem; font-weight: 700; line-height: 1.2; letter-spacing: -.01em;
  color: var(--text); margin: 0; word-break: break-word;
}
.ses-meta {
  display: flex; align-items: center; flex-wrap: wrap; gap: .55rem;
  margin-top: .5rem; font-size: .85rem; color: var(--muted);
}
.ses-meta-item { display: inline-flex; align-items: center; gap: .35rem; }
.ses-meta-item i { font-size: .92rem; opacity: .8; }
.ses-meta a { color: inherit; text-decoration: none; font-weight: 600; }
.ses-meta a:hover { color: var(--primary); }
.ses-meta .sep { opacity: .4; }
.ses-tag {
  font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  padding: .18rem .55rem; border-radius: 999px; background: var(--surface-3); color: var(--muted);
}
.ses-tag.is-upcoming { background: var(--info-soft); color: #075985; }
[data-theme="dark"] .ses-tag.is-upcoming { background: rgba(14,165,233,.18); color: #7dd3fc; }

/* contextual icon actions — quiet at rest */
.ses-actions { display: flex; align-items: center; gap: .15rem; flex-shrink: 0; }
.ses-actions .btn-icon { width: 36px; height: 36px; font-size: 1rem; }
.ses-actions form { display: inline-flex; margin: 0; }

.ses-divider { height: 1px; background: var(--border); margin: 1.15rem 0 1.5rem; border: 0; }

/* content blocks — typography-led, borderless */
.ses-block { margin-bottom: 1.7rem; }
.ses-label {
  display: flex; align-items: center; gap: .45rem; margin-bottom: .55rem;
  font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted-soft);
}
.ses-label i { font-size: .9rem; color: var(--primary); opacity: .85; }
.ses-content { font-size: .97rem; line-height: 1.72; color: var(--text-soft); }
.ses-content > *:first-child { margin-top: 0; }
.ses-content > *:last-child { margin-bottom: 0; }
/* notes block reads quieter, on a soft surface */
.ses-block.is-notes .ses-content {
  background: var(--surface-2); border-radius: 12px; padding: .85rem 1.05rem;
  font-size: .92rem; color: var(--muted);
}

/* previous-class link row */
.ses-prev {
  display: flex; align-items: center; gap: .7rem; text-decoration: none;
  padding: .6rem .7rem; border-radius: 12px; background: var(--surface-2);
  transition: background .12s; margin-top: .5rem;
}
.ses-prev:hover { background: var(--surface-3); }
.ses-prev-ico {
  width: 36px; height: 36px; flex-shrink: 0; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(99,102,241,.1); color: var(--primary); font-size: 1rem;
}
[data-theme="dark"] .ses-prev-ico { background: rgba(129,140,248,.18); color: #a5b4fc; }
.ses-prev-main { min-width: 0; }
.ses-prev-title { font-weight: 600; font-size: .92rem; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ses-prev-date { font-size: .78rem; color: var(--muted); margin-top: .05rem; }

/* —— List: each class as a two-column record (meta | lesson log) —— */
.sess-card .card-body { display: flex; flex-direction: column; gap: 0; padding: .35rem; }
.sess-row { position: relative; border-radius: 12px; transition: background .12s; }
.sess-row:not(:last-child) { border-bottom: 1px solid var(--border); }
.sess-row:hover { background: var(--surface-2); }

.sess-grid {
  display: grid; grid-template-columns: minmax(165px, 240px) 1fr;
  gap: .3rem 1.6rem; align-items: start; padding: .65rem .7rem;
}

/* Left column: title · date · student (clickable → opens the edit modal) */
.sess-left {
  min-width: 0; display: flex; flex-direction: column; gap: .15rem;
  background: none; border: 0; text-align: left; cursor: pointer; padding: 0;
}
.sess-title { font-weight: 600; font-size: .95rem; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sess-left:hover .sess-title { color: var(--primary); }
.sess-when { font-size: .8rem; color: var(--muted); }
.sess-student { font-size: .82rem; color: var(--text-soft); font-weight: 500;
  display: flex; align-items: center; gap: .3rem; min-width: 0; }
.sess-student img { flex-shrink: 0; }

/* Right column: lesson log as "Label: value" lines */
.sess-fields { min-width: 0; display: flex; flex-direction: column; gap: .28rem; padding-right: 3.4rem; }
.sess-f { font-size: .85rem; line-height: 1.45; color: var(--text-soft);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.sess-f-lbl { font-weight: 600; color: var(--muted); margin-right: .15rem; }
.sess-f .badge-hw { margin-left: .35rem; font-size: .62rem; padding: .12em .5em; vertical-align: middle; }
.sess-f-empty { color: var(--muted-soft); }

/* Actions: top-right, revealed on hover */
.sess-actions { position: absolute; top: .5rem; right: .55rem; display: flex; gap: 2px;
  opacity: 0; transition: opacity .12s; }
.sess-row:hover .sess-actions, .sess-row:focus-within .sess-actions { opacity: 1; }

@media (max-width: 700px) {
  .sess-grid { grid-template-columns: 1fr; gap: .45rem; }
  .sess-fields { padding-right: 0; }
  .sess-actions { opacity: 1; }
}

/* —— Editor modal: premium, content-block fields, sticky save bar —— */
.cl-modal .modal-content {
  display: flex; flex-direction: column; max-height: 92vh;
  border: 0; border-radius: 18px; box-shadow: var(--shadow-xl); overflow: hidden;
}
.cl-modal .modal-header { padding: 1.05rem 1.4rem .85rem; border-bottom: 1px solid var(--border); }
.cl-modal .modal-title { font-size: 1.05rem; font-weight: 700; display: flex; align-items: center; gap: .5rem; }
.cl-modal .modal-title i { color: var(--primary); }
.cl-modal .modal-body { padding: 1.15rem 1.4rem; overflow-y: auto; }
.cl-modal .modal-footer {
  padding: .85rem 1.4rem; border-top: 1px solid var(--border);
  background: var(--surface); flex-shrink: 0;
}

/* meta strip: student · date · title */
.cl-meta {
  display: grid; grid-template-columns: 1.4fr 1fr 1.3fr; gap: .8rem;
  padding-bottom: 1.15rem; border-bottom: 1px dashed var(--border);
}
@media (max-width: 640px) { .cl-meta { grid-template-columns: 1fr; } }
.cl-meta .cl-flabel, .cl-field .cl-flabel {
  display: flex; align-items: center; gap: .4rem; margin-bottom: .4rem;
  font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted-soft);
}
.cl-field .cl-flabel i { color: var(--primary); opacity: .85; font-size: .9rem; }

/* content fields rendered as soft, borderless blocks */
.cl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem 1.4rem; margin-top: 1.15rem; }
@media (max-width: 760px) { .cl-grid { grid-template-columns: 1fr; gap: 1rem; } }
.cl-field textarea {
  width: 100%; border: 1px solid transparent; background: var(--surface-2);
  border-radius: 12px; padding: .7rem .85rem; font-size: .93rem; line-height: 1.6;
  color: var(--text); resize: vertical; min-height: 96px;
  transition: background .12s, border-color .12s, box-shadow .12s;
}
.cl-field textarea::placeholder { color: var(--muted-soft); }
.cl-field textarea:hover { background: var(--surface-3); }
.cl-field textarea:focus {
  outline: 0; background: var(--surface); border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,.12);
}
.cl-hint { font-size: .72rem; color: var(--muted-soft); margin-top: .35rem; display: flex; align-items: center; gap: .3rem; }
