:root {
    --ui-font: "Segoe UI Variable", "Segoe UI", Arial, Helvetica, sans-serif;
    --math-font: "Cambria Math", Cambria, "STIX Two Math", "Times New Roman", serif;
    --tutor-bg: #f9f9f9;
    --tutor-text: #17202a;
    --tutor-muted: #65727d;
    --tutor-line: #d9e1df;
    --tutor-blue: #0066AA;
    --tutor-blue-dark: #00447F;
    --tutor-blue-soft: #eaf4fb;
    --tutor-yellow: #fff4d8;
    --tutor-green: #edf7ef;
    --tutor-green-strong: #1d6b36;
    --tutor-red: #c94444;
    --main-cell-min: clamp(44px, 4.2vw, 62px);
    --main-cell-size: clamp(54px, 4.8vw, 70px);
    --main-cell-font: clamp(1.12rem, 1.45vw, 1.48rem);
    --formula-box-width: clamp(58px, 6vw, 90px);
    --formula-box-height: clamp(48px, 5vw, 70px);
    --math-font-size: clamp(1.12rem, 1.65vw, 1.55rem);
    --operator-font-size: clamp(1.45rem, 2.1vw, 1.95rem);
    --mini-cell-size: clamp(30px, 2.7vw, 36px);
    --mini-gap: 4px;
    --border-radius: 8px;
    --box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

* {
    box-sizing: border-box;
}

html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

body.tutor-page {
    margin: 0;
    background: var(--tutor-bg);
    color: var(--tutor-text);
    font-family: var(--ui-font);
    line-height: 1.5;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

.site-header {
    position: relative;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    min-height: 70px;
    width: 100%;
    margin: 0 0 0.5rem;
    padding: 0.5rem 24px;
    color: #fff;
    background: linear-gradient(135deg, #00447F 0%, #0066AA 100%);
    border-radius: 0 0 var(--border-radius) var(--border-radius);
    box-shadow: var(--box-shadow);
}

.site-header::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="none"><path d="M0,0 L100,0 L100,100 Z" fill="rgba(255,255,255,0.1)"/></svg>');
    background-size: cover;
}

.site-header > * {
    position: relative;
    z-index: 1;
}

.brand {
    flex: 0 0 auto;
    color: #07385f;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.site-logo-badge {
    display: inline-flex;
    align-items: center;
    min-height: 43px;
    max-width: 100%;
    padding: 0 10px;
    color: #263d4f;
    background-color: rgba(255, 255, 255, 0.9);
    border: 0.9px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    box-shadow:
        inset 2.7px 2.7px 4.5px rgba(0, 0, 0, 0.2),
        inset -2.7px -2.7px 4.5px rgba(255, 255, 255, 0.8),
        0 1.8px 3.6px rgba(0, 0, 0, 0.1);
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    font-size: 18.5px;
    font-weight: 700;
    line-height: 1;
}

.brand-accent {
    margin-left: 1px;
    color: #1677B8;
    font-size: 0.88em;
    font-weight: 700;
}

.top-nav {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 16px;
    flex-wrap: wrap;
}

.top-nav a {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    color: #fff;
    font-size: 0.93rem;
    font-weight: 600;
    text-decoration: none;
}

.top-nav a:hover,
.top-nav a:focus-visible {
    color: #dff5ef;
    text-decoration: underline;
}

.language-selector {
    position: relative;
    display: flex;
    align-items: center;
    margin: 0;
    z-index: 1001;
}

.language-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 30px;
    margin: 0;
    padding: 6px 11px;
    color: #fff;
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.32);
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
}

.language-toggle::after {
    content: "\25BE";
    margin-left: 5px;
    font-size: 0.7rem;
}

.language-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    display: none;
    width: 107px;
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1002;
}

.language-selector:hover .language-dropdown,
.language-selector:focus-within .language-dropdown,
.language-dropdown.active {
    display: block;
}

.language-selector .language-dropdown .language-option {
    display: block;
    padding: 8px 12px;
    color: #075fa8;
    background: #fff;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
}

.language-selector .language-dropdown .language-option:hover,
.language-selector .language-dropdown .language-option:focus,
.language-selector .language-dropdown .language-option:focus-visible {
    color: #064f8a;
    background: #eef6ff;
    text-decoration: none;
}

.language-selector .language-dropdown .language-option.active,
.language-selector .language-dropdown .language-option[aria-current="page"] {
    color: #075fa8;
    background: #e7f1fb;
}

.language-selector .language-dropdown .language-option:last-child {
    border-bottom: 0;
}

.globe-icon {
    margin-right: 5px;
    font-size: 0.9em;
}

.tutor-main {
    max-width: 1360px;
    margin: 0 auto;
    padding: 18px 20px 56px;
}

.tutor-intro {
    max-width: 880px;
    margin: 0 auto 16px;
    text-align: center;
}

.tutor-intro h1 {
    margin-bottom: 8px;
    color: #142631;
    font-size: clamp(2rem, 3vw, 2.7rem);
    font-weight: 700;
    line-height: 1.1;
}

.tutor-intro p {
    margin: 0 auto;
    color: #29485D;
    font-size: 1.08rem;
}

.tutor-card,
.work-canvas,
.final-panel {
    background: #fff;
    border: 1px solid var(--tutor-line);
    border-radius: 8px;
    box-shadow: 0 14px 32px rgba(27, 39, 51, 0.07);
}

.tutor-card {
    padding: 18px;
}

.tutor-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    color: #41566a;
    font-size: clamp(1rem, 1.15vw, 1.16rem);
    font-weight: 500;
}

.tutor-status:empty {
    display: none;
}

.progress-edit {
    min-height: 36px;
    padding: 5px 10px;
    color: var(--tutor-blue-dark);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.progress-edit:hover,
.progress-edit:focus-visible {
    background: #f4f9fc;
    border-color: #a9c9dd;
}

.setup-flow,
.work-flow,
.final-summary {
    display: grid;
    gap: 18px;
}

.setup-size {
    text-align: center;
}

.setup-size h2 {
    margin-bottom: 10px;
    color: #25384a;
    font-size: 1.1rem;
    font-weight: 650;
}

.size-options,
.action-row,
.start-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.matrix-product-layout,
.workspace-equation {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(14px, 2vw, 28px);
    max-width: 100%;
}

.workspace-equation {
    overflow-x: auto;
    padding: 2px 2px 12px;
}

.work-canvas {
    display: grid;
    gap: 22px;
    padding: clamp(18px, 2.5vw, 34px);
    box-shadow: none;
}

.workspace-divider {
    height: 1px;
    background: #eef3f5;
}

.calculation-area {
    display: grid;
    justify-items: center;
    gap: 12px;
    min-width: 0;
    text-align: center;
}

.calculation-area h2 {
    margin-bottom: 0;
    color: #17202a;
    font-size: clamp(1.45rem, 2vw, 1.82rem);
    font-weight: 650;
}

.rule-line {
    margin-bottom: 4px;
    color: var(--tutor-muted);
    font-size: clamp(1.02rem, 1.35vw, 1.25rem);
    font-weight: 500;
}

.matrix-shell {
    display: grid;
    justify-items: center;
    gap: 5px;
    min-width: 0;
}

.matrix-shell h2 {
    margin: 0;
    color: #25384a;
    font-size: clamp(0.98rem, 1.15vw, 1.12rem);
    font-weight: 600;
}

.bracket-matrix {
    position: relative;
    display: inline-block;
    max-width: 100%;
    padding: clamp(8px, 1vw, 12px) clamp(15px, 1.5vw, 20px);
}

.bracket-matrix::before,
.bracket-matrix::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    width: 12px;
    pointer-events: none;
}

.bracket-matrix::before {
    left: 0;
    border-left: 3px solid #333;
    border-top: 3px solid #333;
    border-bottom: 3px solid #333;
}

.bracket-matrix::after {
    right: 0;
    border-right: 3px solid #333;
    border-top: 3px solid #333;
    border-bottom: 3px solid #333;
}

.entry-grid,
.matrix-display,
.result-grid {
    display: grid;
    gap: clamp(4px, 0.55vw, 7px);
    width: max-content;
    max-width: 100%;
}

.entry-grid input,
.formula-input {
    width: 100%;
    min-height: var(--formula-box-height);
    padding: 4px 7px;
    color: var(--tutor-text);
    background: #fff;
    border: 1px solid #bccbd5;
    border-radius: 4px;
    font-family: var(--math-font);
    font-size: clamp(1.18rem, 1.65vw, 1.5rem);
    font-weight: 400;
    line-height: 1;
    text-align: center;
}

.entry-grid input {
    min-width: 0;
    font-size: clamp(1.65rem, 2.2vw, 2rem);
}

.entry-grid input.is-wrong {
    background: #fff7f7;
    border-color: var(--tutor-red);
    box-shadow: 0 0 0 3px rgba(201, 68, 68, 0.16);
}

.matrix-cell,
.result-cell {
    display: grid;
    place-items: center;
    min-width: 0;
    width: 100%;
    height: var(--main-cell-size);
    padding: 3px 7px;
    color: #17202a;
    border: 2px solid transparent;
    border-radius: 5px;
    font-family: var(--math-font);
    font-weight: 400;
    font-size: var(--main-cell-font);
    line-height: 1;
    white-space: nowrap;
}

.result-cell {
    color: #53616b;
    background: #f8fafc;
    border-color: #edf2f5;
}

.row-highlight {
    background: var(--tutor-blue-soft);
}

.col-highlight {
    background: var(--tutor-yellow);
}

.active-position {
    border-color: var(--tutor-blue-dark);
    box-shadow: 0 0 0 3px rgba(0, 68, 127, 0.16);
}

.active-result {
    color: #12371d;
    background: var(--tutor-green);
}

.placed-result {
    color: var(--tutor-green-strong);
    background: var(--tutor-green);
    border-color: #b9dcc2;
}

.multiply-sign,
.equals-sign {
    flex: 0 0 auto;
    align-self: center;
    color: var(--tutor-blue-dark);
    font-size: clamp(1.8rem, 2.4vw, 2.35rem);
    font-family: var(--math-font);
    font-weight: 400;
    line-height: 1;
}

.formula-line {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: clamp(8px, 1vw, 12px);
    flex-wrap: wrap;
    max-width: 100%;
    color: #17202a;
    font-size: var(--math-font-size);
    font-family: var(--math-font);
    font-weight: 400;
}

.term-group {
    display: inline-flex;
    align-items: flex-start;
    gap: clamp(6px, 0.8vw, 10px);
    white-space: nowrap;
}

.operator {
    align-self: flex-start;
    margin-top: calc((var(--formula-box-height) - var(--operator-font-size)) / 2);
    font-family: var(--math-font);
    font-weight: 400;
    font-size: var(--operator-font-size);
}

.formula-box,
.formula-input {
    display: inline-grid;
    place-items: center;
    width: var(--formula-box-width);
    min-width: var(--formula-box-width);
    height: var(--formula-box-height);
    border-radius: 5px;
}

.formula-box {
    padding: 4px 8px;
    color: #1d2a33;
    font-family: var(--math-font);
    font-weight: 400;
    background: #fff;
    border: 1px solid #c7d3dc;
}

.formula-box.is-waiting {
    background: #f5f8fa;
    border-color: #dbe4ea;
}

.formula-box.is-waiting::before {
    content: "";
}

.formula-box.result-box,
.formula-input.result-input {
    color: #12371d;
    background: var(--tutor-green);
    border-color: #84bd90;
}

.formula-input {
    border: 2px solid var(--tutor-blue-dark);
    box-shadow: 0 0 0 3px rgba(0, 68, 127, 0.16);
}

.formula-input.is-wrong {
    color: #7e1f1f;
    background: #fff7f7;
    border-color: var(--tutor-red);
    box-shadow: 0 0 0 3px rgba(201, 68, 68, 0.18);
    animation: answer-shake 320ms ease-in-out;
}

.answer-slot {
    position: relative;
    display: inline-grid;
    justify-items: center;
    vertical-align: top;
    z-index: 2;
}

.answer-cue {
    display: inline-grid;
    justify-items: center;
    gap: 7px;
    margin-top: 3px;
    max-width: min(82vw, 320px);
}

.expression-cue {
    --cue-arrow-width: 1.45rem;
    --cue-padding-left: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    justify-self: start;
    width: max-content;
    max-width: min(86vw, 300px);
    margin-left: calc(50% - (var(--cue-padding-left) + (var(--cue-arrow-width) / 2)));
    padding: 8px 10px 8px 12px;
    color: #5a4523;
    background: #fffaf0;
    border: 1px solid #efd9ad;
    border-radius: 14px;
    box-shadow: none;
    white-space: nowrap;
}

.cue-controls {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 38px;
}

.cue-arrow {
    display: inline-grid;
    place-items: center;
    height: 34px;
    color: var(--tutor-blue-dark);
    font-size: 2.15rem;
    font-weight: 600;
    line-height: 1;
}

.show-step-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 9px 14px;
    color: #2f61b5;
    background: #fff;
    border: 1px solid #c7d8f3;
    border-radius: 15px;
    font: inherit;
    font-size: clamp(1.02rem, 1.22vw, 1.16rem);
    font-weight: 600;
    cursor: pointer;
}

.show-step-button:disabled {
    opacity: 0.62;
    cursor: wait;
}

.mini-help {
    width: 42px;
    min-width: 42px;
    min-height: 42px;
    padding: 0;
    color: #2f61b5;
    background: #fff;
    border: 2px solid currentColor;
    border-radius: 999px;
}

.help-icon-mark {
    display: inline-grid;
    place-items: center;
    width: 1.55em;
    height: 1.55em;
    color: #2f61b5;
    border: 2px solid currentColor;
    border-radius: 999px;
    font-size: 0.9em;
    font-family: var(--ui-font);
    font-weight: 650;
    line-height: 1;
}

.mini-help .help-icon-mark {
    width: 1.55rem;
    height: 1.55rem;
    color: #2f61b5;
    font-size: 1rem;
}

.bottom-help {
    justify-self: center;
}

.mini-product {
    display: inline-flex;
    align-items: center;
    gap: clamp(10px, 1.25vw, 14px);
    padding: 10px 12px;
    color: #273846;
    background: #fbfdff;
    border: 1px solid #e4edf2;
    border-radius: 6px;
}

.mini-matrix-shell {
    display: grid;
    justify-items: center;
    gap: 6px;
}

.mini-label {
    color: #4b5f70;
    font-size: clamp(0.9rem, 1vw, 1rem);
    font-weight: 600;
    line-height: 1;
}

.mini-grid {
    display: grid;
    gap: var(--mini-gap);
    position: relative;
    padding: 8px 12px;
}

.mini-grid::before,
.mini-grid::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    width: 8px;
    pointer-events: none;
}

.mini-grid::before {
    left: 0;
    border-left: 2px solid #333;
    border-top: 2px solid #333;
    border-bottom: 2px solid #333;
}

.mini-grid::after {
    right: 0;
    border-right: 2px solid #333;
    border-top: 2px solid #333;
    border-bottom: 2px solid #333;
}

.mini-cell {
    width: var(--mini-cell-size);
    height: var(--mini-cell-size);
    background: #f2f5f7;
    border: 1px solid #dfe7ec;
    border-radius: 2px;
}

.mini-row {
    background: var(--tutor-blue-soft);
}

.mini-col {
    background: var(--tutor-yellow);
}

.mini-active {
    border-color: var(--tutor-blue-dark);
    border-width: 3px;
    box-shadow: 0 0 0 3px rgba(0, 68, 127, 0.18);
}

.mini-operator,
.cue-inline-arrow {
    color: var(--tutor-blue-dark);
    font-family: var(--math-font);
    font-weight: 400;
}

.cue-inline-arrow {
    display: inline-grid;
    place-items: center;
    width: var(--cue-arrow-width);
    color: #2f61b5;
    font-size: 1.45rem;
    line-height: 1;
}

.guide-expression {
    color: #233646;
    font-family: var(--math-font);
    font-size: clamp(1.08rem, 1.45vw, 1.28rem);
    font-weight: 400;
    line-height: 1;
}

.cell-complete-line,
.inline-status {
    margin: 8px 0;
    color: #173f24;
    font-family: var(--math-font);
    font-size: clamp(1.08rem, 1.5vw, 1.28rem);
    font-weight: 400;
}

.matrix-equation-label {
    margin: 8px 0;
    color: #173f24;
    font-weight: 500;
}

.size-button,
.action-button,
.secondary-button,
.ghost-button {
    min-height: 38px;
    padding: 8px 12px;
    border-radius: 6px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.size-button {
    color: #29485D;
    background: #F4F9FC;
    border: 1px solid #A9C9DD;
}

.action-button {
    color: #fff;
    background: linear-gradient(135deg, #1677B8 0%, #1E80C1 100%);
    border: 1px solid #1677B8;
}

.secondary-button {
    color: #00447F;
    background: #f7fbff;
    border: 1px solid #8db9dc;
}

.ghost-button {
    color: #29485D;
    background: #F4F9FC;
    border: 1px solid #A9C9DD;
}

.size-button.is-selected {
    color: #fff;
    background: var(--tutor-blue);
    border-color: var(--tutor-blue);
}

.size-button:hover,
.size-button:focus-visible,
.secondary-button:hover,
.secondary-button:focus-visible,
.ghost-button:hover,
.ghost-button:focus-visible,
.show-step-button:hover,
.show-step-button:focus-visible {
    border-color: #8fb4ee;
    background: #f6faff;
    box-shadow: 0 0 0 3px rgba(0, 102, 170, 0.13);
}

.feedback {
    margin: 12px auto 0;
    max-width: 760px;
    padding: 10px 12px;
    color: #29485D;
    background: #f4f9fc;
    border: 1px solid #c8dce9;
    border-radius: 6px;
}

.feedback.is-warning {
    color: #5a3a06;
    background: var(--tutor-yellow);
    border-color: #e6c777;
}

.step-list {
    display: grid;
    gap: 6px;
    margin: 10px 0;
    padding: 0;
    list-style: none;
}

.step-list li {
    padding: 7px 9px;
    background: #f8fbfe;
    border: 1px solid #d8e5ef;
    border-radius: 5px;
    font-family: var(--math-font);
    font-weight: 400;
}

.summary-grid {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    width: 100%;
    overflow-x: auto;
}

.final-panel {
    display: grid;
    gap: 12px;
    padding: 18px;
    box-shadow: none;
    text-align: center;
}

.solution-summary {
    display: none;
}

.solution-summary.is-open {
    display: grid;
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
    outline: 3px solid rgba(0, 102, 170, 0.32);
    outline-offset: 3px;
}

@keyframes answer-shake {
    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-4px);
    }

    50% {
        transform: translateX(4px);
    }

    75% {
        transform: translateX(-2px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .formula-input.is-wrong {
        animation: none;
    }
}

@media (max-width: 700px) {
    .site-header {
        align-items: flex-start;
        flex-direction: column;
        gap: 10px;
        padding-block: 10px;
    }

    .top-nav {
        justify-content: flex-start;
    }
}

@media (max-width: 768px) {
    :root {
        --main-cell-min: 42px;
        --main-cell-size: 54px;
        --main-cell-font: 1.08rem;
        --formula-box-width: 54px;
        --formula-box-height: 48px;
        --math-font-size: 1.05rem;
        --operator-font-size: 1.28rem;
        --mini-cell-size: 28px;
    }

    .setup-flow {
        gap: 14px;
    }

    .matrix-product-layout {
        flex-wrap: wrap;
    }

    .setup-product-layout {
        --main-cell-min: 52px;
        --main-cell-size: 54px;
        --formula-box-height: 54px;
        gap: 12px;
    }

    .setup-product-layout .bracket-matrix {
        padding: 7px 12px;
    }

    .setup-product-layout .entry-grid {
        gap: 4px;
    }

    .setup-product-layout .entry-grid input {
        font-size: 1.5rem;
    }

    .setup-product-layout .multiply-sign {
        font-size: 1.7rem;
    }

    .setup-product-layout:has(.entry-grid label:nth-child(9)) {
        --main-cell-min: 46px;
        --main-cell-size: 48px;
        --formula-box-height: 48px;
        flex-direction: column;
        gap: 8px;
    }

    .setup-product-layout:has(.entry-grid label:nth-child(9)) .multiply-sign {
        align-self: center;
        font-size: 1.55rem;
        line-height: 1;
    }

    .workspace-equation,
    .summary-grid {
        justify-content: flex-start;
    }

    .work-canvas > .workspace-equation {
        --main-cell-min: clamp(22px, 7vw, 32px);
        --main-cell-size: clamp(24px, 7.5vw, 34px);
        --main-cell-font: 0.9rem;
        justify-content: center;
        gap: clamp(5px, 1.5vw, 10px);
        overflow-x: visible;
    }

    .work-canvas > .workspace-equation .matrix-shell {
        flex: 0 1 auto;
        min-width: 0;
    }

    .work-canvas > .workspace-equation .matrix-shell h2 {
        font-size: 0.82rem;
        line-height: 1.15;
        white-space: nowrap;
    }

    .work-canvas > .workspace-equation .bracket-matrix {
        padding: 6px 9px;
    }

    .work-canvas > .workspace-equation .matrix-display,
    .work-canvas > .workspace-equation .result-grid {
        gap: 2px;
    }

    .work-canvas > .workspace-equation .matrix-cell,
    .work-canvas > .workspace-equation .result-cell {
        padding: 2px 3px;
        border-width: 1px;
        border-radius: 4px;
    }

    .work-canvas > .workspace-equation .active-position {
        box-shadow: 0 0 0 2px rgba(0, 68, 127, 0.16);
    }

    .work-canvas > .workspace-equation .multiply-sign,
    .work-canvas > .workspace-equation .equals-sign {
        width: 0.9em;
        font-size: 1.25rem;
        text-align: center;
    }

    .calculation-area {
        gap: 10px;
    }

    .formula-line {
        gap: 7px;
        row-gap: 8px;
        max-width: min(100%, 620px);
        font-size: 1rem;
    }

    .term-group {
        gap: 5px;
    }

    .operator {
        margin-top: calc((var(--formula-box-height) - var(--operator-font-size)) / 2);
    }

    .formula-box,
    .formula-input {
        padding-inline: 6px;
    }

    .product-line {
        --formula-box-width: 50px;
        --formula-box-height: 46px;
        gap: 6px;
    }

    .cue-controls {
        flex-direction: column;
        gap: 4px;
    }
}

@media (max-width: 560px) {
    :root {
        --main-cell-min: 38px;
        --main-cell-size: 48px;
        --main-cell-font: 1rem;
        --formula-box-width: 48px;
        --formula-box-height: 46px;
        --math-font-size: 1rem;
        --operator-font-size: 1.12rem;
        --mini-cell-size: 20px;
        --mini-gap: 3px;
    }

    .tutor-main {
        padding-inline: 10px;
    }

    .tutor-card,
    .work-canvas,
    .final-panel {
        padding: 12px;
    }

    .setup-flow {
        gap: 12px;
    }

    .top-nav {
        gap: 12px;
    }

    .tutor-intro p,
    .formula-line {
        font-size: 1rem;
    }

    .entry-grid,
    .matrix-display,
    .result-grid {
        gap: 3px;
    }

    .setup-product-layout {
        --main-cell-min: 50px;
        --main-cell-size: 52px;
        --formula-box-height: 52px;
        width: calc(100% + 24px);
        margin-inline: -12px;
        gap: 8px;
        flex-wrap: nowrap;
    }

    .setup-product-layout .bracket-matrix {
        padding: 6px 10px;
    }

    .setup-product-layout .bracket-matrix::before,
    .setup-product-layout .bracket-matrix::after {
        width: 10px;
        border-width: 2px;
    }

    .setup-product-layout .entry-grid input {
        font-size: 1.35rem;
    }

    .setup-product-layout .multiply-sign {
        width: 0.65em;
        font-size: 1.4rem;
        text-align: center;
    }

    .setup-product-layout:has(.entry-grid label:nth-child(9)) {
        --main-cell-min: 38px;
        --main-cell-size: 40px;
        --formula-box-height: 40px;
        flex-wrap: wrap;
        width: 100%;
        margin-inline: 0;
        gap: 6px;
    }

    .setup-product-layout:has(.entry-grid label:nth-child(9)) .bracket-matrix {
        padding: 5px 9px;
    }

    .setup-product-layout:has(.entry-grid label:nth-child(9)) .entry-grid input {
        font-size: 1.2rem;
    }

    .workspace-equation {
        padding-bottom: 10px;
    }

    .work-canvas > .workspace-equation {
        --main-cell-min: clamp(20px, 6vw, 24px);
        --main-cell-size: clamp(21px, 6.7vw, 28px);
        --main-cell-font: 0.74rem;
        width: calc(100% + 24px);
        margin-inline: -12px;
        gap: 3px;
        flex-wrap: nowrap;
        padding-inline: 0;
    }

    .work-canvas > .workspace-equation .matrix-shell h2 {
        font-size: 0.76rem;
    }

    .work-canvas > .workspace-equation .bracket-matrix {
        padding: 5px 6px;
    }

    .work-canvas > .workspace-equation .bracket-matrix::before,
    .work-canvas > .workspace-equation .bracket-matrix::after {
        width: 8px;
        border-width: 2px;
    }

    .work-canvas > .workspace-equation .multiply-sign,
    .work-canvas > .workspace-equation .equals-sign {
        width: 0.65em;
        font-size: 1rem;
    }

    .factor-line {
        --formula-box-width: clamp(27px, 7vw, 38px);
        --formula-box-height: clamp(27px, 7vw, 38px);
        position: relative;
        display: flex;
        align-items: flex-start;
        justify-content: center;
        gap: clamp(2px, 0.75vw, 5px);
        flex-wrap: nowrap;
        padding-bottom: 0;
    }

    .product-line {
        --formula-box-width: clamp(27px, 7vw, 38px);
        --formula-box-height: clamp(27px, 7vw, 38px);
        position: relative;
        display: flex;
        align-items: flex-start;
        justify-content: center;
        gap: clamp(2px, 0.75vw, 5px);
        flex-wrap: nowrap;
        padding-bottom: 0;
    }

    .factor-line:has(.factor-locator) {
        padding-bottom: 170px;
    }

    .product-line:has(.expression-cue) {
        padding-bottom: 56px;
    }

    .factor-line .term-group {
        gap: clamp(1px, 0.55vw, 3px);
    }

    .answer-cue {
        gap: 5px;
        max-width: min(78vw, 260px);
    }

    .factor-line .answer-slot,
    .product-line .answer-slot {
        position: relative;
    }

    .factor-line .factor-locator,
    .product-line .expression-cue {
        position: absolute;
        left: 50%;
        top: calc(100% + 4px);
    }

    .factor-line .factor-locator {
        transform: translateX(-50%);
    }

    .factor-line > .term-group:first-child .factor-locator {
        left: 0;
        justify-items: start;
        transform: none;
    }

    .factor-line > .term-group:first-child .factor-locator .cue-controls {
        margin-left: calc((var(--formula-box-width) - 36px) / 2);
    }

    .factor-line:not(:has(> .term-group:nth-child(5))) > .term-group:nth-child(3) .factor-locator,
    .factor-line > .term-group:nth-child(5) .factor-locator {
        right: 0;
        left: auto;
        justify-items: end;
        transform: none;
    }

    .factor-line:not(:has(> .term-group:nth-child(5))) > .term-group:nth-child(3) .factor-locator .cue-controls,
    .factor-line > .term-group:nth-child(5) .factor-locator .cue-controls {
        margin-right: calc((var(--formula-box-width) - 36px) / 2);
    }

    .factor-line > .operator,
    .product-line > .operator {
        flex: 0 0 auto;
        width: auto;
    }

    .factor-line .formula-box,
    .factor-line .formula-input,
    .product-line .formula-box,
    .product-line .formula-input {
        min-width: var(--formula-box-width);
        padding-inline: 3px;
        font-size: clamp(0.82rem, 3.7vw, 1rem);
    }

    .factor-line .operator,
    .product-line .operator {
        font-size: clamp(0.82rem, 3.4vw, 1rem);
    }

    .expression-cue {
        --cue-arrow-width: 1.2rem;
        --cue-padding-left: 8px;
        gap: 7px;
        max-width: min(78vw, 250px);
        padding: 7px 8px 7px var(--cue-padding-left);
        transform: translateX(calc(-1 * (var(--cue-padding-left) + (var(--cue-arrow-width) / 2))));
    }

    .product-line .result-input + .expression-cue {
        right: 0;
        left: auto;
        padding-right: calc(var(--formula-box-width) + 6px);
        transform: none;
    }

    .product-line .result-input + .expression-cue .cue-inline-arrow {
        position: absolute;
        top: 7px;
        right: calc((var(--formula-box-width) - var(--cue-arrow-width)) / 2);
    }

    .mini-product {
        gap: 7px;
        padding: 7px 8px;
    }

    .mini-grid {
        padding: 6px 9px;
    }

    .mini-help {
        width: 36px;
        min-width: 36px;
        min-height: 36px;
    }

    .cue-arrow {
        height: 28px;
        font-size: 1.75rem;
    }

    .guide-expression {
        font-size: 1rem;
    }

}

@media (max-width: 340px) {
    .work-canvas > .workspace-equation {
        --main-cell-min: 19px;
        --main-cell-size: 21px;
        gap: 2px;
    }
}

.tutor-editorial {
    max-width: 880px;
    margin: 36px auto 0;
    padding: clamp(24px, 4vw, 42px);
    color: #1f2d38;
    background: #fff;
    border: 1px solid var(--tutor-line);
    border-radius: 8px;
    box-shadow: 0 14px 32px rgba(27, 39, 51, 0.06);
}

.tutor-editorial h2 {
    margin-bottom: 14px;
    color: #142631;
    font-size: clamp(1.55rem, 2.4vw, 2rem);
    line-height: 1.2;
}

.tutor-editorial-kicker {
    margin-bottom: 18px;
    color: var(--tutor-blue-dark);
    font-size: 1.05rem;
    font-weight: 750;
    line-height: 1.45;
}

.tutor-editorial h3 {
    margin: 28px 0 10px;
    color: #203748;
    font-size: clamp(1.12rem, 1.45vw, 1.28rem);
    line-height: 1.3;
}

.tutor-editorial p,
.tutor-editorial li,
.tutor-editorial dd {
    color: #334958;
    font-size: 1rem;
    line-height: 1.72;
}

.tutor-editorial p {
    margin-bottom: 14px;
}

.tutor-editorial ol,
.tutor-editorial ul {
    margin: 0 0 18px;
    padding-left: 1.35rem;
}

.tutor-editorial li + li {
    margin-top: 7px;
}

.tutor-editorial dl {
    display: grid;
    gap: 10px;
    margin: 0 0 20px;
}

.tutor-editorial dt {
    color: #153f61;
    font-weight: 700;
}

.tutor-editorial dd {
    margin: -6px 0 0;
    padding-bottom: 10px;
    border-bottom: 1px solid #edf3f6;
}

.tutor-editorial-table-wrap {
    max-width: 100%;
    margin: 0 0 20px;
    overflow-x: auto;
}

.tutor-editorial-table {
    width: 100%;
    min-width: 620px;
    border-collapse: collapse;
    background: #fbfdff;
    border: 1px solid #dfe9ef;
}

.tutor-editorial-table th,
.tutor-editorial-table td {
    padding: 12px 14px;
    border-bottom: 1px solid #dfe9ef;
    text-align: left;
    vertical-align: top;
}

.tutor-editorial-table th {
    color: #153f61;
    background: #edf6fb;
    font-weight: 750;
}

.tutor-editorial-table td:first-child {
    width: 36%;
    color: #1d3445;
    font-weight: 650;
}

.tutor-editorial a {
    color: var(--tutor-blue);
    font-weight: 650;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

.tutor-editorial a:hover,
.tutor-editorial a:focus-visible {
    color: var(--tutor-blue-dark);
}

.tutor-editorial-links {
    display: grid;
    gap: 6px;
}

@media (max-width: 560px) {
    .tutor-editorial {
        margin-top: 26px;
        padding: 20px 16px;
    }

    .tutor-editorial-table {
        min-width: 540px;
    }
}
