/* Final cascade layer: loaded after all page-specific styles. */

/* The source files contain wide wordmarks; keep only the mark and center its
   visible crop in the 62px artwork cell to the left of the divider. */
.institution-logo-nju img {
  inset: 50% auto auto 14px !important;
  transform: translateY(-50%) !important;
  transform-origin: center !important;
  transition: opacity 140ms ease !important;
}

.institution-logo-shlab img {
  inset: 50% auto auto 1px !important;
  width: 50px !important;
  height: 30px !important;
  object-fit: contain !important;
  object-position: center !important;
  clip-path: none !important;
  transform: translateY(-50%) !important;
  transform-origin: center !important;
  transition: opacity 140ms ease !important;
}

/* The source CASIA image also contains a light wordmark that becomes visible
   on dark cards. Crop to the emblem portion before centering it. */
.institution-logo-casia img {
  inset: 50% auto auto 5px !important;
  width: auto !important;
  max-width: none !important;
  height: 42px !important;
  object-fit: initial !important;
  object-position: left center !important;
  clip-path: inset(0 calc(100% - 40px) 0 0) !important;
  transform: translateY(-50%) !important;
  transform-origin: center !important;
  transition: opacity 140ms ease !important;
}

.institution-card:hover .institution-logo-nju img {
  transform: translateY(-50%) !important;
}

.institution-card:hover .institution-logo-shlab img {
  transform: translateY(-50%) !important;
}

.institution-card:hover .institution-logo-casia img {
  transform: translateY(-50%) !important;
}

html[data-theme="nocturne"] body .institution-logo-shlab img,
html[data-theme="nocturne"] body .institution-card:hover .institution-logo-shlab img {
  background: transparent !important;
  filter: none !important;
  mix-blend-mode: normal !important;
}

html[data-theme="nocturne"] {
  color-scheme: dark;
  --theme-strong: #c96f54;
  --theme-strong-hover: #d77d61;
  --theme-accent: #d78368;
  --theme-accent-soft: #2d211f;
}

html[data-theme="nocturne"] body,
html[data-theme="nocturne"] .figma-shell,
html[data-theme="nocturne"] .figma-content {
  background: #080d13 !important;
  color: #f0f4f7 !important;
}

html[data-theme="nocturne"] :is(
  .figma-panel,
  .home-board-card,
  .track-card,
  .flow-grid article,
  .guide-page-map article,
  .dataset-section,
  .rules-panel,
  .rules-mode-section,
  .api-contract-section,
  .leaderboard-main-section,
  .leaderboard-detail-panel,
  .capability-breakdown-panel,
  .capability-chart-card,
  .private-result-card,
  .job-stat,
  .documentation-principle-card,
  .doc-pipeline article,
  .doc-audience-grid article,
  .doc-contract-summary article,
  .doc-contract-block,
  .doc-error-policy article,
  .doc-security-grid article,
  .doc-result-flow article,
  .doc-publication-card,
  .institution-card
) {
  border-color: #293b4a !important;
  background: linear-gradient(145deg, #131d27 0%, #101820 100%) !important;
  color: #f0f4f7 !important;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.2) !important;
}

html[data-theme="nocturne"] :is(
  .active-jobs,
  .current-job-scroll,
  .job-detail,
  .active-job-card,
  .dataset-option,
  .suite-dataset-list,
  .column-selector-menu,
  .empty-state,
  .academic-board-empty,
  .leaderboard-coming-soon,
  .doc-table-wrap,
  .doc-contract-body,
  .doc-field-list,
  .capability-overview-strip,
  .capability-card-foot,
  .capability-bar-card .capability-card-head
) {
  border-color: #263947 !important;
  background: #0d151e !important;
  color: #e6edf1 !important;
}

html[data-theme="nocturne"] :is(input, select, textarea) {
  border-color: #344b5d !important;
  background: #0b131c !important;
  color: #f2f5f7 !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025) !important;
}

html[data-theme="nocturne"] :is(input, textarea)::placeholder {
  color: #718391 !important;
  opacity: 1;
}

html[data-theme="nocturne"] :is(input, select, textarea):focus {
  border-color: #db8063 !important;
  outline: 3px solid rgba(239, 138, 105, 0.18) !important;
  box-shadow: none !important;
}

html[data-theme="nocturne"] :is(input, select, textarea):disabled {
  border-color: #273744 !important;
  background: #121a22 !important;
  color: #778692 !important;
}

html[data-theme="nocturne"] select option {
  background: #101922 !important;
  color: #f0f4f7 !important;
}

html[data-theme="nocturne"] :is(
  h1, h2, h3, h4, strong, label, legend,
  .institution-name strong,
  .capability-card-head h3,
  .doc-section-heading h2
) {
  color: #f0f4f7 !important;
}

html[data-theme="nocturne"] :is(
  p, small, .muted, .hero-description, .section-subtitle,
  .institution-name small, .capability-breakdown-title p,
  .capability-card-foot p, .doc-lead
) {
  color: #a4b0ba !important;
}

html[data-theme="nocturne"] :is(table, .leaderboard-table, .private-results-table, .doc-table) {
  border-color: #293b49 !important;
  background: #101820 !important;
  color: #dce4e9 !important;
}

html[data-theme="nocturne"] :is(thead, thead tr, thead th, .doc-table th) {
  border-color: #344654 !important;
  background: #18242e !important;
  color: #eef3f6 !important;
}

html[data-theme="nocturne"] :is(tbody tr, tbody td, .doc-table td) {
  border-color: #263744 !important;
  background-color: #101820 !important;
  color: #d8e0e5 !important;
}

html[data-theme="nocturne"] tbody tr:hover td {
  background-color: #17242e !important;
}

html[data-theme="nocturne"] :is(
  dialog, .modal, .access-dialog-panel,
  .integration-test-panel, .evaluation-request-panel,
  .theme-menu
) {
  border-color: #344958 !important;
  background: #111a23 !important;
  color: #f0f4f7 !important;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.56) !important;
}

html[data-theme="nocturne"] :is(pre, code, .code-block, .doc-contract-body pre) {
  border-color: #293d4b !important;
  background: #081018 !important;
  color: #dce8ee !important;
}

html[data-theme="nocturne"] .documentation-toc a:hover,
html[data-theme="nocturne"] .documentation-toc a:focus-visible {
  background: #182630 !important;
  color: #f2a188 !important;
}

html[data-theme="nocturne"] :is(.doc-mode-badge.smoke, .doc-method.response) {
  background: #182943 !important;
  color: #9ec6ff !important;
}

html[data-theme="nocturne"] .doc-mode-badge.light {
  background: #382d18 !important;
  color: #efc66c !important;
}

html[data-theme="nocturne"] :is(.doc-mode-badge.full, .doc-method.post) {
  background: #173229 !important;
  color: #81d8b4 !important;
}

html[data-theme="nocturne"] .capability-bar-guides i {
  background: #2c3b47 !important;
}

html[data-theme="nocturne"] .capability-bar-guides i::before,
html[data-theme="nocturne"] .capability-bar-label {
  color: #94a5b2 !important;
}

html[data-theme="nocturne"] .capability-bar-score {
  color: #dce6ed !important;
}

html[data-theme="nocturne"] .capability-radar-rank text {
  stroke: rgba(8, 13, 19, 0.94) !important;
}

html[data-theme="nocturne"] .institution-logo {
  border-right-color: #344653 !important;
}

html[data-theme="nocturne"] .institution-logo img {
  background: #111922 !important;
}

html[data-theme="nocturne"] .site-footer {
  border-top-color: #263744 !important;
  background: #0a1118 !important;
}

html[data-theme="nocturne"] a {
  color: #83b9ee;
}

html[data-theme="nocturne"] a:hover {
  color: #add2f5;
}

/* Leaderboards: remove the remaining light composite-header surfaces. */
html[data-theme="nocturne"] body :is(#home, #public, #multimodel, #coding)
  .leaderboard-table :is(thead, thead tr, thead th),
html[data-theme="nocturne"] body :is(#home, #public, #multimodel, #coding)
  .leaderboard-table thead :is(.leaderboard-head-label, .dataset-group-head, .dataset-metric-head) {
  border-color: #304452 !important;
  background: #16232d !important;
  color: #e5ebef !important;
}

html[data-theme="nocturne"] body :is(#home, #public, #multimodel, #coding)
  .leaderboard-header-sort {
  border-color: #344a59 !important;
  background: #1a2934 !important;
  color: #e6edf1 !important;
  box-shadow: none !important;
}

html[data-theme="nocturne"] body :is(#home, #public, #multimodel, #coding)
  .leaderboard-header-sort:hover {
  border-color: #476071 !important;
  background: #20323f !important;
}

html[data-theme="nocturne"] body :is(#home, #public, #multimodel, #coding)
  :is(.leaderboard-main-section, .home-board-card, .unified-board-frame, .home-preview-content) {
  border-color: #283b49 !important;
  background: #0d161f !important;
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.2) !important;
}

html[data-theme="nocturne"] body :is(#home, #public, #multimodel, #coding)
  .leaderboard-table tbody :is(tr, td) {
  border-color: #253744 !important;
  background: #0d161f !important;
  color: #d9e1e6 !important;
}

html[data-theme="nocturne"] body :is(#home, #public, #multimodel, #coding)
  .leaderboard-table tbody tr:hover td {
  background: #15232d !important;
}

html[data-theme="nocturne"] body .leaderboard-coming-soon {
  background:
    radial-gradient(circle at 50% -18%, rgba(201, 111, 84, 0.1), transparent 38%),
    #0c151e !important;
}

html[data-theme="nocturne"] body .leaderboard-edition-switch {
  border-color: #2c404f !important;
  background: #101b24 !important;
}

html[data-theme="nocturne"] body .leaderboard-edition-switch button {
  color: #aab7c0 !important;
}

html[data-theme="nocturne"] body .leaderboard-edition-switch button:hover {
  background: #182733 !important;
  color: #eef3f6 !important;
}

html[data-theme="nocturne"] body .leaderboard-edition-switch button.active {
  background: #263846 !important;
  color: #f1f5f7 !important;
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.22) !important;
}

/* Evaluation results: use quiet dark panels instead of pale error blocks. */
html[data-theme="nocturne"] body #run .overview-card {
  border-color: #2b3e4c !important;
  background: linear-gradient(145deg, #131f29, #0f1821) !important;
  box-shadow: none !important;
}

html[data-theme="nocturne"] body #run .overview-card::before {
  background: #b96952 !important;
  opacity: 0.75 !important;
}

html[data-theme="nocturne"] body #run .overview-card :is(span, small) {
  color: #9eacb6 !important;
}

html[data-theme="nocturne"] body #run .overview-card strong {
  color: #eef3f6 !important;
}

html[data-theme="nocturne"] body #run :is(.private-table-wrap, .private-table) {
  border-color: #2a3e4c !important;
  background: #0d161f !important;
}

html[data-theme="nocturne"] body #run .private-table :is(thead, thead tr, th) {
  border-color: #304452 !important;
  background: #182732 !important;
  color: #dce5ea !important;
}

html[data-theme="nocturne"] body #run .private-table tbody :is(tr, td) {
  border-color: #253744 !important;
  background: #0d161f !important;
  color: #d7e0e5 !important;
}

html[data-theme="nocturne"] body #run .private-table tbody tr:hover td {
  background: #15232d !important;
}

html[data-theme="nocturne"] body #run .result-failure {
  border-color: #633c3a !important;
  background: #211719 !important;
  box-shadow: none !important;
}

html[data-theme="nocturne"] body #run .result-failure summary {
  background: #2a1c1e !important;
  color: #e9867f !important;
}

html[data-theme="nocturne"] body #run .result-failure pre {
  border-top-color: #573638 !important;
  background: #0b1219 !important;
  color: #d9aaa6 !important;
}

html[data-theme="nocturne"] body .evaluation-error-panel {
  border-color: #4a3437 !important;
  background: #15191f !important;
}

html[data-theme="nocturne"] body .evaluation-error-panel-head {
  border-bottom-color: #35434d !important;
}

html[data-theme="nocturne"] body .evaluation-error-panel-head h4,
html[data-theme="nocturne"] body .evaluation-error-title,
html[data-theme="nocturne"] body .evaluation-error-sentence {
  color: #edf2f5 !important;
}

html[data-theme="nocturne"] body .evaluation-error-panel-head p,
html[data-theme="nocturne"] body .evaluation-error-description {
  color: #aebbc4 !important;
}

html[data-theme="nocturne"] body .evaluation-error-card {
  border-color: #344752 !important;
  background: #111c25 !important;
  box-shadow: none !important;
}

html[data-theme="nocturne"] body .evaluation-error-meta code {
  border-left-color: #344752 !important;
  background: transparent !important;
  color: #b5c1c8 !important;
}

html[data-theme="nocturne"] body .evaluation-error-action {
  background: #19252e !important;
  color: #bdc7cd !important;
}

html[data-theme="nocturne"] body .evaluation-error-action-icon {
  background: #111c25 !important;
}

html[data-theme="nocturne"] body .evaluation-error-technical summary {
  color: #9cabb4 !important;
}

html[data-theme="nocturne"] body .evaluation-error-technical pre,
html[data-theme="nocturne"] body .task-error-detail pre,
html[data-theme="nocturne"] body .error-text pre {
  border-color: #30424e !important;
  background: #0a131a !important;
  color: #c6d0d6 !important;
}

html[data-theme="nocturne"] body .task-error-action {
  background: #252315 !important;
  color: #c5c0a5 !important;
}

html[data-theme="nocturne"] body #run .private-score-error {
  border-color: #5e3c3b !important;
  background: #21181a !important;
  color: #ea8b84 !important;
}

html[data-theme="nocturne"] body #run .private-score-item summary {
  border-color: #334754 !important;
  background: #14212b !important;
  color: #dce5ea !important;
}

html[data-theme="nocturne"] body #run .private-score-title {
  color: #dce5ea !important;
}

html[data-theme="nocturne"] body :is(.status-failed, .status-partial, .status-canceled) {
  border-color: #69403e !important;
  background: #2a1b1d !important;
  color: #ef8f87 !important;
}

html[data-theme="nocturne"] body :is(.status-succeeded, .status-approved) {
  border-color: #315b4c !important;
  background: #172a24 !important;
  color: #76c9a5 !important;
}

html[data-theme="nocturne"] body :is(.status-running, .status-queued, .status-pending) {
  border-color: #685535 !important;
  background: #2b2519 !important;
  color: #d9b86e !important;
}

/* Documentation, API guide, and request dialogs. */
html[data-theme="nocturne"] body #api-guide :is(
  .guide-contract-card,
  .param-table,
  .api-example,
  .api-code-block
) {
  border-color: #2d414f !important;
  background: #101a23 !important;
  color: #dce5ea !important;
}

html[data-theme="nocturne"] body #api-guide .guide-contract-card .card-title-row p {
  color: #a6b3bc !important;
}

html[data-theme="nocturne"] body #api-guide .guide-contract-card :is(pre, code) {
  border-color: #2b3e4b !important;
  background: #091119 !important;
  color: #d5e1e7 !important;
}

html[data-theme="nocturne"] body #api-guide .guide-contract-card .param-table > * {
  border-color: #293b48 !important;
  color: #b8c4cb !important;
}

html[data-theme="nocturne"] body :is(
  .integration-test-success,
  .evaluation-request-test-state.passed,
  .evaluation-request-success
) {
  border-color: #315b4c !important;
  background: #172a24 !important;
  color: #8bd5b4 !important;
}

html[data-theme="nocturne"] body :is(
  .integration-test-error,
  .evaluation-request-test-state.failed
) {
  border-color: #633c3a !important;
  background: #281a1c !important;
  color: #ee9189 !important;
}

html[data-theme="nocturne"] body .evaluation-request-test-state:not(.passed):not(.failed) {
  border-color: #665432 !important;
  background: #2a2418 !important;
  color: #d7b66c !important;
}

/* Footer: keep the moving institution strip visually part of the dark page. */
html[data-theme="nocturne"] body .site-footer {
  border-top-color: #263845 !important;
  background:
    radial-gradient(circle at 12% 0%, rgba(201, 111, 84, 0.08), transparent 30%),
    #0a1118 !important;
  color: #9eabb4 !important;
}

html[data-theme="nocturne"] body .site-footer-heading strong {
  color: #edf2f5 !important;
}

html[data-theme="nocturne"] body .site-footer-links a {
  color: #9db5c6 !important;
}

html[data-theme="nocturne"] body .institution-card {
  border-color: #2c404e !important;
  background: linear-gradient(145deg, #14202a, #101820) !important;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.18) !important;
}

html[data-theme="nocturne"] body .institution-card:hover {
  border-color: #465f70 !important;
  background: linear-gradient(145deg, #182631, #121d26) !important;
  box-shadow: 0 11px 28px rgba(0, 0, 0, 0.25) !important;
}

html[data-theme="nocturne"] body .institution-logo {
  border-right-color: #344854 !important;
}

html[data-theme="nocturne"] body .institution-logo img {
  background: #131f29 !important;
}

html[data-theme="nocturne"] body .institution-name strong {
  color: #e5ebef !important;
}

html[data-theme="nocturne"] body .institution-name small {
  color: #8798a3 !important;
}

/* Keep native scrollbars and focus rings calm in the dark palette. */
html[data-theme="nocturne"] {
  scrollbar-color: #435867 #0b141c;
}

html[data-theme="nocturne"] *:focus-visible {
  outline-color: rgba(215, 131, 104, 0.7);
}

/* Runtime API tables: override the light header cells from the presentation
   layer while retaining the same visual hierarchy as the code examples. */
html[data-theme="nocturne"] body #api-guide .guide-contract-card .param-table b {
  border-color: #304552 !important;
  background: #182631 !important;
  color: #e3eaee !important;
}

html[data-theme="nocturne"] body #api-guide .guide-contract-card .param-table > span:nth-child(3n + 1) {
  color: #c8d3d9 !important;
}

html[data-theme="nocturne"] body #api-guide .guide-contract-card .param-table > span:nth-child(3n + 2) {
  color: #e0e7eb !important;
}

html[data-theme="nocturne"] body #api-guide .guide-contract-card .param-table > span:nth-child(3n) {
  color: #aebbc3 !important;
}

/* Evaluation components are generated after authentication, so use their
   concrete runtime class names instead of the generic panel aliases. */
html[data-theme="nocturne"] body #run :is(.dataset-area, .active-jobs) {
  border-color: #2b404e !important;
  background: #0f1922 !important;
  box-shadow: none !important;
}

html[data-theme="nocturne"] body #run .dataset-item {
  border-color: #304654 !important;
  background: #14212b !important;
  color: #dce5ea !important;
  box-shadow: none !important;
}

html[data-theme="nocturne"] body #run .dataset-item:hover {
  border-color: #486171 !important;
  background: #182833 !important;
  box-shadow: none !important;
}

html[data-theme="nocturne"] body #run .dataset-item:has(input:checked) {
  border-color: #b96751 !important;
  background: #241c1b !important;
  box-shadow: 0 0 0 2px rgba(201, 111, 84, 0.16) !important;
}

html[data-theme="nocturne"] body #run .dataset-copy strong {
  color: #e8eef1 !important;
}

html[data-theme="nocturne"] body #run .dataset-copy small {
  color: #8fa0ab !important;
}

html[data-theme="nocturne"] body #run .active-jobs-head span {
  color: #e8eef1 !important;
}

html[data-theme="nocturne"] body #run .active-jobs-head small {
  color: #9baab4 !important;
}

html[data-theme="nocturne"] body #run .active-job-card,
html[data-theme="nocturne"] body #run .active-job-card.selected {
  border-color: #354b59 !important;
  background: #14212b !important;
  color: #dce5ea !important;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.015) !important;
}

html[data-theme="nocturne"] body #run .active-job-card.selected {
  border-color: #536b79 !important;
  background: #182731 !important;
}

html[data-theme="nocturne"] body #run .active-job-card :is(.mono, small) {
  color: #a7b5be !important;
}

html[data-theme="nocturne"] body #run .current-job-panel .active-job-progress {
  border-color: #334854 !important;
  background: #263641 !important;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35) !important;
}

html[data-theme="nocturne"] body #run :is(
  .run-detail-head,
  .job-actions,
  .summary-card,
  .job-task-wrap,
  .recent-table-wrap
) {
  border-color: #2b404e !important;
  background: #101b24 !important;
  color: #dce5ea !important;
  box-shadow: none !important;
}

html[data-theme="nocturne"] body #run .metadata-strip span {
  border-color: #314754 !important;
  background: #14212b !important;
  color: #9eadb6 !important;
}

html[data-theme="nocturne"] body #run .metadata-strip b {
  color: #e1e8ec !important;
}

html[data-theme="nocturne"] body #run .job-actions span {
  color: #9eadb6 !important;
}

html[data-theme="nocturne"] body #run .summary-card span {
  color: #91a2ad !important;
}

html[data-theme="nocturne"] body #run :is(.summary-card strong, .task-count-metric strong) {
  color: #edf2f5 !important;
}

html[data-theme="nocturne"] body #run .job-task-table {
  background: #0d161f !important;
}

html[data-theme="nocturne"] body #run .job-task-table thead,
html[data-theme="nocturne"] body #run .recent-table thead {
  background: #182732 !important;
}

html[data-theme="nocturne"] body #run :is(.job-task-table, .recent-table) th {
  border-color: #304552 !important;
  background: #182732 !important;
  color: #cbd6dc !important;
}

html[data-theme="nocturne"] body #run :is(.job-task-table, .recent-table) td {
  border-color: #263946 !important;
  background: #0d161f !important;
  color: #d5dee3 !important;
}

/* Brand mark: memory nodes + ascending benchmark levels. */
.intro-brand-logo,
.figma-brand-logo {
  display: block;
  flex: 0 0 auto;
  object-fit: contain;
}

.intro-brand-logo {
  width: 38px;
  height: 38px;
}

.figma-top-nav .figma-brand {
  gap: 10px !important;
}

.figma-brand-logo {
  width: 36px;
  height: 36px;
}

html[data-theme="nocturne"] :is(.intro-brand-logo, .figma-brand-logo) {
  content: url("/static/assets/agent-memory-logo-on-dark.png");
}

@media (max-width: 1120px) {
  .figma-brand-logo {
    width: 32px;
    height: 32px;
  }
}
