/* Home surface — opening screen, New Project modal, Navigator action row.
   Line drawings on the field, one light source, oxide tints for categories. */

:root {
  --hs-ease: cubic-bezier(0.2, 0, 0, 1);
  --hs-ink: rgba(235, 232, 224, 0.84);
  --hs-muted: rgba(235, 232, 224, 0.5);
  --hs-rule: rgba(255, 248, 235, 0.2);
  --hs-bar: rgba(255, 248, 235, 0.12);
  --hs-cobalt: #7e94b8;
  --hs-emerald: #7a9a82;
  --hs-gold: #b5946a;
  --hs-amethyst: #9a86b0;
  --hs-burnt: #b8896f;
  --hs-vermilion: #b87466;
  --hs-cut: inset 0 1px 2px rgba(0, 0, 0, 0.5), inset 0 -1px 0 rgba(255, 255, 255, 0.05);
  --hs-puck: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 1px 1.5px rgba(0, 0, 0, 0.55);
  --hs-mono: "JetBrains Mono", "IBM Plex Mono", ui-monospace, Menlo, monospace;
}

body.light-theme {
  --hs-ink: rgba(28, 27, 24, 0.86);
  --hs-muted: rgba(28, 27, 24, 0.5);
  --hs-rule: rgba(20, 18, 14, 0.22);
  --hs-bar: rgba(20, 18, 14, 0.1);
  --hs-cobalt: #3a4f72;
  --hs-emerald: #3b6850;
  --hs-gold: #957532;
  --hs-amethyst: #5e4670;
  --hs-burnt: #92602e;
  --hs-vermilion: #9c4338;
  --hs-cut: inset 0 1px 2px rgba(20, 18, 14, 0.13), inset 0 -1px 0 rgba(255, 255, 255, 0.85);
  --hs-puck: inset 0 1px 0 rgba(255, 255, 255, 0.95), 0 1px 1.5px rgba(20, 18, 14, 0.2);
}

/* ── Drawing primitives ─────────────────────────────────────────────── */
.hs-svg { --sw: 1.1; overflow: visible; }
.hs-glyph { --sw: 1.6; width: 26px; height: 26px; display: block; }
.hs-strip { --sw: 1; width: 64px; height: 40px; display: block; }

.hs-line, .hs-soft, .hs-room, .hs-ok, .hs-no, .hs-pend {
  fill: none;
  stroke-width: var(--sw);
  stroke-linecap: round;
  stroke-linejoin: round;
}
.hs-line { stroke: var(--hs-ink); }
.hs-soft { stroke: var(--hs-rule); }
.hs-room { stroke: var(--hs-ink); stroke-opacity: 0.7; stroke-width: calc(var(--sw) * 0.8); }
.hs-ok { stroke: var(--hs-emerald); }
.hs-no { stroke: var(--hs-vermilion); }
.hs-pend { stroke: var(--hs-gold); }
circle.hs-ok { fill: color-mix(in srgb, var(--hs-emerald) 22%, transparent); }
circle.hs-pend { fill: color-mix(in srgb, var(--hs-gold) 22%, transparent); }
.hs-dot { fill: var(--hs-ink); stroke: none; }
.hs-bar { fill: var(--hs-bar); stroke: none; }
.hs-dash { stroke-dasharray: 4 4; }
.hs-out { opacity: 0; }
.hs-trip { fill: none; stroke: var(--hs-cobalt); stroke-width: calc(var(--sw) * 1.5); stroke-linecap: round; stroke-linejoin: round; }
.hs-heat { fill: color-mix(in srgb, var(--hs-gold) 30%, transparent); stroke: none; }
.hs-shade { fill: rgba(0, 0, 0, 0.12); stroke: none; }

.hs-t1, .hs-t2, .hs-t3, .hs-t4, .hs-t5 { stroke-width: calc(var(--sw) * 0.8); }
.hs-t1 { fill: color-mix(in srgb, var(--hs-amethyst) 16%, transparent); stroke: color-mix(in srgb, var(--hs-amethyst) 55%, transparent); }
.hs-t2 { fill: color-mix(in srgb, var(--hs-cobalt) 16%, transparent); stroke: color-mix(in srgb, var(--hs-cobalt) 55%, transparent); }
.hs-t3 { fill: color-mix(in srgb, var(--hs-emerald) 16%, transparent); stroke: color-mix(in srgb, var(--hs-emerald) 55%, transparent); }
.hs-t4 { fill: color-mix(in srgb, var(--hs-gold) 16%, transparent); stroke: color-mix(in srgb, var(--hs-gold) 55%, transparent); }
.hs-t5 { fill: color-mix(in srgb, var(--hs-burnt) 16%, transparent); stroke: color-mix(in srgb, var(--hs-burnt) 55%, transparent); }

.hs-label { fill: var(--hs-ink); stroke: none; font-family: inherit; font-size: 11px; letter-spacing: 0.01em; }
.hs-label--sm { fill: var(--hs-muted); font-size: 9px; }
.hs-label--lg { font-size: 12.5px; }
.hs-scene-title { fill: var(--hs-ink); font-size: 11px; letter-spacing: 0.02em; }
.hs-lose { opacity: 0.3; }
.hs-out-late { opacity: 0; }

/* Draw-on strokes: pathLength="1" normalises every path. At rest the stroke is whole. */
.hs-draw { stroke-dasharray: 1 1; stroke-dashoffset: 0; }

@keyframes hs-rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes hs-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes hs-join { from { opacity: 0.2; transform: translate(var(--dx, 0px), var(--dy, 0px)); } to { opacity: 1; transform: none; } }
@keyframes hs-out { from { opacity: 0.85; } to { opacity: 0; } }
@keyframes hs-dim { from { opacity: 1; } to { opacity: 0.3; } }

.hs-stage.is-run .hs-scene.is-active .hs-fade,
.hs-cap.is-open > .hs-cap-body:not(.is-settled) .hs-fade {
  animation: hs-rise 340ms var(--hs-ease) both;
  animation-delay: calc(var(--i, 0) * 140ms);
}
.hs-stage.is-run .hs-scene.is-active .hs-draw,
.hs-cap.is-open > .hs-cap-body:not(.is-settled) .hs-draw {
  animation: hs-draw 380ms var(--hs-ease) both;
  animation-delay: calc(var(--i, 0) * 140ms);
}
.hs-stage.is-run .hs-scene.is-active .hs-join {
  animation: hs-join 380ms var(--hs-ease) both;
  animation-delay: calc(160ms + var(--i, 0) * 140ms);
}
.hs-stage.is-run .hs-scene.is-active .hs-out {
  animation: hs-out 380ms var(--hs-ease) 320ms both;
}
/* analyze: every option arrives, then all but the kept one step back */
.hs-stage.is-run .hs-scene.is-active .hs-lose {
  animation: hs-rise 340ms var(--hs-ease) calc(var(--i, 0) * 140ms) both, hs-dim 380ms var(--hs-ease) 1500ms forwards;
}
/* keep track of: the first example gives way to the general word */
.hs-stage.is-run .hs-scene.is-active .hs-out-late {
  animation: hs-out 380ms var(--hs-ease) 1200ms both;
}

.hs-scene { opacity: 0; visibility: hidden; transition: opacity 260ms var(--hs-ease), visibility 0s linear 260ms; }
.hs-scene.is-active { opacity: 1; visibility: visible; transition: opacity 260ms var(--hs-ease); }

/* ── Opening screen — fits its window and never scrolls ────────────── */
/* While the opening screen is shown, the Detail View column takes the
   window's height instead of growing with its content. */
#detail-view:has(> .hs-fit),
#right-column:has(> #detail-view > .hs-fit) { height: 100%; overflow: hidden; }
.window-body:has(> #right-column > #detail-view > .hs-fit) { overflow: hidden; }

.hs-fit {
  container: hs / size;
  height: 100%;
  color: var(--text);
}
body:not(.windowed-layout) .hs-fit { min-height: calc(100vh - 140px); }

.hs-home {
  box-sizing: border-box;
  height: 100%;
  max-width: 1280px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "hero mix" "plan explore";
  gap: clamp(12px, 3.6cqh, 34px) clamp(18px, 3.6cqw, 44px);
  padding: clamp(10px, 3cqh, 28px) clamp(12px, 3cqw, 32px);
  overflow: hidden;
}

.hs-eyebrow {
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.hs-section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: clamp(6px, 1.5cqh, 12px);
}
.hs-section-head h4 { margin: 3px 0 0; font-size: clamp(0.82rem, 2.2cqh, 0.95rem); font-weight: 500; letter-spacing: -0.005em; color: var(--text); }

.hs-quiet {
  appearance: none;
  border: 0;
  border-radius: 6px;
  background: none;
  padding: 4px 8px;
  color: var(--muted);
  font: inherit;
  font-size: 0.72rem;
  cursor: pointer;
  transition: color 160ms var(--hs-ease), background 160ms var(--hs-ease);
}
.hs-quiet:hover { color: var(--text); background: var(--overlay-hover); }

.nav-action svg, .nav-icon-btn svg, .np-chevron {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Hero: greeting, pointer to the Navigator, portfolio totals */
.hs-hero {
  grid-area: hero;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "text aside" "cluster cluster";
  align-items: end;
  gap: clamp(8px, 2.2cqh, 20px) 20px;
}
.hs-hero-text { grid-area: text; min-width: 0; }
.hs-hero h3 {
  margin: clamp(2px, 0.8cqh, 8px) 0 clamp(2px, 0.6cqh, 6px);
  font-size: clamp(1.25rem, 5.4cqh, 2.4rem);
  font-weight: 500;
  letter-spacing: -0.022em;
  line-height: 1.06;
  color: var(--text);
}
.hs-hero p { margin: 0; max-width: 30rem; font-size: clamp(0.78rem, 1.9cqh, 0.92rem); line-height: 1.45; color: var(--muted); }
.hs-hero-aside { grid-area: aside; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; min-width: 0; }
.hs-hint { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-size: 0.76rem; color: var(--muted); white-space: nowrap; }
.hs-hint svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

.hs-guide {
  appearance: none;
  border: 0;
  background: none;
  padding: 2px;
  color: var(--muted);
  font: inherit;
  font-size: 0.74rem;
  cursor: pointer;
  white-space: nowrap;
}
.hs-guide strong { color: var(--text); font-weight: 500; }
.hs-guide:hover strong, .hs-guide:focus-visible strong { color: var(--accent); }
.hs-guide:focus-visible { outline: 1px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

.hs-cluster {
  grid-area: cluster;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.hs-cell { min-width: 0; padding: clamp(5px, 1.6cqh, 12px) 8px clamp(5px, 1.6cqh, 12px) 14px; }
.hs-cell + .hs-cell { border-left: 1px solid var(--border-subtle); }
.hs-cell:first-child { padding-left: 2px; }
.hs-cell-value {
  font-family: var(--hs-mono);
  font-variant-numeric: tabular-nums;
  font-size: clamp(0.95rem, 3.4cqh, 1.35rem);
  font-weight: 500;
  line-height: 1.1;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hs-cell-label { margin-top: 3px; font-size: 0.62rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Across your projects — program mix */
.hs-mix { grid-area: mix; min-width: 0; min-height: 0; display: flex; flex-direction: column; justify-content: flex-end; }
.hs-mix-bar { display: flex; gap: 2px; height: 16px; padding: 3px; border-radius: 8px; box-shadow: var(--hs-cut); }
.hs-mix-seg { flex: 1 1 0; min-width: 3px; border-radius: 3px; }
.hs-mix-seg--0 { background: var(--hs-rule); }
.hs-mix-seg--1 { background: color-mix(in srgb, var(--hs-amethyst) 60%, transparent); }
.hs-mix-seg--2 { background: color-mix(in srgb, var(--hs-cobalt) 60%, transparent); }
.hs-mix-seg--3 { background: color-mix(in srgb, var(--hs-emerald) 60%, transparent); }
.hs-mix-seg--4 { background: color-mix(in srgb, var(--hs-gold) 60%, transparent); }
.hs-mix-seg--5 { background: color-mix(in srgb, var(--hs-burnt) 60%, transparent); }
.hs-mix-list { list-style: none; margin: clamp(6px, 1.6cqh, 12px) 0 0; padding: 0; border-top: 1px solid var(--border-subtle); }
.hs-mix-list li {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto 40px;
  align-items: center;
  gap: 10px;
  padding: clamp(3px, 1cqh, 7px) 2px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.78rem;
}
.hs-mix-list li:nth-child(n + 5) { display: none; }
.hs-mix-swatch { width: 10px; height: 10px; border-radius: 3px; }
.hs-mix-name { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hs-mix-value, .hs-mix-share { font-family: var(--hs-mono); font-size: 0.72rem; font-variant-numeric: tabular-nums; text-align: right; }
.hs-mix-value { color: var(--text); }
.hs-mix-share { color: var(--muted); }
.hs-empty { margin: 0; padding: 8px 2px 0; font-size: 0.8rem; line-height: 1.5; color: var(--muted); }
.hs-empty strong { color: var(--text); font-weight: 500; }
.nav-project-strip { flex: none; display: block; }
.nav-project-strip .hs-strip { width: 44px; height: 28px; }

/* Auto-Plan-Gen stage — the drawing scales to whatever height is left */
.hs-autoplan { grid-area: plan; container: plan / inline-size; min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto; }
.hs-stage {
  min-height: 0;
  display: grid;
  place-items: center;
  padding: clamp(6px, 2cqh, 16px) 12px;
  border-radius: 14px;
  background: var(--bg);
  box-shadow: var(--hs-cut);
}
.hs-stage-svg { display: block; width: 100%; height: 100%; min-height: 0; }
/* Chapters: rooms → auto-plan-gen → applets, each step a tick under its chapter */
.hs-chapters { display: grid; gap: 12px; margin-top: clamp(4px, 1.2cqh, 10px); }
.hs-chapter { min-width: 0; }
.hs-chapter-label {
  padding-top: 5px;
  border-top: 1px solid var(--border);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 160ms var(--hs-ease), border-color 160ms var(--hs-ease);
}
.hs-chapter.is-active .hs-chapter-label { color: var(--text); border-top-color: var(--accent); }
.hs-chapter-steps { display: grid; gap: 3px; margin-top: 5px; }
.hs-step {
  appearance: none;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  border: 0;
  background: transparent;
  padding: 2px 0;
  color: var(--muted);
  font: inherit;
  font-size: 0.68rem;
  text-align: left;
  cursor: pointer;
  transition: color 160ms var(--hs-ease);
}
.hs-step::before { content: ''; height: 2px; border-radius: 1px; background: var(--border); transition: background 160ms var(--hs-ease); }
.hs-step span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hs-step:hover { color: var(--text); }
.hs-step:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; }
.hs-step.is-active { color: var(--text); }
.hs-step.is-active::before { background: var(--accent); }
.hs-caption { margin: clamp(3px, 1cqh, 8px) 2px 0; font-size: 0.8rem; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hs-caption strong { margin-right: 6px; color: var(--text); font-weight: 500; }
@container plan (max-width: 560px) {
  .hs-step span { display: none; }
  .hs-step { padding: 4px 0; }
}

/* What Arrange does — rows share the panel; a branch drills in, never down */
.hs-capabilities { grid-area: explore; container: explore / inline-size; min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr); }
.hs-tree { min-height: 0; display: flex; flex-direction: column; border-top: 1px solid var(--border); overflow: hidden; }
.hs-cap { flex: 1 1 auto; min-height: 31px; max-height: 58px; display: flex; flex-direction: column; border-bottom: 1px solid var(--border); }
.hs-cap-head {
  appearance: none;
  flex: 1 1 auto;
  min-height: 30px;
  width: 100%;
  display: grid;
  grid-template-columns: 28px minmax(84px, 140px) minmax(0, 1fr) 16px;
  align-items: center;
  gap: 12px;
  padding: 0 6px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  transition: background 160ms var(--hs-ease);
}
.hs-cap-head:hover { background: var(--overlay-hover); }
.hs-cap-head:focus-visible { outline: 1px solid var(--accent); outline-offset: -1px; }
.hs-cap-glyph .hs-glyph { width: 24px; height: 24px; }
.hs-cap-label { font-size: 0.92rem; font-weight: 500; letter-spacing: -0.005em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hs-cap-summary { font-size: 0.78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hs-chevron {
  justify-self: center;
  width: 7px;
  height: 7px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform 260ms var(--hs-ease);
}
.hs-cap-body { display: none; }

/* An open branch keeps every other header in view: closed headers compact,
   the open branch takes what is left, and its diagram shrinks first. */
.hs-tree.has-open > .hs-cap:not(.is-open) { flex: 0 0 auto; min-height: 0; max-height: none; }
.hs-tree.has-open > .hs-cap:not(.is-open) > .hs-cap-head { flex: 0 0 28px; min-height: 28px; }
.hs-cap.is-open { flex: 1 1 auto; min-height: 0; max-height: none; }
.hs-cap.is-open > .hs-cap-head { flex: 0 0 34px; min-height: 34px; }
.hs-cap.is-open .hs-cap-label { color: var(--accent); }
.hs-cap.is-open .hs-chevron { transform: rotate(45deg); }
.hs-cap.is-open > .hs-cap-body {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 96px) auto;
  align-content: start;
  gap: 8px;
  padding: 2px 6px 8px 46px;
  overflow: hidden;
}
.hs-cap-figure { min-height: 0; max-height: 120px; display: grid; place-items: center; padding: 6px; border-radius: 10px; background: var(--bg); box-shadow: var(--hs-cut); }
.hs-illustration { display: block; width: 100%; height: 100%; min-height: 0; }
.hs-faq { min-height: 0; overflow: hidden; }
.hs-q > summary {
  list-style: none;
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: clamp(3px, 1.6cqh, 7px) 0;
  font-size: 0.8rem;
  color: var(--text);
  cursor: pointer;
}
.hs-q > summary::-webkit-details-marker { display: none; }
.hs-q > summary::before { content: '+'; flex: none; width: 10px; font-family: var(--hs-mono); color: var(--muted); }
.hs-q[open] > summary::before { content: '\2013'; }
.hs-q > summary:hover { color: var(--accent); }
.hs-q > summary:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
.hs-q p { margin: 0 0 6px 18px; font-size: 0.76rem; line-height: 1.45; color: var(--text-secondary); }
.hs-link {
  appearance: none;
  border: 0;
  background: none;
  padding: 0 0 0 6px;
  color: var(--accent);
  font: inherit;
  font-size: 0.72rem;
  cursor: pointer;
  white-space: nowrap;
}
.hs-link::after { content: ' \2192'; }
.hs-link:hover { text-decoration: underline; text-underline-offset: 3px; }

@container explore (min-width: 520px) {
  .hs-cap.is-open > .hs-cap-body { grid-template-columns: minmax(96px, 0.7fr) minmax(0, 1.4fr); grid-template-rows: minmax(0, 1fr); align-items: start; }
  .hs-cap.is-open .hs-cap-figure { height: min(120px, 100%); }
  .hs-faq { padding-left: 16px; border-left: 1px solid var(--border); }
}
@container explore (max-width: 380px) {
  .hs-cap-head { grid-template-columns: 26px minmax(0, 1fr) 16px; }
  .hs-cap-summary { display: none; }
}
@container hs (max-height: 520px) {
  .hs-cap.is-open .hs-cap-figure { display: none; }
  .hs-cap.is-open > .hs-cap-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
  .hs-faq { padding-left: 0; border-left: 0; }
}

/* Tall or narrow windows stack; the program mix yields its space first. */
@container hs (max-aspect-ratio: 6 / 5) or (max-width: 720px) {
  .hs-home { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(84px, 1fr) auto; grid-template-areas: "hero" "plan" "explore"; }
  /* A branch opened in a stacked window takes the stage's place until it is closed. */
  .hs-home:has(.hs-cap.is-open) { grid-template-rows: auto minmax(0, 1fr); grid-template-areas: "hero" "explore"; }
  .hs-home:has(.hs-cap.is-open) .hs-autoplan { display: none; }
  .hs-mix { display: none; }
}
@container hs (max-width: 520px) {
  .hs-hero { grid-template-columns: minmax(0, 1fr); grid-template-areas: "text" "aside" "cluster"; }
  .hs-hero-aside { align-items: flex-start; }
  .hs-hint { display: none; }
  .hs-cell { padding-left: 8px; }
  .hs-cell-label { font-size: 0.56rem; letter-spacing: 0.05em; }
}
@container hs (max-height: 640px) {
  .hs-hero p { display: none; }
  .hs-autoplan .hs-section-head h4 { display: none; }
  .hs-mix-list li:nth-child(n + 4) { display: none; }
}
@container hs (max-height: 500px) {
  .hs-hint, .hs-caption { display: none; }
  .hs-mix-list li:nth-child(n + 3) { display: none; }
}
/* Stacked and short: the branch index folds into two columns so the drawing keeps its room. */
@container hs ((max-aspect-ratio: 6 / 5) or (max-width: 720px)) and (max-height: 720px) {
  .hs-tree:not(.has-open) { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 14px; }
  .hs-tree:not(.has-open) > .hs-cap { max-height: none; }
  .hs-tree:not(.has-open) .hs-cap-head { grid-template-columns: 24px minmax(0, 1fr) 12px; gap: 8px; }
  .hs-tree:not(.has-open) .hs-cap-summary { display: none; }
}
@container hs (max-height: 380px) {
  .hs-cluster, .hs-hero-aside, .hs-mix-list { display: none; }
}

/* ── New Project modal ─────────────────────────────────────────────── */
.modal-content.np-modal { max-width: 520px; width: calc(100vw - 32px); max-height: none; }
.np-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 4px 20px; }
.np-head h2 { margin: 0; font-size: 1.05rem; font-weight: 600; color: var(--text); }
.np-body { padding: 0 12px 14px; }
.np-eyebrow { padding: 12px 8px 4px; font-size: 0.64rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.np-option {
  appearance: none;
  width: 100%;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 160ms var(--hs-ease);
}
.np-option:hover, .np-option:focus-visible { background: var(--overlay-hover); outline: none; }
.np-option:focus-visible { box-shadow: inset 0 0 0 1px var(--accent); }
.np-option:disabled { opacity: 0.5; cursor: not-allowed; background: transparent; }
.np-glyph { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 9px; box-shadow: var(--hs-cut); }
.np-title { display: block; font-size: 0.86rem; font-weight: 600; line-height: 1.25; }
.np-desc { display: block; margin-top: 2px; font-size: 0.74rem; line-height: 1.35; color: var(--muted); }
.np-desc code { font-size: 0.7rem; }
.np-side { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.np-tag { padding: 2px 7px; border: 1px solid var(--border); border-radius: 999px; font-size: 0.6rem; letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap; }
.np-option:hover .np-chevron { color: var(--text); }
.np-url { display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 12px; padding: 8px; }
.np-url-field { display: flex; gap: 6px; margin-top: 6px; }
.np-url-field input {
  flex: 1;
  min-width: 0;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--input-border);
  border-radius: 6px;
  background: var(--input-bg);
  color: var(--text);
  font-size: 0.78rem;
}
.np-url-field input:focus { outline: none; border-color: var(--accent); }
.np-url-field .btn-primary { height: 30px; padding: 0 14px; font-size: 0.78rem; }

/* ── Navigator header ──────────────────────────────────────────────── */
.tree-header { container: navhead / inline-size; }
.nav-title-group { display: flex; align-items: center; gap: 6px; min-width: 0; }
.nav-title { margin: 0; font-size: 1.1rem; }

.nav-icon-btn {
  appearance: none;
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 160ms var(--hs-ease), color 160ms var(--hs-ease);
}
.nav-icon-btn:hover { color: var(--text); background: var(--overlay-hover); }
.nav-icon-btn:focus-visible { outline: 1px solid var(--accent); outline-offset: 1px; }
.nav-icon-btn.active { color: var(--accent); background: var(--accent-faint); }
#navigator-search-toggle.active { transform: none; box-shadow: inset 0 0 0 1px var(--accent-light); }
.navigator-search-icon { display: inline-grid; place-items: center; color: var(--muted); }
.navigator-search-icon svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; }

.nav-actions:not(:has(> .nav-toolbar:not(.is-hidden))) { display: none; }
.nav-actions > .nav-toolbar {
  display: flex;
  align-items: stretch;
  gap: 3px;
  padding: 3px;
  border-radius: 10px;
  box-shadow: var(--hs-cut);
}
.nav-actions > .nav-toolbar.is-hidden,
.nav-action.is-hidden,
.nav-icon-btn.is-hidden { display: none; }

.nav-action {
  appearance: none;
  flex: 1 1 0;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 30px;
  padding: 0 8px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
  cursor: pointer;
  transition: background 160ms var(--hs-ease), color 160ms var(--hs-ease);
}
.nav-action span { overflow: hidden; text-overflow: ellipsis; }
.nav-action:hover { color: var(--text); background: var(--overlay-hover); }
.nav-action:focus-visible { outline: 1px solid var(--accent); outline-offset: 1px; }
/* The primary action is a white puck in both themes; ink text keeps it legible. */
.nav-action--primary { background: #ffffff; color: #1c1b18; box-shadow: var(--hs-puck); }
.nav-action--primary:hover { background: #ffffff; color: #1c1b18; }
.nav-action--primary svg { color: var(--accent); }
.nav-action--back { flex: 0 0 auto; padding: 0 10px 0 6px; color: var(--muted); }
.nav-action.active { background: var(--accent-faint); color: var(--accent); }

@container navhead (max-width: 300px) {
  .nav-action span { display: none; }
  .nav-action { padding: 0; }
  /* Applets stays named at every width — it is the control people look for. */
  #navigator-layout-toggle { flex: 1.6 1 0; padding: 0 8px; }
  #navigator-layout-toggle span { display: inline; }
  .nav-action--back { padding: 0 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .hs-home *, .np-modal *, .tree-header * { animation: none !important; transition: none !important; }
}
