:root {
    --background-color: #1e1e1e;
    --text-default-color: #e0e0e0;
    --svg-background-color: #2a2a2a;
    --info-background-color: #2a2a2a;
    --panel-background-color: #2a2a2a;

    --shape-fill-color: #3a3a3a;
    --shape-stroke-color: #555;
    --shape-hover-fill-color: #4a4a4a;
    --opacity: 0.5;

    --arrow-color: #444;

    --link-color: #00ffff;
    --info-callout-color: #ffd24a;

    --button-fill-color: #3a3a3a;
    --button-border-color: #555;
    --button-symbol-color: #e0e0e0;
    --button-hover-fill-color: #4a4a4a;
    --button-hover-symbol-color: #ffffff;
    --disabled-button-fill-color: #2a2a2a;
    --disabled-button-border-color: #3a3a3a;
    --disabled-button-symbol-color: #4a4a4a;

    --slider-background-color: #d0d0d0;
    --slider-button-color: #3a3a3a;
    --slider-checked-color: #00c0c0;

    --scrollbar-background-color: #f1f1f1;
    --scrollbar-button-color: #888;
    --scrollbar-hover-color: #555;
}

body {
    font-family: "Quicksand", sans-serif;
    font-weight: 350;
    background-color: var(--background-color);
    color: var(--text-default-color);
    margin: 0;
    transition: all 0.3s ease;
}

#main-container {
    display: flex;
    flex-direction: row;
    height: 98vh;
    gap: 10px;
    padding: 10px;
    min-height: 500px;
    position: relative;
}

#svg {
    flex-grow: 1;
    border-radius: 10px;
    padding: 10px;
    background-color: var(--svg-background-color);
    cursor: move;
    min-width: 450px;
    transition: all 0.3s ease;
}

#sidebar {
    display: flex;
    flex-direction: column;
    width: 30%;
    min-width: 300px;
    gap: 10px;
}

#info-overlay {
    position: absolute;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    border-radius: 10px;
}

.info-overlay-callouts {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.info-overlay-callouts .info-callout-arrow {
    fill: none;
    stroke: var(--info-callout-color);
    stroke-width: 1.5;
    stroke-linecap: round;
    opacity: 0.9;
}

.info-callout-label {
    color: var(--info-callout-color);
    font-size: 12.5px;
    line-height: 1.3;
    text-shadow: 0 0 4px rgba(0, 0, 0, 0.8);
    user-select: none;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
}

.info-callout-label.align-right { text-align: right; justify-content: flex-end; }
.info-callout-label.align-left { text-align: left; justify-content: flex-start; }
.info-callout-label.align-center { text-align: center; justify-content: center; }

.info-overlay-panel {
    background-color: rgba(42, 42, 42, 0.92);
    color: var(--text-default-color);
    border: 1px solid var(--arrow-color);
    border-radius: 10px;
    width: min(720px, 78%);
    max-height: 78%;
    font-size: 15px;
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    z-index: 1;
}

.info-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px 8px;
    flex-shrink: 0;
}

.info-title {
    font-size: 1.05em;
    font-weight: 500;
}

.info-close {
    background: transparent;
    color: var(--text-default-color);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    font-size: 1.4em;
    line-height: 1;
    cursor: pointer;

    &:hover {
        background-color: var(--button-hover-fill-color);
    }
}

.info-tabs {
    display: flex;
    gap: 4px;
    padding: 0 20px;
    border-bottom: 1px solid var(--shape-fill-color);
    flex-shrink: 0;
}

.info-tab {
    background: transparent;
    color: var(--text-default-color);
    height: 32px;
    border-radius: 6px 6px 0 0;
    padding: 0 14px;
    font-size: 0.9em;
    opacity: 0.7;
    cursor: pointer;

    &:hover {
        opacity: 1;
        background-color: rgba(255, 255, 255, 0.04);
    }

    &.active {
        opacity: 1;
        background-color: rgba(255, 255, 255, 0.06);
        border-bottom: 2px solid var(--slider-checked-color);
    }
}

.info-tab-content {
    padding: 16px 24px;
    overflow-y: auto;
    flex-grow: 1;
}

.info-tab-content p { margin: 0 0 10px; }
.info-tab-content ul { margin: 0 0 10px; padding-left: 20px; }
.info-tab-content li { margin-bottom: 6px; }

.info-tab-content code {
    background-color: rgba(255, 255, 255, 0.07);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 0.9em;
}

.info-tab-content pre {
    background-color: rgba(0, 0, 0, 0.35);
    border-radius: 6px;
    padding: 10px 12px;
    overflow-x: auto;
    font-size: 0.85em;
    margin: 0 0 10px;
}

.info-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px 14px;
    border-top: 1px solid var(--shape-fill-color);
    flex-shrink: 0;
    font-size: 0.85em;
}

.info-hint { opacity: 0.6; }

.info-details-hint {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--shape-fill-color);
    font-size: 0.85em;
    opacity: 0.75;
}

.info-docs-link {
    color: var(--link-color);
    text-decoration: none;

    &:hover { text-decoration: underline; }
}

#info {
    flex: 1 1 auto;
    min-height: 50%;
    display: flex;
    flex-direction: column;
    padding: 10px;
    font-size: 16px;
    line-height: 1.5;
    border-radius: 10px;
    overflow-y: auto;
    background-color: var(--info-background-color);
    transition: all 0.3s ease;
}

/* The sidebar content region: a bare flex column that stacks one or more
   panel slots. The box styling lives on `.rplib-panel` so multiple panels each
   read as their own card. Sizes to content between a 30% floor (so a single
   panel still fills a sensible box — see `.rplib-panel`) and a 50% cap, so
   adding panels grows the region without ever shrinking #info below half. */
#panels {
    flex: 0 1 auto;
    min-height: 30%;
    max-height: 50%;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
}

/* A single panel slot (or a transient error takeover). Defaults to
   PANEL_BACKGROUND; a panel can override the background via its `theme` key. */
.rplib-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;

    /* Grow to fill the region. A lone panel fills it entirely (matching the old
       fixed-height references box); multiple panels share it by content size.
       `min-height: 0` + `overflow-y` lets each panel scroll its own overflow. */
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;

    padding: 10px 10px 10px 15px;
    background-color: var(--panel-background-color);
    border-radius: 10px;
    transition: all 0.3s ease;
}

.rplib-panel h3 {
    color: var(--text-default-color);
    margin: 0;
    transition: all 0.3s ease;
}

/* Generic list + link styling for panel content (e.g. a references list). Not
   references-specific — any panel that renders a <ul>/<a> picks these up. */
.rplib-panel ul {
    display: flex;
    flex-direction: column;
    gap: 10px;

    list-style-type: none;
    overflow-y: auto;

    margin: 0;
    padding: 0;
}

.rplib-panel a {
    color: var(--text-default-color);
    text-decoration: none;
    transition: all 0.3s ease;
}

.rplib-panel a:hover {
    color: var(--link-color);
    text-decoration: underline;
    transition: all 0.3s ease;
}

.switch-container {
    display: flex;
    flex-direction: row;
    gap: 10px;
    align-items: center;
    margin-bottom: 5px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 30px;
    height: 18px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--slider-background-color);
    -webkit-transition: .4s ease;
    transition: .4s ease;
    border-radius: 18px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 2px;
    bottom: 2px;
    background-color: var(--slider-button-color);
    -webkit-transition: .4s ease;
    transition: .4s ease;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--slider-checked-color);
    transition: all 0.3s ease;
}

input:focus+.slider {
    box-shadow: 0 0 1px var(--slider-checked-color);
    transition: all 0.3s ease;
}

input:checked+.slider:before {
    -webkit-transform: translateX(12px);
    -ms-transform: translateX(12px);
    transform: translateX(12px);
}

.nav-button {
    cursor: pointer;
    transition: all 0.3s ease;
}

.nav-button rect,
.nav-button path {
    transition: all 0.3s ease;
}

.clickable {
    cursor: pointer;
}

.latex-label:hover {
    cursor: default;
}

.latex-label[data-link]:hover {
    cursor: pointer;
}

::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--scrollbar-background-color);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-button-color);
    border-radius: 10px;
    transition: all 0.3s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-hover-color);
    cursor: pointer;
    transition: all 0.3s ease;
}

select {
    appearance: none;
    border: 0;
    font: inherit;
    text-align: center;
    padding-bottom: 2px;
    background: var(--shape-fill-color);
    color: var(--text-default-color);
    border-radius: 18px;
    cursor: pointer;
    height: 24px;
    flex-grow: 1;
    transition: all 0.3s ease;

    &:focus {
        outline: none;
    }
}

button {
    font: inherit;
    border: 0;
    text-align: center;
    height: 30px;
    background-color: var(--button-fill-color);
    color: var(--text-default-color);
    border-radius: 15px;
    cursor: pointer;
    padding: 0;
    transition: all 0.3s ease;

    &:hover {
        background-color: var(--button-hover-fill-color);
    }
}

.view-title {
    padding-bottom: 4px;
    margin-bottom: 8px;
    font-size: 1.2em;
    text-align: center;
    border-bottom: 2px solid var(--shape-fill-color);
    transition: all 0.3s ease;
}

.view-container {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.view-item {
    cursor: pointer;
    display: flex;
    padding-left: 5px;

    &:hover {
        background-color: var(--shape-fill-color);
    }
}

.expand-icon {
    cursor: pointer;
    margin: 4px;
    color: var(--text-default-color);
    font-size: 0.6em;
    transition: transform 0.2s ease-in-out;
    transform: rotate(90deg);
}

.view-children {
    display: flex;
    flex-direction: column;
    padding-left: 9px;
    margin-left: 13px;
    border-left: 2px solid var(--shape-fill-color);
    transition: all 0.3s ease;
}

#github-button {
    position: absolute;
    bottom: 20px;
    left: 20px;
    width: 32px;
    height: 32px;
    background-color: var(--button-fill-color);
    border: 1px solid var(--button-border-color);
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1000;
    color: var(--button-symbol-color);
    text-decoration: none;
    transition: all 0.3s ease;

    &:hover {
        background-color: var(--button-hover-fill-color);
        color: var(--button-hover-symbol-color);
    }
}

#github-button svg {
    width: 24px;
    height: 24px;
}

#content rect:hover,
#content polygon:hover {
    fill: var(--shape-hover-fill-color);
}

.force-hover {
    fill: var(--shape-hover-fill-color) !important;
}
