/* Property Ontology explorer — palette borrowed from the board report
   (navy / teal / seafoam / cream) with a dark variant. */

:root {
  --navy: #1a2332;
  --teal: #2d8b8b;
  --teal-dk: #1f6b6b;
  --seafoam: #a8dadc;
  --cream: #f1faee;

  --bg: #fbfdfb;
  --bg-alt: #f1f6f3;
  --panel: #ffffff;
  --border: #d9e4e0;
  --ink: #1a2332;
  --muted: #5a6b7c;
  --accent: var(--teal-dk);
  --accent-soft: #e2f1f1;
  --link: #1f6b6b;
  --code-bg: #f4f7f6;
  --shadow: 0 1px 2px rgba(26, 35, 50, .06), 0 8px 24px -16px rgba(26, 35, 50, .25);

  --sidebar-w: 300px;
  --aside-w: 240px;
  --topbar-h: 52px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", "Fira Code", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1520;
    --bg-alt: #141c29;
    --panel: #18212f;
    --border: #273241;
    --ink: #e6edf3;
    --muted: #97a6b8;
    --accent: #5fc4c4;
    --accent-soft: #163336;
    --link: #7fd1d1;
    --code-bg: #0d1117;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -16px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1520;
  --bg-alt: #141c29;
  --panel: #18212f;
  --border: #273241;
  --ink: #e6edf3;
  --muted: #97a6b8;
  --accent: #5fc4c4;
  --accent-soft: #163336;
  --link: #7fd1d1;
  --code-bg: #0d1117;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -16px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--topbar-h) + 12px); }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, kbd, .mono { font-family: var(--mono); }
code { font-size: .9em; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 18px;
  padding: 0 18px;
  background: var(--navy); color: var(--cream);
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--cream); font-weight: 600; letter-spacing: .01em; }
.brand:hover { text-decoration: none; }
.brand-mark { font-family: var(--mono); font-size: 12px; background: var(--teal); color: #fff; padding: 3px 7px; border-radius: 5px; letter-spacing: .08em; }
.topnav { display: flex; gap: 4px; margin-left: 8px; }
.nav-link { color: var(--seafoam); padding: 6px 10px; border-radius: 6px; font-size: 14px; }
.nav-link:hover { background: rgba(255,255,255,.08); text-decoration: none; color: #fff; }
.nav-link.active { background: rgba(255,255,255,.12); color: #fff; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; }
.icon-btn {
  background: rgba(255,255,255,.08); color: var(--cream); border: 1px solid rgba(255,255,255,.12);
  border-radius: 6px; padding: 5px 10px; font: inherit; font-size: 13px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.icon-btn:hover { background: rgba(255,255,255,.16); }
.kbd { font-family: var(--mono); font-size: 11px; border: 1px solid rgba(255,255,255,.3); border-radius: 4px; padding: 0 5px; }

/* ---------- shell layout ---------- */
.shell { display: grid; grid-template-columns: 1fr; flex: 1; min-height: 0; }
.shell.has-sidebar { grid-template-columns: var(--sidebar-w) 1fr; }
.shell.has-sidebar.has-aside { grid-template-columns: var(--sidebar-w) 1fr var(--aside-w); }
.main { min-width: 0; padding: 22px 32px 60px; }
.page-home .main { max-width: 1120px; margin: 0 auto; width: 100%; }

.sidebar {
  border-right: 1px solid var(--border); background: var(--bg-alt);
  position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); overflow: auto;
  font-size: 13.5px;
}
.aside {
  border-left: 1px solid var(--border);
  position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); overflow: auto;
  padding: 18px 14px; font-size: 13px;
}

.footer { border-top: 1px solid var(--border); color: var(--muted); font-size: 12.5px; padding: 14px 24px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* ---------- sidebar tree ---------- */
.sidebar-head { position: sticky; top: 0; background: var(--bg-alt); padding: 12px 12px 8px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; z-index: 1; }
#tree-filter { flex: 1; font: inherit; font-size: 13px; padding: 6px 9px; border: 1px solid var(--border); border-radius: 6px; background: var(--panel); color: var(--ink); }
.tree-total { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree { padding: 8px 6px 20px; }
.tree ul { padding-left: 14px; border-left: 1px dashed var(--border); margin-left: 9px; }
.tree summary { list-style: none; display: flex; align-items: center; gap: 4px; cursor: pointer; padding: 2px 4px; border-radius: 4px; }
.tree summary::-webkit-details-marker { display: none; }
.tree summary:hover { background: var(--accent-soft); }
.tree-caret { width: 10px; height: 10px; display: inline-block; position: relative; flex: none; }
.tree-caret::before { content: ""; position: absolute; left: 3px; top: 2px; border: solid var(--muted); border-width: 0 1.5px 1.5px 0; padding: 2.5px; transform: rotate(-45deg); transition: transform .12s; }
details[open] > summary .tree-caret::before { transform: rotate(45deg); top: 0; }
.tree-link { color: var(--ink); display: inline-flex; align-items: center; gap: 6px; min-width: 0; padding: 2px 4px; border-radius: 4px; flex: 1; }
.tree-link:hover { text-decoration: none; background: var(--accent-soft); }
.tree-link.dir { font-weight: 600; }
.tree-link.current { background: var(--accent); color: #fff; }
.tree-link.current .fi { background: rgba(255,255,255,.2); color: #fff; }
.tree-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-count { margin-left: auto; color: var(--muted); font-size: 11px; padding-right: 4px; }
.tree-file { padding: 0; }
.tree li.filtered-out { display: none; }

/* file-type badges */
.fi {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 16px; padding: 0 4px; border-radius: 4px;
  font: 600 9.5px/1 var(--mono); letter-spacing: .02em; color: #fff; background: #8a97a5; flex: none;
}
.fi-md, .fi-markdown { background: #3b6fb6; }
.fi-py { background: #3572a5; }
.fi-js, .fi-mjs { background: #b8a11a; }
.fi-json, .fi-jsonl { background: #7a5ea7; }
.fi-yaml, .fi-yml { background: #c2542d; }
.fi-ttl { background: #1f6b6b; }
.fi-rq { background: #2d8b8b; }
.fi-sh { background: #4a5a3b; }
.fi-html { background: #d85a30; }
.fi-svg { background: #e0a020; }
.fi-txt { background: #6c7a89; }
.fi-docx { background: #2b5797; }
.fi-zip { background: #555; }
.fi-dir { background: transparent; color: var(--accent); font-size: 14px; }

/* ---------- file header ---------- */
.file-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid var(--border); }
.crumbs { font-size: 15px; display: flex; flex-wrap: wrap; align-items: center; gap: 2px; font-family: var(--mono); }
.crumbs a { color: var(--link); }
.crumb-sep { color: var(--muted); padding: 0 4px; }
.crumb-current { font-weight: 600; color: var(--ink); }
.file-meta { display: flex; gap: 6px; color: var(--muted); font-size: 12.5px; flex-wrap: wrap; }
.file-meta span { background: var(--bg-alt); border: 1px solid var(--border); padding: 1px 8px; border-radius: 999px; }
.file-actions { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.btn {
  font: inherit; font-size: 13px; color: var(--ink); background: var(--panel); border: 1px solid var(--border);
  border-radius: 6px; padding: 5px 11px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { background: var(--accent-soft); text-decoration: none; border-color: var(--accent); }
.btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.is-on { box-shadow: inset 0 0 0 1px var(--accent); }

/* ---------- directory listing ---------- */
.listing-wrap { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--panel); box-shadow: var(--shadow); }
.listing { width: 100%; border-collapse: collapse; font-size: 14px; }
.listing td { padding: 8px 12px; border-top: 1px solid var(--border); vertical-align: middle; }
.listing tr:first-child td { border-top: 0; }
.listing tr:hover td { background: var(--bg-alt); }
.col-icon { width: 44px; text-align: center; }
.col-name a { color: var(--ink); font-weight: 500; }
.col-name a:hover { color: var(--link); }
.col-meta { color: var(--muted); width: 120px; font-size: 12.5px; }
.col-size { color: var(--muted); width: 90px; text-align: right; font-family: var(--mono); font-size: 12px; }
.row-parent td { color: var(--muted); }

/* ---------- code view ---------- */
.code-view { border: 1px solid var(--border); border-radius: 8px; overflow: auto; background: var(--code-bg); box-shadow: var(--shadow); }
.code-view.hljs { padding: 0; }
.code-table { border-collapse: collapse; font-family: var(--mono); font-size: 12.75px; line-height: 1.6; width: 100%; tab-size: 4; }
.code-table td { padding: 0 14px 0 0; vertical-align: top; white-space: pre; }
.code-table td.ln { user-select: none; text-align: right; color: var(--muted); padding: 0 12px 0 14px; width: 1%; min-width: 3.5em; border-right: 1px solid var(--border); position: sticky; left: 0; background: var(--code-bg); }
.code-table td.ln a { color: inherit; opacity: .6; }
.code-table td.ln a:hover { opacity: 1; text-decoration: none; }
.code-table td.lc { padding-left: 14px; }
.code-table tr:target td, .code-table tr.hl td { background: rgba(45, 139, 139, .14); }
.code-table tr:target td.ln { background: rgba(45, 139, 139, .28); }
.code-view.wrap .code-table td.lc { white-space: pre-wrap; word-break: break-word; }

/* ---------- markdown body ---------- */
.markdown-body { max-width: 900px; font-size: 15.5px; line-height: 1.65; }
.page-file .markdown-body { max-width: none; }
.markdown-body > :first-child { margin-top: 0; }
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 { line-height: 1.25; margin: 1.8em 0 .6em; scroll-margin-top: calc(var(--topbar-h) + 14px); position: relative; }
.markdown-body h1 { font-size: 2em; border-bottom: 1px solid var(--border); padding-bottom: .3em; }
.markdown-body h2 { font-size: 1.5em; border-bottom: 1px solid var(--border); padding-bottom: .3em; }
.markdown-body h3 { font-size: 1.2em; }
.markdown-body h1:hover .anchor, .markdown-body h2:hover .anchor, .markdown-body h3:hover .anchor, .markdown-body h4:hover .anchor { opacity: 1; }
.markdown-body .anchor { position: absolute; left: -1.1em; opacity: 0; color: var(--muted); font-weight: 400; }
.markdown-body p, .markdown-body ul, .markdown-body ol { margin: 0 0 1em; }
.markdown-body li + li { margin-top: .25em; }
.markdown-body blockquote { margin: 1em 0; padding: .4em 1em; border-left: 4px solid var(--seafoam); color: var(--muted); background: var(--bg-alt); border-radius: 0 6px 6px 0; }
.markdown-body hr { border: 0; border-top: 1px solid var(--border); margin: 2em 0; }
.markdown-body img { max-width: 100%; border-radius: 6px; }
.markdown-body code { background: var(--code-bg); border: 1px solid var(--border); border-radius: 4px; padding: .1em .35em; font-size: .86em; }
.markdown-body pre { background: var(--code-bg); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; overflow: auto; font-size: 12.75px; line-height: 1.6; margin: 0 0 1.1em; }
.markdown-body pre code { background: none; border: 0; padding: 0; font-size: inherit; }
.md-code { position: relative; }
.copy-btn { position: absolute; top: 8px; right: 8px; font: 11.5px var(--font); background: var(--panel); color: var(--muted); border: 1px solid var(--border); border-radius: 5px; padding: 2px 8px; cursor: pointer; opacity: 0; transition: opacity .12s; }
.md-code:hover .copy-btn, .copy-btn:focus { opacity: 1; }
.copy-btn.done { color: var(--accent); border-color: var(--accent); }
.table-wrap { overflow-x: auto; margin: 0 0 1.2em; border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); }
.markdown-body table { border-collapse: collapse; font-size: 13.5px; width: 100%; min-width: 480px; }
.markdown-body th, .markdown-body td { border-bottom: 1px solid var(--border); padding: 7px 12px; text-align: left; vertical-align: top; }
.markdown-body th { background: var(--bg-alt); font-weight: 600; position: sticky; top: 0; }
.markdown-body tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--bg-alt) 50%, transparent); }
.markdown-body tbody tr:last-child td { border-bottom: 0; }
.markdown-body a.broken-link { color: #b04a3a; text-decoration: line-through dotted; }
.markdown-body .task-list-item { list-style: none; margin-left: -1.4em; }
.front-matter { margin: 0 0 1.5em; }
.front-matter summary, .mermaid-src summary { cursor: pointer; color: var(--muted); font-size: 12.5px; }
.front-matter pre { margin-top: .5em; }

/* mermaid */
.mermaid-block { margin: 1.2em 0; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); padding: 10px 12px 6px; overflow: auto; box-shadow: var(--shadow); }
.mermaid-block pre.mermaid { background: transparent; border: 0; padding: 0; margin: 0; min-height: 40px; color: var(--muted); font-size: 12px; overflow: visible; }
.mermaid-block pre.mermaid:not([data-processed]) { white-space: pre-wrap; opacity: .55; }
.mermaid-block pre.mermaid svg { max-width: 100%; height: auto; }
.mermaid-block .mermaid-src { margin-top: 6px; }
.mermaid-block .mermaid-src pre { margin: 6px 0 0; }
.mermaid-error { color: #b04a3a; font-size: 12.5px; padding: 6px 0; }

/* readme section on directory pages */
.readme { margin-top: 28px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); box-shadow: var(--shadow); }
.readme-head { padding: 10px 18px; border-bottom: 1px solid var(--border); font-family: var(--mono); font-size: 13px; color: var(--muted); background: var(--bg-alt); border-radius: 8px 8px 0 0; }
.readme .markdown-body { padding: 18px 28px 28px; }

/* toc */
.toc-title { text-transform: uppercase; letter-spacing: .1em; font-size: 11px; color: var(--muted); margin-bottom: 8px; }
.toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--border); }
.toc li a { display: block; padding: 3px 10px; color: var(--muted); border-left: 2px solid transparent; margin-left: -1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toc li a:hover { color: var(--ink); text-decoration: none; }
.toc li.active a { color: var(--accent); border-left-color: var(--accent); }
.toc-l1 a { font-weight: 600; }
.toc-l3 a { padding-left: 22px; font-size: 12.5px; }

/* jsonl */
.file-body { min-width: 0; }
.jsonl-view { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.jsonl-rec { border: 1px solid var(--border); border-radius: 8px; background: var(--panel); min-width: 0; overflow: hidden; }
.jsonl-rec summary { cursor: pointer; padding: 8px 12px; font-family: var(--mono); font-size: 13px; display: flex; gap: 10px; align-items: center; }
.jsonl-rec summary::-webkit-details-marker { display: none; }
.jsonl-rec summary::before { content: "▸"; color: var(--muted); }
.jsonl-rec[open] summary::before { content: "▾"; }
.rec-n { color: var(--muted); }
.rec-id { color: var(--accent); font-weight: 600; }
.jsonl-rec pre { margin: 0; padding: 10px 14px; border-top: 1px solid var(--border); font-size: 12.5px; line-height: 1.55; overflow: auto; background: var(--code-bg); border-radius: 0 0 8px 8px; }
.badge { font-size: 10.5px; padding: 1px 6px; border-radius: 999px; background: var(--bg-alt); border: 1px solid var(--border); }
.badge.warn { color: #b04a3a; }

/* html preview / images / binary */
.html-preview { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--panel); box-shadow: var(--shadow); }
.html-preview-bar { padding: 6px 12px; font-size: 12.5px; color: var(--muted); border-bottom: 1px solid var(--border); background: var(--bg-alt); }
.html-preview iframe { width: 100%; height: calc(100vh - 220px); border: 0; background: #fff; }
.image-view { display: flex; justify-content: center; padding: 24px; border: 1px solid var(--border); border-radius: 8px; background: repeating-conic-gradient(var(--bg-alt) 0 25%, transparent 0 50%) 0 0 / 20px 20px; }
.image-view img { max-width: 100%; max-height: 80vh; }
.binary-card { text-align: center; padding: 60px 20px; border: 1px dashed var(--border); border-radius: 12px; color: var(--muted); }
.binary-card h2 { color: var(--ink); font-family: var(--mono); font-size: 18px; }
.binary-icon { font: 700 14px var(--mono); display: inline-block; background: var(--accent); color: #fff; padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; }

/* ---------- home ---------- */
.hero { padding: 28px 0 8px; }
.kicker { margin: 0 0 8px; font-size: 12.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); font-weight: 700; }
.hero h1 { font-size: clamp(28px, 3.6vw, 44px); line-height: 1.1; margin: 0 0 14px; letter-spacing: -.01em; }
.lead { font-size: 17px; color: var(--muted); max-width: 820px; margin: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin: 28px 0 10px; }
.card { display: flex; flex-direction: column; gap: 8px; padding: 22px 22px 18px; border-radius: 12px; border: 1px solid var(--border); background: var(--panel); color: var(--ink); box-shadow: var(--shadow); transition: transform .12s, border-color .12s; }
.card:hover { text-decoration: none; transform: translateY(-2px); border-color: var(--accent); }
.card h2 { margin: 0; font-size: 20px; }
.card p { margin: 0; color: var(--muted); font-size: 14px; flex: 1; }
.card-kicker { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); font-weight: 700; }
.card-foot { font-size: 12px; color: var(--muted); font-family: var(--mono); padding-top: 8px; border-top: 1px solid var(--border); }
.card-report { border-top: 4px solid var(--navy); }
.card-atlas { border-top: 4px solid var(--teal); }
.card-files { border-top: 4px solid var(--seafoam); }
.section { margin: 30px 0 0; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); margin: 0 0 12px; font-weight: 600; }
.dir-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.dir-card { display: block; padding: 12px 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); color: var(--ink); }
.dir-card:hover { text-decoration: none; border-color: var(--accent); background: var(--accent-soft); }
.dir-card-name { font-family: var(--mono); font-weight: 600; font-size: 14px; }
.dir-card-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: 1px solid var(--border); border-radius: 999px; font-size: 13px; background: var(--panel); color: var(--ink); font-family: var(--mono); }
.chip b { color: var(--accent); }
a.chip:hover { text-decoration: none; border-color: var(--accent); }

/* ---------- search dialog ---------- */
.search-dialog { border: 1px solid var(--border); border-radius: 12px; padding: 0; width: min(680px, 92vw); background: var(--panel); color: var(--ink); box-shadow: 0 30px 80px -20px rgba(0,0,0,.5); margin-top: 10vh; }
.search-dialog::backdrop { background: rgba(10, 16, 26, .55); backdrop-filter: blur(2px); }
.search-form { display: flex; gap: 8px; padding: 12px; border-bottom: 1px solid var(--border); }
#search-input { flex: 1; font: inherit; font-size: 16px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--ink); }
.search-form .icon-btn { background: var(--bg-alt); color: var(--muted); border-color: var(--border); }
.search-results { list-style: none; margin: 0; padding: 6px; max-height: 50vh; overflow: auto; }
.search-results li a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; color: var(--ink); font-family: var(--mono); font-size: 13px; }
.search-results li a:hover, .search-results li.active a { background: var(--accent-soft); text-decoration: none; }
.search-results .sr-dir { color: var(--muted); }
.search-results .sr-size { margin-left: auto; color: var(--muted); font-size: 11.5px; }
.search-results mark { background: transparent; color: var(--accent); font-weight: 700; }
.search-empty { color: var(--muted); padding: 14px; text-align: center; font-size: 13.5px; }

.empty { text-align: center; padding: 80px 20px; color: var(--muted); }
.empty h1 { color: var(--ink); }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .shell.has-sidebar.has-aside { grid-template-columns: var(--sidebar-w) 1fr; }
  .aside { display: none; }
}
@media (max-width: 820px) {
  .shell.has-sidebar, .shell.has-sidebar.has-aside { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; max-height: 40vh; border-right: 0; border-bottom: 1px solid var(--border); }
  .main { padding: 16px; }
  .topnav { display: none; }
  .file-actions { margin-left: 0; }
}
