:root {
  --bg: #f9f9f9;
  --text: #222;
  --primary: #4A90E2;
  --secondary: #f0f0f0;
  --hover: #e0e0e0;
  --accent: #7ED321;
  --brand: #0033a0;
  --panel-bg: #ffffff;
  --panel-border: #eeeeee;
  --shadow: 0 2px 8px rgba(0,0,0,.04);
  --shadow-strong: 0 4px 14px rgba(0,0,0,.08);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.content-container {
  max-width: 1200px;
  margin: 0 auto;
  padding-left: 40px;
  padding-right: 20px;
}

/* Header */
header {
  background-color: #fff;
  border-bottom: 1px solid #eee;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
}
.site-name { font-size: 20px; font-weight: bold; }

.nav-menu {
  list-style: none;
  display: flex;
  gap: 20px;
  margin: 0;
  padding: 0;
}
.nav-menu li a {
  text-decoration: none;
  color: #000;
  font-size: 15px;
  font-weight: 500;
  transition: color .2s ease;
}
.nav-menu li a:hover,
.nav-menu li a.active { color: #d90c1a; }

/* Intro */
.intro-flex {
  display: flex;
  align-items: flex-start;
  gap: 32px;
  max-width: 1200px;
  margin: 40px auto;
  padding: 0 20px;
}
.intro-image {
  width: 200px;
  height: auto;
  border-radius: 10px;
  box-shadow: 0 4px 8px rgba(0,0,0,.1);
  margin-top: 0.5em;
  flex-shrink: 0;
}
.intro-text-block {
  flex: 1;
  padding-left: 20px;
  max-width: 800px;
}
h1.left-aligned {
  font-size: 26px;
  margin-bottom: 20px;
  text-align: left;
}
#description {
  font-size: 15px;
  line-height: 1.5;
  color: #000;
  text-align: left;
}
#description p { margin: 10px 0 14px 0; }
#description ul { margin: 14px 0 0 24px; }

/* Main / Panels */
main { width: 100%; display: block; }
.viz-wrap {
  max-width: 1200px;
  margin: 60px auto 20px auto;
  padding: 0 20px 20px 20px;
}
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}
.panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 16px 16px 8px 16px;
  box-shadow: var(--shadow);
}
.panel:hover { box-shadow: var(--shadow-strong); }
.panel h2 {
  font-size: 18px;
  margin: 0 0 10px 0;
  letter-spacing: .2px;
  line-height: 1.3;
}
.svg-holder { width: 100%; display: block; margin-top: 0; height: 520px; }
.svg-holder.large { height: 760px; }
svg { background: #fff; border-radius: 10px; }
#viz1.svg-holder,
#viz2.svg-holder { height: clamp(560px, 62vh, 760px) !important; }

/* Tooltip */
#tooltip {
  position: fixed;
  padding: 10px 14px;
  background: #fff;
  border: 1px solid #3a78c0;
  border-radius: 8px;
  pointer-events: none;
  font-size: 14px;
  color: #222;
  box-shadow: 0 4px 10px rgba(0,0,0,.1);
  opacity: 0;
  visibility: hidden;
  transition: opacity .15s;
  min-width: 180px;
  max-width: 480px;
  max-height: calc(100vh - 32px);
  overflow: auto;
  width: auto;
  white-space: pre-line;
  word-wrap: break-word;
  line-height: 1;
  z-index: 200;
}
#tooltip .t-name { font-weight: 700; margin-bottom: 4px; color: #000; }
#tooltip .t-path { font-size: 12px; color: #3a78c0; }
#tooltip .t-extra { margin-top: 6px; font-size: 14px; color: #444; line-height: 1.3; }
#tooltip .t-extra .t-field { margin-top: 6px; }
#tooltip .t-extra strong { color: #000; font-weight: 600; margin-right: 4px; }

/* Link & Node styles */
#viz1 .links path,
#viz2 .links path {
  stroke: var(--primary);
  stroke-opacity: .8;
  stroke-width: 1.5;
  fill: none;
}
#viz2 .links path { stroke: var(--accent); }
#viz1 .nodes circle,
#viz2 .nodes circle {
  fill: var(--primary);
  transition: transform .08s ease-out, r .12s ease-out;
}
#viz2 .nodes circle { fill: var(--accent); }
.nodes circle:hover { r: 7.5; filter: drop-shadow(0 1px 2px rgba(0,0,0,.15)); }

/* Legend */
.legend-host { margin: 20px 0 2px 0; }
.legend.legend-dom { font-size: 16px; color: #333; user-select: none; }
.legend.legend-dom .legend-btnrow {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.legend.legend-dom .legend-btn {
  height: 24px;
  min-width: 56px;
  padding: 0 8px;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 5px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .2px;
  color: #222;
  cursor: pointer;
}
.legend.legend-dom .legend-btn:hover { box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.legend.legend-dom .legend-btn:active { transform: translateY(1px); }
.legend.legend-dom .legend-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 6px 18px;
}
.legend.legend-dom .legend-item {
  display: grid;
  grid-template-columns: 14px 12px 1fr;
  align-items: center;
  column-gap: 8px;
  position: relative;
  cursor: pointer;
}
.legend.legend-dom .legend-item input[type="checkbox"] {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.legend.legend-dom .legend-item .cb {
  width: 14px;
  height: 14px;
  border: 1px solid #999;
  border-radius: 3px;
  background: #fff;
  pointer-events: none;
  position: relative;
}
.legend.legend-dom .legend-item input[type="checkbox"]:checked + .cb { border-color: #222; }
.legend.legend-dom .legend-item input[type="checkbox"]:checked + .cb::after {
  content: "";
  position: absolute;
  width: 7px;
  height: 4px;
  left: 2px;
  top: 3px;
  border-left: 1px solid #222;
  border-bottom: 1px solid #222;
  transform: rotate(-45deg);
}
.legend.legend-dom .legend-item .swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  opacity: 1;
  transition: opacity .15s ease;
}
.legend.legend-dom .legend-item .label {
  color:#333;
  line-height: 1.2;
  font-size: 14px;
}

/* Footer */
footer {
  background-color: #fff;
  color: #444;
  font-size: 13px;
  text-align: center;
  padding: 50px 0 10px 0;
  border-top: 1px solid #eee;
  margin-top: 40px;
}
footer a { color: #3a3aff; text-decoration: none; }
footer a:hover { text-decoration: underline; }

/* Responsive */
@media (max-width: 1000px) {
  .grid-2 { grid-template-columns: 1fr; }
  .svg-holder { height: 460px; }
  .svg-holder.large { height: 680px; }
  .panel { padding: 14px 14px 8px 14px; }

  .intro-flex {
    flex-direction: column;
    align-items: center;
    padding: 0 20px;
  }
  .intro-image { width: 60%; margin-bottom: 16px; }
  .intro-text-block { text-align: left; width: 100%; padding: 0; }
}
@media (max-width: 720px) {
  h1.left-aligned { font-size: 22px; text-align: center; }
}
@media (max-width: 700px){
  .legend.legend-dom .legend-grid { grid-template-columns: 1fr; }
  #tooltip { max-width: 320px; }
}
@media (max-width: 600px) {
  .svg-holder { height: 420px; }
  .svg-holder.large { height: 620px; }
  .site-name { font-size: 20px; }
  .nav-menu { gap: 16px; }
  .nav-menu li a { font-size: 15px; }
  #tooltip { max-width: 280px; }
}
@media print {
  header, footer { display: none !important; }
  .viz-wrap { padding: 0; margin: 0; }
  .panel { border: none; box-shadow: none; }
  body { background: #fff; }
}
