body { background: #f5f7fb; }
.card { border-radius: 1rem; }
.catalog-explorer { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 1.25rem; min-height: calc(100vh - 11rem); }
.catalog-sidebar {
  background: linear-gradient(180deg, #fcfcfd 0%, #f4f5f8 100%);
  overflow: hidden;
  position: sticky;
  top: 5rem;
  max-height: calc(100vh - 6rem);
  align-self: start;
  display: flex;
  flex-direction: column;
}
.catalog-sidebar-header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1rem 1rem .75rem; border-bottom: 1px solid #e7e9ef; }
.catalog-sidebar-title { font-size: 1rem; font-weight: 700; margin: 0; color: #3a4052; }
.catalog-search { position: relative; padding: .75rem .85rem .35rem; border-bottom: 1px solid #edf0f4; }
.catalog-search-input { border-radius: .8rem; border-color: #d9deea; background: rgba(255,255,255,.85); }
.catalog-search-input:focus { border-color: #89a3df; box-shadow: 0 0 0 .2rem rgba(90, 120, 200, .15); }
.catalog-search-results { position: absolute; left: .85rem; right: .85rem; top: calc(100% - .1rem); z-index: 5; background: #fff; border: 1px solid #dfe4ee; border-radius: .9rem; box-shadow: 0 18px 45px rgba(32, 49, 82, .12); max-height: 320px; overflow: auto; padding: .35rem; }
.catalog-search-result { display: block; width: 100%; text-align: left; border: 0; background: transparent; border-radius: .7rem; padding: .55rem .6rem; }
.catalog-search-result:hover { background: #eef3ff; }
.catalog-search-meta { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: #7a8599; margin-bottom: .15rem; }
.catalog-search-title { font-size: .92rem; font-weight: 600; color: #26344f; }
.catalog-search-snippet { margin-top: .2rem; font-size: .83rem; color: #687286; }
.catalog-search-empty { padding: .75rem; color: #6b7280; font-size: .9rem; }
.catalog-tree { padding: .65rem .55rem 1rem; max-height: none; overflow: auto; flex: 1 1 auto; min-height: 0; }
.catalog-empty { padding: 1rem; color: #6b7280; font-size: .95rem; }
.tree-node { margin-bottom: .1rem; }
.tree-node > summary { list-style: none; }
.tree-node > summary::-webkit-details-marker { display: none; }
.tree-summary { position: relative; display: flex; align-items: center; min-height: 2rem; border-radius: .7rem; padding: .25rem .5rem .25rem 1.35rem; cursor: pointer; color: #4b5563; }
.tree-summary::before { content: ''; position: absolute; left: .5rem; top: .77rem; width: .42rem; height: .42rem; border-right: 1.5px solid #9aa3b2; border-bottom: 1.5px solid #9aa3b2; transform: rotate(-45deg); transition: transform .16s ease; }
.tree-node[open] > .tree-summary::before { transform: rotate(45deg); top: .62rem; }
.tree-summary:hover { background: rgba(122, 138, 166, .08); }
.tree-summary.is-active { background: rgba(73, 99, 163, .1); color: #22304d; }
.tree-directory-link { color: inherit; text-decoration: none; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tree-branch { margin-left: .75rem; padding-left: .45rem; border-left: 1px solid #e5e7eb; }
.tree-file-link { display: flex; align-items: center; min-height: 1.9rem; margin: .05rem 0; border-radius: .65rem; padding: .2rem .5rem .2rem 1.15rem; color: #5b6272; text-decoration: none; font-size: .93rem; }
.tree-file-link::before { content: ''; width: .36rem; height: .36rem; margin-right: .55rem; border-radius: 999px; background: #c5cad4; flex: 0 0 auto; }
.tree-file-link:hover { background: rgba(122, 138, 166, .08); color: #2f3645; }
.tree-file-link.is-active { background: #e8edf8; color: #203152; }
.tree-file-link.is-active::before { background: #5a78c8; }
.tree-link-flash { animation: treeLinkFlash 1.2s ease-out 1; }
@keyframes treeLinkFlash {
  0% { box-shadow: 0 0 0 0 rgba(90, 120, 200, .45); background-color: rgba(90, 120, 200, .22); }
  100% { box-shadow: 0 0 0 10px rgba(90, 120, 200, 0); background-color: transparent; }
}
.tree-file-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.catalog-detail { background: linear-gradient(180deg, #ffffff 0%, #fbfbfd 100%); min-width: 0; }
.catalog-detail-body { padding: 1.25rem 1.4rem; }
.catalog-detail-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.25rem; }
.catalog-detail-kicker { text-transform: uppercase; letter-spacing: .08em; font-size: .73rem; color: #8b93a5; margin-bottom: .35rem; }
.catalog-detail-title { margin: 0; font-size: 1.65rem; color: #1f2937; }
.catalog-detail-path { margin-top: .35rem; color: #6b7280; font-size: .92rem; word-break: break-word; }
.catalog-placeholder { border: 1px dashed #d7dbe5; border-radius: 1rem; background: #f8f9fc; padding: 1.2rem 1.1rem; color: #586174; }
.catalog-placeholder-title { margin: 0 0 .45rem; font-weight: 600; color: #2f3b52; }
.catalog-placeholder-text { margin: 0; }
.catalog-markdown { min-width: 0; }
.topic-content { font-size: 1rem; line-height: 1.7; }
.topic-content img { max-width: 100%; height: auto; border-radius: .75rem; margin: 1rem 0; display: block; }
.topic-content a { word-break: break-word; }
.topic-content p:last-child { margin-bottom: 0; }
.preformatted-block { white-space: pre-wrap; word-break: break-word; background: #f8f9fa; padding: 1rem; border-radius: .75rem; max-height: 400px; overflow: auto; }
.diff-table-wrapper { overflow-x: auto; }
.diff-table-wrapper table.diff { width: 100%; font-size: .875rem; }
.diff_add { background: #e9fbe9; }
.diff_sub { background: #ffe6e6; }
.diff_chg { background: #fff5d6; }
.markdown-editor { border: 1px solid #dee2e6; border-radius: 1rem; background: #fff; padding: .75rem; }
.editor-toolbar { display: flex; flex-wrap: wrap; gap: .5rem; }
.editor-surface { min-height: 360px; border: 1px solid #e2e6ef; border-radius: .9rem; padding: 1rem; background: #fff; outline: none; }
.editor-surface:focus { border-color: #89a3df; box-shadow: 0 0 0 .2rem rgba(90, 120, 200, .12); }
.editor-surface:empty::before { content: 'Начните вводить текст...'; color: #9aa3b2; }
.editor-image-library { margin-top: .9rem; border: 1px solid #dfe4ee; border-radius: .95rem; background: linear-gradient(180deg, #fcfcfd 0%, #f5f7fb 100%); padding: .9rem; }
.editor-image-library-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: .75rem; }
.editor-image-library-title { font-weight: 700; color: #26344f; }
.editor-image-library-subtitle { font-size: .88rem; color: #687286; margin-top: .15rem; }
.editor-image-library-actions { display: flex; gap: .75rem; margin-bottom: .75rem; }
.editor-image-library-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .75rem; max-height: 320px; overflow: auto; }
.editor-image-card { display: flex; flex-direction: column; gap: .45rem; border: 1px solid #d8dfec; border-radius: .85rem; background: #fff; padding: .45rem; text-align: left; color: #25324d; transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease; }
.editor-image-card:hover { transform: translateY(-1px); border-color: #9cb3e8; box-shadow: 0 10px 24px rgba(59, 85, 139, .12); }
.editor-image-thumb-wrap { display: block; aspect-ratio: 1 / 1; border-radius: .65rem; overflow: hidden; background: #eef2f8; }
.editor-image-thumb { width: 100%; height: 100%; object-fit: cover; display: block; }
.editor-image-name { font-size: .82rem; line-height: 1.35; word-break: break-word; }
.editor-image-empty { padding: 1rem; border: 1px dashed #cfd7e6; border-radius: .75rem; background: #fff; color: #6a7488; }
.editor-textarea { border: 0; box-shadow: none !important; min-height: 360px; resize: vertical; }
.editor-textarea:focus { border: 0; box-shadow: none !important; }
.markdown-body h1, .markdown-body h2, .markdown-body h3 { margin-top: 1.4rem; margin-bottom: .8rem; }
.markdown-body ul, .markdown-body ol { padding-left: 1.3rem; }
.markdown-body blockquote { border-left: 4px solid #ced4da; padding-left: 1rem; color: #495057; }
.markdown-body code { background: #f1f3f5; padding: .1rem .35rem; border-radius: .35rem; }
@media (max-width: 576px) {
  .container { padding-left: 1rem; padding-right: 1rem; }
  h1, .h1, .h2, .h3 { line-height: 1.25; }
  .editor-toolbar .btn { flex: 1 1 calc(50% - .5rem); }
  .editor-image-library-header, .editor-image-library-actions { flex-direction: column; }
  .editor-surface { min-height: 280px; }
  .editor-textarea { min-height: 280px; }
}
@media (max-width: 991px) {
  .catalog-explorer { grid-template-columns: 1fr; min-height: auto; }
  .catalog-sidebar { position: static; top: auto; max-height: none; }
  .catalog-tree { max-height: 38vh; }
  .catalog-detail-header { flex-direction: column; }
}
