:root {
    color-scheme: dark;
    --bg: #111318;
    --sidebar: #15171d;
    --panel: #191c23;
    --hover: #222630;
    --border: #2c303a;
    --text: #e8eaf0;
    --muted: #858b99;
    --accent: #c94b4b;
    --green: #55c78a;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, "Segoe UI", Arial, sans-serif;
}

.header {
    height: 70px;
    padding: 0 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--sidebar);
    border-bottom: 1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border: 2px solid var(--accent);
    color: var(--accent);
    font-size: 13px;
    font-weight: 800;
}

.logo-title {
    font-size: 16px;
    font-weight: 750;
    letter-spacing: 1px;
}

.logo-subtitle {
    margin-top: 3px;
    color: var(--muted);
    font-size: 9px;
    letter-spacing: 2px;
}

.header-status {
    color: var(--muted);
    font-size: 12px;
}

.status-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-right: 6px;
    border-radius: 50%;
    background: var(--green);
}

.layout {
    display: grid;
    grid-template-columns: 290px minmax(0, 1fr);
    min-height: calc(100vh - 120px);
}

.sidebar {
    padding: 25px 15px;
    background: var(--sidebar);
    border-right: 1px solid var(--border);
}

.sidebar-heading {
    padding: 0 10px 17px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.5px;
}

.nav-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
}

.nav-tab {
    flex: 1;
    padding: 10px 5px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 12px;
}

.nav-tab.active {
    background: #292d37;
    color: var(--text);
    border-color: #454b58;
}

.section-tree {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.tree-item {
    width: 100%;
    padding: 10px;
    border: 0;
    border-radius: 5px;
    background: transparent;
    color: #c3c7d0;
    text-align: left;
    font-size: 12px;
    line-height: 1.5;
    cursor: pointer;
}

.tree-item:hover {
    background: var(--hover);
}

.tree-item.active {
    background: #382326;
    color: #ed9292;
}

.tree-section {
    font-weight: 650;
}

.tree-subsection {
    padding-left: 25px;
    color: var(--muted);
    font-weight: 400;
}

.tree-children {
    display: flex;
    flex-direction: column;
}

.tree-toggle {
    display: inline-block;
    width: 18px;
    color: var(--muted);
}

.content {
    min-width: 0;
    padding: 45px clamp(20px, 5vw, 70px);
}

.welcome {
    max-width: 750px;
    padding-top: 70px;
}

.welcome-label {
    color: var(--accent);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 2px;
}

h1 {
    margin: 17px 0;
    font-size: clamp(30px, 4vw, 45px);
    letter-spacing: -1.5px;
}

.welcome p {
    color: var(--muted);
    line-height: 1.7;
}

.document-heading {
    margin-bottom: 30px;
    padding-bottom: 22px;
    border-bottom: 1px solid var(--border);
}

.document-number {
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
}

.document-heading h1 {
    margin: 10px 0;
    font-size: 30px;
}

.document-subtitle {
    color: var(--muted);
    font-size: 12px;
}

.result-card {
    margin-bottom: 13px;
    padding: 20px 22px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 7px;
}

.result-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-bottom: 12px;
}

.badge {
    padding: 5px 8px;
    border-radius: 4px;
    background: #292d37;
    color: #b6bdca;
    font-size: 10px;
}

.badge-number {
    background: #382326;
    color: #ed9292;
}

.result-title {
    margin: 0 0 12px;
    font-size: 15px;
}

.result-text {
    color: #c3c7d0;
    font-size: 14px;
    line-height: 1.8;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.result-context {
    margin-top: 13px;
    color: var(--muted);
    font-size: 11px;
}

.table-wrapper {
    margin: 18px 0 25px;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 7px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

td {
    min-width: 90px;
    padding: 11px;
    border: 1px solid var(--border);
    color: #c3c7d0;
    line-height: 1.5;
    white-space: pre-wrap;
}

tr:first-child td {
    background: #242832;
    color: var(--text);
    font-weight: 650;
}

.search-box {
    display: flex;
    height: 55px;
    margin: 25px 0;
    padding: 0 15px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 7px;
}

.search-box:focus-within {
    border-color: var(--accent);
}

.search-box input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
    font-size: 14px;
}

.search-box button {
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 24px;
    cursor: pointer;
}

.empty-state {
    padding: 35px 20px;
    color: var(--muted);
    text-align: center;
    background: var(--panel);
    border: 1px dashed var(--border);
    border-radius: 7px;
}

footer {
    display: flex;
    justify-content: space-between;
    padding: 22px 28px;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 11px;
}

[hidden] {
    display: none !important;
}

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

    .sidebar {
        border-right: 0;
        border-bottom: 1px solid var(--border);
        padding: 15px;
    }

    .section-tree {
        max-height: 350px;
        overflow-y: auto;
    }

    .content {
        padding: 30px 18px;
    }

    .welcome {
        padding-top: 25px;
    }
}

/* Исправленная навигация */
.tree-row {
    gap: 4px;
}

.tree-toggle {
    flex: 0 0 24px;
    width: 24px;
    min-width: 24px;
    padding: 5px 0;
    border: none;
    background: transparent;
    color: #aab4c5;
    cursor: pointer;
    text-align: center;
}

.tree-toggle:hover {
    color: #ffffff;
}

/* Отображение документа */
.document-paragraph {
    margin: 8px 0 14px;
    line-height: 1.7;
    white-space: pre-wrap;
}

.rule-entry {
    margin: 12px 0;
    padding: 12px 16px;
    border-left: 3px solid #526b99;
    background: rgba(255, 255, 255, 0.025);
    border-radius: 4px;
}

.rule-entry .result-text {
    margin-top: 7px;
    line-height: 1.65;
    white-space: pre-wrap;
}

.subsection-card {
    margin: 22px 0;
    padding: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
}

.subsection-card .result-title {
    margin-top: 0;
}

.open-subsection {
    margin-top: 12px;
    padding: 7px 12px;
    border: 1px solid #526b99;
    border-radius: 5px;
    background: transparent;
    color: inherit;
    cursor: pointer;
}

.open-subsection:hover {
    background: rgba(82, 107, 153, 0.2);
}

/* === Structured rule subitems === */

.rule-main-text {
    white-space: pre-wrap;
    line-height: 1.55;
}

.rule-subitems {
    margin-top: 0.45rem;
    padding-left: 0.35rem;
}

.rule-subheading {
    margin-top: 0.45rem;
    margin-bottom: 0.15rem;
    font-size: inherit;
    font-weight: 600;
    line-height: 1.5;
}

.rule-subitem {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-top: 0.22rem;
    padding-left: 0.15rem;
    font-size: inherit;
    font-weight: 400;
    line-height: 1.5;
}

.rule-subitem-marker {
    flex: 0 0 auto;
    width: 0.7rem;
    font-size: 0.9em;
    font-weight: 600;
    line-height: 1.5;
    text-align: center;
}

.rule-subitem-text {
    min-width: 0;
    white-space: pre-wrap;
    font-size: inherit;
    font-weight: 400;
    line-height: 1.5;
}

/* === UX ADAPTATION V1 START === */

/* ---------- Общая геометрия ---------- */

html {
    scroll-behavior: smooth;
}

body {
    min-width: 320px;
    overflow-x: hidden;
}

button,
input {
    font: inherit;
}

button {
    transition:
        background-color 0.15s ease,
        border-color 0.15s ease,
        color 0.15s ease,
        opacity 0.15s ease;
}

/* ---------- Шапка ---------- */

.header {
    position: sticky;
    top: 0;
    z-index: 100;
    height: 64px;
    padding: 0 clamp(16px, 2.5vw, 28px);
    backdrop-filter: blur(12px);
    background: rgba(21, 23, 29, 0.96);
}

.logo-icon {
    width: 36px;
    height: 36px;
}

.logo-title {
    font-size: 15px;
}

.header-status {
    display: flex;
    align-items: center;
    white-space: nowrap;
}

/* ---------- Основная сетка ---------- */

.layout {
    grid-template-columns: 280px minmax(0, 1fr);
    min-height: calc(100vh - 108px);
}

/* ---------- Sidebar ---------- */

.sidebar {
    position: sticky;
    top: 64px;
    align-self: start;
    height: calc(100vh - 64px);
    padding: 22px 14px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #343945 transparent;
}

.sidebar::-webkit-scrollbar {
    width: 7px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: #343945;
    border-radius: 999px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-heading {
    padding-bottom: 14px;
}

.nav-tabs {
    position: sticky;
    top: -22px;
    z-index: 5;
    padding: 10px 0 12px;
    margin-bottom: 8px;
    background: var(--sidebar);
}

.nav-tab {
    min-height: 38px;
}

.nav-tab:hover {
    background: var(--hover);
    color: var(--text);
}

.tree-row {
    border-radius: 6px;
}

.tree-item {
    min-height: 38px;
    padding: 9px 10px;
    border-radius: 6px;
    transition:
        background-color 0.15s ease,
        color 0.15s ease;
}

.tree-item:hover {
    color: var(--text);
}

.tree-item.active {
    box-shadow: inset 3px 0 0 var(--accent);
}

.tree-toggle {
    border-radius: 5px;
}

.tree-toggle:hover {
    background: var(--hover);
}

/* ---------- Контент ---------- */

.content {
    width: 100%;
    padding:
        clamp(28px, 4vw, 48px)
        clamp(20px, 4.5vw, 64px)
        56px;
}

#welcome,
#searchPanel,
#documentContent {
    width: min(100%, 1180px);
    margin-inline: auto;
}

.welcome {
    max-width: 760px;
    margin-inline: 0;
    padding-top: clamp(30px, 7vh, 80px);
}

/* ---------- Заголовки ---------- */

h1 {
    line-height: 1.12;
}

.document-heading {
    margin-bottom: 24px;
    padding-bottom: 20px;
}

.document-heading h1 {
    margin-bottom: 0;
    font-size: clamp(26px, 3vw, 34px);
    line-height: 1.15;
}

/* ---------- Правила ---------- */

.rule-entry {
    margin: 10px 0;
    padding: 13px 16px;
    border-left-width: 3px;
    border-radius: 5px;
    transition:
        background-color 0.15s ease,
        border-color 0.15s ease;
}

.rule-entry:hover {
    background: rgba(255, 255, 255, 0.04);
    border-left-color: #6c8ac0;
}

.result-text,
.rule-main-text,
.rule-subitem,
.document-paragraph {
    font-size: 14px;
    line-height: 1.62;
}

.rule-main-text {
    color: #d3d7df;
}

.rule-subitems {
    margin-top: 0.5rem;
    padding-left: 0.5rem;
}

.rule-subitem {
    gap: 0.45rem;
    margin-top: 0.22rem;
}

.rule-subitem-marker {
    width: 0.65rem;
    color: #8fa7d4;
}

.rule-subitem-text {
    color: #c7ccd5;
}

.rule-subheading {
    color: #e2e5eb;
}

/* ---------- Подразделы ---------- */

.subsection-card {
    margin: 18px 0;
    background: rgba(255, 255, 255, 0.018);
}

.open-subsection {
    min-height: 36px;
}

/* ---------- Поиск ---------- */

#searchPanel > h1 {
    margin-top: 0;
}

.search-box {
    position: sticky;
    top: 82px;
    z-index: 50;
    height: 52px;
    margin: 20px 0 24px;
    background: rgba(25, 28, 35, 0.96);
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
}

.search-box input {
    font-size: 15px;
}

.search-box button {
    width: 42px;
    min-width: 42px;
    border-radius: 5px;
}

.search-box button:hover {
    color: var(--text);
    background: var(--hover);
}

.result-card {
    transition:
        background-color 0.15s ease,
        border-color 0.15s ease,
        transform 0.15s ease;
}

.result-card:hover {
    border-color: #3b414e;
    background: #1c2028;
}

/* ---------- Таблицы ---------- */

.table-wrapper {
    max-width: 100%;
    scrollbar-width: thin;
}

table {
    min-width: 520px;
}

td {
    vertical-align: top;
}

/* ---------- Footer ---------- */

footer {
    min-height: 44px;
    padding: 14px 20px;
}

/* ---------- Планшеты ---------- */

@media (max-width: 1100px) {
    .layout {
        grid-template-columns: 240px minmax(0, 1fr);
    }

    .content {
        padding-inline: 28px;
    }

    .tree-item {
        font-size: 11.5px;
    }
}

/* ---------- Мобильная версия ---------- */

@media (max-width: 800px) {
    .header {
        position: sticky;
        height: 58px;
        padding: 0 14px;
    }

    .logo {
        gap: 9px;
    }

    .logo-icon {
        width: 32px;
        height: 32px;
        font-size: 11px;
    }

    .logo-title {
        font-size: 13px;
    }

    .logo-subtitle {
        font-size: 8px;
        letter-spacing: 1.4px;
    }

    .header-status {
        font-size: 10px;
    }

    .layout {
        display: block;
        min-height: 0;
    }

    .sidebar {
        position: relative;
        top: auto;
        height: auto;
        max-height: none;
        padding: 12px;
        border-right: 0;
        border-bottom: 1px solid var(--border);
        overflow: visible;
    }

    .sidebar-heading {
        display: none;
    }

    .nav-tabs {
        position: static;
        padding: 0;
        margin: 0 0 10px;
    }

    .nav-tab {
        min-height: 42px;
    }

    .section-tree {
        max-height: 260px;
        padding-right: 4px;
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .tree-item {
        min-height: 42px;
        font-size: 12px;
    }

    .content {
        padding: 24px 14px 40px;
    }

    #welcome,
    #searchPanel,
    #documentContent {
        width: 100%;
    }

    .welcome {
        padding-top: 16px;
    }

    h1 {
        font-size: 28px;
    }

    .document-heading {
        margin-bottom: 18px;
        padding-bottom: 16px;
    }

    .document-heading h1 {
        font-size: 25px;
    }

    .rule-entry {
        margin: 8px 0;
        padding: 12px 13px;
    }

    .result-text,
    .rule-main-text,
    .rule-subitem,
    .document-paragraph {
        font-size: 14px;
        line-height: 1.58;
    }

    .rule-subitems {
        padding-left: 0.15rem;
    }

    .search-box {
        top: 66px;
        height: 48px;
        margin-top: 12px;
    }

    .result-card {
        padding: 15px;
    }

    .subsection-card {
        padding: 13px;
    }

    .table-wrapper {
        margin-inline: -2px;
    }

    footer {
        gap: 12px;
        flex-wrap: wrap;
        padding: 12px 14px;
    }
}

/* ---------- Очень маленькие экраны ---------- */

@media (max-width: 480px) {
    .logo-subtitle {
        display: none;
    }

    .header-status {
        max-width: 100px;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .content {
        padding-inline: 11px;
    }

    .rule-entry {
        padding: 11px;
    }

    .result-text,
    .rule-main-text,
    .rule-subitem,
    .document-paragraph {
        font-size: 13.5px;
    }

    .tree-subsection {
        padding-left: 18px;
    }

    footer {
        font-size: 9px;
    }
}

/* ---------- Доступность ---------- */

button:focus-visible,
input:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition: none !important;
    }
}

/* === UX ADAPTATION V1 END === */

/* === UX CONTROLS V1 START === */

.header-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

.sidebar-toggle {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
}

.sidebar-toggle:hover {
    background: var(--hover);
    border-color: #454b58;
    color: var(--text);
}

/* ---------- Collapsed desktop sidebar ---------- */

body.sidebar-collapsed .layout {
    grid-template-columns: 0 minmax(0, 1fr);
}

body.sidebar-collapsed .sidebar {
    width: 0;
    padding-left: 0;
    padding-right: 0;
    border-right: 0;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
}

.layout,
.sidebar {
    transition:
        grid-template-columns 0.18s ease,
        width 0.18s ease,
        padding 0.18s ease,
        opacity 0.12s ease;
}

/* ---------- Rule tools ---------- */

.rule-entry {
    position: relative;
}

.rule-tools {
    display: flex;
    justify-content: flex-end;
    margin-top: 8px;
    padding-top: 7px;
    border-top: 1px solid rgba(255, 255, 255, 0.045);
    opacity: 0;
    transition: opacity 0.15s ease;
}

.rule-entry:hover .rule-tools,
.rule-entry:focus-within .rule-tools {
    opacity: 1;
}

.rule-tool-button {
    min-height: 28px;
    padding: 4px 8px;
    border: 1px solid transparent;
    border-radius: 5px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 11px;
}

.rule-tool-button:hover {
    border-color: var(--border);
    background: var(--hover);
    color: var(--text);
}

/* ---------- Back to top ---------- */

.back-to-top {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 150;

    display: grid;
    place-items: center;

    width: 42px;
    height: 42px;

    border: 1px solid var(--border);
    border-radius: 8px;

    background: rgba(25, 28, 35, 0.94);
    color: var(--text);

    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);

    cursor: pointer;
    font-size: 20px;

    backdrop-filter: blur(10px);
}

.back-to-top:hover {
    border-color: #4a5160;
    background: var(--hover);
}

/* ---------- Mobile menu ---------- */

@media (max-width: 800px) {
    .header-actions {
        gap: 9px;
    }

    .sidebar-toggle {
        width: 36px;
        height: 36px;
    }

    .sidebar {
        display: none;
    }

    body.sidebar-open .sidebar {
        display: block;
    }

    body.sidebar-collapsed .layout {
        display: block;
    }

    .rule-tools {
        opacity: 1;
    }

    .rule-tool-button {
        min-height: 34px;
        font-size: 12px;
    }

    .back-to-top {
        right: 14px;
        bottom: 14px;
        width: 40px;
        height: 40px;
    }
}

@media (max-width: 480px) {
    .header-status {
        display: none;
    }
}

/* === UX CONTROLS V1 END === */

/* === CONTINUOUS DOCUMENT V3 START === */


/* ==========================================================
   Сплошное отображение подразделов
   ========================================================== */

.inline-subsection {
    margin: 38px 0 8px;
    scroll-margin-top: 86px;
}

.inline-subsection
.inline-subsection {
    margin-top: 32px;
}

.inline-subsection-title {
    display: flex;
    align-items: baseline;
    gap: 8px;

    margin: 0 0 14px;
    padding: 0 0 10px;

    border-bottom:
        1px solid rgba(255,255,255,.10);

    color: #f0f2f6;

    font-size: 19px;
    font-weight: 700;
    line-height: 1.3;
}

.inline-subsection-number {
    flex: 0 0 auto;
    color: #7799d4;
}


/* ==========================================================
   Правила
   ========================================================== */

.rule-entry {
    margin: 8px 0;
    padding: 11px 14px;

    border-left:
        3px solid #526b99;

    border-radius: 4px;

    background:
        rgba(255,255,255,.022);
}

.rule-entry:hover {
    background:
        rgba(255,255,255,.035);
}

.rule-main-text {
    margin: 0 !important;

    color: #d2d6de;

    font-size: 14px;
    line-height: 1.58;
}

.rule-continuation {
    margin-top: 5px;
}

.rule-continuation-text {
    margin-top: 3px !important;

    color: #c4c9d2;

    font-size: 14px;
    line-height: 1.55;
}

.rule-subheading {
    margin:
        8px 0 3px;

    color: #eceef2;

    font-weight: 650;
}

.rule-subitem {
    display: flex;
    align-items: flex-start;

    gap: 7px;

    margin-top: 3px;

    color: #c7ccd5;
}

.rule-subitem-marker {
    flex: 0 0 10px;

    color: #89a4d3;

    text-align: center;
}

.rule-subitem-text {
    min-width: 0;
}


/* Кнопка копирования не должна создавать визуальный шум. */

.rule-tools {
    margin-top: 5px;
    padding-top: 4px;

    border-top: 0;
}


/* ==========================================================
   Маркированный текст памяток
   ========================================================== */

.document-bullet {
    display: flex;
    align-items: flex-start;

    gap: 8px;

    margin: 7px 0;
    padding-left: 3px;

    color: #cbd0d9;

    font-size: 14px;
    line-height: 1.6;
}

.document-bullet-marker {
    flex: 0 0 auto;

    color: #829ed0;
}

.document-bullet-text {
    min-width: 0;
    white-space: pre-wrap;
}

.document-inner-heading {
    margin: 27px 0 10px;

    color: #f0f2f5;

    font-size: 17px;
}


/* ==========================================================
   P4 — профессии
   ========================================================== */

.role-heading {
    margin: 27px 0 8px;
    padding: 9px 12px;

    border-left:
        3px solid #526b99;

    border-radius: 4px;

    background:
        rgba(82,107,153,.10);

    color: #e8ebf1;

    font-size: 15px;
    font-weight: 700;
}


/* ==========================================================
   Амнезиаки — таблица по оригиналу
   ========================================================== */

.amnestic-table-wrapper {
    margin: 24px 0 30px;

    overflow-x: auto;

    border: 0;

    background: #ffffff;
}

.amnestic-table {
    min-width: 720px;

    width: 100%;

    border-collapse: collapse;

    background: #ffffff;

    font-family:
        Arial,
        sans-serif;
}

.amnestic-table td {
    min-width: 110px;

    padding: 10px 9px;

    border:
        1px solid #222222;

    background: #ffffff;
    color: #111111;

    text-align: center;
    vertical-align: top;

    font-size: 14px;
    line-height: 1.3;

    white-space: normal;
}

.amnestic-table
tr:first-child td {
    background: #c7dcef;
    color: #111111;

    font-weight: 700;

    text-align: center;
}

.amnestic-person {
    display: block;

    font-weight: 700;

    line-height: 1.35;
}

.amnestic-scientist {
    color: #34b4e6;
}

.amnestic-lab {
    color: #6aa842;
}

.amnestic-blue {
    color: #1717a9;
}

.amnestic-ovb {
    color: #bb63ba;
}

.amnestic-green {
    color: #356d48;
}


/* ==========================================================
   Иерархия
   ========================================================== */

.hierarchy-rule {
    margin-bottom: 30px;
}

.hierarchy-chart {
    width: min(100%, 900px);

    margin:
        22px auto 5px;

    padding: 18px;

    border:
        1px solid var(--border);

    border-radius: 8px;

    background:
        rgba(0,0,0,.16);
}

.hierarchy-section {
    margin-bottom: 30px;
    padding-bottom: 26px;

    border-bottom:
        1px solid rgba(255,255,255,.10);
}

.hierarchy-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;

    border-bottom: 0;
}

.hierarchy-banner {
    margin-bottom: 6px;
    padding: 7px 10px;

    border:
        2px solid rgba(0,0,0,.75);

    border-radius: 6px;

    color: #080808;

    font-size:
        clamp(17px, 2vw, 25px);

    line-height: 1.1;

    text-align: center;
}

.hierarchy-general-banner {
    background: #9164b7;
}

.hierarchy-object-banner {
    background: #ff174d;
}

.hierarchy-dblock-banner {
    background: #ff8611;
}

.hierarchy-recruit-banner {
    background: #52e7c7;
}

.hierarchy-node {
    display: flex;
    align-items: center;
    justify-content: center;

    min-height: 34px;

    margin: 5px 0;
    padding: 5px 9px;

    border:
        2px solid rgba(0,0,0,.75);

    background: #2828ce;
    color: #ffffff;

    font-size:
        clamp(12px, 1.4vw, 17px);

    line-height: 1.15;

    text-align: center;
}

.hierarchy-ovb {
    background: #b375b5;
    color: #111111;
}

.hierarchy-sector {
    background: #3513dd;
}

.hierarchy-blue {
    background: #2626c9;
}

.hierarchy-purple {
    background: #5310a5;
}

.hierarchy-gbr {
    background: #6360ae;
}

.hierarchy-light {
    background: #78a3ec;
    color: #101010;
}

.hierarchy-mog {
    background: #344483;
}

.hierarchy-main-grid {
    display: grid;

    grid-template-columns:
        1.05fr
        1.05fr
        .8fr;

    gap: 14px;
}

.hierarchy-recruit-grid {
    display: grid;

    grid-template-columns:
        1fr
        1fr;

    gap: 18px;

    width: min(100%, 700px);

    margin-inline: auto;
}

.hierarchy-column {
    min-width: 0;
}

.hierarchy-row {
    display: flex;

    gap: 6px;

    width: min(100%, 650px);

    margin-inline: auto;
}

.hierarchy-row
> .hierarchy-node {
    flex: 1 1 0;

    min-width: 0;
}

.hierarchy-wide {
    width: 100%;
}

.hierarchy-medium {
    width: min(72%, 620px);

    margin-inline: auto;
}

.hierarchy-short {
    width: 36%;

    margin-inline: auto;
}


/* ==========================================================
   Старые карточки подразделов больше не используются
   ========================================================== */

.subsection-card,
.open-subsection {
    display: none !important;
}


/* ==========================================================
   Mobile
   ========================================================== */

@media (max-width: 800px) {

    .inline-subsection {
        margin-top: 30px;
        scroll-margin-top: 72px;
    }

    .inline-subsection-title {
        font-size: 17px;
    }

    .rule-entry {
        padding: 10px 11px;
    }

    .hierarchy-chart {
        padding: 10px;
    }

    .hierarchy-main-grid,
    .hierarchy-recruit-grid {
        grid-template-columns: 1fr;
    }

    .hierarchy-medium,
    .hierarchy-short {
        width: 100%;
    }

    .hierarchy-section {
        margin-bottom: 24px;
        padding-bottom: 20px;
    }
}


@media (max-width: 480px) {

    .hierarchy-row {
        gap: 3px;
    }

    .hierarchy-node {
        min-height: 30px;

        padding: 4px;

        font-size: 11px;
    }

    .hierarchy-banner {
        font-size: 16px;
    }
}


/* === CONTINUOUS DOCUMENT V3 END === */

/* === PROTOCOL HEADING START === */

.protocol-heading {
    margin: 26px 0 16px;
    padding-bottom: 8px;

    border-bottom: 1px solid rgba(255, 255, 255, 0.10);

    color: #f0f2f6;

    font-size: 20px;
    font-weight: 700;
    line-height: 1.3;
}

@media (max-width: 800px) {
    .protocol-heading {
        margin-top: 22px;
        font-size: 18px;
    }
}

/* === PROTOCOL HEADING END === */

/* === SEARCH FOCUS FIX START === */

.search-box {
    transition:
        border-color 0.15s ease,
        box-shadow 0.15s ease,
        background-color 0.15s ease;
}

.search-box:focus-within {
    border-color: var(--accent);
    box-shadow:
        0 0 0 1px rgba(201, 75, 75, 0.18);
}

/* Фокус отображает сам контейнер поиска,
   поэтому отдельная рамка input здесь не нужна. */
.search-box input:focus,
.search-box input:focus-visible {
    outline: none;
    box-shadow: none;
}

/* Кнопка очистки тоже не должна ломать общую рамку. */
.search-box button:focus-visible {
    outline: none;
}

.search-box button:focus-visible::after {
    content: "";
}

/* === SEARCH FOCUS FIX END === */

/* === SEARCH NATIVE CLEAR FIX START === */

/* Убираем встроенный крестик Chromium/Opera/Safari.
   Используем только нашу кнопку очистки. */
.search-box input[type="search"]::-webkit-search-cancel-button,
.search-box input[type="search"]::-webkit-search-decoration {
    -webkit-appearance: none;
    appearance: none;
    display: none;
}

/* === SEARCH NATIVE CLEAR FIX END === */

/* === STAGE2 NAV SEARCH START === */

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

.result-action {
    min-height: 34px;
    padding: 6px 11px;

    border: 1px solid var(--border);
    border-radius: 5px;

    background: transparent;
    color: var(--muted);

    cursor: pointer;
    font-size: 12px;
}

.result-action:hover {
    border-color: #4b5362;
    background: var(--hover);
    color: var(--text);
}

.result-action-primary {
    border-color: #526b99;
    color: #dce5f5;
}

.search-mark {
    padding: 0 0.08em;

    border-radius: 2px;

    background:
        rgba(232, 183, 70, 0.27);

    color: inherit;
}

.navigation-target {
    animation:
        navigation-target-pulse
        2.4s
        ease-out;
}

@keyframes navigation-target-pulse {
    0% {
        box-shadow:
            0 0 0 2px
                rgba(201,75,75,.85),
            0 0 26px
                rgba(201,75,75,.20);
    }

    45% {
        box-shadow:
            0 0 0 1px
                rgba(201,75,75,.45),
            0 0 18px
                rgba(201,75,75,.10);
    }

    100% {
        box-shadow:
            0 0 0 0
                rgba(201,75,75,0);
    }
}

.inline-subsection.navigation-target,
.protocol-heading.navigation-target,
.document-paragraph.navigation-target,
.document-bullet.navigation-target,
.role-heading.navigation-target,
.table-wrapper.navigation-target {
    border-radius: 6px;
}

.rule-tools {
    gap: 5px;
}

.result-context:empty {
    display: none;
}

@media (max-width: 800px) {
    .result-actions {
        gap: 6px;
    }

    .result-action {
        flex: 1 1 auto;
        min-height: 38px;
    }
}

/* === STAGE2 NAV SEARCH END === */

/* === STAGE3 DASHBOARD START === */

.home-dashboard {
    width: 100%;
    max-width: 1080px;
    margin: 0 auto;
    padding-top: clamp(20px, 4vh, 48px);
}

.home-hero {
    margin-bottom: 28px;
}

.home-hero h1 {
    margin:
        14px 0 10px;

    font-size:
        clamp(32px, 5vw, 48px);

    line-height: 1.06;
    letter-spacing: -1.6px;
}

.home-hero > p {
    max-width: 690px;
    margin: 0;

    color: var(--muted);

    font-size: 15px;
    line-height: 1.65;
}


/* ----------------------------------------------------------
   HOME SEARCH
   ---------------------------------------------------------- */

.home-search {
    display: flex;
    width: min(100%, 760px);
    min-height: 58px;

    margin-top: 24px;

    padding: 5px;

    border:
        1px solid var(--border);

    border-radius: 8px;

    background:
        var(--panel);

    transition:
        border-color .15s ease,
        box-shadow .15s ease;
}

.home-search:focus-within {
    border-color: var(--accent);

    box-shadow:
        0 0 0 1px
        rgba(201,75,75,.16);
}

.home-search input {
    flex: 1;
    min-width: 0;

    padding:
        0 15px;

    border: 0;
    outline: 0;

    background: transparent;
    color: var(--text);

    font:
        inherit;

    font-size: 15px;
}

.home-search input:focus,
.home-search input:focus-visible {
    outline: none;
    box-shadow: none;
}

.home-search
input[type="search"]
::-webkit-search-cancel-button,

.home-search
input[type="search"]
::-webkit-search-decoration {
    display: none;

    -webkit-appearance: none;
    appearance: none;
}

.home-search button {
    flex: 0 0 auto;

    min-width: 135px;

    border:
        1px solid
        rgba(201,75,75,.55);

    border-radius: 6px;

    background:
        rgba(201,75,75,.12);

    color: #f0d9d9;

    cursor: pointer;

    font-size: 13px;
    font-weight: 700;

    transition:
        background-color .15s ease,
        border-color .15s ease;
}

.home-search button:hover {
    border-color: var(--accent);

    background:
        rgba(201,75,75,.20);
}


/* ----------------------------------------------------------
   DASHBOARD GRID
   ---------------------------------------------------------- */

.home-grid {
    display: grid;

    grid-template-columns:
        minmax(0, 1.25fr)
        minmax(300px, .75fr);

    gap: 18px;
}

.dashboard-card {
    min-width: 0;

    padding: 22px;

    border:
        1px solid var(--border);

    border-radius: 9px;

    background:
        linear-gradient(
            180deg,
            rgba(255,255,255,.018),
            rgba(255,255,255,.006)
        ),
        var(--panel);

    box-shadow:
        0 12px 34px
        rgba(0,0,0,.10);
}

.dashboard-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;

    gap: 18px;

    margin-bottom: 18px;
}

.dashboard-card-header h2 {
    margin: 4px 0 0;

    font-size: 20px;
    line-height: 1.25;
}

.dashboard-eyebrow {
    color: var(--muted);

    font-size: 9px;
    font-weight: 800;

    letter-spacing: 1.7px;
}


/* ----------------------------------------------------------
   SERVER STATUS
   ---------------------------------------------------------- */

.server-card {
    position: relative;
    overflow: hidden;
}

.server-card::before {
    content: "";

    position: absolute;

    inset:
        0 auto 0 0;

    width: 3px;

    background: #555d6b;
}

.server-card.is-online::before {
    background: var(--green);
}

.server-card.is-offline::before {
    background: var(--accent);
}

.server-state {
    display: inline-flex;
    align-items: center;

    gap: 7px;

    padding:
        6px 9px;

    border:
        1px solid var(--border);

    border-radius: 999px;

    color: var(--muted);

    font-size: 11px;
    font-weight: 700;
}

.server-state-dot {
    width: 7px;
    height: 7px;

    border-radius: 50%;

    background: #727987;
}

.server-state-online {
    border-color:
        rgba(85,199,138,.28);

    color: #77dca5;

    background:
        rgba(85,199,138,.07);
}

.server-state-online
.server-state-dot {
    background: var(--green);

    box-shadow:
        0 0 0 4px
        rgba(85,199,138,.09);
}

.server-state-offline {
    border-color:
        rgba(201,75,75,.30);

    color: #e58d8d;

    background:
        rgba(201,75,75,.07);
}

.server-state-offline
.server-state-dot {
    background: var(--accent);

    box-shadow:
        0 0 0 4px
        rgba(201,75,75,.09);
}

.server-name {
    min-height: 28px;

    margin-bottom: 20px;

    color: #e9ebef;

    font-size: 16px;
    font-weight: 650;

    line-height: 1.45;
}

.server-metrics {
    display: grid;

    grid-template-columns:
        repeat(3, minmax(0, 1fr));

    gap: 9px;
}

.server-metric {
    min-width: 0;

    padding:
        12px 13px;

    border:
        1px solid
        rgba(255,255,255,.055);

    border-radius: 6px;

    background:
        rgba(0,0,0,.12);
}

.server-metric-label {
    display: block;

    margin-bottom: 6px;

    color: var(--muted);

    font-size: 10px;
}

.server-metric-value {
    display: block;

    overflow: hidden;

    color: #e3e6eb;

    font-size: 14px;
    font-weight: 700;

    text-overflow: ellipsis;
    white-space: nowrap;
}

.server-address-row {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 12px;

    margin-top: 12px;

    padding:
        10px 12px;

    border:
        1px solid
        rgba(255,255,255,.045);

    border-radius: 6px;

    color: var(--muted);

    font-size: 11px;
}

.server-address-row code {
    overflow: hidden;

    color: #cbd0d8;

    font-size: 11px;

    text-overflow: ellipsis;
    white-space: nowrap;
}

.server-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 12px;

    margin-top: 15px;

    color: var(--muted);

    font-size: 10px;
}

.server-refresh-button {
    padding:
        6px 9px;

    border:
        1px solid var(--border);

    border-radius: 5px;

    background: transparent;
    color: var(--muted);

    cursor: pointer;

    font-size: 10px;
}

.server-refresh-button:hover {
    background: var(--hover);
    color: var(--text);
}

.server-refresh-button:disabled {
    cursor: default;
    opacity: .55;
}


/* ----------------------------------------------------------
   QUICK LINKS
   ---------------------------------------------------------- */

.quick-links {
    display: grid;

    gap: 8px;
}

.quick-link {
    display: grid;

    grid-template-columns:
        39px minmax(0, 1fr);

    align-items: center;

    gap: 11px;

    width: 100%;

    padding:
        11px 12px;

    border:
        1px solid
        rgba(255,255,255,.055);

    border-radius: 6px;

    background:
        rgba(0,0,0,.10);

    color: var(--text);

    cursor: pointer;

    text-align: left;

    transition:
        border-color .15s ease,
        background-color .15s ease,
        transform .15s ease;
}

.quick-link:hover {
    border-color: #414754;

    background:
        rgba(255,255,255,.035);

    transform:
        translateX(2px);
}

.quick-link-number {
    display: grid;
    place-items: center;

    width: 36px;
    height: 36px;

    border:
        1px solid
        rgba(119,153,212,.25);

    border-radius: 5px;

    color: #8da8d5;

    background:
        rgba(82,107,153,.10);

    font-size: 11px;
    font-weight: 800;
}

.quick-link strong {
    display: block;

    margin-bottom: 3px;

    font-size: 12px;
}

.quick-link small {
    display: block;

    overflow: hidden;

    color: var(--muted);

    font-size: 10px;

    text-overflow: ellipsis;
    white-space: nowrap;
}


/* ----------------------------------------------------------
   HEADER STATUS
   ---------------------------------------------------------- */

.header-status {
    display: inline-flex;
    align-items: center;

    min-width: 0;
}

.status-dot-neutral {
    background: #727987 !important;
}

.status-dot-online {
    background: var(--green) !important;

    box-shadow:
        0 0 0 4px
        rgba(85,199,138,.07);
}

.status-dot-offline {
    background: var(--accent) !important;

    box-shadow:
        0 0 0 4px
        rgba(201,75,75,.07);
}


/* ----------------------------------------------------------
   RESPONSIVE
   ---------------------------------------------------------- */

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

@media (max-width: 800px) {
    .home-dashboard {
        padding-top: 12px;
    }

    .home-hero h1 {
        font-size: 31px;
    }

    .dashboard-card {
        padding: 17px;
    }

    .server-metrics {
        grid-template-columns:
            repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 560px) {
    .home-search {
        min-height: 52px;
    }

    .home-search button {
        min-width: 90px;

        padding:
            0 10px;

        font-size: 11px;
    }

    .server-metrics {
        grid-template-columns: 1fr;
    }

    .server-metric {
        display: flex;
        align-items: center;
        justify-content: space-between;

        gap: 12px;
    }

    .server-metric-label {
        margin: 0;
    }

    .dashboard-card-header {
        gap: 10px;
    }

    .server-footer {
        align-items: flex-start;
        flex-direction: column;
    }

    .server-refresh-button {
        min-height: 34px;
    }
}

/* === STAGE3 DASHBOARD END === */

/* === HOME NAV TAB START === */

.nav-tabs {
    display: grid;
    grid-template-columns:
        repeat(3, minmax(0, 1fr));
}

.nav-tab {
    min-width: 0;
    padding-left: 8px;
    padding-right: 8px;
}

@media (max-width: 800px) {
    .nav-tab {
        font-size: 11px;
    }
}

/* === HOME NAV TAB END === */

/* === MAIN NAV V2 START === */

.nav-tabs {
    display: grid;
    grid-template-columns:
        repeat(2, minmax(0, 1fr));
    gap: 5px;
}

.nav-tab {
    min-width: 0;
}

/* === MAIN NAV V2 END === */

/* === CLICKABLE LOGO START === */

.logo-home-link {
    border-radius: 5px;

    cursor: pointer;

    user-select: none;

    transition:
        opacity .15s ease,
        background-color .15s ease;
}

.logo-home-link:hover {
    opacity: .88;
}

.logo-home-link:focus-visible {
    outline:
        2px solid
        rgba(201,75,75,.75);

    outline-offset: 5px;
}

/* === CLICKABLE LOGO END === */

/* === STAGE4A LAWYER START === */

.nav-tabs {
    grid-template-columns:
        repeat(3, minmax(0, 1fr));
}

.lawyer-panel {
    width: 100%;
    max-width: 980px;
    margin: 0 auto;
    padding-bottom: 40px;
}

.lawyer-heading {
    margin-bottom: 22px;
}

.lawyer-heading h1 {
    margin:
        10px 0 8px;

    font-size:
        clamp(30px, 4vw, 42px);

    line-height: 1.08;
}

.lawyer-heading p {
    max-width: 700px;
    margin: 0;

    color: var(--muted);

    font-size: 14px;
    line-height: 1.65;
}

.lawyer-mode-switch {
    display: inline-grid;

    grid-template-columns:
        repeat(2, minmax(0, 1fr));

    gap: 4px;

    margin-bottom: 12px;

    padding: 4px;

    border:
        1px solid var(--border);

    border-radius: 7px;

    background:
        rgba(0,0,0,.14);
}

.lawyer-mode {
    padding:
        8px 14px;

    border: 0;
    border-radius: 5px;

    background: transparent;
    color: var(--muted);

    cursor: pointer;

    font-size: 12px;
    font-weight: 700;
}

.lawyer-mode:hover {
    color: var(--text);
}

.lawyer-mode.active {
    background:
        rgba(201,75,75,.14);

    color: #efdcdc;

    box-shadow:
        inset 0 0 0 1px
        rgba(201,75,75,.28);
}

.lawyer-form {
    overflow: hidden;

    border:
        1px solid var(--border);

    border-radius: 8px;

    background:
        var(--panel);

    transition:
        border-color .15s ease,
        box-shadow .15s ease;
}

.lawyer-form:focus-within {
    border-color: var(--accent);

    box-shadow:
        0 0 0 1px
        rgba(201,75,75,.14);
}

.lawyer-form textarea {
    display: block;

    width: 100%;
    min-height: 145px;

    padding:
        16px 17px;

    resize: vertical;

    border: 0;
    outline: 0;

    background: transparent;
    color: var(--text);

    font: inherit;
    font-size: 14px;

    line-height: 1.6;
}

.lawyer-form textarea:focus {
    outline: 0;
}

.lawyer-form-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 12px;

    padding:
        9px 10px 9px 15px;

    border-top:
        1px solid
        rgba(255,255,255,.045);
}

.lawyer-counter {
    color: var(--muted);

    font-size: 10px;
}

.lawyer-submit {
    min-height: 37px;

    padding:
        0 15px;

    border:
        1px solid
        rgba(201,75,75,.55);

    border-radius: 5px;

    background:
        rgba(201,75,75,.13);

    color: #f0dada;

    cursor: pointer;

    font-size: 12px;
    font-weight: 700;
}

.lawyer-submit:hover {
    border-color: var(--accent);

    background:
        rgba(201,75,75,.21);
}

.lawyer-submit:disabled {
    cursor: default;
    opacity: .55;
}

.lawyer-examples {
    display: flex;
    flex-wrap: wrap;
    align-items: center;

    gap: 6px;

    margin-top: 10px;

    color: var(--muted);

    font-size: 10px;
}

.lawyer-examples button {
    padding:
        5px 8px;

    border:
        1px solid var(--border);

    border-radius: 999px;

    background: transparent;
    color: var(--muted);

    cursor: pointer;

    font-size: 10px;
}

.lawyer-examples button:hover {
    border-color: #4a505d;
    color: var(--text);
}

.lawyer-results {
    margin-top: 25px;
}

.lawyer-state {
    padding: 22px;

    border:
        1px dashed var(--border);

    border-radius: 7px;

    color: var(--muted);

    text-align: center;

    line-height: 1.6;
}

.lawyer-state strong {
    display: block;
    margin-bottom: 6px;

    color: var(--text);
}

.lawyer-state p {
    margin: 0;
}

.lawyer-state-error {
    border-color:
        rgba(201,75,75,.32);

    color: #d99090;
}

.lawyer-summary {
    margin-bottom: 22px;

    padding:
        17px 18px;

    border:
        1px solid
        rgba(82,107,153,.30);

    border-radius: 7px;

    background:
        rgba(82,107,153,.07);
}

.lawyer-summary-label {
    margin-bottom: 7px;

    color: #8ea9d7;

    font-size: 9px;
    font-weight: 800;

    letter-spacing: 1.4px;
}

.lawyer-summary p {
    margin: 0;

    line-height: 1.65;
}

.lawyer-clarification {
    margin-top: 11px;
    padding-top: 11px;

    border-top:
        1px solid
        rgba(255,255,255,.06);

    color: var(--muted);

    font-size: 12px;
    line-height: 1.55;
}

.lawyer-clarification strong {
    color: #d6d9df;
}

.lawyer-results-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 12px;

    margin-bottom: 10px;
}

.lawyer-results-heading h2 {
    margin: 0;

    font-size: 16px;
}

.lawyer-results-heading > span {
    display: grid;
    place-items: center;

    min-width: 27px;
    height: 27px;

    border:
        1px solid var(--border);

    border-radius: 999px;

    color: var(--muted);

    font-size: 10px;
}

.lawyer-source {
    margin-bottom: 9px;

    padding:
        16px;

    border:
        1px solid var(--border);

    border-radius: 7px;

    background:
        var(--panel);
}

.lawyer-source.is-primary {
    border-color:
        rgba(201,75,75,.35);

    box-shadow:
        inset 3px 0 0
        rgba(201,75,75,.65);
}

.lawyer-source-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;

    gap: 12px;
}

.lawyer-source-titlebox {
    display: flex;
    align-items: center;

    min-width: 0;

    gap: 9px;
}

.lawyer-source-titlebox h3 {
    margin: 0;

    font-size: 14px;
}

.lawyer-source-ref {
    flex: 0 0 auto;

    padding:
        4px 6px;

    border:
        1px solid
        rgba(82,107,153,.30);

    border-radius: 4px;

    color: #96add5;

    background:
        rgba(82,107,153,.08);

    font-size: 10px;
    font-weight: 800;
}

.lawyer-primary-badge {
    flex: 0 0 auto;

    color: #d88a8a;

    font-size: 9px;
    font-weight: 700;
}

.lawyer-source-context {
    margin-top: 8px;

    color: var(--muted);

    font-size: 10px;
}

.lawyer-source-text {
    margin-top: 12px;

    color: #d9dce2;

    font-size: 13px;
    line-height: 1.62;

    white-space: pre-wrap;
}

.lawyer-source-meta {
    display: grid;
    gap: 6px;

    margin-top: 12px;
}

.lawyer-meta-block {
    display: grid;

    grid-template-columns:
        80px minmax(0, 1fr);

    gap: 10px;

    padding:
        8px 10px;

    border-radius: 5px;

    background:
        rgba(0,0,0,.13);

    font-size: 11px;
    line-height: 1.5;
}

.lawyer-meta-block span {
    color: var(--muted);
}

.lawyer-meta-block strong {
    font-weight: 500;
}

.lawyer-source-actions {
    margin-top: 13px;
}

.lawyer-source-open {
    padding:
        6px 10px;

    border:
        1px solid var(--border);

    border-radius: 5px;

    background: transparent;
    color: var(--muted);

    cursor: pointer;

    font-size: 10px;
}

.lawyer-source-open:hover {
    background: var(--hover);
    color: var(--text);
}

.lawyer-disclaimer {
    margin-top: 15px;

    color: var(--muted);

    font-size: 10px;
    line-height: 1.55;
}

@media (max-width: 650px) {
    .lawyer-mode-switch {
        display: grid;
        width: 100%;
    }

    .lawyer-source-header {
        flex-direction: column;
    }

    .lawyer-meta-block {
        grid-template-columns: 1fr;
        gap: 3px;
    }
}

/* === STAGE4A LAWYER END === */

/* STAGE4C3_AI_UI */

.lawyer-ai-loading {
    padding: 22px;
    border: 1px solid var(--border-color, #30343b);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.025);
    opacity: 0.85;
}

.lawyer-ai-card {
    margin-bottom: 18px;
    padding: 20px;
    border: 1px solid var(--border-color, #30343b);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.025);
}

.lawyer-ai-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 14px;
}

.lawyer-ai-card h3,
.lawyer-ai-section h4,
.lawyer-ai-grounded h4,
.lawyer-ai-sources h4 {
    margin-top: 0;
}

.lawyer-ai-eyebrow {
    margin-bottom: 5px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.65;
}

.lawyer-ai-confidence {
    white-space: nowrap;
    font-size: 0.86rem;
    opacity: 0.8;
}

.lawyer-ai-summary {
    margin: 0 0 12px;
    font-weight: 650;
}

.lawyer-ai-explanation {
    line-height: 1.65;
}

.lawyer-ai-used-rules {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
}

.lawyer-ai-rule-chip {
    padding: 4px 9px;
    border: 1px solid currentColor;
    border-radius: 999px;
    font-weight: 700;
    text-decoration: none;
}

.lawyer-ai-section,
.lawyer-ai-grounded {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.lawyer-ai-section ul {
    margin-bottom: 0;
}

.lawyer-ai-grounded-rule {
    margin-top: 10px;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
}

.lawyer-ai-grounded-head,
.lawyer-ai-source-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.lawyer-ai-fact {
    margin-top: 8px;
    line-height: 1.55;
}

.lawyer-ai-meta {
    margin-top: 16px;
    font-size: 0.78rem;
    opacity: 0.55;
}

.lawyer-ai-source-list {
    display: grid;
    gap: 12px;
}

.lawyer-ai-source-card {
    padding: 15px;
    border: 1px solid var(--border-color, #30343b);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.018);
}

.lawyer-ai-ref {
    font-family: monospace;
    font-weight: 700;
    opacity: 0.8;
}

.lawyer-ai-context {
    margin-top: 5px;
    font-size: 0.8rem;
    opacity: 0.6;
}

.lawyer-ai-snippet {
    margin: 10px 0;
    line-height: 1.55;
    white-space: pre-line;
}

.lawyer-ai-rule-link {
    font-weight: 650;
    text-decoration: none;
}

.lawyer-ai-rule-link:hover {
    text-decoration: underline;
}

.lawyer-ai-fallback {
    border-style: dashed;
}

.lawyer-ai-verdict-likely_violation {
    border-left-width: 4px;
}

.lawyer-ai-verdict-possible_violation {
    border-left-width: 3px;
}

.lawyer-ai-verdict-no_violation_seen {
    border-left-width: 3px;
}

.lawyer-ai-verdict-insufficient_information {
    border-left-width: 3px;
}

@media (max-width: 700px) {
    .lawyer-ai-card-head,
    .lawyer-ai-grounded-head,
    .lawyer-ai-source-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .lawyer-ai-confidence {
        white-space: normal;
    }
}

/* === LAWYER AI UX V2 START === */

.lawyer-ai-grounded-heading {
    min-width: 0;
}

.lawyer-ai-grounded-title {
    display: block;
    margin-top: 5px;
    line-height: 1.4;
}

.lawyer-ai-grounded-text {
    margin-top: 12px;
    line-height: 1.62;
    white-space: pre-wrap;
}

.lawyer-ai-grounded-text + .lawyer-ai-fact {
    margin-top: 12px;
}

.lawyer-ai-source-note {
    margin-top: 10px;
    font-size: 0.82rem;
    opacity: 0.65;
}

/*
 * Hybrid V4 retrieval candidates are internal AI evidence.
 * On successful analysis only grounded/applicable rules are shown.
 * Raw retrieval is exposed only as the local fallback.
 */

/* === LAWYER AI UX V2 END === */

/* === LAWYER AI UX V2.1 START === */

.lawyer-ai-grounded-rule {
    padding: 16px 18px;
}

.lawyer-ai-grounded-head {
    align-items: flex-start;
}

.lawyer-ai-grounded-heading {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.lawyer-ai-grounded-text {
    margin-top: 14px;
    padding: 0;
    text-align: left;
    text-indent: 0;
    line-height: 1.6;
}

.lawyer-ai-grounded-text::first-line {
    text-indent: 0;
}

.lawyer-ai-grounded-title:empty {
    display: none;
}

/* === LAWYER AI UX V2.1 END === */

/* === LAWYER AI UX V2.2 START === */

.lawyer-ai-loading {
    display: flex;
    align-items: center;
    gap: 14px;

    min-height: 74px;
    padding: 18px 20px;

    opacity: 1;
}

.lawyer-ai-loading-spinner {
    width: 22px;
    height: 22px;

    flex: 0 0 22px;

    border: 2px solid rgba(255, 255, 255, 0.16);
    border-top-color: currentColor;
    border-radius: 50%;

    animation:
        lawyer-ai-spin
        0.8s
        linear
        infinite;
}

.lawyer-ai-loading-body {
    display: flex;
    flex-direction: column;
    gap: 4px;

    min-width: 0;
}

.lawyer-ai-loading-body strong {
    line-height: 1.3;
}

.lawyer-ai-loading-status {
    font-size: 0.88rem;
    line-height: 1.4;
    opacity: 0.65;
}

.lawyer-form.is-analyzing textarea {
    opacity: 0.82;
}

.lawyer-form.is-analyzing .lawyer-submit {
    cursor: wait;
}

@keyframes lawyer-ai-spin {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 650px) {
    .lawyer-ai-loading {
        align-items: flex-start;
        padding: 16px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .lawyer-ai-loading-spinner {
        animation: none;

        border-top-color:
            rgba(255, 255, 255, 0.16);
    }
}

/* === LAWYER AI UX V2.2 END === */

/* === LAWYER AI UX V2.3 START === */

.lawyer-ai-grounded-text {
    white-space: pre-line;
    text-align: left;
    text-indent: 0;
}

/* === LAWYER AI UX V2.3 END === */
