:root {
  color-scheme: light;
  font-family: "Inter", "Segoe UI", sans-serif;
  color: #33475b;
  background-color: #f5f8fa;
  line-height: 1.6;
  --color-primary: #ff7a59;
  --color-primary-dark: #e66a4e;
  --color-secondary: #00a4bd;
  --color-secondary-dark: #008aa0;
  --color-border: #d1d6dc;
  --color-muted: #7c8a96;
  --tree-highlight: var(--color-secondary);
  --tree-highlight-soft: rgba(0, 164, 189, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 0 2rem 3rem;
  background: linear-gradient(180deg, #fefefe 0%, #f5f8fa 100%);
  align-items: stretch;
}

main {
  height: 1000px !important;
}

.header {
  padding: 2.75rem 0 1.75rem;
}

.header__content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  text-align: center;
}

.header__brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.header__logo {
  height: clamp(40px, 6vw, 64px);
  width: auto;
  max-width: clamp(160px, 30vw, 260px);
  object-fit: contain;
}

.legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin: 0 auto 1.5rem;
  padding: 0.65rem 1.1rem;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 999px;
  box-shadow: 0 12px 24px rgba(51, 71, 91, 0.08);
  max-width: min(96%, 720px);
}

.legend[hidden] {
  display: none;
}

.legend__label {
  font-weight: 600;
  color: #33404d;
  font-size: 0.95rem;
}

.legend__list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.legend__item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.04);
  font-size: 0.85rem;
  color: #52606d;
}

.legend__swatch {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 50%;
  border: 2px solid var(--legend-color, var(--color-border));
  background: var(--legend-bg, #fff);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.8);
}

.legend__text {
  font-weight: 500;
}


.header__toolbar {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
}

.header__toolbar > * {
  flex: 1 1 auto;
}

.header__controls {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
  width: 100%;
  max-width: 840px;
  margin-inline: auto;
  padding: 0.85rem 1.1rem;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 28px;
  box-shadow: 0 16px 32px rgba(51, 71, 91, 0.14);
}

.header__controls-buttons {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.header__group {
  display: inline-flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.header__group button {
  border-radius: 999px;
}

.header__group.header__group--zoom {
  gap: 0.45rem;
}

.header__actions > .header__group {
  align-self: flex-end;
}

.tree-search {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  min-width: 220px;
  padding: 0.4rem 0.75rem;
  background: #fff;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.04);
  flex: 1 1 320px;
  position: relative;
}

.tree-search__label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.tree-search__controls {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex: 1 1 auto;
}

.tree-search__input {
  flex: 1 1 160px;
  min-width: 150px;
  border: none;
  background: transparent;
  font-size: 0.92rem;
  padding: 0.15rem 0.25rem;
  color: #21303d;
}

.tree-search__input:focus {
  outline: none;
  box-shadow: none;
}

.tree-search__input::placeholder {
  color: #7c8a96;
}

.tree-search__reset {
  background: transparent;
  color: var(--color-secondary);
  border-color: var(--color-secondary);
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
}

.tree-search__controls button[type="submit"] {
  border-color: var(--color-secondary);
  background-color: var(--color-secondary);
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
}

.tree-search__controls button[type="submit"]:hover,
.tree-search__controls button[type="submit"]:focus {
  background-color: var(--color-secondary-dark);
  border-color: var(--color-secondary-dark);
}

.tree-search__reset:hover,
.tree-search__reset:focus {
  background-color: rgba(0, 164, 189, 0.12);
  color: var(--color-secondary-dark);
}

.tree-search__message {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.tree-search__message--visible {
  position: static;
  display: block;
  width: 100%;
  height: auto;
  margin-top: 0.35rem;
  padding: 0;
  clip: auto;
  white-space: normal;
  color: var(--color-muted);
  font-size: 0.82rem;
}

.tree-search__message--visible[data-tone="error"] {
  color: #d64545;
  font-weight: 600;
}

.tree-search.tree-search--disabled {
  opacity: 0.6;
  pointer-events: none;
}



button {
  border: 1px solid var(--color-primary);
  background-color: var(--color-primary);
  color: #fff;
  border-radius: 999px;
  padding: 0.45rem 1.35rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease, box-shadow 0.2s ease,
    transform 0.2s ease;
}

button:hover,
button:focus {
  background-color: var(--color-primary-dark);
  outline: none;
  transform: translateY(-1px);
}

button:focus-visible {
  box-shadow: 0 0 0 3px rgba(255, 122, 89, 0.28);
}

main {
  flex: 1;
  overflow-x: auto;
  overflow-y: auto;
  position: relative;
}

.tree {
  position: relative;
  width: 100%;
  min-height: 100%;
  overflow: visible;
  padding-bottom: 1.5rem;
}

.tree__viewport {
  height: 1000px !important;
  min-width: 100%;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 1.5rem 2rem 3rem;
  position: relative;

  /* overflow: auto; */

}

.tree__root {
  position: relative;
  display: flex;
  justify-content: center;
  transform-origin: top center;
  transition: transform 0.2s ease;
  padding-top: 0;
  list-style: none;
  margin: 0;
  padding-left: 0;
  width: max-content;

}

.tree__children {
  position: relative;
  display: flex;
  justify-content: center;
  list-style: none;
  margin: 0;
  padding-left: 0;
  gap: 2rem;
  padding-top: 2.5rem;
}

.tree__children::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  border-left: 2px solid var(--branch-connector-color, var(--color-border));
  height: 2.5rem;
}

.tree__branch {
  position: relative;
  padding: 2.5rem 1.25rem 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 0 0 auto;
}

.tree__branch::before,
.tree__branch::after {
  content: "";
  position: absolute;
  top: 0;
  width: 50%;
  height: 2.5rem;
  border-top: 2px solid var(--branch-connector-color, var(--color-border));
}

.tree__branch::before {
  left: 50%;
  border-left: 2px solid var(--branch-connector-color, var(--color-border));
}

.tree__branch::after {
  right: 50%;
  border-right: 2px solid var(--branch-connector-color, var(--color-border));
}

.tree__branch:first-child::after,
.tree__branch:last-child::before {
  border-top: none;
  width: 0;
}

.tree__branch:only-child::after {
  display: none;
}

.tree__branch:only-child::before {
  right: auto;
  left: 50%;
  width: 0;
  border-right: none;
  border-left: 2px solid var(--branch-connector-color, var(--color-border));
}

.tree__branch--root {
  padding-top: 0;
}

.tree__branch--root::before,
.tree__branch--root::after {
  display: none;
}

.node {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.45rem;
  background: var(--node-background-color, #ffffff);
  border: 1.5px solid var(--node-border-color, var(--color-border));
  border-radius: 16px;
  padding: 1.1rem 1.45rem;
  min-width: 220px;
  box-shadow: 0 18px 40px var(--node-shadow-color, rgba(51, 71, 91, 0.08));
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease,
    background-color 0.2s ease;
}

.node:hover {
  border-color: var(--node-hover-border-color, var(--color-secondary));
  box-shadow: 0 20px 45px var(--node-shadow-color, rgba(0, 164, 189, 0.16));
  transform: translateY(-2px);
}

.node__toggle {
  position: absolute;
  top: -0.75rem;
  right: -0.75rem;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  border: 1px solid rgba(0, 164, 189, 0.45);
  background: linear-gradient(135deg, #ffffff 0%, rgba(0, 164, 189, 0.12) 100%);
  color: var(--color-secondary);
  font-size: 1.1rem;
  padding: 0;
  display: grid;
  place-items: center;
  transition: transform 0.2s ease, background-color 0.2s ease;
}

.node__toggle:hover,
.node__toggle:focus {
  background-color: rgba(0, 164, 189, 0.2);
}

.node__toggle[hidden] {
  display: none;
}

.node__body {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
}

.node__badge {
  position: absolute;
  top: -1.0rem;
  left: -1.0rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  font-size: 1rem;
  font-weight: 700;
  color: #d64545;
  border: 2px solid rgba(214, 69, 69, 0.35);
  box-shadow: 0 10px 22px rgba(214, 69, 69, 0.2);
  background: rgba(214, 69, 69, 0.12);
  z-index: 1;
}

.node__badge::before {
  content: "★";
  transform: translateY(-1px);
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.18));
}

.node__badge--positive {
  color: #1fab5a;
  background: rgba(76, 217, 100, 0.18);
  border-color: rgba(31, 171, 90, 0.45);
  box-shadow: 0 12px 26px rgba(76, 217, 100, 0.28);
}

.node__badge--negative {
  color: #d64545;
  background: rgba(230, 57, 70, 0.18);
  border-color: rgba(214, 69, 69, 0.55);
  box-shadow: 0 12px 26px rgba(214, 69, 69, 0.28);
}

.node__badge[hidden] {
  display: none;
}

.node__name {
  display: block;
  font-weight: 700;
  font-size: 1.08rem;
  color: #21303d;
}

.node__meta {
  display: grid;
  gap: 0.4rem;
  width: 100%;
  font-size: 0.9rem;
  color: var(--color-muted);
  text-align: left;
}

.node__meta-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.node__meta-label {
  font-weight: 600;
  color: #33404d;
}

.node__meta-value {
  color: #52606d;
  text-align: right;
}

.tree__branch.is-collapsed > .tree__children {
  display: none;
}

.tree__branch.is-collapsed > .node {
  opacity: 0.92;
}

.tree__branch.is-collapsed::before,
.tree__branch.is-collapsed::after,
.tree__branch.is-collapsed > .tree__children::before {
  border-color: transparent;
}

.tree__branch--selected > .node,
.tree__branch--selected .node {
  border-color: var(--node-hover-border-color, var(--tree-highlight));
  box-shadow: 0 0 0 3px var(--tree-highlight-soft),
    0 18px 40px var(--node-shadow-color, rgba(0, 164, 189, 0.14));
  background: var(--node-background-color, #ffffff);
}

.tree__branch--selected::before,
.tree__branch--selected::after,
.tree__branch--selected > .tree__children::before,
.tree__branch--selected .tree__branch::before,
.tree__branch--selected .tree__branch::after {
  border-color: var(--branch-connector-color, var(--tree-highlight));
}

.zoom__label {
  min-width: 3.5rem;
  text-align: center;
  font-weight: 600;
  color: #33404d;
}

.header__group button[aria-label^="Zoom"] {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  padding: 0;
  font-size: 1.1rem;
}

.header__group button#zoomReset {
  border-radius: 999px;
  padding-inline: 0.9rem;
}

.header__group button[aria-label^="Zoom"][disabled],
.header__group button#zoomReset[disabled] {
  opacity: 0.5;
  cursor: default;
}

@media (max-width: 768px) {
  body {
    padding-inline: 1rem;
  }

  .tree__viewport {
    padding-inline: 1rem;
    position: relative;  
  }
  .header__toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .header__toolbar > * {
    width: 100%;
  }

  .header__brand {
    flex-direction: column;
    gap: 0.65rem;
  }

  .header__logo {
    height: 42px;
  }

  .legend {
    flex-direction: column;
    gap: 0.5rem;
    border-radius: 20px;
  }

  .tree__root {
    gap: 2rem;
  }

  .tree-search__controls {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .tree-search__input {
    width: 100%;
    min-width: 0;
  }

  .tree-search {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    border-radius: 24px;
  }

  .tree-search__controls button {
    width: 100%;
  }

  .tree-search__message--visible {
    text-align: center;
  }
}

.tree-search__results {
  list-style: none;
  padding: 0.5rem;
  margin: 0.5rem auto 0;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  background: #ffffff;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
  max-height: 320px;
  overflow-y: auto;
}

.tree-search__result {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.75rem;
  font: inherit;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: #33475b;
  cursor: pointer;
}

.tree-search__result:hover,
.tree-search__result:focus-visible {
  background: var(--tree-highlight-soft);
  outline: none;
}
