.math-tool {
    --math-result-color: #69d9aa;
    --math-axis-x: #ff828a;
    --math-axis-y: #93d774;
    --math-axis-z: #84b9ff;
}

html[data-theme="light"] .math-tool {
    --math-result-color: #00784e;
    --math-axis-x: #b52d3a;
    --math-axis-y: #427125;
    --math-axis-z: #245eb1;
}

.math-heading {
    display: grid;
    gap: .5rem;
    margin: 1rem 0 1.5rem;
}

.math-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.8fr) minmax(0, 1fr);
    align-items: start;
    gap: var(--gap);
}

.math-panel {
    display: grid;
    gap: 1rem;
    padding: clamp(1rem, 3vw, 1.5rem);
    background: var(--card);
    border: 1px solid var(--card-edge);
}

.math-tool .btn {
    justify-self: start;
    background: var(--bg-soft);
    cursor: pointer;
}

.math-tool .btn:hover,
.math-tool .btn[aria-pressed="true"] {
    border-color: var(--accent);
    color: var(--accent);
}

.math-toolbar,
.math-view-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .4rem;
}

.math-toolbar {
    justify-content: space-between;
}

.math-view-controls .btn {
    padding: .4rem .65rem;
}

.math-viewport-help {
    font-size: .9rem;
}

.math-result {
    border-top: 1px solid var(--card-edge);
    padding-top: 1rem;
    display: grid;
    gap: .5rem;
}

.math-vector {
    min-width: 0;
    border: 0;
}

.math-vector legend {
    margin-bottom: .35rem;
    font-weight: 600;
}

.math-coordinates {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .5rem;
}

.math-coordinates .field {
    color: var(--muted);
    font-size: .85rem;
}

.math-coordinates input {
    min-width: 0;
    padding: .5rem;
}

.math-bounds-list,
.math-bound {
    display: grid;
    gap: .75rem;
}

.math-bound {
    border: 1px solid var(--card-edge);
    padding: .75rem;
}

.math-preview {
    display: block;
    width: 100%;
    height: clamp(18rem, 44vw, 30rem);
    background: var(--bg-soft);
    outline: 1px solid var(--card-edge);
    cursor: grab;
    touch-action: none;
}

.math-preview.is-dragging {
    cursor: grabbing;
}

.math-output {
    margin: 0;
    font-family: ui-monospace, monospace;
    line-height: 1.55;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.math-code {
    margin-top: var(--gap);
}

.math-code pre {
    overflow: auto;
    padding: 1rem;
    background: var(--bg-soft);
    border: 1px solid var(--card-edge);
    line-height: 1.55;
}

.math-copy-status {
    font-size: .9rem;
}

.math-copy-status:empty {
    height: 0;
    margin-block-start: -1rem;
}

@media (max-width: 760px) {
    .math-layout {
        grid-template-columns: minmax(0, 1fr);
    }
}
