:root {
  --bg: #f4efe4;
  --bg-alt: #e2ebdf;
  --paper: rgba(255, 251, 243, 0.78);
  --ink: #23313a;
  --ink-soft: #51636d;
  --line: rgba(35, 49, 58, 0.1);
  --accent: #0d7a72;
  --accent-strong: #09574f;
  --accent-warm: #c46e44;
  --shadow: 0 22px 70px rgba(34, 55, 58, 0.12);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Avenir Next", "Trebuchet MS", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(196, 110, 68, 0.14), transparent 28%),
    radial-gradient(circle at right 15%, rgba(13, 122, 114, 0.12), transparent 26%),
    linear-gradient(140deg, var(--bg), var(--bg-alt));
}

.page-bg::before,
.page-bg::after {
  content: "";
  position: fixed;
  border-radius: 999px;
  filter: blur(8px);
  z-index: 0;
}

.page-bg::before {
  width: 18rem;
  height: 18rem;
  right: -4rem;
  top: 5rem;
  background: rgba(196, 110, 68, 0.16);
}

.page-bg::after {
  width: 12rem;
  height: 12rem;
  left: -2rem;
  bottom: 10rem;
  background: rgba(13, 122, 114, 0.16);
}

.shell {
  position: relative;
  z-index: 1;
  width: min(1440px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 3rem 0 4rem;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 2.5fr) minmax(18rem, 1fr);
  gap: 0.6rem 2.4rem;
  align-items: end;
  padding: 0.5rem 0 1.45rem;
  max-width: none;
}

.hero .eyebrow {
  grid-column: 1 / -1;
}

.eyebrow,
.panel-kicker {
  margin: 0 0 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.78rem;
  color: var(--accent-strong);
}

.hero h1,
.panel h2 {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", serif;
  font-weight: 600;
  line-height: 0.95;
}

.hero h1 {
  font-size: clamp(2.5rem, 6vw, 4.6rem);
  max-width: none;
}

.hero-copy {
  max-width: 30rem;
  margin-top: 0;
  color: var(--ink-soft);
  font-size: 1.03rem;
  line-height: 1.7;
}

.tab-switcher {
  display: inline-flex;
  gap: 0.45rem;
  margin-bottom: 1.4rem;
  padding: 0.4rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(35, 49, 58, 0.1);
  box-shadow: 0 12px 24px rgba(35, 49, 58, 0.08);
}

.tab-button {
  border: none;
  border-radius: 999px;
  padding: 0.8rem 1rem;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  font-weight: 600;
  transition: background 180ms ease, color 180ms ease, transform 180ms ease;
}

.tab-button:hover {
  transform: translateY(-1px);
}

.tab-button.active {
  background: linear-gradient(120deg, var(--accent), var(--accent-strong));
  color: #f7f7f2;
  box-shadow: 0 10px 20px rgba(13, 122, 114, 0.18);
}

.tab-content {
  display: block;
}

.layout {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 1rem;
}

.graph-layout {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 1rem;
}

.panel {
  background: var(--paper);
  backdrop-filter: blur(18px);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  padding: 1.35rem;
  min-height: 18rem;
}

.panel-query {
  grid-column: span 4;
}

.panel-results {
  grid-column: span 4;
}

.panel-transcript {
  grid-column: span 4;
  grid-row: span 2;
  display: flex;
  flex-direction: column;
}

.panel-add {
  grid-column: span 4;
}

.panel-catalog {
  grid-column: span 4;
}

.panel-map-view {
  grid-column: 1 / -1;
}

.panel-map-info {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 1rem;
  align-items: start;
}

.graph-toolbar,
.graph-zoom-controls {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.panel-head {
  margin-bottom: 1.1rem;
}

.panel-map-info > .panel-head {
  grid-column: 1 / -1;
  margin-bottom: 0;
}

.panel-head-split {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.stack {
  display: grid;
  gap: 0.9rem;
}

.field {
  display: grid;
  gap: 0.42rem;
}

.field span {
  font-size: 0.92rem;
  color: var(--ink-soft);
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  padding: 0.88rem 0.98rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(35, 49, 58, 0.14);
  background: rgba(255, 255, 255, 0.74);
  color: var(--ink);
  transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

input:focus,
select:focus {
  outline: none;
  border-color: rgba(13, 122, 114, 0.5);
  box-shadow: 0 0 0 4px rgba(13, 122, 114, 0.1);
  transform: translateY(-1px);
}

.button {
  border: none;
  border-radius: 999px;
  padding: 0.95rem 1.2rem;
  cursor: pointer;
  font-weight: 600;
  transition: transform 180ms ease, box-shadow 180ms ease, opacity 180ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.button-primary {
  background: linear-gradient(120deg, var(--accent), var(--accent-strong));
  color: #f7f7f2;
  box-shadow: 0 16px 30px rgba(13, 122, 114, 0.2);
}

.button-secondary {
  background: linear-gradient(120deg, #c98962, var(--accent-warm));
  color: #fff7f1;
  box-shadow: 0 16px 30px rgba(196, 110, 68, 0.18);
}

.ghost-button {
  border: 1px solid rgba(35, 49, 58, 0.12);
  border-radius: 999px;
  padding: 0.55rem 0.9rem;
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink);
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.ghost-button:hover {
  transform: translateY(-1px);
  border-color: rgba(13, 122, 114, 0.28);
  background: rgba(255, 255, 255, 0.88);
}

.hidden {
  display: none !important;
}

.results-empty,
.result-card,
.result-status {
  border-radius: var(--radius-lg);
  border: 1px solid rgba(35, 49, 58, 0.08);
  background: rgba(255, 255, 255, 0.56);
}

.results-empty {
  display: grid;
  place-items: center;
  min-height: 14rem;
  color: var(--ink-soft);
  text-align: center;
  padding: 1.5rem;
}

.result-card {
  padding: 1rem;
}

.result-card h3,
.result-status h3 {
  margin: 0 0 0.4rem;
  font-size: 1rem;
}

.result-card p,
.result-status p {
  margin: 0;
  color: var(--ink-soft);
}

.result-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.7rem;
}

.result-item {
  padding: 0.8rem 0.9rem;
  border-radius: var(--radius-md);
  background: rgba(226, 235, 223, 0.72);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.result-item small {
  color: var(--ink-soft);
}

.result-status {
  padding: 1rem;
}

.graph-stage {
  position: relative;
  min-height: clamp(44rem, 76vh, 64rem);
  overflow: hidden;
  padding: 1.35rem;
  border-radius: 24px;
  border: 1px solid rgba(35, 49, 58, 0.08);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(248, 246, 240, 0.94)),
    linear-gradient(90deg, rgba(13, 122, 114, 0.035) 1px, transparent 1px),
    linear-gradient(rgba(13, 122, 114, 0.035) 1px, transparent 1px);
  background-size: auto, 34px 34px, 34px 34px;
  cursor: grab;
  touch-action: none;
}

.graph-stage.is-panning {
  cursor: grabbing;
}

.graph-empty {
  position: absolute;
  inset: 1.35rem;
  z-index: 2;
  display: grid;
  place-items: center;
  padding: 2rem;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(248, 246, 240, 0.92));
  color: var(--ink-soft);
  text-align: center;
  line-height: 1.7;
}

.family-graph {
  display: block;
  width: 100%;
  min-width: 0;
  height: auto;
}

.graph-edge {
  fill: none;
  stroke-width: 3;
  opacity: 0.9;
  transition: opacity 180ms ease, stroke-width 180ms ease;
}

.graph-edge.tata {
  stroke: #11756d;
}

.graph-edge.mama {
  stroke: #c46e44;
}

.graph-edge.dimmed {
  opacity: 0.16;
}

.graph-edge.active {
  stroke-width: 4;
  opacity: 1;
}

.graph-node {
  cursor: pointer;
  transition: opacity 180ms ease, transform 180ms ease;
}

.graph-node rect {
  fill: rgba(255, 252, 247, 0.94);
  stroke: rgba(35, 49, 58, 0.16);
  stroke-width: 1.5;
  filter: drop-shadow(0 10px 18px rgba(35, 49, 58, 0.08));
}

.graph-node text {
  fill: var(--ink);
  font-size: 15px;
  font-weight: 600;
}

.graph-node.dimmed {
  opacity: 0.28;
}

.graph-node.active rect {
  stroke: rgba(13, 122, 114, 0.78);
  stroke-width: 2.4;
  fill: rgba(236, 251, 248, 0.98);
}

.graph-node:hover rect {
  transform: translateY(-1px);
}

.graph-node-level {
  fill: var(--ink-soft);
  font-size: 12px;
  font-weight: 500;
}

.graph-stats {
  grid-column: 1 / -1;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.graph-component-label {
  fill: var(--ink-soft);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.graph-component-outline {
  fill: rgba(255, 255, 255, 0.18);
  stroke: rgba(35, 49, 58, 0.08);
  stroke-width: 1.2;
  stroke-dasharray: 8 8;
}

.graph-family-block rect {
  fill: rgba(13, 122, 114, 0.06);
  stroke: rgba(13, 122, 114, 0.2);
  stroke-width: 1.2;
}

.graph-family-block text {
  fill: var(--accent-strong);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.graph-family-block.dimmed {
  opacity: 0.2;
}

.graph-family-block.active rect {
  fill: rgba(13, 122, 114, 0.12);
  stroke: rgba(13, 122, 114, 0.42);
}

.graph-legend {
  grid-column: span 4;
  display: grid;
  gap: 0.75rem;
  padding: 1rem;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.56);
  border: 1px solid rgba(35, 49, 58, 0.08);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--ink-soft);
}

.legend-line {
  display: inline-block;
  width: 2.6rem;
  height: 0.25rem;
  border-radius: 999px;
}

.legend-line-father {
  background: #11756d;
}

.legend-line-mother {
  background: #c46e44;
}

.graph-note,
.graph-selection {
  padding: 1rem;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.56);
  border: 1px solid rgba(35, 49, 58, 0.08);
}

.graph-note {
  grid-column: span 8;
  color: var(--ink-soft);
  line-height: 1.7;
}

.graph-selection {
  grid-column: 1 / -1;
}

.graph-selection h3 {
  margin: 0 0 0.7rem;
  font-size: 1rem;
}

.graph-selection-content {
  color: var(--ink-soft);
  line-height: 1.7;
}

.graph-selection-content strong {
  display: inline-block;
  font-size: 1.08rem;
  color: var(--ink);
}

.graph-selection-content p {
  margin: 0.55rem 0 0;
}

.graph-selection-meta {
  margin-top: 0.65rem;
  color: var(--ink-soft);
}

.graph-selection-group + .graph-selection-group {
  margin-top: 0.9rem;
}

.graph-selection-list {
  margin: 0.55rem 0 0;
  padding-left: 1.1rem;
}

.graph-selection-list li + li {
  margin-top: 0.25rem;
}

.transcript-console {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 28rem;
  padding: 1rem;
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(9, 19, 24, 0.96), rgba(19, 34, 39, 0.96)),
    radial-gradient(circle at top right, rgba(13, 122, 114, 0.18), transparent 30%);
  color: #def7f1;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.transcript-empty {
  display: grid;
  place-items: center;
  flex: 1;
  color: rgba(222, 247, 241, 0.68);
  text-align: center;
  line-height: 1.7;
  padding: 1rem;
}

.transcript-log {
  display: grid;
  gap: 0.8rem;
  overflow: auto;
  max-height: 52rem;
  padding-right: 0.2rem;
}

.transcript-entry {
  padding: 0.9rem;
  border-radius: 18px;
  background: rgba(8, 15, 18, 0.62);
  border: 1px solid rgba(126, 255, 228, 0.12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.transcript-entry-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.7rem;
}

.transcript-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 0.35rem 0.55rem;
  border-radius: 999px;
  background: rgba(126, 255, 228, 0.08);
  color: #9fe5da;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.transcript-copy {
  border: none;
  padding: 0;
  background: transparent;
  color: #93cbc1;
  cursor: pointer;
  font-size: 0.84rem;
}

.transcript-copy:hover {
  color: #dffaf5;
}

.transcript-block {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.7;
  font-family: "SFMono-Regular", "Menlo", monospace;
  font-size: 0.92rem;
}

.transcript-divider {
  height: 1px;
  margin: 0.72rem 0;
  background: linear-gradient(90deg, rgba(159, 229, 218, 0.16), transparent);
}

.truth-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  width: fit-content;
  margin-top: 0.75rem;
  padding: 0.5rem 0.8rem;
  border-radius: 999px;
  background: rgba(13, 122, 114, 0.12);
  color: var(--accent-strong);
  font-weight: 700;
}

.truth-chip.false {
  background: rgba(196, 110, 68, 0.16);
  color: #8f4a22;
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.stat-card {
  padding: 0.95rem 1rem;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.64);
  border: 1px solid rgba(35, 49, 58, 0.08);
}

.stat-label {
  display: block;
  color: var(--ink-soft);
  font-size: 0.86rem;
}

.stat-card strong {
  display: block;
  margin-top: 0.4rem;
  font-size: 2rem;
  font-family: "Iowan Old Style", "Palatino Linotype", serif;
}

.people-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.person-pill {
  padding: 0.48rem 0.82rem;
  border-radius: 999px;
  background: rgba(13, 122, 114, 0.1);
  color: var(--accent-strong);
  border: 1px solid rgba(13, 122, 114, 0.12);
  font-size: 0.92rem;
}

.notice {
  margin-top: 0.8rem;
  padding: 0.82rem 0.95rem;
  border-radius: var(--radius-md);
  background: rgba(13, 122, 114, 0.1);
  color: var(--accent-strong);
}

.notice.error {
  background: rgba(196, 110, 68, 0.14);
  color: #8f4a22;
}

code {
  font-family: "SFMono-Regular", "Menlo", monospace;
  font-size: 0.92em;
  padding: 0.14rem 0.32rem;
  border-radius: 0.35rem;
  background: rgba(35, 49, 58, 0.08);
}

@media (max-width: 920px) {
  .panel-query,
  .panel-results,
  .panel-transcript,
  .panel-add,
  .panel-catalog,
  .panel-map-view,
  .panel-map-info {
    grid-column: 1 / -1;
  }

  .panel-transcript {
    grid-row: auto;
  }

  .hero {
    grid-template-columns: 1fr;
    gap: 0.8rem;
    padding-bottom: 1.7rem;
  }

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

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

  .graph-legend,
  .graph-note {
    grid-column: 1 / -1;
  }

  .hero h1 {
    max-width: 11ch;
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(100% - 1rem, 100%);
    padding-top: 1.4rem;
  }

  .panel {
    padding: 1rem;
    border-radius: 22px;
  }

  .panel-head-split {
    flex-direction: column;
    align-items: flex-start;
  }

  .stats {
    grid-template-columns: 1fr;
  }

  .graph-stats {
    grid-template-columns: 1fr;
  }

  .result-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .transcript-console {
    min-height: 22rem;
  }

  .graph-stage {
    min-height: 26rem;
    padding: 0.75rem;
  }

  .graph-empty {
    inset: 0.75rem;
    padding: 1.25rem;
  }
}
