/* ===== TEORIA LAYOUT ===== */
.tr-layout {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 8px;
}

/* ===== TOC ===== */
.tr-toc {
    width: 100%;
    background: white;
    border-radius: 16px;
    padding: 10px 14px;
    box-shadow: 0 4px 20px rgba(15,23,42,0.06);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    position: sticky;
    top: 8px;
    z-index: 10;
}
.tr-toc-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #9ca3af;
    padding-right: 10px;
    margin-right: 4px;
    border-right: 1px solid #f3f4f6;
    white-space: nowrap;
    align-self: center;
}
.tr-toc a {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 500;
    color: #6b7280;
    text-decoration: none;
    border-radius: 8px;
    border: 1px solid transparent;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.tr-toc a:hover { color: #2563eb; background: #f0f5ff; }
.tr-toc a.active {
    color: #2563eb;
    font-weight: 700;
    background: #f0f5ff;
    border-color: #bfdbfe;
}
.tr-toc-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px; height: 20px;
    background: #f3f4f6;
    border-radius: 5px;
    font-size: 10px; font-weight: 700;
    color: #6b7280; flex-shrink: 0;
}
.tr-toc a.active .tr-toc-num { background: #dbeafe; color: #2563eb; }

/* ===== CONTENT ===== */
.tr-content {
    flex: 1;
    min-width: 0;
    column-count: 2;
    column-gap: 20px;
}

/* ===== SECTION CARD ===== */
.tr-section {
    background: white;
    border-radius: 20px;
    padding: 32px 40px;
    box-shadow: 0 4px 20px rgba(15,23,42,0.06);
    margin-bottom: 20px;
    scroll-margin-top: 24px;
    break-inside: avoid;
}
.tr-section.full {
    column-span: all;
    break-inside: auto;
}
.tr-section-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 2px solid #f3f4f6;
}
.tr-badge {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px;
    background: linear-gradient(135deg, #2563eb, #60a5fa);
    border-radius: 12px;
    font-size: 16px; font-weight: 800; color: white;
    flex-shrink: 0;
}
.tr-badge.def   { background: linear-gradient(135deg, #7c3aed, #a78bfa); font-size: 12px; }
.tr-badge.extra { background: linear-gradient(135deg, #059669, #34d399); font-size: 12px; }
.tr-section-title { font-size: 1.2rem; font-weight: 700; color: #07142f; line-height: 1.2; }
.tr-section-sub   { font-size: 12px; color: #9ca3af; font-weight: 500; margin-top: 2px; }

.tr-section p { color: #374151; line-height: 1.85; margin-bottom: 1em; font-size: 1rem; }
.tr-section p:last-child { margin-bottom: 0; }
.tr-section h4 {
    font-size: 0.78rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.6px; color: #9ca3af; margin: 18px 0 8px;
}
.tr-rule {
    background: #f0f5ff; border-left: 4px solid #2563eb;
    border-radius: 0 12px 12px 0;
    padding: 14px 18px; margin: 14px 0;
    color: #1e40af; font-weight: 500; line-height: 1.7; font-size: 0.97rem;
}
.tr-note {
    background: #fffbeb; border-left: 4px solid #f59e0b;
    border-radius: 0 12px 12px 0;
    padding: 12px 16px; margin: 14px 0;
    color: #374151; font-size: 0.93rem; line-height: 1.7;
}
.tr-note strong { color: #92400e; }

.tr-examples {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 12px;
}
.tr-ex {
    background: #f8fafc; border: 1px solid #e5e7eb; border-radius: 10px;
    padding: 9px 14px; font-size: 0.92rem; color: #374151; line-height: 1.6;
}
.tr-ex.span-full { grid-column: 1 / -1; }
.hl { color: #2563eb; font-weight: 700; margin-left:5px; }

/* steps inside a single tr-ex bubble */
.tr-steps { display: flex; flex-direction: column; gap: 0.55em; }
.tr-steps .param { font-size: .85rem; color: #9ca3af; font-style: italic; }

/* step-by-step examples already fill one grid cell each */
.tr-ex.tr-steps { min-width: 0; }

/* ===== FIGURE / SVG ===== */
.tr-fig-center { text-align: center; margin: 16px 0; }
.tr-fig-center svg,
.tr-fig-center img { max-width: 100%; height: auto; }

/* ===== FACTORIZATION TABLE ===== */
.fact-wrap { overflow-x: auto; margin: 14px 0; }
.fact-table { border-collapse: collapse; font-size: 14px; }
.fact-table td { padding: 5px 12px; text-align: right; border: 1px solid #e5e7eb; color: #374151; }
.fact-table td.sep { border-right: 2px solid #374151; }
.fact-table tr.hline td { border-top: 2px solid #374151; }
.fact-table td.hlc { color: #2563eb; font-weight: 700; }

/* ===== DIVISORS ===== */
.tr-divisors { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.tr-divisor {
    background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 8px;
    padding: 5px 12px; font-size: 13px; font-weight: 600; color: #1d4ed8;
}

/* ===== SISTEMA DE EQUAÇÕES ===== */
.se-sol-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 12px;
    margin-top: 14px;
}
.se-sol-card {
    border-radius: 10px;
    padding: 14px 16px;
    font-size: 0.91rem;
    line-height: 1.6;
}
.se-sol-card.unique   { background: #f0fdf4; border: 1px solid #86efac; }
.se-sol-card.infinite { background: #fffbeb; border: 1px solid #fcd34d; }
.se-sol-card.none     { background: #fef2f2; border: 1px solid #fca5a5; }
.se-sol-card strong   { display: block; margin-bottom: 5px; font-size: 0.93rem; }
.se-sol-card.unique strong   { color: #15803d; }
.se-sol-card.infinite strong { color: #b45309; }
.se-sol-card.none strong     { color: #b91c1c; }
.se-steps { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.se-step  { display: flex; gap: 12px; align-items: flex-start; }
.se-step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    height: 26px;
    background: #2563eb;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 800;
    color: white;
    flex-shrink: 0;
    margin-top: 2px;
}
.se-step-body { flex: 1; font-size: 0.92rem; color: #374151; line-height: 1.7; overflow-x: auto; }
.se-step-body .ml { display: block; margin: 0.45em 0; }
.se-result {
    background: #f0fdf4;
    border: 1px solid #86efac;
    border-radius: 10px;
    padding: 10px 16px;
    margin-top: 14px;
    font-weight: 600;
    color: #15803d;
    font-size: 0.93rem;
}


@media (max-width: 900px) 
{
    .tr-examples { grid-template-columns: 1fr; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1450px) {
    .tr-toc { position: static; }
    .tr-toc-title { border-right: none; padding-right: 0; margin-right: 0; width: 100%; padding-bottom: 6px; }
    .tr-section { padding: 20px 16px; }
    .tr-content { column-count: 1; }

}