:root {
    --paper: #f3efe6;
    --paper-deep: #e6dfd1;
    --ink: #172424;
    --muted: #687373;
    --line: #c9c1b2;
    --accent: #dc5f45;
    --accent-dark: #a73c2b;
    --teal: #156f70;
    --panel: rgba(255, 253, 248, 0.82);
    --shadow: 0 20px 55px rgba(43, 52, 48, 0.12);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }

body {
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at 10% 5%, rgba(220, 95, 69, 0.1), transparent 28rem),
        radial-gradient(circle at 92% 90%, rgba(21, 111, 112, 0.1), transparent 34rem),
        var(--paper);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    overflow: hidden;
}

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.site-header {
    height: 78px;
    padding: 14px clamp(18px, 3vw, 44px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 28px;
    border-bottom: 1px solid rgba(95, 100, 94, 0.18);
    background: rgba(243, 239, 230, 0.82);
    backdrop-filter: blur(18px);
    position: relative;
    z-index: 20;
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    color: inherit;
    text-decoration: none;
    min-width: max-content;
}

.brand-mark {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 50% 50% 44% 56%;
    color: white;
    background: var(--accent);
    font: 700 27px/1 Georgia, serif;
    transform: rotate(-5deg);
    box-shadow: 0 7px 16px rgba(220, 95, 69, 0.25);
}

.brand strong {
    display: block;
    font: 700 clamp(19px, 2vw, 24px)/1 Georgia, "Times New Roman", serif;
    letter-spacing: -0.02em;
}

.brand small {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.15em;
}

.search { width: min(420px, 48vw); position: relative; }

.search > svg {
    position: absolute;
    left: 15px;
    top: 50%;
    width: 18px;
    transform: translateY(-50%);
    fill: none;
    stroke: var(--muted);
    stroke-width: 1.8;
    pointer-events: none;
}

.search input {
    width: 100%;
    height: 46px;
    padding: 0 18px 0 43px;
    color: var(--ink);
    background: rgba(255, 255, 255, 0.62);
    border: 1px solid rgba(96, 102, 95, 0.25);
    border-radius: 999px;
    outline: none;
    transition: border-color 160ms, box-shadow 160ms, background 160ms;
}

.search input:focus {
    border-color: var(--teal);
    background: white;
    box-shadow: 0 0 0 4px rgba(21, 111, 112, 0.1);
}

.search-results {
    position: absolute;
    top: calc(100% + 9px);
    right: 0;
    width: min(520px, 90vw);
    max-height: min(440px, 65vh);
    overflow: auto;
    padding: 7px;
    background: #fffdf8;
    border: 1px solid rgba(96, 102, 95, 0.18);
    border-radius: 17px;
    box-shadow: var(--shadow);
}

.search-result {
    width: 100%;
    display: block;
    padding: 11px 12px;
    text-align: left;
    color: inherit;
    background: transparent;
    border: 0;
    border-radius: 11px;
    cursor: pointer;
}

.search-result:hover, .search-result:focus-visible { background: var(--paper); outline: none; }
.search-result strong { display: block; font-size: 14px; }
.search-result small { color: var(--muted); }
.search-empty { margin: 12px; color: var(--muted); font-size: 13px; }

.workspace {
    height: calc(100vh - 78px);
    min-height: 520px;
    padding: clamp(12px, 2vw, 26px);
    display: grid;
    grid-template-columns: minmax(0, 1fr) clamp(270px, 25vw, 360px);
    gap: clamp(12px, 2vw, 24px);
}

.graph-panel, .details {
    border: 1px solid rgba(96, 102, 95, 0.18);
    background: var(--panel);
    box-shadow: var(--shadow);
}

.graph-panel {
    min-width: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    border-radius: 26px;
    overflow: hidden;
}

.graph-toolbar {
    min-height: 70px;
    padding: 14px 18px 10px 22px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    position: relative;
    z-index: 2;
}

.eyebrow {
    margin: 0 0 5px;
    color: var(--accent-dark);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.zoom-controls {
    display: flex;
    padding: 3px;
    gap: 2px;
    background: rgba(243, 239, 230, 0.8);
    border: 1px solid rgba(96, 102, 95, 0.15);
    border-radius: 999px;
}

.zoom-controls button {
    width: 34px;
    height: 34px;
    padding: 0;
    color: var(--ink);
    background: transparent;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
    font-size: 19px;
}

.zoom-controls button:hover, .zoom-controls button:focus-visible { background: white; outline: none; }
.graph-stage { min-height: 0; position: relative; overflow: hidden; }
#graph { width: 100%; height: 100%; display: block; cursor: grab; }
#graph:active { cursor: grabbing; }

.edge {
    stroke: #7d8783;
    stroke-linecap: round;
    vector-effect: non-scaling-stroke;
}

.edge.reciprocal { stroke: var(--teal); }
.node { cursor: pointer; outline: none; }
.node circle { stroke: #fffdf8; stroke-width: 2px; transition: stroke-width 150ms, filter 150ms; }
.node:hover circle, .node:focus-visible circle { stroke-width: 4px; filter: drop-shadow(0 3px 5px rgba(23, 36, 36, 0.28)); }
.node.focus circle { fill: var(--accent) !important; stroke: #fff; stroke-width: 4px; filter: drop-shadow(0 5px 9px rgba(167, 60, 43, 0.36)); }

.node-label {
    paint-order: stroke;
    stroke: #fffdf8;
    stroke-width: 3.5px;
    stroke-linejoin: round;
    fill: var(--ink);
    font-weight: 650;
    letter-spacing: -0.01em;
    pointer-events: none;
}

.node-label.focus, .node-label.hovered {
    fill: #111d1d;
    font-weight: 850;
    stroke-width: 5px;
}

.node-label.hovered {
    font-size: 12px !important;
    opacity: 1 !important;
}

.loading, .graph-error {
    position: absolute;
    inset: 0;
    display: grid;
    place-content: center;
    justify-items: center;
    background: rgba(243, 239, 230, 0.8);
    backdrop-filter: blur(4px);
    z-index: 5;
}

.loading[hidden], .graph-error[hidden] { display: none; }
.loading p, .graph-error { color: var(--muted); font-size: 13px; }
.loading span { width: 28px; height: 28px; border: 3px solid var(--paper-deep); border-top-color: var(--accent); border-radius: 50%; animation: spin 700ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.details {
    padding: clamp(22px, 3vw, 34px);
    border-radius: 26px;
    overflow: auto;
}

.details h1 {
    margin: 12px 0 9px;
    font: 700 clamp(25px, 3vw, 38px)/1.08 Georgia, "Times New Roman", serif;
    letter-spacing: -0.035em;
    overflow-wrap: anywhere;
}

.detail-date { margin: 0 0 22px; color: var(--muted); font-size: 12px; }
.detail-excerpt { color: #405050; font: 16px/1.62 Georgia, "Times New Roman", serif; }
.detail-excerpt:empty { display: none; }
.term-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 22px 0; }
.term { padding: 5px 9px; color: var(--teal); background: rgba(21, 111, 112, 0.09); border-radius: 999px; font-size: 10px; font-weight: 700; }

.detail-stats {
    margin: 24px 0;
    padding: 16px 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.detail-stats div + div { padding-left: 18px; border-left: 1px solid var(--line); }
.detail-stats dt { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .12em; }
.detail-stats dd { margin: 4px 0 0; font: 700 22px/1 Georgia, serif; }

.article-link {
    min-height: 48px;
    padding: 0 17px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: white;
    background: var(--ink);
    border-radius: 999px;
    text-decoration: none;
    font-weight: 750;
    font-size: 13px;
    transition: transform 150ms, background 150ms;
}

.article-link:hover, .article-link:focus-visible { background: var(--accent-dark); transform: translateY(-1px); outline: none; }
.article-link svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.details-hint { margin: 18px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
noscript { position: fixed; inset: 0; display: grid; place-items: center; background: var(--paper); z-index: 100; }

@media (max-width: 700px) {
    body { overflow: auto; }
    .site-header { height: 68px; padding: 10px 14px; gap: 12px; }
    .brand small { display: none; }
    .brand-mark { width: 37px; height: 37px; }
    .brand strong { font-size: 18px; }
    .search { width: min(52vw, 300px); }
    .search input { height: 42px; }
    .workspace { height: auto; min-height: calc(100vh - 68px); padding: 10px; display: block; }
    .graph-panel { height: min(66vh, 620px); min-height: 470px; border-radius: 20px; }
    .graph-toolbar { padding: 12px 13px 8px 16px; }
    .details { margin-top: 10px; min-height: 300px; border-radius: 20px; padding: 24px 21px; }
    .details h1 { font-size: 29px; }
    .node-label { stroke-width: 4.5px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
