:root {
  --ink: #202122;
  --muted: #54595d;
  --subtle: #72777d;
  --line: #c8ccd1;
  --soft-line: #eaecf0;
  --surface: #fff;
  --canvas: #f8f9fa;
  --blue: #3366cc;
  --blue-hover: #2a4b8d;
  --blue-soft: #eaf3ff;
  --red: #b32424;
  --red-soft: #fee7e6;
  --green: #14866d;
  --shadow: 0 2px 12px rgba(32, 33, 34, .08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--canvas); }
button, input, select { font: inherit; }
button, select { cursor: pointer; }
a { color: var(--blue); }
.skip-link { position: fixed; left: 16px; top: -80px; z-index: 99; padding: 10px 14px; background: var(--ink); color: #fff; text-decoration: none; border-radius: 4px; }
.skip-link:focus { top: 12px; }

.site-header { height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 0 clamp(20px, 4vw, 64px); background: rgba(255,255,255,.96); border-bottom: 1px solid var(--soft-line); }
.brand { display: flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--line); background: #fff; border-radius: 5px; }
.brand-mark svg { width: 25px; fill: none; stroke: var(--ink); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.brand-mark circle { fill: var(--blue); stroke: #fff; }
.brand strong, .brand small { display: block; }
.brand strong { font-family: Georgia, "Times New Roman", serif; font-size: 21px; line-height: 1; }
.brand small { margin-top: 4px; color: var(--muted); font-size: 11px; letter-spacing: .02em; }
.header-links { display: flex; align-items: center; gap: 24px; font-size: 14px; }
.header-links a, .text-button { color: var(--muted); text-decoration: none; }
.header-links a:hover, .text-button:hover { color: var(--blue); }
.text-button { padding: 0; border: 0; background: transparent; }

main { max-width: 1500px; margin: 0 auto; padding: 0 clamp(20px, 4vw, 64px) 48px; }
.workspace-intro { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(280px, .65fr); gap: clamp(48px, 8vw, 120px); align-items: end; padding: 52px 0 34px; }
.eyebrow { margin: 0 0 9px; color: var(--blue); font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
h1 { margin: 0; max-width: 780px; font-family: Georgia, "Times New Roman", serif; font-weight: 400; font-size: clamp(34px, 4.1vw, 58px); line-height: 1.06; letter-spacing: -.025em; }
h1 span { color: var(--muted); }
.intro-copy { max-width: 660px; margin: 18px 0 0; color: var(--muted); font-size: 16px; line-height: 1.6; }
.topic-picker { padding-bottom: 4px; }
.topic-picker label { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 700; }
.select-wrap { position: relative; }
.select-wrap select { width: 100%; appearance: none; padding: 13px 42px 13px 14px; color: var(--ink); font-weight: 600; background: #fff; border: 1px solid #a2a9b1; border-radius: 3px; outline: none; }
.select-wrap select:focus { border-color: var(--blue); box-shadow: inset 0 0 0 1px var(--blue); }
.select-wrap svg { pointer-events: none; position: absolute; right: 14px; top: 50%; width: 16px; transform: translateY(-50%); fill: none; stroke: var(--muted); stroke-width: 1.7; }
.topic-picker p { margin: 8px 0 0; color: var(--subtle); font-size: 12px; line-height: 1.45; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr) 1.5fr; background: #fff; border: 1px solid var(--line); border-radius: 4px 4px 0 0; }
.stat, .coverage-stat { min-height: 88px; display: flex; align-items: center; gap: 12px; padding: 17px 20px; border-right: 1px solid var(--soft-line); }
.stat-icon { display: grid; place-items: center; flex: 0 0 auto; width: 31px; height: 31px; border-radius: 50%; font-weight: 700; }
.stat-icon.blue { color: var(--blue); background: var(--blue-soft); }
.stat-icon.red { color: var(--red); background: var(--red-soft); }
.stat-icon.neutral { color: var(--muted); background: var(--canvas); }
.stat strong, .stat span { display: block; }
.stat strong { font-family: Georgia, "Times New Roman", serif; font-size: 23px; font-weight: 400; }
.stat div span { margin-top: 2px; color: var(--muted); font-size: 11px; }
.coverage-stat { display: block; border-right: 0; padding-top: 20px; }
.coverage-stat > div:first-child { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }
.coverage-stat strong { color: var(--ink); font-size: 14px; }
.progress { height: 7px; margin-top: 12px; overflow: hidden; background: var(--soft-line); border-radius: 999px; }
.progress span { display: block; height: 100%; width: 0; background: var(--blue); border-radius: inherit; transition: width .4s ease; }

.explorer { display: grid; grid-template-columns: 292px minmax(0, 1fr); min-height: 620px; background: #fff; border: 1px solid var(--line); border-top: 0; border-radius: 0 0 4px 4px; box-shadow: var(--shadow); }
.controls { padding: 25px 22px; background: #f8f9fa; border-right: 1px solid var(--line); }
.control-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.control-heading .eyebrow { margin-bottom: 4px; }
.control-heading h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 25px; font-weight: 400; }
.source-pill { padding: 4px 7px; color: var(--muted); background: #fff; border: 1px solid var(--line); border-radius: 3px; font-size: 10px; font-weight: 700; letter-spacing: .04em; }
.search-field { position: relative; display: block; margin: 22px 0 24px; }
.search-field svg { position: absolute; left: 11px; top: 50%; width: 18px; transform: translateY(-50%); fill: none; stroke: var(--muted); stroke-width: 1.6; }
.search-field input { width: 100%; height: 42px; padding: 0 41px 0 37px; border: 1px solid #a2a9b1; border-radius: 3px; outline: none; background: #fff; }
.search-field input:focus { border-color: var(--blue); box-shadow: inset 0 0 0 1px var(--blue); }
.search-field kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); min-width: 21px; padding: 2px 6px; color: var(--subtle); text-align: center; background: var(--canvas); border: 1px solid var(--line); border-radius: 3px; font: 11px/1.4 inherit; }
fieldset { margin: 0; padding: 0; border: 0; }
legend { width: 100%; padding: 0; margin-bottom: 9px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); overflow: hidden; border: 1px solid #a2a9b1; border-radius: 3px; }
.segmented button { min-height: 34px; padding: 4px 5px; color: var(--muted); background: #fff; border: 0; border-right: 1px solid var(--line); font-size: 11px; }
.segmented button:last-child { border: 0; }
.segmented button.active { color: #fff; background: var(--blue); }
.depth-group { margin-top: 26px; }
.depth-group legend { display: flex; justify-content: space-between; }
.depth-group legend strong { color: var(--ink); font-weight: 600; text-transform: none; letter-spacing: 0; }
.depth-group input { width: 100%; accent-color: var(--blue); }
.range-labels { display: flex; justify-content: space-between; padding: 0 3px; color: var(--subtle); font-size: 10px; }
.legend { margin: 28px 0 22px; padding: 17px 0; border-top: 1px solid var(--soft-line); border-bottom: 1px solid var(--soft-line); }
.legend p { margin: 0 0 11px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.legend span { display: flex; align-items: center; gap: 8px; margin-top: 8px; color: var(--muted); font-size: 11px; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; }
.legend-dot.blue { background: var(--blue); }
.legend-dot.red { background: var(--red); }
.secondary-button { width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px; color: var(--blue); background: #fff; border: 1px solid var(--blue); border-radius: 3px; font-size: 12px; font-weight: 700; }
.secondary-button:hover { color: #fff; background: var(--blue); }
.secondary-button svg { width: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; }

.tree-panel { min-width: 0; }
.tree-toolbar { min-height: 78px; display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 15px 24px; border-bottom: 1px solid var(--soft-line); }
.breadcrumbs { display: flex; align-items: center; gap: 7px; color: var(--subtle); font-size: 12px; }
.breadcrumbs button { padding: 0; color: var(--blue); background: none; border: 0; }
.breadcrumbs strong { color: var(--ink); font-weight: 600; }
.tree-toolbar p { margin: 6px 0 0; color: var(--muted); font-size: 11px; }
.icon-button { display: grid; place-items: center; width: 34px; height: 34px; color: var(--muted); background: #fff; border: 1px solid var(--line); border-radius: 3px; }
.icon-button:hover { color: var(--blue); border-color: var(--blue); }
.icon-button svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; }
.tree-wrap { min-height: 540px; padding: 14px 20px 32px; overflow-x: auto; }
.tree-list { min-width: 580px; margin: 0; padding: 0; list-style: none; }
.tree-list .tree-list { position: relative; margin-left: 27px; padding-left: 15px; }
.tree-list .tree-list::before { content: ""; position: absolute; left: 0; top: 0; bottom: 16px; border-left: 1px solid #dfe2e5; }
.tree-item { position: relative; }
.tree-list .tree-list > .tree-item::before { content: ""; position: absolute; left: -15px; top: 23px; width: 13px; border-top: 1px solid #dfe2e5; }
.node-row { min-height: 47px; display: grid; grid-template-columns: 28px minmax(170px, 1fr) auto; align-items: center; gap: 5px; padding: 4px 9px 4px 2px; border-bottom: 1px solid #f0f1f2; border-radius: 3px; }
.node-row:hover { background: #f8f9fa; }
.toggle { display: grid; place-items: center; width: 27px; height: 27px; padding: 0; color: var(--muted); background: transparent; border: 0; border-radius: 3px; }
.toggle:hover { background: #eaecf0; color: var(--ink); }
.toggle svg { width: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; transition: transform .14s ease; }
.tree-item.open > .node-row .toggle svg { transform: rotate(90deg); }
.toggle.placeholder { visibility: hidden; }
.node-main { min-width: 0; padding: 5px 0; }
.node-title { display: inline; font-size: 14px; font-weight: 600; line-height: 1.35; }
a.node-title { color: var(--blue); text-decoration: none; }
a.node-title:hover { color: var(--blue-hover); text-decoration: underline; }
.node-title.missing { color: var(--red); border-bottom: 1px dashed rgba(179,36,36,.45); }
.node-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-top: 3px; color: var(--subtle); font-size: 10px; }
.node-meta a { color: var(--blue); text-decoration: none; }
.node-meta a:hover { text-decoration: underline; }
.node-meta .sep { color: #a2a9b1; }
.node-actions { display: flex; align-items: center; gap: 7px; }
.status-badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 7px; white-space: nowrap; border-radius: 999px; font-size: 9px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; }
.status-badge.exists { color: var(--blue-hover); background: var(--blue-soft); }
.status-badge.missing { color: var(--red); background: var(--red-soft); }
.count-badge { min-width: 24px; color: var(--subtle); font-size: 10px; text-align: right; }
.tree-item > .tree-list { display: none; }
.tree-item.open > .tree-list { display: block; }
.loading-state { min-height: 450px; display: grid; place-content: center; justify-items: center; color: var(--muted); }
.loading-state span { width: 30px; height: 30px; border: 3px solid var(--soft-line); border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
.loading-state p { font-size: 13px; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state { min-height: 400px; place-content: center; justify-items: center; text-align: center; color: var(--muted); }
.empty-state:not([hidden]) { display: grid; }
.empty-state span { font: 42px Georgia, serif; color: var(--line); }
.empty-state h3 { margin: 12px 0 5px; color: var(--ink); font: 23px Georgia, serif; }
.empty-state p { margin: 0; font-size: 13px; }

footer { display: flex; justify-content: space-between; gap: 24px; max-width: 1500px; margin: 0 auto; padding: 25px clamp(20px, 4vw, 64px) 38px; color: var(--subtle); font-size: 11px; }
footer p { margin: 0; }
footer a { text-decoration: none; }
dialog { width: min(570px, calc(100% - 32px)); padding: 34px; border: 1px solid var(--line); border-radius: 4px; box-shadow: 0 16px 50px rgba(32,33,34,.25); }
dialog::backdrop { background: rgba(32,33,34,.42); }
dialog h2 { margin: 0 0 15px; font: 32px/1.15 Georgia, serif; }
dialog p:not(.eyebrow) { color: var(--muted); line-height: 1.65; }
.dialog-close { position: absolute; top: 12px; right: 15px; padding: 4px; color: var(--muted); background: none; border: 0; font-size: 26px; }

@media (max-width: 920px) {
  .workspace-intro { grid-template-columns: 1fr; gap: 28px; padding-top: 38px; }
  .topic-picker { max-width: 480px; }
  .stats { grid-template-columns: repeat(3, 1fr); }
  .coverage-stat { grid-column: 1 / -1; border-top: 1px solid var(--soft-line); }
  .explorer { grid-template-columns: 1fr; }
  .controls { border-right: 0; border-bottom: 1px solid var(--line); }
  .legend { display: none; }
  .control-heading, .search-field, .filter-group, .depth-group { max-width: 620px; }
  .secondary-button { width: auto; padding-inline: 18px; }
}

@media (max-width: 620px) {
  .site-header { height: 64px; padding-inline: 16px; }
  .brand small, .header-links a { display: none; }
  .header-links { gap: 0; }
  main { padding-inline: 12px; }
  .workspace-intro { padding: 30px 5px 24px; }
  h1 { font-size: 35px; }
  .intro-copy { font-size: 14px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat { min-height: 77px; padding: 12px; }
  .stat:nth-child(3) { grid-column: 1 / -1; border-top: 1px solid var(--soft-line); }
  .stat:nth-child(2), .stat:nth-child(3) { border-right: 0; }
  .controls { padding: 20px 16px; }
  .tree-toolbar { padding: 14px 16px; }
  .tree-wrap { padding-inline: 10px; }
  .node-row { grid-template-columns: 26px minmax(150px,1fr) auto; }
  .node-actions .count-badge { display: none; }
  footer { display: block; padding-inline: 17px; }
  footer p + p { margin-top: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
.stat-icon {
  position: relative;
  font-size: 0;
}

.stat-icon::before {
  position: absolute;
  top: 50%;
  left: 50%;
  font-size: 17px;
  line-height: 1;
  transform: translate(-50%, -50%);
}

.stat-icon.blue::before {
  content: "✓";
}

.stat-icon.red::before {
  content: "+";
}

.stat-icon.neutral::before {
  content: "⌘";
  font-size: 15px;
}