:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-strong: #fcfcf9;
  --surface-soft: #f3f4ef;
  --ink: #161616;
  --muted: #6b6f67;
  --line: #e3e5dc;
  --line-strong: #d1d5cc;
  --accent: #111111;
  --accent-strong: #000000;
  --ok: #19724a;
  --error: #b42318;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "IBM Plex Sans", "Avenir Next", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top, rgba(17, 17, 17, 0.035), transparent 42%),
    var(--bg);
}

.shell {
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
  padding: 40px 0 56px;
}

.hero {
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 600;
}

h1,
h2 {
  margin: 0;
  font-weight: 700;
  line-height: 1.05;
}

h1 {
  font-size: clamp(1.3rem, 5vw, 2.2rem);
  /* max-width: 11ch; */
  letter-spacing: -0.04em;
}

h2 {
  font-size: 1.4rem;
  letter-spacing: -0.03em;
}

.lede {
  /* max-width: 56ch; */
  margin-top: 14px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.form {
  display: grid;
  gap: 18px;
}

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

label {
  display: grid;
  gap: 8px;
  font-size: 0.92rem;
  font-weight: 500;
}

input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-strong);
  color: var(--ink);
  font: inherit;
  transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

input:focus {
  outline: none;
  border-color: #b8beb2;
  box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.05);
  background: #fff;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
}

.checkbox input {
  width: 18px;
  height: 18px;
}

button,
.downloads a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 11px 16px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--accent);
  color: white;
  text-decoration: none;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

button:hover,
.downloads a:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.status {
  margin: 18px 0;
  padding: 14px 18px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
}

.status.success {
  color: var(--ok);
}

.status.error {
  color: var(--error);
}

.hidden {
  display: none;
}

.results-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.downloads {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.downloads a {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line-strong);
}

.downloads a:hover {
  background: var(--surface-soft);
  color: var(--ink);
  border-color: var(--line-strong);
}

.summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.search-bar {
  margin-bottom: 20px;
}

.search-bar input {
  max-width: 540px;
}

.search-feedback {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.tree-panel {
  margin-bottom: 24px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface-soft);
}

.tree-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.tree-controls {
  display: grid;
  gap: 12px;
  justify-items: end;
}

.tree-note {
  margin: 0;
  max-width: 34ch;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.tree-preview {
  overflow-x: auto;
}

.view-switch {
  display: inline-flex;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}

.view-switch-button {
  padding: 9px 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 500;
}

.view-switch-button.is-active {
  background: var(--surface-soft);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}

.empty-state {
  color: var(--muted);
}

.empty-state {
  margin: 0;
  padding: 8px 0;
}

.tree-preview ul {
  list-style: none;
  margin: 0;
  padding-left: 22px;
  position: relative;
}

.tree-preview > ul {
  padding-left: 0;
}

.tree-preview li {
  position: relative;
  padding: 10px 0 0 18px;
}

.flat-preview-list {
  padding-left: 0;
}

.flat-preview-list li {
  padding-left: 0;
}

.flat-preview-list li::before,
.flat-preview-list li::after {
  display: none;
}

.tree-preview li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: -4px;
  width: 1px;
  background: var(--line-strong);
}

.tree-preview li::after {
  content: "";
  position: absolute;
  left: 0;
  top: 22px;
  width: 12px;
  height: 1px;
  background: var(--line-strong);
}

.tree-preview > ul > li:first-child::before {
  top: 22px;
}

.tree-node {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.tree-node a {
  color: var(--ink);
  text-decoration: none;
  word-break: break-word;
  font-weight: 500;
}

.tree-item.is-404 .tree-node a {
  color: var(--error);
  font-weight: 700;
}

.tree-item.is-match .tree-node a {
  text-decoration: underline;
  text-decoration-color: rgba(22, 22, 22, 0.35);
  text-decoration-thickness: 2px;
}

.tree-item.is-context .tree-node a {
  opacity: 0.62;
}

.tree-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tree-badge,
.tree-meta {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 9px;
  background: var(--surface);
  font-size: 0.78rem;
  color: var(--muted);
}

.tree-meta {
  margin-top: 6px;
}

.tree-badge.is-404,
.tree-item.is-404 .tree-meta {
  border-color: rgba(146, 47, 47, 0.25);
  background: rgba(146, 47, 47, 0.08);
  color: var(--error);
}

.summary article {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  background: var(--surface-soft);
}

.summary strong {
  display: block;
  margin-bottom: 6px;
  font-size: 1.65rem;
  letter-spacing: -0.04em;
}

.summary span {
  color: var(--muted);
}

.tree-node a:hover {
  text-decoration: underline;
}

@media (max-width: 780px) {
  .shell {
    width: min(100% - 20px, 1120px);
    padding: 28px 0 40px;
  }

  .grid,
  .summary {
    grid-template-columns: 1fr;
  }

  .results-header,
  .tree-header {
    flex-direction: column;
  }

  .tree-controls {
    justify-items: start;
  }
}
