:root {
  color-scheme: light dark;
  --bg: #f8f9fb;
  --panel: #ffffff;
  --ink: #1f2933;
  --border: #d0d7e2;
  --male-bg: #d7edff;
  --female-bg: #ffd9e6;
  --junction: #94a3b8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
}

.app {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.app__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
}

h1 {
  margin: 0;
  font-size: 1.8rem;
}

p {
  margin: 4px 0 0;
  color: #52606d;
}

.legend {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.9rem;
}

.legend__swatch {
  width: 18px;
  height: 12px;
  border-radius: 4px;
  display: inline-block;
  margin-right: 6px;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.legend__swatch--male {
  background: var(--male-bg);
}

.legend__swatch--female {
  background: var(--female-bg);
}

.control-block {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

button,
label.file-input {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--ink);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.15s ease;
}

button.primary {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}

button:hover,
label.file-input:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.15);
}

label.file-input input {
  display: none;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  gap: 16px;
  min-height: 680px;
}

.workspace__left,
.workspace__right {
  background: var(--panel);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  display: flex;
  flex-direction: column;
}

.workspace__left {
  gap: 12px;
  min-height: 760px;
}

.settings-panel {
  background: rgba(248, 250, 252, 0.85);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.slider-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.slider {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9rem;
}

.slider select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  font-size: 0.95rem;
  background: #fff;
  color: var(--ink);
}

.slider__header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-weight: 600;
}

.slider output {
  font-variant-numeric: tabular-nums;
  color: #475569;
}

.slider input[type="range"] {
  width: 100%;
  accent-color: #2563eb;
}

.slider--checkbox {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.checkbox-label input {
  display: none;
}

.switch {
  width: 42px;
  height: 22px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #e2e8f0;
  position: relative;
  transition: background 0.2s ease;
}

.switch::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  top: 1px;
  left: 1px;
  transition: transform 0.2s ease;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.3);
}

.checkbox-label input:checked + .switch {
  background: #2563eb;
}

.checkbox-label input:checked + .switch::after {
  transform: translateX(20px);
}

.export-btn {
  width: 100%;
}

#chart {
  flex: 1;
  border: 1px dashed var(--border);
  border-radius: 12px;
  position: relative;
  min-height: 640px;
  background: radial-gradient(circle at center, rgba(99, 102, 241, 0.06), transparent 60%);
  overflow: hidden;
}

#chart svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  position: absolute;
  inset: 0;
}

#status {
  margin-top: 12px;
  font-size: 0.9rem;
  color: #475569;
}

.family-card rect {
  stroke: #1e293b;
  stroke-width: 1;
}

.family-card text {
  fill: #0f172a;
  font-weight: 600;
  text-anchor: middle;
  dominant-baseline: middle;
}

.family-card .direct-indicator {
  pointer-events: none;
  stroke: none;
}

.root-node .root-label {
  fill: #0f172a;
  font-weight: 600;
}

.family-card .role {
  font-size: 0.72em;
  fill: #475569;
}

.link {
  fill: none;
}

.junction-line {
  fill: none;
}

circle.generation-ring {
  stroke: rgba(59, 130, 246, 0.2);
  stroke-dasharray: 6 6;
  fill: none;
}

@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 1fr;
  }
}
.slider--color input {
  width: 100%;
  height: 38px;
  padding: 0;
  border: none;
  background: transparent;
}
