/* Встроенная пользовательская справка (HelpPanel.js).
   Немодальная панель ПОВЕРХ рабочей области: не четвёртая колонка, чтобы не
   перестраивать дерево/сцену/свойства (PLAN_USER_HELP «Представление»). */

.help-panel {
    --help-bg: #ffffff;
    --help-fg: #1f2933;
    --help-muted: #5f6b7a;
    --help-border: #d5dbe3;
    --help-accent: #1d5fa8;
    --help-accent-bg: #e8f0fa;
    --help-code-bg: #f3f5f8;
    --help-mark: #ffe58a;

    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 100001;               /* выше экрана загрузки модели (99999) */
    width: 460px;
    max-width: 100vw;
    display: flex;
    flex-direction: column;
    background: var(--help-bg);
    color: var(--help-fg);
    border-left: 1px solid var(--help-border);
    box-shadow: -6px 0 24px rgba(20, 30, 45, .18);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}
.help-panel[hidden] { display: none; }
/* Прокручивается только тело статьи; остальные полосы не сжимаются flex-ом. */
.help-panel > :not(.help-body) { flex: 0 0 auto; }

@media (max-width: 700px) {
    .help-panel { width: 100vw; border-left: 0; }
}

.help-head {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 8px 6px 8px;
    border-bottom: 1px solid var(--help-border);
}
.help-title {
    flex: 1 1 auto;
    margin: 0 4px;
    font-size: 16px;
    font-weight: 600;
}
.help-btn {
    width: 32px;
    height: 32px;
    border: 1px solid transparent;
    border-radius: 4px;
    background: transparent;
    color: var(--help-fg);
    font-size: 17px;
    line-height: 1;
    cursor: pointer;
}
.help-btn:hover:not(:disabled) { background: var(--help-accent-bg); }
.help-btn:disabled { opacity: .35; cursor: default; }
.help-panel :focus-visible {
    outline: 2px solid var(--help-accent);
    outline-offset: 1px;
}

.help-search { padding: 8px 12px 4px 12px; }
.help-search-input {
    width: 100%;
    box-sizing: border-box;
    padding: 6px 10px;
    border: 1px solid var(--help-border);
    border-radius: 4px;
    font: inherit;
}

.help-crumbs {
    padding: 2px 14px 6px 14px;
    color: var(--help-muted);
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.help-crumbs a { color: var(--help-accent); text-decoration: none; }
.help-crumbs a:hover { text-decoration: underline; }
.help-crumb-sep { margin: 0 5px; }

.help-context {
    margin: 0 12px 6px 12px;
    padding: 6px 10px;
    border-radius: 4px;
    background: var(--help-accent-bg);
    font-size: 13px;
}
.help-context h3 { margin: 0 0 2px 0; font-size: 12px; font-weight: 600; color: var(--help-muted); }
.help-context ul { margin: 0; padding-left: 18px; }

.help-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 4px 16px 16px 16px;
    overscroll-behavior: contain;
}
.help-body:focus { outline: none; }

.help-foot {
    padding: 5px 14px;
    border-top: 1px solid var(--help-border);
    color: var(--help-muted);
    font-size: 11px;
}

/* ---- содержимое статьи ---- */
.help-panel h1 { font-size: 20px; margin: 10px 0 8px 0; font-weight: 600; }
.help-panel .help-article h2,
.help-panel .help-toc-view h2 { font-size: 16px; margin: 18px 0 6px 0; font-weight: 600; }
.help-panel .help-article h3 { font-size: 14px; margin: 14px 0 4px 0; font-weight: 600; }
.help-panel .help-article h4 { font-size: 14px; margin: 12px 0 4px 0; font-style: italic; }
.help-panel p { margin: 0 0 8px 0; }
.help-panel ul, .help-panel ol { margin: 0 0 8px 0; padding-left: 22px; }
.help-panel li { margin: 2px 0; }
.help-panel a { color: var(--help-accent); }
.help-panel code {
    padding: 0 3px;
    border-radius: 3px;
    background: var(--help-code-bg);
    font-family: Consolas, Menlo, monospace;
    font-size: 12.5px;
}
.help-panel pre {
    padding: 8px 10px;
    border-radius: 4px;
    background: var(--help-code-bg);
    overflow-x: auto;
}
.help-panel pre code { padding: 0; background: none; }
.help-panel kbd {
    display: inline;              /* inline-block рвёт строку у «(» и «)» вокруг клавиши */
    white-space: nowrap;
    padding: 0 5px;
    border: 1px solid var(--help-border);
    border-bottom-width: 2px;
    border-radius: 3px;
    background: #fafbfc;
    color: var(--help-fg);        /* Bootstrap красит kbd белым по тёмному — на страницах base.html клавиши были невидимы */
    box-shadow: none;
    font-family: inherit;
    font-size: 12px;
}
.help-panel blockquote {
    margin: 0 0 8px 0;
    padding: 2px 10px;
    border-left: 3px solid var(--help-border);
    color: var(--help-muted);
}
.help-table-wrap { overflow-x: auto; margin-bottom: 8px; }
.help-panel table { border-collapse: collapse; width: 100%; font-size: 13px; }
.help-panel th, .help-panel td {
    border: 1px solid var(--help-border);
    padding: 4px 6px;
    vertical-align: top;
    text-align: left;
}
.help-panel th { background: var(--help-code-bg); font-weight: 600; }
.help-figure { margin: 8px 0 12px 0; }
.help-figure img { max-width: 100%; height: auto; border: 1px solid var(--help-border); border-radius: 3px; cursor: zoom-in; }
.help-figure figcaption { color: var(--help-muted); font-size: 12px; margin-top: 2px; }

.help-callout {
    margin: 0 0 10px 0;
    padding: 6px 10px;
    border-left: 4px solid var(--help-accent);
    border-radius: 3px;
    background: var(--help-accent-bg);
}
.help-callout > :last-child { margin-bottom: 0; }
.help-callout-title { font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.help-callout-tip { border-color: #2f8f5b; background: #e9f6ee; }
.help-callout-warning { border-color: #c77700; background: #fff4e0; }
.help-callout-important { border-color: #b3261e; background: #fdecea; }

.help-staff {
    margin: 12px 0;
    padding: 4px 10px 6px 10px;
    border: 1px dashed #8a6d3b;
    border-radius: 4px;
    background: #fbf8f1;
}
.help-staff-label { font-size: 11px; font-weight: 600; color: #8a6d3b; text-transform: uppercase; }

.help-onpage {
    margin: 0 0 10px 0;
    padding: 4px 10px;
    border-left: 2px solid var(--help-border);
    font-size: 13px;
}
.help-onpage ul { margin: 0; padding-left: 14px; }

.help-related {
    margin-top: 18px;
    padding-top: 8px;
    border-top: 1px solid var(--help-border);
}
.help-related h3 { font-size: 13px; margin: 0 0 4px 0; color: var(--help-muted); }

.help-summary { color: var(--help-muted); font-size: 12.5px; }
.help-toc-view li { margin-bottom: 5px; }

.help-results { list-style: none; padding-left: 0; }
.help-result { margin: 0 0 12px 0; }
.help-result > a { font-weight: 600; text-decoration: none; }
.help-result > a:hover { text-decoration: underline; }
.help-result-section { color: var(--help-muted); font-size: 11.5px; }
.help-result-snippet { font-size: 13px; }
.help-panel mark { background: var(--help-mark); color: inherit; padding: 0 1px; border-radius: 2px; }
.help-search-count, .help-status { color: var(--help-muted); }

/* ---------------------------------------------------------------------------
   Редактор справки (HelpEditor.js) — только разработчики на dev-стенде.
   Большое окно поверх всего: слева Markdown, справа предпросмотр шириной
   с настоящую панель (как увидит пользователь). */
.help-editor {
    position: fixed;
    inset: 0;
    z-index: 100002;               /* выше панели справки */
    background: rgba(20, 30, 45, .45);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
}
.help-editor[hidden] { display: none; }
.help-editor-box {
    width: 96vw;
    height: 94vh;
    display: flex;
    flex-direction: column;
    background: #fff;
    color: #1f2933;
    border-radius: 6px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, .35);
    overflow: hidden;
}
.help-editor-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid #d5dbe3;
    background: #f7f9fb;
}
.help-editor-title { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.help-editor-path { color: #5f6b7a; font-size: 12px; }
.help-editor-status { font-size: 12.5px; color: #5f6b7a; max-width: 45%; text-align: right; }
.help-editor-status.is-ok { color: #2f8f5b; }
.help-editor-status.is-dirty { color: #c77700; }
.help-editor-status.is-error { color: #b3261e; }
.help-editor-btn {
    border: 1px solid #c5cdd8;
    background: #fff;
    border-radius: 4px;
    padding: 3px 10px;
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
}
.help-editor-btn:hover { background: #e8f0fa; }
.help-editor-save.is-dirty { background: #1d5fa8; border-color: #1d5fa8; color: #fff; }
.help-editor-main { flex: 1 1 auto; display: flex; min-height: 0; }
.help-editor-src { flex: 1 1 auto; min-width: 0; border-right: 1px solid #d5dbe3; }
.help-editor-src .CodeMirror { height: 100%; font-size: 13.5px; line-height: 1.45; }
.help-editor-side { flex: 0 0 480px; overflow: auto; background: #fff; }
/* Предпросмотр переиспользует стили панели, но без её позиционирования. */
.help-panel.help-editor-preview {
    position: static;
    width: auto;
    max-width: none;
    z-index: auto;
    display: block;
    border: 0;
    box-shadow: none;
}
.help-editor-preview .help-body { padding: 4px 16px 16px 16px; overflow: visible; }
.help-editor-msgs { flex: 0 0 auto; max-height: 20vh; overflow: auto; padding: 4px 12px; font-size: 12.5px; border-top: 1px solid #d5dbe3; }
.help-editor-msgs ul { margin: 2px 0 4px 0; padding-left: 20px; }
.help-editor-errors { color: #b3261e; }
.help-editor-warnings { color: #8a6d3b; }
.help-editor-ok { color: #2f8f5b; }
.help-editor-images { flex: 0 0 auto; padding: 4px 12px; border-top: 1px solid #d5dbe3; }
.help-editor-images:empty { display: none; }
.help-editor-images-title { font-size: 12px; color: #5f6b7a; margin-bottom: 4px; }
.help-editor-thumbs { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.help-editor-thumb { margin: 0; flex: 0 0 auto; width: 150px; font-size: 11px; color: #5f6b7a; }
.help-editor-thumb img { width: 150px; height: 84px; object-fit: contain; background: #f3f5f8; border: 1px solid #d5dbe3; cursor: pointer; }
.help-editor-thumb figcaption { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.help-editor-hint { flex: 0 0 auto; padding: 4px 12px 6px 12px; font-size: 12px; color: #5f6b7a; border-top: 1px solid #eef1f5; }
.help-editor-hint kbd { font-size: 11px; padding: 0 4px; border: 1px solid #c5cdd8; border-radius: 3px; background: #f3f5f8; color: #1f2933; box-shadow: none; }
