/* ================================================================
   Интерактивная лекция «Как работают нейросети» (шорткод [it_nn_lecture])
   Всё внутри .nn, оформление статьи (.entry-content) сюда не попадает
================================================================ */
.nn {
    --nn-c1: #00f2fe;
    --nn-c2: #4facfe;
    --nn-neg: #f472b6;
    --nn-ok: #34d399;
    --nn-bad: #fb7185;
    --nn-text: #e2e8f0;
    --nn-muted: #94a3b8;
    --nn-line: rgba(255, 255, 255, 0.1);
    --nn-card: rgba(255, 255, 255, 0.035);
    max-width: 960px;
    margin: 0 auto;
    color: var(--nn-text);
    font-size: 17px;
    line-height: 1.7;
}

.nn *,
.nn *::before,
.nn *::after {
    box-sizing: border-box;
}

.nn p { margin: 0 0 14px; }
.nn h2 {
    margin: 0 0 16px;
    font-size: 1.75em;
    line-height: 1.25;
    color: #f8fafc;
}
.nn h3 { margin: 0 0 8px; font-size: 1.12em; color: #f1f5f9; }
.nn h4 {
    margin: 0 0 10px;
    font-size: 0.8em;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--nn-muted);
}
.nn strong, .nn b { color: #fff; font-weight: 600; }
.nn-muted { color: var(--nn-muted); font-size: 0.92em; }

/* Содержание */
.nn-toc {
    position: sticky;
    top: 84px;
    z-index: 5;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    margin: 10px 0 30px;
    padding: 8px;
    border: 1px solid var(--nn-line);
    border-radius: 14px;
    background: rgba(15, 23, 42, 0.85);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    scrollbar-width: none;
}
.nn-toc::-webkit-scrollbar { display: none; }
.nn-toc a {
    flex: 0 0 auto;
    padding: 6px 12px;
    border-radius: 9px;
    font-size: 0.82em;
    color: var(--nn-muted);
    text-decoration: none;
    transition: background 0.2s, color 0.2s;
}
.nn-toc a:hover { color: #fff; background: rgba(255, 255, 255, 0.06); }
.nn-toc a.is-active { color: #0f172a; background: linear-gradient(45deg, var(--nn-c1), var(--nn-c2)); }

/* Секции */
.nn-sec {
    position: relative;
    padding: 34px 0 26px;
    border-top: 1px solid var(--nn-line);
    scroll-margin-top: 150px;
}
.nn-sec:first-of-type { border-top: 0; }
.nn-num {
    display: inline-block;
    margin-bottom: 6px;
    font-size: 0.85em;
    font-weight: 700;
    letter-spacing: 0.1em;
    background: linear-gradient(to right, var(--nn-c1), var(--nn-c2));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.nn-try {
    padding: 10px 14px;
    border-left: 3px solid var(--nn-c1);
    border-radius: 0;
    background: rgba(0, 242, 254, 0.06);
    font-size: 0.95em;
}
.nn-try::before { content: '👆 '; }

/* Карточки */
.nn-card {
    padding: 20px;
    border: 1px solid var(--nn-line);
    border-radius: 16px;
    background: var(--nn-card);
}
.nn-card p:last-child { margin-bottom: 0; }
.nn-card--accent {
    border-color: rgba(0, 242, 254, 0.35);
    background: linear-gradient(160deg, rgba(0, 242, 254, 0.08), rgba(79, 172, 254, 0.02));
}
.nn-compare,
.nn-types {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}
.nn-code {
    margin: 0 0 12px;
    padding: 12px 14px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.35);
    font: 0.88em/1.6 Consolas, 'Courier New', monospace;
    color: #a5f3fc;
    white-space: pre;
}
.nn-pics { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.nn-pics span {
    padding: 4px 10px;
    border: 1px solid var(--nn-line);
    border-radius: 20px;
    font-size: 0.85em;
}
.nn-ico { font-size: 1.8em; line-height: 1; margin-bottom: 10px; }

/* Интерактивная «лаборатория» */
.nn-lab {
    margin-top: 18px;
    padding: 22px;
    border: 1px solid rgba(0, 242, 254, 0.22);
    border-radius: 18px;
    background: rgba(2, 6, 23, 0.55);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

/* Кнопки */
.nn-btn {
    padding: 9px 16px;
    border: 1px solid rgba(0, 242, 254, 0.4);
    border-radius: 10px;
    background: rgba(0, 242, 254, 0.08);
    color: #e0fdff;
    font: inherit;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}
.nn-btn:hover { background: rgba(0, 242, 254, 0.18); }
.nn-btn:active { transform: translateY(1px); }
.nn-btn:disabled { opacity: 0.4; cursor: default; }
.nn-btn--main {
    border-color: transparent;
    background: linear-gradient(45deg, var(--nn-c1), var(--nn-c2));
    color: #0f172a;
}
.nn-btn--main:hover { background: linear-gradient(45deg, #5ff7ff, #7cc2ff); }
.nn-btn--ghost { border-color: var(--nn-line); background: transparent; color: var(--nn-muted); }
.nn button:focus-visible,
.nn [tabindex]:focus-visible,
.nn input:focus-visible {
    outline: 2px solid var(--nn-c1);
    outline-offset: 2px;
}

/* 2. Нейрон */
.nn-nrow {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 18px;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px dashed var(--nn-line);
}
.nn-switch { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.nn-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.nn-switch span {
    position: relative;
    flex: 0 0 auto;
    width: 38px;
    height: 22px;
    border-radius: 11px;
    background: rgba(255, 255, 255, 0.15);
    transition: background 0.2s;
}
.nn-switch span::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.2s;
}
.nn-switch input:checked + span { background: var(--nn-c2); }
.nn-switch input:checked + span::after { transform: translateX(16px); }
.nn-switch input:focus-visible + span { outline: 2px solid var(--nn-c1); outline-offset: 2px; }
.nn-slider { display: flex; align-items: center; gap: 12px; font-size: 0.9em; color: var(--nn-muted); }
.nn-slider > span { flex: 0 0 82px; }
.nn-slider b { color: #fff; }
.nn input[type=range] { flex: 1; accent-color: var(--nn-c1); }
.nn-neuron-out { margin-top: 18px; }
.nn-formula {
    margin-bottom: 12px;
    font: 0.95em/1.6 Consolas, 'Courier New', monospace;
    color: #cbd5e1;
}
.nn-formula .nn-off { opacity: 0.35; }
.nn-meter {
    position: relative;
    height: 16px;
    border-radius: 8px;
    background: linear-gradient(to right, rgba(244, 114, 182, 0.25), rgba(0, 242, 254, 0.25));
    overflow: hidden;
}
.nn-meter-fill {
    height: 100%;
    border-radius: 8px;
    background: linear-gradient(to right, var(--nn-c2), var(--nn-c1));
    transition: width 0.3s ease;
}
.nn-meter-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 0.88em;
    color: var(--nn-muted);
}
.nn-verdict { font-weight: 700; color: #fff; }

/* 3. Сеть */
.nn-net-svg { display: block; width: 100%; height: auto; }
.nn-edge { stroke-linecap: round; opacity: 0.18; transition: opacity 0.35s; }
.nn-edge.pos { stroke: var(--nn-c1); }
.nn-edge.neg { stroke: var(--nn-neg); }
.nn-edge.is-live { opacity: 0.85; }
.nn-net-svg.is-running .nn-edge.is-live { stroke-dasharray: 6 6; animation: nn-flow 0.5s linear infinite; }
@keyframes nn-flow { to { stroke-dashoffset: -12; } }
.nn-in { cursor: pointer; }
.nn-in circle {
    fill: rgba(148, 163, 184, 0.15);
    stroke: rgba(148, 163, 184, 0.6);
    stroke-width: 1.5;
    transition: fill 0.25s, stroke 0.25s;
}
.nn-in.is-on circle { fill: var(--nn-c2); stroke: var(--nn-c1); }
.nn-in:hover circle { stroke: #fff; }
.nn-hid,
.nn-out {
    fill: var(--nn-c1);
    stroke: var(--nn-c1);
    stroke-width: 1.5;
    transition: fill-opacity 0.35s;
}
.nn-out { fill: var(--nn-c2); stroke: var(--nn-c2); }
.nn-svg-h { fill: #f1f5f9; font-size: 14px; font-weight: 600; text-anchor: middle; }
.nn-svg-l { fill: #cbd5e1; font-size: 14px; }
.nn-svg-l.is-win { fill: #fff; font-weight: 700; }
.nn-svg-v { fill: #0f172a; font-size: 13px; font-weight: 700; text-anchor: middle; pointer-events: none; }
.nn-in:not(.is-on) .nn-svg-v { fill: #cbd5e1; }
.nn-net-result { margin-top: 8px; text-align: center; font-size: 1.05em; }

/* 4. Обучение */
.nn-steps { margin: 0 0 16px; padding-left: 1.4em; }
.nn-steps li { margin-bottom: 6px; }
.nn-train-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 18px; }
.nn-train-stat { margin-left: auto; font-size: 0.9em; color: var(--nn-muted); }
.nn-train-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 24px; }
.nn-animal {
    display: grid;
    grid-template-columns: 1fr auto 90px 72px;
    gap: 10px;
    align-items: center;
    padding: 6px 8px;
    border-radius: 8px;
    font-size: 0.9em;
    transition: background 0.3s;
}
.nn-animal.is-ok { background: rgba(52, 211, 153, 0.08); }
.nn-animal.is-bad { background: rgba(251, 113, 133, 0.08); }
.nn-a-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nn-a-feat { display: flex; gap: 3px; }
.nn-a-feat i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 5px;
    font-size: 11px;
    font-style: normal;
    font-weight: 700;
    color: var(--nn-muted);
    background: rgba(255, 255, 255, 0.05);
}
.nn-a-feat i.on { color: #0f172a; background: var(--nn-c2); }
.nn-a-bar { height: 8px; border-radius: 4px; background: rgba(244, 114, 182, 0.35); overflow: hidden; }
.nn-a-bar span { display: block; height: 100%; background: var(--nn-c1); transition: width 0.2s; }
.nn-a-pred { text-align: right; font-variant-numeric: tabular-nums; color: var(--nn-muted); }
.nn-animal.is-ok .nn-a-pred { color: var(--nn-ok); }
.nn-animal.is-bad .nn-a-pred { color: var(--nn-bad); }
.nn-wrow {
    display: grid;
    grid-template-columns: 100px 1fr 44px;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
    font-size: 0.9em;
}
.nn-wrow b { text-align: right; font-variant-numeric: tabular-nums; }
.nn-wbar { position: relative; height: 12px; border-radius: 6px; background: rgba(255, 255, 255, 0.06); }
.nn-wbar::after { content: ''; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: rgba(255, 255, 255, 0.3); }
.nn-wbar span { position: absolute; top: 0; height: 100%; border-radius: 6px; transition: width 0.2s, left 0.2s; }
.nn-wbar span.pos { background: var(--nn-c1); }
.nn-wbar span.neg { background: var(--nn-neg); }
.nn-loss {
    display: block;
    width: 100%;
    height: 130px;
    border: 1px solid var(--nn-line);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.2);
}
.nn-train-note { margin: 16px 0 0; }

/* 5. Глубина */
.nn-tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.nn-tab {
    flex: 1;
    padding: 9px;
    border: 1px solid var(--nn-line);
    border-radius: 10px;
    background: transparent;
    color: var(--nn-muted);
    font: inherit;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
}
.nn-tab.is-active { color: #0f172a; border-color: transparent; background: linear-gradient(45deg, var(--nn-c1), var(--nn-c2)); }
.nn-deep-view { display: grid; grid-template-columns: 300px 1fr; gap: 24px; align-items: center; }
.nn-deep-svg { width: 100%; height: auto; }
.nn-deep-svg line,
.nn-deep-svg path,
.nn-deep-svg polygon,
.nn-deep-svg circle,
.nn-deep-svg ellipse {
    fill: none;
    stroke: var(--nn-c1);
    stroke-width: 2.5;
    stroke-linecap: round;
    transition: opacity 0.4s, fill 0.4s, stroke 0.4s;
}
.nn-deep-svg .nn-l2,
.nn-deep-svg .nn-l3 { opacity: 0; transition: opacity 0.4s; }
.nn-deep-svg[data-layer="1"] .nn-l1 line,
.nn-deep-svg[data-layer="1"] .nn-l1 path { stroke-dasharray: 4 5; }
.nn-deep-svg[data-layer="2"] .nn-l1 { opacity: 0.25; }
.nn-deep-svg[data-layer="2"] .nn-l2 { opacity: 1; }
.nn-deep-svg[data-layer="2"] .nn-l2 polygon,
.nn-deep-svg[data-layer="2"] .nn-l2 circle { fill: rgba(0, 242, 254, 0.18); }
.nn-deep-svg[data-layer="3"] .nn-l2,
.nn-deep-svg[data-layer="3"] .nn-l3 { opacity: 1; }
.nn-deep-svg[data-layer="3"] .nn-l2 polygon { fill: rgba(79, 172, 254, 0.35); stroke: var(--nn-c2); }
.nn-deep-svg[data-layer="3"] .nn-l2 circle { fill: var(--nn-c1); }
.nn-deep-svg[data-layer="3"] .nn-l3 ellipse { stroke: var(--nn-c2); fill: rgba(79, 172, 254, 0.08); }
.nn-deep-text { font-size: 1.05em; }

/* 7. Следующее слово */
.nn-llm-text {
    min-height: 3.2em;
    margin-bottom: 16px;
    font-size: 1.35em;
    font-weight: 600;
    color: #fff;
}
.nn-llm-text mark { padding: 0 4px; border-radius: 5px; background: rgba(0, 242, 254, 0.18); color: #a5f3fc; }
.nn-caret { color: var(--nn-c1); animation: nn-blink 1s steps(2) infinite; }
@keyframes nn-blink { 50% { opacity: 0; } }
.nn-llm-options { display: grid; gap: 8px; margin-bottom: 16px; }
.nn-opt {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border: 1px solid var(--nn-line);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--nn-text);
    font: inherit;
    text-align: left;
    cursor: pointer;
    overflow: hidden;
}
.nn-opt:hover { border-color: rgba(0, 242, 254, 0.5); }
.nn-opt-bar { position: absolute; left: 0; top: 0; bottom: 0; background: rgba(0, 242, 254, 0.12); }
.nn-opt-w,
.nn-opt-p { position: relative; }
.nn-opt-p { font-variant-numeric: tabular-nums; color: var(--nn-muted); }
.nn-llm-controls { display: flex; gap: 10px; margin-bottom: 14px; }

/* 9. Тест */
.nn-q { padding: 4px 0 16px; border-bottom: 1px dashed var(--nn-line); margin-bottom: 16px; }
.nn-q:last-child { border-bottom: 0; margin-bottom: 0; }
.nn-q-title { font-weight: 600; color: #fff; }
.nn-q-opts { display: grid; gap: 8px; }
.nn-q-opt {
    padding: 10px 14px;
    border: 1px solid var(--nn-line);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--nn-text);
    font: inherit;
    font-size: 0.95em;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}
.nn-q:not(.is-done) .nn-q-opt:hover { border-color: rgba(0, 242, 254, 0.5); }
.nn-q.is-done .nn-q-opt { cursor: default; }
.nn-q-opt.is-ok { border-color: var(--nn-ok); background: rgba(52, 211, 153, 0.12); }
.nn-q-opt.is-bad { border-color: var(--nn-bad); background: rgba(251, 113, 133, 0.12); }
.nn-q-fb { margin: 10px 0 0; font-size: 0.92em; color: var(--nn-muted); }
.nn-q-fb:empty { display: none; }
.nn-quiz-score { margin-top: 10px; font-size: 1.05em; }
.nn-quiz-score .nn-btn { margin-left: 8px; }

/* Итог */
.nn-summary {
    margin: 20px 0 10px;
    padding: 26px 28px;
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(0, 242, 254, 0.14), rgba(79, 172, 254, 0.06));
    border: 1px solid rgba(0, 242, 254, 0.35);
}
.nn-summary span {
    display: block;
    margin-bottom: 8px;
    font-size: 0.8em;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--nn-c1);
}
.nn-summary p { margin: 0; font-size: 1.2em; font-weight: 600; color: #fff; }

/* Адаптив */
@media (max-width: 768px) {
    .nn { font-size: 16px; }
    .nn h2 { font-size: 1.45em; }
    .nn-toc { top: 70px; }
    .nn-compare,
    .nn-types,
    .nn-train-grid,
    .nn-deep-view { grid-template-columns: 1fr; }
    .nn-deep-svg { max-width: 260px; margin: 0 auto; }
    .nn-nrow { grid-template-columns: 1fr; gap: 6px; }
    .nn-lab { padding: 16px; }
    .nn-train-stat { margin-left: 0; width: 100%; }
    .nn-animal { grid-template-columns: 1fr auto 60px 64px; gap: 6px; }
}

@media (prefers-reduced-motion: reduce) {
    .nn *,
    .nn *::before,
    .nn *::after {
        animation: none !important;
        transition: none !important;
    }
}
