html.rm-body, body.rm-body {
  height: 100%;
}

[hidden] {
  display: none !important;
}

.rm-body {
  overflow: hidden;
}

.rm-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 28px 32px 20px;
}

/* ---------- Topic nav ---------- */

.rm-topics {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0;
  flex: 0 0 auto;
  padding-bottom: 18px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--hairline);
}

.rm-topic-btn {
  background: none;
  border: none;
  border-left: 1px solid var(--hairline);
  padding: 4px 20px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ink);
  cursor: pointer;
  transition: color 0.2s ease, font-weight 0.15s ease;
}

.rm-topic-btn:first-child {
  border-left: none;
}

.rm-topic-btn:hover {
  color: var(--ink-soft);
}

.rm-topic-btn.is-active {
  font-weight: 700;
}

/* ---------- Stage ---------- */

.rm-stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
}

.rm-hint {
  margin: 0;
  font-size: 13px;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
}

.rm-columns {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 40px;
}

.rm-col {
  flex: 0 1 260px;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  padding-top: 4px;
}

.rm-col + .rm-col {
  border-left: 1px solid var(--hairline);
  padding-left: 40px;
}

.rm-col-refs {
  flex: 1 1 340px;
  max-width: 420px;
}

.rm-col-label {
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 18px;
}

.rm-col-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

/* ---------- Keyword terms (layer 1 / 2) ---------- */

.rm-term {
  background: none;
  border: none;
  text-align: left;
  padding: 9px 6px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 300;
  color: var(--ink);
  cursor: pointer;
  border-bottom: 1px solid var(--hairline);
  transition: color 0.2s ease, font-weight 0.15s ease, background 0.2s ease;
}

.rm-term:hover {
  color: var(--ink-soft);
}

.rm-term.is-selected {
  font-weight: 600;
  background: rgba(17, 17, 17, 0.03);
}

/* ---------- Reference chips (layer 3) ---------- */

.rm-ref {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 6px;
  border-bottom: 1px solid var(--hairline);
}

.rm-ref-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 5px;
}

.rm-ref-body {
  flex: 1 1 auto;
  min-width: 0;
}

.rm-ref-title {
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--ink);
}

.rm-ref-meta {
  margin-top: 2px;
  font-size: 11px;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
}

.rm-ref-info {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid var(--hairline);
  background: #ffffff;
  color: var(--ink-soft);
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  font-weight: 600;
  font-style: italic;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.rm-ref-info:hover {
  border-color: var(--ink);
  color: var(--ink);
}

/* ---------- Legend ---------- */

.rm-legend {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
  padding-top: 16px;
}

.rm-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.rm-legend-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

/* ---------- Tooltip ---------- */

.rm-tooltip {
  position: fixed;
  z-index: 100;
  max-width: 280px;
  background: #ffffff;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(17, 17, 17, 0.12);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rm-tooltip-text {
  font-size: 11px;
  color: var(--ink-soft);
  word-break: break-word;
  line-height: 1.5;
}

.rm-tooltip-link {
  font-size: 11px;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--ink);
  width: fit-content;
}

.rm-tooltip-link:hover {
  color: var(--ink-soft);
  border-color: var(--ink-soft);
}

.rm-tooltip-link.is-disabled {
  pointer-events: none;
  opacity: 0.4;
  border-color: transparent;
}

@media (max-width: 720px) {
  .rm-page {
    padding: 20px 18px 16px;
  }
  .rm-topic-btn {
    padding: 4px 12px;
    font-size: 11px;
  }
  .rm-columns {
    flex-direction: column;
    align-items: stretch;
    gap: 20px;
    overflow-y: auto;
  }
  .rm-col + .rm-col {
    border-left: none;
    padding-left: 0;
    border-top: 1px solid var(--hairline);
    padding-top: 16px;
  }
  .rm-col-refs {
    max-width: none;
  }
}
