/* Palime Culture Map — 2D editorial timeline map (/graph/).
 * Reference look: black instrument panels (top bar, bottom legend bar, detail
 * panel) framing an aged-paper canvas; node pills with round (author) or
 * square (work) thumbs; ink edges with RED reserved for the active chain,
 * selection and primary action. See assets/js/culture-map.js.
 */

.page-culture-map main {
    max-width: none;
    padding: 0;
}

.cm-root {
    position: relative;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 64px);
    min-height: 520px;
    background: var(--paper-bg);
    color: var(--color-text);
    overflow: hidden;
}

/* embed mode (iframe в карточках): только полотно + линейка + мини-карта */

.cm-root--embed {
    height: 100%;
    min-height: 320px;
}

.cm-root--embed .cm-topbar,
.cm-root--embed .cm-bb-legend,
.cm-root--embed .cm-bb-edgekey,
.cm-root--embed .cm-bb-nav,
.cm-root--embed .cm-bb-jumps,
.cm-root--embed .cm-bb-meta,
.cm-root--embed .cm-hint {
    display: none;
}

.cm-root--embed .cm-bottombar {
    min-height: 48px;
}

.cm-root--embed .cm-panel {
    width: 300px;
}

/* === Top bar (black instrument panel) =================================== */

.cm-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 10px 18px;
    background: var(--shell-bg);
    color: var(--shell-fg);
    border-bottom: 1px solid rgba(255, 255, 255, 0.18);
    z-index: 30;
}

.cm-title {
    display: flex;
    flex-direction: column;
    margin-right: 8px;
    padding-left: 12px;
    border-left: 3px solid var(--accent-main);
}

.cm-title b {
    font-family: var(--font-mono);
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    line-height: 1.2;
    color: var(--shell-fg);
}

.cm-title .cm-counts {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.06em;
    color: rgba(255, 255, 255, 0.55);
}

.cm-search-wrap {
    position: relative;
    flex: 0 1 250px;
    min-width: 170px;
}

.cm-search {
    width: 100%;
    padding: 7px 26px 7px 10px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.06);
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--shell-fg);
}

.cm-search::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.cm-search:focus {
    outline: none;
    border-color: var(--shell-fg);
    background: rgba(255, 255, 255, 0.1);
}

.cm-search-key {
    position: absolute;
    right: 7px;
    top: 50%;
    transform: translateY(-50%);
    font-family: var(--font-mono);
    font-size: 10px;
    color: rgba(255, 255, 255, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    padding: 0 4px;
    pointer-events: none;
}

.cm-search-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 300px;
    overflow-y: auto;
    background: var(--paper-surface);
    border: 1px solid var(--color-text);
    border-radius: 2px;
    box-shadow: var(--shadow-md);
    z-index: 40;
}

.cm-search-results button {
    display: block;
    width: 100%;
    padding: 8px 10px;
    border: 0;
    border-bottom: 1px solid var(--paper-border);
    background: none;
    text-align: left;
    cursor: pointer;
    font-family: var(--font-serif);
    font-size: 14px;
    color: var(--color-text);
}

.cm-search-results button small {
    display: block;
    font-family: var(--font-mono);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-faint);
    margin-top: 2px;
}

.cm-search-results button:hover {
    background: var(--color-second);
}

/* Domain / kind buttons: bordered rectangles on black, red = active */

.cm-chips {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.cm-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 11px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 2px;
    background: transparent;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.05em;
    color: var(--shell-fg);
    cursor: pointer;
    transition: border-color var(--transition), color var(--transition);
    user-select: none;
}

.cm-chip i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--cm-lane-color, rgba(255, 255, 255, 0.4));
    font-style: normal;
}

.cm-chip small {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.45);
}

.cm-chip:hover {
    border-color: var(--shell-fg);
}

.cm-chip.is-on {
    border-color: var(--accent-main);
    color: var(--accent-main);
}

.cm-chip.is-on small {
    color: var(--accent-main);
}

.cm-tagsets {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.cm-tagselect {
    padding: 6px 8px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 2px;
    background: var(--shell-bg);
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--shell-fg);
    max-width: 170px;
}

.cm-zoomctl {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-left: auto;
}

.cm-zoomctl button {
    min-width: 30px;
    height: 30px;
    padding: 0 10px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 2px;
    background: transparent;
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--shell-fg);
    cursor: pointer;
}

.cm-zoomctl button:hover {
    border-color: var(--shell-fg);
    background: rgba(255, 255, 255, 0.08);
}

.cm-zoom-pct {
    min-width: 46px;
    text-align: center;
    font-family: var(--font-mono);
    font-size: 11px;
    color: rgba(255, 255, 255, 0.7);
}

/* === Stage (aged paper canvas) ========================================== */

.cm-stage {
    position: relative;
    flex: 1;
    overflow: hidden;
    cursor: grab;
    touch-action: none;
    /* pure white canvas: no texture, no band tints — only barely-there
       era separators (user call, 11.06.2026) */
    background: #fff;
}

.cm-stage.is-dragging {
    cursor: grabbing;
}

.cm-bands,
.cm-nodes {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.cm-bands {
    pointer-events: none;
}

.cm-era-band {
    position: absolute;
    top: 0;
    border-left: 1px dotted rgba(10, 10, 10, 0.14);
    background: none;
}

.cm-era-band.is-odd {
    background: none;
}

.cm-era-band.is-gutter {
    border-left: 1px dashed rgba(10, 10, 10, 0.25);
    background: none;
}

.cm-lane-rule {
    position: absolute;
    left: 0;
    height: 1px;
    background: rgba(10, 10, 10, 0.14);
}

/* === Edges: ink by default, red only when active ======================== */

.cm-edges {
    position: absolute;
    inset: 0;
    overflow: visible;
    pointer-events: none;
}

.cm-edges path {
    fill: none;
    pointer-events: stroke;
    cursor: pointer;
    transition: opacity 0.18s ease;
}

.cm-edge-authorship {
    stroke: var(--color-text);
    stroke-opacity: 0.4;
    stroke-width: 1;
}

.cm-edge-personal {
    stroke: var(--color-text);
    stroke-opacity: 0.4;
    stroke-width: 1;
    stroke-dasharray: 5 4;
}

.cm-edge-influence {
    stroke: var(--color-text);
    stroke-opacity: 0.6;
    stroke-width: 1.4;
}

.cm-edges path.is-hot {
    stroke: var(--accent-main);
    stroke-opacity: 1;
    stroke-width: 2.2;
}

.cm-lifespan {
    stroke: var(--color-text);
    stroke-opacity: 0.3;
    stroke-width: 2;
    pointer-events: none;
}

.cm-lifespan-cap {
    stroke-opacity: 0.5;
    stroke-width: 1.5;
}

/* === Node pills ========================================================== */

.cm-node {
    position: absolute;
    left: 0;
    top: 0;
    will-change: transform;
    display: flex;
    align-items: center;
    gap: 0;
    height: 44px;
    max-width: 200px;
    padding: 0 13px 0 4px;
    border: 1px solid var(--color-text);
    border-radius: 999px;
    background: var(--paper-surface);
    box-shadow: 2px 2px 0 rgba(10, 10, 10, 0.16);
    text-align: left;
    cursor: pointer;
    transition: box-shadow 0.15s ease, border-color 0.15s ease, opacity 0.2s ease;
    overflow: hidden;
    font-family: var(--font-serif);
}

.cm-node:hover,
.cm-node:focus-visible {
    box-shadow: 3px 3px 0 var(--color-text);
    z-index: 5;
    outline: none;
}

.cm-node.is-selected {
    border-color: var(--accent-main);
    box-shadow: 0 0 0 1px var(--accent-main), 3px 3px 0 var(--accent-main);
    z-index: 6;
}

.cm-node.is-selected .cm-node-name {
    color: var(--accent-main);
}

.cm-node-cover {
    flex: 0 0 34px;
    height: 34px;
    position: relative;
    background: var(--color-second);
    border: 1px solid rgba(10, 10, 10, 0.35);
    overflow: hidden;
}

/* authors get round portraits, works get square covers (legend signifier) */
.cm-node--author .cm-node-cover {
    border-radius: 50%;
}

.cm-node--work .cm-node-cover {
    border-radius: 4px;
}

.cm-node-cover img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.cm-node-cover .cm-initial {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-serif);
    font-style: normal;
    font-weight: 600;
    font-size: 15px;
    color: var(--text-soft);
    background:
        linear-gradient(135deg, rgba(10, 10, 10, 0.04), rgba(10, 10, 10, 0.12)),
        var(--color-second);
}

.cm-node-body {
    flex: 1;
    min-width: 0;
    padding-left: 8px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1px;
}

.cm-node-name {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.1;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cm-node-meta {
    font-family: var(--font-mono);
    font-size: 8.5px;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-faint);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* chip LOD: compact pill at far zoom */

.cm-node.is-chip {
    height: 26px;
    max-width: 96px; /* never wider than the layout slot: no pile-ups */
    padding: 0 9px 0 2px;
    box-shadow: 1px 1px 0 rgba(10, 10, 10, 0.22);
}

.cm-node.is-chip .cm-node-cover {
    flex: 0 0 20px;
    height: 20px;
}

.cm-node.is-chip .cm-node-cover .cm-initial {
    font-size: 11px;
}

.cm-node.is-chip .cm-node-body {
    padding-left: 6px;
}

.cm-node.is-chip .cm-node-name {
    font-size: 11px;
}

.cm-node.is-chip .cm-node-meta {
    display: none;
}

/* === Cluster pills ("+N", paper card per reference) ====================== */

.cm-cluster {
    position: absolute;
    left: 0;
    top: 0;
    will-change: transform;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 38px;
    min-width: 56px;
    max-width: 180px;
    padding: 0 12px 0 4px;
    border: 1px solid var(--color-text);
    border-radius: 8px;
    background: var(--paper-surface);
    font-family: var(--font-mono);
    color: var(--color-text);
    cursor: pointer;
    box-shadow: 2px 2px 0 rgba(10, 10, 10, 0.16);
    transition: box-shadow var(--transition), border-color var(--transition), color var(--transition);
    overflow: hidden;
}

.cm-cluster-thumb {
    flex: 0 0 28px;
    height: 28px;
    border-radius: 4px;
    border: 1px solid rgba(10, 10, 10, 0.35);
    background: var(--color-second);
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cm-cluster-thumb img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cm-cluster-thumb i {
    font-style: normal;
    font-size: 13px;
    color: var(--text-faint);
}

.cm-cluster-body {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
    line-height: 1.25;
}

.cm-cluster-body small {
    font-size: 8.5px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-soft);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}

.cm-cluster-body b {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
}

.cm-cluster:hover {
    border-color: var(--accent-main);
    color: var(--accent-main);
    box-shadow: 2px 2px 0 var(--accent-main);
}

/* === Dimming ============================================================= */

.cm-root.is-dim .cm-node,
.cm-root.is-dim .cm-cluster {
    opacity: 0.2;
}

.cm-root.is-dim .cm-node.is-hot {
    opacity: 1;
}

/* lineage fading: the further along the chain, the quieter */
.cm-root.is-dim .cm-node.is-hot-2 {
    opacity: 0.72;
}

.cm-root.is-dim .cm-node.is-hot-3 {
    opacity: 0.45;
}

.cm-root.is-dim .cm-edges path {
    opacity: 0.08;
}

.cm-root.is-dim .cm-edges path.is-hot {
    opacity: 1;
}

.cm-root.is-dim .cm-edges path.is-hot.is-hot-far {
    opacity: 0.55;
}

/* === Screen overlays: ruler, lane labels, hints ========================= */

.cm-ruler {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 28px;
    border-bottom: 1px solid var(--color-text);
    background: rgba(255, 255, 255, 0.96);
    cursor: pointer; /* клик по линейке — срез времени */
    z-index: 10;
    overflow: hidden;
}

.cm-ruler span {
    pointer-events: none;
}

.cm-ruler span {
    position: absolute;
    top: 7px;
    transform: translateX(-50%);
    font-family: var(--font-mono);
    font-size: 9.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-text);
    white-space: nowrap;
}

.cm-ruler span.is-year {
    color: var(--text-soft);
    font-weight: 400;
    letter-spacing: 0.04em;
}

.cm-ruler span.is-year::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 16px;
    width: 1px;
    height: 5px;
    background: var(--text-soft);
}

.cm-lanebar {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 10;
}

.cm-lanebar span {
    position: absolute;
    left: 0;
    transform: translateY(-50%);
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--color-text);
    background: var(--paper-surface);
    padding: 4px 10px 4px 8px;
    border: 1px solid var(--color-text);
    border-left: 3px solid var(--cm-lane-color, var(--text-faint));
    border-radius: 0 2px 2px 0;
    box-shadow: 1px 1px 0 rgba(10, 10, 10, 0.18);
}

.cm-hint {
    position: absolute;
    right: 14px;
    bottom: 12px;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.04em;
    color: var(--text-faint);
    background: rgba(255, 255, 255, 0.92);
    padding: 4px 8px;
    border-radius: 2px;
    pointer-events: none;
    z-index: 10;
}

.cm-status[hidden] {
    display: none;
}

.cm-status {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-soft);
    z-index: 20;
}

.cm-status button {
    padding: 8px 16px;
    border: 1px solid var(--color-text);
    background: none;
    font-family: var(--font-mono);
    font-size: 12px;
    cursor: pointer;
}

.cm-empty {
    position: absolute;
    top: 46%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.04em;
    color: var(--text-soft);
    background: var(--paper-surface);
    border: 1px dashed var(--color-text);
    border-radius: 2px;
    padding: 10px 16px;
    pointer-events: none;
    z-index: 8;
}

.cm-empty[hidden] {
    display: none;
}

.cm-selrect {
    position: absolute;
    border: 1px dashed var(--accent-main);
    background: rgba(217, 21, 21, 0.06);
    z-index: 9;
    pointer-events: none;
}

.cm-selrect[hidden] {
    display: none;
}

/* === First-visit tour ==================================================== */

.cm-tour {
    position: absolute;
    left: 14px;
    bottom: 14px;
    max-width: 270px;
    background: var(--paper-surface);
    border: 1px solid var(--color-text);
    border-radius: 2px;
    box-shadow: 3px 3px 0 rgba(10, 10, 10, 0.25);
    z-index: 14;
    padding: 12px 14px 10px;
}

.cm-tour-step {
    font-family: var(--font-serif);
    font-size: 13.5px;
    line-height: 1.45;
    color: var(--color-text);
}

.cm-tour-step b {
    color: var(--accent-main);
}

.cm-tour-foot {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
}

.cm-tour-foot span {
    font-family: var(--font-mono);
    font-size: 9.5px;
    color: var(--text-faint);
    margin-right: auto;
}

.cm-tour-skip {
    border: 0;
    background: none;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-faint);
    cursor: pointer;
}

.cm-tour-skip:hover {
    color: var(--color-text);
}

.cm-tour-next {
    border: 1px solid var(--color-text);
    border-radius: 2px;
    background: var(--color-text);
    color: var(--color-bg);
    font-family: var(--font-mono);
    font-size: 10.5px;
    letter-spacing: 0.06em;
    padding: 5px 12px;
    cursor: pointer;
}

.cm-tour-next:hover {
    background: var(--accent-main);
    border-color: var(--accent-main);
    color: #fff;
}

/* === Tooltip ============================================================= */

.cm-edgetip {
    position: absolute;
    max-width: 260px;
    padding: 8px 10px;
    background: var(--color-text);
    color: var(--color-bg);
    border-radius: 2px;
    font-family: var(--font-mono);
    font-size: 11px;
    line-height: 1.5;
    pointer-events: none;
    z-index: 50;
    box-shadow: var(--shadow-md);
}

.cm-edgetip b {
    color: #fff;
}

.cm-edgetip .cm-edgetip-type {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 9.5px;
    color: rgba(255, 255, 255, 0.65);
}

/* === Bottom bar (black legend strip, per reference) ====================== */

.cm-bottombar {
    display: flex;
    align-items: stretch;
    gap: 0;
    background: var(--shell-bg);
    color: var(--shell-fg);
    border-top: 2px solid var(--color-text);
    z-index: 25;
    min-height: 86px;
}

.cm-bb-col {
    padding: 10px 16px;
    border-right: 1px solid rgba(255, 255, 255, 0.14);
    display: flex;
    flex-direction: column;
    gap: 4px;
    justify-content: flex-start;
}

.cm-bb-col:last-child {
    border-right: 0;
}

.cm-bb-col h4 {
    margin: 0 0 4px;
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: rgba(255, 255, 255, 0.45);
}

.cm-bb-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.03em;
    color: rgba(255, 255, 255, 0.75);
    white-space: nowrap;
}

/* legend rows are live filters */
button.cm-bb-row {
    border: 0;
    background: none;
    padding: 1px 0;
    cursor: pointer;
    text-align: left;
    transition: opacity var(--transition), color var(--transition);
}

button.cm-bb-row:hover {
    color: #fff;
}

button.cm-bb-row.is-off {
    opacity: 0.35;
    text-decoration: line-through;
}

.cm-bb-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 14px;
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
    position: relative;
}

.cm-bb-pill--author::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.7);
    position: absolute;
    left: 2px;
}

.cm-bb-pill--work::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.7);
    position: absolute;
    left: 2px;
}

.cm-bb-pill--cluster {
    border-radius: 4px;
    font-size: 8px;
    font-family: var(--font-mono);
    color: rgba(255, 255, 255, 0.8);
}

.cm-bb-line {
    display: inline-block;
    width: 26px;
    height: 0;
    border-top: 2px solid rgba(255, 255, 255, 0.65);
    flex-shrink: 0;
}

.cm-bb-line.is-active {
    border-top-color: var(--accent-main);
}

.cm-bb-line.is-weak {
    border-top-style: dashed;
    border-top-width: 1px;
}

.cm-bb-line.is-thin {
    border-top-width: 1px;
    opacity: 0.7;
}

.cm-bb-mini {
    flex: 1;
    min-width: 200px;
}

.cm-minimap {
    position: relative;
    flex: 1;
    min-height: 44px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.04);
    cursor: pointer;
    user-select: none;
}

.cm-minimap svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.cm-minimap-viewport {
    position: absolute;
    top: 0;
    bottom: 0;
    border: 1px solid var(--accent-main);
    background: rgba(217, 21, 21, 0.12);
    cursor: grab;
    min-width: 10px;
}

.cm-minimap-era {
    position: absolute;
    bottom: 2px;
    transform: translateX(-50%);
    font-family: var(--font-mono);
    font-size: 8px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.5);
    pointer-events: none;
    white-space: nowrap;
}

.cm-bb-btns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
}

.cm-bb-btns button {
    padding: 5px 10px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 2px;
    background: transparent;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.04em;
    color: var(--shell-fg);
    cursor: pointer;
    white-space: nowrap;
}

.cm-bb-btns button:hover {
    border-color: var(--accent-main);
    color: var(--accent-main);
}

.cm-bb-meta {
    position: relative;
    min-width: 150px;
}

.cm-bb-version {
    color: rgba(255, 255, 255, 0.55);
}

.cm-stamp {
    position: absolute;
    right: 12px;
    bottom: 8px;
    transform: rotate(-7deg);
    border: 2px solid var(--accent-main);
    border-radius: 3px;
    color: var(--accent-main);
    font-family: var(--font-mono);
    font-size: 8px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    line-height: 1.5;
    padding: 4px 8px;
    opacity: 0.85;
    pointer-events: none;
}

.cm-stamp b {
    font-size: 9px;
}

/* === Detail panel (black, per reference) ================================= */

.cm-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 372px;
    max-width: 92vw;
    background: #101010;
    color: #EDEAE4;
    border-left: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: var(--shadow-lg);
    z-index: 35;
    display: flex;
    flex-direction: column;
    transform: translateX(105%);
    transition: transform 0.24s ease;
}

.cm-panel.is-open {
    transform: translateX(0);
}

.cm-panel-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 14px 20px 24px;
}

.cm-panel-handle {
    display: none;
    padding: 8px 0 4px;
    cursor: grab;
    touch-action: none;
    flex-shrink: 0;
}

.cm-panel-handle i {
    display: block;
    width: 44px;
    height: 4px;
    margin: 0 auto;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.35);
}

.cm-panel.is-sheet-drag {
    transition: none;
}

.cm-panel-x {
    position: absolute;
    top: 8px;
    right: 12px;
    width: 28px;
    height: 28px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 2px;
    background: #101010;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    z-index: 2;
    color: #EDEAE4;
}

.cm-panel-x:hover {
    background: var(--accent-main);
    border-color: var(--accent-main);
    color: #fff;
}

.cm-panel-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 30px 10px 0;
    margin-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.16);
    font-family: var(--font-mono);
    font-size: 9.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: rgba(255, 255, 255, 0.6);
}

.cm-panel-id {
    margin-left: auto;
    color: rgba(255, 255, 255, 0.35);
    font-weight: 400;
}

.cm-panel-cover {
    width: 100%;
    height: 200px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 2px;
    background: #1A1A1A;
    overflow: hidden;
    margin-bottom: 14px;
}

.cm-panel-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.cm-panel-cover .cm-initial {
    display: flex;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
    font-family: var(--font-serif);
    font-style: normal;
    font-weight: 600;
    font-size: 56px;
    color: rgba(255, 255, 255, 0.25);
}

.cm-panel h2 {
    font-family: var(--font-serif);
    font-size: 25px;
    font-weight: 600;
    line-height: 1.12;
    margin: 0 0 4px;
    color: #fff;
}

.cm-panel-date {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.05em;
    color: rgba(255, 255, 255, 0.55);
    margin-bottom: 12px;
}

.cm-panel-facts {
    margin: 0 0 4px;
}

.cm-panel-facts div {
    display: flex;
    gap: 10px;
    padding: 3px 0;
}

.cm-panel-facts dt {
    flex: 0 0 96px;
    font-family: var(--font-mono);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.4);
    padding-top: 1px;
}

.cm-panel-facts dd {
    margin: 0;
    font-family: var(--font-mono);
    font-size: 11px;
    color: rgba(255, 255, 255, 0.8);
}

.cm-panel h3 {
    font-family: var(--font-mono);
    font-size: 9.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: rgba(255, 255, 255, 0.45);
    margin: 16px 0 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.14);
    padding-top: 12px;
}

.cm-panel-desc {
    font-family: var(--font-serif);
    font-size: 14px;
    line-height: 1.55;
    color: rgba(255, 255, 255, 0.82);
    margin: 0 0 6px;
}

.cm-panel-loading {
    color: rgba(255, 255, 255, 0.35);
}

.cm-panel-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.cm-panel-tags button {
    padding: 4px 9px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 2px;
    background: none;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.04em;
    color: rgba(255, 255, 255, 0.75);
    cursor: pointer;
}

.cm-panel-tags button:hover,
.cm-panel-tags button.is-on {
    border-color: var(--accent-main);
    color: var(--accent-main);
}

.cm-panel-rel {
    display: flex;
    width: 100%;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border: 0;
    border-radius: 2px;
    background: none;
    text-align: left;
    cursor: pointer;
}

.cm-panel-rel:hover {
    background: rgba(255, 255, 255, 0.07);
}

.cm-panel-rel-thumb {
    flex: 0 0 30px;
    height: 30px;
    border-radius: 4px;
    overflow: hidden;
    background: #1A1A1A;
    border: 1px solid rgba(255, 255, 255, 0.25);
    position: relative;
}

.cm-panel-rel-thumb.is-round {
    border-radius: 50%;
}

.cm-panel-rel-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.cm-panel-rel-thumb .cm-initial {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-serif);
    font-style: normal;
    font-weight: 600;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.4);
}

.cm-panel-rel-body {
    min-width: 0;
}

.cm-panel-rel-body b {
    display: block;
    font-family: var(--font-serif);
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cm-panel-rel-body small {
    font-family: var(--font-mono);
    font-size: 9.5px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(255, 255, 255, 0.45);
}

.cm-panel-more {
    display: block;
    border: 0;
    background: none;
    cursor: pointer;
    text-align: left;
    font-family: var(--font-mono);
    font-size: 10px;
    color: rgba(255, 255, 255, 0.5);
    padding: 4px 8px;
}

button.cm-panel-more:hover {
    color: var(--accent-main);
}

.cm-panel-articles a {
    display: block;
    padding: 7px 8px;
    border-radius: 2px;
    font-family: var(--font-serif);
    font-size: 14px;
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    line-height: 1.3;
}

.cm-panel-articles a:hover {
    background: rgba(255, 255, 255, 0.07);
}

.cm-panel-articles a span {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-family: var(--font-serif);
    font-size: 12px;
    line-height: 1.4;
    color: rgba(255, 255, 255, 0.55);
    margin-top: 2px;
}

.cm-panel-articles a small {
    display: block;
    font-family: var(--font-mono);
    font-size: 9px;
    color: rgba(255, 255, 255, 0.4);
    margin-top: 2px;
}

.cm-panel-cta {
    display: block;
    margin-top: 18px;
    padding: 12px 16px;
    background: var(--accent-main);
    color: #fff;
    text-align: center;
    text-decoration: none;
    font-family: var(--font-mono);
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    border-radius: 2px;
}

.cm-panel-cta:hover {
    background: #B91010;
}

.cm-panel-share {
    display: block;
    width: 100%;
    margin-top: 8px;
    padding: 9px 16px;
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 2px;
    color: rgba(255, 255, 255, 0.75);
    text-align: center;
    font-family: var(--font-mono);
    font-size: 10.5px;
    letter-spacing: 0.06em;
    cursor: pointer;
}

.cm-panel-share:hover {
    border-color: #fff;
    color: #fff;
}

/* cluster member list (reuses the dark panel) */

.cm-panel-members {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 12px;
}

.cm-panel-member {
    display: flex;
    width: 100%;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border: 0;
    border-radius: 2px;
    background: none;
    text-align: left;
    cursor: pointer;
}

.cm-panel-member:hover {
    background: rgba(255, 255, 255, 0.07);
}

.cm-panel-member-cover {
    flex: 0 0 32px;
    height: 42px;
    border-radius: 3px;
    overflow: hidden;
    background: #1A1A1A;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.25);
}

.cm-panel-member-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.cm-panel-member-cover .cm-initial {
    display: flex;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
    font-family: var(--font-serif);
    font-style: normal;
    font-weight: 600;
    font-size: 15px;
    color: rgba(255, 255, 255, 0.4);
}

.cm-panel-member b {
    display: block;
    font-family: var(--font-serif);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    color: #fff;
}

.cm-panel-member small {
    font-family: var(--font-mono);
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(255, 255, 255, 0.45);
}

/* === Mobile ============================================================== */

@media (max-width: 980px) {
    .cm-bb-legend,
    .cm-bb-edgekey,
    .cm-bb-nav,
    .cm-bb-meta {
        display: none;
    }

    .cm-bottombar {
        min-height: 64px;
    }
}

@media (max-width: 760px) {
    .cm-root {
        height: calc(100vh - 56px);
        height: calc(100dvh - 56px);
    }

    .cm-topbar {
        gap: 8px;
        padding: 8px 10px;
    }

    .cm-title .cm-counts {
        display: none;
    }

    .cm-search-wrap {
        flex: 1 1 130px;
        order: 2;
    }

    .cm-search-key {
        display: none;
    }

    .cm-chips {
        order: 3;
        width: 100%;
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 2px;
        scrollbar-width: none;
    }

    .cm-tagselect {
        order: 4;
    }

    .cm-zoomctl {
        order: 2;
    }

    .cm-zoom-pct {
        display: none;
    }

    .cm-hint {
        display: none;
    }

    .cm-bb-jumps {
        padding: 8px 10px;
        justify-content: center;
    }

    .cm-bb-jumps h4 {
        display: none;
    }

    .cm-bb-btns {
        display: flex;
        gap: 4px;
    }

    .cm-bb-btns button {
        font-size: 9px;
        padding: 4px 6px;
    }

    .cm-bb-mini {
        padding: 8px 10px;
    }

    .cm-bb-mini h4 {
        display: none;
    }

    .cm-lanebar span {
        font-size: 8.5px;
        padding: 2px 6px 2px 5px;
    }

    .cm-panel {
        top: auto;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-width: none;
        height: 64%;
        border-left: 0;
        border-top: 1px solid rgba(255, 255, 255, 0.3);
        border-radius: 10px 10px 0 0;
        transform: translateY(108%);
    }

    .cm-panel.is-open {
        transform: translateY(0);
    }

    .cm-panel-handle {
        display: block;
    }

    .cm-panel-x {
        top: 12px;
    }

    .cm-panel-cover {
        height: 140px;
    }
}

/* touch targets on coarse pointers */
@media (pointer: coarse) {
    .cm-node.is-chip {
        height: 30px;
        max-width: 110px;
    }

    .cm-node.is-chip .cm-node-cover {
        flex: 0 0 24px;
        height: 24px;
    }

    .cm-cluster {
        height: 42px;
    }
}
