/* Mạng xã hội phần 2 — trang cá nhân, diễn đàn, tin nhắn.
   Direction: "Học viện hoàng gia" — the app's light paper stays, but the
   halls of honour are black lacquer with gold leaf and a vermilion seal,
   set in a serif display face. Reuses social.css for comments/reactions.
   Palette lives on .nw-page so nothing leaks into other pages. */

.nw-page {
  --nw-lacquer: #10162a;
  --nw-lacquer-2: #1a2142;
  --nw-gold: #d9b262;
  --nw-gold-hi: #f4e0a6;
  --nw-gold-deep: #8a5f16;
  --nw-seal: #a51d2d;
  --nw-ivory: #fdfaf2;
  --nw-hair: color-mix(in srgb, var(--nw-gold) 38%, transparent);
  --nw-serif: "Playfair Display", "Noto Serif", Georgia, "Times New Roman", serif;
  max-width: 1180px;
  margin: 0 auto;
  padding: var(--sp-4) var(--sp-4) var(--sp-12);
}

/* ---------- Type ---------- */
.nw-eyebrow {
  margin: 0 0 var(--sp-2);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold-600);
}
.nw-eyebrow--gold { color: var(--nw-gold); }
.nw-display {
  margin: 0;
  font-family: var(--nw-serif);
  font-weight: 800;
  font-size: clamp(1.9rem, 1.3rem + 2.4vw, 2.9rem);
  line-height: 1.08;
  letter-spacing: -0.01em;
}
.nw-display--sm { font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2.1rem); color: var(--text-color); }
.nw-lede {
  margin: var(--sp-3) 0 0;
  max-width: 62ch;
  color: var(--text-muted);
  line-height: 1.6;
}
.nw-lede--tight { margin: 0 0 var(--sp-4); }
.nw-section-h {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin: var(--sp-6) 0 var(--sp-3);
  font-family: var(--nw-serif);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-color);
}
.nw-section-h::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--nw-hair), transparent);
}
.nw-count {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--gold-600);
  background: color-mix(in srgb, var(--nw-gold) 16%, #fff);
  padding: 0.05rem 0.5rem;
  border-radius: var(--radius-pill);
}
.nw-empty { color: var(--text-muted); padding: var(--sp-4) 0; }
.nw-time { color: var(--text-muted); font-size: 0.78rem; }
.nw-back {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-bottom: var(--sp-3);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
}
.nw-back:hover { color: var(--accent-color); }

/* ---------- Buttons & inputs ---------- */
.nw-btn-gold {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: linear-gradient(180deg, #e7c677, #c79a3e 55%, #b0852d);
  color: #2a1d05;
  border: 1px solid #9c7424;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), 0 2px 6px rgba(138, 95, 22, 0.25);
  font-weight: 700;
}
.nw-btn-gold:hover { filter: brightness(1.06); transform: translateY(-1px); }
.nw-btn-gold:active { transform: translateY(0); filter: brightness(0.97); }
.nw-btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: transparent;
  color: inherit;
  border: 1px solid currentColor;
  box-shadow: none;
}
.nw-input {
  width: 100%;
  font: inherit;
  color: var(--text-color);
  background: #fff;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.8rem;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.nw-input:focus {
  outline: none;
  border-color: var(--nw-gold);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--nw-gold) 25%, transparent);
}
.nw-input--title { font-family: var(--nw-serif); font-size: 1.1rem; font-weight: 700; }
.nw-select { font: inherit; padding: 0.4rem 0.6rem; border: 1px solid var(--glass-border); border-radius: var(--radius-sm); background: #fff; }
.nw-select-label { display: inline-flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); color: var(--text-muted); }
.nw-inline-form { display: inline; margin: 0; }
.nw-hint { margin: var(--sp-2) 0 0; font-size: 0.78rem; color: var(--text-muted); }

/* ---------- Hall of honour (profile hero) ---------- */
.nw-hall {
  --rank: var(--nw-gold);
  position: relative;
  overflow: hidden;
  isolation: isolate;
  border-radius: var(--radius-lg);
  color: #ece6d6;
  background:
    radial-gradient(ellipse 60% 90% at 12% 40%, color-mix(in srgb, var(--rank) 34%, transparent), transparent 70%),
    radial-gradient(ellipse 50% 70% at 100% 0%, rgba(217, 178, 98, 0.16), transparent 70%),
    linear-gradient(160deg, var(--nw-lacquer-2), var(--nw-lacquer) 60%);
  box-shadow: 0 24px 60px -24px rgba(16, 22, 42, 0.55), inset 0 0 0 1px rgba(217, 178, 98, 0.35);
}
.nw-hall-ornament {
  position: absolute;
  inset: 10px;
  z-index: -1;
  border: 1px solid var(--nw-hair);
  border-radius: calc(var(--radius-lg) - 6px);
  background-image:
    repeating-linear-gradient(45deg, rgba(217, 178, 98, 0.05) 0 1px, transparent 1px 22px),
    repeating-linear-gradient(-45deg, rgba(217, 178, 98, 0.05) 0 1px, transparent 1px 22px);
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, #000 55%, #000 100%);
  mask-image: linear-gradient(90deg, transparent 0%, #000 55%, #000 100%);
}
.nw-hall-inner {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--sp-8);
  padding: clamp(1.5rem, 1rem + 2vw, 2.75rem);
}
.nw-hall-portrait { display: grid; justify-items: center; gap: var(--sp-3); }
.nw-hall-frame {
  padding: 6px;
  border-radius: 50%;
  background: conic-gradient(from 210deg, var(--nw-gold-hi), var(--nw-gold-deep), var(--nw-gold), var(--nw-gold-hi), var(--nw-gold-deep), var(--nw-gold-hi));
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4), 0 10px 40px -8px color-mix(in srgb, var(--rank) 70%, transparent);
}
.nw-hall-frame .mascot-avatar { box-shadow: 0 0 0 3px var(--nw-lacquer); background: radial-gradient(circle at 50% 38%, #fff, #e7ebf6 75%); }
.nw-hall-frame .mascot-avatar--teacher { font-size: 2.4rem !important; }
.nw-hall-mascot-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: var(--nw-gold-hi);
  text-decoration: none;
  opacity: 0.85;
}
.nw-hall-mascot-link:hover { opacity: 1; text-decoration: underline; }
.nw-hall-name {
  margin: 0;
  font-family: var(--nw-serif);
  font-weight: 800;
  font-size: clamp(2rem, 1.3rem + 2.8vw, 3.25rem);
  line-height: 1.05;
  background: linear-gradient(180deg, #fff6d8 0%, var(--nw-gold-hi) 35%, var(--nw-gold) 70%, #b98a36 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 2px 18px rgba(217, 178, 98, 0.18);
}
.nw-hall-class { margin: var(--sp-1) 0 0; color: #b9b3a3; letter-spacing: 0.04em; }
.nw-hall-bio {
  margin: var(--sp-4) 0 0;
  max-width: 56ch;
  padding-left: var(--sp-3);
  border-left: 2px solid var(--nw-gold);
  font-family: var(--nw-serif);
  font-style: italic;
  font-size: 1.05rem;
  color: #efe8d5;
}
.nw-hall-bio--empty { font-style: normal; font-family: var(--font-body); font-size: var(--fs-sm); color: #a7a190; }
.nw-hall-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-6); }
.nw-hall-actions .nw-btn-ghost { color: var(--nw-gold-hi); }

.nw-titles { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin: var(--sp-4) 0 0; padding: 0; list-style: none; }
.nw-title {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.7rem;
  border: 1px solid var(--nw-hair);
  border-radius: 3px;
  font-family: var(--nw-serif);
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  color: var(--nw-gold-hi);
  background: rgba(217, 178, 98, 0.08);
}
.nw-title--podium {
  color: #2a1d05;
  border-color: #9c7424;
  background: linear-gradient(180deg, #f3d98f, #cfa048);
}

/* The vermilion seal: class standing, stamped. */
.nw-seal {
  display: grid;
  justify-items: center;
  align-content: center;
  width: 128px;
  aspect-ratio: 1;
  transform: rotate(-4deg);
  color: #fff4e6;
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.16), transparent 45%),
    var(--nw-seal);
  border: 3px double rgba(255, 236, 214, 0.85);
  outline: 2px solid var(--nw-seal);
  outline-offset: 3px;
  border-radius: 8px;
  box-shadow: 0 12px 30px -10px rgba(165, 29, 45, 0.7);
}
.nw-seal-label { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.3em; text-transform: uppercase; opacity: 0.85; }
.nw-seal-pos { font-family: var(--nw-serif); font-weight: 800; font-size: 3.1rem; line-height: 1; }
.nw-seal-of { font-size: 0.75rem; opacity: 0.85; }

/* ---------- Plaques (season record) ---------- */
.nw-plaques {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: var(--sp-3);
  margin-top: calc(-1 * var(--sp-6));
  padding: 0 var(--sp-4);
  position: relative;
  z-index: 1;
}
.nw-plaque {
  grid-column: span 1;
  display: grid;
  align-content: start;
  gap: 0.2rem;
  padding: var(--sp-4);
  background: var(--nw-ivory);
  border: 1px solid #efe4c8;
  border-top: 3px solid var(--nw-gold);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
}
.nw-plaque--hero { grid-column: span 2; background: linear-gradient(180deg, #fffaf0, var(--nw-ivory)); }
.nw-plaque-k { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--gold-600); }
.nw-plaque-v { font-family: var(--nw-serif); font-weight: 800; font-size: 2rem; line-height: 1.1; color: var(--text-color); font-variant-numeric: lining-nums tabular-nums; }
.nw-plaque--hero .nw-plaque-v { font-size: 2.6rem; }
.nw-plaque-v--time { font-size: 1.35rem; }
.nw-plaque-s { font-size: 0.78rem; color: var(--text-muted); }
.nw-meter { display: block; height: 6px; margin-top: var(--sp-2); border-radius: 99px; background: #efe6cf; overflow: hidden; }
.nw-meter > span { display: block; height: 100%; background: linear-gradient(90deg, var(--nw-gold-deep), var(--nw-gold), var(--nw-gold-hi)); border-radius: inherit; }

/* ---------- Layout ---------- */
.nw-layout, .nw-profile-cols {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: var(--sp-6);
  align-items: start;
}
.nw-profile-cols { margin-top: var(--sp-4); }
.nw-aside { display: grid; gap: var(--sp-4); position: sticky; top: var(--sp-4); }

/* ---------- Community banner, tabs, composer ---------- */
.nw-hall-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-6);
  padding: clamp(1.25rem, 1rem + 1.5vw, 2.25rem);
  border-radius: var(--radius-lg);
  color: #ece6d6;
  background:
    radial-gradient(ellipse 45% 100% at 100% 50%, rgba(217, 178, 98, 0.18), transparent 70%),
    linear-gradient(160deg, var(--nw-lacquer-2), var(--nw-lacquer));
  box-shadow: inset 0 0 0 1px rgba(217, 178, 98, 0.3), var(--shadow-md);
}
.nw-hall-banner .nw-display {
  background: linear-gradient(180deg, #fff6d8, var(--nw-gold) 80%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.nw-hall-banner .nw-eyebrow { color: var(--nw-gold); }
.nw-hall-banner .nw-lede { color: #c9c2b0; }
.nw-hall-banner-me {
  display: grid;
  justify-items: center;
  gap: 0.2rem;
  flex-shrink: 0;
  text-decoration: none;
  color: inherit;
}
.nw-hall-banner-me .mascot-avatar { box-shadow: 0 0 0 3px var(--nw-lacquer), 0 0 0 5px var(--nw-gold); }
.nw-hall-banner-me-name { font-weight: 700; color: #fff; margin-top: var(--sp-1); }
.nw-hall-banner-me-pts { font-family: var(--nw-serif); color: var(--nw-gold-hi); font-weight: 700; }

.nw-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
  margin: var(--sp-6) 0 var(--sp-4);
  border-bottom: 1px solid var(--glass-border);
}
.nw-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 0.9rem;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-weight: 600;
  text-decoration: none;
}
.nw-tab:hover { color: var(--text-color); }
.nw-tab[aria-current="page"] { color: var(--gold-600); border-bottom-color: var(--nw-gold); }

.nw-composer {
  padding: var(--sp-4);
  background: #fff;
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
  display: grid;
  gap: var(--sp-3);
}
.nw-composer-head { display: flex; align-items: center; gap: var(--sp-3); }
.nw-composer-foot { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); justify-content: space-between; }
.nw-composer-foot .cmt-counter { margin-left: auto; }

.nw-topic-filter { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin: var(--sp-4) 0; }
.nw-chip {
  padding: 0.3rem 0.8rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--glass-border);
  background: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
}
.nw-chip:hover { border-color: var(--nw-gold); color: var(--text-color); }
.nw-chip[aria-current="true"] { background: var(--nw-lacquer); border-color: var(--nw-lacquer); color: var(--nw-gold-hi); }

/* ---------- Posts ---------- */
.nw-feed { display: grid; gap: var(--sp-4); }
.nw-post {
  position: relative;
  padding: var(--sp-4) var(--sp-4) var(--sp-3);
  background: #fff;
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--dur-med) var(--ease-out), transform var(--dur-med) var(--ease-out);
}
.nw-post:hover { box-shadow: var(--shadow-md); }
.nw-post--pinned { border-color: #e8d6a6; background: linear-gradient(180deg, #fffcf3, #fff 40%); }
.nw-post--pinned::before {
  content: "";
  position: absolute;
  left: -1px; top: 14px; bottom: 14px;
  width: 3px;
  border-radius: 3px;
  background: linear-gradient(var(--nw-gold-hi), var(--nw-gold-deep));
}
.nw-post--muted { opacity: 0.7; border-style: dashed; }
.nw-post-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--sp-3); }
.nw-post-flags { display: flex; flex-wrap: wrap; gap: var(--sp-1); justify-content: flex-end; }
.nw-post-title { margin: var(--sp-3) 0 var(--sp-2); font-family: var(--nw-serif); font-size: 1.3rem; font-weight: 700; line-height: 1.25; }
.nw-post-title a { color: var(--text-color); text-decoration: none; }
.nw-post-title a:hover { color: var(--gold-600); }
.nw-post-body { line-height: 1.65; color: #2a3346; overflow-wrap: anywhere; }
.nw-post-body--clamp { display: -webkit-box; -webkit-line-clamp: 5; line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.nw-post-foot { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); margin-top: var(--sp-3); padding-top: var(--sp-3); border-top: 1px solid var(--border-soft); }
.nw-post-comments { margin-left: auto; display: inline-flex; align-items: center; gap: 0.3rem; font-size: var(--fs-sm); color: var(--text-muted); text-decoration: none; }
.nw-post-comments:hover { color: var(--accent-color); }
.nw-post-tools { display: flex; gap: var(--sp-3); justify-content: flex-end; margin: var(--sp-2) 0 0; }

.nw-topic, .nw-flag {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.1rem 0.55rem;
  border-radius: var(--radius-pill);
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
  --t: #64748b;
  color: color-mix(in srgb, var(--t) 85%, #000);
  background: color-mix(in srgb, var(--t) 11%, #fff);
  border: 1px solid color-mix(in srgb, var(--t) 28%, #fff);
}
.nw-topic--algebra { --t: #2749c9; }
.nw-topic--geometry { --t: #047857; }
.nw-topic--arithmetic { --t: #0369a1; }
.nw-topic--applied { --t: #b45309; }
.nw-topic--method { --t: #6d28d9; }
.nw-topic--question { --t: #be123c; }
.nw-topic--share { --t: #475569; }
.nw-flag--pin { --t: #8a5f16; }

/* Author line — name + rank + points: the "số má". */
.nw-author { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.nw-author-ava { flex: none; }
.nw-author-meta { display: grid; gap: 0.15rem; min-width: 0; }
.nw-author-name { font-weight: 700; color: var(--text-color); text-decoration: none; }
.nw-author-name:hover { color: var(--gold-600); }
.nw-author-standing { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
.nw-points { font-family: var(--nw-serif); font-weight: 700; font-size: 0.8rem; color: var(--gold-600); }
.cmt-name { color: var(--text-color); text-decoration: none; font-weight: 700; }
.cmt-name:hover { color: var(--gold-600); }

.nw-comments { margin-top: var(--sp-4); }

/* ---------- Honour roll (aside) ---------- */
.nw-honour {
  padding: var(--sp-4);
  background: var(--nw-ivory);
  border: 1px solid #efe4c8;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
}
.nw-honour-h {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0 var(--sp-3);
  font-family: var(--nw-serif);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--gold-600);
}
.nw-honour-list { margin: 0; padding: 0; list-style: none; display: grid; gap: var(--sp-2); }
.nw-honour-row { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; align-items: center; gap: var(--sp-2); }
.nw-honour-pos {
  display: grid; place-items: center;
  width: 24px; height: 24px;
  border-radius: 50%;
  font-family: var(--nw-serif); font-weight: 800; font-size: 0.8rem;
  color: var(--text-muted);
  background: #fff;
  border: 1px solid var(--glass-border);
}
.nw-honour-row--1 .nw-honour-pos { background: linear-gradient(180deg, #f6dc8f, #c9983b); border-color: #a77b25; color: #2a1d05; }
.nw-honour-row--2 .nw-honour-pos { background: linear-gradient(180deg, #eef1f5, #b9c1cc); border-color: #98a2b0; color: #1e2633; }
.nw-honour-row--3 .nw-honour-pos { background: linear-gradient(180deg, #f1c9a3, #b87a44); border-color: #9a6233; color: #2b1606; }
.nw-honour-who { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; color: var(--text-color); text-decoration: none; font-weight: 600; font-size: 0.9rem; }
.nw-honour-who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nw-honour-who:hover span { color: var(--gold-600); }
.nw-honour-val { font-family: var(--nw-serif); font-weight: 800; color: var(--gold-600); font-variant-numeric: tabular-nums; }
.nw-honour-val--time { font-family: var(--font-body); font-weight: 700; font-size: 0.78rem; }
.nw-honour-note, .nw-honour-empty { margin: var(--sp-2) 0 0; font-size: 0.78rem; color: var(--text-muted); }
.nw-honour-list--titles li { display: grid; gap: 0.1rem; padding-bottom: var(--sp-2); border-bottom: 1px dashed #eadfbf; }
.nw-honour-list--titles li:last-child { border-bottom: 0; }
.nw-honour-list--titles strong { font-family: var(--nw-serif); color: var(--text-color); }
.nw-honour-list--titles span { font-size: 0.78rem; color: var(--text-muted); }

.nw-bio-form .nw-section-h { margin-top: var(--sp-4); }
.nw-bio-row { display: flex; gap: var(--sp-2); }
.nw-bio-row .nw-btn-ghost { color: var(--gold-600); }

/* ---------- Direct messages ---------- */
.nw-dm-head { margin-bottom: var(--sp-4); }
.nw-oversight {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  margin: var(--sp-3) 0 0;
  padding: 0.55rem 0.8rem;
  max-width: 72ch;
  font-size: 0.82rem;
  color: #6b4a0e;
  background: #fdf5e1;
  border: 1px solid #f0dcaa;
  border-radius: var(--radius-sm);
}
.nw-oversight svg { flex: none; margin-top: 2px; }
.nw-oversight--bar { margin: 0; max-width: none; border-radius: 0; border-width: 0 0 1px; }
.nw-dm-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4); align-items: start; }
.nw-dm-panel {
  padding: var(--sp-4);
  background: #fff;
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.nw-dm-panel .nw-section-h { margin-top: 0; }
.nw-inbox-list, .nw-people, .nw-audit { margin: 0; padding: 0; list-style: none; display: grid; gap: 2px; }
.nw-inbox-row, .nw-person {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 0.55rem 0.6rem;
  border-radius: var(--radius-sm);
  color: var(--text-color);
  text-decoration: none;
  min-width: 0;
}
.nw-inbox-row:hover, .nw-person:hover { background: var(--ink-900); }
.nw-inbox-row[aria-current="page"] { background: var(--primary-50); box-shadow: inset 3px 0 0 var(--accent-color); }
.nw-inbox-main { display: grid; min-width: 0; flex: 1; }
.nw-inbox-name { font-weight: 600; }
.nw-inbox-row.is-unread .nw-inbox-name, .nw-inbox-row.is-unread .nw-inbox-preview { font-weight: 800; color: var(--text-color); }
.nw-inbox-preview { font-size: 0.8rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nw-inbox-side { display: grid; justify-items: end; gap: 0.2rem; font-size: 0.72rem; color: var(--text-muted); flex: none; }
.nw-person-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.nw-people { max-height: 60vh; overflow-y: auto; }
.nw-search { display: flex; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-3); color: var(--text-muted); }

/* ---------- Bạn học (class directory) ---------- */
.nw-mates-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-4); }
.nw-mates .nw-search { max-width: 360px; }
.nw-mates-grid { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--sp-3); }
.nw-mate {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--nw-ivory);
  border: 1px solid var(--glass-border);
  border-left: 4px solid var(--rank, var(--nw-gold));
  border-radius: var(--radius-sm);
  transition: transform var(--dur-fast), box-shadow var(--dur-fast);
}
.nw-mate:hover, .nw-mate:focus-within { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(16, 22, 42, 0.12); }
.nw-mate--me { background: color-mix(in srgb, var(--nw-gold) 14%, #fff); border-color: var(--nw-hair); }
.nw-mate-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3); color: var(--text-color); text-decoration: none; }
.nw-mate-main:focus-visible { outline: 2px solid var(--accent-color); outline-offset: -2px; border-radius: inherit; }
.nw-mate-pos { width: 1.6rem; text-align: center; font-family: var(--nw-serif); font-weight: 800; color: var(--gold-600); font-variant-numeric: tabular-nums; }
.nw-mate-id { display: grid; gap: 0.2rem; min-width: 0; }
.nw-mate-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nw-mate-main:hover .nw-mate-name { color: var(--gold-600); }
.nw-mate-me { font-size: 0.7rem; font-weight: 700; color: #2a1d05; background: var(--nw-gold); padding: 0.05rem 0.45rem; border-radius: var(--radius-pill); vertical-align: middle; }
.nw-mate-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.1rem 0.35rem; font-size: 0.78rem; color: var(--text-muted); }
.nw-mate-dm { display: grid; place-items: center; width: 40px; height: 40px; margin-right: var(--sp-2); border-radius: 50%; color: var(--text-muted); }
.nw-mate-dm:hover, .nw-mate-dm:focus-visible { color: var(--gold-600); background: color-mix(in srgb, var(--nw-gold) 16%, #fff); }

.nw-chat-grid { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: var(--sp-4); align-items: start; }
.nw-chat-side { max-height: calc(100vh - 7rem); overflow-y: auto; }
.nw-chat {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: calc(100vh - 7rem);
  min-width: 0;
  background: #fff;
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.nw-chat--readonly { height: auto; }
.nw-chat-head { padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border-soft); background: linear-gradient(180deg, #fff, var(--ink-900)); }
.nw-chat-who { display: flex; align-items: center; gap: var(--sp-3); color: var(--text-color); text-decoration: none; }
.nw-chat-who > span { display: grid; gap: 0.15rem; justify-items: start; }
.nw-chat-name { font-family: var(--nw-serif); font-weight: 700; font-size: 1.15rem; }
.nw-chat-log {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  background: var(--ink-950);
}
.nw-chat-log--tall { max-height: none; }
.nw-chat-empty { margin: auto; color: var(--text-muted); text-align: center; }
/* Right padding keeps Send clear of the site-wide floating buttons
   (AI helper + online counter) fixed at the bottom-right corner. */
.nw-chat-form { display: flex; gap: var(--sp-2); align-items: flex-end; padding: var(--sp-3) calc(var(--sp-3) + 76px) var(--sp-3) var(--sp-3); border-top: 1px solid var(--border-soft); }
.nw-chat-form textarea { flex: 1; min-width: 0; resize: none; max-height: 8rem; }
.nw-chat-form .btn { flex: none; width: auto; padding-inline: 0.9rem; }
.nw-chat .cmt-error { margin: 0 var(--sp-3) var(--sp-3); }

.nw-msg { display: flex; align-items: flex-end; gap: var(--sp-2); max-width: 78%; }
.nw-msg--mine { align-self: flex-end; flex-direction: row-reverse; }
.nw-msg-ava { flex: none; }
.nw-msg-bubble {
  padding: 0.5rem 0.75rem 0.35rem;
  border-radius: 14px 14px 14px 4px;
  background: #fff;
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.nw-msg--mine .nw-msg-bubble { border-radius: 14px 14px 4px 14px; background: var(--primary-600); border-color: var(--primary-600); color: #fff; }
.nw-msg-body { line-height: 1.5; overflow-wrap: anywhere; }
.nw-msg-sender { display: block; font-size: 0.72rem; font-weight: 700; color: var(--gold-600); margin-bottom: 0.1rem; }
.nw-msg-note { font-size: 0.75rem; font-style: italic; color: var(--text-muted); }
.nw-msg--mine .nw-msg-note { color: rgba(255, 255, 255, 0.8); }
.nw-msg-note--report { color: var(--danger-color); font-style: normal; font-weight: 700; }
.nw-msg--recalled .nw-msg-bubble { background: transparent; border-style: dashed; box-shadow: none; }
.nw-msg--mine.nw-msg--recalled .nw-msg-bubble { color: var(--text-muted); border-color: var(--glass-border); }
.nw-msg--mine.nw-msg--recalled .nw-msg-note { color: var(--text-muted); }
.nw-msg--reported .nw-msg-bubble { box-shadow: 0 0 0 2px color-mix(in srgb, var(--danger-color) 35%, transparent); }
.nw-msg-meta { display: flex; align-items: center; gap: var(--sp-2); justify-content: flex-end; margin-top: 0.15rem; font-size: 0.68rem; opacity: 0.75; }
.nw-msg-act {
  padding: 0; border: 0; background: none;
  font: inherit; color: inherit; text-decoration: underline; cursor: pointer;
  opacity: 0; transition: opacity var(--dur-fast);
}
.nw-msg:hover .nw-msg-act, .nw-msg-act:focus-visible { opacity: 1; }
@media (hover: none) { .nw-msg-act { opacity: 1; } }

/* ---------- Teacher tables ---------- */
.nw-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.nw-table th { text-align: left; font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); padding: 0.5rem; border-bottom: 1px solid var(--glass-border); }
.nw-table td { padding: 0.6rem 0.5rem; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.nw-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.nw-table tr.is-flagged td { background: #fff4f5; }
.nw-pair { display: inline-flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; font-weight: 600; }
.nw-alert-inline { color: var(--danger-color); }
.nw-audit li { display: grid; gap: 0.15rem; padding: 0.55rem 0; border-bottom: 1px solid var(--border-soft); }
.nw-audit a { color: var(--text-color); text-decoration: none; }
.nw-audit a:hover { color: var(--accent-color); }
.nw-audit-meta { font-size: 0.78rem; color: var(--text-muted); display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .nw-plaques { grid-template-columns: repeat(3, 1fr); }
  .nw-plaque--hero { grid-column: span 3; }
  .nw-layout, .nw-profile-cols { grid-template-columns: minmax(0, 1fr); }
  .nw-aside { position: static; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
}
@media (max-width: 760px) {
  .nw-hall-inner { grid-template-columns: 1fr; justify-items: center; text-align: center; gap: var(--sp-4); }
  .nw-hall-bio { border-left: 0; padding-left: 0; }
  .nw-titles, .nw-hall-actions { justify-content: center; }
  .nw-seal { width: 104px; }
  .nw-seal-pos { font-size: 2.5rem; }
  .nw-plaques { grid-template-columns: repeat(2, 1fr); margin-top: var(--sp-4); padding: 0; }
  .nw-plaque--hero { grid-column: span 2; }
  .nw-hall-banner { flex-direction: column; align-items: flex-start; }
  .nw-hall-banner-me { flex-direction: row; display: flex; align-items: center; gap: var(--sp-3); }
  .nw-dm-grid, .nw-chat-grid { grid-template-columns: minmax(0, 1fr); }
  .nw-chat-side { display: none; }
  .nw-chat { height: calc(100dvh - 9rem); }
  .nw-msg { max-width: 90%; }
  .nw-table thead { display: none; }
  .nw-table tr { display: grid; padding: var(--sp-2) 0; border-bottom: 1px solid var(--border-soft); }
  .nw-table td { border: 0; padding: 0.2rem 0; text-align: left !important; }
  .nw-table td[data-label]::before { content: attr(data-label) ": "; font-weight: 700; color: var(--text-muted); font-size: 0.75rem; }
  .nw-post-head { flex-direction: column; }
  .nw-post-flags { justify-content: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
  .nw-post, .nw-btn-gold { transition: none; }
}
