:root {
  --font-body: "Source Serif 4", Georgia, serif;
  --font-mono: "JetBrains Mono", monospace;
  --font-ui: "DM Sans", system-ui, sans-serif;
  --color-bg: #f7f5f0;
  --color-fg: #2e2c2a;
  --color-muted: #807a72;
  --color-accent: #4a6fa5;
  --color-error: #b84a3c;
  --color-border: #ddd8d0;
  --color-surface: #fdfcf9;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg: #1e1d1b;
    --color-fg: #d4d0c8;
    --color-muted: #918b82;
    --color-accent: #7ea8d4;
    --color-error: #d4816e;
    --color-border: #38352f;
    --color-surface: #26251f;
  }
}

:root[data-theme="dark"] {
  --color-bg: #1e1d1b;
  --color-fg: #d4d0c8;
  --color-muted: #918b82;
  --color-accent: #7ea8d4;
  --color-error: #d4816e;
  --color-border: #38352f;
  --color-surface: #26251f;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-fg);
  line-height: 1.6;
}

#app {
  max-width: 42rem;
  margin: 0 auto;
  padding: 2rem 1rem;
  position: relative;
}

#theme-toggle {
  position: fixed;
  top: 0.75rem;
  right: 0.75rem;
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  opacity: 0.8;
  z-index: 20;
}

#theme-toggle:hover {
  opacity: 1;
}

.screen[hidden] {
  display: none !important;
}

/* ─── Entry screen ─── */
#entry-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding-top: 20vh;
}

#entry-screen h1 {
  font-family: var(--font-ui);
  font-size: 2rem;
  font-weight: 600;
}

.subtitle {
  color: var(--color-muted);
  font-size: 0.95rem;
}

#repo-form {
  display: flex;
  gap: 0.5rem;
  width: 100%;
  max-width: 28rem;
}

#repo-input {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface);
  color: var(--color-fg);
}

#repo-input:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: -1px;
}

button {
  font-family: var(--font-ui);
  font-size: 0.9rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface);
  color: var(--color-fg);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

button:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.error {
  color: var(--color-error);
  font-size: 0.85rem;
}

#loading-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
  background: var(--color-bg);
  z-index: 30;
}

.loading {
  color: var(--color-muted);
  font-style: italic;
  animation: loading-pulse 1.2s ease-in-out infinite;
}

@keyframes loading-pulse {
  0%, 100% {
    opacity: 0.55;
  }

  50% {
    opacity: 1;
  }
}

/* ─── Overview screen ─── */
#overview-header {
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--color-border);
}

#overview-header h2 {
  font-family: var(--font-ui);
  font-size: 1.4rem;
  font-weight: 600;
}

.branch-toggle {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--color-muted);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.15rem;
  background: none;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 2px 6px;
  cursor: pointer;
}

.branch-toggle:hover {
  color: var(--color-accent);
}

.branch-form {
  margin-top: 0.15rem;
}

.branch-input {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 0.15rem 0.4rem;
  border: 1px solid var(--color-accent);
  border-radius: 4px;
  background: var(--color-surface);
  color: var(--color-fg);
  outline: none;
}

.branch-form[hidden] {
  display: none;
}

#overview-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
  margin-bottom: 1.25rem;
}

.source-badge {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  padding: 0;
  border: none;
  background: none;
  color: var(--color-border);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

span.source-badge[data-active="false"] {
  cursor: default;
}

button.source-badge[data-active="true"] {
  color: var(--color-muted);
  cursor: pointer;
}

button.source-badge[data-active="true"]:hover {
  color: var(--color-accent);
}

#overview-actions {
  margin-bottom: 1.25rem;
}

.overview-search-container {
  margin-top: 0.75rem;
}

#overview-search {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface);
  color: var(--color-fg);
}

#overview-search:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: -1px;
}

#overview-suggestions h3 {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.suggestion-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.suggestion-item {
  display: flex;
  width: 100%;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--color-border);
  border-bottom: none;
  background: var(--color-surface);
  cursor: pointer;
  transition: background 0.12s;
  text-align: left;
}

.suggestion-list > li:first-child .suggestion-item {
  border-radius: 8px 8px 0 0;
}

.suggestion-list > li:last-child .suggestion-item {
  border-bottom: 1px solid var(--color-border);
  border-radius: 0 0 8px 8px;
}

.suggestion-list > li:only-child .suggestion-item {
  border-radius: 8px;
  border-bottom: 1px solid var(--color-border);
}

.suggestion-item:hover {
  background: color-mix(in srgb, var(--color-accent) 5%, var(--color-surface));
  border-color: var(--color-accent);
}

.suggestion-list > li:hover + li .suggestion-item,
.suggestion-list > li:focus-within + li .suggestion-item {
  border-top-color: var(--color-accent);
}

.suggestion-item .label {
  font-family: var(--font-ui);
  font-weight: 500;
  white-space: nowrap;
}

.suggestion-item .path {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--color-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── Navigation bars ─── */
#file-nav,
#beads-nav,
#history-nav,
#wai-nav,
#specs-nav {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  margin-bottom: 0.75rem;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}

#file-breadcrumb,
#beads-breadcrumb,
#history-breadcrumb,
#wai-breadcrumb,
#specs-breadcrumb {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--color-muted);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  direction: rtl;
  text-align: left;
}

#file-actions,
#specs-actions {
  display: inline-flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.breadcrumb-seg {
  display: inline;
  font-family: var(--font-mono);
  font-size: inherit;
  color: var(--color-accent);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.breadcrumb-seg:hover {
  text-decoration: underline;
}

.breadcrumb-sep {
  color: var(--color-muted);
  margin: 0 0.1rem;
}

.breadcrumb-meta-sep {
  color: var(--color-muted);
  margin: 0 0.45rem;
}

.canonical-spec-link {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  color: var(--color-accent);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.canonical-spec-link:hover {
  text-decoration: underline;
}

.copy-link-button {
  min-width: 2.4rem;
  font-size: 0.8rem;
}

.copy-link-button.copied {
  color: var(--color-accent);
}

#file-nav button,
#beads-nav button,
#history-nav button,
#wai-nav button,
#specs-nav button {
  flex-shrink: 0;
  font-size: 0.8rem;
  padding: 0.3rem 0.6rem;
}

.suggestion-item,
.tree-item,
.tree-search-item {
  appearance: none;
  border-radius: 0;
}

.suggestion-item:focus-visible,
.tree-item:focus-visible,
.tree-search-item:focus-visible,
.breadcrumb-seg:focus-visible,
.changed-path-link:focus-visible,
.wai-artifact-link:focus-visible,
.canonical-spec-link:focus-visible,
.copy-link-button:focus-visible,
#specs-download:focus-visible,
.beads-list-item:focus-visible,
.beads-dep-link:focus-visible,
.issue-ref-link:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
}

/* ─── Content panels ─── */
#file-content,
#beads-content,
#history-content,
#wai-content,
#specs-content {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
}

/* ─── Markdown document typography ─── */
#file-content h1,
#file-content h2,
#file-content h3,
#file-content h4,
#file-content h5,
#file-content h6 {
  font-family: var(--font-ui);
  line-height: 1.3;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

#file-content h1:first-child,
#file-content h2:first-child,
#file-content h3:first-child {
  margin-top: 0;
}

#file-content h1 { font-size: 1.6rem; }
#file-content h2 { font-size: 1.3rem; border-bottom: 1px solid var(--color-border); padding-bottom: 0.3rem; }
#file-content h3 { font-size: 1.1rem; }
#file-content h4 { font-size: 1rem; }

#file-content .openspec-summary {
  cursor: pointer;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

#file-content .openspec-heading {
  display: inline;
  margin: 0;
}

#file-content .openspec-details-scenario .openspec-summary {
  font-weight: 500;
}

#file-content .openspec-heading-scenario {
  font-size: 0.92rem;
}

#file-content p {
  margin-top: 0.75rem;
  margin-bottom: 0;
}

/* ─── Table of Contents ─── */
#file-content .doc-toc {
  background: var(--color-bg-panel);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
  font-size: 0.88rem;
}

#file-content .doc-toc ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

#file-content .doc-toc li {
  padding: 0.15rem 0;
}

#file-content .doc-toc li.toc-indent-1 { padding-left: 1rem; }
#file-content .doc-toc li.toc-indent-2 { padding-left: 2rem; }
#file-content .doc-toc li.toc-indent-3 { padding-left: 3rem; }
#file-content .doc-toc li.toc-indent-4 { padding-left: 4rem; }

#file-content .doc-toc a {
  color: var(--color-text-muted);
  text-decoration: none;
}

#file-content .doc-toc a:hover {
  color: var(--color-text);
  text-decoration: underline;
}

#file-content a {
  color: var(--color-accent);
  text-decoration: none;
}

#file-content a:hover {
  text-decoration: underline;
}

#file-content strong {
  font-weight: 600;
}

#file-content img {
  max-width: 100%;
  height: auto;
}

#file-content ul,
#file-content ol {
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
  padding-left: 1.5rem;
}

#file-content li {
  margin-bottom: 0.25rem;
}

#file-content li > ul,
#file-content li > ol {
  margin-top: 0.25rem;
  margin-bottom: 0;
}

#file-content blockquote {
  margin: 0.75rem 0;
  padding: 0.5rem 1rem;
  border-left: 3px solid var(--color-accent);
  color: var(--color-muted);
  background: var(--color-bg);
  border-radius: 0 4px 4px 0;
}

#file-content blockquote p {
  margin-top: 0;
}

#file-content pre {
  margin: 0.75rem 0;
  padding: 0.75rem 1rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  overflow-x: auto;
  white-space: pre;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.5;
}

#file-content code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  padding: 0.15rem 0.35rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 3px;
}

#file-content pre code {
  padding: 0;
  background: none;
  border: none;
  border-radius: 0;
  font-size: inherit;
}

#file-content table {
  width: 100%;
  margin: 0.75rem 0;
  border-collapse: collapse;
  font-size: 0.9rem;
}

#file-content th,
#file-content td {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--color-border);
  text-align: left;
}

#file-content th {
  font-family: var(--font-ui);
  font-weight: 600;
  background: var(--color-bg);
}

#file-content hr {
  margin: 1.5rem 0;
  border: none;
  border-top: 1px solid var(--color-border);
}

/* ─── Specs bundle ─── */
#specs-content h1,
#specs-content h2,
#specs-content h3,
#specs-content h4,
#specs-content h5,
#specs-content h6 {
  font-family: var(--font-ui);
  line-height: 1.3;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

#specs-content h1:first-child,
#specs-content h2:first-child,
#specs-content h3:first-child {
  margin-top: 0;
}

#specs-content h1 { font-size: 1.6rem; }
#specs-content h2 { font-size: 1.3rem; border-bottom: 1px solid var(--color-border); padding-bottom: 0.3rem; }
#specs-content h3 { font-size: 1.1rem; }
#specs-content h4 { font-size: 1rem; }

#specs-content .openspec-summary { cursor: pointer; font-weight: 600; margin-bottom: 0.5rem; }
#specs-content .openspec-heading { display: inline; margin: 0; }
#specs-content .openspec-details-scenario .openspec-summary { font-weight: 500; }
#specs-content .openspec-heading-scenario { font-size: 0.92rem; }
#specs-content p { margin-top: 0.75rem; margin-bottom: 0; }

#specs-content .doc-toc {
  background: var(--color-bg-panel);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
  font-size: 0.88rem;
}
#specs-content .doc-toc ol { margin: 0; padding: 0; list-style: none; }
#specs-content .doc-toc li { padding: 0.15rem 0; }
#specs-content .doc-toc li.toc-indent-1 { padding-left: 1rem; }
#specs-content .doc-toc li.toc-indent-2 { padding-left: 2rem; }
#specs-content .doc-toc li.toc-indent-3 { padding-left: 3rem; }
#specs-content .doc-toc li.toc-indent-4 { padding-left: 4rem; }
#specs-content .doc-toc a { color: var(--color-text-muted); text-decoration: none; }
#specs-content .doc-toc a:hover { color: var(--color-text); text-decoration: underline; }

#specs-content a { color: var(--color-accent); text-decoration: none; }
#specs-content a:hover { text-decoration: underline; }
#specs-content strong { font-weight: 600; }
#specs-content img { max-width: 100%; height: auto; }
#specs-content ul, #specs-content ol { margin-top: 0.5rem; margin-bottom: 0.5rem; padding-left: 1.5rem; }
#specs-content li { margin-bottom: 0.25rem; }
#specs-content li > ul, #specs-content li > ol { margin-top: 0.25rem; margin-bottom: 0; }
#specs-content blockquote {
  margin: 0.75rem 0;
  padding: 0.5rem 1rem;
  border-left: 3px solid var(--color-accent);
  color: var(--color-muted);
  background: var(--color-bg);
  border-radius: 0 4px 4px 0;
}
#specs-content blockquote p { margin-top: 0; }
#specs-content pre {
  margin: 0.75rem 0;
  padding: 0.75rem 1rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  overflow-x: auto;
  white-space: pre;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.5;
}
#specs-content code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  padding: 0.15rem 0.35rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 3px;
}
#specs-content pre code { padding: 0; background: none; border: none; border-radius: 0; font-size: inherit; }
#specs-content table { width: 100%; margin: 0.75rem 0; border-collapse: collapse; font-size: 0.9rem; }
#specs-content th, #specs-content td { padding: 0.4rem 0.75rem; border: 1px solid var(--color-border); text-align: left; }
#specs-content th { font-family: var(--font-ui); font-weight: 600; background: var(--color-bg); }
#specs-content hr { margin: 1.5rem 0; border: none; border-top: 1px solid var(--color-border); }

.specs-toc {
  background: var(--color-bg-panel);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
  font-size: 0.88rem;
}
.specs-toc ol { margin: 0; padding: 0; list-style: none; }
.specs-toc li { padding: 0.15rem 0; }
.specs-toc a { color: var(--color-accent); text-decoration: none; }
.specs-toc a:hover { text-decoration: underline; }

.spec-divider {
  margin: 2rem 0;
  border: none;
  border-top: 2px solid var(--color-border);
}

.spec-section { scroll-margin-top: 3rem; }

.specs-empty {
  color: var(--color-muted);
  font-style: italic;
}

/* ─── Beads / History / WAI panels ─── */
.beads-panel h3,
.history-panel h3,
.wai-panel h3 {
  font-family: var(--font-ui);
  margin-bottom: 0.5rem;
}

.beads-panel p + p,
.beads-panel ul,
.beads-panel .warning,
.history-panel p + p,
.history-list,
.wai-panel p + p,
.wai-group {
  margin-top: 0.75rem;
}

.beads-panel ul {
  padding-left: 1.25rem;
}

.changed-paths {
  padding-left: 2.75rem;
  margin-bottom: 0.5rem;
}

.beads-panel .warning {
  color: var(--color-error);
  font-family: var(--font-ui);
}

/* ─── Beads list/detail view ─── */
.beads-freshness {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  color: var(--color-muted);
  margin-bottom: 0.75rem;
}

.beads-freshness code {
  font-family: var(--font-mono);
  font-size: 0.7rem;
}

.beads-toolbar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.beads-search-wrap {
  position: relative;
  flex: 1;
  min-width: 10rem;
}

.beads-search {
  width: 100%;
  padding: 0.3rem 2rem 0.3rem 0.5rem;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-surface);
  color: var(--color-fg);
}

.beads-search-clear {
  position: absolute;
  top: 50%;
  right: 0.35rem;
  transform: translateY(-50%);
  padding: 0.1rem 0.35rem;
  border: none;
  background: none;
  color: var(--color-muted);
  font-size: 1rem;
  line-height: 1;
}

.beads-search-clear:hover {
  color: var(--color-accent);
}

.beads-filter {
  padding: 0.3rem 0.5rem;
  font-family: var(--font-ui);
  font-size: 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-surface);
  color: var(--color-fg);
}

.beads-empty-state {
  width: 100%;
  min-height: 20rem;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1rem;
}

.beads-empty-filter {
  color: var(--color-muted);
  font-family: var(--font-ui);
  font-size: 0.85rem;
}

.beads-filters-clear {
  margin-left: 0.4rem;
  padding: 0;
  border: 0;
  background: none;
  color: var(--color-accent);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.beads-layout {
  display: flex;
  gap: 1rem;
  min-height: 20rem;
}

.beads-layout-empty {
  display: block;
}

.beads-list {
  flex: 0 0 45%;
  max-height: 70vh;
  overflow-y: auto;
  border-right: 1px solid var(--color-border);
  padding-right: 1rem;
  list-style: none;
}

.beads-list-item {
  width: 100%;
  padding: 0.5rem 0.5rem;
  cursor: pointer;
  border: none;
  border-bottom: 1px solid var(--color-border);
  border-radius: 0;
  background: transparent;
  text-align: left;
}

.beads-list-item:hover {
  background: var(--color-surface);
}

.beads-list-item.selected {
  background: var(--color-surface);
  border-left: 3px solid var(--color-accent);
  padding-left: calc(0.5rem - 3px);
}

.beads-item-title {
  display: block;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 500;
}

.beads-item-meta {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.25rem;
}

.beads-badge {
  font-family: var(--font-ui);
  font-size: 0.65rem;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  background: var(--color-border);
  color: var(--color-fg);
}

.beads-status-open { color: var(--color-accent); }
.beads-status-closed { color: var(--color-muted); }
.beads-status-in_progress { color: #b88a2a; }

.beads-detail-panel {
  flex: 1;
  min-width: 0;
  max-height: 70vh;
  overflow-y: auto;
}

.beads-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.beads-detail h3 {
  font-family: var(--font-ui);
  margin-bottom: 0;
}

.beads-meta {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  margin-bottom: 1rem;
  border-collapse: collapse;
}

.beads-meta th {
  text-align: left;
  padding: 0.2rem 0.75rem 0.2rem 0;
  color: var(--color-muted);
  font-weight: 500;
}

.beads-meta td {
  padding: 0.2rem 0;
}

.beads-description {
  font-size: 0.85rem;
  line-height: 1.5;
  margin-bottom: 1rem;
}

.beads-deps {
  margin-top: 1rem;
}

.beads-deps h4 {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  margin-bottom: 0.35rem;
}

.beads-deps ul {
  padding-left: 1.25rem;
  font-size: 0.8rem;
}

.beads-dep-link {
  background: none;
  border: none;
  color: var(--color-accent);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0;
}

.beads-dep-link:hover {
  text-decoration: underline;
}

.beads-dep-type {
  color: var(--color-muted);
  font-size: 0.7rem;
}

.beads-refs {
  margin-top: 1rem;
}

.beads-refs h4 {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  margin-bottom: 0.35rem;
}

.beads-refs ul {
  padding-left: 1.25rem;
  font-size: 0.8rem;
}

.beads-refs .ref-path {
  color: var(--color-muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
}

.beads-refs .ref-hint {
  color: var(--color-muted);
  font-size: 0.7rem;
}

.beads-detail-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--color-muted);
  font-family: var(--font-ui);
  font-size: 0.85rem;
}

@media (max-width: 600px) {
  .beads-layout {
    flex-direction: column;
  }
  .beads-list {
    flex: none;
    max-height: 40vh;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
    padding-right: 0;
    padding-bottom: 0.75rem;
  }
}

/* Mobile filter toggle — hide panel, show button on narrow viewports */
#beads-filter-toggle {
  display: none;
  padding: 0.3rem 0.6rem;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-surface);
  color: var(--color-fg);
  cursor: pointer;
  white-space: nowrap;
}

.beads-filter-panel {
  display: contents;
}

@media (max-width: 480px) {
  #beads-filter-toggle {
    display: block;
  }

  .beads-filter-panel {
    display: none;
    flex-basis: 100%;
    flex-direction: column;
    gap: 0.5rem;
  }

  .beads-filter-panel.is-open {
    display: flex;
  }
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.history-item {
  padding: 0.1rem 0;
  border-bottom: 1px solid var(--color-border);
}

.history-item:last-child {
  border-bottom: none;
}

.history-summary {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.4rem 0;
  list-style: none;
}

.history-summary::-webkit-details-marker {
  display: none;
}

details > .history-summary {
  cursor: pointer;
}

details > .history-summary:hover .history-title {
  color: var(--color-accent);
}

a.history-sha,
span.history-sha {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--color-muted);
  flex-shrink: 0;
  text-decoration: none;
}

a.history-sha:hover {
  color: var(--color-accent);
  text-decoration: underline;
}

.history-title {
  font-family: var(--font-ui);
  font-size: 0.9rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-body {
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--color-muted);
  white-space: pre-wrap;
  margin: 0.25rem 0 0.5rem 2.75rem;
  padding: 0;
  background: none;
  border: none;
  line-height: 1.5;
}

.history-meta {
  font-size: 0.75rem;
  color: var(--color-muted);
  font-family: var(--font-ui);
  margin: 0.15rem 0 0.25rem 2.75rem;
  display: flex;
  gap: 0.5rem;
}

.history-scope {
  color: var(--color-muted);
  font-size: 0.9rem;
}

.wai-scope,
.wai-artifact-path {
  color: var(--color-muted);
  font-size: 0.9rem;
}

.wai-group {
  margin-top: 0.25rem;
}

.wai-group .wai-group {
  padding-left: 0.75rem;
}

.wai-summary {
  font-family: var(--font-ui);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0;
  list-style: none;
}

.wai-summary::-webkit-details-marker {
  display: none;
}

.wai-summary::before {
  content: "▶";
  font-size: 0.6rem;
  color: var(--color-muted);
  transition: transform 0.15s;
}

details[open] > .wai-summary::before {
  transform: rotate(90deg);
}

.wai-summary-h3 {
  font-size: 1.1rem;
  font-weight: 600;
  padding: 0.4rem 0;
}

.wai-summary-h4 {
  font-size: 0.95rem;
  font-weight: 500;
}

.wai-summary-h5 {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.wai-count {
  font-size: 0.7rem;
  color: var(--color-muted);
  font-weight: 400;
}

.wai-artifact-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.wai-artifact-link {
  width: 100%;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.wai-artifact-name {
  font-family: var(--font-ui);
  font-weight: 500;
}

.wai-artifact-path {
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

/* ─── Language Explorer ─── */
.wai-language-entry {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
  background: var(--color-accent, var(--color-surface));
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-family: var(--font-ui);
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-fg);
  cursor: pointer;
  text-align: left;
}

.wai-language-entry::before {
  content: "⬡";
  font-size: 1.1rem;
}

.wai-language-entry:hover {
  background: var(--color-hover, var(--color-surface));
  border-color: var(--color-accent-border, var(--color-border));
}

.language-overview {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.language-context-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.language-context-item {
  width: 100%;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface);
  cursor: pointer;
  font-family: var(--font-ui);
}

.language-context-item:hover {
  background: var(--color-hover, var(--color-surface));
}

.language-context-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.language-context-purpose {
  font-size: 0.85rem;
  color: var(--color-muted);
}

.glossary {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.25rem 1.5rem;
  font-family: var(--font-body);
}

.glossary dt {
  font-weight: 600;
  padding-top: 0.5rem;
  color: var(--color-fg);
}

.glossary dd {
  margin: 0;
  padding-top: 0.5rem;
  color: var(--color-muted);
}

.language-not-found,
.language-error {
  padding: 0.5rem 0.75rem;
  border-left: 3px solid var(--color-warning, var(--color-border));
  color: var(--color-muted);
  margin-bottom: 1rem;
}

/* ─── Tree / file browser screen ─── */
#tree-nav {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  margin-bottom: 0.75rem;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}

#tree-breadcrumb {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--color-muted);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#tree-nav button {
  flex-shrink: 0;
  font-size: 0.8rem;
  padding: 0.3rem 0.6rem;
}

#tree-search-container {
  margin-bottom: 0.75rem;
}

#tree-search {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface);
  color: var(--color-fg);
}

#tree-search:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: -1px;
}

#tree-content {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 0.5rem 0;
}

.tree-list {
  list-style: none;
}

.tree-item {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.75rem;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  transition: background 0.1s;
  text-align: left;
}

.tree-item:hover {
  background: color-mix(in srgb, var(--color-accent) 5%, var(--color-surface));
}

.tree-item[data-type="tree"] {
  font-family: var(--font-ui);
  font-weight: 500;
}

.tree-icon {
  flex-shrink: 0;
  width: 1em;
  color: var(--color-muted);
  font-size: 0.75rem;
}

.tree-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-children {
  list-style: none;
  padding-left: 1.25rem;
}

.tree-children[hidden] {
  display: none;
}

.tree-search-results {
  list-style: none;
}

.tree-search-item {
  display: flex;
  width: 100%;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.4rem 0.75rem;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: background 0.1s;
  text-align: left;
}

.tree-search-item:hover {
  background: color-mix(in srgb, var(--color-accent) 5%, var(--color-surface));
}

.tree-search-item .tree-search-name {
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: 0.85rem;
}

.tree-search-item .tree-search-path {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--color-muted);
}

.tree-empty {
  padding: 1rem 0.75rem;
  color: var(--color-muted);
  font-size: 0.85rem;
  text-align: center;
}

/* ─── Error screen ─── */
#error-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding-top: 20vh;
}

#error-screen .error {
  font-size: 1rem;
}

.error-hint {
  font-size: 0.875rem;
  color: var(--text-muted, #888);
  margin-top: 0.25rem;
}
