:root {
  color-scheme: light;
  --bg: #f6f7f8;
  --surface: #ffffff;
  --surface-soft: #f0f4f3;
  --ink: #17201e;
  --muted: #65736f;
  --line: #d8dfdd;
  --line-strong: #b8c3bf;
  --teal: #007c74;
  --teal-ink: #003f3b;
  --blue: #285da8;
  --green: #287a3e;
  --amber: #a46300;
  --red: #b43a31;
  --shadow: 0 18px 45px rgba(23, 32, 30, 0.08);
  --radius: 8px;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(0, 124, 116, 0.08), rgba(246, 247, 248, 0) 260px),
    var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 20px clamp(16px, 4vw, 34px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(12px);
  position: relative;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  padding: 8px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #eaf4f1;
  flex: 0 0 auto;
}

.brand-mark span {
  width: 100%;
  aspect-ratio: 1;
  border: 2px solid var(--teal);
  border-radius: 3px;
  background: var(--surface);
}

.brand h1,
.brand p,
.panel-heading h2,
.panel-heading p,
.inspector-header h2,
.inspector-header p,
.sidebar-header h2 {
  margin: 0;
}

.brand h1 {
  font-size: 1.2rem;
  line-height: 1.2;
}

.brand p,
.panel-heading p,
.inspector-header p,
#sampleStatus {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.35;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.icon-button,
.text-button,
.tab-button,
.segment {
  min-height: 36px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius);
}

.icon-button {
  width: 38px;
  display: inline-grid;
  place-items: center;
  font-family: var(--mono);
  font-weight: 700;
}

.text-button {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  padding: 0 12px;
  font-weight: 650;
}

.text-button.small {
  min-height: 32px;
  padding: 0 10px;
  font-size: 0.86rem;
}

.icon-button:hover,
.text-button:hover,
.tab-button:hover,
.segment:hover,
.target-button:hover {
  border-color: var(--teal);
  color: var(--teal-ink);
}

.layout {
  display: grid;
  grid-template-columns: minmax(240px, 290px) minmax(0, 1fr);
  gap: 18px;
  padding: 18px clamp(16px, 4vw, 34px) 34px;
  align-items: start;
}

.sidebar,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.sidebar {
  position: sticky;
  top: 90px;
  max-height: calc(100vh - 112px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.sidebar-header,
.panel-heading,
.inspector-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.sidebar-header {
  padding: 16px 16px 10px;
  align-items: center;
}

.sidebar-header h2,
.panel-heading h2,
.inspector-header h2 {
  font-size: 1rem;
  line-height: 1.25;
}

.count-pill,
.kind-pill,
.member-kind,
.owner-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
}

.count-pill {
  background: #e8f2ff;
  color: var(--blue);
}

.kind-pill {
  background: #eef7ed;
  color: var(--green);
}

.search-control {
  display: grid;
  gap: 6px;
  padding: 0 16px 14px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
}

.search-control input,
.search-control select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 0 10px;
  color: var(--ink);
  background: var(--surface);
  text-transform: none;
  font-weight: 500;
}

.target-list {
  overflow: auto;
  padding: 0 10px 14px;
}

.target-group {
  padding-top: 10px;
}

.target-group-title {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  padding: 8px 6px;
  text-transform: uppercase;
}

.target-button {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  border-radius: var(--radius);
  padding: 10px 8px;
  text-align: left;
}

.target-button.active {
  background: #eaf4f1;
  border-color: #9ecfc8;
}

.target-name {
  font-family: var(--mono);
  font-size: 0.88rem;
  overflow-wrap: anywhere;
}

.target-meta {
  color: var(--muted);
  font-size: 0.76rem;
  margin-top: 2px;
}

.target-badge {
  color: var(--teal-ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 7px;
  font-size: 0.72rem;
  font-weight: 700;
}

.workspace {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.stage-row {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: 18px;
}

.panel {
  min-width: 0;
}

.panel-heading,
.inspector-header {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.panel-heading.tight {
  padding-bottom: 12px;
}

.sample-root {
  padding: 16px;
}

.sample-card {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 16px;
  background:
    linear-gradient(90deg, rgba(40, 93, 168, 0.08), transparent 34%),
    linear-gradient(180deg, rgba(40, 122, 62, 0.08), transparent 48%),
    var(--surface);
}

.sample-card * {
  min-width: 0;
}

.sample-card [data-inspect-key] {
  outline: 1px solid transparent;
  outline-offset: 3px;
  transition:
    outline-color 140ms ease,
    background-color 140ms ease,
    box-shadow 140ms ease;
}

.sample-card [data-inspect-key]:hover,
.sample-card [data-inspect-key].selected-node {
  outline-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(0, 124, 116, 0.12);
}

.sample-card header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}

.node-token,
demo-badge {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 0 9px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 700;
}

.node-token {
  color: var(--blue);
  background: #e8f2ff;
}

demo-badge {
  color: var(--amber);
  background: #fff1dc;
}

.sample-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin: 0 0 14px;
}

.sample-form label {
  display: grid;
  gap: 5px;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 700;
}

.sample-form input {
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 0 10px;
}

.sample-form button {
  align-self: end;
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid var(--teal);
  border-radius: var(--radius);
  background: var(--teal);
  color: #fff;
  font-weight: 750;
}

.sample-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.sample-nav a {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--blue);
  background: var(--surface);
  text-decoration: none;
  font-weight: 700;
}

.sample-svg {
  display: block;
  width: min(100%, 280px);
  aspect-ratio: 16 / 7;
  margin: 4px 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f9fbfb;
}

.sample-svg rect {
  fill: #e8f2ff;
  stroke: var(--blue);
  stroke-width: 3;
}

.sample-svg circle {
  fill: #eef7ed;
  stroke: var(--green);
  stroke-width: 3;
}

.sample-svg path {
  stroke: var(--red);
  stroke-width: 4;
  stroke-linecap: round;
}

.sample-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.sample-list li {
  min-height: 34px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: #fafafa;
  font-family: var(--mono);
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 16px;
}

.detail-item,
.check-item,
.origin-panel,
.fact-row,
.compare-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfc;
}

.detail-item {
  padding: 10px;
}

.detail-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.detail-value {
  margin-top: 5px;
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 0 16px 16px;
}

.check-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 34px;
  padding: 7px 9px;
  font-family: var(--mono);
  font-size: 0.76rem;
}

.check-item[data-pass="true"] {
  border-color: rgba(40, 122, 62, 0.45);
  background: #f1fbf2;
}

.check-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--line-strong);
  flex: 0 0 auto;
}

.check-item[data-pass="true"] .check-dot {
  background: var(--green);
}

.chain-panel {
  overflow: hidden;
}

.chain-visual {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(150px, 1fr);
  gap: 12px;
  overflow-x: auto;
  padding: 16px;
}

.chain-node {
  position: relative;
  min-height: 126px;
  display: grid;
  align-content: start;
  gap: 8px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--surface);
  text-align: left;
}

.chain-node::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -13px;
  width: 12px;
  height: 1px;
  background: var(--line-strong);
}

.chain-node:last-child::after {
  display: none;
}

.chain-node.active {
  border-color: var(--teal);
  background: #eaf4f1;
}

.chain-node.instance {
  border-color: rgba(40, 93, 168, 0.45);
}

.chain-node.null-node {
  background: #f3f3f3;
  color: var(--muted);
}

.chain-index {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.chain-name {
  font-family: var(--mono);
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.chain-meta {
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.35;
}

.inspector-panel {
  overflow: hidden;
}

.inspector-header {
  align-items: center;
}

.tab-list {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f4f6f6;
}

.tab-button {
  min-height: 32px;
  padding: 0 11px;
  border-color: transparent;
  background: transparent;
  font-size: 0.86rem;
  font-weight: 750;
}

.tab-button.active {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--teal-ink);
}

.tab-view {
  display: none;
}

.tab-view.active {
  display: block;
}

.member-controls {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 12px;
  align-items: end;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.member-search,
.compare-select {
  padding: 0;
}

.segmented-control {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f4f6f6;
}

.segment {
  min-height: 32px;
  padding: 0 9px;
  border-color: transparent;
  background: transparent;
  font-size: 0.8rem;
  font-weight: 750;
}

.segment.active {
  background: var(--surface);
  border-color: var(--line-strong);
}

.origin-panel {
  margin: 16px 16px 0;
  padding: 12px;
  display: grid;
  gap: 6px;
}

.origin-title {
  font-weight: 800;
}

.origin-meta {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

.table-wrap {
  max-height: 540px;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f4f6f6;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0;
  text-transform: uppercase;
}

td {
  font-size: 0.85rem;
}

.mono-cell,
.member-name,
.owner-name,
.member-preview,
.member-flags {
  font-family: var(--mono);
}

.member-name {
  color: var(--teal-ink);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.owner-name {
  color: var(--blue);
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}

.member-preview,
.member-flags {
  color: var(--muted);
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}

.member-kind {
  border-radius: var(--radius);
  background: #f3f3f3;
}

.member-kind.method {
  color: var(--blue);
  background: #e8f2ff;
}

.member-kind.property {
  color: var(--green);
  background: #eef7ed;
}

.member-kind.accessor {
  color: var(--amber);
  background: #fff1dc;
}

.member-kind.symbol {
  color: var(--red);
  background: #fff0ef;
}

.chain-facts,
.compare-output {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.fact-row {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) minmax(120px, auto);
  gap: 12px;
  padding: 12px;
  align-items: center;
}

.fact-name {
  font-family: var(--mono);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.fact-meta {
  color: var(--muted);
  font-size: 0.82rem;
}

.compare-toolbar {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.compare-select {
  max-width: 360px;
}

.compare-output {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.compare-card {
  padding: 12px;
  min-height: 180px;
}

.compare-card h3 {
  margin: 0 0 10px;
  font-size: 0.9rem;
}

.compare-list {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.compare-list li {
  padding: 7px 8px;
  border-radius: var(--radius);
  background: var(--surface-soft);
  font-family: var(--mono);
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}

.empty-state {
  padding: 22px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1120px) {
  .layout,
  .stage-row {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    max-height: none;
  }

  .target-list {
    max-height: 320px;
  }
}

@media (max-width: 760px) {
  .topbar,
  .inspector-header,
  .member-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    position: static;
  }

  .top-actions,
  .tab-list {
    width: 100%;
  }

  .tab-button,
  .segment {
    flex: 1 1 auto;
  }

  .member-controls,
  .compare-output,
  .details-grid,
  .check-grid {
    grid-template-columns: 1fr;
  }

  .sample-form,
  .sample-list {
    grid-template-columns: 1fr;
  }

  .fact-row {
    grid-template-columns: 1fr;
  }
}
