:root {
    color-scheme: light;
    --paper: #f9f9f1;
    --ink: #1e2a27;
    --muted: #55645d;
    --line: #d9e0d4;
    --dark: #111e20;
    --dark-line: #334646;
    --lime: #c2e786;
    --project: #c2e786;
    --workflow: #83dbc8;
    --knowledge: #f2cd8b;
    --tool: #c7b6ee;
    font: 16px/1.48 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--paper); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button, .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    min-height: 2.4rem;
    padding: .45rem .7rem;
    border: 1px solid var(--line);
    border-radius: .45rem;
    background: transparent;
    color: inherit;
    font-size: .85rem;
    font-weight: 650;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
}
button:not(:disabled):hover, .button:hover { background: #e9eddf; }
button:disabled { opacity: .54; cursor: default; }
:focus-visible { outline: 2px solid #518157; outline-offset: 3px; }
input, select, textarea {
    width: 100%;
    padding: .6rem .65rem;
    border: 1px solid #bdcabd;
    border-radius: .45rem;
    background: #fdfdf7;
    color: var(--ink);
}
label { display: block; margin-bottom: .35rem; font-size: .82rem; font-weight: 650; }
textarea { min-height: 11rem; resize: vertical; }
h1, h2, h3, p { margin: 0; }
h1, h2 { font-family: Georgia, "Times New Roman", serif; font-weight: 500; line-height: 1.07; }
h1, h2, strong, .project-label { overflow-wrap: anywhere; }
.eyebrow { font-size: .67rem; font-weight: 760; letter-spacing: .14em; text-transform: uppercase; }
.muted { color: var(--muted); }
.error { color: #a13229; }
.primary { background: var(--lime); border-color: transparent; color: #1e301a; }
.primary:not(:disabled):hover { background: #d1ef9c; }
.secondary { border-color: #b8c8b8; }
.text-button { padding: .35rem .3rem; border: 0; font-size: .75rem; color: #365746; }
.danger { color: #9b342d; }
.danger-fill, .danger-fill:not(:disabled):hover { background: #9b342d; color: #fff; }
.skip { position: fixed; top: -4rem; left: 1rem; z-index: 5; padding: .6rem; background: var(--paper); color: var(--ink); }
.skip:focus { top: 1rem; }

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .6rem;
    padding: .8rem clamp(1rem, 2.4vw, 2rem);
    border-bottom: 1px solid #dfe5d9;
    background: #eff1e6;
}
.brand { display: flex; align-items: center; gap: .7rem; font-weight: 760; letter-spacing: -.02em; }
.brand small { margin-left: .55rem; color: var(--muted); font-weight: 520; white-space: nowrap; }
.logo {
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    flex: 0 0 2rem;
    border-radius: .5rem;
    background: var(--dark);
    color: var(--lime);
    font-size: 1.1rem;
}
.top-actions { display: flex; gap: .4rem; }
.quiet { border-color: #d2dacd; white-space: nowrap; }
.board {
    display: grid;
    grid-template-columns: minmax(12rem, .85fr) minmax(23rem, 2.55fr) minmax(17rem, 1.2fr);
    min-height: calc(100vh - 4.4rem);
}
.sidebar { padding: 1.5rem 1.05rem; background: #eff1e6; min-width: 0; }
.side-head h1 { font-size: clamp(1.7rem, 2.4vw, 2.45rem); margin: .38rem 0 1rem; }
.side-head .primary { width: 100%; }
.filters { margin-top: 1.4rem; }
.filters label:not(:first-child) { margin-top: .85rem; }
.filters input, .filters select { font-size: .83rem; }
.side-count { margin: 1.15rem 0 .4rem; color: var(--muted); font-size: .75rem; font-weight: 650; }
.node-list { list-style: none; padding: 0; margin: 0; max-height: min(50vh, 40rem); overflow: auto; }
.node-link {
    justify-content: flex-start;
    width: 100%;
    min-height: 3.3rem;
    text-align: left;
    gap: .6rem;
    border-color: transparent;
}
.node-link[aria-current] { background: #dde9d4; border-color: #bfcfba; }
.node-copy { min-width: 0; }
.node-copy strong, .node-copy small { display: block; }
.node-copy small { margin-top: .22rem; color: var(--muted); font-weight: 500; }
.list-empty { padding: .5rem; color: var(--muted); font-size: .85rem; }

.map-panel { min-width: 0; background: var(--dark); color: #eff5e8; }
.map-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-end;
    gap: .7rem;
    padding: 1.55rem clamp(1rem, 2.6vw, 2rem) 1.2rem;
    border-bottom: 1px solid var(--dark-line);
}
.map-head .eyebrow { color: var(--lime); }
.map-head h2 { font-size: clamp(1.75rem, 3.5vw, 3.05rem); margin: .28rem 0 .4rem; }
.map-head .muted { color: #b4c6bd; font-size: .84rem; }
.view-switch { display: flex; flex-wrap: wrap; gap: .35rem; }
.view-switch button { color: #d4e1d7; border-color: #516664; }
.view-switch button:not(:disabled):hover { background: #2b4140; }
.view-switch button[aria-pressed="true"] { background: #2b4140; border-color: #87a89a; }
.map-panel :focus-visible { outline-color: var(--lime); }
.graph-wrap {
    display: grid;
    position: relative;
    align-content: center;
    min-height: 24rem;
    overflow: auto;
    background-image: radial-gradient(circle, #34494a 1px, transparent 1px);
    background-size: 22px 22px;
}
#graph { display: block; width: 100%; min-width: 31rem; }
.graph-empty {
    position: absolute;
    inset: 50% auto auto 50%;
    width: min(90%, 19rem);
    transform: translate(-50%, -50%);
    padding: 1rem;
    border: 1px solid var(--dark-line);
    border-radius: .55rem;
    background: #19282a;
    text-align: center;
}
.graph-empty p { margin-top: .45rem; font-size: .85rem; color: #bdcdc4; }
.orbit { fill: none; stroke: #384c4c; stroke-dasharray: 4 6; }
.orbit.inner { stroke: #2f4545; }
.map-edge { fill: none; stroke: #728c87; stroke-width: 1.35; }
.map-edge.active { stroke: #b3d9ba; stroke-width: 1.8; }
.arrow-normal { fill: #728c87; }
.arrow-active { fill: #b3d9ba; }
.graph-node { cursor: pointer; color: var(--lime); }
.graph-node text {
    fill: #edf4e9;
    font: 650 14px system-ui, sans-serif;
    paint-order: stroke;
    stroke: #111e20;
    stroke-width: 4px;
    stroke-linejoin: round;
}
.graph-node .center-label { font-size: 16px; }
.graph-node .halo { fill: currentColor; opacity: .10; }
.graph-node .node-disc { fill: #263836; stroke: currentColor; stroke-width: 1.5; }
.graph-node .node-core { fill: currentColor; }
.graph-node:is(.selected, :hover, :focus-visible) .node-disc { fill: currentColor; }
.graph-node:is(.selected, :hover, :focus-visible) .node-core { fill: #203130; }
.graph-node:is(.selected, :hover, :focus-visible) .halo { opacity: .24; }
.map-foot {
    display: flex;
    flex-wrap: wrap;
    gap: .65rem 1rem;
    padding: .9rem clamp(1rem, 2.6vw, 2rem);
    border-top: 1px solid var(--dark-line);
    font-size: .77rem;
}
.project { --type: var(--project); }
.workflow { --type: var(--workflow); }
.knowledge { --type: var(--knowledge); }
.tool { --type: var(--tool); }
.graph-node { color: var(--type); }
.legend { display: inline-flex; gap: .4rem; align-items: center; color: #d9e3dc; }
.legend::before, .type-dot {
    content: "";
    flex: 0 0 .56rem;
    width: .56rem;
    height: .56rem;
    border-radius: 50%;
    background: var(--type);
}
.type-dot { outline: 1px solid #556b58; }

.detail { min-width: 0; padding: 1.55rem clamp(1rem, 2vw, 1.7rem) 2rem; scroll-margin-top: .5rem; }
.detail > .eyebrow { color: #45624f; margin-bottom: .8rem; }
.detail > h2 { margin-bottom: .8rem; font-size: clamp(1.65rem, 2.6vw, 2.65rem); }
.detail > p + .secondary { margin-top: 1rem; }
.entry-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .65rem; margin-bottom: .55rem; }
.pill { border-radius: 99px; background: var(--type); padding: .22rem .55rem; font-size: .7rem; font-weight: 700; }
.project-label { color: var(--muted); font-size: .77rem; }
.entry-body { margin-top: 1.1rem; font-size: .91rem; overflow-wrap: anywhere; }
.entry-body p { margin: .65rem 0; white-space: pre-wrap; }
.entry-body h3 { margin: .95rem 0 .28rem; font-size: .95rem; }
.entry-body ul { margin: .25rem 0 .75rem; padding-left: 1.2rem; }
.entry-body li + li { margin-top: .22rem; }
.detail-section { margin-top: 1rem; padding-top: .9rem; border-top: 1px solid var(--line); }
.detail-section h3 { margin-bottom: .5rem; font-size: .97rem; }
.detail-section p { margin-top: .45rem; font-size: .82rem; }
.stars { display: flex; flex-wrap: wrap; gap: .12rem; }
.star { padding: .3rem; border: 0; min-height: 2rem; color: #795812; font-size: 1.35rem; }
.rating-text { font-size: .8rem; margin-right: .5rem; }
.edge-list { padding: 0; margin: .5rem 0 0; list-style: none; }
.edge-list li { display: flex; gap: .4rem; align-items: center; justify-content: space-between; border-bottom: 1px solid #e8ebdf; }
.edge-list li:last-child { border-bottom: 0; }
.edge-jump { display: grid; justify-content: start; gap: .2rem; border: 0; text-align: left; min-width: 0; }
.edge-jump small { color: var(--muted); }
.entry-footer { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .4rem; }
.entry-footer small { font-size: .71rem; }
.notice { position: fixed; z-index: 3; right: 1rem; bottom: 1rem; max-width: min(27rem, calc(100% - 2rem)); padding: .7rem 1rem; border-radius: .45rem; background: #ddebcb; color: #253825; box-shadow: 0 5px 20px #14262022; }
.notice-error { background: #fae0d9; color: #812a22; }
dialog { width: min(32rem, calc(100vw - 1.5rem)); max-height: calc(100dvh - 1.5rem); border: 1px solid var(--line); border-radius: .75rem; background: var(--paper); color: var(--ink); padding: 1.35rem; box-shadow: 0 1.5rem 5rem #00110b55; }
dialog::backdrop { background: #10211bd0; }
dialog h2 { font-size: 1.9rem; margin: .35rem 0 1rem; }
.editor-fields { display: grid; gap: .7rem; }
.editor-hint { font-size: .75rem; }
.editor-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }
#editor-error { margin-top: .65rem; font-size: .83rem; }

.login-page { display: grid; place-items: center; min-height: 100vh; padding: 1rem; background: var(--dark); background-image: radial-gradient(circle, #334646 1px, transparent 1px); background-size: 22px 22px; }
.login-card { width: min(100%, 25rem); border-radius: .8rem; background: var(--paper); padding: clamp(1.2rem, 5vw, 2rem); box-shadow: 0 1rem 4rem #0004; }
.login-card .eyebrow { margin-top: 1.65rem; color: #45624f; }
.login-card h1 { margin: .3rem 0 .55rem; font-size: clamp(1.9rem, 5vw, 2.8rem); }
.login-card form { margin-top: 1.1rem; }
.login-card .primary { width: 100%; margin-top: .75rem; }
.login-card .error { margin-top: .5rem; font-size: .82rem; }

@media (max-width: 1030px) and (min-width: 931px) {
    .board { grid-template-columns: 12rem minmax(0, 1fr) 16rem; }
    #graph { min-width: 26rem; }
}
@media (max-width: 930px) {
    .board { grid-template-columns: minmax(11rem, .8fr) minmax(0, 2fr); }
    .detail { grid-column: 1 / -1; }
    .graph-wrap { min-height: 20rem; }
    #graph { min-width: 28rem; }
}
@media (max-width: 610px) {
    .brand small { display: none; }
    .board { display: flex; flex-direction: column; }
    .sidebar { padding: 1rem; }
    .side-head { display: grid; grid-template-columns: 1fr auto; align-items: center; column-gap: .55rem; }
    .side-head h1 { margin-bottom: 0; }
    .side-head .primary { grid-column: 2; grid-row: 1 / span 2; width: auto; }
    .filters { margin-top: .8rem; }
    .node-list { max-height: 11rem; }
    .graph-wrap { min-height: 18rem; }
    .graph-wrap:has(.graph-empty:not([hidden])) { overflow: hidden; }
    .map-head { padding-top: 1.15rem; }
    .top-actions { gap: .25rem; }
    .top-actions > *, .top-actions button { font-size: .76rem; }
}

.login-card form label:not(:first-of-type) { margin-top: .65rem; }
.login-card > p:not(.eyebrow):not(.error), .manual-key p { color: var(--muted); }
.login-card .manual-key { margin-top: .9rem; }
.manual-key summary { cursor: pointer; font-size: .86rem; }
.manual-key p { font-size: .75rem; margin: .4rem 0; }
.manual-key code { font-size: .78rem; overflow-wrap: anywhere; }
.pairing-qr { display: block; width: min(100%, 14rem); height: auto; margin: .8rem auto; }
.recovery-list { list-style: none; padding: 0; margin: .8rem 0; font-size: .8rem; }
.recovery-list li { padding: .2rem .35rem; background: #eff1e6; overflow-wrap: anywhere; }
.login-card .restart-login { margin-top: .45rem; }
