:root {
  --bg: #eef2ef;
  --surface: #ffffff;
  --surface-soft: #f6f8f6;
  --ink: #132d26;
  --muted: #607069;
  --faint: #89948f;
  --line: #dce4e0;
  --line-strong: #bdcbc5;
  --green: #1b6b57;
  --green-dark: #0f4035;
  --green-soft: #dcebe5;
  --orange: #d27a42;
  --orange-soft: #f6e7dc;
  --navy: #173c48;
  --purple: #775a91;
  --shadow: 0 14px 38px rgba(25, 54, 45, 0.07);
  --background: var(--bg);
  --foreground: var(--ink);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 85% -12%, rgba(52, 122, 158, 0.08), transparent 35rem),
    var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}

button,
input,
select {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(27, 107, 87, 0.25);
  outline-offset: 2px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.research-app {
  min-height: 100vh;
}

.app-header {
  position: sticky;
  z-index: 30;
  top: 0;
  display: grid;
  grid-template-columns: minmax(235px, 300px) minmax(320px, 760px) auto;
  align-items: center;
  gap: 24px;
  min-height: 78px;
  padding: 11px 24px;
  background: rgba(15, 64, 53, 0.97);
  color: #f4f8f5;
  box-shadow: 0 8px 28px rgba(8, 36, 29, 0.16);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-symbol {
  position: relative;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  overflow: hidden;
  background: #f4e7c8;
  border-radius: 10px;
}

.brand-symbol span {
  position: absolute;
  left: 19px;
  top: 13px;
  width: 2px;
  height: 24px;
  background: var(--green-dark);
  border-radius: 2px;
  transform-origin: 50% 100%;
}

.brand-symbol span:first-child {
  transform: rotate(-37deg);
}

.brand-symbol span:last-child {
  transform: rotate(37deg);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.12rem;
  font-weight: 500;
}

.brand small {
  margin-top: 2px;
  color: rgba(244, 248, 245, 0.62);
  font-size: 0.68rem;
}

.global-search {
  position: relative;
  display: block;
}

.global-search > span {
  position: absolute;
  z-index: -1;
  opacity: 0;
}

.global-search input {
  width: 100%;
  height: 46px;
  padding: 0 74px 0 17px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.global-search input::placeholder {
  color: rgba(255, 255, 255, 0.56);
}

.global-search input:focus {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.36);
}

.global-search button {
  position: absolute;
  top: 8px;
  right: 8px;
  height: 30px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  font-size: 0.69rem;
}

.header-actions {
  display: flex;
  justify-content: end;
  gap: 8px;
}

.header-actions > button {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: transparent;
  color: #ffffff;
  font-size: 0.73rem;
  font-weight: 650;
}

.header-actions .review-button {
  background: #f4e7c8;
  color: var(--green-dark);
  border-color: #f4e7c8;
}

.review-button b {
  display: inline-grid;
  place-items: center;
  min-width: 21px;
  height: 21px;
  margin-left: 5px;
  background: var(--green-dark);
  color: #ffffff;
  border-radius: 999px;
  font-size: 0.65rem;
}

.app-layout {
  display: grid;
  grid-template-columns: 276px minmax(0, 1fr);
  width: min(1920px, 100%);
  margin-inline: auto;
}

.left-rail {
  position: sticky;
  top: 78px;
  height: calc(100vh - 78px);
  overflow-y: auto;
  background: #f8faf8;
  border-right: 1px solid var(--line);
}

.main-nav {
  display: grid;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.main-nav button {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  grid-template-rows: auto auto;
  column-gap: 7px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.main-nav button:hover {
  background: #eef4f1;
}

.main-nav button.active {
  background: var(--green-soft);
  color: var(--green-dark);
}

.main-nav button > span {
  grid-row: 1 / 3;
  color: var(--faint);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.72rem;
  line-height: 1.5;
}

.main-nav strong {
  font-size: 0.78rem;
  font-weight: 700;
}

.main-nav small {
  margin-top: 1px;
  color: var(--faint);
  font-size: 0.65rem;
}

.filter-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  padding: 18px 18px 12px;
}

.filter-header strong {
  font-size: 0.82rem;
}

.filter-header button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--green);
  font-size: 0.68rem;
  font-weight: 700;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--green);
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.year-filter {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  padding: 0 18px 14px;
}

.year-filter label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 700;
}

.year-filter input {
  width: 100%;
  height: 36px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
}

.facet-section {
  border-top: 1px solid var(--line);
}

.facet-section summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  color: var(--ink);
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 720;
  list-style: none;
}

.facet-section summary::-webkit-details-marker {
  display: none;
}

.facet-section summary::after {
  content: "+";
  color: var(--faint);
  font-size: 1rem;
  font-weight: 400;
}

.facet-section[open] summary::after {
  content: "−";
}

.facet-section summary b {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  margin-left: auto;
  margin-right: 9px;
  background: var(--green);
  color: #ffffff;
  border-radius: 999px;
  font-size: 0.61rem;
}

.facet-options {
  display: grid;
  gap: 7px;
  padding: 0 18px 13px;
}

.facet-options label {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) auto;
  align-items: start;
  gap: 7px;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.35;
}

.facet-options input {
  margin: 2px 0 0;
  accent-color: var(--green);
}

.facet-options em {
  color: var(--faint);
  font-size: 0.64rem;
  font-style: normal;
  font-variant-numeric: tabular-nums;
}

.facet-more {
  justify-self: start;
  padding: 2px 0;
  border: 0;
  background: transparent;
  color: var(--green);
  font-size: 0.65rem;
  font-weight: 700;
}

.facet-caveat {
  margin: 4px 0 0;
  color: var(--faint);
  font-size: 0.62rem;
  line-height: 1.4;
}

.quality-filter {
  display: grid;
  gap: 8px;
  padding: 14px 18px 22px;
  margin: 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.quality-filter legend {
  padding-top: 13px;
  margin-bottom: 8px;
  font-size: 0.72rem;
  font-weight: 720;
}

.quality-filter label {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 0.7rem;
}

.quality-filter input {
  accent-color: var(--green);
}

.workspace {
  min-width: 0;
  padding: 26px clamp(18px, 3vw, 44px) 44px;
}

.workspace-topline {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line-strong);
}

.workspace-topline h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.65rem, 2.5vw, 2.35rem);
  font-weight: 500;
  letter-spacing: -0.035em;
}

.query-status {
  display: grid;
  grid-template-columns: auto auto;
  align-items: baseline;
  gap: 2px 7px;
  text-align: right;
}

.query-status strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.55rem;
  font-weight: 500;
}

.query-status span {
  color: var(--muted);
  font-size: 0.72rem;
}

.query-status small {
  grid-column: 1 / -1;
  color: var(--faint);
  font-size: 0.62rem;
}

.active-filter-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding: 12px 0 4px;
}

.active-filter-bar > span {
  color: var(--faint);
  font-size: 0.66rem;
}

.active-filter-bar button {
  flex: 0 0 auto;
  padding: 5px 8px;
  border: 1px solid #c6ddd4;
  border-radius: 999px;
  background: #edf6f2;
  color: var(--green-dark);
  font-size: 0.65rem;
}

.view-stack {
  display: grid;
  gap: 18px;
  padding-top: 20px;
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(360px, 1.08fr);
  align-items: center;
  gap: 28px;
  padding: clamp(22px, 3vw, 34px);
  overflow: hidden;
  background:
    radial-gradient(circle at 88% 15%, rgba(244, 231, 200, 0.17), transparent 15rem),
    linear-gradient(135deg, #123e34, #0e2f28);
  color: #f6faf7;
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.hero-panel h2 {
  max-width: 680px;
  margin-bottom: 12px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.45rem, 3vw, 2.35rem);
  font-weight: 500;
  line-height: 1.17;
  letter-spacing: -0.035em;
}

.hero-panel p:not(.eyebrow) {
  max-width: 720px;
  margin-bottom: 0;
  color: rgba(246, 250, 247, 0.68);
  line-height: 1.55;
}

.hero-panel .eyebrow {
  color: #e5c98f;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 22px;
}

.hero-visual {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  background: #082d25;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.2);
}

.hero-visual img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1672 / 939;
  object-fit: cover;
}

.primary-button,
.secondary-button,
.section-heading > button,
.card-heading > button,
.drawer-primary-actions button,
.drawer-primary-actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 39px;
  padding: 0 13px;
  border-radius: 8px;
  font-size: 0.7rem;
  font-weight: 700;
  text-decoration: none;
}

.primary-button {
  border: 1px solid var(--green);
  background: var(--green);
  color: #ffffff;
}

.secondary-button {
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metric-grid > div {
  display: grid;
  gap: 5px;
  min-height: 125px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(25, 54, 45, 0.035);
}

.metric-grid span,
.metric-grid small {
  color: var(--muted);
  font-size: 0.67rem;
}

.metric-grid strong {
  align-self: end;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.5rem, 2.5vw, 2.15rem);
  font-weight: 500;
}

.analysis-grid {
  display: grid;
  gap: 18px;
}

.analysis-grid.two-wide {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.analysis-grid.three-wide {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.analysis-card,
.node-inspector,
.review-list,
.comparison-table-wrap,
.empty-review {
  min-width: 0;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 13px;
  box-shadow: 0 8px 25px rgba(25, 54, 45, 0.035);
}

.card-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 17px;
}

.card-heading h3 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.08rem;
  font-weight: 500;
}

.card-heading > button,
.section-heading > button {
  border: 1px solid var(--line-strong);
  background: #ffffff;
  color: var(--green);
}

.bar-list {
  display: grid;
  gap: 10px;
}

.bar-list > div,
.bar-list > button {
  display: grid;
  grid-template-columns: minmax(115px, 1.2fr) minmax(70px, 2fr) 32px;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.bar-list > button:hover .bar-label {
  color: var(--green);
  text-decoration: underline;
}

.bar-label {
  overflow: hidden;
  font-size: 0.7rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  height: 7px;
  overflow: hidden;
  background: #edf0ee;
  border-radius: 999px;
}

.bar-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.bar-list strong {
  color: var(--muted);
  font-size: 0.66rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.card-note {
  margin: 13px 0 0;
  color: var(--faint);
  font-size: 0.63rem;
}

.trend-chart svg {
  display: block;
  width: 100%;
  height: auto;
}

.chart-grid {
  stroke: var(--line);
  stroke-width: 1;
}

.chart-axis {
  fill: var(--faint);
  font-size: 11px;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 7px;
}

.chart-legend span,
.topic-legend button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.66rem;
}

.chart-legend i,
.topic-legend i,
.graph-type-controls i,
.topic-label i,
.drawer-kicker i {
  display: inline-block;
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.opportunity-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}

.opportunity-grid button {
  display: grid;
  gap: 4px;
  min-height: 105px;
  padding: 13px;
  border: 1px solid #ecd6c6;
  border-radius: 9px;
  background: #fdf7f2;
  color: var(--ink);
  text-align: left;
}

.opportunity-grid button:hover {
  border-color: var(--orange);
}

.opportunity-grid span {
  color: var(--orange);
  font-size: 0.63rem;
  font-weight: 800;
  text-transform: uppercase;
}

.opportunity-grid strong {
  font-size: 0.75rem;
  line-height: 1.35;
}

.opportunity-grid em {
  color: var(--muted);
  font-size: 0.68rem;
  font-style: normal;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 26px;
  padding: 4px 2px 2px;
}

.section-heading h2 {
  margin-bottom: 7px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.35rem, 2.5vw, 2rem);
  font-weight: 500;
  letter-spacing: -0.03em;
}

.section-heading p:not(.eyebrow) {
  max-width: 770px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.5;
}

.landscape-card,
.graph-card {
  padding: 13px;
}

.landscape-wrap,
.graph-canvas-wrap {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 50%, rgba(27, 107, 87, 0.06), transparent 55%),
    #fbfcfb;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.landscape-wrap canvas,
.graph-canvas-wrap canvas {
  display: block;
  max-width: 100%;
  cursor: crosshair;
}

.canvas-tooltip {
  position: absolute;
  left: 14px;
  bottom: 14px;
  display: grid;
  gap: 3px;
  max-width: min(460px, calc(100% - 28px));
  padding: 10px 12px;
  background: rgba(15, 49, 41, 0.94);
  color: #ffffff;
  border-radius: 8px;
  box-shadow: var(--shadow);
  pointer-events: none;
}

.canvas-tooltip span {
  color: rgba(255, 255, 255, 0.62);
  font-size: 0.62rem;
}

.canvas-tooltip strong {
  font-size: 0.74rem;
  line-height: 1.35;
}

.topic-legend,
.graph-type-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 13px;
  padding: 11px 5px 2px;
}

.topic-legend button {
  padding: 0;
  border: 0;
  background: transparent;
}

.result-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  padding-top: 2px;
}

.result-toolbar strong,
.result-toolbar span {
  display: block;
}

.result-toolbar strong {
  font-size: 0.82rem;
}

.result-toolbar span {
  margin-top: 3px;
  color: var(--faint);
  font-size: 0.65rem;
}

.result-toolbar button {
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--green);
  font-size: 0.66rem;
}

.document-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.document-card {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 10px;
  min-height: 220px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 11px;
}

.document-card:hover {
  border-color: #b8ccc3;
  box-shadow: 0 10px 26px rgba(25, 54, 45, 0.05);
}

.document-card-top,
.document-card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.document-card-top > span,
.document-card-bottom > span:last-child {
  color: var(--faint);
  font-size: 0.62rem;
}

.save-button {
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--green);
  font-size: 0.62rem;
  font-weight: 700;
}

.save-button.saved {
  background: var(--green-soft);
  border-color: #bdd7cc;
}

.document-title {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.96rem;
  font-weight: 500;
  line-height: 1.35;
  text-align: left;
}

.document-title:hover {
  color: var(--green);
}

.document-card > p {
  margin: 0;
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.45;
}

.topic-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.62rem;
}

.document-card-bottom > span:last-child {
  overflow: hidden;
  max-width: 45%;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-limit {
  color: var(--faint);
  font-size: 0.66rem;
  text-align: center;
}

.compact-select,
.matrix-dimension-controls label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 700;
}

.compact-select select,
.matrix-dimension-controls select {
  min-width: 140px;
  height: 37px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.7rem;
}

.graph-type-controls {
  padding: 0;
}

.graph-type-controls button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.65rem;
}

.graph-type-controls button.active {
  background: var(--green-soft);
  border-color: #bdd7cc;
  color: var(--green-dark);
}

.node-inspector {
  display: grid;
  grid-template-columns: minmax(220px, 0.7fr) minmax(0, 1.8fr);
  gap: 24px;
}

.node-summary h3 {
  margin-bottom: 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.35rem;
  font-weight: 500;
}

.node-summary p,
.node-copy {
  color: var(--muted);
  font-size: 0.73rem;
  line-height: 1.5;
}

.node-documents,
.compact-document-list {
  display: grid;
}

.node-documents button,
.compact-document-list button {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 9px;
  padding: 10px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font-size: 0.7rem;
  line-height: 1.4;
  text-align: left;
}

.node-documents span,
.compact-document-list span {
  color: var(--faint);
  font-size: 0.64rem;
}

.matrix-dimension-controls {
  display: flex;
  gap: 9px;
}

.matrix-card {
  padding: 18px;
}

.matrix-summary {
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 0 0 16px;
}

.matrix-summary > div {
  display: grid;
}

.matrix-summary strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.5rem;
  font-weight: 500;
}

.matrix-summary span,
.matrix-summary p {
  color: var(--muted);
  font-size: 0.65rem;
}

.matrix-summary p {
  max-width: 360px;
  margin: 0 0 0 auto;
  line-height: 1.45;
}

.matrix-scroll {
  overflow-x: auto;
}

.evidence-matrix {
  display: grid;
  min-width: 960px;
  gap: 4px;
}

.matrix-row {
  display: contents;
}

.matrix-corner {
  display: flex;
  align-items: end;
  padding: 0 8px 8px 0;
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 700;
}

.matrix-col-label {
  display: flex;
  align-items: end;
  justify-content: center;
  height: 128px;
  padding: 0 0 8px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 650;
  text-align: left;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}

.matrix-row-label {
  padding: 0 8px 0 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 0.68rem;
  font-weight: 650;
  text-align: left;
}

.matrix-cell {
  min-height: 50px;
  border: 0;
  border-radius: 5px;
  font-size: 0.7rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.matrix-cell.gap {
  color: #9a5b33 !important;
}

.matrix-cell:hover,
.matrix-col-label:hover,
.matrix-row-label:hover {
  box-shadow: inset 0 0 0 2px var(--green-dark);
}

.compact-document-list button {
  grid-template-columns: 45px minmax(0, 1fr) minmax(90px, 0.35fr);
}

.compact-document-list em {
  color: var(--muted);
  font-size: 0.63rem;
  font-style: normal;
  text-align: right;
}

.segmented-control {
  display: flex;
  padding: 3px;
  background: #e5ece8;
  border-radius: 8px;
}

.segmented-control button {
  min-height: 33px;
  padding: 0 11px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
}

.segmented-control button.active {
  background: #ffffff;
  color: var(--green-dark);
  box-shadow: 0 2px 8px rgba(25, 54, 45, 0.08);
}

.empty-review {
  padding: 54px 24px;
  text-align: center;
}

.empty-review strong {
  display: block;
  margin-bottom: 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.35rem;
  font-weight: 500;
}

.empty-review p,
.compare-prompt {
  color: var(--muted);
  font-size: 0.74rem;
}

.review-list {
  display: grid;
  gap: 0;
  padding: 0 20px;
}

.review-list article {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr) minmax(150px, 0.45fr) 70px;
  align-items: center;
  gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.review-list label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.65rem;
}

.review-title,
.remove-review {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 0.73rem;
  font-weight: 650;
  line-height: 1.4;
  text-align: left;
}

.review-list article > span {
  color: var(--muted);
  font-size: 0.66rem;
}

.remove-review {
  color: #9a4e4e;
  font-size: 0.64rem;
  text-align: right;
}

.comparison-table-wrap {
  overflow-x: auto;
  padding: 0;
}

.comparison-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  font-size: 0.68rem;
}

.comparison-table th,
.comparison-table td {
  min-width: 220px;
  padding: 12px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  line-height: 1.48;
  text-align: left;
  vertical-align: top;
}

.comparison-table th {
  background: #f4f7f5;
  color: var(--ink);
}

.comparison-table thead th {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.78rem;
  font-weight: 500;
}

.compare-prompt {
  padding: 14px;
  background: var(--green-soft);
  border-radius: 8px;
  text-align: center;
}

.drawer-scrim {
  position: fixed;
  z-index: 60;
  inset: 0;
  border: 0;
  background: rgba(8, 27, 22, 0.42);
  backdrop-filter: blur(2px);
}

.document-drawer {
  position: fixed;
  z-index: 61;
  top: 0;
  right: 0;
  width: min(620px, 94vw);
  height: 100vh;
  overflow-y: auto;
  padding: 24px 28px 44px;
  background: var(--surface);
  box-shadow: -18px 0 50px rgba(11, 34, 28, 0.2);
}

.drawer-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 20px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.drawer-actions button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--green);
  font-size: 0.68rem;
  font-weight: 700;
}

.drawer-kicker {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 750;
  text-transform: uppercase;
}

.document-drawer h2 {
  margin-bottom: 13px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.45rem, 3vw, 2.15rem);
  font-weight: 500;
  line-height: 1.22;
  letter-spacing: -0.03em;
}

.drawer-authors {
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.5;
}

.drawer-metadata,
.drawer-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.drawer-metadata span,
.drawer-tags span {
  padding: 5px 8px;
  background: #edf2ef;
  color: var(--muted);
  border-radius: 5px;
  font-size: 0.63rem;
}

.drawer-primary-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 18px;
}

.drawer-primary-actions a {
  background: var(--green);
  color: #ffffff;
}

.drawer-primary-actions button {
  border: 1px solid var(--line-strong);
  background: #ffffff;
  color: var(--green);
}

.document-drawer section {
  padding-top: 20px;
  margin-top: 20px;
  border-top: 1px solid var(--line);
}

.document-drawer section h3 {
  margin-bottom: 9px;
  color: var(--green-dark);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.document-drawer section p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.62;
}

.document-drawer section small {
  display: block;
  margin-top: 7px;
  color: var(--faint);
  font-size: 0.63rem;
}

.quality-section {
  padding: 14px !important;
  background: var(--orange-soft);
  border: 0 !important;
  border-radius: 8px;
}

.quality-section .drawer-tags span {
  background: rgba(255, 255, 255, 0.65);
  color: #8a5734;
}

.similar-list {
  display: grid;
}

.similar-list button {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 8px;
  padding: 10px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font-size: 0.7rem;
  line-height: 1.4;
  text-align: left;
}

.similar-list span {
  color: var(--faint);
  font-size: 0.62rem;
}

.app-footer {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 26px 22px calc(276px + 3vw);
  background: #e5ebe8;
  color: var(--faint);
  border-top: 1px solid var(--line);
  font-size: 0.62rem;
}

.load-state {
  display: grid;
  place-content: center;
  min-height: 100vh;
  padding: 32px;
  text-align: center;
}

.load-state h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
}

.loader-mark {
  width: 36px;
  height: 36px;
  margin: 0 auto 14px;
  border: 3px solid rgba(27, 107, 87, 0.15);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 850ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .loader-mark {
    animation: none;
  }
}

@media (max-width: 1250px) {
  .app-header {
    grid-template-columns: 250px minmax(280px, 1fr) auto;
    gap: 14px;
  }

  .header-actions > button:first-child {
    display: none;
  }

  .document-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .analysis-grid.three-wide {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 960px) {
  .app-header {
    position: static;
    grid-template-columns: 1fr auto;
  }

  .global-search {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .app-layout {
    grid-template-columns: 1fr;
  }

  .left-rail {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .main-nav {
    display: flex;
    overflow-x: auto;
  }

  .main-nav button {
    flex: 0 0 150px;
  }

  .filter-header,
  .year-filter,
  .facet-section,
  .quality-filter {
    display: none;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .analysis-grid.two-wide,
  .analysis-grid.three-wide {
    grid-template-columns: 1fr;
  }

  .app-footer {
    padding-left: 24px;
  }
}

@media (max-width: 680px) {
  .app-header {
    padding: 10px 12px;
  }

  .brand small {
    display: none;
  }

  .header-actions > button {
    min-height: 34px;
    padding-inline: 8px;
  }

  .workspace {
    padding: 20px 12px 36px;
  }

  .workspace-topline,
  .section-heading,
  .result-toolbar,
  .matrix-summary,
  .app-footer {
    align-items: start;
    flex-direction: column;
  }

  .query-status {
    text-align: left;
  }

  .metric-grid,
  .document-grid,
  .opportunity-grid {
    grid-template-columns: 1fr;
  }

  .hero-panel {
    grid-template-columns: 1fr;
  }

  .hero-actions {
    align-items: stretch;
    flex-direction: column;
    width: 100%;
  }

  .matrix-dimension-controls {
    width: 100%;
  }

  .matrix-dimension-controls label {
    flex: 1;
  }

  .matrix-dimension-controls select {
    width: 100%;
    min-width: 0;
  }

  .node-inspector {
    grid-template-columns: 1fr;
  }

  .review-list article {
    grid-template-columns: 80px minmax(0, 1fr);
  }

  .review-list article > span,
  .remove-review {
    grid-column: 2;
  }
}


/* ── Added: research-category facet swatch, paper knowledge graph, mode/colour switches ── */
.facet-swatch {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 6px;
  border-radius: 3px;
  vertical-align: middle;
}

.graph-mode-switch {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  margin: 2px 0 2px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  width: fit-content;
}
.graph-mode-switch button {
  padding: 7px 15px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}
.graph-mode-switch button.active {
  background: var(--surface);
  color: var(--green-dark);
  box-shadow: 0 1px 4px rgba(25, 54, 45, 0.12);
}

.category-legend {
  max-height: 118px;
  overflow-y: auto;
}

.paper-graph-wrap {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 45%, rgba(27, 107, 87, 0.06), transparent 58%),
    #fbfcfb;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.paper-graph-svg {
  display: block;
  width: 100%;
  height: clamp(460px, 66vh, 760px);
  touch-action: none;
  cursor: grab;
}
.paper-graph-svg:active {
  cursor: grabbing;
}
.paper-graph-controls {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}
.paper-graph-controls .compact-select {
  flex-direction: row;
  align-items: center;
  gap: 6px;
}
.paper-graph-controls > button {
  padding: 6px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 700;
}
.paper-graph-count {
  color: var(--faint);
  font-size: 0.64rem;
  font-weight: 600;
}

.landscape-tools {
  display: flex;
  align-items: center;
  gap: 12px;
}
.color-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 4px 4px 10px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.color-toggle > span {
  color: var(--faint);
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.color-toggle button {
  padding: 5px 11px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
}
.color-toggle button.active {
  background: var(--green-soft);
  color: var(--green-dark);
}
