/* 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; }
}

/* One shared control rail for project navigation and view actions. */
.nav-actions {
  display: flex;
  min-width: 0;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  width: 100%;
}

.nav-actions > .nav-toolbar {
  display: flex;
  min-width: 0;
  flex: 0 0 auto;
  align-items: center;
  flex-wrap: nowrap;
  gap: 4px;
  padding: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.nav-actions > .nav-toolbar.is-hidden,
.nav-action.is-hidden {
  display: none;
}

.nav-actions > .nav-view-toolbar {
  margin-left: auto;
}

.nav-actions .nav-action {
  box-sizing: border-box;
  min-width: 34px;
  height: 34px;
  flex: 0 0 auto;
  gap: 6px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text-secondary, var(--muted));
  font-size: 0.76rem;
  font-weight: 550;
}

.nav-actions .nav-action:hover {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
  background: color-mix(in srgb, var(--bg-card) 82%, var(--overlay-hover));
  color: var(--text);
}

.nav-actions .nav-action.active,
#navigator-search-toggle.active {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--border));
  background: var(--accent-faint);
  color: var(--accent);
  box-shadow: none;
  transform: none;
}

.nav-actions .nav-action:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#tree-sort-toggle::after {
  content: "View";
  font-size: 0.76rem;
}

@container navhead (max-width: 320px) {
  .nav-actions {
    gap: 3px;
  }

  .nav-actions > .nav-toolbar {
    gap: 3px;
  }

  .nav-actions .nav-action {
    width: 34px;
    min-width: 34px;
    padding: 0;
  }

  .nav-actions .nav-action span,
  #tree-sort-toggle::after {
    display: none;
  }
}

/* Project home uses one page scroll; its cards stay content sized. */
#detail-view:has(> .project-home-dashboard) {
  display: block;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.project-home-dashboard {
  display: flex;
  box-sizing: border-box;
  width: 100%;
  height: auto;
  min-height: 100%;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
  overflow: visible;
  padding: 18px clamp(12px, 1.6vw, 24px) 26px;
}

.project-home-header {
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  padding: 2px 2px 14px;
}

.project-home-heading {
  min-width: 0;
  flex: 1 1 220px;
}

.project-home-heading h2 {
  margin: 2px 0 5px;
  font-size: clamp(1.2rem, 1.5vw, 1.55rem);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.project-home-storage {
  min-width: 0;
  flex-wrap: wrap;
  gap: 7px;
  font-size: 0.75rem;
}

.project-home-settings-button {
  min-height: 34px;
  flex: 0 0 auto;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.76rem;
  font-weight: 600;
  margin-left: auto;
}

.project-home-analytics {
  display: grid;
  gap: 10px;
}

.project-home-section-head,
.project-home-panel-heading {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.project-home-section-head h3,
.project-home-panel-heading h3 {
  margin: 1px 0 0;
  color: var(--text);
  font-size: 0.98rem;
  font-weight: 650;
  line-height: 1.25;
}

.project-home-analytics-actions {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 9px;
}

.project-home-widget-count,
.project-home-panel-heading > span,
.project-home-structure-actions > span {
  color: var(--muted);
  font-size: 0.7rem;
  white-space: nowrap;
}

.project-home-customizer {
  position: relative;
  z-index: 5;
}

.project-home-customizer > summary {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  gap: 7px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text);
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 600;
  list-style: none;
  user-select: none;
}

.project-home-customizer > summary::-webkit-details-marker {
  display: none;
}

.project-home-customizer > summary:hover,
.project-home-customizer[open] > summary {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--border));
  background: var(--accent-faint);
  color: var(--accent);
}

.project-home-customizer-menu {
  position: absolute;
  top: calc(100% + 7px);
  right: 0;
  width: min(290px, calc(100vw - 32px));
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card);
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.2);
}

.project-home-customizer-menu > p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.45;
}

.project-home-widget-choices {
  display: grid;
  gap: 2px;
}

.project-home-widget-choice {
  display: flex;
  min-height: 32px;
  align-items: center;
  gap: 8px;
  padding: 3px 5px;
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  font-size: 0.76rem;
}

.project-home-widget-choice:hover {
  background: color-mix(in srgb, var(--bg-card) 78%, var(--overlay-hover));
}

.project-home-widget-choice input {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--accent);
}

.project-home-reset-widgets {
  margin-top: 9px;
  padding: 5px 0 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
}

.project-home-widget-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.project-home-widget {
  display: grid;
  min-width: 0;
  min-height: 102px;
  align-content: start;
  gap: 5px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg-card);
}

.project-home-widget[hidden] {
  display: none;
}

.project-home-widget-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
}

.project-home-widget-label > span:first-child {
  display: inline-grid;
  width: 18px;
  height: 18px;
  place-items: center;
  border-radius: 5px;
  background: color-mix(in srgb, var(--accent) 10%, var(--bg-card));
  color: var(--accent);
  font-size: 0.74rem;
}

.project-home-widget-value {
  color: var(--text);
  font-size: 1.35rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.1;
}

.project-home-widget-detail {
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.35;
}

.project-home-analytics-empty {
  margin: 0;
  padding: 16px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
}

.project-home-analytics-empty[hidden] {
  display: none;
}

.project-home-reference-note {
  display: flex;
  min-width: 0;
  align-items: baseline;
  justify-content: flex-end;
  gap: 6px;
  color: var(--muted);
  font-size: 0.67rem;
}

.project-home-reference-note strong {
  color: var(--text-secondary, var(--text));
  font-weight: 550;
}

.project-home-next-step {
  display: flex;
  min-width: 0;
  align-items: baseline;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: color-mix(in srgb, var(--bg-card) 82%, var(--overlay-subtle));
}

.project-home-next-step > span {
  flex: 0 0 auto;
  color: var(--accent);
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.project-home-next-step p {
  margin: 0;
  color: var(--text-secondary, var(--text));
  font-size: 0.75rem;
  line-height: 1.4;
}

.project-home-main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(250px, 0.85fr);
  align-items: start;
  gap: 12px;
}

.project-home-main-grid > .detail-panel,
.project-home-side-rail > .detail-panel {
  min-width: 0;
  margin: 0;
  padding: 13px;
  border-radius: 10px;
}

.project-home-panel-heading {
  margin-bottom: 10px;
}

.project-home-panel-heading .overview-kicker {
  margin-bottom: 1px;
}

.project-home-structure-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.project-home-structure-add {
  width: 31px;
  height: 31px;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg-card);
  color: var(--text);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}

.project-home-structure-add:hover {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--border));
  color: var(--accent);
}

.project-home-structure-tree {
  display: grid;
}

.project-home-department {
  min-width: 0;
  border-top: 1px solid var(--border);
}

.project-home-department > summary,
.project-home-functional-area > summary {
  display: grid;
  min-width: 0;
  grid-template-columns: 16px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  padding: 9px 3px;
  cursor: pointer;
  list-style: none;
}

.project-home-department > summary::-webkit-details-marker,
.project-home-functional-area > summary::-webkit-details-marker {
  display: none;
}

.project-home-tree-chevron {
  display: inline-block;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1;
  transition: transform 120ms ease;
}

.project-home-department[open] > summary .project-home-tree-chevron,
.project-home-functional-area[open] > summary .project-home-tree-chevron {
  transform: rotate(90deg);
}

.project-home-tree-name {
  min-width: 0;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 620;
  overflow-wrap: anywhere;
}

.project-home-tree-meta {
  color: var(--muted);
  font-size: 0.67rem;
  line-height: 1.3;
  text-align: right;
  white-space: nowrap;
}

.project-home-functional-areas {
  padding: 0 0 7px 18px;
}

.project-home-functional-area {
  border-top: 1px solid color-mix(in srgb, var(--border) 75%, transparent);
}

.project-home-functional-area > summary {
  grid-template-columns: 15px minmax(0, 1fr) auto;
  padding: 8px 3px;
}

.project-home-functional-area .project-home-tree-name {
  font-size: 0.74rem;
  font-weight: 560;
}

.project-home-functional-area .project-home-tree-meta {
  font-size: 0.65rem;
}

.project-home-room-content {
  padding: 0 0 9px 20px;
}

.project-home-room-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.project-home-room-table th {
  padding: 5px 4px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 650;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.035em;
}

.project-home-room-table td {
  padding: 6px 4px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  color: var(--text-secondary, var(--text));
  font-size: 0.7rem;
  vertical-align: middle;
}

.project-home-room-table th:first-child,
.project-home-room-table td:first-child {
  width: 48px;
}

.project-home-room-table th:nth-child(3),
.project-home-room-table td:nth-child(3) {
  width: 66px;
}

.project-home-room-table th:nth-child(4),
.project-home-room-table td:nth-child(4) {
  width: 38px;
  text-align: right;
}

.project-home-room-table input[type="number"] {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  height: 27px;
  padding: 3px 4px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--bg-card);
  color: var(--text);
  font: inherit;
  font-size: 0.69rem;
  text-align: center;
}

.project-home-room-name {
  display: flex;
  min-width: 0;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 3px 6px;
}

.project-home-room-number,
.project-home-room-code {
  color: var(--muted);
  font-size: 0.65rem;
  font-variant-numeric: tabular-nums;
}

.project-home-room-number.is-empty {
  font-style: italic;
}

.project-home-room-name strong {
  min-width: 0;
  color: var(--text);
  font-size: 0.7rem;
  font-weight: 560;
  overflow-wrap: anywhere;
}

.project-home-room-name small {
  flex-basis: 100%;
  color: var(--muted);
  font-size: 0.62rem;
}

.project-home-room-equipment {
  font-variant-numeric: tabular-nums;
}

.project-home-tree-empty {
  margin: 0;
  padding: 7px 3px 10px;
  color: var(--muted);
  font-size: 0.7rem;
}

.project-home-structure-empty {
  display: grid;
  justify-items: start;
  gap: 8px;
  padding: 10px 2px 2px;
}

.project-home-structure-empty p {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.project-home-side-rail {
  display: grid;
  min-width: 0;
  gap: 12px;
}

.project-home-tools-list {
  display: grid;
  gap: 5px;
}

.project-home-tool {
  display: grid;
  min-width: 0;
  min-height: 49px;
  grid-template-columns: 28px minmax(0, 1fr) 14px;
  align-items: center;
  gap: 8px;
  padding: 6px 7px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.project-home-tool:hover {
  border-color: var(--border);
  background: color-mix(in srgb, var(--bg-card) 84%, var(--overlay-hover));
}

.project-home-tool:focus-visible,
.project-home-structure-add:focus-visible,
.project-home-customizer > summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.project-home-tool-icon {
  display: inline-grid;
  width: 27px;
  height: 27px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg-card);
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 650;
}

.project-home-tool-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.project-home-tool-copy strong {
  font-size: 0.74rem;
  font-weight: 620;
}

.project-home-tool-copy small {
  color: var(--muted);
  font-size: 0.65rem;
  line-height: 1.3;
}

.project-home-tool-arrow {
  color: var(--muted);
  font-size: 1rem;
  text-align: right;
}

.project-home-main-grid .project-change-dashboard-panel {
  padding: 0;
}

.project-home-main-grid .project-change-dashboard-summary {
  min-height: 42px;
  padding: 9px 11px;
}

@container project-detail-pane (max-width: 760px) {
  .project-home-main-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .project-home-side-rail {
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    align-items: start;
  }
}

@container project-detail-pane (max-width: 520px) {
  .project-home-dashboard {
    gap: 11px;
    padding: 12px 10px 18px;
  }

  .project-home-header {
    align-items: flex-start;
  }

  .project-home-analytics-actions {
    gap: 5px;
  }

  .project-home-widget-count {
    display: none;
  }

  .project-home-widget-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .project-home-department > summary,
  .project-home-functional-area > summary {
    grid-template-columns: 15px minmax(0, 1fr);
  }

  .project-home-tree-meta {
    grid-column: 2;
    text-align: left;
  }

  .project-home-functional-areas {
    padding-left: 12px;
  }

  .project-home-room-content {
    padding-left: 4px;
  }

  .project-home-room-table th:first-child,
  .project-home-room-table td:first-child {
    width: 42px;
  }

  .project-home-room-table th:nth-child(3),
  .project-home-room-table td:nth-child(3) {
    width: 58px;
  }
}

.project-home-dashboard,
.project-home-analytics,
.project-home-widget-grid,
.project-home-main-grid,
.project-home-side-rail {
  min-width: 0;
}

@media (max-width: 900px) {
  .project-home-header,
  .project-home-section-head,
  .project-home-panel-heading {
    flex-wrap: wrap;
  }

  .project-home-heading {
    min-width: 0;
    flex: 1 1 220px;
  }

  .project-home-heading h2 {
    overflow-wrap: anywhere;
  }

  .project-home-settings-button {
    margin-left: auto;
  }

  .project-home-analytics-actions {
    width: 100%;
    justify-content: space-between;
  }

  .project-home-widget-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .project-home-main-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@container project-detail-pane (max-width: 380px) {
  .project-home-widget-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}
