/* =========================================
   POLYNOMIALS — INTRODUCTION
   ========================================= */

:root {
    --poly-page-bg: #f7f7f3;
    --poly-text: #303030;
    --poly-heading: #753ab5;
    --poly-muted: #666666;
    --poly-accent: #7C5C9E;
    --poly-border: #e3e3df;

    --poly-idea-bg: #F3EDF8;
    --poly-idea-border: #DFD0EA;

    --poly-example-bg: #f0faf3;
    --poly-example-border: #d8efdf;

    --poly-warm-bg: #fff7ed;
    --poly-warm-border: #f5dfc3;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--poly-page-bg);
    color: var(--poly-text);
    font-family: Georgia, "Times New Roman", serif;
    line-height: 1.6;
}

a {
    color: inherit;
}

button {
    font: inherit;
}

/* Header */

header {
    min-height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 6%;
    background: #f0f1f7;
    border-bottom: 1px solid #e1e2e8;
}

.logo {
    color: #252525;
    text-decoration: none;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.05rem;
    font-weight: 700;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 18px;
}

.chapter-info {
    color: #666b78;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 0.78rem;
}

.theme-button {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    padding: 0;
    background: #ffffff;
    color: #303030;
    border: 1px solid #d9dbe2;
    border-radius: 7px;
    cursor: pointer;
}

/* Page layout */

.lesson-page {
    min-height: calc(100vh - 58px);
    padding: 0 0 56px;
}

.lesson-content {
    width: 90%;
    max-width: 850px;
    margin: 0 auto;
    padding-top: 28px;
}

.lesson-progress {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    margin-bottom: 48px;
    color: var(--poly-muted);
    font-family: Georgia, "Times New Roman", serif;
    font-size: 0.8rem;
}

.chapter-back {
    color: var(--poly-muted);
    text-decoration: none;
}

.chapter-back:hover,
.lesson-footer a:hover {
    color: var(--poly-accent);
}

/* Introduction */

.lesson-introduction {
    max-width: 700px;
    margin: 0 auto 42px;
    text-align: center;
}

.chapter-label,
.key-idea-label,
.example-label,
.check-label,
.takeaway-label {
    margin: 0 0 12px;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.14em;
}

.chapter-label {
    color: var(--poly-accent);
}

.lesson-introduction h1 {
    margin: 0 0 18px;
    color: var(--poly-heading);
    font-size: clamp(2rem, 5vw, 2.5rem);
    line-height: 1.15;
}

.intro-description {
    max-width: 570px;
    margin: 0 auto;
    color: var(--poly-muted);
    font-size: 1.08rem;
    line-height: 1.7;
}

/* Explanatory sections */

.lesson-section {
    max-width: 700px;
    margin: 0 auto 28px;
    text-align: center;
}

.lesson-section h2,
.quick-check h2 {
    margin: 0 0 14px;
    color: var(--poly-heading);
    font-size: clamp(1.3rem, 3vw, 1.65rem);
    line-height: 1.35;
}

.lesson-section p,
.quick-check>p {
    margin: 0 0 14px;
    font-size: 1rem;
    line-height: 1.75;
}

.lesson-section strong {
    color: var(--poly-heading);
}

/* Example */

.example-box {
    margin: 0 auto 36px;
    padding: 24px clamp(16px, 4vw, 30px);
    text-align: center;
    background: var(--poly-example-bg);
    border: 1px solid var(--poly-example-border);
    border-left: 4px solid #18804a;
    border-radius: 14px;
}

.example-label {
    color: #18804a;
}

.cost-breakdown {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(14px, 4vw, 30px);
    margin: 18px 0;
}

.cost-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.cost-number {
    color: #245f3d;
    font-size: clamp(1.7rem, 5vw, 2.3rem);
    font-weight: 700;
    line-height: 1.3;
}

.cost-caption {
    color: #52645a;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 0.78rem;
}

.cost-plus {
    color: #18804a;
    font-size: 1.7rem;
}

.number-answer {
    margin: 20px auto;
    color: #222222;
    font-size: clamp(1.35rem, 4vw, 1.8rem);
    font-weight: 600;
    line-height: 1.5;
}

.math-highlight {
    color: var(--poly-accent);
}

.example-note {
    max-width: 560px;
    margin: 0 auto;
    color: #4d4d4d;
    font-size: 0.95rem;
    line-height: 1.7;
}

/* Worked calculation */

.calculation {
    margin: 20px auto;
    padding: 15px 12px;
    background: var(--poly-idea-bg);
    border: 1px solid var(--poly-idea-border);
    border-radius: 10px;
    color: var(--poly-heading);
    font-size: clamp(1.2rem, 4vw, 1.65rem);
    font-weight: 600;
    text-align: center;
}

.calculation strong {
    white-space: nowrap;
}

/* Key idea */

.key-idea {
    margin: 0 auto 38px;
    padding: 25px clamp(18px, 4vw, 30px);
    background: var(--poly-idea-bg);
    border: 1px solid var(--poly-idea-border);
    border-left: 4px solid var(--poly-accent);
    border-radius: 14px;
    text-align: center;
}

.key-idea-label {
    color: var(--poly-accent);
}

.key-idea h2 {
    margin: 0 0 14px;
    color: #242424;
    font-size: clamp(1.3rem, 3vw, 1.7rem);
    line-height: 1.4;
}

.key-idea p:last-child {
    margin: 0;
    color: #4d4d4d;
    font-size: 0.98rem;
    line-height: 1.7;
}

/* Quick check */

.quick-check {
    max-width: 700px;
    margin: 0 auto 38px;
    padding: 24px clamp(18px, 4vw, 28px);
    border: 1px solid var(--poly-border);
    border-radius: 14px;
    text-align: center;
}

.check-label {
    color: var(--poly-accent);
}

.quick-check h2 {
    margin-bottom: 12px;
}

.check-options {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
}

.check-option {
    min-width: 95px;
    padding: 10px 20px;
    background: #ffffff;
    color: #303030;
    border: 1px solid #d9dbe2;
    border-radius: 9px;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.check-option:hover {
    border-color: var(--poly-accent);
}

.check-option:focus-visible {
    outline: 2px solid var(--poly-accent);
    outline-offset: 3px;
}

.check-option.is-correct {
    background: #e6f7eb;
    border-color: #18804a;
    color: #145c34;
}

.check-option.is-wrong {
    background: #fff0ed;
    border-color: #c74b36;
    color: #8b2c1d;
}

.check-feedback {
    min-height: 1.6em;
    margin: 16px 0 0;
    font-size: 0.93rem;
    line-height: 1.6;
}

.feedback-correct {
    color: #18733f;
}

.feedback-wrong {
    color: #a13a2b;
}

/* Takeaway */

.takeaway {
    margin: 0 auto 30px;
    padding: 22px clamp(18px, 4vw, 28px);
    background: var(--poly-warm-bg);
    border: 1px solid var(--poly-warm-border);
    border-left: 4px solid #c96a16;
    border-radius: 14px;
    text-align: center;
}

.takeaway-label {
    color: #c96a16;
}

.takeaway p:last-child {
    margin: 0;
    color: #4d4d4d;
    font-size: 0.97rem;
    line-height: 1.7;
}

/* =========================================

   FOOTER

   ========================================= */



.minimal-footer {

    padding: 10px 20px;



    text-align: center;



    font-size: 0.74rem;



    color: #777;



    background: #ffffff;



    border-top: 1px solid #e5e5e5;

}

.footer-links {
    display: flex;
    gap: 20px;
    flex-wrap: wrap
}

.footer-links a {
    color: var(--muted);
    text-decoration: none;
    font-size: .8rem
}

.footer-links a:hover {
    color: var(--heading)
}




/* Dark mode */

body.dark {
    --poly-page-bg: #171821;
    --poly-text: #e6e6ec;
    --poly-heading: #C9AFE0;
    --poly-muted: #b0b1bf;
    --poly-accent: #BFA0D9;
    --poly-border: #383947;

    --poly-idea-bg: #2B2432;
    --poly-idea-border: #51405F;

    --poly-example-bg: #1d2b25;
    --poly-example-border: #345541;

    --poly-warm-bg: #30261e;
    --poly-warm-border: #59402c;
}

body.dark header {
    background: #20212b;
    border-bottom-color: #383947;
}

body.dark .logo,
body.dark .theme-button {
    color: #ededf4;
}

body.dark .chapter-info {
    color: #b0b1bf;
}

body.dark .theme-button {
    background: #292a36;
    border-color: #454656;
}

body.dark .key-idea h2,
body.dark .key-idea p:last-child,
body.dark .example-note,
body.dark .takeaway p:last-child {
    color: #e0e0e8;
}

body.dark .cost-number {
    color: #a9e5bd;
}

body.dark .cost-caption {
    color: #c0d6c8;
}

body.dark .number-answer {
    color: #f0f0f5;
}

body.dark .check-option {
    background: #252631;
    color: #eeeeF5;
    border-color: #454656;
}

body.dark .check-option.is-correct {
    background: #1c3828;
    color: #b5efc7;
    border-color: #3d8c5c;
}

body.dark .check-option.is-wrong {
    background: #3a2424;
    color: #ffc0b5;
    border-color: #a84f43;
}

body.dark .feedback-correct {
    color: #a9e5bd;
}

body.dark .feedback-wrong {
    color: #ffb4a8;
}

body.dark .minimal-footer {

    background: #181b20;

    border-color: #2a2e35;

    color: #8f949d;

}

/* Small screens */

@media (max-width: 520px) {
    header {
        padding: 10px 5%;
    }

    .header-right {
        gap: 10px;
    }

    .chapter-info {
        font-size: 0.7rem;
    }

    .lesson-content {
        width: 91%;
        padding-top: 22px;
    }

    .lesson-progress {
        align-items: flex-start;
        margin-bottom: 38px;
        font-size: 0.74rem;
    }

    .lesson-introduction {
        margin-bottom: 34px;
    }

    .lesson-section {
        margin-bottom: 25px;
    }

    .example-box {
        margin-bottom: 30px;
    }

    .check-options {
        gap: 8px;
    }

    .check-option {
        min-width: 82px;
        padding: 10px 15px;
    }
}



/* =========================================
   PREVIOUS / NEXT LESSON NAVIGATION
   ========================================= */

.lesson-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin: 36px auto 48px;
    padding-top: 24px;
    border-top: 1px solid var(--poly-border);
}

.next-lesson {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    min-width: min(100%, 260px);
    padding: 14px 18px;
    color: #ffffff;
    background: var(--poly-accent);
    border-color: var(--poly-accent);
    border-radius: 10px;
    text-decoration: none;
    transition: background 0.15s ease;
}

.next-lesson:hover {
    background: var(--poly-muted);
}

.next-lesson small,
.next-lesson strong {
    display: block;
}

.next-lesson small {
    margin-bottom: 4px;
    font-family: Arial, sans-serif;
    font-size: 0.65rem;
    letter-spacing: 0.12em;
    opacity: 0.85;
}

.next-lesson strong {
    font-size: 0.95rem;
    line-height: 1.4;
}

.navigation-arrow {
    font-family: Arial, sans-serif;
    font-size: 1.5rem;
}

/* Dark-mode navigation and footer */

body.dark .next-lesson {
    color: #102725;
    background: var(--poly-accent);
    border-color: var(--poly-accent);
}

body.dark .next-lesson:hover {
    background: var(--poly-muted);
}

@media (max-width: 520px) {
    .lesson-navigation {
        margin-bottom: 36px;
    }

    .next-lesson {
        min-width: 0;
        width: 100%;
    }
}

/* =========================================
   EXPRESSION BREAKDOWN
   ========================================= */

.expression-display {
    margin: 20px auto;
    color: var(--poly-heading);
    font-size: clamp(2rem, 6vw, 2.8rem);
    font-weight: 600;
    line-height: 1.4;
    text-align: center;
}

.expression-anatomy {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    max-width: 700px;
    margin: 0 auto 38px;
}

.expression-part {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 18px;
    background: #ffffff;
    border: 1px solid var(--poly-border);
    border-radius: 12px;
}

.part-symbol {
    flex: 0 0 auto;
    min-width: 42px;
    color: var(--poly-accent);
    font-size: 1.15rem;
    font-weight: 700;
    text-align: center;
}

.expression-part h3 {
    margin: 0 0 6px;
    color: var(--poly-heading);
    font-size: 1rem;
    line-height: 1.4;
}

.expression-part p {
    margin: 0;
    color: var(--poly-muted);
    font-size: 0.9rem;
    line-height: 1.6;
}

/* =========================================
   POLYNOMIAL EXAMPLES
   ========================================= */

.polynomial-example {
    padding: 10px 0;
    border-bottom: 1px solid var(--poly-example-border);
}

.polynomial-example:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.example-expression {
    display: block;
    margin-bottom: 6px;
    color: var(--poly-heading);
    font-size: clamp(1.45rem, 4vw, 1.8rem);
    font-weight: 600;
}

.example-status {
    display: inline-block;
    margin-bottom: 7px;
    color: #18804a;
    font-family: Arial, sans-serif;
    font-size: 0.76rem;
    font-weight: 700;
}

.polynomial-example p {
    margin: 0;
    color: #4d4d4d;
    font-size: 0.93rem;
    line-height: 1.6;
}

/* =========================================
   PREVIOUS LESSON LINK
   ========================================= */

.previous-lesson {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
    padding: 12px 0;
    color: var(--poly-text);
    text-decoration: none;
}

.previous-lesson small,
.previous-lesson strong {
    display: block;
}

.previous-lesson small {
    margin-bottom: 4px;
    color: var(--poly-muted);
    font-family: Arial, sans-serif;
    font-size: 0.65rem;
    letter-spacing: 0.1em;
}

.previous-lesson strong {
    font-size: 0.9rem;
    line-height: 1.4;
}

.previous-lesson:hover {
    color: var(--poly-accent);
}

/* =========================================
   DARK MODE
   ========================================= */

body.dark .expression-part {
    background: #20212b;
    border-color: var(--poly-border);
}

body.dark .polynomial-example p {
    color: #e0e0e8;
}

body.dark .example-status {
    color: #a9e5bd;
}

/* =========================================
   RESPONSIVE LAYOUT
   ========================================= */

@media (max-width: 600px) {
    .expression-anatomy {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .expression-part {
        padding: 16px;
    }

    .lesson-navigation {
        align-items: stretch;
        gap: 10px;
    }

    .previous-lesson {
        flex: 1;
        gap: 8px;
    }

    .previous-lesson strong {
        font-size: 0.8rem;
    }

    .next-lesson {
        flex: 1;
        gap: 10px;
        padding: 12px;
    }

    .next-lesson strong {
        font-size: 0.82rem;
    }
}

/* =========================================
   RECOGNISING POLYNOMIALS
   ========================================= */

.recognition-examples {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    max-width: 750px;
    margin: 0 auto 38px;
}

.recognition-card {
    padding: 20px;
    background: #ffffff;
    border: 1px solid var(--poly-border);
    border-radius: 12px;
}

.recognition-topline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 15px;
}

.recognition-tag {
    font-family: Arial, sans-serif;
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.recognition-symbol {
    display: grid;
    place-items: center;
    width: 25px;
    height: 25px;
    border-radius: 50%;
    font-family: Arial, sans-serif;
    font-weight: 700;
}

.is-polynomial .recognition-tag,
.is-polynomial .recognition-symbol {
    color: #18804a;
}

.is-polynomial .recognition-symbol {
    background: #e3f5e9;
}

.is-not-polynomial .recognition-tag,
.is-not-polynomial .recognition-symbol {
    color: #a34736;
}

.is-not-polynomial .recognition-symbol {
    background: #fff0ed;
}

.recognition-expression {
    margin-bottom: 12px;
    color: var(--poly-heading);
    font-size: clamp(1.25rem, 3.5vw, 1.65rem);
    font-weight: 600;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.recognition-card p {
    margin: 0;
    color: var(--poly-muted);
    font-size: 0.92rem;
    line-height: 1.7;
}

.recognition-options .check-option {
    min-width: 115px;
}

/* Dark mode */

body.dark .recognition-card {
    background: #20212b;
    border-color: var(--poly-border);
}

body.dark .is-polynomial .recognition-symbol {
    background: #1c3828;
    color: #a9e5bd;
}

body.dark .is-not-polynomial .recognition-symbol {
    background: #3a2424;
    color: #ffb4a8;
}

@media (max-width: 600px) {
    .recognition-examples {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .recognition-card {
        padding: 18px;
    }
}

/* =========================================
   DEGREE COMPARISON
   ========================================= */

.degree-comparison {
    max-width: 620px;
    margin: 22px auto 24px;
    padding: 8px 20px;
    background: #ffffff;
    border: 1px solid var(--poly-border);
    border-radius: 12px;
}

.degree-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 16px;
    padding: 15px 0;
    border-bottom: 1px solid var(--poly-border);
}

.degree-row:last-child {
    border-bottom: 0;
}

.degree-expression {
    color: var(--poly-heading);
    font-size: clamp(1.2rem, 3.5vw, 1.55rem);
    font-weight: 600;
}

.degree-result {
    color: var(--poly-muted);
    font-family: Arial, sans-serif;
    font-size: 0.82rem;
}

/* =========================================
   POLYNOMIAL TYPES
   ========================================= */

.degree-types {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    max-width: 750px;
    margin: 0 auto 38px;
}

.degree-type {
    padding: 20px;
    background: #ffffff;
    border: 1px solid var(--poly-border);
    border-radius: 12px;
}

.type-degree {
    color: var(--poly-accent);
    font-family: Arial, sans-serif;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.type-expression {
    margin: 13px 0 8px;
    color: var(--poly-heading);
    font-size: clamp(1.45rem, 4vw, 1.85rem);
    font-weight: 600;
}

.degree-type h3 {
    margin: 0 0 7px;
    color: var(--poly-heading);
    font-size: 1.08rem;
}

.degree-type p {
    margin: 0;
    color: var(--poly-muted);
    font-size: 0.91rem;
    line-height: 1.65;
}

/* =========================================
   WORKED DEGREE EXAMPLE
   ========================================= */

.worked-degree-expression {
    margin: 18px 0;
    color: var(--poly-heading);
    font-size: clamp(1.5rem, 4vw, 2rem);
    font-weight: 600;
    line-height: 1.5;
}

.worked-degree-answer {
    margin: 18px 0;
    color: #18804a;
    font-size: 1.25rem;
}

.worked-degree-answer strong {
    font-size: 1.6rem;
}

/* =========================================
   DARK MODE
   ========================================= */

body.dark .degree-comparison,
body.dark .degree-type {
    background: #20212b;
    border-color: var(--poly-border);
}

body.dark .worked-degree-answer {
    color: #a9e5bd;
}

/* =========================================
   RESPONSIVE LAYOUT
   ========================================= */

@media (max-width: 600px) {
    .degree-types {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .degree-type {
        padding: 18px;
    }

    .degree-comparison {
        padding-right: 15px;
        padding-left: 15px;
    }

    .degree-row {
        align-items: flex-start;
        flex-direction: column;
        gap: 5px;
    }
}

/* =========================================
   EXPLORE: ZERO POLYNOMIAL
   ========================================= */

.explore-box {
    margin: 0 auto 38px;
    overflow: hidden;
    background: #ffffff;
    border: 1px solid var(--poly-border);
    border-left: 4px solid var(--poly-accent);
    border-radius: 12px;
}

.explore-box summary {
    padding: 17px 20px;
    color: var(--poly-heading);
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.6;
    cursor: pointer;
    list-style: none;
}

.explore-box summary::-webkit-details-marker {
    display: none;
}

.explore-box summary::after {
    content: "+";
    float: right;
    margin-left: 12px;
    color: var(--poly-accent);
    font-size: 1.2rem;
    font-weight: 400;
}

.explore-box[open] summary::after {
    content: "−";
}

.explore-box summary:hover {
    background: var(--poly-idea-bg);
}

.explore-content {
    padding: 0 20px 20px;
    border-top: 1px solid var(--poly-border);
}

.explore-content p {
    margin: 16px 0 10px;
    color: var(--poly-text);
    font-size: 0.95rem;
    line-height: 1.75;
}

.explore-expression {
    margin: 14px 0;
    color: var(--poly-heading);
    font-size: clamp(1.15rem, 3.5vw, 1.5rem);
    font-weight: 600;
    line-height: 1.6;
    text-align: center;
    overflow-wrap: anywhere;
}

body.dark .explore-box {
    background: #20212b;
    border-color: var(--poly-border);
    border-left-color: var(--poly-accent);
}

body.dark .explore-box summary:hover {
    background: var(--poly-idea-bg);
}

/* =========================================
   EVALUATING A POLYNOMIAL
   ========================================= */

.evaluation-expression {
    margin: 18px auto;
    color: var(--poly-heading);
    font-size: clamp(1.8rem, 5vw, 2.3rem);
    font-weight: 600;
    line-height: 1.4;
    text-align: center;
}

.evaluation-step {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    margin: 20px 0;
    text-align: left;
}

.step-number {
    flex: 0 0 30px;
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    color: #ffffff;
    background: var(--poly-accent);
    border-radius: 50%;
    font-family: Arial, sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
}

.step-heading {
    margin: 0 0 8px;
    color: #4d4d4d;
    font-size: 0.92rem;
}

.step-math {
    color: var(--poly-heading);
    font-size: clamp(1.2rem, 3.5vw, 1.6rem);
    font-weight: 600;
    line-height: 1.6;
    overflow-wrap: anywhere;
}

.evaluation-result {
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px solid var(--poly-example-border);
    color: #18804a;
    font-size: 1rem;
    text-align: center;
}

.evaluation-result strong {
    font-size: 1.45rem;
}

.evaluation-working {
    margin-top: 18px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.55);
    border-radius: 10px;
}

.evaluation-working p {
    margin: 10px 0 4px;
    color: #4d4d4d;
    font-size: 0.92rem;
    line-height: 1.6;
}

.evaluation-working .step-math {
    margin-bottom: 14px;
    text-align: center;
}

body.dark .step-heading,
body.dark .evaluation-working p {
    color: #e0e0e8;
}

body.dark .evaluation-working {
    background: rgba(0, 0, 0, 0.12);
}

body.dark .evaluation-result {
    color: #a9e5bd;
}

@media (max-width: 520px) {
    .evaluation-step {
        gap: 11px;
    }

    .evaluation-working {
        padding: 12px;
    }
}

/* =========================================
   LINEAR POLYNOMIALS
   ========================================= */

.linear-example-expression {
    margin: 18px 0 22px;
    color: var(--poly-heading);
    font-size: clamp(1.7rem, 5vw, 2.2rem);
    font-weight: 600;
    text-align: center;
}

.linear-value-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 14px;
    padding: 14px 0;
    border-bottom: 1px solid var(--poly-example-border);
    text-align: left;
}

.linear-value-row:last-of-type {
    border-bottom: 0;
}

.linear-value-row span {
    color: var(--poly-muted);
    font-size: 0.95rem;
}

.linear-value-row strong {
    color: #18804a;
    font-size: 1.05rem;
}

.linear-example-note {
    margin: 18px 0 0;
    padding-top: 16px;
    border-top: 1px solid var(--poly-example-border);
    color: #4d4d4d;
    font-size: 0.95rem;
    line-height: 1.7;
}

body.dark .linear-value-row strong {
    color: #a9e5bd;
}

body.dark .linear-example-note {
    color: #e0e0e8;
}

@media (max-width: 520px) {
    .linear-value-row {
        align-items: flex-start;
        flex-direction: column;
        gap: 5px;
    }
}

/* Linear Patterns lesson */
.pattern-example {
    margin-top: 22px;
}

.pattern-example .example-label {
    margin-bottom: 12px;
    color: #18804a;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.09em;
}

.pattern-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 12px 2px;
    border-bottom: 1px solid var(--poly-example-border);
}

.pattern-row:last-of-type {
    border-bottom: 0;
}

.pattern-row span {
    color: var(--poly-muted);
}

.pattern-row strong {
    color: #18804a;
    font-size: 1.15rem;
}

.pattern-change {
    margin: 16px 0 0;
    padding-top: 14px;
    border-top: 1px solid var(--poly-example-border);
}

.pattern-change strong {
    color: #18804a;
}

.difference-line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 22px 0;
    padding: 18px 12px;
    border: 1px solid var(--poly-border);
    border-radius: 12px;
    background: var(--poly-page-bg);
}

.difference-line>span:not(.difference-arrow) {
    color: var(--poly-heading);
    font-size: 1.15rem;
    font-weight: 700;
}

.difference-arrow {
    color: var(--poly-muted);
    font-size: 0.9rem;
}

.pattern-rule {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin: 20px 0;
    padding: 22px 16px;
    border: 1px solid var(--poly-idea-border);
    border-radius: 12px;
    background: var(--poly-idea-bg);
}

.pattern-rule .rule-label {
    color: var(--poly-muted);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.pattern-rule strong {
    color: var(--poly-heading);
    font-size: 2rem;
}

.pattern-calculation {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 8px 16px;
    padding: 13px 0;
    border-bottom: 1px solid var(--poly-example-border);
}

.pattern-calculation:last-child {
    border-bottom: 0;
}

.pattern-calculation span {
    color: var(--poly-muted);
}

.pattern-calculation strong {
    color: #18804a;
    font-weight: 600;
}

body.dark .pattern-example .example-label,
body.dark .pattern-row strong,
body.dark .pattern-change strong,
body.dark .pattern-calculation strong {
    color: #a9e5bd;
}

@media (max-width: 520px) {
    .difference-line {
        gap: 7px;
        padding: 15px 8px;
    }

    .difference-arrow {
        font-size: 0.8rem;
    }

    .pattern-calculation {
        align-items: flex-start;
        flex-direction: column;
        gap: 5px;
    }
}

/* Linear Polynomial Applications */
.application-expression {
    margin: 20px 0;
    padding: 20px;
    border: 1px solid var(--poly-idea-border);
    border-radius: 12px;
    background: var(--poly-idea-bg);
    text-align: center;
}

.application-expression span {
    display: block;
    margin-bottom: 8px;
    color: var(--poly-muted);
    font-size: 0.9rem;
}

.application-expression strong {
    color: var(--poly-heading);
    font-size: 2rem;
}

.application-calculation {
    color: var(--poly-heading);
    font-size: 1.15rem;
    font-weight: 600;
}

@media (max-width: 520px) {
    .application-expression {
        padding: 16px;
    }
}

/* Static graph illustrations */
.graph-comparison {
    align-items: stretch;
}

.graph-card {
    min-width: 0;
}

.graph-expression {
    color: var(--poly-heading);
    font-weight: 600;
    text-align: center;
}

.graph-visual {
    display: block;
    width: 100%;
    height: auto;
    margin: 12px auto;
    overflow: visible;
}

.graph-grid-line {
    stroke: var(--poly-border);
    stroke-width: 0.7;
}

.graph-axis {
    fill: none;
    stroke: var(--poly-muted);
    stroke-width: 1.4;
}

.graph-axis-arrow {
    fill: none;
    stroke: var(--poly-muted);
    stroke-width: 1.4;
}

.graph-curve {
    fill: none;
    stroke: var(--poly-accent);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.quadratic-curve {
    stroke: #18804a;
}

.graph-point {
    fill: var(--poly-accent);
}

.graph-label {
    fill: var(--poly-text);
    font-size: 11px;
}

.graph-card>p:last-child {
    font-size: 0.92rem;
}

@media (max-width: 520px) {
    .graph-visual {
        max-width: 300px;
    }
}

/* Constant shifts graph */
.shift-up-line {
    fill: none;
    stroke: #1683C4;
    stroke-width: 3;
    stroke-linecap: round;
}

.shift-down-line {
    fill: none;
    stroke: #D97706;
    stroke-width: 3;
    stroke-linecap: round;
}

.shift-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px 16px;
    margin-top: 12px;
}

.shift-legend p {
    display: flex;
    align-items: center;
    gap: 7px;
    margin: 0;
    font-size: 0.85rem;
}

.shift-swatch {
    display: inline-block;
    width: 18px;
    height: 3px;
    border-radius: 2px;
}

.shift-original {
    background: var(--poly-accent);
}

.shift-up {
    background: #1683C4;
}

.shift-down {
    background: #D97706;
}

body.dark .shift-up-line {
    stroke: #65BDEB;
}

body.dark .shift-down-line {
    stroke: #F4B15F;
}

body.dark .shift-up {
    background: #65BDEB;
}

body.dark .shift-down {
    background: #F4B15F;
}

/* Side-by-side graph comparisons */
.shift-graph-pair {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    align-items: start;
    margin: 20px 0px;
}

.shift-graph-card {
    min-width: 0;
    padding: 12px;
}

.shift-graph-card .graph-visual {
    display: block;
    width: 100%;
    height: auto;
}

.shift-graph-card .graph-expression {
    text-align: center;
    font-weight: 600;
}

.shift-graph-card .shift-legend {
    justify-content: center;
}

@media (max-width: 520px) {
    .shift-graph-pair {
        grid-template-columns: 1fr;
    }
}

/* Interactive linear graph explorer */
.graph-explorer {
    padding: 20px;
    border: 1px solid var(--border-color, #dedede);
    border-radius: 12px;
    background: var(--card-background, #fff);
}

.explorer-equation {
    margin-bottom: 8px;
    color: var(--poly-accent, #7C5C9E);
    text-align: center;
    font-size: 1.3rem;
    font-weight: 700;
}

.explorer-graph {
    display: block;
    width: 100%;
    max-width: 480px;
    height: auto;
    margin: 0 auto 16px;
}

.explorer-controls {
    display: grid;
    gap: 20px;
    max-width: 480px;
    margin: 0 auto;
}

.explorer-control-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.explorer-control-heading label {
    font-weight: 600;
}

.explorer-control-heading output {
    min-width: 32px;
    padding: 3px 8px;
    border-radius: 6px;
    background: var(--example-background, #f0f8f2);
    text-align: center;
    font-weight: 700;
}

.explorer-control input[type="range"] {
    display: block;
    width: 100%;
    accent-color: var(--poly-accent, #7C5C9E);
    cursor: pointer;
}

.explorer-range-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 4px;
    color: var(--text-secondary, #666);
    font-size: 0.8rem;
}

.explorer-reset {
    justify-self: start;
    cursor: pointer;
    margin-bottom: 15px;
}

.explorer-observation {
    margin: 20px 0 0;
    padding: 12px 14px;
    border-left: 3px solid var(--poly-accent, #7C5C9E);
    border-radius: 5px;
    background: var(--takeaway-background, #f5eff9);
    line-height: 1.6;
}

body.dark .graph-explorer {
    background: var(--card-background, #202020);
}

body.dark .explorer-control-heading output {
    background: var(--example-background, #26382d);
}

body.dark .explorer-observation {
    background: var(--takeaway-background, #302639);
}

@media (max-width: 480px) {
    .graph-explorer {
        padding: 12px;
    }
}

/* Polynomials chapter overview */
.number-systems-home .chapter-home-intro h1 {
    color: #7C5C9E;
}

body.dark .number-systems-home .chapter-home-intro h1 {
    color: #c5a8e5;
}

.number-systems-home .primary-action {
    background: #7C5C9E;
    border-color: #62457f;
}

.number-systems-home .primary-action:hover {
    border-color: #4e3568;
}

body.dark .number-systems-home .primary-action {
    background: #c5a8e5;
    border-color: #e4d5f5;
    color: #24202a;
}

body.dark .number-systems-home .primary-action .action-description {
    color: #494052;
}

/* Quick revision question spacing */
.revision-question {
    padding: 16px 0;
    border-bottom: 1px solid var(--border, #e5e5e5);
}

.revision-question:last-of-type {
    border-bottom: none;
}

.revision-question>p:first-child {
    margin-top: 0;
}

.revision-feedback {
    margin: 10px 0 0;
    font-size: 0.9rem;
    line-height: 1.5;
}

.revision-feedback:empty {
    display: none;
}

body.dark .revision-question {
    border-color: #30343a;
}


/* ---------------------------------------------------------
   Final practice prompt
--------------------------------------------------------- */

.revision-check {
    margin: 55px auto 35px;
    padding: 32px;

    text-align: center;

    background: var(--why-bg);
    border: 1px solid var(--why-border);
    border-radius: 10px;
}

.revision-check-label {
    margin-bottom: 10px;

    font-size: 0.72rem;
    letter-spacing: 0.18em;
    font-weight: 700;

    color: var(--why-accent);
}

.revision-check h2 {
    margin-bottom: 20px;

    color: var(--text);
}

.revision-practice-button {
    display: inline-block;

    padding: 11px 22px;

    border-radius: 7px;

    background: var(--text);
    color: var(--page-bg);

    text-decoration: none;
    font-weight: 600;
}

.revision-practice-button:hover {
    opacity: 0.85;
}


@media (max-width: 768px) {



    .pattern-rule {

        flex-direction: column;

        gap: 12px;

    }



    .journey-complete {

        padding: 30px 22px;

    }



}



.journey-complete {

    width: 100%;

    margin: 45px auto 20px;

    padding: 22px 30px;



    text-align: center;



    background: #f0f9f2;

    border: 1px solid #b9dfc0;

    border-left: 3px solid #299447;

    border-radius: 10px;

}



.journey-complete p {

    margin: 0;



    font-size: 1.05rem;

    line-height: 1.6;

    font-weight: 600;



    color: #26783b;

}



body.dark .journey-complete {

    background: #17241b;

    border-color: #285c35;

    border-left-color: #4caf68;

}



body.dark .journey-complete p {

    color: #8bcf9a;

}