/* Protected module content stays hidden from first paint until identity and permissions pass. */
html[data-portal-booting] body [data-portal-module] { visibility: hidden !important; }

/* All portal rules are scoped; standalone reader/workbench styling is unchanged. */
.portal-page, .has-portal-shell {
  --portal-top: calc(58px + env(safe-area-inset-top, 0px));
  --portal-bottom: 0px;
  --ui-brand: #123f35;
  --ui-primary: #155846;
  --ui-primary-hover: #0f4336;
  --ui-primary-soft: #e8f0eb;
  --ui-canvas: #f5f6f2;
  --ui-surface: #fff;
  --ui-paper: #fbf8f1;
  --ui-text: #1d2c27;
  --ui-text-muted: #52665d;
  --ui-border: #d9e1db;
  --ui-control-border: #7a8d83;
  --ui-danger: #b42318;
  --ui-warning: #8a5a00;
}
.portal-page { margin: 0; background: var(--ui-canvas); color: var(--ui-text); font: 15px/1.6 system-ui, "PingFang SC", sans-serif; }
.portal-page *, .portal-shell *, .portal-bottom *, .portal-module-error * { box-sizing: border-box; }
.portal-page a, .portal-module-error a { color: var(--ui-primary); text-underline-offset: 3px; }
.portal-page h1 { font-size: clamp(26px, 4vw, 36px); line-height: 1.2; margin: 8px 0 18px; }
.portal-page h2 { font-size: 20px; line-height: 1.4; }
.portal-eyebrow { color: #477767; letter-spacing: .14em; font-size: 12px; margin: 0; }
.portal-muted { color: var(--ui-text-muted); font-size: 14px; }
.portal-error { color: var(--ui-danger); min-height: 1.5em; overflow-wrap: anywhere; }
.portal-page button, .portal-page input, .portal-shell button, .portal-module-error button { font: inherit; }
.portal-page button, .portal-module-error button { min-height: 44px; padding: 8px 15px; color: var(--ui-primary); background: var(--ui-surface); border: 1px solid var(--ui-control-border); border-radius: 8px; cursor: pointer; }
.portal-page button:not(:disabled):hover, .portal-module-error button:not(:disabled):hover { background: var(--ui-primary-soft); }
.portal-page button:disabled, .portal-shell button:disabled { opacity: .55; cursor: wait; }
.portal-page .portal-primary { background: var(--ui-primary); color: #fff; border-color: var(--ui-primary); }
.portal-page .portal-primary:not(:disabled):hover { background: var(--ui-primary-hover); border-color: var(--ui-primary-hover); }
.portal-page :is(a, button, input, select, summary):focus-visible, .portal-shell :is(a, button, select, summary):focus-visible, .portal-bottom a:focus-visible { outline: 2px solid var(--ui-primary); outline-offset: 2px; }
.portal-page label { display: grid; gap: 6px; margin: 16px 0; font-weight: 550; }
.portal-page input:not([type="checkbox"]) { width: 100%; min-width: 0; min-height: 46px; border: 1px solid var(--ui-control-border); border-radius: 8px; background: var(--ui-surface); color: var(--ui-text); padding: 9px 12px; }
.portal-page .portal-check { display: flex; align-items: center; gap: 9px; margin: 10px 0; }
.portal-check input { width: 19px; height: 19px; accent-color: #255f4e; }
.portal-page fieldset { border: 1px solid #becbc0; border-radius: 8px; margin: 20px 0; }
.portal-auth-page { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px max(24px, env(safe-area-inset-bottom)); }
.portal-card { width: min(100%, 460px); padding: clamp(24px, 5vw, 40px); background: #fffef8; border: 1px solid #d4dacc; border-radius: 18px; box-shadow: 0 15px 50px #24392c0b; }
.portal-card form > button { width: 100%; margin-bottom: 18px; }
.has-portal-shell { padding-top: var(--portal-top); padding-bottom: var(--portal-bottom); }
.portal-shell { position: fixed; z-index: 1000; inset: 0 0 auto; height: var(--portal-top); display: flex; align-items: center; gap: 8px; padding: env(safe-area-inset-top, 0px) max(12px, env(safe-area-inset-right, 0px)) 0 max(12px, env(safe-area-inset-left, 0px)); background: var(--ui-brand); border-bottom: 1px solid #30594d; color: #fff; font: 14px/1.4 system-ui, "PingFang SC", sans-serif; }
.portal-shell-search-slot { display: flex; flex: 1 1 420px; align-items: center; min-width: 0; max-width: none; margin: 0; }
.has-portal-shell[data-portal-active-module] .portal-shell-search-slot > form.portal-search-form { display: flex; flex: 1 1 auto; align-items: center; gap: 6px; width: auto; min-width: 0; max-width: none; margin: 0; padding: 0; }
.has-portal-shell[data-portal-active-module] .portal-search-form :is(select,input,button) { height: 40px; min-height: 40px; border: 1px solid var(--ui-control-border); border-radius: 8px; background: var(--ui-surface); color: var(--ui-text); font: 14px/1.4 system-ui, "PingFang SC", sans-serif; }
.has-portal-shell[data-portal-active-module] .portal-search-form select { width: min(30%, 185px); min-width: 84px; padding: 5px 7px; }
.has-portal-shell[data-portal-active-module] .portal-search-form input[type="search"] { flex: 1 1 160px; min-width: 0; padding: 5px 10px; }
.has-portal-shell[data-portal-active-module] .portal-search-form .library-search-query-wrap { position: relative; flex: 1 1 160px; min-width: 0; }
.has-portal-shell[data-portal-active-module] .portal-search-form .library-search-query-wrap input { width: 100%; }
.has-portal-shell[data-portal-active-module] .portal-search-form button[type="submit"] { flex: none; min-width: 40px; padding: 4px 11px; background: var(--ui-primary); border-color: var(--ui-primary); color: #fff; white-space: nowrap; }
.has-portal-shell[data-portal-active-module] .portal-search-form button[type="submit"]:hover { background: var(--ui-primary-hover); border-color: var(--ui-primary-hover); }
.has-portal-shell[data-portal-active-module] .portal-search-form .library-search-suggestions { position: absolute; top: 100%; left: 0; width: min(360px, 90vw); z-index: 1100; }
.has-portal-shell[data-portal-active-module] .portal-shell .portal-brand,
.has-portal-shell[data-portal-active-module] .portal-shell :is(.portal-modules a,.portal-bookmarks-trigger,.portal-account summary) { color: #faf7ed; }
.has-portal-shell[data-portal-active-module] .portal-shell .portal-brand::before { content: ""; width: 30px; height: 30px; background: url('/library/assets/chronology/art/brand-seal.svg') center/contain no-repeat; flex: none; }
.has-portal-shell[data-portal-active-module] .portal-shell .portal-account-menu :is(a,button) { color: #25323b; }
.portal-library-search { display: flex; flex: 1 1 360px; align-items: center; gap: 6px; min-width: 220px; max-width: 720px; }
.portal-library-search input, .portal-library-search select { min-width: 0; min-height: 44px; padding: 7px 9px; border: 1px solid var(--ui-control-border); border-radius: 8px; background: var(--ui-surface); color: var(--ui-text); font: inherit; }
.portal-library-search input { flex: 1; }
.portal-library-search select { max-width: 145px; }
.portal-library-search button { min-height: 44px; padding: 7px 11px; border: 1px solid var(--ui-primary); border-radius: 8px; color: #fff; background: var(--ui-primary); font: inherit; cursor: pointer; white-space: nowrap; }
.portal-library-search button:hover { background: var(--ui-primary-hover); border-color: var(--ui-primary-hover); }
.has-portal-shell.portal-has-library-search { --portal-top: calc(58px + env(safe-area-inset-top, 0px)); }
.portal-shell a, .portal-bottom a { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 8px 12px; color: #35594b; text-decoration: none; border-radius: 8px; white-space: nowrap; }
.portal-bookmarks-trigger, .portal-reader-bookmark-save { min-width: 44px; min-height: 44px; padding: 8px 12px; border: 0; border-radius: 8px; color: #35594b; background: transparent; cursor: pointer; }
.portal-reader-bookmark-save { border: 1px solid #9daf9f; background: #fffdf6; font-weight: 700; }
.portal-reader-bookmark-save:disabled { opacity: .55; cursor: not-allowed; }
.portal-shell .portal-brand { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; font-weight: 700; font-size: 16px; letter-spacing: .03em; }
.portal-shell a[aria-current], .portal-bottom a[aria-current] { background: var(--ui-primary-soft); color: var(--ui-primary); font-weight: 700; }
.portal-modules { display: flex; gap: 4px; }
.portal-account { position: relative; margin-left: auto; }
.portal-account summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; max-width: min(26vw, 250px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.portal-account-menu { position: absolute; top: calc(100% + 8px); right: 0; width: min(290px, calc(100vw - 32px)); max-height: calc(100dvh - var(--portal-top) - var(--portal-bottom) - 20px); overflow: auto; padding: 16px; border: 1px solid #bdcbbb; border-radius: 12px; background: #fffdf6; box-shadow: 0 15px 40px #1b372d22; }
.portal-account-menu p { margin: 4px 0 12px; overflow-wrap: anywhere; }
.portal-account-menu a, .portal-account-menu button { display: flex; width: 100%; justify-content: flex-start; min-height: 44px; border: 0; border-radius: 8px; background: transparent; color: #274f40; padding: 10px; cursor: pointer; }
.portal-account-menu a:hover, .portal-account-menu button:hover { background: #edf0e7; }
.portal-bottom { display: none; }
.portal-home, .portal-admin { max-width: 1440px; margin: auto; padding: clamp(24px, 5vw, 56px) clamp(16px, 4vw, 48px); }
.portal-home-modules { display: flex; flex-wrap: wrap; gap: 20px; margin: 32px 0 56px; }
.portal-home-modules a { flex: 1; min-width: 180px; padding: 32px; border: 1px solid #c0cdbc; border-radius: 16px; font-size: 22px; text-decoration: none; background: #fffdf5; }
.portal-reporting { margin: 28px 0; }
.portal-reporting .portal-home-modules { margin: 12px 0 24px; }
.portal-reporting .portal-home-modules article { flex: 1; min-width: 140px; display: grid; gap: 4px; padding: 18px; border: 1px solid #c0cdbc; border-radius: 12px; background: #fffdf5; }
.portal-reporting .portal-home-modules strong { color: #225847; font-size: 26px; }
.portal-reporting .portal-home-modules span { color: #5b6b62; }
.portal-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.portal-table-scroll { width: 100%; overflow: auto; border: 1px solid #c5cebf; border-radius: 12px; background: #fffef7; }
.portal-table { width: 100%; border-collapse: collapse; text-align: left; }
.portal-table th, .portal-table td { padding: 14px; vertical-align: top; border-bottom: 1px solid #e0e4d9; overflow-wrap: anywhere; min-width: 90px; max-width: 280px; }
.portal-table th { background: #eaf0e3; white-space: nowrap; }
.portal-row-actions { min-width: 255px !important; }
.portal-row-actions button { margin: 0 4px 6px 0; font-size: 13px; }
.portal-dialog { width: min(480px, calc(100vw - 32px)); max-height: calc(100dvh - 40px); padding: 28px; border: 1px solid #9dac99; border-radius: 14px; color: #29483b; background: #fffef7; overflow: auto; }
.portal-dialog::backdrop { background: #112a2377; }
.portal-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 20px; }
.portal-credentials { margin: 24px 0; padding: 24px; border: 2px solid #b28632; border-radius: 12px; background: #fff5d7; overflow-wrap: anywhere; }
.portal-credentials code { display: block; font-size: 22px; user-select: all; margin: 16px 0; }
.portal-credentials button { margin-right: 10px; }
.portal-module-error { position: relative; z-index: 100; margin: 18px; padding: 24px; border: 1px solid #a58245; border-radius: 12px; background: #fff9e9; color: #523b21; font: 15px/1.6 system-ui, sans-serif; }
.portal-module-error a { display: inline-block; margin-right: 20px; }
.portal-bookmarks-dialog { width: min(460px, calc(100vw - 28px)); max-height: min(70dvh, 620px); border: 1px solid #9dac99; border-radius: 14px; padding: 22px; background: #fffef7; color: #29483b; }
.portal-bookmarks-dialog::backdrop { background: #112a2377; }
.portal-bookmarks-list { display: grid; gap: 10px; padding-left: 22px; }
.portal-bookmarks-list li { padding: 8px 0; border-bottom: 1px solid #e0e4d9; }
.portal-bookmarks-list a { display: inline; color: #246859; overflow-wrap: anywhere; }
.portal-bookmarks-list button { float: right; min-height: 44px; margin-left: 12px; }
.portal-bookmarks-dialog > button:last-child { min-height: 44px; min-width: 44px; }
.has-portal-shell [data-portal-module] > [hidden] { display: none !important; }
.has-portal-shell[data-portal-active-module="atlas"] .workbench-shell { top: var(--portal-top); bottom: var(--portal-bottom); height: calc(100dvh - var(--portal-top) - var(--portal-bottom)); }
.has-portal-shell[data-portal-active-module="atlas"] .right-tools { max-height: calc(100% - 18px); overflow-y: auto; overscroll-behavior: contain; grid-auto-rows: max-content; scrollbar-width: thin; }
@media (max-width: 960px) {
  .has-portal-shell[data-portal-active-module="atlas"] .workbench-shell { min-width: 0; }
  .has-portal-shell[data-portal-active-module="atlas"] .model-panel { top: var(--portal-top); bottom: var(--portal-bottom); }
}
.has-portal-shell[data-portal-active-module="atlas"] .workbench-shell > .portal-module-error { position: absolute; inset: 10px 10px auto; }
.has-portal-shell[data-portal-active-module="library"] .workspace-drawer-bar { top: var(--portal-top); }
.has-portal-shell[data-portal-active-module="herbs"] .herb-directory { top: calc(var(--portal-top) + 14px); }
.has-portal-shell .herb-standalone-back { display: none; }
@media (max-width: 720px) {
  .has-portal-shell.portal-has-library-search { --portal-top: calc(112px + env(safe-area-inset-top, 0px)); }
  .has-portal-shell { --portal-bottom: calc(64px + env(safe-area-inset-bottom, 0px)); }
  .has-portal-shell.portal-no-modules { --portal-bottom: 0px; }
  .portal-shell { gap: 8px; padding-inline: 16px; }
  .portal-has-library-search .portal-shell { gap: 4px 8px; flex-wrap: wrap; align-content: center; }
  .portal-library-search { order: 5; flex-basis: 100%; max-width: none; }
  .portal-library-search select { max-width: 105px; }
  .portal-modules { display: none; }
  .portal-account summary { max-width: 35vw; }
  .portal-shell > [data-portal-bookmarks] { padding-inline: 8px; }
  .portal-reader-bookmark-save { padding-inline: 8px; }
  .portal-bottom { position: fixed; z-index: 1000; inset: auto 0 0; display: flex; align-items: stretch; justify-content: space-around; height: var(--portal-bottom); padding: 4px max(8px, env(safe-area-inset-right, 0px)) calc(4px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px)); border-top: 1px solid #becbbf; background: #fcfaf3; font: 13px/1.3 system-ui, sans-serif; }
  .portal-bottom a { flex: 1; padding: 8px; }
  .has-portal-shell[data-portal-active-module="library"] .reader-floating-dock { bottom: calc(var(--portal-bottom) + 10px); }
  .has-portal-shell[data-portal-active-module="library"] .reader-shell:has(.reader-floating-dock) { padding-bottom: calc(14rem + var(--portal-bottom)); scroll-padding-bottom: calc(14rem + var(--portal-bottom)); }
  .has-portal-shell[data-portal-active-module="atlas"] .workbench-shell { min-width: 0; }
  .has-portal-shell[data-portal-active-module="atlas"] .model-panel { top: var(--portal-top); bottom: var(--portal-bottom); }
  .has-portal-shell[data-portal-active-module="atlas"] .right-tools { top: 9px; max-height: calc(100% - 18px); overflow-y: auto; overscroll-behavior: contain; grid-auto-rows: max-content; scrollbar-width: thin; }
  .portal-heading > div:last-child { display: flex; flex-wrap: wrap; gap: 8px; }
}

/* One compact, persistent header across classics, anatomy and herb atlas. */
.has-portal-shell[data-portal-active-module] { --portal-top: calc(58px + env(safe-area-inset-top, 0px)); }
.has-portal-shell[data-portal-active-module] .portal-shell {
  box-sizing: border-box;
  height: var(--portal-top);
  flex-wrap: nowrap;
  gap: 8px;
  background: var(--ui-brand);
  color: #faf7ed;
}
.has-portal-shell[data-portal-active-module] .portal-shell-search-slot {
  order: 0;
  flex: 1 1 360px;
  max-width: none;
  margin: 0;
}
.has-portal-shell[data-portal-active-module] .portal-shell .portal-brand,
.has-portal-shell[data-portal-active-module] .portal-modules a,
.has-portal-shell[data-portal-active-module] .portal-bookmarks-trigger,
.has-portal-shell[data-portal-active-module] .portal-account summary { color: #faf7ed; }
.has-portal-shell[data-portal-active-module] .portal-shell .portal-brand::before {
  content: "";
  width: 30px;
  height: 30px;
  background: url('/library/assets/chronology/art/brand-seal.svg') center/contain no-repeat;
  flex: none;
}
.has-portal-shell[data-portal-active-module] .portal-account-menu :is(a,button) { color: #25323b; }
.has-portal-shell[data-portal-active-module] .portal-bottom { background: var(--ui-brand); border-top-color: #30594d; }
.has-portal-shell[data-portal-active-module] .portal-bottom a:not([aria-current]) { color: #faf7ed; }

@media (max-width: 1023px) {
  .has-portal-shell[data-portal-active-module] .portal-shell { gap: 6px; padding-inline: 10px; }
  .has-portal-shell[data-portal-active-module] .portal-shell-search-slot { flex: 1 1 240px; min-width: 0; }
}
@media (max-width: 720px) {
  .has-portal-shell[data-portal-active-module] .portal-modules { display: none; }
  .has-portal-shell[data-portal-active-module] .portal-shell { gap: 5px; }
  .has-portal-shell[data-portal-active-module] .portal-shell .portal-brand { font-size: 0; }
  .has-portal-shell[data-portal-active-module] .portal-account summary { max-width: 35px; min-width: 35px; padding-inline: 8px; }
  .has-portal-shell[data-portal-active-module] .portal-shell > [data-portal-bookmarks] { min-width: 35px; padding-inline: 7px; font-size: 0; }
  .has-portal-shell[data-portal-active-module] .portal-shell > [data-portal-bookmarks]::before { content: '☆'; font-size: 21px; }
  .has-portal-shell[data-portal-active-module] .portal-shell-search-slot > form.portal-search-form { display: flex; gap: 4px; }
  .has-portal-shell[data-portal-active-module] .portal-search-form button[type="submit"] { width: 40px; min-width: 40px; padding-inline: 6px; font-size: 0; }
  .has-portal-shell[data-portal-active-module] .portal-search-form button[type="submit"]::before { content: '⌕'; font-size: 20px; }
  .has-portal-shell[data-portal-active-module] .portal-search-form select { width: clamp(70px, 27%, 110px); min-width: 70px; max-width: 110px; }
}
@media (max-width: 375px) {
  .has-portal-shell[data-portal-active-module] .portal-shell { gap: 3px; padding-inline: 6px; }
  .has-portal-shell[data-portal-active-module] .portal-search-form select { width: 66px; min-width: 66px; }
}

/* Shared product canvas: one warm-paper UI across classics, anatomy and materia medica.
   The anatomy viewport and its floating controls intentionally keep their dark contrast. */
:root {
  --weiyi-page: #f4f0e7;
  --weiyi-surface: #fcfaf5;
  --weiyi-surface-muted: #f2eee5;
  --weiyi-border: #ded7c9;
  --weiyi-ink: #283039;
  --weiyi-muted: #716e68;
  --weiyi-link: #416270;
  --weiyi-accent: #984b40;
  --weiyi-accent-soft: #ede0d7;
  --weiyi-green: #496b54;
  --weiyi-serif: "Songti SC", "STSong", "Noto Serif CJK SC", "SimSun", serif;
  --weiyi-sans: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
}

body.has-portal-shell[data-portal-active-module] {
  color: var(--weiyi-ink);
  font-family: var(--weiyi-sans);
  color-scheme: light;
}

body.has-portal-shell[data-portal-active-module="library"] {
  background-color: var(--weiyi-page);
  color: var(--weiyi-ink);
}

body.has-portal-shell[data-portal-active-module="library"] .library-page {
  color: var(--weiyi-ink);
  background: var(--weiyi-surface);
  font-family: var(--weiyi-sans);
}

body.has-portal-shell[data-portal-active-module="library"] .library-header h1 {
  color: var(--weiyi-ink);
  font-family: var(--weiyi-serif);
}

body.has-portal-shell[data-portal-active-module="atlas"] .workbench-shell {
  color: var(--weiyi-ink);
  background: var(--weiyi-page);
}

body.has-portal-shell[data-portal-active-module="atlas"] .module-rail,
body.has-portal-shell[data-portal-active-module="atlas"] .model-panel {
  color: var(--weiyi-ink);
  background: var(--weiyi-surface);
  border-color: var(--weiyi-border);
}

body.has-portal-shell[data-portal-active-module="atlas"] .module-link {
  color: var(--weiyi-muted);
  border-radius: 8px;
}

body.has-portal-shell[data-portal-active-module="atlas"] .module-link:hover,
body.has-portal-shell[data-portal-active-module="atlas"] .module-link.is-active {
  color: var(--weiyi-green);
  background: #e8ece4;
}

body.has-portal-shell[data-portal-active-module="atlas"] .module-link.is-active span {
  color: #fff;
  background: var(--weiyi-green);
}

body.has-portal-shell[data-portal-active-module="atlas"] .panel-header h1 {
  color: var(--weiyi-ink);
  font: 650 19px/1.4 var(--weiyi-serif);
}

body.has-portal-shell[data-portal-active-module="atlas"] .model-panel .eyebrow {
  color: var(--weiyi-green);
}

body.has-portal-shell[data-portal-active-module="atlas"] .draft-badge {
  color: #6f5730;
  border-color: #d8c89f;
  background: #f1ead7;
}

body.has-portal-shell[data-portal-active-module="atlas"] .panel-section {
  border-color: var(--weiyi-border);
}

body.has-portal-shell[data-portal-active-module="atlas"] .section-title {
  color: var(--weiyi-ink);
}

body.has-portal-shell[data-portal-active-module="atlas"] :is(.revision-label, .layer-state, .range-control, .more-panel label, .panel-note) {
  color: var(--weiyi-muted);
}

body.has-portal-shell[data-portal-active-module="atlas"] .search-trigger {
  color: var(--weiyi-muted);
  background: var(--weiyi-surface-muted);
  border-color: var(--weiyi-border);
  border-radius: 8px;
}

body.has-portal-shell[data-portal-active-module="atlas"] kbd {
  color: var(--weiyi-green);
  background: #e8ece4;
  border-color: #cbd3c5;
}

body.has-portal-shell[data-portal-active-module="atlas"] .sex-switch {
  background: #ede9df;
}

body.has-portal-shell[data-portal-active-module="atlas"] .sex-button {
  color: var(--weiyi-muted);
  border-radius: 6px;
}

body.has-portal-shell[data-portal-active-module="atlas"] .sex-button.is-active {
  color: #fff;
  background: var(--weiyi-green);
}

body.has-portal-shell[data-portal-active-module="atlas"] .layer-row {
  color: #46524b;
  border-radius: 7px;
}

body.has-portal-shell[data-portal-active-module="atlas"] .layer-row:hover {
  background: #f0eee7;
}

body.has-portal-shell[data-portal-active-module="atlas"] input[type="range"] {
  accent-color: var(--weiyi-green);
}

body.has-portal-shell[data-portal-active-module="atlas"] .layer-mode-switch button {
  color: var(--weiyi-muted);
  border-color: var(--weiyi-border);
  background: var(--weiyi-surface);
  border-radius: 8px;
}

body.has-portal-shell[data-portal-active-module="atlas"] .layer-mode-switch button.is-active {
  color: var(--weiyi-green);
  border-color: #a9baa4;
  background: #e8ece4;
}

body.has-portal-shell[data-portal-active-module="atlas"] .muscle-inspector {
  color: var(--weiyi-ink);
  border-color: #c8d4c3;
  background: #edf0e8;
}

body.has-portal-shell[data-portal-active-module="atlas"] .muscle-inspector-label {
  color: var(--weiyi-muted);
}

body.has-portal-shell[data-portal-active-module="atlas"] .muscle-inspector strong {
  color: var(--weiyi-ink);
}

body.has-portal-shell[data-portal-active-module="atlas"] .muscle-actions button {
  color: #46524b;
  background: var(--weiyi-surface);
  border-color: var(--weiyi-border);
  border-radius: 7px;
}

body.has-portal-shell[data-portal-active-module="atlas"] .inline-warning {
  color: #6b5430;
  border-left-color: #b79558;
  background: #f4efe3;
}

body.has-portal-shell[data-portal-active-module="atlas"] .model-panel :is(button, input, select, textarea) {
  font-family: var(--weiyi-sans);
}

body.has-portal-shell[data-portal-active-module="atlas"] .model-panel :is(button, input, select, textarea):focus-visible {
  outline-color: #936924;
}

body.has-portal-shell[data-portal-active-module="atlas"] .viewport-stage {
  /* Preserve the dark contrast needed for 3D anatomy and its floating tools. */
  color-scheme: dark;
}

body.has-portal-shell[data-portal-active-module="herbs"] {
  color-scheme: light;
  background: var(--weiyi-page);
  color: var(--weiyi-ink);
}

body.has-portal-shell[data-portal-active-module="herbs"] .herb-gallery {
  --herb-bg: var(--weiyi-page);
  --herb-text: var(--weiyi-ink);
  --herb-muted: var(--weiyi-muted);
  --herb-accent: var(--weiyi-green);
  --herb-line: var(--weiyi-border);
  color: var(--weiyi-ink);
  background: var(--weiyi-page);
  font-family: var(--weiyi-sans);
  color-scheme: light;
}

body.has-portal-shell[data-portal-active-module="herbs"] .herb-header h1,
body.has-portal-shell[data-portal-active-module="herbs"] .herb-detail-title h2,
body.has-portal-shell[data-portal-active-module="herbs"] .herb-photo-card h3 {
  color: var(--weiyi-ink);
  font-family: var(--weiyi-serif);
}

body.has-portal-shell[data-portal-active-module="herbs"] .herb-directory,
body.has-portal-shell[data-portal-active-module="herbs"] .herb-photo-card,
body.has-portal-shell[data-portal-active-module="herbs"] .herb-image-dialog {
  color: var(--weiyi-ink);
  background: var(--weiyi-surface);
  border-color: var(--weiyi-border);
}

body.has-portal-shell[data-portal-active-module="herbs"] .herb-search {
  color: var(--weiyi-ink);
  background: #fffefa;
  border-color: #c8cfc3;
}

body.has-portal-shell[data-portal-active-module="herbs"] .herb-search::placeholder {
  color: #77766f;
}

body.has-portal-shell[data-portal-active-module="herbs"] .herb-alphabet button,
body.has-portal-shell[data-portal-active-module="herbs"] .herb-result {
  color: #46524b;
}

body.has-portal-shell[data-portal-active-module="herbs"] .herb-alphabet button[aria-pressed="true"],
body.has-portal-shell[data-portal-active-module="herbs"] .herb-result[aria-pressed="true"] {
  color: var(--weiyi-green);
  border-color: #a9baa4;
  background: #e8ece4;
}

body.has-portal-shell[data-portal-active-module="herbs"] .herb-result:hover,
body.has-portal-shell[data-portal-active-module="herbs"] .herb-alphabet button:hover {
  background: #f0eee7;
}

body.has-portal-shell[data-portal-active-module="herbs"] .herb-photo-card,
body.has-portal-shell[data-portal-active-module="herbs"] .herb-directory,
body.has-portal-shell[data-portal-active-module="herbs"] .herb-image-dialog {
  border-radius: 8px;
}

body.has-portal-shell[data-portal-active-module="herbs"] .herb-gallery a {
  color: var(--weiyi-link);
}

body.has-portal-shell[data-portal-active-module="herbs"] .herb-stage-title {
  color: var(--weiyi-green);
  border-bottom-color: var(--weiyi-border);
}

body.has-portal-shell[data-portal-active-module="herbs"] :is(.herb-photo-facts dt, .herb-evidence summary, .herb-evidence) {
  color: var(--weiyi-muted);
}

body.has-portal-shell[data-portal-active-module="herbs"] .herb-image-button {
  background: #eeece4;
}

body.has-portal-shell[data-portal-active-module="herbs"] .herb-image-hint {
  color: #fff;
  background: var(--weiyi-green);
}

body.has-portal-shell[data-portal-active-module="herbs"] .herb-no-photo,
body.has-portal-shell[data-portal-active-module="herbs"] .herb-empty {
  color: var(--weiyi-muted);
  border-color: var(--weiyi-border);
  background: var(--weiyi-surface-muted);
}

body.has-portal-shell[data-portal-active-module="herbs"] .herb-gallery :is(button, input, select) {
  font-family: var(--weiyi-sans);
  border-radius: 8px;
}

body.has-portal-shell[data-portal-active-module="herbs"] .herb-gallery :is(button, input, select):focus-visible {
  outline-color: #936924;
}

/* One consistent frame for every shared-header action; active module remains visibly selected. */
.portal-shell :is(.portal-modules > a, [data-portal-bookmarks], .portal-account > summary) {
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  height: 44px;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid #7b998b;
  border-radius: 8px;
  color: #faf7ed;
  background: transparent;
  font: 500 14px/1.4 system-ui, "PingFang SC", sans-serif;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.portal-shell .portal-account > summary {
  max-width: min(26vw, 250px);
  overflow: hidden;
  text-overflow: ellipsis;
  list-style: none;
}
.portal-shell .portal-account > summary::-webkit-details-marker { display: none; }
.portal-shell .portal-modules > a[aria-current="page"] {
  color: var(--ui-primary);
  background: var(--ui-primary-soft);
  font-weight: 700;
}
.portal-shell :is(.portal-modules > a, [data-portal-bookmarks], .portal-account > summary):hover {
  background: #285c4c;
}
.portal-shell .portal-modules > a[aria-current="page"]:hover { background: var(--ui-primary-soft); }
.has-portal-shell[data-portal-active-module] .portal-shell .portal-modules > a[aria-current="page"] {
  color: var(--ui-primary);
}
