:root {
    --ink: #1b2436;
    --ink-soft: #5b6478;
    --blue: #2470ff;
    --blue-soft: #e9f1ff;
    --blue-line: #cfe0ff;
    --green: #1fae6b;
    --red: #ff5c5c;
    --purple: #8b5cf6;
    --card-bg: #ffffff;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: #f6f9ff;
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
    line-height: 1.5;
}

.wrap {
    max-width: 760px;
    margin: 0 auto;
    padding: 36px 20px 80px;
}

/* ===================== */
/* HEADER */
/* ===================== */
.topbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 26px;
}

.topbar a {
    color: var(--blue);
    text-decoration: none;
    font-weight: bold;
    font-size: 14px;
}

.topbar a:hover { text-decoration: underline; }

.page-header {
    text-align: center;
    margin-bottom: 40px;
}

.eyebrow {
    display: inline-block;
    background: var(--blue-soft);
    color: var(--blue);
    font-size: 13px;
    font-weight: bold;
    padding: 5px 14px;
    border-radius: 20px;
    margin-bottom: 12px;
}

.page-header h1 {
    font-family: "Fredoka", Arial, sans-serif;
    font-size: 36px;
    margin: 0;
}

/* ===================== */
/* CARDS */
/* ===================== */
.card {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 26px 26px 28px;
    margin-bottom: 22px;
    box-shadow: 0 8px 24px rgba(20, 30, 60, .06);
}

.card h2 {
    font-family: "Fredoka", Arial, sans-serif;
    font-size: 22px;
    margin: 0 0 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card h2 .num {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--blue);
    color: white;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.card p { margin: 0 0 12px; }
.card p:last-child { margin-bottom: 0; }

.examples {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}

.example-chip {
    background: var(--blue-soft);
    color: var(--blue);
    font-weight: bold;
    padding: 8px 14px;
    border-radius: 12px;
    font-size: 15px;
    display: inline-flex;
    align-items: center;
}

.example-chip .frac {
    margin: 0;
    font-size: 16px;
}

.note {
    background: #fff8e6;
    border-left: 4px solid #ffb020;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 15px;
    margin-top: 14px;
}

/* ===================== */
/* ЦЕЛЫЕ / ДРОБНЫЕ DIAGRAM */
/* ===================== */
.split-diagram {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 18px 0 6px;
}

.split-root {
    background: var(--blue);
    color: white;
    padding: 10px 20px;
    border-radius: 12px;
    font-weight: bold;
    font-size: 15px;
}

.split-lines {
    width: 2px;
    height: 22px;
    background: #cfd6e6;
}

.split-branches {
    display: flex;
    gap: 30px;
    width: 100%;
    justify-content: center;
}

.split-branch {
    flex: 1;
    max-width: 260px;
    border-radius: 16px;
    padding: 16px;
    text-align: center;
}

.split-branch.whole { background: var(--blue-soft); border: 2px solid var(--blue-line); }
.split-branch.frac { background: #f2edff; border: 2px solid #ddccff; }

.split-branch h3 {
    margin: 0 0 6px;
    font-family: "Fredoka", Arial, sans-serif;
    font-size: 17px;
}

.split-branch.whole h3 { color: var(--blue); }
.split-branch.frac h3 { color: var(--purple); }

.split-branch p { font-size: 13px; color: var(--ink-soft); margin: 0 0 10px; }

.split-branch .example-chip {
    display: inline-block;
    margin: 3px;
}

.split-branch.frac .example-chip { background: #f2edff; color: var(--purple); }

/* ===================== */
/* FRACTION VISUAL */
/* ===================== */
.frac {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    vertical-align: middle;
    margin: 0 8px;
    font-family: "Fredoka", Arial, sans-serif;
    font-weight: 600;
    font-size: 20px;
}

.frac .frac-num,
.frac .frac-den {
    padding: 2px 8px;
    white-space: nowrap;
}

.frac .frac-num {
    border-bottom: 2.5px solid currentColor;
}

.frac-block {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 14px;
    margin: 14px 0;
}

.frac-arrow {
    font-size: 22px;
    color: var(--ink-soft);
}

/* сокращаемая часть — перечёркнута под 45°.
   Полоска задана в % от ширины блока и растягивается под неё,
   поэтому не бывает "слишком короткой" ни для цифры, ни для длинной скобки. */
.cancel-num,
.cancel-var {
    position: relative;
    display: inline-block;
}

.cancel-num::after,
.cancel-var::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    height: 2.5px;
    opacity: .6;
    transform: translate(-50%, -50%) rotate(-45deg);
}

/* одна буква/цифра — полоска чуть длиннее самого символа */
.cancel-num::after,
.cancel-var::after { width: 190%; }

/* целая скобка/выражение — полоска короче, не через весь текст */
.cancel-num.wide::after,
.cancel-var.wide::after { width: 65%; }

/* числа — красным, буквы/выражения с буквой — синим */
.cancel-num::after { background: var(--red); }
.cancel-var::after { background: var(--blue); }

/* исправление "было → стало": старое значение зачёркнуто (та же диагональ, красный — это число), новое пишем рядом/сверху */
.correction {
    display: inline-flex;
    flex-direction: column-reverse;
    align-items: center;
    vertical-align: bottom;
    line-height: 1.1;
}

/* для знаменателя — новая цифра снизу, зеркально числителю,
   чтобы не наезжать на черту дроби и не "съезжать" вниз */
.correction.below {
    flex-direction: column;
    vertical-align: top;
}

.correction .old {
    position: relative;
    display: inline-block;
}

.correction .old::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 190%;
    height: 2.5px;
    opacity: .6;
    background: var(--red);
    transform: translate(-50%, -50%) rotate(-45deg);
}

.correction .new {
    color: var(--green);
    font-weight: 700;
    font-size: 0.8em;
    margin-bottom: 2px;
}

.correction.below .new {
    margin-bottom: 0;
    margin-top: 2px;
}

/* ===================== */
/* REDUCE STEP EXAMPLE CARDS */
/* ===================== */
.reduce-example {
    border: 2px solid var(--ex-line, #edf1fb);
    border-radius: 18px;
    padding: 20px 22px 24px;
    margin-bottom: 18px;
    background: var(--ex-bg, #fbfcff);
}

.reduce-example:last-child { margin-bottom: 0; }

.ex-1 { --ex-color: #2470ff; --ex-bg: #f5f9ff; --ex-line: #d7e6ff; }
.ex-2 { --ex-color: #8b5cf6; --ex-bg: #faf7ff; --ex-line: #e5d9ff; }
.ex-3 { --ex-color: #1fae6b; --ex-bg: #f2fbf7; --ex-line: #c9ecdc; }
.ex-4 { --ex-color: #ff9800; --ex-bg: #fff9f1; --ex-line: #ffe1ae; }
.ex-5 { --ex-color: #e64980; --ex-bg: #fff5f8; --ex-line: #ffd0e0; }

.ex-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.ex-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--ex-color);
    color: white;
    font-family: "Fredoka", Arial, sans-serif;
    font-weight: 700;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ex-title {
    font-family: "Fredoka", Arial, sans-serif;
    font-weight: 600;
    font-size: 17px;
    color: var(--ex-color);
}

.derivation {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    margin: 6px 0 22px;
    font-family: "Fredoka", Arial, sans-serif;
    font-weight: 600;
    font-size: 18px;
}

.deriv-line:not(:last-child)::after {
    content: "↓";
    display: block;
    color: var(--ink-soft);
    font-size: 16px;
    margin-top: 4px;
    font-family: Arial, sans-serif;
}

/* ===================== */
/* TRAINER LINK */
/* ===================== */
.trainer-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: linear-gradient(135deg, var(--blue), #4c8bff);
    color: white;
    border-radius: 20px;
    padding: 24px 26px;
    text-decoration: none;
    margin-top: 8px;
    transition: transform .15s ease, box-shadow .15s ease;
    box-shadow: 0 10px 26px rgba(36, 112, 255, .3);
}

.trainer-link:hover {
    transform: translateY(-3px);
    box-shadow: 0 14px 32px rgba(36, 112, 255, .4);
}

.trainer-link .tl-text h3 {
    margin: 0 0 4px;
    font-family: "Fredoka", Arial, sans-serif;
    font-size: 20px;
}

.trainer-link .tl-text p {
    margin: 0;
    font-size: 14px;
    opacity: .9;
}

.trainer-link .tl-go {
    font-size: 28px;
    flex-shrink: 0;
}

@media (max-width: 560px) {
    .split-branches { flex-direction: column; align-items: center; }
    .page-header h1 { font-size: 28px; }
}
