:root {
    --bg: #f3ead7;
    --panel: #fffaf0;
    --ink: #2b2118;
    --muted: #75685a;

    --primary: #355e3b;
    --primary-dark: #244229;

    --accent: #b7791f;
    --accent-dark: #8a5a12;

    --pivot-row: #f77676;
    --pivot-column: #46fb6a;
    --pivot-cell: #21639c;
    --active-cell: #7f1d1d;
    --filled-cell: #d9ead3;

    --border: #b7a990;
}
body {
    font-family: Georgia, "Times New Roman", serif;
    margin: 0;
    background: var(--bg);
    color: var(--ink);
}
header {
    padding: 28px 36px;
    background: #2b2118;
    color: #fff7e6;
    border-bottom: 5px solid var(--accent);
}

header h1 {
    margin: 0 0 8px 0;
    letter-spacing: 0.5px;
}

header p {
    margin: 0;
    color: #e8dcc7;
}

.app-layout {
    display: grid;
    grid-template-columns: 42% 58%;
    gap: 20px;
    padding: 20px;
}

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 22px;
    box-shadow: rgba(255, 255, 255, 0.5) 0px 0px 0px 1px inset,
                rgba(43, 33, 24, 0.65) 0px 0px 0px 1px,
                rgba(43, 33, 24, 0.18) 4px 4px 0px 0px;
}

.controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

input {
    padding: 6px;
    width: 70px;
}

button {
    padding: 8px 12px;
    border: 1px solid var(--primary-dark);
    border-radius: 6px;
    background: var(--primary);
    color: white;
    cursor: pointer;
    font-weight: bold;
}

button:hover:not(:disabled) {
    background: var(--primary-dark);
}

button:disabled {
    background: #a89f91;
    border-color: #a89f91;
    cursor: not-allowed;
}

#startButton {
    margin-top: 16px;
    background: var(--accent);
    border-color: var(--accent-dark);
}

#startButton:hover:not(:disabled) {
    background: var(--accent-dark);
}
.step-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.step-info {
    background: #f8efd9;
    border-left: 5px solid var(--accent);
    padding: 12px;
    margin-bottom: 18px;
    border-radius: 6px;
}
.matrix-comparison {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

table {
    border-collapse: collapse;
    margin-top: 10px;
}

td {
    border: 1px solid #6f6253;
    min-width: 45px;
    height: 38px;
    text-align: center;
    padding: 4px;
    background: #fffdf7;
}

.matrix-input {
    width: 55px;
    text-align: center;
}

.new-filled-cell {
    background: #bbf7d0; /* verde claro para celdas ya calculadas */
}

.pivot-row {
    background: var(--pivot-row);
}

.pivot-column {
    background: var(--pivot-column);
}

.pivot-cell {
    background: var(--pivot-cell);
    color: white;
    font-weight: bold;
}

.active-cell {
    outline: 3px solid var(--active-cell);
    font-weight: bold;
}

.new-filled-cell {
    background: var(--filled-cell);
}

.blank-cell {
    color: #a89f91;
}.formula-box {
    margin-top: 20px;
    background: #2b2118;
    color: #fff7e6;
    padding: 14px;
    border-radius: 8px;
    font-family: Consolas, monospace;
    line-height: 1.5;
    white-space: pre-wrap;
    border: 1px solid var(--border);
}

@media (max-width: 900px) {
    .app-layout {
        grid-template-columns: 1fr;
    }

    .matrix-comparison {
        grid-template-columns: 1fr;
    }
}
/* Matrix highlight priority */

.new-filled-cell {
    background: var(--filled-cell);
}

.pivot-row {
    background: var(--pivot-row);
}

.pivot-column {
    background: var(--pivot-column);
}

td.pivot-cell {
    background: var(--pivot-cell);
    color: white;
    font-weight: bold;
}

td.active-cell {
    outline: 3px solid var(--active-cell);
    font-weight: bold;
}

.blank-cell {
    color: #a89f91;
}
.hint {
    margin-top: 8px;
    color: var(--muted);
    font-size: 0.95rem;
    line-height: 1.4;
}
.top-nav {
    display: flex;
    gap: 18px;
    margin-top: 18px;
}

.top-nav a {
    color: #fff7e6;
    text-decoration: none;
    font-weight: bold;
    padding-bottom: 4px;
    border-bottom: 2px solid transparent;
}

.top-nav a:hover {
    border-bottom: 2px solid var(--accent);
}

.theory-layout {
    padding: 24px;
    max-width: 950px;
    margin: 0 auto;
}

.theory-card {
    line-height: 1.65;
}

.theory-card h2 {
    margin-top: 32px;
    border-bottom: 2px solid var(--border);
    padding-bottom: 6px;
}

.theory-card h2:first-child {
    margin-top: 0;
}

.theory-card h3 {
    margin-top: 24px;
    color: var(--ink);
}

.theory-card p {
    color: var(--ink);
}

.theory-card li {
    margin-bottom: 8px;
}

.formula-card {
    background: #2b2118;
    color: #fff7e6;
    padding: 14px 16px;
    border-radius: 8px;
    font-family: Consolas, monospace;
    margin: 16px 0;
    border: 1px solid var(--border);
    white-space: normal;
}
td.zero-row {
    background: #e7e2d6 !important;
    color: var(--muted);
    font-weight: bold;
}

td.contradiction-row {
    background: #f2c8b7 !important;
    color: #7f1d1d;
    font-weight: bold;
}

td.contradiction-value {
    background: #7f1d1d !important;
    color: white;
    font-weight: bold;
}
td.zero-row {
    background: #e7e2d6 !important;
    color: var(--muted);
    font-weight: bold;
}

td.contradiction-row {
    background: #f2c8b7 !important;
    color: #7f1d1d;
    font-weight: bold;
}

td.contradiction-value {
    background: #7f1d1d !important;
    color: #fff7e6;
    font-weight: bold;
    outline: 3px solid #2b2118;
}
.theory-figure {
    margin: 24px 0;
    text-align: center;
}

.theory-figure img {
    max-width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: rgba(43, 33, 24, 0.18) 4px 4px 0px 0px;
}

.theory-figure figcaption {
    margin-top: 8px;
    color: var(--muted);
    font-size: 0.95rem;
}