:root {
    --background-color: #1e1e1e;
    --text-default-color: #e0e0e0;
    --svg-background-color: #2a2a2a;
    --info-background-color: #2a2a2a;
    --reference-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;
    --component-edit-target-color: #4d8cff;

    --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 {
    height: 70%;
    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;
}

#references {
    height: 30%;
    display: flex;
    flex-direction: column;
    gap: 10px;

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

#references h3 {
    color: var(--text-default-color);
    margin: 0;
    transition: all 0.3s ease;
}

#references-list {
    display: flex;
    flex-direction: column;
    gap: 10px;

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

    margin: 0;
    padding: 0;
}

#references-list a {
    color: var(--text-default-color);
    text-decoration: none;
    transition: all 0.3s ease;
}

#references-list 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;
    }
}

/*
option:checked {
    background-color: green;
}
*/

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);
    }
}

.edit-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    justify-content: center;
    flex-grow: 1;
    padding: 0 10px;
}

/* TODO Play with some other styling ideas for these buttons */
.edit-button {
    height: 20%;
    border-radius: 10px;
    width: 100%;
}

textarea {
    flex-grow: 1;
    border: 0;
    font: inherit;
    background-color: var(--shape-fill-color);
    color: var(--text-default-color);
    border-radius: 10px;
    padding: 10px;
    resize: none;
    overflow-wrap: normal;
    transition: all 0.3s ease;

    &:focus {
        outline: none;
    }
}

#abstract-editor {
    margin-bottom: 10px;
    flex-grow: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

#abstract-editor .cm-editor {
    flex-grow: 1;
    min-height: 0;
    height: 100%;
}

#abstract-editor .cm-editor.cm-focused {
    outline: none;
}

.abstract-editor-buttons {
    display: flex;
    flex-direction: row;
    gap: 8px;
    flex-shrink: 0;
}

.abstract-editor-buttons button {
    flex: 1 1 0;
    min-width: 0;
    height: 26px;
    border-radius: 8px;
    padding: 0 10px;
}

.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;
}

/* Targeted item in component-edit mode: bright accent + glow makes it
   unmistakable against the dim editor canvas. */
#content rect.component-edit-target,
#content polygon.component-edit-target {
    fill: var(--component-edit-target-color) !important;
    stroke: var(--info-callout-color) !important;
    stroke-width: 3px !important;
    filter: drop-shadow(0 0 6px var(--info-callout-color));
}

/* Group highlight for all items belonging to the same imported component —
   weaker than the primary target so the boundary reads as "this whole chunk
   is one import," not as "this individual item is selected." */
#content rect.component-edit-target-group,
#content polygon.component-edit-target-group {
    fill: var(--component-edit-target-color) !important;
    stroke: var(--info-callout-color) !important;
    stroke-width: 2px !important;
    stroke-dasharray: 4 3 !important;
    opacity: 0.75;
}

/* Component editor */
.component-editor {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    padding: 0 10px;
    overflow-y: auto;
    /* .edit-container centers its children — fine for the 2-3-button menu, but
       for our tall form that clips the top of the first row. */
    justify-content: flex-start;
}

.component-editor .ce-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
    margin-bottom: 5px;
}

.component-editor .ce-meta {
    flex-wrap: wrap;
}

.component-editor .ce-row textarea,
.component-editor .ce-row .ce-input {
    flex-grow: 1;
    min-width: 0;
    height: 26px;
    border: 0;
    background-color: var(--shape-fill-color);
    color: var(--text-default-color);
    border-radius: 8px;
    padding: 2px 8px;
    font: inherit;

    &:focus {
        outline: none;
    }
}

.component-editor .ce-row textarea.ce-input {
    height: auto;
    min-height: 40px;
    resize: vertical;
}

.component-editor .ce-label {
    min-width: 90px;
    font-size: 0.85em;
    opacity: 0.85;
    flex-shrink: 0;
}

.component-editor .ce-meta {
    gap: 6px;
}

.advanced-row {
    display: flex;
    flex-direction: row;
    gap: 8px;
    margin-bottom: 5px;
}

.advanced-row button {
    flex: 1 1 0;
    min-width: 0;
}

.ce-bottom-row {
    display: flex;
    flex-direction: row;
    gap: 8px;
    margin-top: 10px;
    flex-shrink: 0;
}

.ce-bottom-row button {
    flex: 1 1 0;
    min-width: 0;
    height: 26px;
    border-radius: 8px;
    padding: 0 10px;
}

.ce-bottom-row .ce-advanced-active {
    background-color: var(--button-fill-color-active, #4a4a4a);
}

.component-editor .ce-section-sep {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 8px 0 4px;
    font-size: 0.8em;
    opacity: 0.6;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.component-editor .ce-section-sep::before,
.component-editor .ce-section-sep::after {
    content: '';
    flex: 1 1 0;
    border-top: 1px solid var(--shape-fill-color);
}

.component-editor .ce-pair {
    flex-wrap: nowrap;
}

.component-editor .ce-pair .ce-pair-half {
    flex: 1 1 0;
    min-width: 0;
    margin-bottom: 0;
    flex-wrap: nowrap;
}

.component-editor .ce-pair .ce-pair-half .ce-label {
    min-width: 0;
    flex-shrink: 0;
}

.component-editor .ce-pair .ce-pair-half .ce-input {
    min-width: 0;
}

.component-editor .ce-separator {
    width: 100%;
    border: 0;
    border-top: 1px solid var(--shape-fill-color);
    margin: 4px 0 9px 0;
}

.component-editor .ce-meta button,
.component-editor .ce-meta .ce-import-select {
    flex: 1 1 0;
    min-width: 0;
    height: 26px;
    border-radius: 8px;
    padding: 0 10px;
}

.component-editor .ce-import-select {
    /* The global `select` rule sets a different background/height; align with
       buttons in the meta row so the import affordance reads as one of them. */
    background: var(--button-fill-color);
    text-align: center;
    cursor: pointer;
}

.component-editor .ce-subgroup {
    border-left: 2px solid var(--shape-fill-color);
    padding-left: 8px;
    margin-top: 6px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.component-editor .ce-subheading {
    font-size: 0.9em;
    opacity: 0.7;
    margin-bottom: 2px;
}

.component-editor .ce-entry {
    background-color: rgba(255, 255, 255, 0.03);
    border-radius: 6px;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.component-editor .ce-imported {
    opacity: 0.85;
    background-color: rgba(255, 255, 255, 0.04);
    border-radius: 6px;
    padding: 8px;
}

.component-editor .ce-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 6px;
    background-color: var(--shape-fill-color);
    font-size: 0.85em;
    margin-bottom: 6px;
}

.component-editor .ce-radio {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.85em;
    cursor: pointer;
}

.component-editor button {
    height: 26px;
    border-radius: 8px;
    padding: 0 10px;
}