:root {
  --bg: #fbfbfa; --surface: #ffffff; --text: #1d1d1f; --muted: #6b6b70; --line: #e6e5e2;
  --accent: #3554d1; --accent-soft: #eef1fc; --code-bg: #f3f2ef;
  --s-idea: #6b7a99; --s-research: #7a4fc4; --s-in_progress: #c27a00; --s-parked: #9a9a9a; --s-done: #2f8a4f; --s-contra: #c0392b;
  --radius: 10px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141416; --surface: #1c1c1f; --text: #e8e8ea; --muted: #9a9aa2; --line: #2c2c31;
    --accent: #8ea2ff; --accent-soft: #23283d; --code-bg: #232327;
    --s-idea: #8f9dbb; --s-research: #b08cf0; --s-in_progress: #e3a63a; --s-parked: #7c7c82; --s-done: #5cbf7e; --s-contra: #ef6b5b;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }

.top { border-bottom: 1px solid var(--line); background: var(--surface); }
.top-in { max-width: 720px; margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; gap: 16px; }
.top-in.wide { max-width: 1040px; }
.brand { font-weight: 650; color: var(--text); }
.top nav { margin-left: auto; display: flex; gap: 16px; }
.top nav a { color: var(--muted); }
.top nav a[aria-current] { color: var(--text); }

.wrap { max-width: 720px; margin: 0 auto; padding: 32px 16px 64px; }
.head-row { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
h1 { font-size: 1.75rem; line-height: 1.25; margin: 0 0 8px; font-weight: 650; letter-spacing: -0.01em; }
h1 .total { color: var(--muted); font-weight: 400; font-size: 1.1rem; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0 28px; }
.chip { font: inherit; font-size: 0.875rem; color: var(--muted); background: transparent; border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.chip .n { opacity: 0.7; }
.chip[aria-pressed="true"] { color: var(--text); background: var(--surface); border-color: var(--muted); }
.chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--c, var(--muted)); }

.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.card-link { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; color: inherit; }
.card-link:hover { text-decoration: none; border-color: var(--muted); }
.card-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.card h2 { font-size: 1.15rem; line-height: 1.35; margin: 10px 0 6px; font-weight: 620; }
.card-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 0.85rem; color: var(--muted); }
.one { margin: 0 0 8px; }
.next { margin: 0 0 8px; color: var(--muted); font-size: 0.95rem; }
.next .lbl { color: var(--text); font-weight: 550; }
.card-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 10px; font-size: 0.82rem; color: var(--muted); }
.tags { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.tag { background: var(--code-bg); border-radius: 6px; padding: 1px 8px; color: var(--muted); font-size: 0.8rem; }
.warn { color: var(--s-in_progress); font-size: 0.8rem; }
.empty { color: var(--muted); text-align: center; padding: 32px 0; }

.badge { --c: var(--muted); display: inline-block; font-size: 0.78rem; font-weight: 550; padding: 1px 9px; border-radius: 999px; color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); }
.s-idea { --c: var(--s-idea); } .s-research { --c: var(--s-research); } .s-in_progress { --c: var(--s-in_progress); }
.s-parked { --c: var(--s-parked); } .s-done { --c: var(--s-done); }

/* страницы идей */
.page { max-width: 720px; margin: 0 auto; padding: 28px 16px 72px; }
.page.has-toc { max-width: 1040px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; }
@media (min-width: 960px) {
  .page.has-toc { grid-template-columns: 240px minmax(0, 720px); gap: 48px; }
  .side { position: sticky; top: 16px; align-self: start; max-height: calc(100vh - 32px); overflow-y: auto; }
  .toc summary { pointer-events: none; }
  .toc summary::marker, .toc summary::-webkit-details-marker { content: ""; display: none; }
}
.doc { min-width: 0; }
.toc { font-size: 0.9rem; }
.toc summary { cursor: pointer; color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; padding: 4px 0; }
.toc summary .n { opacity: 0.7; }
.toc ul { list-style: none; margin: 4px 0 8px; padding: 0; }
.toc li a { display: block; padding: 4px 8px; border-radius: 6px; color: var(--muted); line-height: 1.35; }
.toc li a:hover { color: var(--text); background: var(--code-bg); text-decoration: none; }
.toc li a[aria-current] { color: var(--accent); background: var(--accent-soft); }
.toc-dir { margin: 12px 0 0; padding: 0 8px; font-size: 0.78rem; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }

.card-head { padding-bottom: 20px; margin-bottom: 28px; border-bottom: 1px solid var(--line); }
.card-head h1 { margin-top: 12px; }
.card-head .one { font-size: 1.1rem; }
.rel { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 4px; font-size: 0.95rem; }
.rel li { display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 8px; align-items: baseline; }
.rtype { color: var(--muted); font-size: 0.85rem; }
.broken { color: var(--s-contra); text-decoration: line-through; }
.notice { font-size: 0.85rem; color: var(--muted); border-left: 3px solid var(--s-in_progress); padding: 2px 10px; }
.btn { display: inline-block; background: var(--accent); color: #fff; padding: 10px 18px; border-radius: 8px; font-weight: 600; margin-top: 8px; }
@media (prefers-color-scheme: dark) { .btn { color: #10131f; } }
.btn:hover { text-decoration: none; filter: brightness(1.08); }
.crumbs { font-size: 0.85rem; color: var(--muted); margin-bottom: 20px; display: flex; flex-wrap: wrap; gap: 6px; }
.crumbs .path { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.wip > summary { cursor: pointer; color: var(--muted); padding: 10px 14px; border: 1px dashed var(--line); border-radius: var(--radius); }
.wip[open] > summary { margin-bottom: 20px; }

/* markdown */
.md { overflow-wrap: break-word; }
.md h1, .md h2, .md h3, .md h4 { line-height: 1.3; margin: 1.8em 0 0.6em; font-weight: 630; }
.md h1 { font-size: 1.6rem; } .md h2 { font-size: 1.3rem; } .md h3 { font-size: 1.1rem; } .md h4 { font-size: 1rem; }
.md > :first-child { margin-top: 0; }
.md p, .md ul, .md ol, .md blockquote, .md pre, .md table { margin: 0 0 1em; }
.md ul, .md ol { padding-left: 1.4em; }
.md li + li { margin-top: 0.25em; }
.md blockquote { border-left: 3px solid var(--line); padding: 0 0 0 14px; color: var(--muted); }
.md code { font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace; font-size: 0.88em; background: var(--code-bg); padding: 1px 5px; border-radius: 4px; }
.md pre { background: var(--code-bg); padding: 14px 16px; border-radius: 8px; overflow-x: auto; line-height: 1.45; }
.md pre code { background: none; padding: 0; font-size: 0.85em; }
.md pre.mermaid { background: transparent; text-align: center; }
.md table { display: block; overflow-x: auto; border-collapse: collapse; font-size: 0.92rem; max-width: 100%; }
.md th, .md td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; vertical-align: top; }
.md th { background: var(--code-bg); font-weight: 600; }
.md img { max-width: 100%; height: auto; border-radius: 6px; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }

/* страница идеи: кокпит (основная колонка + правая панель) */
.idea { max-width: 1040px; margin: 0 auto; padding: 28px 16px 72px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 28px; }
.idea.no-rail { max-width: 712px; }
@media (min-width: 1000px) {
  .idea { grid-template-columns: minmax(0, 680px) 280px; gap: 40px; justify-content: center; }
  .r-toc { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; }
}
@media (max-width: 999px) { .r-toc { display: none; } }
.idea-main { min-width: 0; }
.sec-label, .rlabel, .more-label, .now-label { font-size: 0.72rem; font-weight: 650; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; line-height: 1.2; }
.rlabel .n, .more-label .n { font-weight: 500; opacity: 0.75; }

.ihead { margin-bottom: 22px; }
.ihead h1 { margin: 12px 0 8px; font-size: 1.9rem; }
.ihead .sub { font-size: 1.2rem; line-height: 1.45; margin: 0 0 12px; color: color-mix(in srgb, var(--text) 80%, var(--muted)); }
.ihead-tags { margin-top: 4px; }

.now { margin: 0 0 24px; padding: 16px 20px 18px; background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent); border-left: 4px solid var(--accent); border-radius: var(--radius); }
.now .now-label { color: var(--accent); }
.now-next { margin: 0; font-size: 1.15rem; line-height: 1.4; font-weight: 560; }
.todos { list-style: none; padding: 0; margin: 12px 0 0; }
.now-next + .todos { border-top: 1px solid color-mix(in srgb, var(--accent) 22%, transparent); padding-top: 10px; }
.todos li { position: relative; padding-left: 26px; margin: 6px 0; line-height: 1.45; overflow-wrap: anywhere; }
.todos li::before { content: ""; position: absolute; left: 2px; top: 0.25em; width: 13px; height: 13px; border: 1.5px solid color-mix(in srgb, var(--accent) 70%, var(--muted)); border-radius: 4px; }
.todos code { font-size: 0.88em; background: var(--surface); padding: 1px 5px; border-radius: 4px; }
.todos-more > summary { cursor: pointer; color: var(--muted); font-size: 0.88rem; margin-top: 6px; padding-left: 26px; }

.sec { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 22px 20px; margin: 0 0 16px; scroll-margin-top: 16px; }
.sec-summary .sec-body { font-size: 1.05rem; }
.sec-body > :last-child { margin-bottom: 0; }
.js .sec-body.clamp { max-height: 15rem; overflow: hidden; position: relative; }
.js .sec-body.clamp::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 5rem; background: linear-gradient(to bottom, color-mix(in srgb, var(--surface) 0%, transparent), var(--surface)); pointer-events: none; }
.js .sec-body.clamp.open { max-height: none; overflow: visible; }
.js .sec-body.clamp.open::after { display: none; }
.expand { display: none; font: inherit; font-size: 0.85rem; color: var(--accent); background: transparent; border: 1px solid var(--line); border-radius: 999px; padding: 4px 14px; margin-top: 12px; cursor: pointer; }
.js .expand { display: inline-block; }
.expand:hover { border-color: var(--accent); }
.expand:focus-visible, .more-sec > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.more { margin-top: 28px; scroll-margin-top: 16px; }
.more-sec { border-top: 1px solid var(--line); scroll-margin-top: 16px; }
.more-sec:last-child { border-bottom: 1px solid var(--line); }
.more-sec > summary { cursor: pointer; list-style: none; padding: 12px 4px; font-weight: 560; display: flex; gap: 10px; align-items: baseline; }
.more-sec > summary::-webkit-details-marker { display: none; }
.more-sec > summary::before { content: "›"; color: var(--muted); display: inline-block; width: 0.8em; transition: transform 0.15s; }
.more-sec[open] > summary::before { transform: rotate(90deg); }
.more-sec > summary:hover { color: var(--accent); }
.more-sec > .md { padding: 2px 4px 18px 22px; }
.wip-in { margin-top: 16px; }

.rail { display: flex; flex-direction: column; gap: 14px; min-width: 0; font-size: 0.9rem; overflow-wrap: anywhere; }
.rcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.rlist { list-style: none; margin: 0; padding: 0; }
.rlist li { margin: 5px 0; line-height: 1.35; }
.rgroup + .rgroup { margin-top: 12px; }
.rg { margin: 0 0 2px; font-size: 0.78rem; color: var(--muted); }
.rel-list a { display: inline; }
.rel-list .dot { margin-right: 7px; vertical-align: 0.08em; }
.hint { color: var(--muted); font-size: 0.78rem; margin-left: 6px; }
.rdir { margin-top: 8px; }
.rdir > summary { cursor: pointer; color: var(--muted); font-size: 0.85rem; }
.rdir .rlist { margin: 4px 0 0 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 0.92em; }
.n { opacity: 0.75; }
.rmeta { margin: 10px 0 0; color: var(--muted); font-size: 0.8rem; }
.btn-sm { padding: 6px 14px; font-size: 0.88rem; margin-top: 10px; }
.src a { display: block; padding: 2px 0; }
.src a:hover { text-decoration: none; }
.src-t { display: block; color: var(--text); }
.src a:hover .src-t { color: var(--accent); }
.src-h { display: block; color: var(--muted); font-size: 0.78rem; }
.rmore > summary { cursor: pointer; color: var(--muted); font-size: 0.85rem; margin-top: 6px; }
.hist li { display: grid; gap: 0; }
.h-d { color: var(--muted); font-size: 0.78rem; }
.h-s { font-size: 0.85rem; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.md li:has(> input[type="checkbox"]) { list-style: none; margin-left: -1.3em; }
.md li > input[type="checkbox"] { margin: 0 0.45em 0 0; vertical-align: -0.1em; }
@media (max-width: 599px) {
  .ihead h1 { font-size: 1.6rem; }
  .ihead .sub { font-size: 1.1rem; }
  .sec { padding: 16px 16px 18px; }
  .now { padding: 14px 16px 16px; }
}
.outline a { color: var(--muted); display: block; padding: 2px 0; }
.outline a:hover { color: var(--text); text-decoration: none; }
.outline ul { list-style: none; margin: 2px 0 4px; padding-left: 12px; font-size: 0.85rem; }

/* граф */
.graph-wrap { display: flex; flex-direction: column; height: calc(100vh - 53px); height: calc(100dvh - 53px); }
.graph-bar { max-width: 1040px; width: 100%; margin: 0 auto; padding: 16px 16px 8px; display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 24px; }
.graph-bar h1 { font-size: 1.25rem; margin: 0; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 0.85rem; color: var(--muted); }
.legend > span { display: inline-flex; align-items: center; gap: 6px; }
#graph { flex: 1; min-height: 320px; }
.graph-msg { color: var(--muted); text-align: center; padding: 48px 16px; }
div.vis-tooltip { background: var(--surface) !important; color: var(--text) !important; border: 1px solid var(--line) !important; border-radius: 8px !important; font: 13px/1.4 system-ui, sans-serif !important; padding: 8px 10px !important; max-width: 320px; white-space: pre-wrap !important; box-shadow: 0 4px 16px rgb(0 0 0 / 0.12) !important; }

/* превью */
.preview-page { display: flex; flex-direction: column; height: 100vh; height: 100dvh; margin: 0; }
.pbar { display: flex; justify-content: space-between; gap: 16px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--surface); font-size: 0.9rem; }
.preview-page iframe { flex: 1; width: 100%; border: 0; background: #fff; }
