.hatg-wrap {
    position: relative;
    font-family: inherit;
    background: var(--hatg-bg, #111);
    border-radius: 4px;
    overflow: hidden;
    color: var(--hatg-text, #fff);
}

/* Header */
.hatg-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 12px;
    background: #1a1a1a;
    border-bottom: 1px solid #2a2a2a;
    flex-wrap: wrap;
    gap: 10px;
}

.hatg-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.hatg-filter-label {
    font-size: 11px;
    color: #ccc;
    white-space: nowrap;
}

.hatg-header input[type="range"] {
    width: 80px;
    accent-color: #e8774a;
    cursor: pointer;
}

/* Graph */
.hatg-graph {
    position: relative;
    width: 100%;
    background: var(--hatg-bg, #111);
    cursor: grab;
}
.hatg-graph:active { cursor: grabbing; }
.hatg-graph svg { display: block; }

.hatg-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #555;
    font-size: 13px;
}

/* Footer */
.hatg-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 12px;
    background: #1a1a1a;
    border-top: 1px solid #2a2a2a;
    gap: 10px;
}

.hatg-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex: 1;
}

/* Cluster toggle buttons */
.hatg-legend-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    padding: 3px 9px;
    border-radius: 3px;
    border: 1px solid #444;
    cursor: pointer;
    background: #222;
    color: #ddd;
    transition: opacity 0.15s;
    white-space: nowrap;
}
.hatg-legend-btn--on  { opacity: 1; }
.hatg-legend-btn--off { opacity: 0.35; }

.hatg-legend-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Action buttons */
.hatg-btn {
    background: #2a2a2a;
    border: 1px solid #444;
    color: #ddd;
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 3px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
    flex-shrink: 0;
}
.hatg-btn:hover { background: #383838; color: #fff; }
.hatg-btn[aria-pressed="true"] {
    background: #e8774a;
    border-color: #e8774a;
    color: #fff;
}
.hatg-btn--icon { padding: 4px 9px; font-size: 14px; }

/* Nodes */
.hatg-node { transition: opacity 0.5s; cursor: pointer; }
.hatg-node--cluster { cursor: default; }

/* Links */
.hatg-link { transition: stroke-opacity 0.5s, stroke 0.5s; }

/* Labels */
.hatg-label { pointer-events: none; user-select: none; transition: opacity 0.2s; }
.hatg-label--cluster { font-weight: 700; fill: #fff; }
.hatg-label--term    { fill: #ccc; }
.hatg-label--post    { fill: #999; }

/* Tooltip */
.hatg-tooltip {
    position: absolute;
    background: #1e1e1e;
    border: 1px solid #444;
    border-radius: 3px;
    padding: 6px 10px;
    font-size: 12px;
    color: #ddd;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    max-width: 220px;
    z-index: 10;
}
.hatg-tooltip--visible { opacity: 1; pointer-events: auto; }
.hatg-tooltip strong { display: block; color: #fff; margin-bottom: 2px; }
.hatg-tooltip span   { color: #aaa; font-size: 10px; }
.hatg-tooltip-link {
    display: inline-block;
    margin-top: 3px;
    color: #e8774a;
    font-size: 10px;
    text-decoration: none;
    pointer-events: auto;
}
.hatg-tooltip-link:hover { text-decoration: underline; }

/* View toggle */
.hatg-view-toggle {
    display: flex;
    border: 1px solid #444;
    border-radius: 4px;
    overflow: hidden;
}
.hatg-view-btn {
    background: #222;
    color: #aaa;
    border: none;
    font-size: 11px;
    padding: 5px 11px;
    cursor: pointer;
}
.hatg-view-btn + .hatg-view-btn { border-left: 1px solid #444; }
.hatg-view-btn[aria-pressed="true"] { background: #e8774a; color: #fff; }

/* Drilldown */
.hatg-drilldown {
    position: relative;
    width: 100%;
    background: var(--hatg-bg, #111);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px 0;
    overflow: auto;
}
#hatg-dd-sunburst { width: min(90%, 420px); }
#hatg-dd-sunburst svg text { fill: #1a1a1a; }
.hatg-dd-caption {
    text-align: center;
    font-size: 13px;
    color: var(--hatg-text, #fff);
    opacity: 0.7;
    margin: 10px 0 0;
}
.hatg-dd-preview {
    margin-top: 14px;
    padding: 12px 16px;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 8px;
    display: flex;
    gap: 10px;
    align-items: center;
    max-width: 320px;
}
.hatg-dd-preview-thumb {
    width: 48px;
    height: 48px;
    border-radius: 6px;
    background: #000;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.hatg-dd-preview-thumb img { width: 100%; height: 100%; object-fit: cover; }
.hatg-dd-preview-title {
    font-size: 13px;
    font-weight: 600;
    color: #eee;
    margin: 0 0 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}
.hatg-dd-preview-link { font-size: 12px; color: #e8774a; text-decoration: none; }

/* Fullscreen */
#hatg-wrap:fullscreen { background: #111; }
#hatg-wrap:fullscreen .hatg-graph { height: calc(100vh - 90px) !important; }

/* Post preview modal */
.hatg-modal {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 20;
}
.hatg-modal[aria-hidden="false"] { display: flex; }

.hatg-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
}

.hatg-modal-panel {
    position: relative;
    max-width: min(720px, 90%);
    max-height: 85%;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 6px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 1;
}

.hatg-modal-close {
    position: absolute;
    top: 8px;
    right: 10px;
    background: none;
    border: none;
    color: #aaa;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}
.hatg-modal-close:hover { color: #fff; }

.hatg-modal-media {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    border-radius: 4px;
    overflow: hidden;
    min-height: 120px;
}
.hatg-modal-media img,
.hatg-modal-media video {
    max-width: 100%;
    max-height: 60vh;
    display: block;
}
.hatg-modal-media iframe {
    width: min(640px, 80vw);
    aspect-ratio: 16 / 9;
    height: auto;
    border: 0;
}

.hatg-modal-title {
    color: #eee;
    font-size: 14px;
    font-weight: 600;
}

.hatg-modal-terms {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 12px;
}
.hatg-modal-term-row { color: #999; display: flex; align-items: center; gap: 6px; }
.hatg-modal-term-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.hatg-modal-term-tax { font-weight: 600; }
.hatg-modal-term-vals { color: #ccc; }

.hatg-modal-link {
    align-self: flex-start;
}
