:root {
  /* Material Design — Google-inspired tokens */
  --md-sys-color-primary: #1a73e8;
  --md-sys-color-on-primary: #ffffff;
  --md-sys-color-primary-container: #d2e3fc;
  --md-sys-color-surface: #ffffff;
  --md-sys-color-surface-container: #f8f9fa;
  --md-sys-color-surface-container-high: #f1f3f4;
  --md-sys-color-on-surface: #202124;
  --md-sys-color-on-surface-variant: #5f6368;
  --md-sys-color-outline: #dadce0;
  --md-sys-color-outline-variant: #e8eaed;
  --md-sys-color-upstream: #1967d2;
  --md-sys-color-downstream: #e37400;
  --md-sys-color-hub: #188038;
  --md-elevation-1: 0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);
  --md-elevation-2: 0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 2px 6px 2px rgba(60, 64, 67, 0.15);
  --md-radius: 8px;
  --md-radius-lg: 12px;
  --font: "Roboto", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "Roboto Mono", "SF Mono", ui-monospace, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--md-sys-color-primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 24px 64px;
}

/* App bar */
.app-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--md-sys-color-outline);
}

.app-bar h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--md-sys-color-on-surface);
}

.app-bar .subtitle {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--md-sys-color-on-surface-variant);
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.nav-links a,
.nav-links button {
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--md-sys-color-primary);
  background: transparent;
  border: none;
  padding: 8px 12px;
  border-radius: 20px;
  cursor: pointer;
}

.nav-links a:hover,
.nav-links button:hover {
  background: var(--md-sys-color-primary-container);
  text-decoration: none;
}

/* Toolbar */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.search-field {
  flex: 1;
  min-width: 220px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--md-sys-color-surface);
  border: 1px solid var(--md-sys-color-outline);
  border-radius: 24px;
  padding: 4px 4px 4px 16px;
  box-shadow: var(--md-elevation-1);
}

.search-field:focus-within {
  border-color: var(--md-sys-color-primary);
  box-shadow: 0 0 0 1px var(--md-sys-color-primary);
}

.search-field input {
  flex: 1;
  border: none;
  outline: none;
  font: inherit;
  font-size: 14px;
  background: transparent;
  padding: 8px 0;
  color: var(--md-sys-color-on-surface);
}

.search-field input::placeholder {
  color: var(--md-sys-color-on-surface-variant);
}

.btn {
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.25px;
  padding: 10px 24px;
  border-radius: 20px;
  border: none;
  cursor: pointer;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.btn-filled {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}

.btn-filled:hover {
  box-shadow: var(--md-elevation-1);
  filter: brightness(1.05);
}

.btn-text {
  background: transparent;
  color: var(--md-sys-color-primary);
  padding: 10px 12px;
}

.btn-text:hover {
  background: var(--md-sys-color-primary-container);
}

.btn-outlined {
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-primary);
  border: 1px solid var(--md-sys-color-outline);
}

.btn-outlined:hover {
  background: var(--md-sys-color-surface-container-high);
}

/* Surface card */
.surface {
  background: var(--md-sys-color-surface);
  border-radius: var(--md-radius-lg);
  border: 1px solid var(--md-sys-color-outline-variant);
  box-shadow: var(--md-elevation-1);
}

/* ——— Overview: three hubs ——— */
.overview {
  padding: 32px 24px 40px;
}

.overview-title {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 500;
  text-align: center;
  color: var(--md-sys-color-on-surface);
}

.overview-desc {
  margin: 0 auto 28px;
  max-width: 560px;
  text-align: center;
  font-size: 13px;
  color: var(--md-sys-color-on-surface-variant);
}

.hub-map {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  max-width: 720px;
  margin: 0 auto;
}

.hub-row-top {
  display: flex;
  justify-content: center;
}

.hub-row-bottom {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}

.hub-connectors {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 48px;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 12px;
}

.hub-connectors svg {
  width: 100%;
  max-width: 420px;
  height: 48px;
}

.hub-card {
  display: block;
  width: 100%;
  max-width: 280px;
  margin: 0 auto;
  text-align: left;
  padding: 16px 20px;
  background: var(--md-sys-color-surface);
  border: 1px solid var(--md-sys-color-outline);
  border-radius: var(--md-radius);
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.hub-card:hover {
  border-color: var(--md-sys-color-primary);
  box-shadow: var(--md-elevation-2);
  background: #fff;
}

.hub-card:focus-visible {
  outline: 2px solid var(--md-sys-color-primary);
  outline-offset: 2px;
}

.hub-card .label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--md-sys-color-hub);
  margin-bottom: 4px;
}

.hub-card .name {
  font-size: 18px;
  font-weight: 500;
  margin: 0 0 8px;
  color: var(--md-sys-color-on-surface);
}

.hub-card .metrics {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--md-sys-color-on-surface-variant);
}

.hub-card .metrics strong {
  display: block;
  font-size: 20px;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  color: var(--md-sys-color-on-surface);
  font-family: var(--mono);
}

.edge-legend {
  margin: 28px auto 0;
  max-width: 560px;
  padding: 12px 16px;
  background: var(--md-sys-color-surface-container-high);
  border-radius: var(--md-radius);
  font-size: 13px;
  color: var(--md-sys-color-on-surface-variant);
}

.edge-legend strong {
  color: var(--md-sys-color-on-surface);
  font-weight: 500;
}

.edge-legend ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.edge-legend li {
  margin: 4px 0;
}

/* ——— Focus view ——— */
.focus-view {
  display: none;
}

.focus-view.is-active {
  display: block;
}

.overview.is-hidden,
#overview[hidden] {
  display: none !important;
}

#focus-view[hidden] {
  display: none !important;
}

.focus-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.focus-grid {
  display: grid;
  grid-template-columns: 1fr minmax(220px, 280px) 1fr;
  gap: 16px;
  align-items: start;
  padding: 16px;
  min-height: 420px;
}

@media (max-width: 900px) {
  .focus-grid {
    grid-template-columns: 1fr;
  }

  .focus-center-col {
    order: -1;
  }
}

.col-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
  padding: 0 4px;
}

.col-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
}

.col-head .count {
  font-size: 12px;
  color: var(--md-sys-color-on-surface-variant);
}

.col-head.up h2 {
  color: var(--md-sys-color-upstream);
}

.col-head.down h2 {
  color: var(--md-sys-color-downstream);
}

.word-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 560px;
  overflow: auto;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-radius);
  background: var(--md-sys-color-surface);
}

.word-list li {
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.word-list li:last-child {
  border-bottom: none;
}

.word-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  align-items: center;
  width: 100%;
  padding: 12px 14px;
  border: none;
  background: transparent;
  font: inherit;
  text-align: left;
  cursor: pointer;
  color: var(--md-sys-color-on-surface);
  transition: background 0.12s ease;
}

.word-row:hover {
  background: var(--md-sys-color-surface-container-high);
}

.word-row:focus-visible {
  outline: 2px solid var(--md-sys-color-primary);
  outline-offset: -2px;
}

.word-row .wn {
  font-size: 14px;
  font-weight: 400;
  line-height: 1.35;
}

.word-row .wn .hub-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.3px;
  color: var(--md-sys-color-hub);
  background: #e6f4ea;
  border-radius: 4px;
  vertical-align: middle;
}

.word-row .ws {
  font-family: var(--mono);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--md-sys-color-on-surface);
  font-weight: 500;
}

.word-row .bar {
  grid-column: 1 / -1;
  height: 3px;
  background: var(--md-sys-color-outline-variant);
  border-radius: 2px;
  overflow: hidden;
}

.word-row .bar > i {
  display: block;
  height: 100%;
  border-radius: 2px;
  background: var(--md-sys-color-upstream);
  opacity: 0.7;
}

.word-list.down .word-row .bar > i {
  background: var(--md-sys-color-downstream);
}

.empty-col {
  padding: 24px 16px;
  text-align: center;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 13px;
  border: 1px dashed var(--md-sys-color-outline);
  border-radius: var(--md-radius);
  background: var(--md-sys-color-surface-container);
}

/* Focus center card */
.focus-center-col {
  position: sticky;
  top: 16px;
}

.focus-card {
  padding: 24px 20px;
  text-align: center;
  border: 2px solid var(--md-sys-color-primary);
  border-radius: var(--md-radius-lg);
  background: var(--md-sys-color-surface);
  box-shadow: var(--md-elevation-2);
}

.focus-card .eyebrow {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--md-sys-color-primary);
  margin-bottom: 8px;
}

.focus-card .fname {
  font-size: 22px;
  font-weight: 500;
  margin: 0 0 16px;
  line-height: 1.3;
  color: var(--md-sys-color-on-surface);
}

.focus-card .fmetrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  text-align: left;
  padding: 12px;
  background: var(--md-sys-color-surface-container);
  border-radius: var(--md-radius);
  margin-bottom: 16px;
}

.focus-card .fmetrics div span {
  display: block;
  font-size: 11px;
  color: var(--md-sys-color-on-surface-variant);
}

.focus-card .fmetrics div strong {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.flow-hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.3px;
  color: var(--md-sys-color-on-surface-variant);
  margin-bottom: 16px;
  padding: 0 4px;
}

.flow-hint .u {
  color: var(--md-sys-color-upstream);
}
.flow-hint .d {
  color: var(--md-sys-color-downstream);
}

.focus-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.focus-actions .btn {
  width: 100%;
}

/* Interp + brand */
.section {
  margin-top: 32px;
}

.section h2 {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 500;
}

.section .hint {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--md-sys-color-on-surface-variant);
}

.interp-box {
  min-height: 120px;
  padding: 16px;
  border: 1px solid var(--md-sys-color-outline);
  border-radius: var(--md-radius);
  background: var(--md-sys-color-surface);
  white-space: pre-wrap;
  font-size: 13px;
  line-height: 1.65;
  outline: none;
}

.interp-box:focus {
  border-color: var(--md-sys-color-primary);
  box-shadow: 0 0 0 1px var(--md-sys-color-primary);
}

.interp-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  align-items: center;
}

#save-tip {
  font-size: 12px;
  color: var(--md-sys-color-hub);
}

.brand-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.brand-card {
  display: block;
  padding: 14px 16px;
  background: var(--md-sys-color-surface);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-radius);
  color: inherit;
  text-decoration: none;
  transition: box-shadow 0.15s, border-color 0.15s;
}

.brand-card:hover {
  border-color: var(--md-sys-color-primary);
  box-shadow: var(--md-elevation-1);
  text-decoration: none;
}

.brand-card strong {
  display: block;
  font-weight: 500;
  margin-bottom: 4px;
}

.brand-card .s {
  font-size: 12px;
  color: var(--md-sys-color-on-surface-variant);
  font-family: var(--mono);
}

.footer-note {
  margin-top: 32px;
  font-size: 12px;
  color: var(--md-sys-color-on-surface-variant);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ——— Secondary pages (centers / brand / word) ——— */
.topbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--md-sys-color-outline);
}

.brand-mark {
  margin: 0;
  font-size: 22px;
  font-weight: 400;
}

.meta {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--md-sys-color-on-surface-variant);
}

.panel {
  background: var(--md-sys-color-surface);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-radius-lg);
  padding: 16px 20px;
  box-shadow: var(--md-elevation-1);
  margin-bottom: 16px;
}

.panel h2,
.section-title {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 500;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-radius);
  background: var(--md-sys-color-surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

th {
  font-size: 12px;
  font-weight: 500;
  color: var(--md-sys-color-on-surface-variant);
  background: var(--md-sys-color-surface-container);
}

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--md-sys-color-surface-container-high);
}

.badge.up {
  color: var(--md-sys-color-upstream);
  background: #e8f0fe;
}
.badge.down {
  color: var(--md-sys-color-downstream);
  background: #fef7e0;
}
.badge.center {
  color: var(--md-sys-color-hub);
  background: #e6f4ea;
}

.kv {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 8px;
  margin: 0;
}

.kv dt {
  margin: 0;
  color: var(--md-sys-color-on-surface-variant);
}
.kv dd {
  margin: 0;
  font-weight: 500;
}

.placeholder-box {
  margin-top: 16px;
  padding: 16px;
  border: 1px dashed var(--md-sys-color-outline);
  border-radius: var(--md-radius);
  background: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface-variant);
  font-size: 13px;
}

.graph-shell {
  display: none;
}

.legend,
.controls,
.chip-list,
.chip,
.side,
.empty-sel,
.hint {
  /* used lightly on secondary */
}

.hint {
  font-size: 13px;
  color: var(--md-sys-color-on-surface-variant);
}
