/* ============================================================
   Class Study Hub — Stylesheet
   Aesthetic: a quiet lecture archive. Warm paper background,
   a textbook serif for headings, monospace for catalogue-style
   metadata (course codes, timestamps), forest green as the one accent.
   ============================================================ */

:root {
  --paper:        #f6f1e7;
  --paper-raised: #fffdf8;
  --ink:          #2a2622;
  --ink-soft:     #6b6358;
  --rule:         #ddd3c0;
  --forest:       #1f3b2c;
  --forest-soft:  #2e5440;
  --forest-tint:  #e7eee7;
  --amber:        #b5742a;
  --danger:       #9a3b2f;
  --radius:       10px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden; /* safety net — no element should ever force horizontal scroll */
}

h1, h2, h3, h4 {
  font-family: 'Source Serif 4', Georgia, serif;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 0.4em;
  color: var(--ink);
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; }

p { margin: 0 0 1em; }

a { color: var(--forest-soft); text-decoration: none; }
a:hover { text-decoration: underline; }

.mono {
  font-family: 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;
  letter-spacing: 0.02em;
}

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

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px;
}

.topbar {
  background: var(--paper-raised);
  border-bottom: 1px solid var(--rule);
  position: sticky;
  top: 0;
  z-index: 100;
  --topbar-height: 64px; /* used by .nav-links (mobile drawer) to sit just below */
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  gap: 12px;
  position: relative;
}

/* ── Brand / logo ─────────────────────────────────────────────────────── */
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--ink);
  text-decoration: none;
  flex-shrink: 0;
}
.brand:hover { text-decoration: none; }

.brand-logo {
  height: 38px;
  width: auto;
  max-width: 160px;
  object-fit: contain;
  display: block;
  border-radius: 4px;
}

.brand .mark {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  background: var(--forest);
  color: var(--paper-raised);
  padding: 3px 7px;
  border-radius: 4px;
  letter-spacing: 0.06em;
}

/* ── Desktop nav ──────────────────────────────────────────────────────── */
.nav-links {
  display: flex;
  align-items: center;
  gap: 18px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.nav-links a { color: var(--ink-soft); white-space: nowrap; }
.nav-links a:hover { color: var(--forest); text-decoration: none; }
.nav-links a.active { color: var(--forest); }

.nav-links .pill {
  background: var(--forest);
  color: var(--paper-raised) !important;
  padding: 8px 14px;
  border-radius: 6px;
}
.nav-links .pill:hover { background: var(--forest-soft); }

/* ── Hamburger button (mobile only) ──────────────────────────────────── */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  background: none;
  border: 1px solid var(--rule);
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
}
.nav-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--ink);
  border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

/* Animate to X when open */
.nav-toggle[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.nav-toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}
.nav-toggle[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ── Mobile drawer ────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .nav-toggle { display: flex; }

  .nav-links {
    /* Hidden off-screen by default.
       Anchored to the viewport (left:0/right:0 fixed) rather than bleeding
       past .wrap with negative margins — that approach widened the page's
       scrollable area and caused horizontal scroll even while closed. */
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    position: fixed;
    top: var(--topbar-height, 64px);
    left: 0;
    right: 0;
    width: 100%;
    background: var(--paper-raised);
    border-bottom: 2px solid var(--forest);
    box-shadow: 0 8px 24px rgba(31,59,44,0.12);
    padding: 8px 0 16px;
    z-index: 99;
    box-sizing: border-box;
    /* Collapse animation */
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transition: max-height 0.28s ease, opacity 0.2s ease;
  }

  /* Open state toggled by JS adding .nav-open to the nav element */
  .nav-links.nav-open {
    max-height: 400px;
    opacity: 1;
    pointer-events: auto;
  }

  .nav-links a {
    display: block;
    padding: 13px 24px;
    font-size: 0.88rem;
    color: var(--ink);
    border-bottom: 1px solid var(--rule);
    letter-spacing: 0.03em;
  }
  .nav-links a:last-child { border-bottom: none; }
  .nav-links a:hover {
    background: var(--forest-tint);
    color: var(--forest);
    text-decoration: none;
  }
  .nav-links a.active {
    background: var(--forest-tint);
    color: var(--forest);
    font-weight: 600;
  }

  .nav-links .pill {
    margin: 10px 24px 4px;
    display: block;
    text-align: center;
    border-radius: 6px;
    padding: 12px;
    border-bottom: none !important;
  }
  .nav-links .pill:hover { background: var(--forest-soft); }

  /* Hide the desktop-only divider line inside mobile drawer */
  .nav-divider { display: none; }

  /* Log out: same style as other drawer links on mobile */
  .nav-links .nav-logout {
    color: var(--ink) !important;
    font-size: 0.88rem !important;
    padding: 13px 24px;
    border-bottom: 1px solid var(--rule);
  }
  .nav-links .nav-logout:last-child { border-bottom: none; }
  .nav-links .nav-logout:hover {
    color: var(--danger) !important;
    background: #fdf0ee;
  }

  /* Admin link: small badge treatment inside drawer */
  .nav-links .nav-admin {
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .nav-links .nav-admin::after {
    content: 'Admin';
    font-size: 0.65rem;
    background: var(--amber);
    color: #fff;
    padding: 2px 6px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-family: 'JetBrains Mono', monospace;
  }

  .brand-logo {
    height: 32px;
    max-width: 130px;
  }
}

@media (max-width: 360px) {
  .brand-logo { height: 28px; max-width: 110px; }
  .topbar { --topbar-height: 58px; }
}

main { min-height: 60vh; padding: 32px 0 64px; }

footer {
  border-top: 1px solid var(--rule);
  padding: 22px 0;
  font-size: 0.85rem;
  color: var(--ink-soft);
  text-align: center;
}

/* ---------- Buttons & forms ---------- */

.btn {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 11px 20px;
  border-radius: 6px;
  border: 1px solid var(--forest);
  background: var(--forest);
  color: var(--paper-raised);
  cursor: pointer;
  text-align: center;
}
.btn:hover { background: var(--forest-soft); text-decoration: none; }
.btn.outline { background: transparent; color: var(--forest); }
.btn.outline:hover { background: var(--forest-tint); }
.btn.danger { background: var(--danger); border-color: var(--danger); }
.btn.danger:hover { background: #7e2f25; }
.btn.full { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
.field input, .field select, .field textarea {
  width: 100%;
  font-family: inherit;
  font-size: 1rem;
  padding: 11px 13px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--paper-raised);
  color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--forest-soft);
  outline-offset: 1px;
}
.field textarea { resize: vertical; min-height: 90px; }
.field .hint { font-size: 0.82rem; color: var(--ink-soft); margin-top: 5px; }

.card-form {
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 440px;
  margin: 24px auto;
}
.card-form.wide { max-width: 640px; }

.alert {
  border-radius: 6px;
  padding: 12px 16px;
  margin-bottom: 18px;
  font-size: 0.92rem;
}
.alert.error { background: #f6e3df; color: var(--danger); border: 1px solid #e2bdb4; }
.alert.success { background: var(--forest-tint); color: var(--forest); border: 1px solid #bcd4bf; }

/* ---------- Hero ---------- */

.hero {
  padding: 28px 0 8px;
  border-bottom: 1px dashed var(--rule);
  margin-bottom: 28px;
}
.hero .eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--amber);
  margin-bottom: 8px;
}
.hero p.lede { font-size: 1.05rem; color: var(--ink-soft); max-width: 620px; }

/* ---------- Filter bar ---------- */

.filters {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
  align-items: center;
}
.filters select {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  padding: 8px 12px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--paper-raised);
}

/* Search input — takes priority width, wraps to its own row on small screens */
.search-field {
  position: relative;
  flex: 1 1 240px;
  min-width: 200px;
  display: flex;
  align-items: center;
}
.search-field input[type="search"] {
  width: 100%;
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 0.92rem;
  padding: 10px 36px 10px 36px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--paper-raised);
  color: var(--ink);
}
.search-field input[type="search"]:focus {
  outline: 2px solid var(--forest-soft);
  outline-offset: 1px;
  border-color: var(--forest);
}
/* Remove native browser search decorations for consistent styling */
.search-field input[type="search"]::-webkit-search-decoration,
.search-field input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

.search-icon {
  position: absolute;
  left: 11px;
  font-size: 0.85rem;
  opacity: 0.5;
  pointer-events: none;
}

.search-clear {
  position: absolute;
  right: 6px;
  background: var(--rule);
  color: var(--ink-soft);
  border: none;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  font-size: 0.7rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.search-clear:hover { background: var(--forest); color: #fff; }

.search-submit {
  font-family: 'JetBrains Mono', monospace;
}

.search-result-count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: var(--ink-soft);
  margin-bottom: 18px;
}
.search-result-count strong { color: var(--forest); }

@media (max-width: 600px) {
  .search-field { flex-basis: 100%; }
}

/* ---------- Video grid & cards ---------- */

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

.video-card {
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.video-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(31, 59, 44, 0.1);
}

.video-thumb {
  position: relative;
  aspect-ratio: 16/9;
  background: var(--forest);
  display: flex;
  align-items: center;
  justify-content: center;
}
.video-thumb img { width: 100%; height: 100%; object-fit: cover; }
.play-mark {
  width: 46px; height: 46px;
  border-radius: 50%;
  background: rgba(255,255,255,0.92);
  display: flex; align-items: center; justify-content: center;
  position: relative;
  z-index: 2;
}
.play-mark::after {
  content: '';
  border-style: solid;
  border-width: 8px 0 8px 13px;
  border-color: transparent transparent transparent var(--forest);
  margin-left: 2px;
}

.video-body { padding: 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }

.course-stamp {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--forest);
  background: var(--forest-tint);
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  width: fit-content;
}

.video-body h3 { font-size: 1.05rem; margin-bottom: 2px; }
.video-meta { font-size: 0.83rem; color: var(--ink-soft); }
.video-summary { font-size: 0.88rem; color: var(--ink-soft); }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--ink-soft);
}
.empty-state .eyebrow { color: var(--amber); }

/* ---------- Video detail page ---------- */

.video-page-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 28px;
}
@media (min-width: 880px) {
  .video-page-grid { grid-template-columns: 1.4fr 1fr; }
}

.player-wrap {
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 16/9;
}
.player-wrap video { width: 100%; height: 100%; }

.summary-box {
  background: var(--forest-tint);
  border-left: 3px solid var(--forest);
  border-radius: 6px;
  padding: 16px 18px;
  margin-top: 18px;
  font-size: 0.94rem;
}
.summary-box .eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  text-transform: uppercase;
  color: var(--forest);
  margin-bottom: 6px;
}

/* ---------- AI Chat panel ---------- */

.ai-panel {
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  max-height: 600px;
}
.ai-panel-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--rule);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--forest);
}
.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 200px;
}
.ai-msg { max-width: 90%; font-size: 0.92rem; }
.ai-msg.user {
  align-self: flex-end;
  background: var(--forest);
  color: var(--paper-raised);
  padding: 9px 13px;
  border-radius: 10px 10px 2px 10px;
}
.ai-msg.assistant {
  align-self: flex-start;
  background: var(--forest-tint);
  padding: 9px 13px;
  border-radius: 10px 10px 10px 2px;
}
.ai-msg.unavailable {
  align-self: center;
  color: var(--ink-soft);
  font-size: 0.85rem;
  font-style: italic;
}
.ai-input-row {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--rule);
}
.ai-input-row input {
  flex: 1;
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 10px 12px;
  font-family: inherit;
}
.ai-input-row button {
  font-family: 'JetBrains Mono', monospace;
  background: var(--forest);
  color: var(--paper-raised);
  border: none;
  border-radius: 6px;
  padding: 0 16px;
  cursor: pointer;
  font-size: 0.85rem;
}
.ai-input-row button:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Tables (admin) ---------- */

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
}
thead { background: var(--forest-tint); }
th, td {
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--rule);
  font-size: 0.9rem;
}
th {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--forest);
}
tr:last-child td { border-bottom: none; }

.status-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 4px;
  display: inline-block;
}
.status-badge.pending { background: #f3e7ce; color: var(--amber); }
.status-badge.approved { background: var(--forest-tint); color: var(--forest); }
.status-badge.rejected, .status-badge.suspended { background: #f6e3df; color: var(--danger); }

.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.row-actions form { display: inline; }
.btn-sm {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  text-transform: uppercase;
  padding: 6px 11px;
  border-radius: 5px;
  border: 1px solid var(--rule);
  background: var(--paper-raised);
  cursor: pointer;
}
.btn-sm.approve { border-color: var(--forest); color: var(--forest); }
.btn-sm.approve:hover { background: var(--forest-tint); }
.btn-sm.reject { border-color: var(--danger); color: var(--danger); }
.btn-sm.reject:hover { background: #f6e3df; }

.admin-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  text-transform: uppercase;
}
.admin-tabs a {
  padding: 9px 16px;
  border-radius: 6px;
  color: var(--ink-soft);
}
.admin-tabs a.active { background: var(--forest); color: var(--paper-raised); }

.stat-row { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; }
.stat-card {
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 16px 20px;
  min-width: 140px;
}
.stat-card .num { font-size: 1.8rem; font-weight: 700; color: var(--forest); }
.stat-card .label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  text-transform: uppercase;
  color: var(--ink-soft);
}

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

.table-wrap { overflow-x: auto; }
.section-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 16px;
}

@media (max-width: 600px) {
  .hero h1 { font-size: 1.5rem; }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .video-card { transition: none; }
}

/* Visible focus for keyboard users */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--forest-soft);
  outline-offset: 2px;
}

/* ── Brand fallback (shown when logo.jpg fails to load) ─────────────── */
.brand-fallback {
  display: none;
  align-items: baseline;
  gap: 8px;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
}
.brand-name {
  font-family: 'Source Serif 4', Georgia, serif;
}

/* ── Nav divider (desktop only) ──────────────────────────────────────── */
.nav-divider {
  display: block;
  width: 1px;
  height: 16px;
  background: var(--rule);
  flex-shrink: 0;
}

/* ── Log out link — subtle on desktop ───────────────────────────────── */
.nav-logout {
  color: var(--ink-soft) !important;
  font-size: 0.78rem !important;
}
.nav-logout:hover { color: var(--danger) !important; }

/* ── Nav overlay (mobile) — dark sheet behind open drawer ────────────── */
.nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(31, 38, 34, 0.35);
  z-index: 98;
  backdrop-filter: blur(1px);
  -webkit-backdrop-filter: blur(1px);
}
.nav-overlay.active {
  display: block;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}


/* ── PWA Install Banner ───────────────────────────────────────────────── */
.install-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: 0 0 env(safe-area-inset-bottom, 0);
  animation: slideUp 0.3s ease;
}
@keyframes slideUp {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.install-banner[hidden] { display: none !important; }

.install-banner-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--paper-raised);
  border-top: 1px solid var(--rule);
  box-shadow: 0 -4px 20px rgba(31,59,44,0.10);
  padding: 14px 18px;
  max-width: 640px;
  margin: 0 auto;
  border-radius: 12px 12px 0 0;
}

.install-banner-logo {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 8px;
  flex-shrink: 0;
}

.install-banner-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.install-banner-text strong {
  font-size: 0.92rem;
  color: var(--ink);
}
.install-banner-text span {
  font-size: 0.8rem;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.install-banner-btn {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 9px 16px;
  border-radius: 6px;
  background: var(--forest);
  color: var(--paper-raised);
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
}
.install-banner-btn:hover { background: var(--forest-soft); }

.install-banner-close {
  background: none;
  border: none;
  color: var(--ink-soft);
  font-size: 1rem;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  flex-shrink: 0;
  line-height: 1;
}
.install-banner-close:hover { color: var(--ink); background: var(--rule); }

@media (max-width: 480px) {
  .install-banner-text span { display: none; }
  .install-banner-inner { gap: 10px; padding: 12px 14px; }
}

/* ── Pending badge on Admin nav link ─────────────────────────────────── */
.nav-admin {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 99px;
  background: #c0392b;
  color: #fff;
  font-size: 0.65rem;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1;
  animation: badgePop 0.25s cubic-bezier(0.34,1.56,0.64,1) both;
}

@keyframes badgePop {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* Badge inside mobile drawer */
@media (max-width: 640px) {
  .nav-admin {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
  }
  /* Override the admin::after pseudo-element when badge is present */
  .nav-badge {
    font-size: 0.72rem;
    min-width: 22px;
    height: 22px;
  }
}

/* ── Notifications page ───────────────────────────────────────────────── */
.notify-mode-tabs {
  display: flex;
  gap: 0;
  border: 1px solid var(--rule);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 24px;
  background: var(--paper-raised);
}
.notify-mode-tabs button {
  flex: 1;
  padding: 11px 10px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: none;
  border: none;
  border-right: 1px solid var(--rule);
  cursor: pointer;
  color: var(--ink-soft);
  transition: background 0.15s, color 0.15s;
}
.notify-mode-tabs button:last-child { border-right: none; }
.notify-mode-tabs button.active {
  background: var(--forest);
  color: var(--paper-raised);
}
.notify-mode-tabs button:hover:not(.active) {
  background: var(--forest-tint);
  color: var(--forest);
}

.channel-pick {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.channel-pick label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  padding: 10px 16px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--paper-raised);
  transition: border-color 0.15s, background 0.15s;
}
.channel-pick label:has(input:checked) {
  border-color: var(--forest);
  background: var(--forest-tint);
  color: var(--forest);
}
.channel-pick input[type="checkbox"] { accent-color: var(--forest); }

.member-checklist {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 12px;
  background: var(--paper-raised);
}
.member-checklist label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  padding: 6px 8px;
  border-radius: 5px;
  cursor: pointer;
}
.member-checklist label:hover { background: var(--forest-tint); }
.member-checklist input[type="checkbox"] { accent-color: var(--forest); flex-shrink: 0; }

.char-counter {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--ink-soft);
  text-align: right;
  margin-top: 4px;
}
.char-counter.warn { color: var(--amber); }
.char-counter.over { color: var(--danger); font-weight: 600; }

.notify-log {
  margin-top: 32px;
}
.notify-log-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 0;
  border-bottom: 1px solid var(--rule);
  font-size: 0.88rem;
}
.notify-log-item:last-child { border-bottom: none; }
.notify-log-icon {
  font-size: 1rem;
  flex-shrink: 0;
  margin-top: 1px;
}
.notify-log-meta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: var(--ink-soft);
  margin-top: 3px;
}

/* ── Role badge in members table ─────────────────────────────────────── */
.role-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 3px;
  background: var(--forest-tint);
  color: var(--forest);
  letter-spacing: 0.05em;
  margin-left: 4px;
}
.role-badge.admin-role {
  background: #f3e7ce;
  color: var(--amber);
}
