/* calc.css — стили калькуляторов в стиле chinoharu.ru */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    font-family: 'Roboto', sans-serif;
    background-color: #0c0c0c;
    color: #e0e0e0;
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #000;
}

::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 10px;
    border: 2px solid #000;
}

::-webkit-scrollbar-thumb:hover {
    background: #444;
}

/* ── Навбар ── */
nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background-color: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 5%;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

.logo {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: white;
    font-weight: 500;
    transition: opacity 0.3s ease;
    flex-shrink: 0;
}

.logo:hover {
    opacity: 0.8;
}

.logo img {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 35%;
    margin-right: 0.75rem;
    object-fit: cover;
}

.logo span {
    font-size: 1rem;
    white-space: nowrap;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
    list-style: none;
}

.nav-links a {
    color: white;
    text-decoration: none;
    font-weight: 400;
    font-size: 0.95rem;
    transition: opacity 0.3s ease;
}

.nav-links a:hover {
    opacity: 0.7;
}

/* ── Основной контейнер ── */
.calc-page {
    padding-top: 80px;
    min-height: calc(100vh - 80px);
    display: flex;
    flex-direction: column;
}

.calc-container {
    max-width: 1300px;
    margin: 2rem auto;
    padding: 2rem 5%;
    flex: 1;
}


h1.calc-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 2rem;
    color: #ffffff;
}

/* ── Табы ── */
.tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid #2a2a2a;
    flex-wrap: wrap;
}

.tab {
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.95rem;
    color: #909090;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.2s, border-color 0.2s;
    user-select: none;
    border-radius: 6px 6px 0 0;
}

.tab:hover {
    color: #d0d0d0;
}

.tab.active {
    color: #ffffff;
    border-bottom-color: #ffffff;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ── Блоки секций ── */
.calc-section {
    background: #191919;
    border: 1px solid #282828;
    border-radius: 1rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.calc-section h2,
.calc-section h3 {
    color: #ffffff;
    margin-bottom: 1rem;
    font-size: 1.2rem;
    font-weight: 600;
}

.calc-section p {
    color: #b0b0b0;
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
}

/* ── Управление размерностью ── */
.dimension-control {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.25rem;
    padding: 1rem 1.25rem;
    background: #111;
    border: 1px solid #2a2a2a;
    border-radius: 0.75rem;
}

label {
    color: #d0d0d0;
    font-weight: 500;
    font-size: 0.95rem;
}

/* ── Инпуты ── */
input[type="number"],
input[type="text"] {
    background: #111;
    color: #e0e0e0;
    border: 1px solid #333;
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    font-size: 0.95rem;
    font-family: 'Roboto', sans-serif;
    transition: border-color 0.2s;
    width: 100px;
}

input[type="number"]:focus,
input[type="text"]:focus {
    outline: none;
    border-color: #666;
}

input[type="number"]:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.matrix-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-top: 1rem;
    padding-bottom: 0.5rem;
}

.matrix-container table {
    table-layout: auto !important;
    width: max-content;
    min-width: 100%;
    margin-top: 0;
}

.matrix-input {
    width: 80px;
    text-align: center;
    background: #111;
    color: #e0e0e0;
    border: 1px solid #2e2e2e;
    border-radius: 5px;
    padding: 0.45rem;
    font-size: 0.9rem;
    transition: border-color 0.2s;
}

.matrix-input:focus {
    outline: none;
    border-color: #555;
}

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1.5rem;
    align-items: center;
}

.dimension-control {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

/* ── Кнопки ── */
button {
    background: #1e1e1e;
    color: #e0e0e0;
    border: 1px solid #333;
    padding: 0.6rem 1.25rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    font-family: 'Roboto', sans-serif;
    transition: background 0.2s, transform 0.15s, box-shadow 0.15s;
}

button:hover {
    background: #2a2a2a;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

button:active {
    transform: translateY(0);
}

button.btn-primary {
    background: #2d2d2d;
    border-color: #555;
    color: #fff;
    width: 100%;
    padding: 0.9rem;
    font-size: 1.05rem;
    margin-top: 1rem;
}

button.btn-primary:hover {
    background: #383838;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

button.btn-primary:active {
    transform: translateY(0);
}

/* ── Разное (Адаптив) ── */
canvas {
    max-width: 100%;
    height: auto !important;
}

/* ── Таблицы ── */
.matrix-container {
    overflow-x: auto;
    margin-top: 0.75rem;
    border: 1px solid #282828;
    border-radius: 0.75rem;
    padding: 0.75rem;
    background: #111;
    max-width: 100vw;
}

table {
    border-collapse: collapse;
    width: max-content;
    min-width: 100%;
}

th,
td {
    padding: 0.6rem 0.9rem;
    text-align: center;
    border: 1px solid #2a2a2a;
    font-size: 0.9rem;
}

th {
    background: #1e1e1e;
    color: #d0d0d0;
    font-weight: 600;
}

td {
    color: #c0c0c0;
}

tr:nth-child(even) td {
    background: #141414;
}

/* ── Сетка диагоналей ── */
.tridiagonal-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-top: 1rem;
}

.diagonal-block {
    background: #141414;
    border: 1px solid #282828;
    border-radius: 0.75rem;
    padding: 1rem;
}

.diagonal-block h3 {
    font-size: 0.95rem;
    color: #aaa;
    margin-bottom: 0.75rem;
    text-align: center;
}

/* ── Контроли ── */
.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1rem;
    align-items: center;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ── Сообщения ── */
.error-message,
.warning-message,
.success-message {
    padding: 0.85rem 1rem;
    border-radius: 8px;
    margin: 0.75rem 0;
    font-size: 0.9rem;
    display: none;
}

.error-message {
    background: #1f0a0a;
    color: #ff6b6b;
    border-left: 4px solid #c62828;
}

.warning-message {
    background: #1a1100;
    color: #ffba57;
    border-left: 4px solid #e65100;
}

.success-message {
    background: #0a1f0e;
    color: #66bb6a;
    border-left: 4px solid #2e7d32;
}

.calc-loading {
    text-align: center;
    padding: 1.25rem;
    font-size: 1rem;
    color: #888;
    display: none;
}

/* ── Решение ── */
.solution-display {
    background: #0d1f10;
    border: 1px solid #1e4022;
    border-radius: 0.75rem;
    padding: 1.25rem;
    margin-top: 1rem;
}

.solution-display h3 {
    color: #66bb6a;
    margin-bottom: 0.75rem;
}

.solution-values {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    font-size: 1.05rem;
    font-weight: 600;
}

.solution-value {
    background: #0f2813;
    border: 1px solid #1e4022;
    color: #a5d6a7;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    min-width: 110px;
    text-align: center;
}

/* ── Инфо-карточки ── */
.iteration-info {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1rem;
    justify-content: center;
}

.info-card {
    background: #191919;
    border: 1px solid #303030;
    color: #d0d0d0;
    padding: 1rem 1.5rem;
    border-radius: 0.75rem;
    min-width: 160px;
    text-align: center;
}

.info-card h4 {
    font-size: 0.85rem;
    color: #888;
    margin-bottom: 0.5rem;
    font-weight: 400;
}

.info-card .value {
    font-size: 1.6rem;
    font-weight: 700;
    color: #ffffff;
}

/* ── Verification grid ── */
.verification-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.verification-item {
    background: #141414;
    border: 1px solid #282828;
    border-radius: 0.75rem;
    padding: 1rem;
    text-align: center;
}

.verification-item h4 {
    font-size: 0.85rem;
    color: #888;
    margin-bottom: 0.5rem;
}

.verification-item .value {
    font-size: 1.2rem;
    font-weight: 700;
    color: #e0e0e0;
}

/* ── Шаги решения ── */
.steps-section {}

.step {
    background: #141414;
    border: 1px solid #282828;
    border-left: 3px solid #555;
    border-radius: 0.75rem;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
}

.step h4 {
    color: #d0d0d0;
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.forward-sweep,
.backward-sweep {
    background: #111;
    border: 1px solid #282828;
    border-left: 3px solid #444;
    border-radius: 0.5rem;
    padding: 1rem;
    margin-top: 0.75rem;
}

.forward-sweep h4,
.backward-sweep h4 {
    color: #aaa;
    margin-bottom: 0.5rem;
}

.sweep-equation {
    font-family: 'Courier New', monospace;
    background: #0c0c0c;
    border: 1px solid #2a2a2a;
    padding: 0.5rem 0.75rem;
    border-radius: 5px;
    margin: 0.4rem 0;
    font-size: 0.95rem;
    color: #ccc;
}

/* ── Коэффициенты ── */
.coefficients-table {
    margin-top: 1rem;
}

/* ── Info box ── */
.info-box {
    background: #141414;
    border: 1px solid #282828;
    border-left: 4px solid #444;
    border-radius: 0.75rem;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
}

.info-box h3 {
    color: #d0d0d0;
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.info-box p {
    color: #999;
    font-size: 0.9rem;
}

.matrix-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.info-item {
    background: #141414;
    border: 1px solid #282828;
    border-radius: 0.75rem;
    padding: 1rem;
    font-size: 0.9rem;
    color: #aaa;
    line-height: 1.8;
}

.info-item strong {
    color: #d0d0d0;
}

/* ── Condition check ── */
.condition-check,
.dominance-check {
    margin-top: 1rem;
    padding: 1rem;
    background: #111;
    border: 1px solid #282828;
    border-left: 3px solid #555;
    border-radius: 0.75rem;
}

.condition-check h4,
.dominance-check h4 {
    color: #ccc;
    margin-bottom: 0.75rem;
    font-size: 0.95rem;
}

.condition-row,
.dominance-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid #222;
    font-size: 0.85rem;
    color: #999;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.condition-row:last-child,
.dominance-row:last-child {
    border-bottom: none;
}

.condition-status,
.dominance-status {
    font-weight: 600;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.8rem;
}

.condition-ok,
.dominance-ok {
    background: #0f2813;
    color: #66bb6a;
}

.condition-fail,
.dominance-fail {
    background: #1f0a0a;
    color: #ef5350;
}

/* ── Convergence canvas ── */
.convergence-chart {
    background: #141414;
    border: 1px solid #282828;
    border-radius: 0.75rem;
    padding: 1.25rem;
    margin-top: 1rem;
}

.convergence-chart h3 {
    color: #ccc;
    margin-bottom: 0.75rem;
    font-size: 1rem;
}

#convergenceCanvas {
    width: 100%;
    height: 280px;
    background: #0c0c0c;
    border-radius: 6px;
    border: 1px solid #222;
}

/* ── Diagonal element colours ── */
.diagonal-element {
    color: #81c784;
    font-weight: bold;
}

.upper-diagonal {
    color: #64b5f6;
}

.lower-diagonal {
    color: #ce93d8;
}

.error-column {
    color: #ffb74d;
    font-weight: bold;
}

/* ── Responsive ── */
@media (max-width: 900px) {
    .tridiagonal-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    nav {
        padding: 0.6rem 4%;
    }

    .calc-container {
        padding: 1rem 4%;
    }

    h1.calc-title {
        font-size: 1.4rem;
        margin-bottom: 1rem;
    }

    .tab {
        padding: 0.5rem 0.75rem;
        font-size: 0.82rem;
    }

    .verification-grid {
        grid-template-columns: 1fr 1fr;
    }

    .dimension-control {
        flex-direction: column;
        align-items: flex-start;
    }

    .controls {
        flex-direction: column;
        align-items: flex-start;
    }

    .matrix-input {
        width: 64px;
        font-size: 0.82rem;
    }

    .info-card {
        min-width: 120px;
        padding: 0.75rem 1rem;
    }

    .info-card .value {
        font-size: 1.2rem;
    }
}

@media (max-width: 360px) {
    .logo span {
        display: none;
    }

    .tab {
        padding: 0.4rem 0.6rem;
        font-size: 0.78rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}