.history-status { color: var(--muted); font-size: 12px; margin: 10px 0; }
.homepage-desktop-layout { margin: 14px 0; }
.homepage-desktop-layout p { margin: 6px 0 0; }
.history-status[hidden], #mobileHistoryHost[hidden] { display: none !important; }
.mobile-matrix-tools, .mobile-public-tools, #mobileHeaderActions, #mobileHeaderButton, #mobileHeaderMenu,
.mobile-map-fullscreen { display: none; }
.mobile-matrix-tools[hidden], .mobile-map-fullscreen[hidden] { display: none !important; }
/* Shared geometry for the full, region-zoomed and public dense matrices. */
.layout.dense-layout { grid-template-columns: minmax(0, 1fr); }
#publicMetricsPanel { max-width: none; }
#matrix.dense-map, #publicMatrix.public-dense-map {
  border-spacing: var(--dense-axis-gap, 1px) !important;
}
#matrix.dense-map.dense-zoom .dense-cell {
  font-size: min(calc(var(--dense-size) * .9), clamp(10px, calc(var(--dense-size) * .28), 16px)) !important;
}
#matrix.dense-map .dense-source-col,
#matrix.dense-map th.row.dense-row,
#publicMatrix.public-dense-map .public-dense-source,
#publicMatrix.public-dense-map th.row {
  width: var(--dense-source-label-width, 110px) !important;
  min-width: var(--dense-source-label-width, 110px) !important;
  max-width: none !important;
  font-size: var(--dense-axis-font-size, 10px) !important; line-height: 1 !important;
  vertical-align: middle; white-space: nowrap !important;
  position: relative; padding: 0 5px 0 14px !important;
}
#matrix.dense-map .dense-target,
#publicMatrix.public-dense-map .public-dense-target {
  height: var(--dense-axis-label-height, auto) !important;
  padding: 6px 0 !important; font-size: var(--dense-axis-font-size, 10px) !important;
  vertical-align: bottom !important;
}
#matrix.dense-map .dense-target span,
#publicMatrix.public-dense-map .public-dense-target span {
  display: inline-block !important; max-height: none !important;
  white-space: nowrap !important; writing-mode: vertical-rl !important;
  line-height: 1 !important;
}
/* Rotate the entire external name, including CJK glyphs, to read upward.
   Sideways text keeps its natural vertical box for dynamic height measuring. */
#matrix.dense-map .dense-target.external-target span,
#publicMatrix.public-dense-map .public-dense-target.external-target span {
  text-orientation: sideways !important;
  transform: rotate(180deg) !important;
}
#matrix.dense-map th.row .node-status,
#publicMatrix.public-dense-map th.row .node-status {
  width: min(5px, var(--dense-axis-font-size, 10px));
  height: min(5px, var(--dense-axis-font-size, 10px));
  position: absolute; left: 4px; top: 50%;
  margin: calc(min(5px, var(--dense-axis-font-size, 10px)) * -.5) 0 0;
}
/* On desktop, keep the overview as compact as the announcement. The square
   sizing controller fits all targets to this width and reduces height too. */
@media (min-width: 761px) {
  :root { --desktop-overview-width: 680px; }
  .public-home.announcement-only,
  #publicMetricsPanel:not(:fullscreen):not(.app-fullscreen),
  .layout.dense-layout {
    width: 100%; max-width: var(--desktop-overview-width); margin-inline: auto;
  }
  .layout.panel-layout-stacked {
    grid-template-columns: minmax(0, 1fr); width: 100%;
    max-width: var(--desktop-overview-width); margin-inline: auto;
  }
  .layout.panel-layout-side {
    grid-template-columns: minmax(0, 1.65fr) minmax(320px, 1fr);
    align-items: start; width: 100%; max-width: none; margin-inline: auto;
  }
  .layout.panel-layout-side > #matrixPanel {
    width: 100%; max-width: var(--desktop-overview-width); justify-self: end;
  }
}
.app-fullscreen { position: fixed !important; inset: 0; z-index: 100; margin: 0 !important;
  width: 100vw !important; height: 100dvh !important; border-radius: 0 !important;
  background: var(--bg) !important; overflow: auto; padding: 14px !important; }
body.mobile-overlay-open { overflow: hidden; }
#mobileHistoryHost { position: fixed; inset: 0; z-index: 120; }
.mobile-history-backdrop { display: block; position: absolute; inset: 0; background: #0008; }
#mobileHistoryHost > #chartPanel, #mobileHistoryHost > #publicHistorySection {
  position: absolute; left: 0; right: 0; bottom: 0; margin: 0;
  max-height: min(85dvh, 720px); overflow: auto; overscroll-behavior: contain;
  padding: 20px 15px calc(20px + env(safe-area-inset-bottom));
  border: 1px solid var(--line); border-radius: 18px 18px 0 0;
  background: var(--panel); box-shadow: 0 -18px 60px #0007;
}
.mobile-history-close { position: absolute; top: 8px;
  right: 12px; z-index: 2; width: 44px; height: 44px; padding: 0;
  border-radius: 50%; background: var(--panel); border-color: var(--line);
  color: var(--text); font-size: 26px; line-height: 1; }
#mobileHistoryHost .chart-header { padding-right: 38px; }
#mobileHistoryHost .chartbox { height: 230px; }

@media (max-width: 760px) {
  .matrix-layout-control { display: none !important; }
  body > header { min-height: 62px; padding: 12px 15px !important; flex-wrap: nowrap; }
  body > header .header-actions { display: none !important; }
  .brand { min-width: 0; }
  .brand h1 { font-size: 18px; }
  .brand .sub { overflow-wrap: anywhere; }
  #mobileHeaderActions { display: flex; align-items: center; flex: none; gap: 2px; margin-left: auto; }
  #mobileHeaderButton, #mobileThemeButton { display: grid; place-items: center; flex: none;
    width: 44px; height: 44px; padding: 0; border-color: transparent;
    background: transparent; color: var(--text); }
  #mobileHeaderButton svg { width: 21px; height: 21px; }
  #mobileHeaderMenu { display: block; position: fixed; inset: 0; z-index: 130;
    background: #0008; visibility: hidden; opacity: 0; pointer-events: none;
    transition: opacity .18s ease; }
  #mobileHeaderMenu.open { visibility: visible; opacity: 1; pointer-events: auto; }
  .mobile-menu-card { position: absolute; right: 10px; top: max(12px, env(safe-area-inset-top));
    width: min(316px, calc(100vw - 20px)); max-height: calc(100dvh - 24px);
    overflow: auto; padding: 17px; border: 1px solid var(--line); border-radius: 12px;
    background: var(--panel); box-shadow: 0 18px 55px #0008; }
  .mobile-menu-close { position: absolute; right: 7px; top: 4px; width: 44px;
    height: 44px; border: 0; background: transparent; color: var(--muted);
    padding: 0; font-size: 25px; }
  .mobile-menu-title { font-weight: 800; margin: 0 36px 18px 0; }
  .mobile-menu-card label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; }
  .mobile-menu-card select { min-height: 44px; }
  .mobile-menu-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 12px; }
  .mobile-menu-actions button { min-height: 44px; padding: 7px; font-size: 12px; }
  .mobile-matrix-tools { display: grid; grid-template-columns: auto minmax(0,1fr) auto auto;
    gap: 6px; align-items: center; margin: 10px 0; }
  .mobile-matrix-tools select { min-width: 0; min-height: 44px; padding: 7px; font-size: 13px; }
  .mobile-matrix-tools button, .mobile-public-tools button { min-height: 44px; padding: 7px 9px; font-size: 12px; }
  .mobile-matrix-tools button.active { background: var(--aqua); border-color: var(--aqua); color: var(--bg); }
  .mobile-matrix-tools label { display: inline-flex; align-items: center; gap: 6px;
    grid-column: 2 / -1; color: var(--muted); font-size: 12px; }
  .mobile-matrix-tools input { width: 18px; height: 18px; accent-color: var(--aqua); }
  .mobile-public-tools { display: flex; justify-content: flex-end; margin-bottom: 8px; }
  .matrix-tools { display: none !important; }
  .dense-zoom-tools { flex-wrap: wrap; }
  .dense-zoom-tools button { min-height: 44px; }
  .matrix-wrap { overscroll-behavior: contain; }
  .touch-matrix-wrap { max-height: 65dvh; overflow: auto; touch-action: none; }
  .touch-matrix-wrap .matrix th:not(.row) { position: sticky; top: 0; z-index: 3; background: var(--panel); }
  .touch-matrix-wrap .matrix th.row { position: sticky; left: 0; z-index: 2; background: var(--panel); }
  .touch-matrix-wrap .matrix tr:first-child th.row { z-index: 4; }
  .mobile-focus-matrix { min-width: 0 !important; table-layout: fixed; border-spacing: 4px; }
  .mobile-focus-matrix th { font-size: 12px; max-width: none; padding: 3px;
    overflow: hidden; text-overflow: ellipsis; }
  .mobile-focus-matrix th.row { width: 48%; min-width: 0; text-align: left; white-space: nowrap; }
  .mobile-focus-matrix .mobile-focus-cell { min-width: 0; width: 26%; height: 48px;
    border-radius: 8px; font-size: 13px; }
  .mobile-focus-matrix .mobile-focus-cell.diag { font-size: 12px; }
  .mobile-focus-matrix .hint { padding: 18px 6px; }
  #publicMatrix.public-dense-map col:not(.public-dense-source) { width: var(--public-dense-size) !important; }
  #matrixPanel:fullscreen, #publicMetricsPanel:fullscreen, #topologyPanel:fullscreen {
    width: 100%; height: 100%; overflow: auto; padding: 14px; background: var(--bg); }
  #matrixPanel:fullscreen .matrix-wrap, #matrixPanel.app-fullscreen .matrix-wrap,
  #publicMetricsPanel:fullscreen .matrix-wrap, #publicMetricsPanel.app-fullscreen .matrix-wrap { max-height: calc(100dvh - 180px); }
  .app-fullscreen .matrix th:not(.row), :fullscreen .matrix th:not(.row) {
    position: sticky; top: 0; z-index: 3; background: var(--panel); }
  .app-fullscreen .matrix th.row, :fullscreen .matrix th.row {
    position: sticky; left: 0; z-index: 2; background: var(--panel); }
  .app-fullscreen .matrix tr:first-child th.row, :fullscreen .matrix tr:first-child th.row { z-index: 4; }
  #mobileHistoryHost .rangebar.custom .range-custom { grid-template-columns: minmax(0,1fr); gap: 7px; }
  #mobileHistoryHost .range-custom span { display: none; }
  #mobileHistoryHost .rangebar.custom .range-custom input { width: 100%; min-height: 44px; font-size: 16px; }
  #mobileHistoryHost .rangebar button, #mobileHistoryHost .rangebar select { min-height: 44px; }
  #mobileHistoryHost .chart-header h2 { white-space: normal; overflow-wrap: anywhere; }
  #nodesModal .node-manager-page { padding: 14px 12px calc(28px + env(safe-area-inset-bottom)); }
  #nodesModal .node-manager-head { top: 0; }
  #nodesModal .node-list { padding: 0 11px; }
  #nodesModal .node-item { display: grid; grid-template-columns: 18px 8px minmax(0,1fr) auto;
    gap: 8px; align-items: start; padding: 13px 0; }
  #nodesModal .node-select { margin-top: 4px; }
  #nodesModal .node-main strong { font-size: 14px; }
  #nodesModal .node-main small { white-space: normal; overflow-wrap: anywhere; line-height: 1.45; }
  #nodesModal .mobile-node-more { position: relative; }
  #nodesModal .mobile-node-more > summary { list-style: none; min-width: 48px; min-height: 44px;
    display: grid; place-items: center; padding: 7px 8px; border: 1px solid var(--line);
    border-radius: 7px; background: var(--panel); color: var(--text); font-size: 12px; cursor: pointer; }
  #nodesModal .mobile-node-more > summary::-webkit-details-marker { display: none; }
  #nodesModal .mobile-node-more-actions { position: absolute; right: 0; top: 46px; z-index: 4;
    display: grid; gap: 5px; min-width: 112px; padding: 6px; border: 1px solid var(--line);
    border-radius: 9px; background: var(--panel); box-shadow: 0 12px 32px #0006; }
  #nodesModal .mobile-node-more-actions button { width: 100%; min-height: 44px; margin: 0;
    padding: 8px; font-size: 12px; text-align: left; }
  #nodesModal .node-item:last-child .mobile-node-more-actions { top: auto; bottom: 46px; }
  #topologyPanel:not(.mobile-map-node-focus) .geo-edge,
  #topologyPanel:not(.mobile-map-node-focus) .geo-pulse,
  #topologyPanel .geo-node:not(.active) .geo-name,
  #topologyPanel .geo-node:not(.active) .geo-place { display: none; }
  .mobile-map-fullscreen { display: inline-flex; min-height: 44px; }
  #topologySvg { width: 100%; min-width: 0; height: 100%; }
  #topologyPanel .topology-canvas { min-height: 240px; height: clamp(240px, 45dvh, 390px); }
  #topologyPanel:fullscreen .topology-canvas, #topologyPanel.app-fullscreen .topology-canvas {
    height: calc(100dvh - 235px); min-height: 190px; }
  #topologyPanel .topology-details { max-height: 135px; overflow: auto; }
}
/* The dotted geographic view scales uniformly at every viewport size. It
   replaces the old fixed-height SVG and the ocean-wide decorative dot layer. */
#topologyPanel.point-map .topology-canvas {
  aspect-ratio: 2 / 1; height: auto; min-height: 0; overflow: hidden;
  background: radial-gradient(ellipse at 45% 20%, #12233766, transparent 70%), #080e17;
}
#topologyPanel.point-map .topology-canvas:before { display: none; }
#topologyPanel.point-map #topologySvg {
  width: 100%; height: auto; min-width: 0; aspect-ratio: 2 / 1;
}
#topologyPanel.point-map .geo-land-dots { fill: #407b9d; }
#topologyPanel.point-map .geo-land-dots.tone-0 { opacity: .42; }
#topologyPanel.point-map .geo-land-dots.tone-1 { opacity: .58; }
#topologyPanel.point-map .geo-land-dots.tone-2 { opacity: .78; }
#topologyPanel.point-map .geo-edge {
  stroke-width: .8; opacity: .55; stroke-dasharray: none;
  animation: none; pointer-events: none; filter: none;
}
#topologyPanel.point-map .geo-edge.selected { stroke-width: 1.8 !important; opacity: 1; }
#topologyPanel.point-map .geo-route-hit {
  fill: none; stroke: transparent; stroke-width: 10;
  pointer-events: stroke; cursor: pointer; outline: none;
}
#topologyPanel.point-map .geo-route-hit:hover + .geo-edge,
#topologyPanel.point-map .geo-route-hit:focus-visible + .geo-edge { opacity: 1; stroke-width: 1.8; }
#topologyPanel.point-map .geo-route-bead { opacity: .8; pointer-events: none; }
#topologyPanel.point-map .geo-route-badge { cursor: pointer; outline: none; }
#topologyPanel.point-map .geo-route-badge rect { fill: #080e17; stroke-width: .7; }
#topologyPanel.point-map .geo-route-badge text { font: 600 8px sans-serif; text-anchor: middle; pointer-events: none; }
#topologyPanel.point-map .geo-route-badge:focus-visible rect { stroke-width: 2; }
#topologyPanel.point-map .geo-node-halo { opacity: .09; pointer-events: none; }
#topologyPanel.point-map .geo-node-ring { opacity: .4; stroke-width: .8; pointer-events: none; }
#topologyPanel.point-map .geo-node .geo-core { stroke-width: .65; filter: none; }
#topologyPanel.point-map .geo-node:focus-visible .geo-core { stroke-width: 2; }
#topologyPanel.point-map .geo-node-label { pointer-events: none; }
#topologyPanel.point-map .geo-name { fill: #f2f7ff; font: 650 9px sans-serif; stroke: #080e17; stroke-width: 2.5; }
#topologyPanel.point-map .geo-place { fill: #95a9c1; font: 400 8px sans-serif; stroke: #080e17; stroke-width: 2.5; }
body.theme-light #topologyPanel.point-map .topology-canvas { background: #eff5fb; }
body.theme-light #topologyPanel.point-map .geo-land-dots { fill: #376581; }
body.theme-light #topologyPanel.point-map .geo-route-badge rect { fill: #eff5fb; }
body.theme-light #topologyPanel.point-map .geo-name { fill: #162c42; stroke: #eff5fb; }
body.theme-light #topologyPanel.point-map .geo-place { fill: #536c85; stroke: #eff5fb; }
@media (max-width: 760px) {
  #topologyPanel.point-map:not(.mobile-map-node-focus) .geo-route-layer { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  #mobileHeaderMenu { transition: none; }
}
