/* ==========================================================================
   J Academy — portal.css (student portal, dashboard, admin)
   Loads after styles.css and reuses its design tokens.
   ========================================================================== */

.portal-body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1000px 400px at 90% -10%, rgba(213, 174, 99, 0.07), transparent 60%),
    var(--paper);
}

.portal-main {
  flex: 1;
  padding-block: 2rem 4rem;
}

/* ---------- Demo banner ---------- */

.demo-banner {
  background: linear-gradient(90deg, rgba(213, 174, 99, 0.25), rgba(213, 174, 99, 0.12));
  border-bottom: 1px solid rgba(176, 138, 56, 0.3);
  font-size: 0.85rem;
  color: var(--ink);
}

.demo-banner .container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 1rem;
  padding-block: 0.55rem;
}

.demo-banner strong { color: var(--gold-600); }

.demo-banner button {
  margin-left: auto;
  background: none;
  border: 1px solid rgba(176, 138, 56, 0.5);
  border-radius: 999px;
  padding: 0.2rem 0.75rem;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gold-600);
  cursor: pointer;
}

.demo-banner button:hover { background: rgba(213, 174, 99, 0.2); }

/* ---------- Top bar ---------- */

.portal-topbar {
  background: var(--navy-800);
  color: var(--white);
}

.portal-topbar .container {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-block: 0.8rem;
}

.portal-topbar .brand { color: var(--white); }
.portal-topbar .brand-name { color: var(--white); font-size: 1.2rem; }

.topbar-label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold-400);
  border-left: 1px solid rgba(255, 255, 255, 0.25);
  padding-left: 1rem;
}

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

.topbar-user {
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.85);
}

.topbar-link {
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.9rem;
  text-decoration: none;
}

.topbar-link:hover { color: var(--gold-300); }

.btn-logout {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  color: var(--white);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.4rem 1rem;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.btn-logout:hover { background: rgba(255, 255, 255, 0.2); border-color: var(--gold-400); }

/* ---------- Dashboard shell: left sidebar ---------- */

.portal-layout {
  display: flex;
  flex: 1;
  align-items: stretch;
}

/* inside the shell, the main column manages its own gutters (flex sizing
   overrides the .container width formula) */
.portal-layout > .portal-main {
  flex: 1;
  min-width: 0;
  width: auto;
  max-width: 1240px;
  padding-inline: 2.25rem;
}

@media (max-width: 960px) {
  .portal-layout > .portal-main { padding-inline: 1.25rem; }
}

.portal-sidebar {
  width: 236px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  background:
    radial-gradient(500px 300px at 110% -10%, rgba(213, 174, 99, 0.14), transparent 65%),
    var(--navy-800);
  color: var(--white);
  padding: 1.4rem 1rem 1.25rem;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-top {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.7rem;
  padding-inline: 0.5rem;
}

.portal-sidebar .brand { color: var(--white); }
.portal-sidebar .brand-name { color: var(--white); font-size: 1.15rem; }

.sidebar-role {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold-300);
  background: rgba(213, 174, 99, 0.16);
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.side-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  border-radius: 10px;
  padding: 0.62rem 0.85rem;
  font-size: 0.92rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.72);
  text-decoration: none;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.side-link:hover { background: rgba(255, 255, 255, 0.08); color: var(--white); }

.side-link.is-active {
  background: rgba(213, 174, 99, 0.18);
  color: var(--gold-300);
}

.side-link svg { flex-shrink: 0; }

.side-badge {
  margin-left: auto;
  background: var(--gold-500);
  color: var(--navy-900, #0B1A2C);
  font-size: 0.68rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.06rem 0.45rem;
}

.sidebar-foot {
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  padding: 1rem 0.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.sidebar-user { min-width: 0; font-size: 0.86rem; }
.sidebar-user strong { display: block; }

.sidebar-user span {
  display: block;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.6);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-foot .btn-logout { align-self: flex-start; }

@media (max-width: 960px) {
  .portal-layout { flex-direction: column; }

  .portal-sidebar {
    position: static;
    width: auto;
    height: auto;
    align-self: stretch;
    overflow: visible;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem 1rem;
    padding: 0.75rem 1rem;
  }

  .sidebar-top { flex-direction: row; align-items: center; padding: 0; }

  .sidebar-nav {
    order: 3;
    width: 100%;
    flex-direction: row;
    gap: 0.35rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.15rem;
  }

  .side-link { padding: 0.45rem 0.8rem; white-space: nowrap; font-size: 0.85rem; }
  .side-badge { margin-left: 0.35rem; }

  .sidebar-foot {
    margin-top: 0;
    margin-left: auto;
    border-top: none;
    padding: 0;
    flex-direction: row;
    align-items: center;
  }

  .sidebar-user span { display: none; }
  .sidebar-user strong { font-size: 0.85rem; }
}

@media (max-width: 640px) {
  .sidebar-user { display: none; }
  .portal-sidebar .brand-name { font-size: 1.05rem; }
}

/* ---------- Auth page ---------- */

.auth-wrap {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 3rem 1.25rem 4rem;
}

.auth-card {
  width: min(100%, 430px);
  background: var(--white);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 2.25rem 2rem;
}

.auth-title {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.auth-sub {
  font-size: 0.95rem;
  color: var(--muted);
  margin-bottom: 1.5rem;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.25rem;
  background: var(--tint);
  border-radius: 999px;
  padding: 0.25rem;
  margin-bottom: 1.5rem;
}

.auth-tab {
  border: none;
  background: none;
  border-radius: 999px;
  padding: 0.55rem 0.75rem;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.auth-tab.is-active {
  background: var(--white);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.auth-error {
  background: #FBE9E7;
  border: 1px solid #E8B4AC;
  color: #8C2E1F;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  padding: 0.6rem 0.85rem;
  margin-bottom: 1rem;
}

.auth-success {
  background: #E8F2E4;
  border: 1px solid #B5D3A8;
  color: #2F5B1E;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  padding: 0.6rem 0.85rem;
  margin-bottom: 1rem;
}

.auth-note {
  margin-top: 1.25rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.auth-note a { color: var(--gold-600); font-weight: 600; }

.demo-hint {
  margin-top: 1.5rem;
  border-top: 1px dashed var(--line);
  padding-top: 1.25rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.demo-hint h2 {
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold-600);
  margin-bottom: 0.6rem;
}

.demo-hint code {
  background: var(--tint);
  border-radius: 6px;
  padding: 0.1rem 0.4rem;
  font-size: 0.82rem;
  color: var(--ink);
}

.demo-hint p { margin-bottom: 0.4rem; }

/* ---------- Page head / stats ---------- */

.portal-head { margin-bottom: 1.75rem; }

.portal-head h1 {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 1.3rem + 1.4vw, 2.25rem);
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.portal-head p { color: var(--muted); font-size: 0.98rem; }

.stat-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.1rem;
  margin-bottom: 1.75rem;
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  padding: 1.1rem 1.3rem;
  box-shadow: var(--shadow-sm);
}

.stat-card-label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.3rem;
}

.stat-card-value {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--navy-800);
  line-height: 1.25;
}

.stat-card-value small {
  display: block;
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted);
  margin-top: 0.1rem;
}

/* ---------- Panels & layout ---------- */

.panel {
  background: var(--white);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
}

.panel-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.panel-title-row .panel-title { margin-bottom: 0; }

.portal-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
  margin-bottom: 1.25rem;
}

.day-panel { position: sticky; top: 1.25rem; }

.day-panel-date {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gold-600);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.75rem;
}

.panel-empty {
  color: var(--muted);
  font-size: 0.9rem;
  padding: 1rem 0;
}

/* ---------- Calendar ---------- */

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

.cal-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
}

.cal-nav { display: flex; gap: 0.4rem; }

.cal-btn {
  min-width: 36px;
  height: 36px;
  padding: 0 0.7rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--white);
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.cal-btn:hover { background: var(--tint); border-color: var(--gold-500); }
.cal-btn-today { font-size: 0.85rem; }

.cal-dow {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 4px;
}

.cal-dow span {
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding-block: 0.3rem;
}

.cal-dow .dow-short { display: none; }

@media (max-width: 640px) {
  .cal-dow .dow-short { display: inline; }
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.cal-day {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  min-height: 88px;
  padding: 6px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: var(--paper);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.cal-day:hover { border-color: var(--gold-500); background: var(--white); }

.cal-day.is-out { opacity: 0.4; background: transparent; }

.cal-day.is-today .cal-num {
  background: var(--navy-800);
  color: var(--gold-300);
}

.cal-day.is-selected {
  border-color: var(--gold-500);
  background: var(--white);
  box-shadow: 0 0 0 2px rgba(176, 138, 56, 0.25);
}

.cal-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink);
}

.cal-chips {
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow: hidden;
}

.cal-chip {
  display: block;
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: #E3EAF3;
  color: #16304F;
}

.cal-chip-text { display: inline; }

/* per-student colours (admin view) */
.cal-c0 { background: #E3EAF3; color: #16304F; }
.cal-c1 { background: #F3E9D3; color: #6E5310; }
.cal-c2 { background: #DDF0EC; color: #145C4F; }
.cal-c3 { background: #EFE3F2; color: #6A2E79; }
.cal-c4 { background: #FBE4DC; color: #973B1E; }
.cal-c5 { background: #E4F0DB; color: #3D6B21; }

.cal-chip.is-absence {
  background: #FCEBCC;
  color: #8A5B00;
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

.cal-chip.is-past { opacity: 0.5; }

.cal-more {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
  padding-left: 2px;
}

/* ---------- Lesson list items ---------- */

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

.lesson-item {
  display: flex;
  gap: 0.9rem;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  padding: 0.9rem 1rem;
  background: var(--paper);
}

.lesson-item.is-past { opacity: 0.6; }

.lesson-time {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 74px;
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--navy-800);
}

.lesson-date {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--gold-600);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.lesson-dur {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
}

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

.lesson-title {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.15rem;
}

.lesson-meta {
  font-size: 0.82rem;
  color: var(--muted);
}

.lesson-student {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.15rem;
}

.student-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  background: #16304F;
}

.dot-c0 { background: #16304F; }
.dot-c1 { background: #B08A38; }
.dot-c2 { background: #1D7A68; }
.dot-c3 { background: #8A449C; }
.dot-c4 { background: #C25230; }
.dot-c5 { background: #5A8A38; }

/* absence controls */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 0.2rem 0.65rem;
}

.badge-absence { background: #FCEBCC; color: #8A5B00; }
.badge-past { background: var(--tint); color: var(--muted); }
.badge-seen { background: #E8F2E4; color: #2F5B1E; }

.lesson-actions { margin-top: 0.55rem; display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }

.btn-mini {
  border: 1px solid var(--line);
  background: var(--white);
  border-radius: 999px;
  padding: 0.32rem 0.85rem;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--navy-700);
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.btn-mini:hover { border-color: var(--gold-500); background: var(--tint); }

.btn-mini-danger { color: #973B1E; }
.btn-mini-danger:hover { border-color: #C25230; background: #FBE4DC; }

.btn-mini-primary {
  background: var(--navy-800);
  border-color: var(--navy-800);
  color: var(--white);
}

.btn-mini-primary:hover { background: var(--navy-700); border-color: var(--navy-700); }

.absence-form { margin-top: 0.6rem; }

.absence-form textarea {
  width: 100%;
  min-height: 68px;
  resize: vertical;
  padding: 0.6rem 0.75rem;
  font: inherit;
  font-size: 0.88rem;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--white);
}

.absence-form textarea:focus {
  outline: none;
  border-color: var(--gold-500);
  box-shadow: 0 0 0 3px rgba(176, 138, 56, 0.18);
}

.absence-form-actions { display: flex; gap: 0.5rem; margin-top: 0.5rem; }

.absence-note {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.4rem;
}

.absence-policy {
  background: #FDF7EA;
  border-left: 3px solid var(--gold-400);
  border-radius: 0 8px 8px 0;
  padding: 0.5rem 0.7rem;
  line-height: 1.5;
}

/* ---------- Admin: legend, notices, students ---------- */

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.1rem;
  margin-top: 1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--line-soft);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}

.notice {
  border: 1px solid rgba(176, 138, 56, 0.35);
  background: #FDF7EA;
  border-radius: var(--radius-md);
  padding: 0.9rem 1rem;
}

.notice.is-seen {
  border-color: var(--line-soft);
  background: var(--paper);
  opacity: 0.75;
}

.notice-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.3rem 0.5rem;
  font-size: 0.9rem;
}

.notice-head strong { color: var(--ink); }
.notice-head em { color: var(--muted); font-style: normal; }

.notice-msg {
  font-size: 0.88rem;
  color: var(--ink);
  background: var(--white);
  border-left: 3px solid var(--gold-400);
  border-radius: 0 8px 8px 0;
  padding: 0.5rem 0.75rem;
  margin: 0.55rem 0;
}

.notice-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.admin-columns {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
  margin-top: 1.25rem;
}

.students-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }

.students-table th {
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--line);
}

.students-table td {
  padding: 0.6rem;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}

.students-table tr:last-child td { border-bottom: none; }

/* ---------- Modal ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 26, 44, 0.55);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  padding: 1.25rem;
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s;
}

.modal-overlay.is-open { opacity: 1; visibility: visible; }

.modal {
  width: min(100%, 480px);
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 1.75rem;
  transform: translateY(12px);
  transition: transform 0.25s var(--ease);
}

.modal-overlay.is-open .modal { transform: translateY(0); }

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

.modal-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
}

.modal-close {
  border: none;
  background: var(--tint);
  border-radius: 50%;
  width: 34px;
  height: 34px;
  font-size: 1.1rem;
  line-height: 1;
  color: var(--ink);
  cursor: pointer;
}

.modal-close:hover { background: var(--gold-300); }

/* ---------- Status badges & role tags ---------- */

.badge-draft { background: var(--tint); color: var(--muted); }
.badge-submitted { background: #E3EAF3; color: #16304F; }
.badge-reviewed { background: #E8F2E4; color: #2F5B1E; }

.role-tag {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gold-600);
  background: rgba(213, 174, 99, 0.18);
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
}

.panel-sub {
  font-size: 0.85rem;
  color: var(--muted);
  margin: -0.5rem 0 1rem;
}

.form-note {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 1rem;
}

.stat-cards-4 { grid-template-columns: repeat(4, 1fr); }

/* ---------- Messages ---------- */

.msg-thread {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  max-height: 340px;
  overflow-y: auto;
  padding: 0.25rem 0.25rem 0.25rem 0;
  margin-bottom: 0.9rem;
}

.msg-thread-modal { max-height: 44vh; min-height: 120px; }

.msg { display: flex; flex-direction: column; align-items: flex-start; max-width: 88%; }
.msg.is-mine { align-self: flex-end; align-items: flex-end; }

.msg-bubble {
  background: var(--paper);
  border: 1px solid var(--line-soft);
  border-radius: 14px 14px 14px 4px;
  padding: 0.55rem 0.85rem;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg.is-mine .msg-bubble {
  background: var(--navy-800);
  border-color: var(--navy-800);
  color: var(--white);
  border-radius: 14px 14px 4px 14px;
}

.msg-meta {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.2rem;
  padding-inline: 0.2rem;
}

.msg-compose textarea {
  width: 100%;
  min-height: 64px;
  resize: vertical;
  padding: 0.6rem 0.75rem;
  font: inherit;
  font-size: 0.88rem;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--white);
}

.msg-compose textarea:focus {
  outline: none;
  border-color: var(--gold-500);
  box-shadow: 0 0 0 3px rgba(176, 138, 56, 0.18);
}

.msg-compose-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.msg-note { font-size: 0.78rem; color: var(--muted); }

/* messages page layout */

.messages-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr);
  gap: 1.25rem;
  align-items: start;
}

.messages-grid.is-student { grid-template-columns: minmax(0, 1fr); max-width: 760px; }

.thread-panel { position: sticky; top: 1.25rem; }

.msg-thread-page { max-height: 52vh; min-height: 200px; }

.conv-row.is-active {
  border-color: var(--gold-500);
  background: var(--white);
  box-shadow: 0 0 0 2px rgba(176, 138, 56, 0.22);
}

.people-columns { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); margin-top: 0; }

/* conversation list (admin) */

.conv-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.5rem; }

.conv-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  min-width: 0;
  text-align: left;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  background: var(--paper);
  padding: 0.7rem 0.9rem;
  font: inherit;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.conv-row:hover { border-color: var(--gold-500); background: var(--white); }

.conv-main { flex: 1; min-width: 0; }

.conv-name {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 600;
  font-size: 0.92rem;
}

.unread-pill {
  background: var(--gold-500);
  color: var(--navy-900, #0B1A2C);
  font-size: 0.68rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.05rem 0.45rem;
}

.conv-preview {
  font-size: 0.82rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 0.1rem;
}

.conv-time { flex-shrink: 0; font-size: 0.75rem; color: var(--muted); }

.conv-picker {
  max-width: 200px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--white);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--navy-700);
  padding: 0.32rem 0.7rem;
  cursor: pointer;
}

/* ---------- People (students & tutors) ---------- */

.tutor-select {
  width: 100%;
  max-width: 160px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  font: inherit;
  font-size: 0.82rem;
  padding: 0.3rem 0.4rem;
}

.tutors-head { margin-top: 1.75rem; }

.tutor-rows { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.5rem; }

.tutor-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  background: var(--paper);
  padding: 0.65rem 0.9rem;
  font-size: 0.9rem;
}

.tutor-row div { min-width: 0; }

.tutor-row span {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.tutor-count { flex-shrink: 0; font-size: 0.78rem; color: var(--muted); }

/* ---------- Essay rows (dashboard + admin lists) ---------- */

.essay-rows { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.55rem; }

.essay-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  background: var(--paper);
  padding: 0.75rem 0.9rem;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.essay-row:hover { border-color: var(--gold-500); background: var(--white); }
.essay-row.is-draft { opacity: 0.7; }

.essay-row-main { flex: 1; min-width: 0; }

.essay-row-title {
  font-weight: 600;
  font-size: 0.93rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.essay-row-meta { font-size: 0.8rem; color: var(--muted); margin-top: 0.15rem; }
.essay-row-meta strong { color: var(--gold-600); }

.essay-row .badge { flex-shrink: 0; }

/* ---------- Essay workspace ---------- */

.essay-head { margin-bottom: 1.1rem; }

.essay-title {
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 1.15rem + 1.2vw, 2rem);
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.essay-title-input {
  width: 100%;
  border: none;
  border-bottom: 2px dashed var(--line);
  background: transparent;
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 1.15rem + 1.2vw, 2rem);
  font-weight: 600;
  color: var(--ink);
  padding: 0.15rem 0;
  margin-bottom: 0.5rem;
}

.essay-title-input:focus { outline: none; border-bottom-color: var(--gold-500); }

.essay-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.9rem;
}

.essay-meta { font-size: 0.82rem; color: var(--muted); }
.save-state { font-style: italic; }

.essay-paper { padding: 1.75rem; }

.essay-editor {
  width: 100%;
  min-height: 62vh;
  border: none;
  resize: vertical;
  background: transparent;
  font-family: var(--font-display);
  font-size: 1.02rem;
  line-height: 1.85;
  color: var(--ink);
}

.essay-editor:focus { outline: none; }

.essay-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
}

.essay-actions .btn { padding: 0.6rem 1.5rem; }

.essay-submit-note {
  flex-basis: 100%;
  font-size: 0.8rem;
  color: var(--muted);
}

.essay-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}

.essay-side {
  display: grid;
  gap: 1.25rem;
  position: sticky;
  top: 1.25rem;
  max-height: calc(100vh - 2.5rem);
  overflow-y: auto;
}

.essay-text {
  font-family: var(--font-display);
  font-size: 1.02rem;
  line-height: 1.85;
  color: var(--ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

mark.essay-mark {
  background: rgba(213, 174, 99, 0.32);
  border-bottom: 2px solid var(--gold-500);
  border-radius: 2px;
  padding: 0.05em 0;
  color: inherit;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

mark.essay-mark:hover { background: rgba(213, 174, 99, 0.5); }

mark.essay-mark.is-active {
  background: rgba(213, 174, 99, 0.65);
  border-bottom-color: var(--gold-600);
}

.comment-hint {
  font-size: 0.8rem;
  color: var(--muted);
  background: var(--tint);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  margin-bottom: 1.1rem;
}

.comment-fab[hidden] { display: none; }

.comment-fab {
  position: fixed;
  z-index: 300;
  display: flex;
  gap: 2px;
  background: var(--navy-800);
  border-radius: 999px;
  padding: 3px;
  box-shadow: var(--shadow-md);
}

.comment-fab button {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: transparent;
  color: var(--white);
  border: none;
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.comment-fab button:hover { background: var(--navy-700); }
.comment-fab button + button { border-left: 1px solid rgba(255, 255, 255, 0.18); border-radius: 0 999px 999px 0; }
.comment-fab button:first-child { border-radius: 999px 0 0 999px; }

/* ---------- Suggestions (tracked edits) ---------- */

.essay-text del.sugg-del {
  background: #FBE4DC;
  color: #973B1E;
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
  border-bottom: 2px solid #C25230;
  border-radius: 2px;
  padding: 0.05em 0;
  cursor: pointer;
}

.essay-text del.sugg-del.is-active { background: #F6C9B8; }

.essay-text ins.sugg-ins {
  background: #E4F0DB;
  color: #3D6B21;
  text-decoration: none;
  border-bottom: 2px solid #5A8A38;
  border-radius: 2px;
  padding: 0.05em 0.15em;
  margin-left: 0.1em;
  cursor: pointer;
}

.essay-text ins.sugg-ins.is-active { background: #CBE4BA; }

.sugg-tag {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #3D6B21;
  background: #E4F0DB;
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
}

.sugg-diff {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: none;
  font: inherit;
  font-size: 0.85rem;
  line-height: 1.5;
  border-left: 3px solid #5A8A38;
  padding: 0.15rem 0 0.15rem 0.6rem;
  margin: 0.45rem 0;
  cursor: pointer;
}

.sugg-diff del {
  display: block;
  color: #973B1E;
  text-decoration: line-through;
  overflow-wrap: anywhere;
}

.sugg-diff ins {
  display: block;
  color: #3D6B21;
  text-decoration: none;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.comment-quote del { color: #973B1E; }

/* ---------- Essay question ---------- */

.essay-question-field { margin-bottom: 1rem; }

.essay-question-field label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.essay-question-field .optional { font-weight: 400; color: var(--muted); }

.essay-question-field textarea {
  width: 100%;
  resize: vertical;
  padding: 0.65rem 0.85rem;
  font: inherit;
  font-size: 0.92rem;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--white);
}

.essay-question-field textarea:focus {
  outline: none;
  border-color: var(--gold-500);
  box-shadow: 0 0 0 3px rgba(176, 138, 56, 0.18);
}

.essay-question {
  background: #FDF7EA;
  border: 1px solid rgba(176, 138, 56, 0.35);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.92rem;
  line-height: 1.6;
  font-style: italic;
  margin-bottom: 1.1rem;
}

.essay-question-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  font-style: normal;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold-600);
  margin-bottom: 0.25rem;
}

.inline-edit-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.9rem;
  padding-top: 0.9rem;
  border-top: 1px dashed var(--line);
}

#inlineEditor {
  border: 1.5px dashed var(--gold-400);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  background: #FFFDF7;
}

/* comment cards */

.comment-list { display: grid; gap: 0.7rem; }

.comment-card {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  background: var(--paper);
  padding: 0.8rem 0.9rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.comment-card.is-active {
  border-color: var(--gold-500);
  box-shadow: 0 0 0 2px rgba(176, 138, 56, 0.22);
}

.comment-card.is-resolved { opacity: 0.65; }

.comment-card.is-pending {
  border-color: var(--gold-500);
  background: #FDF7EA;
}

.comment-quote {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: none;
  font: inherit;
  font-size: 0.8rem;
  font-style: italic;
  color: var(--muted);
  border-left: 3px solid var(--gold-400);
  padding: 0.1rem 0 0.1rem 0.6rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
}

.comment-quote:hover { color: var(--ink); }

div.comment-quote { cursor: default; }
div.comment-quote:hover { color: var(--muted); }

.comment-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
}

.comment-time { font-size: 0.72rem; color: var(--muted); margin-left: auto; }

.comment-body {
  font-size: 0.88rem;
  line-height: 1.55;
  margin-top: 0.3rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.comment-reply {
  border-left: 2px solid var(--line);
  padding-left: 0.7rem;
  margin-top: 0.7rem;
}

.comment-compose { margin-top: 0.6rem; }

.comment-compose textarea {
  width: 100%;
  min-height: 60px;
  resize: vertical;
  padding: 0.55rem 0.7rem;
  font: inherit;
  font-size: 0.86rem;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--white);
}

.comment-compose textarea:focus {
  outline: none;
  border-color: var(--gold-500);
  box-shadow: 0 0 0 3px rgba(176, 138, 56, 0.18);
}

.comment-compose-actions { display: flex; gap: 0.5rem; margin-top: 0.5rem; }

.comment-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.6rem;
}

/* ---------- Lesson modal: type toggle & student checklist ---------- */

.field-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.type-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.25rem;
  background: var(--tint);
  border-radius: 999px;
  padding: 0.25rem;
}

.type-option {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0.45rem 0.75rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.type-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: auto;
  padding: 0;
}

.type-option.is-active {
  background: var(--white);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.check-list {
  display: grid;
  gap: 0.35rem;
  max-height: 180px;
  overflow-y: auto;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  padding: 0.6rem 0.75rem;
}

.check-option {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.check-option input {
  width: 16px;
  height: 16px;
  padding: 0;
  margin: 0;
  accent-color: var(--navy-800);
  flex-shrink: 0;
}

/* group lesson colouring */

.badge-group { background: #E3EAF3; color: #16304F; }

.dot-group { background: var(--gold-500); }

.cal-chip.cal-group { background: var(--navy-800); color: var(--gold-300); }

/* ---------- Rooms page ---------- */

.rooms-month {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.rooms-day {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-height: 66px;
  padding: 6px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: var(--paper);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.rooms-day:hover { border-color: var(--gold-500); background: var(--white); }
.rooms-day.is-out { opacity: 0.4; background: transparent; }
.rooms-day.is-today .cal-num { background: var(--navy-800); color: var(--gold-300); }
.rooms-day.is-selected {
  border-color: var(--gold-500);
  background: var(--white);
  box-shadow: 0 0 0 2px rgba(176, 138, 56, 0.25);
}

/* three mini timelines per day (Rooms 1–3, top to bottom) */

.rm-bars {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
}

.rm-bar {
  position: relative;
  display: block;
  height: 7px;
  border-radius: 4px;
  background: var(--white);
  border: 1px solid var(--line-soft);
  overflow: hidden;
}

.rm-bar.is-closed {
  background: repeating-linear-gradient(-45deg, transparent, transparent 3px, rgba(0, 0, 0, 0.07) 3px, rgba(0, 0, 0, 0.07) 6px);
  border-style: dashed;
}

.rm-seg {
  position: absolute;
  top: 0;
  bottom: 0;
  background: #4A6FA0;
  border-radius: 2px;
}

.rm-seg.is-group { background: var(--navy-800); }
.rm-seg.is-conflict { background: #C25230; }

.rm-bar-sample { width: 44px; flex-shrink: 0; }

.rooms-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  margin-top: 1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--line-soft);
  font-size: 0.82rem;
  color: var(--muted);
}

.rooms-legend .legend-item { gap: 0.45rem; font-weight: 500; }

.rooms-day-panel { margin-top: 1.25rem; }

.week-strip {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 1.25rem;
}

.week-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: var(--paper);
  padding: 0.45rem 0.25rem;
  font: inherit;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.week-day span {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.week-day strong { font-size: 0.95rem; color: var(--ink); }

.week-day:hover { border-color: var(--gold-500); background: var(--white); }
.week-day.is-closed { opacity: 0.55; }
.week-day.is-today strong { color: var(--gold-600); }
.week-day.is-selected {
  border-color: var(--gold-500);
  background: var(--white);
  box-shadow: 0 0 0 2px rgba(176, 138, 56, 0.25);
}

.room-lanes { display: grid; gap: 0.9rem; }

.room-lane {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 0.75rem;
  align-items: stretch;
}

.room-lane-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--navy-800);
  display: flex;
  align-items: center;
}

.room-track {
  position: relative;
  min-height: 64px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: var(--paper);
  overflow: hidden;
}

.room-track.is-closed {
  display: grid;
  place-items: center;
  background: repeating-linear-gradient(-45deg, var(--paper), var(--paper) 8px, rgba(0, 0, 0, 0.025) 8px, rgba(0, 0, 0, 0.025) 16px);
}

.room-closed-note {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

.room-tick {
  position: absolute;
  top: 0;
  bottom: 0;
  border-left: 1px solid var(--line-soft);
}

.room-tick em {
  position: absolute;
  top: 3px;
  left: 3px;
  font-style: normal;
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.room-block {
  position: absolute;
  border-radius: 8px;
  background: #E3EAF3;
  color: #16304F;
  border: 1px solid rgba(22, 48, 79, 0.25);
  font-size: 0.72rem;
  line-height: 1.25;
  padding: 0.3rem 0.45rem;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  min-width: 0;
  cursor: pointer;
  transition: box-shadow 0.15s ease, filter 0.15s ease;
}

.room-block:hover { box-shadow: var(--shadow-sm); filter: brightness(1.03); }

.room-block.is-group { background: var(--navy-800); color: var(--gold-300); border-color: var(--navy-800); }

.room-block.is-conflict {
  background: #FBE4DC;
  color: #973B1E;
  border-color: #C25230;
  box-shadow: 0 0 0 2px rgba(194, 82, 48, 0.3);
}

.rooms-note {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 1rem;
}

/* floating booking details card */

.room-tip {
  position: fixed;
  z-index: 320;
  max-width: 280px;
  background: var(--navy-800);
  color: var(--white);
  border-radius: 10px;
  padding: 0.65rem 0.85rem;
  box-shadow: var(--shadow-lg);
  font-size: 0.82rem;
  line-height: 1.45;
  pointer-events: none;
}

.room-tip[hidden] { display: none; }

.room-tip-time {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--gold-300);
  margin-bottom: 0.15rem;
}

.room-tip-title { font-weight: 600; }
.room-tip-title .badge { margin-left: 0.3rem; }

.room-tip-line { color: rgba(255, 255, 255, 0.82); margin-top: 0.15rem; }
.room-tip-line.is-notes { font-style: italic; }

.room-tip-hint {
  margin-top: 0.4rem;
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.55);
}

/* feedback card */

.grade-pill {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--navy-800);
  background: rgba(213, 174, 99, 0.25);
  border: 1px solid var(--gold-400);
  border-radius: 12px;
  padding: 0.3rem 1rem;
  margin-bottom: 0.75rem;
}

.feedback-text {
  font-size: 0.9rem;
  line-height: 1.6;
  white-space: pre-wrap;
}

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

@media (max-width: 960px) {
  .portal-grid { grid-template-columns: minmax(0, 1fr); }
  .day-panel { position: static; }
  .admin-columns { grid-template-columns: minmax(0, 1fr); }
  .stat-cards-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .essay-grid { grid-template-columns: minmax(0, 1fr); }
  .essay-side { position: static; max-height: none; overflow: visible; }
  .messages-grid { grid-template-columns: minmax(0, 1fr); }
  .thread-panel { position: static; }
  .people-columns { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 640px) {
  .portal-main { padding-block: 1.25rem 3rem; }
  .portal-head { margin-bottom: 1.25rem; }

  /* stats: compact label/value rows instead of three tall cards */
  .stat-cards { grid-template-columns: minmax(0, 1fr); gap: 0.6rem; margin-bottom: 1.25rem; }
  .stat-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1.1rem;
  }
  .stat-card-label { margin-bottom: 0; }
  .stat-card-value { font-size: 1.05rem; text-align: right; }
  .stat-card-value small { margin-top: 0; }

  .portal-topbar .container { flex-wrap: wrap; row-gap: 0.4rem; }
  .topbar-label { border-left: none; padding-left: 0; }

  .panel { padding: 1.1rem; }
  .portal-grid { gap: 0.9rem; }
  .admin-columns { gap: 0.9rem; margin-top: 0.9rem; }

  /* single-letter weekday labels */
  .cal-dow .dow-full { display: none; }

  /* students table: stacked rows (name + email + tutor left, count right) */
  .students-table thead { display: none; }
  .students-table tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--line-soft);
  }
  .students-table tr:last-child { border-bottom: none; }
  .students-table td { display: block; border: none; padding: 0; min-width: 0; }
  .students-table td:nth-child(2) {
    font-size: 0.8rem;
    color: var(--muted);
    overflow-wrap: anywhere;
  }
  .students-table td:nth-child(3) { margin-top: 0.3rem; }
  .students-table td:nth-child(4) {
    grid-column: 2;
    grid-row: 1 / span 3;
    font-weight: 700;
    color: var(--navy-800);
  }
  .students-table td:nth-child(4)::after {
    content: " upcoming";
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--muted);
  }

  /* add-lesson modal becomes a bottom sheet */
  .modal-overlay { padding: 0; place-items: end stretch; }
  .modal {
    width: 100%;
    max-height: 88vh;
    border-radius: 20px 20px 0 0;
    transform: translateY(30px);
    padding: 1.5rem 1.25rem calc(1.5rem + env(safe-area-inset-bottom));
  }

  /* calendar: chips collapse to dots */
  .cal-day { min-height: 58px; padding: 4px; border-radius: 8px; }
  .cal-chips { flex-direction: row; flex-wrap: wrap; gap: 3px; }
  .cal-chip { width: 8px; height: 8px; border-radius: 50%; padding: 0; }
  .cal-chip-text { display: none; }
  .cal-chip.is-absence { outline: 1.5px solid #C99013; outline-offset: 1px; text-decoration: none; }
  .cal-more { font-size: 0.6rem; }
  .cal-num { width: 20px; height: 20px; font-size: 0.72rem; }
  .cal-title { font-size: 1.1rem; }

  .lesson-item { flex-direction: column; gap: 0.4rem; }
  .lesson-time { flex-direction: row; align-items: baseline; gap: 0.5rem; min-width: 0; }

  .stat-cards-4 { grid-template-columns: minmax(0, 1fr); }
  .essay-paper { padding: 1.2rem; }

  /* rooms page on small screens */
  .rooms-day { min-height: 48px; padding: 4px; border-radius: 8px; gap: 3px; }
  .rooms-day .cal-num { width: 20px; height: 20px; font-size: 0.72rem; }
  .rm-bars { gap: 2px; }
  .rm-bar { height: 5px; }
  .room-lane { grid-template-columns: minmax(0, 1fr); gap: 0.25rem; }
  .room-lane-label { align-items: flex-start; }
  .week-day span { font-size: 0.58rem; }
  .essay-editor { min-height: 50vh; }
  .conv-picker { max-width: 150px; }
  .conv-time { display: none; }
  .msg { max-width: 100%; }
}
