:root {
    color-scheme: light dark;
    --bg: #eef2f7;
    --bg-2: #dbe7f3;
    --card: rgba(255, 255, 255, 0.86);
    --card-solid: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --soft: rgba(15, 23, 42, 0.07);
    --line: rgba(15, 23, 42, 0.12);
    --accent: #0f766e;
    --accent-2: #2563eb;
    --good: #16a34a;
    --talk: #dc2626;
    --warn: #d97706;
    --shadow: 0 10px 30px rgba(15, 23, 42, 0.10);
    --shadow-strong: 0 18px 48px rgba(15, 23, 42, 0.16);
    --radius-lg: 20px;
    --radius-md: 16px;
    --radius-sm: 11px;
    --max-width: 1380px;
}

[data-theme="dark"] {
    --bg: #020617;
    --bg-2: #0f172a;
    --card: rgba(15, 23, 42, 0.82);
    --card-solid: #111827;
    --text: #e5edf8;
    --muted: #94a3b8;
    --soft: rgba(226, 232, 240, 0.08);
    --line: rgba(226, 232, 240, 0.13);
    --accent: #2dd4bf;
    --accent-2: #60a5fa;
    --good: #4ade80;
    --talk: #fb7185;
    --warn: #fbbf24;
    --shadow: 0 12px 34px rgba(0, 0, 0, 0.30);
    --shadow-strong: 0 22px 56px rgba(0, 0, 0, 0.42);
}

* {
    box-sizing: border-box;
}

/* hidden должен всегда побеждать стили карточек/панелей.
   Иначе браузер может показать empty-state поверх уже отрисованных карточек. */
[hidden] {
    display: none !important;
}

html {
    min-height: 100%;
    background: var(--bg);
}

body {
    min-height: 100vh;
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(45, 212, 191, 0.13), transparent 28rem),
        radial-gradient(circle at top right, rgba(96, 165, 250, 0.14), transparent 28rem),
        linear-gradient(145deg, var(--bg), var(--bg-2));
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    border: 0;
}

.app-shell {
    width: min(100% - 20px, var(--max-width));
    margin: 0 auto;
    padding: max(8px, env(safe-area-inset-top)) 0 18px;
}

.top-bar,
.panel-card,
.compact-summary article,
.node-card {
    border: 1px solid var(--line);
    background: var(--card);
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.top-bar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 52px;
    padding: 8px 10px;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.brand-line,
.top-actions,
.status-pill,
.brand-mark,
.panel-head,
.node-card-head,
.node-footer,
.player-controls {
    display: flex;
    align-items: center;
}

.brand-line {
    min-width: 0;
    gap: 10px;
}

.brand-mark {
    flex: 0 0 auto;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 999px;
    background: var(--soft);
    color: var(--text);
    font-size: 0.78rem;
    font-weight: 900;
    letter-spacing: 0.08em;
}

.brand-dot,
.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--good);
    box-shadow: 0 0 0 6px rgba(22, 163, 74, 0.12);
}

.pulse-dot {
    animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(0.75); opacity: 0.55; }
}

.brand-title {
    min-width: 0;
}

.brand-title h1 {
    margin: 0;
    max-width: 56vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: clamp(0.92rem, 1.8vw, 1.18rem);
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.brand-title span {
    display: block;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--muted);
    font-size: 0.72rem;
}

.top-actions {
    flex: 0 0 auto;
    justify-content: flex-end;
    gap: 8px;
}

.status-pill {
    gap: 7px;
    min-height: 34px;
    padding: 7px 10px;
    border-radius: 999px;
    background: rgba(22, 163, 74, 0.12);
    color: var(--good);
    font-size: 0.76rem;
    font-weight: 800;
    white-space: nowrap;
}

.status-pill.is-offline {
    color: var(--talk);
    background: rgba(220, 38, 38, 0.13);
}

.status-pill.is-offline .pulse-dot {
    background: var(--talk);
    box-shadow: 0 0 0 6px rgba(220, 38, 38, 0.13);
}

.status-pill.is-warning {
    color: var(--warn);
    background: rgba(217, 119, 6, 0.13);
}

.status-pill.is-warning .pulse-dot {
    background: var(--warn);
    box-shadow: 0 0 0 6px rgba(217, 119, 6, 0.13);
}

.theme-toggle,
.listen-button {
    cursor: pointer;
    color: var(--text);
    background: var(--soft);
    transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.theme-toggle {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    font-size: 1rem;
}

.theme-toggle:hover {
    transform: translateY(-1px);
    background: rgba(45, 212, 191, 0.15);
}

.listen-button:hover {
    transform: translateY(-1px) scale(1.03);
}

.compact-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin: 10px 0;
}

.compact-summary article {
    min-height: 54px;
    border-radius: var(--radius-sm);
    padding: 8px 10px;
}

.compact-summary span {
    display: block;
    color: var(--muted);
    font-size: 0.70rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.compact-summary strong {
    display: block;
    margin-top: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: clamp(1rem, 2.3vw, 1.28rem);
    line-height: 1.1;
}

.dashboard-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
    align-items: start;
    gap: 10px;
}

.panel-card {
    border-radius: var(--radius-lg);
    padding: 12px;
}

.compact-head {
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.eyebrow {
    margin: 0 0 2px;
    color: var(--accent);
    font-size: 0.68rem;
    font-weight: 900;
    letter-spacing: 0.10em;
    text-transform: uppercase;
}

h2 {
    margin: 0;
    font-size: 1rem;
    line-height: 1.15;
    letter-spacing: -0.02em;
}

.mini-hint,
.audio-badge {
    flex: 0 0 auto;
    padding: 6px 9px;
    border-radius: 999px;
    color: var(--muted);
    background: var(--soft);
    font-size: 0.72rem;
    font-weight: 800;
    white-space: nowrap;
}

.audio-badge.is-ready {
    color: var(--good);
    background: rgba(22, 163, 74, 0.12);
}

.audio-badge.is-error {
    color: var(--talk);
    background: rgba(220, 38, 38, 0.13);
}

.audio-badge.is-wait {
    color: var(--warn);
    background: rgba(217, 119, 6, 0.13);
}

.nodes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 8px;
}

.node-card {
    position: relative;
    overflow: hidden;
    min-height: 132px;
    border-radius: var(--radius-md);
    padding: 9px;
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.node-card:hover {
    transform: translateY(-1px);
    border-color: rgba(45, 212, 191, 0.42);
}

.node-card.is-clickable {
    cursor: pointer;
}

.node-card.is-clickable:focus-visible {
    outline: 3px solid rgba(45, 212, 191, 0.45);
    outline-offset: 2px;
}

.node-card.is-clickable.is-talker::after {
    content: "Нажми, чтобы слушать";
    position: absolute;
    right: 8px;
    bottom: 7px;
    padding: 3px 6px;
    border-radius: 999px;
    color: #fff;
    background: rgba(220, 38, 38, 0.86);
    font-size: 0.58rem;
    font-weight: 900;
    letter-spacing: 0.02em;
}

.node-card.is-talker {
    border-color: rgba(220, 38, 38, 0.62);
    background:
        linear-gradient(135deg, rgba(220, 38, 38, 0.18), transparent 56%),
        var(--card);
    box-shadow: var(--shadow-strong);
    animation: talkerBlink 1.05s ease-in-out infinite;
}

@keyframes talkerBlink {
    0%, 100% { box-shadow: 0 0 0 rgba(220, 38, 38, 0), var(--shadow-strong); }
    50% { box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.18), var(--shadow-strong); }
}

.node-card.is-lastheard:not(.is-talker) {
    border-color: rgba(217, 119, 6, 0.45);
    background:
        linear-gradient(135deg, rgba(217, 119, 6, 0.13), transparent 58%),
        var(--card);
}

.node-card-head {
    justify-content: space-between;
    gap: 8px;
}

.node-avatar {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    overflow: hidden;
    border-radius: 11px;
    color: #fff;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.03em;
}

.node-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.node-main-title {
    min-width: 0;
    flex: 1 1 auto;
}

.node-main-title h3 {
    margin: 0;
    overflow: visible;
    word-break: normal;
    overflow-wrap: anywhere;
    font-size: clamp(0.92rem, 1.5vw, 1.05rem);
    line-height: 1.05;
    letter-spacing: 0.015em;
}

.node-main-title p {
    margin: 2px 0 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--muted);
    font-size: 0.72rem;
}

.node-state {
    flex: 0 0 auto;
    padding: 5px 7px;
    border-radius: 999px;
    color: var(--good);
    background: rgba(22, 163, 74, 0.12);
    font-size: 0.66rem;
    font-weight: 900;
    text-transform: uppercase;
}

.is-talker .node-state {
    color: #fff;
    background: var(--talk);
}

.is-lastheard:not(.is-talker) .node-state {
    color: var(--warn);
    background: rgba(217, 119, 6, 0.12);
}

.node-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
    margin-top: 9px;
}

.meta-row {
    min-width: 0;
    padding: 6px 7px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--soft);
}

.meta-row span {
    display: block;
    color: var(--muted);
    font-size: 0.63rem;
    font-weight: 900;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.meta-row strong {
    display: block;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.75rem;
    line-height: 1.18;
}

.compact-primary {
    grid-column: 1 / -1;
}

.compact-primary strong {
    white-space: normal;
}

.node-footer {
    justify-content: space-between;
    gap: 8px;
    margin-top: 8px;
    color: var(--muted);
    font-size: 0.68rem;
}

.node-footer span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.node-footer span:first-child {
    flex: 0 0 auto;
}

.bad-version {
    color: var(--warn);
    font-weight: 900;
}

.info-stack {
    display: grid;
    gap: 10px;
}

.player-controls {
    gap: 8px;
    margin: 10px 0 8px;
}

.tg-picker {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 8px;
    padding: 7px 9px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--soft);
}

.tg-picker span {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 900;
}

.tg-picker select {
    flex: 1 1 auto;
    min-width: 0;
    border: 0;
    outline: none;
    color: var(--text);
    background: transparent;
    font-weight: 800;
}

/* Нативный список option рисуется системой, поэтому задаём контраст явно. */
.tg-picker select option {
    color: #0f172a;
    background: #ffffff;
}

[data-theme="dark"] .tg-picker select option {
    color: #e5edf8;
    background: #0f172a;
}

.listen-button {
    position: relative;
    flex: 0 0 auto;
    display: inline-grid;
    place-items: center;
    width: 42px;
    height: 42px;
    min-height: 42px;
    padding: 0;
    overflow: hidden;
    border-radius: 50%;
    color: #fff;
    font-size: 1.05rem;
    font-weight: 900;
    box-shadow: 0 10px 22px rgba(15, 23, 42, 0.20);
}

.listen-button::before {
    content: "";
    position: absolute;
    inset: -35%;
    opacity: 0;
    background: conic-gradient(from 0deg, transparent, rgba(255, 255, 255, 0.62), transparent 34%);
}

.listen-button.is-off {
    background: linear-gradient(135deg, #dc2626, #991b1b);
}

.listen-button.is-waiting {
    background: linear-gradient(135deg, #16a34a, #15803d);
    animation: playWaitPulse 1.35s ease-in-out infinite;
}

.listen-button.is-waiting::before {
    opacity: 0.45;
    animation: playSweep 1.5s linear infinite;
}

.listen-button.is-playing {
    background: linear-gradient(135deg, #22c55e, #06b6d4);
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.16), 0 0 26px rgba(34, 197, 94, 0.48);
    animation: playGlow 0.82s ease-in-out infinite;
}

.listen-button.is-playing::before {
    opacity: 0.62;
    animation: playSweep 0.9s linear infinite;
}

.listen-button.is-error {
    background: linear-gradient(135deg, #f59e0b, #dc2626);
}

.listen-button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
    transform: none;
}

.play-icon {
    position: relative;
    z-index: 1;
    transform: translateX(1px);
    line-height: 1;
}

.play-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

@keyframes playWaitPulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.24); }
    50% { transform: scale(1.04); box-shadow: 0 0 0 7px rgba(22, 163, 74, 0.05); }
}

@keyframes playGlow {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.22); }
}

@keyframes playSweep {
    to { transform: rotate(360deg); }
}

.player-note {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 0.78rem;
    line-height: 1.35;
}

.scanner-box {
    margin-top: 10px;
    padding: 9px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--soft);
}

.scanner-head,
.scanner-editor,
.scanner-chips {
    display: flex;
    align-items: center;
}

.scanner-head {
    justify-content: space-between;
    gap: 8px;
    color: var(--text);
    font-size: 0.78rem;
    font-weight: 900;
}

.scanner-editor {
    gap: 7px;
    margin-top: 8px;
}

.scanner-editor input {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 34px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 11px;
    outline: none;
    color: var(--text);
    background: var(--card-solid);
    font-size: 0.8rem;
    font-weight: 800;
}

.mini-button {
    cursor: pointer;
    min-height: 30px;
    padding: 0 9px;
    border-radius: 10px;
    color: var(--text);
    background: var(--card-solid);
    font-size: 0.72rem;
    font-weight: 900;
}

.mini-button.accent {
    color: #fff;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.scanner-chips {
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.scanner-chip {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 28px;
    padding: 0 8px;
    border-radius: 999px;
    color: var(--text);
    background: var(--card-solid);
    font-size: 0.74rem;
    font-weight: 900;
}

.scanner-chip b {
    color: var(--talk);
    font-size: 0.92rem;
    line-height: 1;
}

.scanner-empty {
    color: var(--muted);
    font-size: 0.74rem;
    font-weight: 800;
}

.scanner-note {
    margin: 7px 0 0;
    color: var(--muted);
    font-size: 0.72rem;
    line-height: 1.3;
}

.info-list {
    margin: 8px 0 0;
}

.info-list div {
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr);
    gap: 8px;
    padding: 8px 0;
    border-top: 1px solid var(--line);
}

.info-list dt {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 900;
    text-transform: uppercase;
}

.info-list dd {
    min-width: 0;
    margin: 0;
    overflow-wrap: anywhere;
    font-size: 0.78rem;
    font-weight: 700;
}

.legend-list {
    margin: 8px 0 0;
    padding: 0;
    list-style: none;
}

.legend-list li {
    padding: 7px 0;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.78rem;
    line-height: 1.35;
}

.empty-state {
    display: grid;
    place-items: center;
    min-height: 220px;
    padding: 24px;
    text-align: center;
    color: var(--muted);
}

.empty-state h3 {
    margin: 8px 0 4px;
    color: var(--text);
}

.empty-state p {
    margin: 0;
}

.empty-icon {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--soft);
    font-size: 1.7rem;
}

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

    .nodes-panel {
        order: 1;
    }

    .info-stack {
        order: 2;
    }
}

@media (max-width: 680px) {
    .app-shell {
        width: min(100% - 12px, var(--max-width));
        padding-top: 0;
    }

    .top-bar {
        border-radius: 0 0 14px 14px;
    }

    .brand-title h1 {
        max-width: 44vw;
        font-size: 0.9rem;
    }

    .status-pill span:last-child {
        display: none;
    }

    .compact-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px;
        margin: 8px 0;
    }

    .nodes-grid {
        grid-template-columns: 1fr;
        gap: 7px;
    }

    .node-card {
        min-height: auto;
    }

    .node-meta {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .panel-card {
        padding: 10px;
        border-radius: 16px;
    }

    .player-controls {
        align-items: stretch;
        flex-direction: column;
    }

    .listen-button {
        width: 46px;
        height: 46px;
        align-self: flex-end;
    }

    .scanner-editor {
        align-items: stretch;
        flex-direction: column;
    }

    .mini-button.accent {
        width: 100%;
    }
}

@media (min-width: 1280px) {
    .nodes-grid {
        grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    }
}


/* Native select dropdown: отдельные браузеры не наследуют тему от select. */
.tg-picker option {
    color: #0f172a;
    background: #ffffff;
}

[data-theme="dark"] .tg-picker option {
    color: #e5edf8;
    background: #111827;
}

/* 20260707t: выравнивание общего контейнера и детализация карточек. */
.top-bar,
.compact-summary,
.dashboard-layout {
    width: 100%;
}

.app-shell {
    width: min(100% - 14px, var(--max-width));
}

.node-state-last-swap {
    position: relative;
    display: inline-grid;
    min-width: 52px;
    justify-items: center;
    overflow: hidden;
}

.node-state-last-swap .state-last,
.node-state-last-swap .state-online {
    grid-area: 1 / 1;
    transition: opacity 0.2s ease;
}

.node-state-last-swap .state-last {
    animation: lastOnlineLast 2.2s ease-in-out infinite;
}

.node-state-last-swap .state-online {
    animation: lastOnlineOnline 2.2s ease-in-out infinite;
}

@keyframes lastOnlineLast {
    0%, 42% { opacity: 1; transform: translateY(0); }
    55%, 100% { opacity: 0; transform: translateY(-4px); }
}

@keyframes lastOnlineOnline {
    0%, 42% { opacity: 0; transform: translateY(4px); }
    55%, 100% { opacity: 1; transform: translateY(0); }
}

.node-card.is-clickable::after {
    content: "Подробнее";
    position: absolute;
    right: 8px;
    bottom: 7px;
    padding: 3px 6px;
    border-radius: 999px;
    color: var(--muted);
    background: var(--soft);
    font-size: 0.56rem;
    font-weight: 900;
    letter-spacing: 0.02em;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.16s ease, transform 0.16s ease;
}

.node-card.is-clickable:hover::after,
.node-card.is-clickable:focus-visible::after {
    opacity: 1;
    transform: translateY(0);
}

.node-card.is-clickable.is-talker::after {
    content: "Подробнее";
    color: #fff;
    background: rgba(220, 38, 38, 0.86);
}

.node-modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 16px;
}

.node-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(2, 6, 23, 0.72);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.node-modal-dialog {
    position: relative;
    z-index: 1;
    width: min(720px, 100%);
    max-height: min(86vh, 760px);
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 24px;
    background: var(--card-solid);
    box-shadow: var(--shadow-strong);
    padding: 18px;
}

.node-modal-close {
    cursor: pointer;
    position: absolute;
    top: 12px;
    right: 12px;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    color: var(--text);
    background: var(--soft);
    font-size: 1.4rem;
    line-height: 1;
}

.node-modal-head {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr) auto;
    align-items: center;
    gap: 14px;
    padding-right: 42px;
}

.node-modal-avatar {
    display: grid;
    place-items: center;
    width: 96px;
    height: 96px;
    overflow: hidden;
    border-radius: 24px;
    color: #fff;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    font-size: 1.35rem;
    font-weight: 950;
    letter-spacing: 0.04em;
}

.node-modal-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.node-modal-titlebox {
    min-width: 0;
}

.node-modal-titlebox h2 {
    overflow-wrap: anywhere;
    font-size: clamp(1.25rem, 3vw, 1.85rem);
}

.node-modal-titlebox p:not(.eyebrow) {
    margin: 6px 0 0;
    color: var(--muted);
    overflow-wrap: anywhere;
}

.node-modal-state {
    justify-self: end;
    padding: 7px 10px;
    border-radius: 999px;
    color: var(--good);
    background: rgba(22, 163, 74, 0.12);
    font-size: 0.76rem;
    font-weight: 900;
    text-transform: uppercase;
}

.node-modal-state.is-talker {
    color: #fff;
    background: var(--talk);
}

.node-modal-state.is-lastheard {
    color: var(--warn);
    background: rgba(217, 119, 6, 0.13);
}

.node-modal-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 16px;
}

.node-detail-row {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 10px;
    background: var(--soft);
}

.node-detail-row.is-important {
    background: linear-gradient(135deg, rgba(45, 212, 191, 0.12), var(--soft));
}

.node-detail-row span {
    display: block;
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 900;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.node-detail-row strong {
    display: block;
    margin-top: 4px;
    overflow-wrap: anywhere;
    font-size: 0.9rem;
}

.node-modal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

.node-modal-raw {
    margin-top: 14px;
    border-top: 1px solid var(--line);
    padding-top: 10px;
}

.node-modal-raw summary {
    cursor: pointer;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 900;
}

.node-modal-raw pre {
    max-height: 240px;
    overflow: auto;
    padding: 10px;
    border-radius: 12px;
    background: var(--soft);
    font-size: 0.74rem;
    line-height: 1.35;
    white-space: pre-wrap;
}

body.has-node-modal {
    overflow: hidden;
}

@media (max-width: 680px) {
    .node-modal-head {
        grid-template-columns: 72px minmax(0, 1fr);
    }

    .node-modal-avatar {
        width: 72px;
        height: 72px;
        border-radius: 18px;
        font-size: 1rem;
    }

    .node-modal-state {
        grid-column: 1 / -1;
        justify-self: start;
    }

    .node-modal-grid {
        grid-template-columns: 1fr;
    }
}

/* 20260707t: карточки всегда открывают подробности, модалка стала компактным текстовым паспортом ноды. */
.node-card.is-clickable::after {
    content: "Подробнее";
}

.node-card.is-clickable.is-talker::after {
    content: "Подробнее";
}

.node-modal-dialog {
    width: min(680px, 100%);
}

.node-modal-text {
    display: block;
    margin-top: 16px;
    border: 1px solid var(--line);
    border-radius: 18px;
    overflow: hidden;
    background: var(--soft);
}

.node-detail-section {
    padding: 9px 12px 7px;
    color: var(--accent-strong);
    background: rgba(45, 212, 191, 0.08);
    border-top: 1px solid var(--line);
    font-size: 0.72rem;
    font-weight: 950;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.node-detail-section:first-child {
    border-top: 0;
}

.node-detail-row {
    display: grid;
    grid-template-columns: minmax(112px, 0.34fr) minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    min-width: 0;
    border: 0;
    border-top: 1px solid var(--line);
    border-radius: 0;
    padding: 8px 12px;
    background: transparent;
}

.node-detail-row.is-important {
    background: rgba(45, 212, 191, 0.055);
}

.node-detail-row span {
    display: block;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 950;
    letter-spacing: 0.035em;
    text-transform: uppercase;
}

.node-detail-row strong {
    display: block;
    margin-top: 0;
    color: var(--text);
    overflow-wrap: anywhere;
    font-size: 0.9rem;
    line-height: 1.35;
}

.node-modal-grid {
    grid-template-columns: 1fr;
}

@media (max-width: 680px) {
    .node-detail-row {
        grid-template-columns: 1fr;
        gap: 3px;
    }
}

/* 20260707u: ускорение UI и масштабируемое окно подробностей. */
.node-card {
    contain: layout paint style;
    content-visibility: auto;
    contain-intrinsic-size: 190px;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    transition: transform 90ms ease, border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.node-card:hover {
    transform: translateY(-1px);
}

.nodes-grid {
    align-items: start;
}

.node-modal-backdrop {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.node-modal-dialog {
    resize: both;
    min-width: min(360px, calc(100vw - 32px));
    min-height: 320px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 32px);
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    will-change: transform;
}

.node-modal-dialog::after {
    content: "";
    position: sticky;
    float: right;
    display: block;
    width: 16px;
    height: 16px;
    margin: 4px -6px -8px 0;
    opacity: 0.55;
    background:
        linear-gradient(135deg, transparent 0 45%, var(--muted) 46% 55%, transparent 56%),
        linear-gradient(135deg, transparent 0 62%, var(--muted) 63% 70%, transparent 71%);
    pointer-events: none;
}

.node-modal-raw pre {
    contain: content;
}

@media (max-width: 680px) {
    .node-modal-dialog {
        resize: none;
        width: calc(100vw - 18px);
        max-width: calc(100vw - 18px);
        max-height: calc(100vh - 18px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .node-card,
    .node-card:hover {
        transition: none;
        transform: none;
    }
}


/* 20260707w: возврат нормального вида карточек.
   Карточки снова заполняют ширину сетки, не имеют жёсткой высоты
   и не обрезают внутренние строки. Частоты остаются только в подробностях. */
.nodes-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    justify-content: stretch;
    align-items: stretch;
    grid-auto-rows: auto;
    gap: 8px;
}

.node-card {
    width: auto;
    height: auto;
    min-height: 132px;
    max-height: none;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.node-meta {
    flex: 0 0 auto;
    overflow: visible;
    align-content: stretch;
}

.node-footer {
    flex: 0 0 auto;
    min-height: 16px;
}

.node-card .meta-row {
    min-height: 0;
}

.node-card .meta-row:nth-child(n+4) {
    display: none;
}

@media (min-width: 1280px) {
    .nodes-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }
}

@media (max-width: 680px) {
    .nodes-grid {
        grid-template-columns: 1fr;
    }

    .node-card {
        width: auto;
        min-height: 132px;
    }
}


/* 20260707x: корректная последняя активная нода и кнопка быстрого добавления TG. */
.node-card.is-clickable::after,
.node-card.is-clickable:hover::after,
.node-card.is-clickable:focus-visible::after,
.node-card.is-clickable.is-talker::after {
    display: none;
}

.node-footer {
    align-items: center;
}

.card-quick-listen {
    flex: 0 0 auto;
    margin-left: auto;
    padding: 3px 7px;
    border: 1px solid rgba(45, 212, 191, 0.30);
    border-radius: 999px;
    color: var(--accent);
    background: rgba(45, 212, 191, 0.10);
    font-size: 0.58rem;
    font-weight: 900;
    letter-spacing: 0.03em;
    cursor: pointer;
    transition: transform 0.14s ease, background 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}

.card-quick-listen:hover,
.card-quick-listen:focus-visible {
    transform: translateY(-1px);
    color: #fff;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border-color: transparent;
    outline: none;
}

.node-card.is-talker .card-quick-listen {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.22);
    background: rgba(220, 38, 38, 0.86);
}

.node-card.is-lastheard:not(.is-talker) .card-quick-listen {
    color: var(--warn);
    border-color: rgba(217, 119, 6, 0.30);
    background: rgba(217, 119, 6, 0.12);
}
