:root {
  --bg: #f7f6f3; --surface: #ffffff; --text: #1d1e21; --muted: #6b6e76; --line: #e3e1dc;
  --accent: #2f5fb3; --accent-soft: #e6edf9; --code-bg: #f0eee9; --mark: #ffe58a;
  --radius: 10px; --gutter: 16px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Hebrew", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17181b; --surface: #1f2024; --text: #e6e6e3; --muted: #9a9ca3; --line: #34363c;
    --accent: #8db1f0; --accent-soft: #24304a; --code-bg: #26282d; --mark: #6b5a12;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.6 var(--font); }
a { color: var(--accent); }
time, .fname, .meta, .n, .path, .count { color: var(--muted); font-size: .8rem; }

/* top bar */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px var(--gutter); padding-top: max(10px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; color: var(--text); text-decoration: none; }
.crumbs { font-size: .9rem; color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1 1 auto; }
.crumbs a { color: var(--muted); }
.search { margin-left: auto; flex: 0 1 260px; min-width: 140px; }
.search input { width: 100%; font: inherit; font-size: 16px; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); }

main { max-width: 46rem; margin: 0 auto; padding: 16px var(--gutter) 64px; }
body.wide main { max-width: 72rem; }

/* home tree */
.tools { display: flex; gap: 8px; justify-content: flex-end; margin-bottom: 8px; }
.tools button { font: inherit; font-size: .8rem; color: var(--muted); background: none; border: 1px solid var(--line);
  border-radius: 999px; padding: 3px 10px; cursor: pointer; }
details.project { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin: 10px 0; }
details > summary { list-style: none; cursor: pointer; display: flex; align-items: baseline; gap: 10px; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "›"; display: inline-block; width: 1ch; color: var(--muted); transition: transform .15s; }
details[open] > summary::before { transform: rotate(90deg); }
details.project > summary { padding: 12px 14px; font-weight: 600; }
details.project > summary .meta { margin-left: auto; font-weight: 400; white-space: nowrap; }
details.project > :not(summary) { margin-left: 14px; margin-right: 14px; }
details.project[open] { padding-bottom: 8px; }
details.folder > summary { padding: 6px 0; font-weight: 500; color: var(--muted); border-top: 1px solid var(--line); }
details.folder > summary .t { color: var(--text); }
details.folder > ul { padding-left: 18px; }
ul.docs { list-style: none; margin: 0; padding: 0; }
ul.docs a { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; padding: 7px 0; text-decoration: none; color: var(--text); }
ul.docs a:hover .t { color: var(--accent); text-decoration: underline; }
ul.docs .t { flex: 0 1 auto; min-width: 0; overflow-wrap: anywhere; }
ul.docs time { margin-left: auto; white-space: nowrap; }
ul.docs a.last .t { background: var(--accent-soft); border-radius: 4px; }
.empty { color: var(--muted); }

/* doc pages */
.docmeta { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: baseline; margin-bottom: 8px; font-size: .8rem; color: var(--muted); }
.docmeta a { font-size: .8rem; }
.md { overflow-wrap: break-word; }
.md h1, .md h2, .md h3, .md h4 { line-height: 1.25; margin: 1.6em 0 .5em; }
.md h1 { font-size: 1.8rem; margin-top: .4em; }
.md h2 { font-size: 1.4rem; padding-bottom: .2em; border-bottom: 1px solid var(--line); }
.md h3 { font-size: 1.15rem; }
.md img { max-width: 100%; height: auto; border-radius: 6px; }
.md blockquote { margin: 1em 0; padding: .2em 1em; border-inline-start: 4px solid var(--line); color: var(--muted); }
.md hr { border: none; border-top: 1px solid var(--line); margin: 2em 0; }
.md li { margin: .2em 0; }
code, pre { font-family: var(--mono); font-size: .88em; }
:not(pre) > code { background: var(--code-bg); padding: .1em .35em; border-radius: 4px; }
pre { background: var(--code-bg); padding: 12px 14px; border-radius: 8px; overflow-x: auto; line-height: 1.45; direction: ltr; text-align: left; }
pre.txt { white-space: pre-wrap; overflow-wrap: anywhere; direction: inherit; text-align: start; }
.table-wrap { overflow-x: auto; margin: 1em 0; }
table { border-collapse: collapse; font-size: .92rem; min-width: 50%; }
th, td { border: 1px solid var(--line); padding: 6px 10px; vertical-align: top; text-align: start; }
th { background: var(--code-bg); font-weight: 600; }
tr:nth-child(even) td { background: color-mix(in srgb, var(--code-bg) 45%, transparent); }
[dir="auto"] { unicode-bidi: plaintext; }
li[dir="auto"] { text-align: start; }
figure.image { margin: 0; text-align: center; }
figure.image img { max-width: 100%; height: auto; background: #fff; border-radius: 6px; }
iframe.pdf, iframe.htmldoc { width: 100%; height: calc(100dvh - 140px); min-height: 420px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.stl { position: relative; width: 100%; height: calc(100dvh - 170px); min-height: 320px; border: 1px solid var(--line);
  border-radius: 8px; overflow: hidden; background: var(--surface); touch-action: none; }
.stl canvas { display: block; width: 100%; height: 100%; }
.stl .loading { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; color: var(--muted); }
.hint { color: var(--muted); font-size: .8rem; text-align: center; }

/* search */
.results ul { list-style: none; padding: 0; }
.results li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.results li > a { display: flex; flex-direction: column; text-decoration: none; }
.results .t { font-weight: 600; }
.results .snip { margin: 4px 0 0; font-size: .9rem; color: var(--muted); }
mark { background: var(--mark); color: inherit; border-radius: 2px; }

/* login */
.login-page main.login { max-width: 22rem; padding-top: 18vh; text-align: center; }
.login h1 { margin: 8px 0 20px; font-size: 1.5rem; }
.login form { display: flex; flex-direction: column; gap: 10px; text-align: start; }
.login label { font-size: .9rem; color: var(--muted); }
.login input[type=password] { font: inherit; font-size: 16px; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.login button { font: inherit; font-weight: 600; padding: 10px; border: none; border-radius: 8px; background: var(--accent); color: var(--bg); cursor: pointer; }
.error { color: #c0392b; margin: 0; font-size: .9rem; }

@media (max-width: 560px) {
  .crumbs { order: 3; flex-basis: 100%; }
  .search { flex: 1 1 140px; }
  .md h1 { font-size: 1.5rem; }
}

/* print: just the doc */
@media print {
  :root { --bg: #fff; --surface: #fff; --text: #000; --muted: #444; --line: #bbb; --code-bg: #f3f3f3; --accent: #000; }
  @page { margin: 16mm 14mm; }
  body { font-size: 11pt; background: #fff; }
  .top, .docmeta, .hint, .tools { display: none !important; }
  main { max-width: none; padding: 0; margin: 0; }
  .md h1 { margin-top: 0; }
  h1, h2, h3, h4 { break-after: avoid; }
  pre, table, figure, img, blockquote, tr { break-inside: avoid; }
  pre { white-space: pre-wrap; overflow-wrap: anywhere; }
  .table-wrap { overflow: visible; }
  .md a[href^="http"]::after { content: " (" attr(href) ")"; font-size: .85em; color: #444; overflow-wrap: anywhere; }
  a { color: #000; }
  iframe.pdf, iframe.htmldoc { height: auto; border: none; }
}
