/* MS1001 chrome v8 — IP-style unified sticky header (two rows, one block) */
:root {
  /* Flush with body: tight side gutters so brand can pin left */
  --ms1001-chrome-max: 100%;
  --ms1001-chrome-gutter: clamp(12px, 1.5vw, 24px);
  --ms1001-chrome-pad-estimate: 132px;
  --ms1001-content-gap: 28px;
  --ms1001-page-bg-warm: #ffffff;
  --ms1001-page-bg-soft: #f7f9fc;
  --ms1001-page-bg-cool: #f5f7fb;
  /* Light chrome: solid white (portal / CUHK), not warm cream */
  --ms1001-chrome-bg: #ffffff;
  --ms1001-chrome-border: rgba(0, 32, 91, 0.06);
  /* CUHK-SZ header: soft downward elevation under the bar */
  --ms1001-chrome-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

html[data-ms1001-chrome="on"]:not([data-ms1001-chrome-layout="sidebar"]) body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: #ffffff;
}

/* Full-page dark wash: portal / brand / edu only (data-ms1001-chrome-only-dark != 1) */
html[data-ms1001-chrome="on"][data-surface-theme="dark"]:not([data-ms1001-chrome-only-dark="1"]):not([data-ms1001-chrome-layout="sidebar"]) body::before,
html[data-ms1001-chrome="on"][data-theme="dark"]:not([data-ms1001-chrome-only-dark="1"]):not([data-ms1001-chrome-layout="sidebar"]) body::before {
  background:
    radial-gradient(ellipse 70% 50% at 12% 0%, rgba(240, 193, 75, 0.1), transparent 52%),
    linear-gradient(180deg, #2a1428 0%, #3a2236 42%, #2f1a2d 100%);
}

/* Chrome-only dark: keep page body white; header uses surface-theme rules below */
html[data-ms1001-chrome="on"][data-ms1001-chrome-only-dark="1"] body::before,
html[data-ms1001-chrome="on"][data-ms1001-chrome-only-dark="1"][data-surface-theme="dark"] body::before,
html[data-ms1001-chrome="on"][data-ms1001-chrome-only-dark="1"][data-theme="dark"] body::before {
  background: #ffffff !important;
}

html.ms1001-chrome-pending body:not(.ms1001-chrome-sidebar-active) {
  padding-top: calc(var(--ms1001-chrome-pad-estimate) + var(--ms1001-content-gap));
}

html.ms1001-chrome-mounted body:not(.ms1001-chrome-sidebar-active),
body.ms1001-chrome-active:not(.ms1001-chrome-sidebar-active) {
  padding-top: calc(var(--ms1001-chrome-pad, var(--ms1001-chrome-pad-estimate)) + var(--ms1001-content-gap));
}

body.ms1001-chrome-sidebar-active {
  padding-top: 0 !important;
}

html[data-ms1001-chrome-layout="sidebar"].ms1001-chrome-pending body {
  padding-top: 0 !important;
}

html[data-ms1001-chrome="on"] header.topbar:not(.ms1001-chrome-unified),
html[data-ms1001-chrome="on"] #siteHeader:not(.ms1001-chrome-unified):not(:empty),
html[data-ms1001-chrome="on"] .site-header:not(.ms1001-chrome-unified):not(#ms1001-chrome .site-header),
html[data-ms1001-chrome="on"] .puzzle-native-header,
html[data-ms1001-chrome="on"] #root > div.min-h-screen > div.sticky.top-0 {
  display: none !important;
}

#ms1001-chrome {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 2147482000;
  font-family: "Geist", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

#ms1001-chrome.is-ready {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

#ms1001-chrome.is-sidebar-mode {
  position: relative;
  inset: auto;
  z-index: 12;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  flex: 0 0 auto;
}

#ms1001-chrome.is-sidebar-waiting {
  display: none !important;
}

/* Sidebar stack — four items vertical at top-left */
.ms1001-chrome-sidebar-stack {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  padding: 0 0 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

#ms1001-chrome.is-sidebar-mode .ms1001-portal-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #f8fafc;
  text-decoration: none;
}

#ms1001-chrome.is-sidebar-mode .ms1001-portal-link img {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  flex-shrink: 0;
}

#ms1001-chrome.is-sidebar-mode .ms1001-portal-link strong {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
}

#ms1001-chrome.is-sidebar-mode .ms1001-site-title-link {
  display: block;
  text-decoration: none;
  color: #f8fafc;
}

#ms1001-chrome.is-sidebar-mode .ms1001-site-title {
  display: block;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.25;
  color: #f8fafc;
}

#ms1001-chrome.is-sidebar-mode .ms1001-stack-auth,
#ms1001-chrome.is-sidebar-mode .ms1001-stack-lang {
  width: 100%;
}

#ms1001-chrome.is-sidebar-mode .ms1001-btn-stack {
  width: 100%;
  justify-content: center;
  box-sizing: border-box;
}

#ms1001-chrome.is-sidebar-mode .ms1001-stack-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
}

#ms1001-chrome.is-sidebar-mode .ms1001-stack-user-name {
  font-size: 13px;
  font-weight: 600;
  color: #f8fafc;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#ms1001-chrome.is-sidebar-mode .ms1001-btn-stack-logout {
  flex-shrink: 0;
  border-color: rgba(255, 255, 255, 0.2);
  color: #e2e8f0;
  background: transparent;
}

#ms1001-chrome.is-sidebar-mode .ms1001-stack-auth-loading {
  display: flex;
  justify-content: center;
  padding: 8px 0;
}

#ms1001-chrome.is-sidebar-mode .ms1001-lang-toggle {
  width: 100%;
  display: flex;
}

#ms1001-chrome.is-sidebar-mode .ms1001-lang-toggle button {
  flex: 1;
  border-color: rgba(255, 255, 255, 0.18);
  color: #cbd5e1;
  background: rgba(255, 255, 255, 0.04);
}

#ms1001-chrome.is-sidebar-mode .ms1001-lang-toggle button.is-active {
  color: #0f172a;
  background: #f8fafc;
  border-color: #f8fafc;
}

#ms1001-chrome.is-sidebar-mode .ms1001-btn-login {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.08);
  color: #f8fafc;
}

.ms1001-chrome-unified {
  position: sticky;
  top: 0;
  border-bottom: 0;
  background: #fff;
  background: var(--ms1001-chrome-bg);
  box-shadow: var(--ms1001-chrome-shadow);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  z-index: 1100;
}

.ms1001-chrome-container {
  width: min(var(--ms1001-chrome-max), calc(100% - var(--ms1001-chrome-gutter) * 2));
  margin: 0 auto;
  padding: 16px var(--ms1001-chrome-gutter);
  box-sizing: border-box;
}

/* CUHK two-row: utility links on top, brand + main tools below */
.ms1001-chrome-unified.is-cuhk-two-row .ms1001-chrome-container {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding-top: 0;
  padding-bottom: 0;
}
.ms1001-chrome-unified.is-cuhk-two-row .ms1001-chrome-utility {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: nowrap;
  gap: 16px 28px;
  padding: 14px 0 12px;
  border-bottom: 0 !important;
  box-shadow: none;
  width: 100%;
  margin: 0;
}
.ms1001-chrome-unified.is-cuhk-two-row .ms1001-chrome-brand-group {
  flex: 0 1 auto;
  min-width: 0;
  margin: 0;
}
.ms1001-chrome-unified.is-cuhk-two-row .ms1001-chrome-utility-end {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 12px 20px;
  margin-left: auto;
  min-width: 0;
}
.ms1001-chrome-unified.is-cuhk-two-row .ms1001-utility-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0 18px;
  min-width: 0;
}
.ms1001-chrome-unified.is-cuhk-two-row .ms1001-utility-nav .ms1001-nav-link {
  border: 0;
  background: transparent;
  box-shadow: none;
  border-radius: 0;
  padding: 9px 0;
  font-size: 17px;
  font-weight: 700;
  color: #6b7280;
  line-height: 1.25;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.ms1001-chrome-unified.is-cuhk-two-row .ms1001-utility-nav .ms1001-nav-link:hover,
.ms1001-chrome-unified.is-cuhk-two-row .ms1001-utility-nav .ms1001-nav-link.is-primary-nav,
.ms1001-chrome-unified.is-cuhk-two-row .ms1001-utility-nav .ms1001-nav-link.is-active {
  color: #c9a227;
  font-weight: 700;
}
.ms1001-chrome-unified.is-cuhk-two-row .ms1001-portal-admin {
  display: none;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  max-width: none;
}
.ms1001-chrome-unified.is-cuhk-two-row .ms1001-portal-admin.is-visible {
  display: inline-flex;
}
.ms1001-chrome-unified.is-cuhk-two-row .ms1001-portal-admin .status-text:not(.dirty) {
  display: none;
}
.ms1001-chrome-unified.is-cuhk-two-row .ms1001-portal-admin .ms1001-admin-tool,
.ms1001-chrome-unified.is-cuhk-two-row .ms1001-portal-admin .ghost-btn {
  appearance: none;
  border: 1px solid rgba(0, 32, 91, 0.18);
  background: transparent;
  color: #334155;
  border-radius: 0;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.2;
  box-shadow: none;
}
.ms1001-chrome-unified.is-cuhk-two-row .ms1001-portal-admin .ms1001-admin-tool:hover,
.ms1001-chrome-unified.is-cuhk-two-row .ms1001-portal-admin .ghost-btn:hover {
  border-color: #00205b;
  color: #00205b;
}
.ms1001-chrome-unified.is-cuhk-two-row .ms1001-portal-admin .status-text {
  font-size: 11px;
  font-weight: 700;
  color: #64748b;
  white-space: nowrap;
  max-width: 9em;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ms1001-chrome-unified.is-cuhk-two-row .ms1001-portal-admin .status-text.dirty {
  color: #e11d48;
}
.ms1001-chrome-unified.is-cuhk-two-row .ms1001-portal-admin .ms1001-admin-save,
.ms1001-chrome-unified.is-cuhk-two-row .ms1001-portal-admin .primary-btn {
  appearance: none;
  border: 0;
  background: #c9a227;
  color: #00205b !important;
  border-radius: 0;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.2;
  box-shadow: none;
}
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-portal-admin .ms1001-admin-tool,
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-portal-admin .ghost-btn {
  border-color: rgba(255, 255, 255, 0.28);
  color: rgba(255, 255, 255, 0.88) !important;
  background: rgba(255, 255, 255, 0.08);
}
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-portal-admin .ms1001-admin-tool:hover,
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-portal-admin .ghost-btn:hover {
  border-color: #e2c878;
  color: #e2c878 !important;
}
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-portal-admin .status-text {
  color: rgba(255, 255, 255, 0.72);
}
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-portal-admin .status-text.dirty {
  color: #fb7185;
}
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-portal-admin .ms1001-admin-save,
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-portal-admin .primary-btn {
  background: #c9a227 !important;
  color: #00205b !important;
}
/* Hero brand: large, left-pinned page anchor */
.ms1001-chrome-unified.is-cuhk-two-row .ms1001-portal-link {
  gap: 14px;
}
.ms1001-chrome-unified.is-cuhk-two-row .ms1001-portal-link img {
  width: 56px;
  height: 56px;
  border-radius: 14px;
}
.ms1001-chrome-unified.is-cuhk-two-row .ms1001-portal-link strong {
  font-size: clamp(16px, 1.5vw, 18px) !important;
  font-weight: 800 !important;
  line-height: 1.2 !important;
  letter-spacing: 0 !important;
}
.ms1001-chrome-unified.is-cuhk-two-row .ms1001-site-title {
  font-size: clamp(20px, 2.1vw, 28px) !important;
  font-weight: 900 !important;
  line-height: 1.1 !important;
  letter-spacing: -0.02em !important;
}
.ms1001-chrome-unified.is-cuhk-two-row .ms1001-chrome-primary {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 12px 20px;
  padding: 8px 0 12px;
  min-width: 0;
  width: 100%;
  border-top: 0 !important;
  border-bottom: 0 !important;
}
.ms1001-chrome-unified.is-cuhk-two-row .ms1001-chrome-primary.is-portal-home {
  display: none !important;
}
/* One tools strip only — never stack search / cats into a 3rd header row */
.ms1001-chrome-unified.is-cuhk-two-row .ms1001-matrix-tools {
  display: flex;
  flex-direction: row !important;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 16px 22px;
  flex: 1 1 auto;
  min-width: 0;
  margin-left: 0;
  width: 100%;
}
.ms1001-chrome-unified.is-cuhk-two-row .ms1001-matrix-cats {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0 16px;
  flex: 1 1 auto;
  min-width: 0;
  order: 1;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.ms1001-chrome-unified.is-cuhk-two-row .ms1001-matrix-cats::-webkit-scrollbar {
  display: none;
}
.ms1001-chrome-unified.is-cuhk-two-row .ms1001-matrix-cats .filter {
  appearance: none;
  border: 0;
  background: transparent;
  box-shadow: none;
  border-radius: 0;
  padding: 6px 0;
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: #334155;
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.2;
}
.ms1001-chrome-unified.is-cuhk-two-row .ms1001-matrix-cats .filter:hover {
  color: #00205b;
}
.ms1001-chrome-unified.is-cuhk-two-row .ms1001-matrix-cats .filter.active {
  color: #00205b;
  box-shadow: inset 0 -2px 0 #00205b;
  background: transparent;
  border: 0;
}
.ms1001-chrome-unified.is-cuhk-two-row .ms1001-matrix-search-end {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 240px;
  min-width: 180px;
  max-width: 280px;
  margin-left: 0;
  order: 2;
  padding-left: 0;
  border-left: 0;
}
.ms1001-chrome-unified.is-cuhk-two-row .ms1001-matrix-search-end .search-box {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 0;
  color: #64748b;
  font-size: 14px;
}
.ms1001-chrome-unified.is-cuhk-two-row .ms1001-matrix-search-end .search-box input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font: inherit;
  color: #0f172a;
  padding: 4px 0;
}
.ms1001-chrome-unified.is-cuhk-two-row .ms1001-matrix-search-end .search-box input::placeholder {
  color: #94a3b8;
}
.ms1001-chrome-unified.is-cuhk-two-row .ms1001-matrix-search-end .result-count {
  display: none;
  font-size: 12px;
  color: #64748b;
  white-space: nowrap;
}
@media (min-width: 1280px) {
  .ms1001-chrome-unified.is-cuhk-two-row .ms1001-matrix-search-end .result-count {
    display: block;
  }
}

.ms1001-chrome-top {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 14px;
}

.ms1001-chrome-brand-group {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 0 1 auto;
}

.ms1001-chrome-inline-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  flex: 1 1 auto;
  min-width: 0;
  justify-content: flex-start;
}

.ms1001-chrome-inline-nav .ms1001-nav-link {
  font-size: 14px;
}

.ms1001-chrome-actions {
  flex: 0 0 auto;
  margin-left: auto;
}

.ms1001-portal-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: #0f172a;
  min-width: 0;
}

.ms1001-portal-link img {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.ms1001-portal-link strong {
  font-size: 15px !important;
  font-weight: 700 !important;
  line-height: 1.25 !important;
  letter-spacing: 0 !important;
  color: #00205b !important;
}

.ms1001-site-title {
  font-size: 18px !important;
  font-weight: 800 !important;
  line-height: 1.25 !important;
  letter-spacing: 0 !important;
  color: #00205b !important;
}

.ms1001-site-identity {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}

.ms1001-site-badge {
  width: auto;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
  color: #fff;
  background: #00205b;
  box-shadow: none;
  flex-shrink: 0;
}

.ms1001-site-titles {
  min-width: 0;
  max-width: min(42vw, 28rem);
  display: flex;
  flex-direction: row;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0.45rem;
  overflow: hidden;
}

.ms1001-site-title {
  display: inline-block;
  max-width: 100%;
  font-size: clamp(0.92rem, 1.35vw, 1.12rem);
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ms1001-site-subtitle {
  margin: 0;
  font-size: 12px;
  line-height: 1.2;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 0 1 auto;
  min-width: 0;
  font-weight: 500;
}

.ms1001-site-subtitle:empty {
  display: none;
}

.ms1001-chrome-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 0 auto;
  margin-left: auto;
}

.ms1001-auth-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.ms1001-auth-loading {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: #64748b;
}

.ms1001-auth-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #e2e8f0;
  border-top-color: #64748b;
  border-radius: 50%;
  animation: ms1001-spin 0.7s linear infinite;
}

@keyframes ms1001-spin {
  to { transform: rotate(360deg); }
}

.ms1001-btn {
  appearance: none;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #334155;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.ms1001-btn:hover {
  border-color: #fdba74;
  color: #ea580c;
}

.ms1001-btn-login svg {
  width: 16px;
  height: 16px;
}

.ms1001-btn-assoc {
  border-color: #fed7aa;
  background: #fff7ed;
  color: #9a3412;
  font-size: 12px;
  font-weight: 700;
  padding: 8px 12px;
}

.ms1001-btn-admin {
  border-color: #fcd34d;
  background: #fffbeb;
  color: #92400e;
  font-size: 12px;
  font-weight: 700;
  padding: 8px 12px;
}

.ms1001-admin-wrap {
  position: relative;
}

.ms1001-admin-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  min-width: 152px;
  padding: 4px 0;
  border-radius: 12px;
  border: 1px solid #fcd34d;
  background: #fff;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
  z-index: 10;
}

.ms1001-admin-wrap.is-open .ms1001-admin-menu {
  display: block;
}

.ms1001-admin-menu a {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 600;
  color: #78350f;
  text-decoration: none;
}

.ms1001-admin-menu a:hover {
  background: #fffbeb;
}

.ms1001-btn-user {
  max-width: 128px;
  font-size: 14px;
  color: #475569;
}

.ms1001-btn-user span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ms1001-btn-icon {
  padding: 8px;
  color: #64748b;
}

.ms1001-btn-icon:hover {
  color: #0f172a;
}

.ms1001-btn-upgrade {
  border: none;
  background: linear-gradient(90deg, #9333ea, #f97316);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(147, 51, 234, 0.25);
}

.ms1001-surface-toggle,
.ms1001-lang-toggle {
  display: inline-flex;
  padding: 4px;
  border-radius: 999px;
  border: 1px solid #e2e8f0;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.ms1001-surface-toggle button {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  background: transparent;
  color: #00205b;
  line-height: 1.25;
}

.ms1001-surface-toggle button.is-active {
  background: #00205b;
  color: #fff;
}

/* Surface dark: chrome shell (matrix boxes stay light via portal_app.css) */
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-chrome-unified {
  background: #00205b;
  border-bottom-color: rgba(255, 255, 255, 0.18);
  box-shadow: none;
}
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-portal-link,
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-portal-link strong,
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-site-title,
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-nav-link {
  color: #fff !important;
}
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-nav-link:hover,
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-nav-link.is-primary-nav {
  color: #e2c878;
}
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-site-badge {
  background: rgba(201, 162, 39, 0.2);
  color: #e2c878;
  border-color: rgba(201, 162, 39, 0.45);
}
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-surface-toggle,
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-lang-toggle {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.28);
}
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-surface-toggle button {
  color: #fff;
}
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-surface-toggle button.is-active {
  background: #c9a227;
  color: #00205b;
}
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-lang-toggle button {
  color: rgba(255, 255, 255, 0.85);
}
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-lang-toggle button.is-active {
  background: #fff;
  color: #00205b;
}
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-btn-login,
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-btn-account,
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-auth-slot,
html[data-surface-theme="dark"] #ms1001-chrome a.ms1001-cta[href*="account"] {
  background: #c9a227 !important;
  color: #00205b !important;
  border-color: #c9a227 !important;
  font-weight: 800;
}
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-btn-login *,
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-btn-account * {
  color: #00205b !important;
  fill: #00205b !important;
}
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-btn-login:hover,
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-btn-account:hover {
  background: #e2c878 !important;
  color: #00205b !important;
}
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-btn-admin {
  background: rgba(201, 162, 39, 0.22) !important;
  border-color: rgba(201, 162, 39, 0.65) !important;
  color: #f0d78a !important;
}
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-btn-admin:hover {
  background: #c9a227 !important;
  color: #00205b !important;
}
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-btn-icon {
  background: rgba(255, 255, 255, 0.1) !important;
  border-color: rgba(255, 255, 255, 0.3) !important;
  color: #fff !important;
}
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-btn-icon:hover {
  color: #e2c878 !important;
  border-color: #e2c878 !important;
}
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-btn-assoc {
  background: rgba(255, 255, 255, 0.1) !important;
  border-color: rgba(255, 255, 255, 0.3) !important;
  color: #fff !important;
}
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-admin-menu {
  background: #001a4a;
  border-color: rgba(255, 255, 255, 0.22);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
}
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-admin-menu a {
  color: #fff;
}
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-admin-menu a:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #e2c878;
}
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-auth-loading {
  color: rgba(255, 255, 255, 0.7);
}
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-burger {
  border-color: rgba(255, 255, 255, 0.35);
  color: #fff;
}
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-burger span {
  background: #fff;
}
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-mobile-drawer {
  background: #001a4a;
  border-color: rgba(255, 255, 255, 0.18);
}
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-mobile-drawer .ms1001-nav-link {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.12);
}
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-chrome-unified.is-cuhk-two-row .ms1001-chrome-utility {
  border-bottom: 0 !important;
  box-shadow: none;
}
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-chrome-unified.is-cuhk-two-row .ms1001-utility-nav .ms1001-nav-link {
  color: rgba(255, 255, 255, 0.7);
}
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-chrome-unified.is-cuhk-two-row .ms1001-utility-nav .ms1001-nav-link:hover,
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-chrome-unified.is-cuhk-two-row .ms1001-utility-nav .ms1001-nav-link.is-active,
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-chrome-unified.is-cuhk-two-row .ms1001-utility-nav .ms1001-nav-link.is-primary-nav {
  color: #e2c878;
}
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-chrome-unified.is-cuhk-two-row .ms1001-matrix-cats .filter {
  color: rgba(255, 255, 255, 0.9);
}
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-chrome-unified.is-cuhk-two-row .ms1001-matrix-cats .filter.active,
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-chrome-unified.is-cuhk-two-row .ms1001-matrix-cats .filter:hover {
  color: #e2c878;
  box-shadow: inset 0 -2px 0 #c9a227;
}
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-chrome-unified.is-cuhk-two-row .ms1001-matrix-search-end {
  border-left-color: rgba(255, 255, 255, 0.22);
}
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-chrome-unified.is-cuhk-two-row .ms1001-matrix-search-end .search-box,
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-chrome-unified.is-cuhk-two-row .ms1001-matrix-search-end .result-count {
  color: rgba(255, 255, 255, 0.7);
}
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-chrome-unified.is-cuhk-two-row .ms1001-matrix-search-end .search-box input {
  color: #fff;
}
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-chrome-unified.is-cuhk-two-row .ms1001-matrix-search-end .search-box input::placeholder {
  color: rgba(255, 255, 255, 0.45);
}

.ms1001-lang-toggle button {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  background: transparent;
  color: #1d4ed8;
  line-height: 1.25;
}

.ms1001-lang-toggle button.is-active {
  background: #0f172a;
  color: #fff;
}

.ms1001-chrome-nav-row {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
}

.ms1001-site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
}

.ms1001-nav-link {
  font-size: 16px;
  font-weight: 600;
  color: #00205b;
  text-decoration: none;
  white-space: nowrap;
}

.ms1001-nav-link:hover {
  color: #c9a227;
}

.ms1001-nav-link.is-methodology {
  color: #00205b;
  font-weight: 600;
}

.ms1001-nav-link.is-methodology:hover {
  color: #c9a227;
}

.ms1001-nav-link.is-primary-nav {
  color: #00205b;
  font-weight: 700;
}

.ms1001-nav-link.is-disabled {
  color: #94a3b8;
  cursor: default;
}

.ms1001-nav-badge {
  margin-left: 4px;
  padding: 2px 6px;
  border-radius: 6px;
  background: #f1f5f9;
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
}

.ms1001-chrome-ctas {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.ms1001-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  line-height: 1.2;
  white-space: nowrap;
}

.ms1001-cta-secondary {
  border: 1px solid #e6ebf2;
  background: #fff;
  color: #00205b;
}

.ms1001-cta-primary {
  border: none;
  background: #00205b;
  color: #fff;
  box-shadow: none;
}

.ms1001-btn-login,
.ms1001-btn-account {
  border-radius: 0;
  border: 0;
  background: #00205b !important;
  color: #fff !important;
  font-weight: 700;
}

.ms1001-btn-login:hover,
.ms1001-btn-account:hover {
  border-color: transparent;
  color: #fff !important;
  background: #0b3a7a !important;
}

/* Legacy sidebar overrides (unused in stack mode) */
#ms1001-chrome.is-sidebar-mode .ms1001-chrome-unified {
  border-radius: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(15, 23, 42, 0.96);
  backdrop-filter: none;
}

#ms1001-chrome.is-sidebar-mode .ms1001-site-subtitle {
  color: #94a3b8;
}

#ms1001-chrome.is-sidebar-mode .ms1001-chrome-nav-row {
  display: none;
}

#ms1001-chrome.is-sidebar-mode .ms1001-site-badge {
  width: 32px;
  height: 32px;
  font-size: 14px;
}

/* Mobile menu trigger / search — hidden on desktop */
.ms1001-menu-btn,
.ms1001-mobile-search-btn {
  display: none;
  appearance: none;
  border: 0;
  background: transparent;
  color: #00205b;
  width: 40px;
  height: 40px;
  padding: 0;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.ms1001-mobile-drawer {
  display: none;
}

body.ms1001-menu-lock {
  overflow: hidden;
}

/* Tablet/phone: CUHK pattern — one title bar + hamburger holds every entry */
@media (max-width: 1100px) {
  :root {
    --ms1001-chrome-gutter: 14px;
  }

  .ms1001-chrome-unified {
    border-bottom: 1px solid rgba(0, 32, 91, 0.12);
  }

  .ms1001-chrome-top {
    flex-wrap: nowrap;
    gap: 8px;
  }

  .ms1001-menu-btn,
  .ms1001-mobile-search-btn {
    display: inline-flex;
  }

  .ms1001-chrome-actions,
  .ms1001-chrome-inline-nav,
  .ms1001-chrome-nav-row {
    display: none !important;
  }

  .ms1001-chrome-unified.is-cuhk-two-row .ms1001-chrome-utility {
    display: flex !important;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    padding: 10px 0 8px;
  }

  .ms1001-chrome-unified.is-cuhk-two-row .ms1001-chrome-utility-end {
    display: none !important;
  }

  .ms1001-chrome-unified.is-cuhk-two-row .ms1001-chrome-brand-group {
    flex: 1 1 auto;
    min-width: 0;
  }

  .ms1001-chrome-unified.is-cuhk-two-row .ms1001-portal-link strong {
    font-size: clamp(14px, 3.6vw, 16px) !important;
  }

  .ms1001-chrome-unified.is-cuhk-two-row .ms1001-portal-link img {
    width: 40px;
    height: 40px;
  }

  .ms1001-chrome-unified.is-cuhk-two-row .ms1001-chrome-primary {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) 40px;
    align-items: center;
    column-gap: 6px;
    row-gap: 8px;
    padding: 8px 0 6px;
  }

  .ms1001-chrome-unified.is-cuhk-two-row .ms1001-menu-btn {
    order: -1;
  }

  .ms1001-chrome-unified.is-cuhk-two-row .ms1001-chrome-brand-group a {
    pointer-events: auto;
  }

  .ms1001-chrome-unified.is-cuhk-two-row .ms1001-matrix-tools {
    display: flex;
    grid-column: 1 / -1;
    grid-row: 2;
    flex: 1 1 100%;
    order: 5;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 0;
    border-top: 0;
    margin-top: 0;
  }

  .ms1001-chrome-unified.is-cuhk-two-row .ms1001-matrix-cats {
    order: 0;
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    gap: 0 14px;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
  }

  .ms1001-chrome-unified.is-cuhk-two-row .ms1001-matrix-cats .filter {
    font-size: 14px;
  }

  .ms1001-chrome-unified.is-cuhk-two-row .ms1001-matrix-search-end {
    order: 0;
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
    margin-left: 0;
    padding-left: 0;
    border-left: 0;
  }

  .ms1001-chrome-unified.is-cuhk-two-row .ms1001-matrix-search-end .result-count {
    display: block;
  }

  .ms1001-chrome-unified.is-cuhk-two-row .ms1001-mobile-search-btn {
    display: none;
  }

  .ms1001-site-subtitle {
    display: none;
  }

  .ms1001-chrome-brand-group {
    flex: 1 1 auto;
    justify-content: center;
    gap: 8px;
    min-width: 0;
  }

  /* Drawer hangs from the same title bar (CUHK-style), not a second nav strip */
  .ms1001-chrome-unified.is-menu-open {
    z-index: 12001;
  }

  .ms1001-portal-link strong,
  .ms1001-site-title {
    font-size: 15px !important;
  }

  .ms1001-site-identity {
    display: none;
  }

  .ms1001-mobile-drawer {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 12000;
    pointer-events: none;
    visibility: hidden;
  }

  .ms1001-mobile-drawer.is-open {
    pointer-events: auto;
    visibility: visible;
  }

  .ms1001-mobile-drawer-backdrop {
    appearance: none;
    border: 0;
    padding: 0;
    position: absolute;
    inset: 0;
    background: rgba(0, 20, 48, 0.45);
    opacity: 0;
    transition: opacity 0.2s ease;
  }

  .ms1001-mobile-drawer.is-open .ms1001-mobile-drawer-backdrop {
    opacity: 1;
  }

  .ms1001-mobile-drawer-panel {
    position: absolute;
    inset: 0;
    background: #00205b;
    color: #fff;
    display: flex;
    flex-direction: column;
    transform: translateY(-8px);
    opacity: 0;
    transition: transform 0.22s ease, opacity 0.22s ease;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  .ms1001-mobile-drawer.is-open .ms1001-mobile-drawer-panel {
    transform: translateY(0);
    opacity: 1;
  }

  .ms1001-mobile-drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 3px solid #c9a227;
    position: sticky;
    top: 0;
    background: #00205b;
    z-index: 1;
  }

  .ms1001-mobile-drawer-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    text-decoration: none;
    min-width: 0;
  }

  .ms1001-mobile-drawer-brand img {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
  }

  .ms1001-mobile-drawer-brand strong {
    font-size: 16px;
    font-weight: 800;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .ms1001-mobile-icon-btn {
    appearance: none;
    border: 0;
    background: transparent;
    color: #fff;
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
  }

  .ms1001-mobile-nav {
    display: flex;
    flex-direction: column;
    padding: 8px 0 20px;
  }

  .ms1001-mobile-nav .ms1001-mobile-nav-link,
  .ms1001-mobile-nav .ms1001-nav-link {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 16px 20px;
    margin: 0;
    border: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 0;
    background: transparent;
    color: #fff !important;
    font-size: 17px;
    font-weight: 600;
    text-decoration: none;
    box-sizing: border-box;
  }

  .ms1001-mobile-nav .ms1001-nav-link.is-active,
  .ms1001-mobile-nav .ms1001-nav-link.is-primary-nav {
    color: #e2c878 !important;
    background: rgba(255, 255, 255, 0.06);
  }

  .ms1001-mobile-tools {
    margin-top: auto;
    padding: 18px 20px 28px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.18);
  }

  .ms1001-mobile-tools-label {
    margin: 0;
    font-size: 12px;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.65);
    font-weight: 700;
  }

  .ms1001-mobile-tools .ms1001-auth-bar,
  .ms1001-mobile-tools .ms1001-surface-toggle,
  .ms1001-mobile-tools .ms1001-lang-toggle {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .ms1001-mobile-tools .ms1001-btn-login,
  .ms1001-mobile-tools .ms1001-btn-account {
    background: #fff;
    color: #00205b;
  }

  .ms1001-mobile-tools .ms1001-surface-toggle,
  .ms1001-mobile-tools .ms1001-lang-toggle {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.28);
    box-shadow: none;
  }

  .ms1001-mobile-tools .ms1001-surface-toggle button,
  .ms1001-mobile-tools .ms1001-lang-toggle button {
    color: #fff;
  }

  .ms1001-mobile-tools .ms1001-surface-toggle button.is-active,
  .ms1001-mobile-tools .ms1001-lang-toggle button.is-active {
    background: #c9a227;
    color: #00205b;
  }
}

@media (max-width: 640px) {
  :root {
    --ms1001-chrome-gutter: 16px;
  }
}

@media (min-width: 641px) {
  .ms1001-nav-link.is-sm-only { display: none; }
}

@media (min-width: 1024px) {
  .ms1001-nav-link.is-lg-only { display: inline; }
}

@media (max-width: 1023px) {
  .ms1001-nav-link.is-lg-only { display: none; }
}

.ms1001-chrome-subnav-row {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--ms1001-chrome-border);
}

.ms1001-chrome-subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.ms1001-subnav-tab,
.ms1001-subnav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(254, 215, 170, 0.55);
  background: rgba(255, 255, 255, 0.72);
  color: #334155;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.ms1001-subnav-tab:hover,
.ms1001-subnav-link:hover {
  border-color: rgba(147, 51, 234, 0.35);
  color: #7c3aed;
}

.ms1001-subnav-tab.is-active {
  background: linear-gradient(90deg, #9333ea, #f97316);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 20px rgba(147, 51, 234, 0.22);
}

.ms1001-nav-link.is-active {
  color: #b9312d;
  background: rgba(185, 49, 45, 0.08);
}
