/* Study 04: navigation changes; the accepted material and compact reader do not. */
.nav-workspace { height: clamp(570px, calc(100svh - 190px), 820px); }
.navigation-study .study-instruction { margin: 22px 0 16px; }
.nav-bar { position: absolute; z-index: 3; inset: 12px 12px auto; padding: 8px 14px; border-radius: 11px; }
.run-heading { display: flex; align-items: center; gap: 16px; min-width: 0; }
#catalog-open { border: 0; padding: 0 4px; }
.run-context { font-size: 11px; color: var(--muted); }
.nav-run-state { display: flex; align-items: center; gap: 9px; margin-left: auto; font-size: 12px; }
.path-line { display: flex; align-items: center; gap: 6px; min-width: 0; }
#up { width: 44px; height: 44px; }
#up .icon { transform: rotate(180deg); }
#up:disabled { opacity: .3; cursor: default; }
#breadcrumbs { display: flex; flex: 1; align-items: center; min-width: 0; overflow-x: auto; scrollbar-width: thin; gap: 4px; }
#breadcrumbs button { white-space: nowrap; min-height: 44px; padding: 8px; border: 0; background: transparent; color: var(--muted); border-radius: 6px; font-size: 13px; }
#breadcrumbs button:hover { background: var(--field); }
#breadcrumbs button[aria-current] { color: var(--ink); font-weight: 500; }
.crumb-separator { color: var(--muted); font-size: 12px; }
.nav-canvas { position: absolute; height: 260px; transform-origin: 0 0; will-change: transform; }
.nav-canvas.moving { transition: transform 300ms cubic-bezier(.2,.8,.25,1); }
.nav-connections { position: absolute; inset: 0; width: 100%; height: 260px; fill: none; stroke: var(--line); stroke-width: 1.3; }
.nav-node { height: 128px; gap: 10px; }
.nav-node strong { font-size: 14px; line-height: 1.35; }
.nav-node .node-kind { max-width: 100%; }
.nav-node code { font-size: 10px; overflow: hidden; text-overflow: ellipsis; }
.node-bottom { margin-top: auto; display: flex; align-items: center; justify-content: space-between; width: 100%; }
.node-bottom .state { margin: 0; }
.nested-count { font-size: 10px; color: var(--muted); display: flex; align-items: center; gap: 3px; }
.nested-count .icon { width: 12px; height: 12px; }
.nav-node:hover { border-color: var(--muted); }
/* Keep the small label readable on a selected, tinted surface; light is unchanged. */
body.navigation-study[data-theme='light'] [data-state='error'] .state { color: #a23832; }
.nav-detail { inset: 128px 12px 74px auto; height: calc(100% - 202px); width: 348px; }
.nav-detail .other-result { padding: 20px; }
.nav-detail .other-result h3 { font-size: 17px; line-height: 1.4; margin-bottom: 10px; }
.nav-detail .other-result p { font-size: 13px; line-height: 1.65; color: var(--muted); margin: 10px 0; }
.detail-head > div { min-width: 0; }
#detail-code { font-family: ui-monospace, monospace; font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-detail-actions { display: flex; flex-direction: column; gap: 8px; padding: 12px 16px 16px; border-top: 1px solid var(--line); }
.nav-detail-actions:has(> :not([hidden])) { flex-shrink: 0; }
.nav-detail-actions:has(> button):not(:has(> :not([hidden]))) { display: none; }
.error-code { font-family: ui-monospace, monospace; font-size: 12px !important; color: var(--ink) !important; padding: 10px 12px; border-left: 2px solid var(--signal); background: var(--field); overflow-wrap: anywhere; }
/* The run hierarchy is an optional layer, anchored above the view toolbar. */
.nav-tree { position: absolute; z-index: 3; inset: 128px auto 74px 12px; margin: 0; width: 344px; max-width: none; max-height: none; height: calc(100% - 202px); color: var(--ink); padding: 0; border-radius: 12px; }
.nav-tree[open] { display: flex; flex-direction: column; }
.nav-tree > header { display: flex; align-items: center; justify-content: space-between; padding: 10px 10px 8px 18px; flex-shrink: 0; }
.nav-tree h2 { font-size: 14px; font-weight: 550; }
#tree-close { width: 44px; height: 44px; }
.tree-scroll { overflow: auto; overscroll-behavior: contain; min-height: 0; flex: 1; padding: 0 12px 18px; scrollbar-width: thin; }
.tree-scroll:focus-visible, .catalog-scroll:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; }
.step-branch { list-style: none; padding: 0 0 0 12px; margin: 0 0 0 12px; }
.step-branch > li { position: relative; }
/* Each vertical rail starts at its parent's chevron; the last elbow terminates it. */
.step-branch > li::before { content: ''; position: absolute; top: 0; bottom: 0; left: -12px; width: 1px; background: var(--tree-rail); }
.step-branch > li:last-child::before { bottom: auto; height: 22px; }
.step-branch > li::after { content: ''; position: absolute; top: 22px; left: -12px; width: 12px; height: 1px; background: var(--tree-rail); }
.nav-tree { --tree-rail: #8499ab; }
body[data-theme='dark'] .nav-tree { --tree-rail: #42596c; }
.step-branch > li:has([aria-current='step'])::before,
.step-branch > li:has([aria-current='step'])::after { background: color-mix(in srgb, var(--accent) 60%, var(--tree-rail)); }
.step-row { position: relative; display: flex; align-items: flex-start; border-radius: 6px; }
.tree-toggle, .tree-spacer { display: inline-grid; place-items: center; flex: 0 0 24px; width: 24px; height: 44px; border: 0; border-radius: 5px; background: transparent; padding: 0; }
.tree-toggle { color: var(--muted); }
.tree-toggle:hover { color: var(--ink); background: var(--field); }
.tree-toggle .icon { width: 15px; height: 15px; stroke-width: 1.7; transform: rotate(90deg); transition: transform 160ms cubic-bezier(.2,.8,.25,1); }
.tree-toggle[aria-expanded='false'] .icon { transform: rotate(0); }
.tree-step { display: flex; align-items: flex-start; gap: 8px; flex: 1; text-align: left; min-width: 0; min-height: 44px; padding: 12px 8px 12px 0; border: 0; border-radius: 6px; background: transparent; font-size: 13px; line-height: 20px; }
.tree-kind { width: 16px; height: 16px; flex-shrink: 0; margin-top: 2px; color: var(--muted); }
.tree-step .lamp { margin: 7px 0 0 auto; flex-shrink: 0; }
.tree-label { overflow-wrap: anywhere; }
.step-group > .tree-step { font-weight: 550; }
.step-group > .tree-step .tree-kind { color: var(--ink); }
.step-row:has([aria-current='step']) { background: color-mix(in srgb, var(--accent) 12%, var(--field)); box-shadow: inset 2px 0 0 var(--accent); }
.tree-root { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 44px; border: 0; border-radius: 6px; padding: 10px 4px; text-align: left; background: transparent; font-size: 14px; font-weight: 550; }
.tree-root .icon { width: 16px; height: 16px; flex-shrink: 0; }
.tree-root[aria-current] { color: var(--accent); }
.nav-workspace .canvas-controls { z-index: 4; }
.tree-tool { position: relative; }
#tree-open { position: relative; color: var(--muted); transition: background 160ms, color 160ms; }
#tree-open .icon { width: 19px; height: 19px; }
#tree-open[aria-pressed='true'] { color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--field)); box-shadow: inset 0 1px 0 var(--reflection); }
.tool-on { position: absolute; bottom: 3px; left: calc(50% - 6px); width: 12px; height: 2px; border-radius: 2px; background: var(--accent); opacity: 0; transition: opacity 160ms; }
#tree-open[aria-pressed='true'] .tool-on { opacity: 1; }
.tool-tooltip { position: absolute; bottom: calc(100% + 12px); right: -4px; z-index: 5; white-space: nowrap; padding: 8px 10px; background: var(--field); color: var(--ink); border: 1px solid var(--line); border-radius: 7px; box-shadow: 0 4px 16px rgb(var(--shadow) / .14); font-size: 12px; line-height: 1.4; opacity: 0; visibility: hidden; transform: translateY(3px); transition: opacity 120ms, transform 120ms, visibility 120ms; pointer-events: none; }
.tree-tool:has(#tree-open:focus-visible):not(.tooltip-dismissed) .tool-tooltip { opacity: 1; visibility: visible; transform: none; }
@media (hover: hover) {
  .step-row:has(.tree-step:hover), .tree-root:hover { background: var(--field); }
  .tree-tool:hover:not(.tooltip-dismissed) .tool-tooltip { opacity: 1; visibility: visible; transform: none; transition-delay: 350ms; }
}
.catalog { position: fixed; inset: 0; margin: auto; padding: 0; width: min(480px, calc(100vw - 24px)); height: min(570px, calc(100dvh - 40px)); max-height: none; color: var(--ink); border-radius: 14px; }
.catalog[open] { display: flex; flex-direction: column; }
.catalog > header { display: flex; justify-content: space-between; align-items: center; padding: 14px 14px 8px 20px; }
.catalog .icon-button { width: 44px; height: 44px; }
.catalog-search { display: flex; align-items: center; gap: 10px; margin: 8px 18px 14px; padding: 4px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--field); }
.catalog-search input { flex: 1; min-width: 0; border: 0; color: var(--ink); background: transparent; font: inherit; font-size: 16px; min-height: 40px; outline-offset: -2px; }
.catalog-search input::placeholder { color: var(--muted); }
.catalog-scroll { overflow: auto; overscroll-behavior: contain; min-height: 0; padding: 10px 16px 24px; }
.catalog-scroll p { margin: 8px 4px 12px; color: var(--muted); font-size: 12px; }
.catalog-row { display: flex; align-items: center; gap: 14px; width: 100%; padding: 16px 10px; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; }
.catalog-row:hover { background: var(--field); }
.catalog-row > span { min-width: 0; flex: 1; }
.catalog-row strong { display: block; font-size: 14px; font-weight: 500; }
.catalog-row small { display: block; margin-top: 5px; font-size: 11px; color: var(--muted); overflow-wrap: anywhere; }
.catalog::backdrop, .nav-tree::backdrop { background: rgb(10 20 30 / .24); }
.catalog.entering, .catalog.leaving, .nav-tree.entering, .nav-tree.leaving { animation: rise var(--duration) cubic-bezier(.2,.8,.25,1) both; }
.catalog.leaving, .nav-tree.leaving { animation-direction: reverse; }
#nav-comment, #copy-fallback { width: 100%; }
.reading-head > div { min-width: 0; }
.navigation-study .reading-head h2 { font-size: 18px; }
@media (max-width: 1024px) {
  .nav-workspace { height: clamp(360px, 56svh, 500px); }
  .nav-bar { inset: 8px 8px auto; padding: 6px 8px; }
  .run-heading { gap: 8px; flex-wrap: wrap; }
  .run-context { display: none; }
  .nav-run-state { font-size: 10px; gap: 6px; }
  #catalog-open { font-size: 12px; }
  #breadcrumbs button { font-size: 12px; padding: 8px 6px; }
  #breadcrumbs { gap: 0; }
  .nav-detail { position: fixed; inset: auto 8px max(8px, env(safe-area-inset-bottom)); width: calc(100vw - 16px); max-width: none; height: min(560px, 82dvh); }
  .nav-detail.entering, .nav-detail.leaving { animation-name: rise; }
  .navigation-study #step-select { display: block; flex: 1; width: 0; }
  .navigation-study .scenario-strip { display: block; }
  .navigation-study .scenario-strip p { margin-bottom: 10px; }
  .navigation-study .scenario-actions { width: 100%; }
  .nav-tree { position: fixed; inset: auto 8px max(8px, env(safe-area-inset-bottom)); width: calc(100vw - 16px); height: min(680px, 85dvh); border-radius: 15px; }
  #tree-close { display: inline-grid; width: 44px; height: 44px; }
  .tree-step { font-size: 13px; }
  .tree-scroll { padding: 0 10px 14px; }
  .nav-workspace .canvas-controls { bottom: 10px; left: 8px; }
  .canvas-controls button { width: 40px; }
  .canvas-controls output { width: 34px; }
  .navigation-study .reading-head h2 { font-size: 15px; }
  .navigation-study .reading-head .state { display: none; }
}
@media (max-width: 360px) {
  .nav-workspace .canvas-controls output { display: none; }
  .nav-workspace .canvas-controls > span { margin: 0 1px; }
}
@media (prefers-reduced-motion: reduce) {
  .nav-canvas.moving, .tree-toggle .icon, #tree-open, .tool-on, .tool-tooltip { transition: none; }
  .navigation-study .entering, .navigation-study .leaving { animation: none; }
}
