.tool-math-pro {
    --tool-primary: #2563eb;
    --tool-primary-hover: #1d4ed8;
    --tool-primary-soft: #f1f6ff;
    --tool-surface: #ffffff;
    --tool-surface-raised: #f8fafc;
    --tool-border: #dce3ec;
    --tool-text: #202735;
    --tool-text-muted: #596579;
    --tool-radius-sm: 6px;
    --tool-radius-md: 6px;
    --tool-radius-lg: 8px;
    --tool-shadow-sm: 0 1px 2px rgba(15, 23, 42, .04);
    background: #f6f7f9;
    color: var(--tool-text);
    font-family: Arial, sans-serif;
    line-height: 1.6;
}

.dark-mode.tool-math-pro {
    --tool-primary: #3b82f6;
    --tool-primary-hover: #60a5fa;
    --tool-primary-soft: #17253d;
    --tool-surface: #1f1f1f;
    --tool-surface-raised: #202020;
    --tool-border: #444444;
    --tool-text: #e0e0e0;
    --tool-text-muted: #d0d4da;
    background: #121212;
}

.tool-math-pro>section:first-of-type {
    padding: 0;
}

.tool-math-pro>section:first-of-type>main,
.tool-math-pro>.math-app-shell,
.tool-math-pro .decomposition-tool,
.tool-math-pro .matrix-tool,
.tool-math-pro .eigen-tool {
    box-sizing: border-box;
    width: min(100%, 1220px);
    max-width: 1220px !important;
    margin: 0 auto;
    padding: 24px !important;
    background: var(--tool-surface);
}


.tool-math-pro .tool-hero,
.tool-math-pro .math-app-header {
    display: block !important;
    max-width: none;
    margin: 0 0 20px !important;
    font-size: 1rem !important;
    text-align: left !important;
}

.tool-math-pro .tool-hero h1,
.tool-math-pro .math-app-header h1 {
    max-width: 920px;
    margin: 0 0 8px !important;
    padding: 0;
    color: var(--tool-text);
    font-size: 2rem !important;
    font-weight: 700;
    letter-spacing: 0;
    line-height: 1.15;
    text-align: left;
}

.tool-math-pro .tool-hero p,
.tool-math-pro .math-app-header>p:last-child {
    max-width: 920px;
    margin: 0 !important;
    padding: 0 !important;
    color: var(--tool-text-muted);
    font-size: 1.08rem !important;
    line-height: 1.55;
    text-align: left !important;
}

.tool-math-pro .eyebrow,
.tool-math-pro .math-eyebrow {
    display: none;
}


.tool-math-pro .panel,
.tool-math-pro .math-control-card,
.tool-math-pro .math-visual-card,
.tool-math-pro .controls-panel,
.tool-math-pro .truth-table-container,
.tool-math-pro .help-strip,
.tool-math-pro .help-box,
.tool-math-pro .concept-grid article {
    box-sizing: border-box;
    border: 1px solid var(--tool-border);
    border-radius: 8px;
    background: var(--tool-surface);
    box-shadow: var(--tool-shadow-sm);
}

.tool-math-pro .panel,
.tool-math-pro .math-control-card,
.tool-math-pro .math-visual-card {
    padding: 18px !important;
}

.tool-math-pro .panel-header,
.tool-math-pro .math-card-heading {
    margin-bottom: 14px;
}

.tool-math-pro .panel-header h2,
.tool-math-pro .math-control-card h2,
.tool-math-pro .math-card-heading h2 {
    margin: 0 0 5px;
    color: var(--tool-text);
    font-size: 1.05rem;
    font-weight: 700;
    text-align: left;
}

.tool-math-pro .panel-header p,
.tool-math-pro .math-card-heading p {
    margin: 0;
    padding: 0;
    color: var(--tool-text-muted);
    font-size: .88rem;
    line-height: 1.45;
}


.tool-math-pro input:not([type="checkbox"]):not([type="range"]),
.tool-math-pro select,
.tool-math-pro textarea {
    box-sizing: border-box;
    border: 1px solid #c5ceda !important;
    border-radius: 6px !important;
    background: var(--tool-surface) !important;
    color: var(--tool-text) !important;
    font: inherit;
}

.dark-mode.tool-math-pro input:not([type="checkbox"]):not([type="range"]),
.dark-mode.tool-math-pro select,
.dark-mode.tool-math-pro textarea {
    border-color: #555 !important;
    background: #2a2a2a !important;
}

.tool-math-pro button {
    min-height: 38px !important;
    padding: 8px 12px !important;
    border: 1px solid var(--tool-primary) !important;
    border-radius: 6px !important;
    background: var(--tool-primary) !important;
    color: #fff !important;
    box-shadow: none !important;
    font-size: .9rem !important;
    font-weight: 700;
    transform: none !important;
}

.tool-math-pro button:hover {
    background: var(--tool-primary-hover) !important;
}

.tool-math-pro .secondary-button,
.tool-math-pro .ghost-button,
.tool-math-pro .mode-tab:not(.active) {
    border-color: #b8cdf8 !important;
    background: #f1f6ff !important;
    color: #17418d !important;
}

.dark-mode.tool-math-pro .secondary-button,
.dark-mode.tool-math-pro .ghost-button,
.dark-mode.tool-math-pro .mode-tab:not(.active) {
    border-color: #294673 !important;
    background: #17253d !important;
    color: #d9e7ff !important;
}


.tool-math-pro .workspace,
.tool-math-pro .lab-layout,
.tool-math-pro .math-app-shell {
    gap: 20px !important;
}

.tool-math-pro .eigen-tool .workspace,
.tool-math-pro .matrix-tool .workspace {
    grid-template-columns: minmax(0, 1fr) !important;
}


.tool-math-pro.tool-math-legacy .math-app-shell {
    display: grid;
    grid-template-columns: minmax(280px, 330px) minmax(0, 1fr) !important;
    align-items: start;
}

.tool-math-pro.tool-math-legacy .math-app-header {
    grid-column: 1 / -1;
}

.tool-math-pro.tool-math-legacy .math-control-card {
    grid-column: 1;
    grid-row: 2;
}

.tool-math-pro.tool-math-legacy .math-visual-card {
    grid-column: 2;
    grid-row: 2;
}

.tool-math-pro.tool-math-legacy .truth-table-container {
    grid-column: 2;
}

.tool-math-pro.tool-math-legacy .help-box {
    grid-column: 1 / -1;
}

.tool-math-pro .decomposition-tool .lab-layout {
    grid-template-columns: minmax(280px, 330px) minmax(0, 1fr) !important;
    align-items: start;
}

.tool-math-pro .decomposition-tool .side-rail {
    grid-template-columns: minmax(0, 1fr) !important;
}


.tool-math-pro .matrix-tool .workspace {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
}

.tool-math-pro .matrix-tool .workspace {
    padding: 0 !important;
}

.tool-math-pro .matrix-tool .workspace>* {
    width: 100%;
    max-width: none;
    margin: 0;
}

.tool-math-pro .matrix-tool .operations-panel,
.tool-math-pro .matrix-tool .result-panel {
    grid-column: 1 / -1;
}

.tool-math-pro .matrix-tool .operations-panel {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto;
    gap: 14px 20px;
    align-items: center;
    padding: 18px;
}

.tool-math-pro .matrix-tool .operations-copy h2 {
    margin: 0 0 4px;
    color: var(--tool-text);
    font-size: 1.05rem;
    text-align: left;
}

.tool-math-pro .matrix-tool .operations-copy p {
    margin: 0;
    padding: 0;
    color: var(--tool-text-muted);
    font-size: .88rem;
}

.tool-math-pro .matrix-tool .operations-copy p.is-error {
    color: #b91c1c;
    font-weight: 700;
}

.tool-math-pro .matrix-tool .operations-panel .action-cluster {
    grid-column: 2;
    grid-row: 1;
    justify-content: flex-end;
}

.tool-math-pro .matrix-tool .operations-panel .preset-bar {
    grid-column: 1 / -1;
    justify-content: flex-start;
}

.tool-math-pro .matrix-tool .operations-panel .status-message {
    grid-column: 1 / -1;
    margin: 0;
}

.tool-math-pro .dimension-controls {
    display: flex;
    gap: 8px;
    align-items: end;
}

.tool-math-pro .dimension-controls label {
    display: grid;
    gap: 4px;
    color: var(--tool-text-muted);
    font-size: .72rem;
    font-weight: 700;
}

.tool-math-pro .dimension-controls select {
    min-width: 66px;
    padding: 6px 8px;
}

.tool-math-pro .matrix-meta {
    align-items: end;
}

.tool-math-pro .method-summary,
.tool-math-pro .dimension-summary {
    border: 0;
    background: transparent;
    box-shadow: none;
    color: var(--tool-text-muted);
}

.tool-math-pro .matrix input {
    background: var(--tool-surface) !important;
}

.tool-math-pro .matrix input.is-inactive {
    background: var(--tool-surface-raised) !important;
    opacity: .42;
}

.tool-math-pro .result-card,
.tool-math-pro .empty-state,
.tool-math-pro .breakdown-card {
    border-color: var(--tool-border);
    border-radius: 6px;
    background: var(--tool-surface-raised);
    box-shadow: none;
}

.tool-math-pro .status-message {
    text-align: left;
}

.tool-math-pro .status-message.is-error,
.tool-math-pro .status-message.is-success {
    padding: 0;
    background: transparent;
}

.tool-math-pro .teaching-panel {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(280px, .9fr);
    gap: 18px;
    margin-top: 20px;
    padding: 18px;
    border: 1px solid var(--tool-border);
    border-radius: 8px;
    background: var(--tool-surface);
    box-shadow: var(--tool-shadow-sm);
}

.tool-math-pro .teaching-panel h2 {
    margin: 0 0 8px;
    color: var(--tool-text);
    font-size: 1.35rem;
    text-align: left;
}

.tool-math-pro .teaching-panel p {
    margin: 0;
    padding: 0;
    color: var(--tool-text-muted);
    font-size: .95rem;
    line-height: 1.6;
}

.tool-math-pro .concept-list {
    align-content: start;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.tool-math-pro .concept-list span {
    padding: 8px 10px;
    border: 1px solid #c9dcff;
    border-radius: 6px;
    background: #f1f6ff;
    color: #173b7a;
    font-size: .86rem;
    font-weight: 700;
}

.dark-mode.tool-math-pro .concept-list span {
    border-color: #294673;
    background: #17253d;
    color: #d9e7ff;
}

.tool-math-pro.tool-math-legacy .teaching-panel {
    grid-column: 1 / -1;
}

.tool-math-pro .truth-table-container tr.is-current td {
    box-shadow: inset 0 0 0 2px var(--tool-primary);
}

.tool-math-pro .truth-table-container tr.is-current td:first-child {
    border-left: 3px solid var(--tool-primary);
}


.tool-math-pro .explanation-section {
    width: min(calc(100% - 48px), 1172px) !important;
    max-width: 1172px !important;
    margin: 40px auto !important;
    padding: 30px !important;
    border: 1px solid var(--tool-border) !important;
    border-radius: 8px !important;
    background: var(--tool-surface) !important;
    box-shadow: var(--tool-shadow-sm) !important;
}

.tool-math-pro .explanation-content {
    display: flex !important;
    flex-direction: column;
    gap: 24px !important;
}

.tool-math-pro .explanation-card {
    padding: 24px !important;
    border: 0 !important;
    border-left: 4px solid var(--tool-primary) !important;
    border-radius: 8px;
    background: var(--tool-surface-raised);
    box-shadow: 0 2px 4px rgba(0, 0, 0, .05);
}

.tool-math-pro .section-header h2 {
    margin: 0 0 24px;
    padding: 0 0 12px;
    border-bottom: 2px solid var(--tool-primary);
    color: var(--tool-text);
    font-size: 1.8rem;
    text-align: left;
}

.tool-math-pro .explanation-card h3 {
    margin: 0 0 16px;
    color: var(--tool-text);
    font-size: 1.3rem;
    text-align: left;
}

.tool-math-pro .explanation-card p,
.tool-math-pro .explanation-card li {
    color: var(--tool-text-muted);
}

.tool-math-pro .formula-box {
    border: 2px solid var(--tool-primary);
    border-radius: 6px;
}

@media (max-width: 680px) {
    .tool-math-pro {
        background: var(--tool-surface);
    }

    .tool-math-pro>section:first-of-type>main,
    .tool-math-pro>.math-app-shell,
    .tool-math-pro .decomposition-tool,
    .tool-math-pro .matrix-tool,
    .tool-math-pro .eigen-tool {
        padding: 10px !important;
    }

    .tool-math-pro .tool-hero h1,
    .tool-math-pro .math-app-header h1 {
        font-size: 1.45rem !important;
    }

    .tool-math-pro .tool-hero p,
    .tool-math-pro .math-app-header>p:last-child {
        font-size: .96rem !important;
    }

    .tool-math-pro .panel,
    .tool-math-pro .math-control-card,
    .tool-math-pro .math-visual-card {
        padding: 12px !important;
        box-shadow: none;
    }

    .tool-math-pro .explanation-section {
        width: calc(100% - 20px) !important;
        padding: 16px !important;
        box-shadow: none !important;
    }

    .tool-math-pro .teaching-panel,
    .tool-math-pro .concept-list {
        grid-template-columns: minmax(0, 1fr);
    }

    .tool-math-pro.tool-math-legacy .math-app-shell,
    .tool-math-pro .decomposition-tool .lab-layout,
    .tool-math-pro .matrix-tool .workspace {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    .tool-math-pro.tool-math-legacy .math-app-header,
    .tool-math-pro.tool-math-legacy .math-control-card,
    .tool-math-pro.tool-math-legacy .math-visual-card,
    .tool-math-pro.tool-math-legacy .truth-table-container,
    .tool-math-pro.tool-math-legacy .help-box,
    .tool-math-pro .matrix-tool .result-panel {
        grid-column: auto;
        grid-row: auto;
    }

    .tool-math-pro .matrix-tool .operations-panel {
        grid-column: auto;
        grid-template-columns: minmax(0, 1fr);
    }

    .tool-math-pro .matrix-tool .operations-panel .action-cluster,
    .tool-math-pro .matrix-tool .operations-panel .preset-bar,
    .tool-math-pro .matrix-tool .operations-panel .status-message {
        grid-column: auto;
        grid-row: auto;
        justify-content: flex-start;
    }
}