:root {
  --paper: #faf9f5;
  --paper-deep: #f2f0e9;
  --surface: rgba(250, 249, 246, 0.94);
  --surface-solid: #ffffff;
  --ink: #262625;
  --ink-soft: #545451;
  --ink-faint: #7b7b76;
  --line: #e1e8ed;
  --line-strong: #9da58a;
  --green: #3a5117;
  --green-deep: #262f0f;
  --green-pale: #edf0e5;
  --rose-pale: #f1e3df;
  --shadow: 0 10px 28px rgba(44, 43, 36, 0.06);
  --sans: "Inter Tight", "Helvetica Neue", Arial, sans-serif;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }
html { color-scheme: light; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--serif);
}

button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid rgba(64, 86, 22, 0.25); outline-offset: 3px; }
[hidden] { display: none !important; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 96px;
  padding: 15px clamp(22px, 4vw, 70px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 254, 250, 0.97);
  backdrop-filter: blur(10px);
}

.header-left { display: flex; align-items: center; flex-shrink: 0; }
.brand { display: inline-flex; align-items: center; color: inherit; text-decoration: none; }
.brand-logo { display: block; width: auto; height: 68px; object-fit: contain; }

.header-search {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  max-width: 480px;
  margin: 0 20px;
}

.site-nav { display: flex; align-items: center; flex-shrink: 0; }
.nav-menu { display: flex; align-items: center; gap: 32px; list-style: none; margin: 0; padding: 0; }
.nav-item { position: relative; }
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  text-decoration: none;
  font-family: var(--sans);
  font-size: 0.88rem;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 16px 0;
  transition: color 140ms ease;
}
.nav-link:hover, .nav-link.is-active { color: var(--green); }
.dropdown-icon { transition: transform 160ms ease; opacity: 0.75; }
.has-dropdown:hover .dropdown-icon { transform: rotate(180deg); }

.sub-menu {
  position: absolute;
  top: calc(100% - 6px);
  left: 0;
  min-width: 230px;
  background: #1c1c1c;
  padding: 12px 0;
  margin: 0;
  list-style: none;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.22);
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px);
  transition: opacity 160ms ease, transform 160ms ease, visibility 160ms ease;
  z-index: 200;
}
.has-dropdown:hover .sub-menu, .has-dropdown:focus-within .sub-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.sub-menu li { margin: 0; padding: 0; }
.sub-menu a {
  display: block;
  padding: 10px 22px;
  color: #ffffff;
  text-decoration: none;
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  transition: background 120ms ease, color 120ms ease;
}
.sub-menu a:hover {
  background: #272727;
  color: #b0d462;
}
.nav-item:last-child .sub-menu { left: auto; right: 0; }

.quiet-button, .text-button { border: 0; background: transparent; cursor: pointer; }
.quiet-button { padding: 9px 13px; color: var(--green-deep); border: 1px solid var(--line); border-radius: 2px; font-family: var(--sans); font-size: 0.76rem; font-weight: 700; white-space: nowrap; }
.quiet-button:hover { border-color: var(--green); background: var(--green-pale); }

/* El acceso a la vista macro estaba escrito con estilos en línea dentro del
   HTML publicado, fuera de esta hoja; aquí pasa a ser una regla más. */
.hero-secondary { margin: 26px 0 0; }
.hero-secondary a {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 18px; border: 1px solid var(--line); border-radius: 2px;
  color: var(--green-deep); background: transparent; text-decoration: none;
  font-family: var(--sans); font-size: .78rem; font-weight: 750;
  transition: border-color 140ms ease, background 140ms ease;
}
.hero-secondary a:hover { border-color: var(--green); background: var(--green-pale); }

.hero { display: flex; flex-direction: column; align-items: center; min-height: calc(100vh - 96px); padding: 44px 22px 64px; text-align: center; }
.eyebrow { margin: 0 0 14px; color: var(--green); font-family: var(--sans); font-size: 0.7rem; font-weight: 750; letter-spacing: 0.18em; text-transform: uppercase; }
.hero h1 { max-width: 980px; margin: 0; font-family: var(--sans); font-size: clamp(3.2rem, 6vw, 6.25rem); font-weight: 800; letter-spacing: -0.065em; line-height: 0.93; }
.hero-copy { max-width: 710px; margin: 25px auto 0; color: var(--ink-soft); font-family: var(--serif); font-size: clamp(1.08rem, 1.8vw, 1.34rem); line-height: 1.46; }

.topic-explorer { width: min(1120px, 100%); margin-top: 38px; text-align: left; }
.topic-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 24px; margin-bottom: 13px; }
.topic-heading h2 { margin: 0; font-family: var(--sans); font-size: 1rem; font-weight: 800; letter-spacing: -.02em; }
.topic-heading p { margin: 0; color: var(--ink-faint); font-size: .82rem; }
.topic-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--line-strong); border-left: 1px solid var(--line-strong); }
.topic-route { min-height: 96px; padding: 17px; border: 0; border-right: 1px solid var(--line-strong); border-bottom: 1px solid var(--line-strong); background: rgba(255, 255, 252, .45); text-align: left; cursor: pointer; transition: color 140ms ease, background 140ms ease; }
.topic-route:hover, .topic-route:focus-visible { color: var(--green-deep); background: var(--green-pale); outline-offset: -4px; }
.topic-route strong { display: block; font-family: var(--sans); font-size: 1rem; font-weight: 750; line-height: 1.16; }
.topic-route span { display: block; margin-top: 13px; color: var(--ink-faint); font-family: var(--serif); font-size: .76rem; line-height: 1.3; }
.topic-route:hover span { color: var(--green); }

.search-divider { display: flex; align-items: center; gap: 14px; width: min(720px, 100%); margin: 28px 0 14px; color: var(--ink-faint); font-family: var(--sans); font-size: .7rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.search-divider::before, .search-divider::after { content: ""; height: 1px; flex: 1; background: var(--line); }
.search-divider span { white-space: nowrap; }
.hero-search { width: min(720px, 100%); margin: 0; }

.search-shell {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 13px;
  width: 100%;
  min-height: 58px;
  padding: 0 20px;
  border: 1px solid var(--green);
  border-radius: 4px;
  background: var(--surface-solid);
  box-shadow: var(--shadow);
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}
.search-shell:focus-within { border-color: #222; box-shadow: 0 12px 32px rgba(43, 49, 25, 0.1); transform: translateY(-1px); }
.search-shell svg { width: 23px; fill: none; stroke: var(--green); stroke-width: 1.75; stroke-linecap: round; }
.search-shell input { width: 100%; min-width: 0; border: 0; outline: 0; color: var(--ink); background: transparent; font-family: var(--serif); font-size: clamp(1.12rem, 2vw, 1.38rem); }
.search-shell input::placeholder { color: #8c9691; }
.search-submit { padding: 4px 8px; border: 1px solid var(--line); border-radius: 2px; color: var(--ink-faint); background: var(--paper); font-size: 0.76rem; cursor: pointer; }
.search-submit:hover, .search-submit:focus-visible { border-color: var(--green); color: var(--green); outline: 0; }
.search-shell--compact { min-height: 46px; grid-template-columns: 20px 1fr; padding: 0 15px; border-width: 1px; border-radius: 2px; box-shadow: none; }
.search-shell--compact svg { width: 18px; }
.search-shell--compact input { font-family: var(--sans); font-size: 0.9rem; }

.examples { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; margin-top: 19px; }
.examples > span { margin-right: 4px; color: var(--ink-faint); font-family: var(--sans); font-size: 0.76rem; }
.examples button { padding: 7px 11px; border: 1px solid var(--line); border-radius: 2px; background: rgba(255,255,252,.68); cursor: pointer; color: var(--ink-soft); font-family: var(--sans); font-size: 0.78rem; }
.examples button:hover { color: var(--green-deep); border-color: var(--green); background: var(--green-pale); }
.search-promise { margin: 17px 0 0; color: var(--ink-faint); font-family: var(--sans); font-size: 0.76rem; }
.search-promise span { color: var(--green); }

.workspace { display: grid; grid-template-columns: minmax(245px, 310px) minmax(430px, 1fr) minmax(345px, 430px); gap: 0; min-height: calc(100vh - 96px); background: var(--paper); }
.results-panel, .detail-panel { min-width: 0; background: rgba(255, 255, 252, 0.7); }
.results-panel { border-right: 1px solid var(--line); }
.detail-panel { border-left: 1px solid var(--line); }
.panel-heading, .detail-header { padding: 27px 24px 20px; border-bottom: 1px solid var(--line); }
.panel-heading .eyebrow, .graph-heading .eyebrow { margin-bottom: 8px; }
.result-explanation { min-height: 2.7em; margin: 0; color: var(--ink-soft); font-family: var(--serif); font-size: 0.98rem; line-height: 1.35; }
.results-list { padding: 10px; }

.result-card { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; padding: 13px 12px; border: 1px solid transparent; border-radius: 2px; color: inherit; background: transparent; text-align: left; text-decoration: none; cursor: pointer; }
.result-card:hover { background: rgba(220,235,228,.48); }
.result-card.is-selected { border-color: #aac9bb; background: var(--green-pale); }
.result-card--source { border-top-color: var(--line); }
.result-card-main { min-width: 0; }
.result-card strong { display: block; overflow: hidden; text-overflow: ellipsis; font-family: var(--sans); font-size: 1rem; font-weight: 700; white-space: nowrap; }
.result-card small { display: block; margin-top: 4px; color: var(--ink-faint); font-family: var(--sans); font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; }
.result-arrow { color: var(--green); opacity: .55; }
.result-card.is-selected .result-arrow { opacity: 1; }

.graph-panel { position: relative; min-width: 0; overflow: hidden; }
.graph-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 27px 30px 0; }
.graph-heading h2 { margin: 0; font-family: var(--sans); font-size: 1.75rem; font-weight: 700; }
.graph-note {
  height: 6.4em;
  margin: 8px 30px 0;
  padding-right: 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  color: var(--ink-soft);
  font-family: var(--serif);
  font-size: .95rem;
  line-height: 1.35;
}
.graph-stage { position: relative; min-height: 590px; height: calc(100vh - 280px); }
#graph-svg { width: 100%; height: 100%; min-height: 560px; overflow: visible; }
.graph-edge { pointer-events: none; stroke: #bac5bf; stroke-width: 1.35; transition: stroke 110ms ease, stroke-width 110ms ease; }
.graph-edge.is-highlighted { stroke: var(--green); stroke-width: 2.4; }
.graph-node { cursor: pointer; }
.graph-node rect { fill: var(--surface-solid); stroke: #aeb19f; stroke-width: 1.15; filter: drop-shadow(0 5px 10px rgba(43,43,35,.07)); transition: fill 120ms ease, stroke 120ms ease; }
.graph-node:hover rect, .graph-node:focus rect { fill: var(--green-pale); stroke: var(--green); }
.graph-node text { fill: var(--ink); font-family: var(--sans); font-size: 13px; font-weight: 620; pointer-events: none; }
/* Vecindario de obras: se usa cuando la idea todavía no tiene ninguna conexión
   validada con otra idea. Se distingue de una relación intelectual con trazo
   discontinuo y caja de papel, para que nunca se lea como una arista del grafo. */
.graph-edge--work { stroke: #c9cfc4; stroke-dasharray: 4 5; }
.graph-node--work { text-decoration: none; }
.graph-node--work rect { fill: var(--paper-deep); stroke: #c2c5b4; stroke-dasharray: 4 5; }
.graph-node--work:hover rect, .graph-node--work:focus-visible rect { fill: var(--surface-solid); stroke: var(--line-strong); stroke-dasharray: none; }
.graph-node--work text { fill: var(--ink-soft); font-family: var(--serif); font-size: 12.5px; font-weight: 600; }

.graph-node--center { cursor: default; }
.graph-node--center rect { fill: var(--green); stroke: var(--green-deep); }
.graph-node--center text { fill: white; font-family: var(--serif); font-size: 18px; font-weight: 600; }

.empty-neighborhood { position: absolute; inset: 50% auto auto 50%; width: min(360px, 80%); transform: translate(-50%, -35%); text-align: center; }
.empty-neighborhood p { margin: 0; font-family: var(--serif); font-size: 1.35rem; }
.empty-neighborhood span { display: block; margin-top: 8px; color: var(--ink-faint); font-size: .82rem; line-height: 1.4; }

.detail-panel { overflow: auto; max-height: calc(100vh - 96px); }
.detail-empty { display: grid; place-items: center; min-height: 55vh; padding: 40px; color: var(--ink-faint); text-align: center; font-family: var(--serif); font-size: 1.05rem; line-height: 1.5; }
.type-pill, .source-kind, .source-authorship { display: inline-flex; width: fit-content; padding: 4px 7px; border-radius: 2px; background: var(--green-pale); color: var(--green-deep); font-size: .62rem; font-weight: 750; letter-spacing: .09em; text-transform: uppercase; }
.detail-header h2 { margin: 11px 0 0; font-family: var(--sans); font-size: clamp(2rem, 3vw, 3rem); font-weight: 800; letter-spacing: -.04em; line-height: 1; }
.aliases { margin: 12px 0 0; color: var(--ink-faint); font-size: .78rem; line-height: 1.4; }
.detail-section { padding: 23px 20px 28px; border-bottom: 1px solid var(--line); }
.section-title-row { display: flex; align-items: baseline; justify-content: space-between; gap: 15px; margin: 0 3px 12px; }
.section-title-row h3 { margin: 0; font-size: .76rem; letter-spacing: .12em; text-transform: uppercase; }
.section-title-row span { color: var(--ink-faint); font-size: .72rem; }
.source-list, .relation-list { display: grid; gap: 9px; }

.source-card { display: block; padding: 14px; border: 1px solid var(--line); border-radius: 2px; color: inherit; background: rgba(255, 255, 252, 0.72); text-decoration: none; transition: transform 140ms ease, border-color 140ms ease, background 140ms ease; }
.source-card:hover { transform: translateY(-1px); border-color: #9cb9ac; background: var(--surface-solid); }
.source-topline { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 9px; }
.source-authorship { max-width: 70%; background: var(--rose-pale); color: #7b4034; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-card strong { display: block; font-family: var(--sans); font-size: 1.02rem; font-weight: 700; line-height: 1.25; }
.source-locator { display: block; margin-top: 7px; color: var(--ink-soft); font-size: .75rem; line-height: 1.45; }
.source-open { display: block; margin-top: 10px; color: var(--green); font-size: .72rem; font-weight: 700; }
.text-button { margin: 13px 2px 0; padding: 2px; color: var(--green); font-size: .78rem; font-weight: 700; }
.text-button:hover { text-decoration: underline; }

.relation-card { padding: 14px; border: 1px solid var(--line); border-radius: 2px; background: rgba(255,255,252,.56); }
.relation-target { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; width: 100%; padding: 0; border: 0; background: transparent; text-align: left; cursor: pointer; }
.relation-target strong { font-family: var(--sans); font-size: 1rem; font-weight: 700; }
.relation-direction { color: var(--ink-faint); font-size: .65rem; letter-spacing: .08em; text-transform: uppercase; }
.relation-target > span:last-child { color: var(--green); }
.relation-phrase { margin: 9px 0 0; color: var(--green-deep); font-size: .75rem; font-weight: 650; }
.relation-summary { margin: 7px 0 0; color: var(--ink-soft); font-family: var(--serif); font-size: .88rem; line-height: 1.43; }
.relation-card details { margin-top: 10px; }
.relation-card summary { cursor: pointer; color: var(--ink-faint); font-size: .7rem; }
.relation-sources { display: grid; gap: 7px; margin-top: 9px; }
.relation-source-link { color: var(--green-deep); font-size: .72rem; line-height: 1.4; text-decoration-thickness: 1px; text-underline-offset: 2px; }
.no-results { padding: 28px 14px; color: var(--ink-faint); text-align: center; font-family: var(--serif); line-height: 1.5; }
.results-fallback { display: grid; gap: 0; margin: 0 10px 18px; border-top: 1px solid var(--line); }
.results-fallback button { padding: 12px 4px; border: 0; border-bottom: 1px solid var(--line); color: var(--ink); background: transparent; text-align: left; cursor: pointer; font-family: var(--sans); font-size: .86rem; font-weight: 650; }
.results-fallback button::after { content: " ↗"; color: var(--green); }
.results-fallback button:hover, .results-fallback button:focus-visible { color: var(--green); background: var(--green-pale); outline-offset: -2px; }
noscript { display: block; padding: 20px; text-align: center; }

@media (max-width: 1180px) {
  .topic-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workspace { grid-template-columns: 255px minmax(420px, 1fr); }
  .detail-panel { grid-column: 1 / -1; max-height: none; border-top: 1px solid var(--line); border-left: 0; }
  .detail-empty { min-height: 180px; }
  #detail-content { display: grid; grid-template-columns: minmax(260px, .65fr) 1fr 1fr; }
  .detail-header, .detail-section { border-right: 1px solid var(--line); border-bottom: 0; }
}

@media (max-width: 960px) {
  .site-header { flex-wrap: wrap; }
  .header-search { order: 3; width: 100%; max-width: 100%; margin: 0; }
  .nav-menu { gap: 18px; }
  .nav-link { font-size: 0.8rem; }
}

@media (max-width: 780px) {
  .site-header { flex-wrap: wrap; justify-content: space-between; gap: 12px; min-height: 76px; padding: 12px 16px; }
  .header-search { order: 3; width: 100%; max-width: 100%; margin: 8px 0 0; }
  .brand-logo { height: 48px; }
  .nav-menu { gap: 14px; }
  .nav-link { font-size: 0.76rem; padding: 6px 0; }
  .sub-menu { min-width: 180px; }
  .sub-menu a { font-size: 0.72rem; padding: 8px 14px; }
  .hero { min-height: calc(100vh - 82px); padding-top: 45px; }
  .hero h1 { font-size: clamp(3rem, 15vw, 5.4rem); }
  .topic-explorer { margin-top: 38px; }
  .topic-heading { display: block; }
  .topic-heading p { margin-top: 5px; }
  .topic-grid { grid-template-columns: 1fr; }
  .topic-route { min-height: 88px; }
  .search-shell { min-height: 62px; border-radius: 3px; }
  .workspace { grid-template-columns: 1fr; }
  .results-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .results-list { display: flex; overflow-x: auto; padding-bottom: 14px; }
  .result-card { min-width: 220px; }
  .graph-heading { padding-inline: 18px; }
  .graph-note { margin-inline: 18px; }
  .graph-stage { height: 570px; min-height: 570px; overflow: auto; }
  #graph-svg { min-width: 720px; }
  #detail-content { display: block; }
  .detail-header, .detail-section { border-right: 0; border-bottom: 1px solid var(--line); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
