.matrix-network-footer,
.matrix-network-panel,
.matrix-network-card,
.matrix-network-copy,
.matrix-network-title,
.matrix-network-meta {
  box-sizing: border-box;
}

:root {
  --matrix-network-footer-height: 54px;
  --matrix-network-footer-safe: env(safe-area-inset-bottom, 0px);
}

/* Fixed footer is an overlay, so normal documents reserve the same amount of
   flow space. The schedules app shell reserves it with .sched-bottom-bar. */
body:has(> .matrix-network-footer) {
  padding-bottom: calc(var(--matrix-network-footer-height) + var(--matrix-network-footer-safe));
}

/* One compact site footer: matrix on the left, attribution and ICP on the right. */
.matrix-network-footer {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 900;
  width: 100%;
  height: calc(var(--matrix-network-footer-height) + var(--matrix-network-footer-safe));
  display: grid;
  grid-template-columns: minmax(576px, 648px) minmax(300px, 1fr);
  align-items: center;
  column-gap: clamp(14px, 2vw, 28px);
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pinch-zoom;
  scrollbar-width: none;
  scroll-padding-inline: 10px;
  -webkit-user-select: none;
  user-select: none;
  padding: 3px clamp(18px, 3vw, 40px) calc(3px + var(--matrix-network-footer-safe));
  scroll-snap-align: end;
  scroll-snap-stop: always;
  border-top: 1px solid rgba(176, 170, 158, .28);
  border-bottom: 1px solid rgba(176, 170, 158, .12);
  background: rgba(250, 248, 242, .96);
  box-shadow: 0 -10px 28px rgba(48, 43, 34, .05);
  backdrop-filter: blur(14px) saturate(1.04);
  color: #101822;
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

.matrix-network-footer::-webkit-scrollbar { display: none; }

/* Historical stand-alone footers are superseded by the integrated matrix footer. */
body:has(.matrix-network-footer) footer:not(.hero-actions),
body:has(.matrix-network-footer) > .site-icp,
.sched-bottom-bar > .site-icp {
  display: none !important;
}

.matrix-network-panel {
  width: 100%;
  max-width: 648px;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: stretch;
}

.matrix-network-card {
  --matrix-accent: #b4832a;
  min-width: 0;
  min-height: 46px;
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-content: center;
  row-gap: 1px;
  overflow: hidden;
  padding: 2px clamp(6px, .8vw, 11px) 3px;
  border-left: 1px solid rgba(176, 170, 158, .22);
  background: transparent;
  text-decoration: none;
  -webkit-user-drag: none;
  color: inherit;
  transition: background .18s ease, color .18s ease;
}

.matrix-network-card:first-child { border-left: 0; }

.matrix-network-card::before {
  content: attr(data-tag);
  grid-column: 1;
  grid-row: 1;
  color: color-mix(in srgb, var(--matrix-accent) 78%, #6f6a60);
  font-size: 8.5px;
  font-weight: 720;
  letter-spacing: .045em;
  line-height: 1;
  white-space: nowrap;
}

.matrix-network-card:hover {
  background: color-mix(in srgb, var(--matrix-accent) 8%, transparent);
}

.matrix-network-drift { --matrix-accent: #9d2233; }
.matrix-network-crux { --matrix-accent: #66703f; }
.matrix-network-nexus { --matrix-accent: #b4832a; }
.matrix-network-locus { --matrix-accent: #087d62; }

.matrix-network-copy {
  grid-column: 1;
  grid-row: 2;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: 1px;
}

.matrix-network-title {
  width: 100%;
  height: 18px;
  display: flex;
  align-items: center;
  min-width: 0;
}

.matrix-network-title img {
  width: auto;
  height: 18px;
  max-width: 100%;
  display: block;
  object-fit: contain;
  object-position: left center;
  pointer-events: none;
  -webkit-user-drag: none;
}

.matrix-network-drift .matrix-network-title,
.matrix-network-drift .matrix-network-title img {
  height: 20px;
}

.matrix-network-sub {
  min-width: 0;
  max-width: 100%;
  color: #818d92;
  font-size: 9px;
  font-weight: 580;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.matrix-network-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  padding-left: clamp(14px, 2vw, 28px);
  border-left: 1px solid rgba(176, 170, 158, .18);
  color: #9b9288;
  font-size: 10px;
  line-height: 1.45;
  text-align: right;
  white-space: nowrap;
}

.matrix-network-meta b { color: #766f66; font-weight: 650; }
.matrix-network-meta a {
  color: #9b9288;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 9px;
  opacity: .62;
  text-decoration: none;
}
.matrix-network-meta a:hover { color: #607148; opacity: 1; }

@media (max-width: 1100px) {
  .matrix-network-footer {
    grid-template-columns: 648px 320px;
    column-gap: 14px;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .matrix-network-panel {
    width: 648px;
    grid-template-columns: repeat(4, minmax(150px, 1fr));
  }
  .matrix-network-meta { width: 320px; }
}

@media (max-width: 620px) {
  .matrix-network-footer {
    padding: 3px 10px calc(3px + var(--matrix-network-footer-safe));
    overflow-x: auto;
    scroll-snap-type: x proximity;
  }
  .matrix-network-card {
    min-height: 46px;
    padding: 2px 7px 3px;
    scroll-snap-align: start;
  }
}
