@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,400;0,9..144,600;1,9..144,500;1,9..144,600&family=Nunito+Sans:wght@400;600;700;800&display=swap');

:root {
  --forest: #1E3327;
  --forest-2: #2C4A38;
  --moss: #4E7350;
  --moss-dark: #3C5B3E;
  --clay: #8B5A3C;
  --sand: #CDA968;
  --cream: #F8F3E7;
  --card: #FFFFFF;
  --ink: #2B281F;
  --ink-soft: #746B57;
  --rule: #E7DFC9;
  --rule-strong: #B7AE8E;

  --done: #4E7350;
  --done-bg: #E4ECE1;
  --due: #B9862E;
  --due-bg: #F5E9D2;
  --overdue: #A8452E;
  --overdue-bg: #F4DED6;

  --radius: 14px;
  --radius-lg: 22px;
  --max-width: 900px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: "Nunito Sans", "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.55;
}

h1, h2, h3, .wordmark {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
  color: var(--forest);
}

h1 { font-size: 1.9rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; font-weight: 600; }

p { margin: 0.3em 0; }
a { color: var(--forest); }

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 22px;
}

.container.wide { max-width: 1360px; }

/* ---------- top bar ---------- */

.topbar {
  background: var(--forest);
  color: var(--cream);
}

.topbar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 20px;
  padding-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}

.wordmark {
  font-style: italic;
  font-weight: 500;
  font-size: 1.5rem;
  color: var(--cream);
}

.wordmark span {
  color: var(--sand);
  font-family: "Nunito Sans", sans-serif;
  font-style: normal;
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  margin-left: 10px;
  vertical-align: middle;
}

.whoami {
  font-size: 0.9rem;
  color: #CFE0D2;
  text-align: right;
}

.whoami .name {
  color: var(--cream);
  font-weight: 700;
}

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

button, .btn {
  font-family: "Nunito Sans", sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  background: var(--moss);
  color: #fff;
  border: 1px solid var(--moss);
  border-radius: 999px;
  padding: 10px 20px;
  cursor: pointer;
  transition: transform 0.06s ease, opacity 0.15s ease;
}

button:hover, .btn:hover { opacity: 0.9; }
button:active { transform: scale(0.98); }
button:disabled { opacity: 0.5; cursor: default; }

button.secondary, .btn.secondary {
  background: transparent;
  color: var(--forest);
  border: 1px solid var(--forest);
}

button.text-link {
  background: var(--card);
  border: 1.5px solid var(--rule);
  color: var(--ink);
  text-decoration: none;
  padding: 7px 15px;
  font-weight: 700;
  font-size: 0.82rem;
  border-radius: 999px;
  box-shadow: 0 1px 4px rgba(30, 51, 39, 0.05);
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.06s ease;
}

button.text-link:hover { border-color: var(--forest); background: var(--cream); }
button.text-link:active { transform: scale(0.97); }

button.text-link.danger {
  color: var(--overdue);
  border-color: var(--overdue-bg);
  background: var(--overdue-bg);
}
button.text-link.danger:hover { background: var(--overdue); border-color: var(--overdue); color: #fff; }

input[type="text"], input[type="email"], input[type="password"], input[type="date"], textarea, select {
  font-family: "Nunito Sans", sans-serif;
  font-size: 0.95rem;
  padding: 12px 16px;
  border: 1.5px solid var(--rule);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
  width: 100%;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type="text"]:focus, input[type="email"]:focus, input[type="password"]:focus,
input[type="date"]:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--moss);
  box-shadow: 0 0 0 4px rgba(78, 115, 80, 0.15);
}

input::placeholder, textarea::placeholder { color: var(--ink-soft); opacity: 0.55; }

textarea { resize: vertical; min-height: 70px; }

/* ---------- icon-prefixed fields (login / register) ---------- */

.field-icon { position: relative; }

.field-icon svg {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--ink-soft);
  pointer-events: none;
}

.field-icon input, .field-icon select {
  padding-left: 46px;
}

.field-icon select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23746B57' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
  padding-right: 40px;
}

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink-soft);
  margin-bottom: 5px;
}

.field { margin-bottom: 14px; }

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

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    radial-gradient(ellipse at top left, rgba(205,169,104,0.25), transparent 55%),
    linear-gradient(160deg, var(--forest), var(--forest-2) 60%, #24402F);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 38px 32px;
  box-shadow: 0 24px 60px rgba(15, 26, 18, 0.35);
  overflow: hidden;
}

.login-card button[type="submit"] { border-radius: 14px; }

/* ---------- auth card header (eyebrow + title + icon badge) ---------- */

.auth-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.auth-eyebrow {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--moss-dark);
}

.auth-icon-badge {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(160deg, var(--moss), var(--forest-2));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 6px 16px rgba(30, 51, 39, 0.28);
}

.auth-icon-badge svg { width: 18px; height: 18px; }

.auth-title {
  font-family: "Fraunces", serif;
  font-weight: 700;
  font-style: normal;
  font-size: 2rem;
  color: var(--forest);
  margin: 12px 0 6px;
}

.auth-subtitle {
  color: var(--ink-soft);
  font-size: 0.92rem;
  margin-bottom: 22px;
}

.auth-hr {
  height: 1px;
  background: var(--rule);
  border: none;
  margin: 0 -32px 26px;
}

/* ---------- footer strip (switch between sign in / create account) ---------- */

.auth-footer {
  margin: 26px -32px -38px;
  padding: 20px 32px;
  border-top: 1px solid var(--rule);
  background: var(--cream);
  text-align: center;
  font-size: 0.88rem;
  color: var(--ink-soft);
}

.auth-footer a { color: var(--forest); text-decoration: none; font-weight: 800; }
.auth-footer a:hover { text-decoration: underline; }

.auth-footnote {
  text-align: center;
  margin-top: 16px;
  font-size: 0.72rem;
}
.auth-footnote a { color: var(--ink-soft); }

.login-card .wordmark {
  display: block;
  text-align: center;
  margin-bottom: 4px;
  color: var(--forest);
}

.login-tagline {
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.88rem;
  margin-bottom: 26px;
}

/* ---------- "or" divider ---------- */

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 22px 0;
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--rule);
}

/* ---------- create-account call to action ---------- */

.create-account-cta {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1.5px dashed var(--rule-strong);
  text-decoration: none;
  color: var(--ink);
  background: var(--card);
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.06s ease;
}

.create-account-cta:hover {
  border-color: var(--moss);
  background: var(--done-bg);
}

.create-account-cta:active { transform: scale(0.99); }

.create-account-cta-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--moss);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.create-account-cta-icon svg { width: 20px; height: 20px; }

.create-account-cta-text { font-size: 0.88rem; line-height: 1.35; }

.create-account-cta-text strong {
  display: block;
  font-family: "Fraunces", serif;
  font-weight: 600;
  font-size: 1rem;
  color: var(--forest);
}

.error-msg {
  color: var(--overdue);
  font-size: 0.85rem;
  margin-top: 10px;
  min-height: 1.2em;
}

.setup-link {
  text-align: center;
  margin-top: 22px;
  font-size: 0.82rem;
}

/* ---------- group tiles (replaces plain tabs) ---------- */

.tabs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 26px 0 28px;
}

.tab {
  padding: 14px 20px;
  cursor: pointer;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 0.95rem;
  color: #fff;
  background: var(--moss);
  opacity: 0.55;
  transition: opacity 0.15s ease, transform 0.1s ease;
}

.tab:hover { opacity: 0.8; }

.tab.active {
  opacity: 1;
  box-shadow: 0 6px 16px rgba(30, 51, 39, 0.25);
}

/* cycling accent colors for visual variety, like a tile mosaic */
.tab.c0 { background: var(--forest); }
.tab.c1 { background: var(--clay); }
.tab.c2 { background: var(--moss); }
.tab.c3 { background: #6B5B95; }
.tab.c4 { background: #3C6E71; }

.tab.add-tab {
  background: transparent;
  border: 1.5px dashed var(--rule-strong);
  color: var(--ink-soft);
  opacity: 1;
  font-weight: 600;
}

.tab.all-tab { background: var(--ink); }

/* ---------- sections ---------- */

section.block {
  margin-bottom: 36px;
}

/* ---------- two-up group detail layout (teacher view) ---------- */

.detail-columns {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 22px;
  align-items: start;
}

.detail-columns section.block { margin-bottom: 0; }

@media (max-width: 900px) {
  .detail-columns { grid-template-columns: 1fr; }
}

.block-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
}

.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: var(--card);
  border-radius: var(--radius);
  margin-bottom: 10px;
  box-shadow: 0 2px 10px rgba(30, 51, 39, 0.06);
}

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

.student-row { cursor: pointer; transition: box-shadow 0.15s ease; }
.student-row:hover { box-shadow: 0 2px 12px rgba(30, 51, 39, 0.14); }
.row-title { font-weight: 700; }
.row-sub { color: var(--ink-soft); font-size: 0.85rem; margin-top: 2px; }

.empty-note {
  color: var(--ink-soft);
  font-size: 0.9rem;
  padding: 18px 20px;
  font-style: italic;
  background: var(--card);
  border-radius: var(--radius);
}

/* ---------- status chips (icon + label) ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 5px 12px 5px 6px;
  border-radius: 999px;
  white-space: nowrap;
}

.badge .dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.badge.done { background: var(--done-bg); color: var(--done); }
.badge.done .dot { background: var(--done); }
.badge.due { background: var(--due-bg); color: var(--due); }
.badge.due .dot { background: var(--due); }
.badge.overdue { background: var(--overdue-bg); color: var(--overdue); }
.badge.overdue .dot { background: var(--overdue); }
.badge.pending { background: var(--rule); color: var(--ink-soft); }
.badge.pending .dot { background: var(--ink-soft); }

/* ---------- groups overview (read-only summary grid + matrix) ---------- */

.section-hint {
  color: var(--ink-soft);
  font-size: 0.9rem;
  margin: -6px 0 18px;
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 18px;
}

.overview-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: 0 2px 10px rgba(30, 51, 39, 0.06);
  cursor: pointer;
  transition: box-shadow 0.15s ease, transform 0.1s ease;
}
.overview-card:hover { box-shadow: 0 6px 18px rgba(30, 51, 39, 0.14); transform: translateY(-1px); }

.overview-card.add-card {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  border: 1.5px dashed var(--rule-strong);
  box-shadow: none;
  color: var(--ink-soft);
  font-weight: 700;
  min-height: 150px;
}
.overview-card.add-card:hover { border-color: var(--forest); color: var(--forest); box-shadow: none; transform: none; }

.overview-badge {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 1.05rem;
  margin-bottom: 16px;
}
.overview-badge.c0 { background: var(--forest); }
.overview-badge.c1 { background: var(--clay); }
.overview-badge.c2 { background: var(--moss); }
.overview-badge.c3 { background: #6B5B95; }
.overview-badge.c4 { background: #3C6E71; }

.overview-name {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 1.05rem;
  margin-bottom: 6px;
}
.overview-meta { color: var(--ink-soft); font-size: 0.85rem; margin-bottom: 18px; }
.overview-open { font-weight: 700; font-size: 0.88rem; color: var(--forest); }

/* ---------- student progress matrix (students x homework) ---------- */

.matrix-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.matrix-toolbar input[type="text"] { max-width: 280px; width: 100%; }

.matrix-scroll {
  overflow-x: auto;
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: 0 2px 10px rgba(30, 51, 39, 0.06);
}

.matrix-table {
  border-collapse: collapse;
  width: 100%;
  min-width: 640px;
}
.matrix-table th, .matrix-table td {
  padding: 14px 18px;
  text-align: left;
  border-bottom: 1px solid var(--rule);
  white-space: nowrap;
}
.matrix-table th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ink-soft);
  font-weight: 700;
  background: var(--cream);
}
.matrix-due {
  display: block;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  color: var(--ink-soft);
  margin-top: 3px;
  font-size: 0.7rem;
}
.matrix-table th.student-col, .matrix-table td.student-col {
  position: sticky;
  left: 0;
  background: var(--card);
  z-index: 1;
}
.matrix-table th.student-col { background: var(--cream); z-index: 2; }
.matrix-table tbody tr:last-child td { border-bottom: none; }

.matrix-student-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
}
.matrix-count {
  margin-left: auto;
  padding-left: 14px;
  color: var(--ink-soft);
  font-weight: 700;
  font-size: 0.82rem;
  white-space: nowrap;
}

/* ---------- homework detail / roster ---------- */

.hw-item {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 12px;
  box-shadow: 0 2px 10px rgba(30, 51, 39, 0.06);
}

.hw-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
}

.hw-desc {
  color: var(--ink-soft);
  font-size: 0.9rem;
  margin: 8px 0 0;
  max-width: 62ch;
}

.hw-body { margin-top: 14px; }

/* bigger, harder-to-miss status badge for the collapsed student homework
   row — "due" and "overdue" get an extra halo so they stand out at a
   glance without opening the card */
.badge-lg {
  font-size: 0.9rem;
  padding: 7px 16px 7px 7px;
  flex-shrink: 0;
}
.badge-lg .dot { width: 20px; height: 20px; }
.badge-lg.due { box-shadow: 0 0 0 2px var(--due-bg), 0 2px 10px rgba(185, 134, 46, 0.35); }
.badge-lg.overdue { box-shadow: 0 0 0 2px var(--overdue-bg), 0 2px 10px rgba(168, 69, 46, 0.35); }

.roster {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
}

.roster .row {
  background: var(--cream);
  padding: 10px 14px;
}

/* ---------- forms inline ---------- */

.inline-form {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  margin-top: 14px;
  margin-bottom: 18px;
  box-shadow: 0 2px 10px rgba(30, 51, 39, 0.06);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

@media (max-width: 560px) {
  .form-grid { grid-template-columns: 1fr; }
  .whoami { text-align: left; }
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

.hint {
  font-size: 0.82rem;
  color: var(--ink-soft);
  margin-top: 10px;
}

/* ---------- avatars ---------- */

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--rule);
  cursor: pointer;
  flex-shrink: 0;
  border: 1px solid var(--rule-strong);
}

.avatar.small { width: 28px; height: 28px; }
.avatar.large { width: 96px; height: 96px; }

.avatar-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--cream);
  font-family: "Fraunces", serif;
  font-weight: 600;
}

/* ---------- lightbox (image viewer) ---------- */

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(10, 16, 12, 0.92);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.lightbox.open { display: flex; }

.lightbox-frame {
  width: 100%;
  height: 100%;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-img {
  max-width: 92vw;
  max-height: 92vh;
  cursor: zoom-in;
  transition: transform 0.15s ease;
  touch-action: pinch-zoom;
}
.lightbox-img.zoomed {
  max-width: none;
  max-height: none;
  width: auto;
  height: 220vh;
  cursor: zoom-out;
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(255,255,255,0.12);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 1.1rem;
  z-index: 1001;
}

/* ---------- chat modal ---------- */

.chat-modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 16, 12, 0.5);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 900;
}
.chat-modal.open { display: flex; }

.chat-panel {
  width: 100%;
  max-width: 480px;
  height: min(80vh, 640px);
  background: var(--cream);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
@media (min-width: 640px) {
  .chat-modal { align-items: center; }
  .chat-panel { border-radius: var(--radius-lg); }
}

.chat-header {
  background: var(--forest);
  color: var(--cream);
  padding: 16px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}
.chat-title { font-family: "Fraunces", serif; font-weight: 600; font-style: italic; font-size: 1.1rem; }
.chat-close { background: none; border: none; color: var(--cream); font-size: 1rem; padding: 4px 8px; border-radius: 50%; }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-bubble {
  max-width: 78%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 0.92rem;
}
.chat-bubble.theirs {
  align-self: flex-start;
  background: var(--card);
  box-shadow: 0 1px 4px rgba(30,51,39,0.08);
  border-bottom-left-radius: 4px;
}
.chat-bubble.mine {
  align-self: flex-end;
  background: var(--moss);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-bubble-text { white-space: pre-wrap; word-break: break-word; }
.chat-bubble-time { font-size: 0.68rem; opacity: 0.7; margin-top: 3px; text-align: right; }

.chat-input-row {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--rule);
  flex-shrink: 0;
  background: var(--card);
}
.chat-input-row input { flex: 1; }
.chat-input-row button { padding: 10px 18px; }

.chat-send-error {
  padding: 0 14px;
  color: var(--overdue);
  font-size: 0.78rem;
  font-weight: 700;
}
.chat-send-error:empty { display: none; }

/* ---------- chat: message rows, action menu, replies, ticks, edit ---------- */

.chat-msg-row {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  max-width: 100%;
  position: relative;
}
.chat-msg-row.mine { justify-content: flex-end; }
.chat-msg-row.theirs { justify-content: flex-start; }

.chat-bubble { position: relative; touch-action: pan-y; user-select: none; }

.chat-msg-menu-btn {
  background: none;
  border: none;
  color: var(--ink-soft);
  font-size: 1.15rem;
  line-height: 1;
  padding: 6px 5px;
  cursor: pointer;
  opacity: 0.5;
  flex-shrink: 0;
  align-self: center;
}
.chat-msg-menu-btn:hover { opacity: 1; }

.chat-bubble-menu {
  position: absolute;
  top: 4px;
  z-index: 20;
  background: var(--card);
  border-radius: 12px;
  box-shadow: 0 6px 20px rgba(30, 51, 39, 0.22);
  padding: 6px;
  display: none;
  min-width: 172px;
}
.chat-bubble-menu.open { display: block; }
.chat-msg-row.mine .chat-bubble-menu { right: 0; }
.chat-msg-row.theirs .chat-bubble-menu { left: 0; }

.chat-bubble-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
}
.chat-bubble-menu button:hover { background: var(--cream); }
.chat-bubble-menu button.danger { color: var(--overdue); }

.chat-reply-hint {
  position: absolute;
  left: -30px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  opacity: 0;
  color: var(--moss);
  pointer-events: none;
}
.chat-msg-row.mine .chat-reply-hint { left: auto; right: -30px; }

.chat-reply-quote {
  border-left: 3px solid rgba(0,0,0,0.18);
  padding: 4px 9px;
  margin-bottom: 6px;
  border-radius: 4px;
  background: rgba(0,0,0,0.05);
  cursor: pointer;
  font-size: 0.82rem;
}
.chat-bubble.mine .chat-reply-quote { border-left-color: rgba(255,255,255,0.55); background: rgba(255,255,255,0.14); }
.chat-reply-quote-author { font-weight: 800; margin-bottom: 1px; }
.chat-reply-quote-text { opacity: 0.85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chat-bubble.deleted .chat-bubble-text { font-style: italic; opacity: 0.65; }

.chat-bubble-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: flex-end;
  margin-top: 3px;
}
.chat-bubble-edited { font-size: 0.68rem; opacity: 0.7; }
.chat-ticks { display: inline-flex; align-items: center; }
.chat-ticks svg { width: 15px; height: 15px; color: rgba(255,255,255,0.75); }
.chat-ticks.seen svg { color: var(--sand); }
.chat-bubble.theirs .chat-ticks { display: none; }

.chat-edit-box textarea {
  width: 100%;
  min-height: 60px;
  font-family: inherit;
  font-size: 0.92rem;
  border-radius: 8px;
  padding: 8px;
  border: 1px solid var(--rule-strong);
  resize: vertical;
}
.chat-edit-actions { display: flex; gap: 8px; margin-top: 6px; }
.chat-edit-actions button { padding: 6px 14px; font-size: 0.82rem; }

.chat-reply-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 14px;
  border-top: 1px solid var(--rule);
  background: var(--cream);
  flex-shrink: 0;
}
.chat-reply-bar.open { display: flex; }
.chat-reply-bar-text { min-width: 0; }
.chat-reply-bar-author { font-weight: 800; font-size: 0.8rem; color: var(--forest); }
.chat-reply-bar-snippet { font-size: 0.8rem; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.chat-reply-cancel { background: none; border: none; font-size: 1rem; color: var(--ink-soft); padding: 4px 8px; flex-shrink: 0; cursor: pointer; }

.chat-highlight { animation: chatHighlight 1s ease; }
@keyframes chatHighlight {
  0% { box-shadow: 0 0 0 3px var(--sand); }
  100% { box-shadow: none; }
}

.unread-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--overdue);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  margin-left: 6px;
}

/* ---------- file-type checkbox grid ---------- */

.filetype-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
  margin-top: 6px;
}
.filetype-grid label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--ink);
  margin-bottom: 0;
}
.filetype-grid input[type="checkbox"] { width: auto; }

/* ---------- custom "add files" control ---------- */

.file-attach-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.file-attach-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  color: var(--forest);
  border: 1.5px solid var(--forest);
  box-shadow: 0 2px 0 var(--forest), 0 3px 8px rgba(30, 51, 39, 0.16);
  padding: 9px 18px 9px 14px;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.file-attach-btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.file-attach-btn:hover { opacity: 1; transform: translateY(-1px); }
.file-attach-btn:active {
  transform: translateY(1px);
  box-shadow: 0 1px 0 var(--forest), 0 2px 5px rgba(30, 51, 39, 0.16);
}

.file-attach-hint { font-size: 0.8rem; color: var(--ink-soft); }

/* ---------- attachment chips ---------- */

.attachment-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}
.attachment-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--cream);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.85rem;
}
.attachment-chip button {
  background: none;
  border: none;
  color: var(--overdue);
  font-weight: 700;
  padding: 0 4px;
  font-size: 0.9rem;
}

/* ---------- settings page ---------- */

.settings-card {
  max-width: 480px;
  margin: 0 auto;
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: 0 2px 10px rgba(30, 51, 39, 0.06);
}
.avatar-edit-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

/* ---------- feedback ---------- */

.feedback-box {
  background: var(--cream);
  border-radius: 10px;
  padding: 10px 14px;
  margin-top: 8px;
  font-size: 0.88rem;
}
.feedback-box .label {
  font-weight: 700;
  color: var(--moss);
  font-size: 0.78rem;
  text-transform: none;
  margin-bottom: 2px;
}

/* ---------- sidebar app shell (student dashboard) ---------- */

.app-shell {
  display: flex;
  min-height: 100vh;
  align-items: flex-start;
}

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--forest);
  color: var(--cream);
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  min-height: 100vh;
  position: sticky;
  top: 0;
}

.sidebar-brand {
  font-family: "Fraunces", serif;
  font-style: italic;
  font-weight: 500;
  font-size: 1.25rem;
  color: var(--cream);
  padding: 0 8px 20px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 12px;
  border-radius: 10px;
  color: #CFE0D2;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-link:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar-link.active { background: rgba(255,255,255,0.14); color: #fff; }
.sidebar-link .unread-dot { margin-left: auto; }

.sidebar-foot {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-foot .name { color: var(--cream); font-weight: 700; font-size: 0.88rem; display: block; }
.sidebar-foot .sub-link { color: #B9CBBB; font-size: 0.78rem; text-decoration: underline; background: none; border: none; padding: 0; cursor: pointer; }

.main-area {
  flex: 1;
  min-width: 0;
  padding: 30px 36px 60px;
}

.main-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 26px;
}

.main-eyebrow {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.main-title {
  font-family: "Fraunces", serif;
  font-weight: 700;
  font-size: 1.9rem;
  color: var(--forest);
  margin: 4px 0 0;
}

.group-pill {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--forest);
  box-shadow: 0 2px 8px rgba(30,51,39,0.06);
}

.section-eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 4px;
}

.section-eyebrow .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--moss); flex-shrink: 0; }

.count-pill {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink-soft);
}

@media (max-width: 760px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    width: 100%;
    min-height: 0;
    position: static;
    flex-wrap: wrap;
    align-items: center;
    padding: 14px 16px;
    gap: 10px;
  }
  .sidebar-brand { padding: 0; flex-shrink: 0; }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; flex: 1 1 auto; gap: 6px; justify-content: flex-end; }
  .sidebar-link { flex-direction: row; gap: 6px; font-size: 0.78rem; padding: 8px 12px; white-space: nowrap; border-radius: 999px; }
  .sidebar-link svg { width: 15px; height: 15px; }
  .sidebar-foot { width: 100%; margin-top: 4px; padding-top: 10px; border-top: 1px solid rgba(255,255,255,0.15); }
  .sidebar-foot .name { display: block; }
  .main-area { padding: 22px 18px 40px; }
}

/* ---------- small icon-style buttons for crowded rows ---------- */

.row-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}
