:root {
  --bg: #fffaf3;
  --bg-soft: #fff7ed;
  --paper: #fffdf9;
  --panel: rgba(255, 255, 255, .9);
  --text: #071126;
  --muted: #65728a;
  --line: #e7d9c6;
  --warm-line: #f4cda2;
  --accent: #f35b21;
  --rose: #ff2e61;
  --violet: #b94bf7;
  --shadow: 0 20px 60px rgba(97, 58, 21, .12);
  --font-sans: "Geist", system-ui, -apple-system, sans-serif;
}


* { box-sizing: border-box; }
html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  background: var(--bg);
}
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--font-sans);
  background: var(--bg);
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }

.wrap {
  width: min(72rem, calc(100% - 48px));
  margin: 0 auto;
  position: relative;
  z-index: 1;
}
/* Legacy page topbar retired — chrome header owns all nav */
.topbar.site-header,
#siteHeader {
  display: none !important;
}
.portal-admin-strip {
  display: none !important;
}
/* Admin tools parked (PORTAL_ADMIN_TOOLS_ENABLED); slot stays in DOM for future use */
#ms1001-portal-admin:not(.is-visible),
#ms1001-chrome .ms1001-portal-admin[hidden] {
  display: none !important;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 0 18px;
}

#ms1001-chrome .ms1001-adopted-site-header.topbar {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 22px 0 18px;
}

#ms1001-chrome .ms1001-adopted-site-header.topbar .brand,
#ms1001-chrome .ms1001-adopted-site-header.topbar .nav-actions {
  width: auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 260px;
}
.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  object-fit: cover;
  box-shadow: 0 12px 28px rgba(20, 20, 40, .12);
}
.brand strong {
  display: block;
  font-size: 15px;
  background: linear-gradient(90deg, #c026d3, #ea580c 55%, #2563eb);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand span { display: block; margin-top: 3px; font-size: 11px; color: var(--muted); }
.nav-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  flex-wrap: wrap;
}
.nav-link, .icon-btn, .primary-btn, .ghost-btn {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 999px;
  padding: 9px 13px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(49, 32, 12, .06);
}
.icon-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-grid;
  place-items: center;
}
.primary-btn {
  border: 0;
  color: white;
  background: linear-gradient(90deg, #b500ff, #ff2667 55%, #ff641c);
  box-shadow: 0 12px 30px rgba(232, 40, 118, .28);
}
.hero.ms1001-hero[data-hero-theme="dark"] .primary-btn {
  background: #fff5bf;
  color: #751515;
}

/* ===== CUHK-inspired portal shell ===== */
body.portal-cuhk {
  --cuhk-navy: #00205b;
  --cuhk-navy-soft: #0b3a7a;
  --cuhk-gold: #c9a227;
  --cuhk-muted: #5b6577;
  --cuhk-line: #e6ebf2;
  --cuhk-bg: #ffffff;
  --ms1001-content-gap: 0px;
  background: #fff !important;
}
body.portal-cuhk .wrap {
  width: calc(100% - clamp(12px, 1.5vw, 24px) * 2);
  max-width: none;
}
html[data-ms1001-chrome="on"] body.portal-cuhk::before {
  background: #fff !important;
}
body.portal-cuhk #ms1001-chrome .ms1001-chrome-unified {
  background: #fff;
  border: 0;
  border-bottom: 0;
  border-radius: 0;
  /* CUHK-SZ: soft shadow under the title bar */
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  backdrop-filter: none;
}
body.portal-cuhk #ms1001-chrome .ms1001-portal-link strong,
body.portal-cuhk #ms1001-chrome .ms1001-site-title {
  color: var(--cuhk-navy);
  font-size: clamp(26px, 2.6vw, 36px) !important;
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: -0.03em;
}
body.portal-cuhk #ms1001-chrome .is-cuhk-two-row .ms1001-portal-link img {
  width: 56px;
  height: 56px;
  border-radius: 14px;
}
body.portal-cuhk #ms1001-chrome .ms1001-site-badge {
  width: auto;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  background: var(--cuhk-navy);
  border-radius: 4px;
  box-shadow: none;
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
}
body.portal-cuhk #ms1001-chrome .ms1001-hero-theme-toggle {
  display: none !important;
}
html[data-surface-theme="dark"] body.portal-cuhk #ms1001-chrome .ms1001-chrome-unified.is-cuhk-two-row {
  border-bottom: 0;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.28);
}
@media (max-width: 1100px) {
  body.portal-cuhk #ms1001-chrome .ms1001-chrome-unified {
    border-bottom: 0 !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  }
  body.portal-cuhk #ms1001-chrome .ms1001-chrome-unified.is-cuhk-two-row .ms1001-chrome-primary {
    border-bottom: 0;
  }
}

/* Surface dark: everything EXCEPT matrix text boxes → navy; boxes stay light */
html[data-surface-theme="dark"] body.portal-cuhk {
  --cuhk-bg: #00205b;
  --cuhk-line: rgba(255, 255, 255, 0.18);
  --cuhk-muted: rgba(255, 255, 255, 0.72);
  --text: #fff;
  --muted: rgba(255, 255, 255, 0.72);
  --line: rgba(255, 255, 255, 0.18);
  background: #00205b !important;
  color: #fff;
}
html[data-ms1001-chrome="on"][data-surface-theme="dark"] body.portal-cuhk::before {
  background: #00205b !important;
}
html[data-surface-theme="dark"] body.portal-cuhk #ms1001-chrome .ms1001-chrome-unified,
html[data-surface-theme="dark"] body.portal-cuhk #ms1001-chrome .ms1001-chrome-unified.is-cuhk-two-row {
  background: #00205b;
  border-bottom: 0 !important;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.28);
}
html[data-surface-theme="dark"] body.portal-cuhk #ms1001-chrome .ms1001-portal-link strong,
html[data-surface-theme="dark"] body.portal-cuhk #ms1001-chrome .ms1001-site-title,
html[data-surface-theme="dark"] body.portal-cuhk #ms1001-chrome .ms1001-nav-link {
  color: #fff !important;
}
html[data-surface-theme="dark"] body.portal-cuhk #ms1001-chrome .ms1001-nav-link:hover,
html[data-surface-theme="dark"] body.portal-cuhk #ms1001-chrome .ms1001-nav-link.is-primary-nav {
  color: #e2c878;
  font-weight: 700;
}
html[data-surface-theme="dark"] body.portal-cuhk .cuhk-section {
  background: #00205b;
}
html[data-surface-theme="dark"] body.portal-cuhk .cuhk-section-head {
  border-bottom-color: rgba(255, 255, 255, 0.28);
}
html[data-surface-theme="dark"] body.portal-cuhk .cuhk-section-head h2 {
  color: #fff;
}
html[data-surface-theme="dark"] body.portal-cuhk .cuhk-section-desc {
  color: rgba(255, 255, 255, 0.72);
}
html[data-surface-theme="dark"] body.portal-cuhk .hero-slider,
html[data-surface-theme="dark"] body.portal-cuhk .hero-slider-stage,
html[data-surface-theme="dark"] body.portal-cuhk .hero-slide,
html[data-surface-theme="dark"] body.portal-cuhk .hero-slide img {
  background: #00205b !important;
}
html[data-surface-theme="dark"] body.portal-cuhk .coop-panel,
html[data-surface-theme="dark"] body.portal-cuhk .coop-mode,
html[data-surface-theme="dark"] body.portal-cuhk .coop-resource,
html[data-surface-theme="dark"] body.portal-cuhk .note {
  background: #00205b;
  border-color: rgba(255, 255, 255, 0.16);
  color: #fff !important;
}
html[data-surface-theme="dark"] body.portal-cuhk .footer {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.22);
  color: rgba(255, 255, 255, 0.88) !important;
}
html[data-surface-theme="dark"] body.portal-cuhk .coop-head h2,
html[data-surface-theme="dark"] body.portal-cuhk .coop-mode h3,
html[data-surface-theme="dark"] body.portal-cuhk .coop-resource h3,
html[data-surface-theme="dark"] body.portal-cuhk .coop-contact h3,
html[data-surface-theme="dark"] body.portal-cuhk .note b {
  color: #fff !important;
}
html[data-surface-theme="dark"] body.portal-cuhk .footer-brand,
html[data-surface-theme="dark"] body.portal-cuhk .footer {
  color: rgba(255, 255, 255, 0.92) !important;
}
html[data-surface-theme="dark"] body.portal-cuhk .coop-panel a:not(.primary-btn),
html[data-surface-theme="dark"] body.portal-cuhk .note a:not(.primary-btn) {
  color: #e2c878 !important;
}
html[data-surface-theme="dark"] body.portal-cuhk .footer a {
  color: #e2c878 !important;
}
html[data-surface-theme="dark"] body.portal-cuhk .coop-panel a:not(.primary-btn):hover,
html[data-surface-theme="dark"] body.portal-cuhk .note a:not(.primary-btn):hover {
  color: #f0d78a !important;
}
html[data-surface-theme="dark"] body.portal-cuhk .footer a:hover {
  color: #f0d78a !important;
}
html[data-surface-theme="dark"] body.portal-cuhk .coop-lead,
html[data-surface-theme="dark"] body.portal-cuhk .coop-mode p,
html[data-surface-theme="dark"] body.portal-cuhk .coop-resource p,
html[data-surface-theme="dark"] body.portal-cuhk .coop-contact p,
html[data-surface-theme="dark"] body.portal-cuhk .contact-note,
html[data-surface-theme="dark"] body.portal-cuhk .footer-close {
  color: rgba(255, 255, 255, 0.72) !important;
}
html[data-surface-theme="dark"] body.portal-cuhk .dev-credit {
  color: rgba(255, 255, 255, 0.72) !important;
}
html[data-surface-theme="dark"] body.portal-cuhk .guide-banner figure img {
  border-color: #e6ebf2;
  background: #fff;
}
/* Gold CTA + navy text — never white-on-gold */
html[data-surface-theme="dark"] body.portal-cuhk .primary-btn,
html[data-surface-theme="dark"] body.portal-cuhk a.primary-btn,
html[data-surface-theme="dark"] body.portal-cuhk .guide-banner a.primary-btn {
  background: #c9a227 !important;
  color: #00205b !important;
  border: 0 !important;
  box-shadow: none;
}
html[data-surface-theme="dark"] body.portal-cuhk .primary-btn:hover,
html[data-surface-theme="dark"] body.portal-cuhk a.primary-btn:hover,
html[data-surface-theme="dark"] body.portal-cuhk .guide-banner a.primary-btn:hover {
  background: #e2c878 !important;
  color: #00205b !important;
}
/* Guide page content boxes stay light on navy shell */
html[data-surface-theme="dark"] body.portal-cuhk .intro-panel,
html[data-surface-theme="dark"] body.portal-cuhk .catalog-panel,
html[data-surface-theme="dark"] body.portal-cuhk .toc-panel,
html[data-surface-theme="dark"] body.portal-cuhk .agent-section,
html[data-surface-theme="dark"] body.portal-cuhk .feedback-section {
  background: #fff !important;
  border-color: #e6ebf2;
  color: #0f172a;
}
/* Matrix cards: flat mosaic on navy; soft ambient lift only on hover */
html[data-surface-theme="dark"] .matrix-section .matrix-card {
  background: #fff;
  border-color: transparent;
  color: #0f172a;
  box-shadow: none;
}
html[data-surface-theme="dark"] .matrix-section .matrix-card:hover {
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.08),
    0 14px 32px rgba(0, 0, 0, 0.18),
    0 32px 64px rgba(0, 0, 0, 0.14);
}
html[data-surface-theme="dark"] .matrix-section .matrix-body h3,
html[data-surface-theme="dark"] .matrix-section .matrix-short,
html[data-surface-theme="dark"] .matrix-section .matrix-desc {
  color: #0f172a;
}
html[data-surface-theme="dark"] .matrix-section .matrix-tag {
  color: #c9a227;
}
html[data-surface-theme="dark"] .matrix-section .matrix-status,
html[data-surface-theme="dark"] .matrix-section .matrix-tags span {
  border-color: #e6ebf2;
  color: #64748b;
  background: #f8fafc;
}
html[data-surface-theme="dark"] .matrix-section .matrix-thumb {
  border-color: #e6ebf2;
  background: #f1f5f9;
}
html[data-surface-theme="dark"] .matrix-section .matrix-thumb-fallback {
  color: #00205b;
}
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-chrome-utility {
  border-bottom: 0;
}
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-utility-nav .ms1001-nav-link {
  color: rgba(255, 255, 255, 0.72);
}
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-utility-nav .ms1001-nav-link:hover,
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-utility-nav .ms1001-nav-link.is-primary-nav,
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-utility-nav .ms1001-nav-link.is-active {
  color: #e2c878;
}
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-matrix-cats .filter {
  color: rgba(255, 255, 255, 0.88);
  background: transparent;
}
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-matrix-cats .filter:hover,
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-matrix-cats .filter.active {
  color: #e2c878;
  box-shadow: inset 0 -2px 0 #c9a227;
  background: transparent;
}
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-matrix-search-end {
  border-left-color: rgba(255, 255, 255, 0.22);
}
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-matrix-search-end .search-box,
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-matrix-search-end .result-count {
  color: rgba(255, 255, 255, 0.72);
}
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-matrix-search-end .search-box input {
  color: #fff;
}
html[data-surface-theme="dark"] #ms1001-chrome .ms1001-matrix-search-end .search-box input::placeholder {
  color: rgba(255, 255, 255, 0.45);
}
/* CUHK-SZ primary-nav scale: ~17px bold for links / account / toggles */
body.portal-cuhk #ms1001-chrome .ms1001-chrome-ctas .ms1001-cta,
body.portal-cuhk #ms1001-chrome .ms1001-cta.is-primary,
body.portal-cuhk #ms1001-chrome a.ms1001-cta[href*="account"],
body.portal-cuhk #ms1001-chrome .ms1001-btn-account {
  border: 0 !important;
  border-radius: 0 !important;
  background: var(--cuhk-navy) !important;
  color: #fff !important;
  box-shadow: none !important;
  padding: 9px 16px !important;
  font-size: 17px !important;
  font-weight: 700 !important;
  line-height: 1.25 !important;
}
html[data-surface-theme="dark"] body.portal-cuhk #ms1001-chrome a.ms1001-cta[href*="account"],
html[data-surface-theme="dark"] body.portal-cuhk #ms1001-chrome .ms1001-btn-account {
  background: #c9a227 !important;
  color: #00205b !important;
}
body.portal-cuhk #ms1001-chrome .is-cuhk-two-row .ms1001-utility-nav {
  gap: 0 22px !important;
}
body.portal-cuhk #ms1001-chrome .is-cuhk-two-row .ms1001-utility-nav .ms1001-nav-link {
  font-size: 17px !important;
  font-weight: 700 !important;
  line-height: 1.25 !important;
  padding: 9px 0 !important;
  letter-spacing: 0.01em;
}
body.portal-cuhk #ms1001-chrome .ms1001-surface-toggle,
body.portal-cuhk #ms1001-chrome .ms1001-lang-toggle {
  padding: 4px !important;
}
body.portal-cuhk #ms1001-chrome .ms1001-surface-toggle button,
body.portal-cuhk #ms1001-chrome .ms1001-lang-toggle button {
  font-size: 16px !important;
  font-weight: 700 !important;
  line-height: 1.25 !important;
  padding: 7px 14px !important;
}
body.portal-cuhk #ms1001-chrome .is-cuhk-two-row .ms1001-portal-admin {
  max-width: none;
  gap: 8px 10px;
}
body.portal-cuhk #ms1001-chrome .is-cuhk-two-row .ms1001-portal-admin .ms1001-admin-tool,
body.portal-cuhk #ms1001-chrome .is-cuhk-two-row .ms1001-portal-admin .ghost-btn,
body.portal-cuhk #ms1001-chrome .is-cuhk-two-row .ms1001-portal-admin .ms1001-admin-save,
body.portal-cuhk #ms1001-chrome .is-cuhk-two-row .ms1001-portal-admin .primary-btn {
  padding: 9px 16px !important;
  font-size: 17px !important;
  font-weight: 700 !important;
  line-height: 1.25 !important;
}
html[data-surface-theme="dark"] body.portal-cuhk #ms1001-chrome .is-cuhk-two-row .ms1001-portal-admin .ms1001-admin-save,
html[data-surface-theme="dark"] body.portal-cuhk #ms1001-chrome .is-cuhk-two-row .ms1001-portal-admin .primary-btn {
  background: #c9a227 !important;
  color: #00205b !important;
}

.hero-slider {
  position: relative;
  width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  margin-bottom: 0;
  background: #eef2f7;
}
/* Full poster visible (contain); letterbox sides follow surface theme */
body.portal-cuhk .hero-slider {
  height: auto;
  min-height: 0;
  max-height: none;
  background: #eef2f7;
}
.hero-slider-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
  max-height: min(680px, 72vh);
  overflow: hidden;
}
body.portal-cuhk .hero-slider-stage {
  aspect-ratio: 16 / 9;
  height: auto;
  max-height: calc(100dvh - var(--ms1001-chrome-pad, var(--ms1001-chrome-pad-estimate, 132px)));
}
.hero-slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity .9s ease;
  pointer-events: none;
}
.hero-slide.is-active {
  opacity: 1;
  pointer-events: auto;
  z-index: 1;
}
.hero-slide-link {
  display: block;
  width: 100%;
  height: 100%;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}
.hero-slide img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  background: #eef2f7;
  transform: none;
  filter: none;
}
body.portal-cuhk .hero-slide img {
  object-fit: contain;
  object-position: center center;
  background: #eef2f7;
}
html[data-surface-theme="dark"] body.portal-cuhk .hero-slider,
html[data-surface-theme="dark"] body.portal-cuhk .hero-slide img {
  background: #00205b;
}
.hero-slide.is-active img { transform: none; }
.hero-slide-copy,
.hero-slide .hero-copy,
.hero-slide figcaption,
.hero-slide h1,
.hero-slide h2,
.hero-slide p { display: none !important; }
.hero-slider-arrow {
  position: absolute;
  top: 50%;
  z-index: 3;
  transform: translateY(-50%);
  width: 46px;
  height: 62px;
  border: 0;
  border-radius: 2px;
  background: rgba(45, 55, 72, .62);
  color: #fff;
  font-size: 32px;
  line-height: 1;
  cursor: pointer;
  transition: background .2s ease;
}
.hero-slider-arrow:hover { background: rgba(45, 55, 72, .82); }
.hero-slider-arrow.is-prev { left: 18px; }
.hero-slider-arrow.is-next { right: 18px; }
.hero-slider-dots {
  position: absolute;
  left: 50%;
  bottom: 24px;
  z-index: 3;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
}
.hero-slider-dots button {
  width: 30px;
  height: 4px;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: rgba(15, 35, 70, .28);
  cursor: pointer;
  transition: width .25s ease, background .25s ease;
}
.hero-slider-dots button.is-active {
  width: 44px;
  background: var(--cuhk-gold, #c9a227);
}

.cuhk-section {
  width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  background: #fff;
  padding: 48px 0 36px;
}
body.portal-cuhk #matrix.cuhk-section {
  /* CUHK campus-news: airy band, not flush under chrome */
  scroll-margin-top: calc(var(--ms1001-chrome-pad, var(--ms1001-chrome-pad-estimate, 132px)) + 8px);
  padding: clamp(56px, 7vh, 88px) 0 clamp(48px, 6vh, 72px);
  background: #fff;
}
/* Dark surface: navy outside the cards; cards stay light */
html[data-surface-theme="dark"] body.portal-cuhk #matrix.cuhk-section {
  background: #00205b;
}
.cuhk-section-inner {
  width: calc(100% - clamp(12px, 1.5vw, 24px) * 2);
  max-width: none;
  margin: 0 auto;
}
.cuhk-section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px 24px;
  margin-bottom: 22px;
  border-bottom: 2px solid var(--cuhk-navy, #00205b);
  padding-bottom: 12px;
  width: 100%;
  flex-wrap: wrap;
}
.cuhk-section-head > div:first-child {
  flex: 0 1 auto;
  margin-right: auto;
  text-align: left;
}
.cuhk-section-head h2 {
  margin: 0;
  font-size: clamp(22px, 2.2vw, 28px);
  font-weight: 800;
  color: var(--cuhk-navy, #00205b);
  text-align: left;
}
/* Matrix head: title + meta, then filters/search — no nested white card */
body.portal-cuhk #matrix .matrix-section-head {
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 14px;
  margin-bottom: 22px;
  padding: 0 0 14px;
  border: 0;
  border-bottom: 2px solid var(--cuhk-navy, #00205b);
  background: transparent;
  box-shadow: none;
}
body.portal-cuhk #matrix .matrix-head-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px 20px;
  flex-wrap: wrap;
  width: 100%;
}
body.portal-cuhk #matrix .matrix-section-head h2 {
  width: auto;
  flex: 1 1 auto;
  text-align: left;
  font-size: clamp(22px, 2.4vw, 30px);
  font-weight: 800;
  letter-spacing: 0;
  color: var(--cuhk-navy, #00205b);
  margin: 0;
  padding: 0;
  line-height: 1.25;
}
body.portal-cuhk #matrix .matrix-head-meta {
  margin: 0;
  flex: 0 0 auto;
}
body.portal-cuhk #matrix .matrix-head-meta .result-count {
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
html[data-surface-theme="dark"] body.portal-cuhk #matrix .matrix-section-head {
  background: transparent;
  border-bottom-color: rgba(255, 255, 255, 0.28);
  box-shadow: none;
}
html[data-surface-theme="dark"] body.portal-cuhk #matrix .matrix-section-head h2 {
  color: #fff;
}
html[data-surface-theme="dark"] body.portal-cuhk #matrix .matrix-head-meta .result-count {
  color: rgba(255, 255, 255, 0.62);
}
.cuhk-section-head .matrix-workbench-tools,
body.portal-cuhk #matrix .matrix-section-head .matrix-workbench-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  width: 100%;
  max-width: none;
  flex: 0 0 auto;
  flex-direction: row;
  margin: 0;
  padding: 0;
  border: 0;
  border-top: 0;
}
body.portal-cuhk #matrix .matrix-section-head .matrix-cats {
  justify-content: flex-start;
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
}
.matrix-workbench-tools .matrix-cats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 4px 4px;
  min-width: 0;
  flex: 1 1 auto;
}
.matrix-workbench-tools .filter {
  appearance: none;
  border: 0;
  background: transparent;
  box-shadow: none;
  border-radius: 0;
  padding: 6px 10px;
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.2;
}
.matrix-workbench-tools .filter:hover {
  color: var(--cuhk-navy, #00205b);
}
.matrix-workbench-tools .filter.active {
  color: var(--cuhk-navy, #00205b);
  box-shadow: inset 0 -2px 0 var(--cuhk-gold, #c9a227);
}
.matrix-workbench-tools .search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 1 260px;
  min-width: min(220px, 100%);
  border: 1px solid #d7dee8;
  background: #f7f9fc;
  padding: 8px 12px;
  color: #64748b;
  border-radius: 0;
}
.matrix-workbench-tools .search-box:focus-within {
  border-color: var(--cuhk-navy, #00205b);
  background: #fff;
}
.matrix-workbench-tools .search-ico {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  position: relative;
  opacity: 0.55;
}
.matrix-workbench-tools .search-ico::after {
  content: "";
  position: absolute;
  width: 6px;
  height: 1.5px;
  background: currentColor;
  right: -3px;
  bottom: -1px;
  transform: rotate(45deg);
  border-radius: 1px;
}
.matrix-workbench-tools .search-box input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: #0f172a;
}
.matrix-workbench-tools .search-box input::placeholder {
  color: #94a3b8;
  font-weight: 500;
}
.matrix-workbench-tools .result-count {
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  white-space: nowrap;
}
html[data-surface-theme="dark"] body.portal-cuhk .cuhk-section-head .matrix-workbench-tools .filter,
html[data-surface-theme="dark"] body.portal-cuhk #matrix .matrix-section-head .matrix-workbench-tools .filter {
  color: rgba(255, 255, 255, 0.68);
}
html[data-surface-theme="dark"] body.portal-cuhk .cuhk-section-head .matrix-workbench-tools .filter:hover,
html[data-surface-theme="dark"] body.portal-cuhk .cuhk-section-head .matrix-workbench-tools .filter.active,
html[data-surface-theme="dark"] body.portal-cuhk #matrix .matrix-section-head .matrix-workbench-tools .filter:hover,
html[data-surface-theme="dark"] body.portal-cuhk #matrix .matrix-section-head .matrix-workbench-tools .filter.active {
  color: #fff;
  box-shadow: inset 0 -2px 0 #c9a227;
}
html[data-surface-theme="dark"] body.portal-cuhk .cuhk-section-head .matrix-workbench-tools .search-box,
html[data-surface-theme="dark"] body.portal-cuhk #matrix .matrix-section-head .matrix-workbench-tools .search-box {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.7);
}
html[data-surface-theme="dark"] body.portal-cuhk .cuhk-section-head .matrix-workbench-tools .search-box:focus-within,
html[data-surface-theme="dark"] body.portal-cuhk #matrix .matrix-section-head .matrix-workbench-tools .search-box:focus-within {
  border-color: rgba(201, 162, 39, 0.65);
  background: rgba(255, 255, 255, 0.1);
}
html[data-surface-theme="dark"] body.portal-cuhk .cuhk-section-head .matrix-workbench-tools .search-box input,
html[data-surface-theme="dark"] body.portal-cuhk #matrix .matrix-section-head .matrix-workbench-tools .search-box input {
  color: #fff;
}
html[data-surface-theme="dark"] body.portal-cuhk .cuhk-section-head .matrix-workbench-tools .search-box input::placeholder,
html[data-surface-theme="dark"] body.portal-cuhk #matrix .matrix-section-head .matrix-workbench-tools .search-box input::placeholder {
  color: rgba(255, 255, 255, 0.42);
}
.matrix-section .matrix-search {
  margin: 0 0 22px;
  border: 1px solid var(--cuhk-line, #e6ebf2);
  border-radius: 0;
  background: #f7f9fc;
  box-shadow: none;
  padding: 16px 18px;
}
.matrix-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
}
/* CUHK campus-news: spaced cards, not flush mosaic */
body.portal-cuhk #matrix .matrix-grid {
  gap: clamp(16px, 2vw, 28px);
}
@media (max-width: 1280px) {
  .matrix-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
.matrix-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #fff;
  /* Rest: flat tile (no floating card shadow) */
  box-shadow: none;
  transition: transform .28s ease, box-shadow .28s ease, z-index 0s;
  align-items: stretch;
  overflow: hidden;
  z-index: 0;
  text-decoration: none;
  color: inherit;
}
body.portal-cuhk #matrix .matrix-card {
  border: 1px solid #e6ebf2;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}
.matrix-card:hover {
  border-color: transparent;
  /* Soft ambient lift — CUHK-like depth, not hard navy glow */
  z-index: 2;
  transform: translateY(-4px);
  box-shadow:
    0 2px 4px rgba(15, 23, 42, 0.04),
    0 12px 28px rgba(15, 23, 42, 0.10),
    0 28px 56px rgba(15, 23, 42, 0.08);
}
.matrix-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #eef2f7;
  border: 0;
  border-bottom: 0;
  flex: 0 0 auto;
}
.matrix-thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  /* Frame is 16:9; avatars are 16:9 — cover fills without crop when ratios match */
  object-fit: cover;
  object-position: center;
  display: block;
  z-index: 1;
}
.matrix-card:hover .matrix-thumb img {
  transform: none;
}
.matrix-thumb img.is-missing,
.matrix-thumb img:not([src]) {
  display: none;
}
.matrix-thumb-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(36px, 4.5vw, 52px);
  font-weight: 800;
  color: rgba(0, 32, 91, 0.22);
  letter-spacing: .04em;
  z-index: 0;
}
.matrix-body {
  padding: 18px 20px 22px;
  background: #fff;
  flex: 1 1 auto;
}
.matrix-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.matrix-tag {
  display: inline-block;
  color: var(--cuhk-gold, #c9a227);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .04em;
}
.matrix-status {
  display: inline-block;
  border: 1px solid #e6ebf2;
  padding: 2px 8px;
  color: #64748b;
  font-size: 11px;
  font-weight: 700;
}
.matrix-body h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.4;
  color: var(--cuhk-navy, #00205b);
  font-weight: 800;
}
.matrix-short {
  margin: 8px 0 0;
  color: #0b3a7a;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.55;
}
.matrix-desc {
  margin: 8px 0 0;
  color: #5b6577;
  font-size: 13px;
  line-height: 1.7;
}
.matrix-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}
.matrix-tags span {
  border: 1px solid #e6ebf2;
  padding: 3px 8px;
  color: #64748b;
  font-size: 11px;
  font-weight: 600;
}
body.portal-cuhk .search-panel,
body.portal-cuhk .note,
body.portal-cuhk .coop-panel,
body.portal-cuhk .coop-mode,
body.portal-cuhk .coop-resource,
body.portal-cuhk .footer {
  border-radius: 0;
}
body.portal-cuhk .primary-btn,
body.portal-cuhk a.primary-btn {
  background: var(--cuhk-navy, #00205b);
  color: #fff !important;
  box-shadow: none;
}
body.portal-cuhk .filter.active {
  background: var(--cuhk-navy, #00205b);
  color: #fff;
  border-color: var(--cuhk-navy, #00205b);
}
/* Light: selected category = navy text + gold underline (not a dark pill) */
body.portal-cuhk #matrix .matrix-workbench-tools .filter.active,
body.portal-cuhk #matrix .matrix-workbench-tools .filter:hover {
  background: transparent !important;
  color: var(--cuhk-navy, #00205b) !important;
  border-color: transparent !important;
  box-shadow: inset 0 -2px 0 var(--cuhk-gold, #c9a227);
}
html[data-surface-theme="dark"] body.portal-cuhk #matrix .matrix-workbench-tools .filter.active,
html[data-surface-theme="dark"] body.portal-cuhk #matrix .matrix-workbench-tools .filter:hover {
  background: transparent !important;
  color: #fff !important;
  border-color: transparent !important;
  box-shadow: inset 0 -2px 0 #c9a227;
}
.kicker {
  margin: 0 0 14px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  color: #f04b18;
}
.lead {
  max-width: 760px;
  margin: 22px auto 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 2;
  font-weight: 400;
}

.quick-grid {
  margin: 36px auto 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  max-width: 820px;
}
.quick-card {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.78);
  border-radius: 12px;
  padding: 16px;
  text-align: left;
  min-height: 104px;
}
.hero.ms1001-hero[data-hero-theme="dark"] .quick-card {
  background: rgba(255, 248, 231, .94);
  border-color: rgba(255, 236, 198, .64);
  color: #160b07;
}
.quick-card i {
  display: inline-flex;
  min-width: 3.4em;
  min-height: 1.8em;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: color-mix(in srgb, var(--c) 12%, white);
  font-style: normal;
  color: var(--c);
  font-size: 13px;
  font-weight: 900;
}
.quick-card strong { display: block; margin: 0 0 5px; font-size: 15px; font-weight: 700; }
.quick-card span { color: var(--muted); font-size: 12px; }
.hero.ms1001-hero[data-hero-theme="dark"] .quick-card span { color: #5c463a; }

.search-panel {
  margin: 34px 0 18px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.78);
  border-radius: 22px;
  box-shadow: 0 14px 40px rgba(30, 20, 10, .06);
  padding: 14px;
}
.search-row {
  display: flex;
  gap: 12px;
  align-items: center;
}
.search-box {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 16px;
  padding: 0 14px;
}
.search-box input {
  width: 100%;
  height: 46px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}
.result-count { color: var(--muted); font-size: 13px; white-space: nowrap; }
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 14px;
  margin-top: 14px;
  border-top: 1px solid var(--line);
}
.filter {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}
.filter.active {
  color: white;
  border-color: transparent;
  background: linear-gradient(90deg, #e63b6b, #ff6a1c);
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin: 30px 0 16px;
}
.section-head p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.7; }
.section-kicker {
  color: #6f7fa0;
  font-size: 11px;
  letter-spacing: .12em;
  font-weight: 900;
}
.section-head h2 {
  margin: 4px 0;
  font-size: 28px;
  font-weight: 900;
  letter-spacing: -.02em;
}
.section-head h2 .section-grad {
  background: linear-gradient(90deg, #ea580c, #db2777 50%, #7c3aed);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.card {
  position: relative;
  min-height: 234px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,.82);
  padding: 18px;
  box-shadow: 0 14px 36px rgba(25, 34, 55, .07);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
  display: flex;
  flex-direction: column;
}
.card:hover { transform: translateY(-3px); border-color: var(--warm-line); box-shadow: var(--shadow); }
.card.dragging { opacity: .4; }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.badge-icon {
  display: inline-flex;
  min-width: 4.2em;
  min-height: 2em;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: color-mix(in srgb, var(--c) 12%, white);
  color: var(--c);
  font-size: 15px;
  font-weight: 900;
}
.status { color: var(--muted); font-size: 11px; border: 1px solid var(--line); border-radius: 999px; padding: 5px 8px; }
.card h3 { margin: 16px 0 8px; font-size: 18px; line-height: 1.28; }
.full-name {
  color: #344054;
  font-size: 13px;
  font-weight: 900;
  line-height: 1.55;
}
.short { color: var(--c); font-size: 13px; font-weight: 900; line-height: 1.6; }
.desc { color: var(--muted); font-size: 13px; line-height: 1.75; margin: 10px 0 0; flex: 1; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0; }
.tag { border: 1px solid var(--line); border-radius: 999px; padding: 4px 7px; color: var(--muted); font-size: 11px; }
.card-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; display: flex; justify-content: space-between; gap: 8px; color: var(--c); font-size: 12px; font-weight: 900; }
.card-foot span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.edit-tools { display: none; position: absolute; right: 10px; top: 10px; gap: 5px; }
.editing .edit-tools { display: flex; }
.tool-btn { border: 1px solid var(--line); background: var(--paper); border-radius: 10px; padding: 5px 7px; cursor: pointer; font-size: 12px; }
.editing .card,
.editing .matrix-card { cursor: grab; }
.editing .card::after,
.editing .matrix-card::after { content: ""; position: absolute; inset: -2px; border-radius: 4px; border: 2px dashed rgba(0, 32, 91, .2); pointer-events: none; }
.card.dragging,
.matrix-card.dragging { opacity: .4; }

.note, .footer {
  margin-top: 24px;
  border-top: 1px solid var(--line);
  padding: 22px 0 40px;
  color: var(--muted);
  line-height: 1.8;
  text-align: center;
}
.note {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,.74);
  padding: 18px;
  text-align: left;
}
.note b, .footer-brand { color: var(--text); }
.footer-brand {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.footer-close {
  margin: 0 auto;
  max-width: 52ch;
  font-size: 14px;
}

.dev-credit {
  margin: 14px 0 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #64748b;
}

.coop-panel {
  margin: 36px 0 24px;
  padding: clamp(28px, 4vw, 44px);
  border: 1px solid var(--cuhk-line, #e6ebf2);
  background: #fff;
  box-shadow: 0 8px 28px rgba(0, 32, 91, 0.05);
  color: #122033;
}
.coop-head {
  max-width: 720px;
  margin: 0 auto 28px;
  text-align: center;
}
.coop-eyebrow {
  margin: 0 0 12px;
  color: var(--cuhk-gold, #c9a227);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
}
.coop-head h2 {
  margin: 0 0 14px;
  color: var(--cuhk-navy, #00205b);
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.3;
  font-weight: 800;
}
.coop-lead {
  margin: 0;
  color: #5b6577;
  font-size: 15px;
  line-height: 1.85;
}
.coop-modes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 22px;
}
.coop-mode {
  padding: 16px 18px;
  border: 1px solid var(--cuhk-line, #e6ebf2);
  background: #f5f7fb;
}
.coop-mode h3 {
  margin: 0 0 8px;
  color: var(--cuhk-navy, #00205b);
  font-size: 15px;
  font-weight: 800;
}
.coop-mode p {
  margin: 0;
  color: #5b6577;
  font-size: 13px;
  line-height: 1.7;
}
.coop-resources {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 0 0 28px;
}
.coop-resource {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 22px 24px;
  border: 1px solid var(--cuhk-line, #e6ebf2);
  background: linear-gradient(180deg, #f8fafc 0%, #fff 100%);
}
.coop-resource h3 {
  margin: 0;
  color: var(--cuhk-navy, #00205b);
  font-size: 18px;
  font-weight: 800;
}
.coop-resource p {
  margin: 0;
  flex: 1;
  color: #5b6577;
  font-size: 14px;
  line-height: 1.75;
}
.coop-resource .primary-btn {
  align-self: flex-start;
  padding: 11px 18px;
  font-size: 14px;
}
.coop-contact {
  text-align: center;
  padding-top: 8px;
  border-top: 1px solid var(--cuhk-line, #e6ebf2);
}
.coop-contact h3 {
  margin: 18px 0 12px;
  color: var(--cuhk-navy, #00205b);
  font-size: 20px;
  font-weight: 800;
}
.coop-contact p {
  margin: 0 auto;
  max-width: 56ch;
  color: #5b6577;
  font-size: 15px;
  line-height: 1.85;
}
.contact-note {
  margin-top: 12px !important;
  font-size: 13px !important;
}
@media (max-width: 900px) {
  .coop-modes {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 720px) {
  .coop-modes,
  .coop-resources {
    grid-template-columns: 1fr;
  }
}
.wechat-qr-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px 24px;
  margin-top: 28px;
}
.wechat-qr-grid figure {
  margin: 0;
  width: min(148px, 28vw);
  padding: 14px 12px 12px;
  background: #fff;
  border: 1px solid #e6ebf2;
  box-sizing: border-box;
}
.wechat-qr-grid img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 0;
  box-shadow: none;
}
.wechat-qr-grid figcaption {
  margin-top: 10px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
  color: #41516b;
}
html[data-surface-theme="dark"] body.portal-cuhk .wechat-qr-grid figure {
  background: #fff;
  border-color: #e6ebf2;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
}
html[data-surface-theme="dark"] body.portal-cuhk .wechat-qr-grid figcaption {
  color: #41516b;
}

.adminbar {
  position: sticky;
  bottom: 16px;
  z-index: 20;
  margin: 22px auto;
  width: min(520px, calc(100% - 32px));
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 12px;
  background: rgba(255,255,255,.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}
.adminbar.show,
.adminbar.is-edit-dock.show { display: flex; }
.adminbar .left { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.adminbar .ghost-btn {
  color: #0f172a;
  background: #fff;
  border-color: #dbe3ef;
}
.adminbar .status-text { color: #52627c; font-size: 12px; font-weight: 700; }
.status-text { color: #52627c; font-size: 12px; font-weight: 700; }
.status-text.dirty { color: #e11d48; font-weight: 900; }
html[data-surface-theme="dark"] body.portal-cuhk .adminbar {
  background: rgba(0, 26, 74, 0.96);
  border-color: rgba(255, 255, 255, 0.22);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}
html[data-surface-theme="dark"] body.portal-cuhk .adminbar .ghost-btn {
  color: #fff !important;
  background: rgba(255, 255, 255, 0.1) !important;
  border-color: rgba(255, 255, 255, 0.28) !important;
}
html[data-surface-theme="dark"] body.portal-cuhk .adminbar .status-text {
  color: rgba(255, 255, 255, 0.78) !important;
}
html[data-surface-theme="dark"] body.portal-cuhk .adminbar .primary-btn {
  background: #c9a227 !important;
  color: #00205b !important;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  place-items: center;
  background: rgba(12, 8, 20, .42);
  padding: 18px;
}
.modal-backdrop.show { display: grid; }
.modal {
  width: min(720px, 100%);
  max-height: 88vh;
  overflow: auto;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: var(--paper);
  box-shadow: 0 30px 90px rgba(0, 0, 0, .25);
  padding: 20px;
}
.modal-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 16px; }
.modal h3 { margin: 0; font-size: 20px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { color: var(--muted); font-size: 12px; font-weight: 900; }
.field input, .field textarea, .field select {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: #071126;
  padding: 11px 12px;
  outline: 0;
}
.field textarea { min-height: 86px; resize: vertical; line-height: 1.6; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: .2s;
  border-radius: 14px;
  background: #111827;
  color: white;
  padding: 11px 14px;
}
.toast.show { opacity: 1; transform: translateY(0); }

.hero-actions { flex-wrap: wrap; }
.filter-row { flex-wrap: wrap; gap: 8px; }
.filter { white-space: nowrap; }

@media (max-width: 920px) {
  .topbar, .section-head, .adminbar, .cuhk-section-head { align-items: flex-start; flex-direction: column; border-radius: 22px; }
  .cuhk-section-head { text-align: left; align-items: stretch; }
  .cuhk-section-head h2 { width: 100%; text-align: left; }
  body.portal-cuhk #matrix .matrix-section-head {
    align-items: stretch;
    text-align: left;
  }
  body.portal-cuhk #matrix .matrix-section-head h2 {
    text-align: left;
  }
  body.portal-cuhk #matrix .matrix-head-top {
    align-items: flex-start;
  }
  .cuhk-section-head .matrix-workbench-tools {
    width: 100%;
    max-width: none;
    justify-content: flex-start;
    flex: 1 1 auto;
  }
  body.portal-cuhk #matrix .matrix-section-head .matrix-workbench-tools {
    align-items: stretch;
    justify-content: flex-start;
    flex-direction: column;
  }
  body.portal-cuhk #matrix .matrix-section-head .matrix-cats {
    justify-content: flex-start;
  }
  body.portal-cuhk #matrix .matrix-workbench-tools .search-box {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
  }
  .matrix-workbench-tools .matrix-cats { justify-content: flex-start; }
  .quick-grid, .grid, .matrix-grid { grid-template-columns: 1fr; gap: 12px; }
  body.portal-cuhk #matrix .matrix-grid { gap: 16px; }
  .matrix-card { flex-direction: column; }
  .matrix-body { padding: 16px 18px 20px; }
}
@media (max-width: 640px) {
  .wrap { width: calc(100% - 24px); max-width: none; }
  .quick-grid, .grid, .form-grid, .matrix-grid { grid-template-columns: 1fr; }
  .search-row { flex-direction: column; align-items: stretch; }
  .result-count { white-space: normal; }
  .hero-slider-stage {
    aspect-ratio: 16 / 9;
    max-height: none;
    height: auto;
  }
  body.portal-cuhk .hero-slider-stage {
    aspect-ratio: 16 / 9;
    height: auto;
    max-height: calc(100dvh - var(--ms1001-chrome-pad, var(--ms1001-chrome-pad-estimate, 132px)));
  }
  .hero-slider-arrow { width: 36px; height: 52px; font-size: 28px; }
  .hero-slider-arrow.is-prev { left: 8px; }
  .hero-slider-arrow.is-next { right: 8px; }
  .matrix-card { flex-direction: column; }
  .matrix-thumb { width: 100%; }
}

/* Mid widths: shrink like CUHK before full phone drawer (portal only) */
@media (max-width: 1100px) and (min-width: 761px) {
  body.portal-cuhk #ms1001-chrome .ms1001-menu-btn,
  body.portal-cuhk #ms1001-chrome .ms1001-mobile-search-btn {
    display: none !important;
  }
  body.portal-cuhk #ms1001-chrome .ms1001-chrome-unified.is-cuhk-two-row .ms1001-chrome-utility-end {
    display: flex !important;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px 12px;
    max-width: min(72%, 820px);
  }
  body.portal-cuhk #ms1001-chrome .ms1001-utility-nav {
    display: flex !important;
    gap: 0 12px;
  }
  body.portal-cuhk #ms1001-chrome .ms1001-chrome-actions {
    display: flex !important;
  }
  body.portal-cuhk #ms1001-chrome .ms1001-chrome-unified.is-cuhk-two-row .ms1001-chrome-primary {
    display: none !important;
  }
  body.portal-cuhk #ms1001-chrome .ms1001-mobile-drawer {
    display: none !important;
  }
  body.portal-cuhk #ms1001-chrome .is-cuhk-two-row .ms1001-utility-nav .ms1001-nav-link,
  body.portal-cuhk #ms1001-chrome .is-cuhk-two-row .ms1001-portal-admin .ms1001-admin-tool,
  body.portal-cuhk #ms1001-chrome .is-cuhk-two-row .ms1001-portal-admin .ghost-btn,
  body.portal-cuhk #ms1001-chrome .is-cuhk-two-row .ms1001-portal-admin .ms1001-admin-save,
  body.portal-cuhk #ms1001-chrome .is-cuhk-two-row .ms1001-portal-admin .primary-btn,
  body.portal-cuhk #ms1001-chrome a.ms1001-cta[href*="account"],
  body.portal-cuhk #ms1001-chrome .ms1001-btn-account,
  body.portal-cuhk #ms1001-chrome .ms1001-surface-toggle button,
  body.portal-cuhk #ms1001-chrome .ms1001-lang-toggle button {
    font-size: 15px !important;
    padding: 7px 12px !important;
  }
  body.portal-cuhk #ms1001-chrome .is-cuhk-two-row .ms1001-utility-nav .ms1001-nav-link {
    padding: 7px 0 !important;
  }
  body.portal-cuhk #ms1001-chrome .is-cuhk-two-row .ms1001-utility-nav {
    gap: 0 14px !important;
  }
  body.portal-cuhk #ms1001-chrome .is-cuhk-two-row .ms1001-portal-link strong {
    font-size: clamp(22px, 2.4vw, 30px) !important;
  }
  body.portal-cuhk #ms1001-chrome .is-cuhk-two-row .ms1001-portal-link img {
    width: 48px;
    height: 48px;
  }
}

/* True phone: brand optically centered; admin stays in header, not bottom dock */
@media (max-width: 760px) {
  body.portal-cuhk #ms1001-chrome .ms1001-chrome-unified.is-cuhk-two-row .ms1001-chrome-primary {
    display: none !important;
  }
  body.portal-cuhk #ms1001-chrome .ms1001-chrome-unified.is-cuhk-two-row .ms1001-chrome-utility {
    position: relative;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px 10px;
    padding: 10px 0 8px;
  }
  body.portal-cuhk #ms1001-chrome .ms1001-menu-btn {
    position: absolute;
    left: 0;
    top: 10px;
    z-index: 2;
  }
  body.portal-cuhk #ms1001-chrome .ms1001-chrome-unified.is-cuhk-two-row .ms1001-chrome-brand-group {
    flex: 0 1 auto;
    justify-content: center;
    margin: 0 auto;
    padding: 0 44px;
  }
  body.portal-cuhk #ms1001-chrome .ms1001-chrome-unified.is-cuhk-two-row .ms1001-chrome-utility-end {
    display: flex !important;
    flex: 1 1 100%;
    width: 100%;
    margin-left: 0;
    justify-content: center;
    order: 5;
    gap: 8px;
  }
  body.portal-cuhk #ms1001-chrome .ms1001-utility-nav,
  body.portal-cuhk #ms1001-chrome .ms1001-chrome-actions {
    display: none !important;
  }
  body.portal-cuhk #ms1001-chrome .ms1001-portal-admin.is-visible {
    display: inline-flex !important;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 100%;
    gap: 6px 8px;
  }
  body.portal-cuhk #ms1001-chrome .is-cuhk-two-row .ms1001-portal-admin .ms1001-admin-tool,
  body.portal-cuhk #ms1001-chrome .is-cuhk-two-row .ms1001-portal-admin .ghost-btn,
  body.portal-cuhk #ms1001-chrome .is-cuhk-two-row .ms1001-portal-admin .ms1001-admin-save,
  body.portal-cuhk #ms1001-chrome .is-cuhk-two-row .ms1001-portal-admin .primary-btn {
    font-size: 13px !important;
    padding: 6px 10px !important;
  }
  body.portal-cuhk #ms1001-chrome .is-cuhk-two-row .ms1001-portal-link strong {
    font-size: clamp(20px, 5.2vw, 26px) !important;
    text-align: center;
  }
  body.portal-cuhk .adminbar:not(.is-edit-dock) {
    display: none !important;
  }
}
