html, body {
    height: 100%;
}

:root {
    --page-white: #ffffff;
    --page: #F5EFE1;
    --page-line: #E4D9C4;
    --text-main: #2C2416;
    --text-soft: #6B5940;
    --text-muted-warm: #8A7859;
    --ink: #2C2416;
    --danger: #993C1D;
    --gold: #D4AF37;
    --blue-connector: #4B8BE6;
}

.editor-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
    background: var(--page-white);
    border-bottom: 1px solid var(--page-line);
}

.editor-topbar a {
    color: var(--text-soft);
    font-size: 18px;
}

.editor-body {
    display: flex;
    height: calc(100vh - 71px);
}

.editor-canvas-wrap {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: var(--page-white);
    background-image: radial-gradient(circle, var(--page-line) 1px, transparent 1px);
    background-size: 24px 24px;
    cursor: grab;
}

.editor-canvas-wrap.panning {
    cursor: grabbing;
}

#connectionsLayer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#nodesLayer {
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: 0 0;
}

.step-node {
    position: absolute;
    min-width: 100px;
    min-height: 60px;
    background: var(--page-white);
    border: 1.5px solid var(--page-line);
    border-radius: 10px;
    padding: 10px 12px;
    cursor: grab;
    user-select: none;
    box-shadow: 0 2px 6px rgba(44, 36, 22, 0.06);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.step-node .title {
    font-size: 13px;
    font-weight: 500;
    line-height: 18px;
    margin: 0;
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    white-space: normal;
    text-align: center;
}

.step-node .resize-handle {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 14px;
    height: 14px;
    cursor: nwse-resize;
    background:
        linear-gradient(135deg, transparent 50%, var(--page-line) 50%, var(--page-line) 60%, transparent 60%),
        linear-gradient(135deg, transparent 65%, var(--page-line) 65%, var(--page-line) 75%, transparent 75%);
}

.step-node:active {
    cursor: grabbing;
}

.step-node.selected {
    border-color: var(--danger);
    outline: 2px solid var(--danger);
    outline-offset: 2px;
    box-shadow: 0 6px 18px rgba(153, 60, 29, 0.25);
    z-index: 5;
}

.step-node.is-start {
    border-color: var(--gold);
}

.step-node.is-ending {
    background: #F3DCD2;
    border-color: var(--danger);
}

.step-node.is-predecessor {
    border-color: #6FAE7C;
    box-shadow: 0 0 0 2px rgba(111, 174, 124, 0.18);
}

.step-node.is-predecessor::after {
    content: "\2192";
    position: absolute;
    top: 4px;
    right: 6px;
    font-size: 12px;
    font-weight: 700;
    color: #6FAE7C;
    pointer-events: none;
}

.step-node.is-child {
    border-color: #E3A97A;
    box-shadow: 0 0 0 2px rgba(227, 169, 122, 0.18);
}

.step-node.is-child::after {
    content: "\2192";
    position: absolute;
    bottom: 4px;
    right: 6px;
    font-size: 12px;
    font-weight: 700;
    color: #E3A97A;
    pointer-events: none;
}

.step-node .key {
    font-size: 14px;
    color: var(--text-muted-warm);
    margin: 0 0 2px;
    flex-shrink: 0;
    text-align: center;
}

.step-node .title-wrap {
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

.step-node .handle {
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--danger, #993C1D);
    border: 2px solid var(--page-white, #FFFDF8);
    z-index: 10;
    cursor: crosshair;
}

.step-node .handle-top {
    top: -7px;
    left: 50%;
    transform: translateX(-50%);
}

.step-node .handle-bottom {
    bottom: -7px;
    left: 50%;
    transform: translateX(-50%);
}

.step-node .handle-left {
    left: -7px;
    top: 50%;
    transform: translateY(-50%);
}

.step-node .handle-right {
    right: -7px;
    top: 50%;
    transform: translateY(-50%);
}

.step-node .handle::before {
    content: "";
    position: absolute;
    inset: -8px;
}

.editor-add-btn {
    position: absolute;
    right: 20px;
    bottom: 20px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--ink);
    color: var(--page);
    border: none;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(44, 36, 22, 0.2);
    z-index: 100;
}

.editor-panel {
    width: 320px;
    background: var(--page-white);
    border-left: 1px solid var(--page-line);
    padding: 20px;
    overflow-y: auto;
    position: relative;
    scrollbar-width: thin;
    scrollbar-color: rgba(100, 100, 100, 0.3) transparent;
}

.editor-panel::-webkit-scrollbar {
    width: 4px;
}

.editor-panel::-webkit-scrollbar-track {
    background: transparent;
}

.editor-panel::-webkit-scrollbar-thumb {
    background: rgba(100, 100, 100, 0.3);
    border-radius: 4px;
}

.editor-panel::-webkit-scrollbar-thumb:hover {
    background: rgba(100, 100, 100, 0.45);
}

.editor-panel textarea {
    width: 100%;
    font-size: 13px;
    padding: 8px 10px;
    border: 1px solid var(--page-line);
    border-radius: 8px;
    resize: vertical;
}

.editor-panel input[type="text"],
.editor-panel input[type="number"] {
    width: 100%;
    font-size: 13px;
    padding: 8px 10px;
    border: 1px solid var(--page-line);
    border-radius: 8px;
}

.editor-choice-row {
    border: 1px solid var(--page-line);
    border-radius: 8px;
    padding: 8px 10px;
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    transition: background .15s ease, border-color .15s ease;
}

.editor-choice-row .del {
    color: var(--text-muted-warm);
    cursor: pointer;
}

.editor-choice-row .del:hover {
    color: var(--danger);
}

.editor-choice-row.active {
    border-color: var(--gold);
    background: #FBF1DA;
}

.node-thumb {
    width: 100%;
    height: 50%;
    object-fit: cover;
    border-radius: 6px;
    margin-bottom: 6px;
    display: block;
    flex-shrink: 0;
}

.editor-panel button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.editor-panel .input-group {
    display: flex;
    align-items: stretch;
}

.editor-panel .input-group .form-control {
    flex: 1;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.editor-panel .input-group .btn {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    flex-shrink: 0;
}

.history-tooltip {
    position: fixed;
    z-index: 1000;
    background: var(--ink, #2C2416);
    color: var(--page, #FFFDF8);
    font-size: 12px;
    line-height: 1.5;
    padding: 8px 12px;
    border-radius: 8px;
    box-shadow: 0 4px 14px rgba(44, 36, 22, 0.25);
    pointer-events: none;
    max-width: 240px;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.12s ease, transform 0.12s ease;
}

.history-tooltip.visible {
    opacity: 1;
    transform: translateY(0);
}

.history-tooltip b {
    font-weight: 600;
}

.history-tooltip .history-tooltip-line + .history-tooltip-line {
    margin-top: 3px;
}

.step-context-menu {
    position: fixed;
    z-index: 1001;
    background: var(--page-white, #FFFDF8);
    border: 1px solid var(--page-line, #E4D9C4);
    border-radius: 8px;
    box-shadow: 0 4px 14px rgba(44, 36, 22, 0.18);
    min-width: 140px;
    overflow: hidden;
    font-size: 13px;
}

.step-context-item {
    padding: 8px 14px;
    cursor: pointer;
}

.step-context-item:hover {
    background: var(--page, #F5EFE1);
}

.step-context-item.danger {
    color: var(--danger, #993C1D);
}

.media-library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, 110px);
    gap: 10px;
}

.media-library-item {
    position: relative;
    cursor: pointer;
    border-radius: 8px;
    overflow: hidden;
    width: 110px;
    height: 110px;
    border: 2px solid transparent;
    background: #2C2416;
}

.media-library-item:not(.selected):hover {
    border-color: var(--page-line, #C9BC9E);
}

.media-library-item.selected {
    border-color: var(--danger, #993C1D);
    box-shadow: 0 0 0 2px rgba(153, 60, 29, 0.2);
}

.media-library-item img,
.media-library-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
}

.media-library-item.selected::after {
    content: "\2713";
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--danger, #993C1D);
    color: #fff;
    font-size: 12px;
    line-height: 20px;
    text-align: center;
}

.media-library-delete {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(20, 16, 10, 0.7);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
}

.step-color-swatch {
    width: 22px;
    height: 22px;
    padding: 0;
    border: 1px solid var(--page-line);
    border-radius: 50%;
    position: relative;
    cursor: pointer;
    transition: transform .12s ease, box-shadow .12s ease;
}

.step-color-swatch:hover {
    transform: scale(1.12);
}

.step-color-swatch.active {
    border: 2px solid var(--ink);
    box-shadow: 0 0 0 2px var(--page-white), 0 0 0 3px var(--ink);
}

.step-color-swatch.active::after {
    content: "\2713";
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: var(--ink);
    text-shadow: 0 0 2px rgba(255,255,255,.9), 0 0 2px rgba(255,255,255,.9);
}

.step-color-swatch-empty {
    background: repeating-conic-gradient(#fff 0% 25%, #E4D9C4 0% 50%) 50% / 8px 8px;
}

.custom-color-swatch-wrap {
    position: relative;
    width: 22px;
    height: 22px;
    display: inline-block;
    flex-shrink: 0;
}

.custom-color-swatch-wrap input[type="color"] {
    width: 22px;
    height: 22px;
    padding: 0;
    border: 1px solid var(--page-line);
    border-radius: 50%;
    overflow: hidden;
    cursor: pointer;
    display: block;
}

.custom-color-swatch-wrap i {
    position: absolute;
    bottom: -3px;
    right: -3px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--page-white);
    border: 1px solid var(--page-line);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 7px;
    font-weight: 700;
    color: var(--text-muted-warm);
    pointer-events: none;
}

.choice-row-with-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.choice-toggle {
    color: var(--text-muted-warm);
    padding: 4px;
    margin: -4px;
    border-radius: 4px;
    display: inline-flex;
}

.choice-toggle:hover {
    background: var(--page);
    color: var(--text-muted-warm);
}

.choice-toggle i {
    transition: transform 0.2s ease;
}

.choice-toggle[aria-expanded="true"] i {
    transform: rotate(180deg);
}

.step-attachments-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.step-attachment-tile {
    position: relative;
    width: 72px;
    height: 72px;
    border-radius: 8px;
    overflow: hidden;
    cursor: grab;
    border: 2px solid transparent;
    background: #000;
}

.step-attachment-tile:active {
    cursor: grabbing;
}

.step-attachment-tile.dragging {
    opacity: 0.35;
}

.step-attachment-tile.drag-over {
    border-color: var(--danger, #993C1D);
}

.step-attachment-tile img,
.step-attachment-tile video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
}

.step-attachment-cover-badge {
    position: absolute;
    bottom: 2px;
    left: 2px;
    font-size: 9px;
    background: rgba(20, 16, 10, 0.7);
    color: #fff;
    padding: 1px 5px;
    border-radius: 6px;
    pointer-events: none;
}

.step-attachment-delete {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(20, 16, 10, 0.7);
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    padding: 0;
}

.step-attachment-crop {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(20, 16, 10, 0.7);
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    padding: 0;
    z-index: 10;
}

.step-attachment-crop:hover {
    background: var(--danger, #993C1D);
}

.step-attachment-add-tile {
    width: 72px;
    height: 72px;
    border-radius: 8px;
    border: 2px dashed var(--page-line);
    background: transparent;
    color: var(--text-muted-warm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.step-attachment-add-tile:hover {
    border-color: var(--danger, #993C1D);
    color: var(--danger, #993C1D);
}

.media-library-play-hint {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 26px;
    background: rgba(0, 0, 0, .25);
    pointer-events: none;
    transition: opacity .15s ease;
}

.media-library-item.playing .media-library-play-hint {
    opacity: 0;
}

.media-library-kind-badge {
    position: absolute;
    bottom: 4px;
    left: 4px;
    font-size: 10px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    padding: 2px 6px;
    border-radius: 8px;
    pointer-events: none;
}

.choice-panel-effects {
    padding: 2px 10px 6px;
    font-size: 12px;
}

.choice-panel-effect {
    padding: 2px 0;
    font-weight: 600;
}

.topbar-action-btn {
    background: none;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--text-muted-warm);
    cursor: pointer;
    transition: color 0.2s ease, transform 0.1s ease;
    padding: 0;
}

.topbar-action-btn:hover {
    color: var(--text-main);
}

.topbar-action-btn:active {
    transform: scale(0.95);
}

.topbar-action-btn i {
    font-size: 22px;
}

.topbar-action-btn span {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.topbar-action-btn.publish-btn {
    color: var(--danger);
}

.topbar-action-btn.publish-btn:hover {
    color: #7a2f16;
}

.custom-scrollbar {
    scrollbar-width: thin;
    scrollbar-color: rgba(100, 100, 100, 0.3) transparent;
}

.custom-scrollbar::-webkit-scrollbar {
    width: 4px;
}

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

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: rgba(100, 100, 100, 0.3);
    border-radius: 4px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: rgba(100, 100, 100, 0.45);
}

.chat-icon-badge {
    position: absolute;
    top: -6px;
    right: -10px;
    min-width: 15px;
    height: 15px;
    padding: 0 3px;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    line-height: 15px;
    text-align: center;
    animation: chat-badge-pulse 1.5s ease-in-out infinite;
}

.chat-icon-total-badge {
    position: absolute;
    bottom: -4px;
    right: -8px;
    min-width: 14px;
    height: 14px;
    padding: 0 3px;
    border-radius: 999px;
    background: var(--text-muted-warm);
    color: #fff;
    font-size: 8px;
    font-weight: 700;
    line-height: 14px;
    text-align: center;
}

@keyframes chat-badge-pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(153, 60, 29, .5);
    }
    50% {
        transform: scale(1.18);
        box-shadow: 0 0 0 4px rgba(153, 60, 29, 0);
    }
}

.notif-badge {
    position: absolute;
    top: -4px;
    right: -8px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    align-items: center;
    justify-content: center;
    animation: chat-badge-pulse 1.5s ease-in-out infinite;
}

.notifications-dropdown {
    position: absolute;
    top: calc(100% + 14px);
    right: -8px;
    width: 320px;
    max-height: 420px;
    background: var(--page-white);
    border: 1px solid var(--page-line);
    border-radius: 10px;
    box-shadow: 0 8px 28px rgba(44, 36, 22, 0.18);
    z-index: 950;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.notifications-dropdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--page-line);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
}

.notifications-mark-all {
    background: none;
    border: none;
    padding: 0;
    font-size: 11px;
    font-weight: 600;
    color: var(--danger);
    cursor: pointer;
}

.notifications-mark-all:hover {
    text-decoration: underline;
}

.notifications-list {
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(100, 100, 100, 0.3) transparent;
}

.notifications-list::-webkit-scrollbar {
    width: 4px;
}

.notifications-list::-webkit-scrollbar-thumb {
    background: rgba(100, 100, 100, 0.3);
    border-radius: 4px;
}

.notification-row {
    padding: 10px 14px;
    border-bottom: 1px solid var(--page-line);
    cursor: pointer;
    transition: background 0.15s ease, opacity 0.25s ease;
}

.notification-row.is-read {
    opacity: 0.5;
}

.notification-row.is-read .notification-row-step {
    color: var(--text-muted-warm);
}

.notification-row:last-child {
    border-bottom: none;
}

.notification-row:hover {
    background: var(--page);
}

.notification-row-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 3px;
}

.notification-row-step {
    font-size: 12px;
    font-weight: 700;
    color: var(--danger);
}

.notification-row-time {
    font-size: 10px;
    color: var(--text-muted-warm);
    white-space: nowrap;
}

.notification-row-author {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 2px;
}

.notification-row-text {
    font-size: 12px;
    color: var(--text-soft);
    line-height: 1.4;
}

.favorite-row-remove {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--text-muted-warm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
    padding: 0;
    transition: background .15s ease, color .15s ease;
}

.favorite-row-remove:hover {
    background: var(--danger);
    color: #fff;
}

.favorite-row .notification-row-top {
    align-items: center;
}

/* ------------------------------------------------------------------ */
/* Левая панель глав — группировка шагов, скрытие/показ по главам      */
/* ------------------------------------------------------------------ */
#chaptersPanel {
    position: relative;
}

#chaptersTreeSvg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 15;
    overflow: visible;
}

.chapter-row-wrap {
    margin-bottom: 6px;
    position: relative;
}

.chapter-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--page-line);
    border-radius: 8px;
    transition: opacity .15s ease;
}

.chapter-row.is-hidden {
    opacity: 1;
    border-color: rgba(228, 217, 196, 0.45);
}

.chapter-row.is-hidden > *:not(.dropdown) {
    opacity: 0.45;
}

.chapter-row.is-hidden .dropdown > button:hover,
.chapter-row.is-hidden .dropdown > button[aria-expanded="true"] {
    opacity: 1;
}

.chapter-row.is-hidden .dropdown > button {
    opacity: 0.45;
    transition: opacity 0.15s ease;
}

.chapter-color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.chapter-row-title {
    flex: 1;
    font-size: 13px;
    color: var(--text-main);
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chapter-row-title:hover {
    text-decoration: underline;
}

.chapter-row-count {
    font-size: 11px;
    color: var(--text-muted-warm);
    background: var(--page);
    border-radius: 999px;
    padding: 1px 7px;
    flex-shrink: 0;
}

.chapter-row-icon-btn {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--text-muted-warm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
    padding: 0;
    transition: background .15s ease, color .15s ease;
}

.chapter-row-goto-first {
    font-size: 11px;
}

.chapter-row-goto-first:hover {
    background: var(--page);
    color: var(--danger);
}

.chapter-row-eye:hover {
    background: var(--page);
    color: var(--text-main);
}

.chapter-row-paid.active {
    color: var(--gold);
}

.chapter-row-paid:hover {
    background: var(--page);
}

.chapter-row-delete:hover {
    background: var(--danger);
    color: #fff;
}

.chapter-row-title-input {
    flex: 1;
    font-size: 13px;
    padding: 2px 6px;
    border: 1px solid var(--danger);
    border-radius: 6px;
    min-width: 0;
}

.chapter-row-chevron i {
    transition: transform .15s ease;
}

.chapter-steps-list {
    margin: 2px 0 0 14px;
    padding-left: 12px;
    border-left: 2px solid var(--page-line);
}

.chapter-description-wrap {
    margin-bottom: 10px;
}

.chapter-step-row-wrap {
    margin-bottom: 2px;
    position: relative;
}

.chapter-step-row {
    display: flex;
    align-items: baseline;
    gap: 6px;
    padding: 5px 8px;
    border-radius: 6px;
    cursor: pointer;
    overflow: hidden;
    transition: opacity .15s ease, background .15s ease, border-color .15s ease;
    border: 1px solid transparent;
}

.chapter-step-row.dragging {
    opacity: .35;
}

.chapter-step-row.drag-over {
    background: var(--page);
    box-shadow: inset 0 2px 0 var(--danger);
}

.chapter-step-row.active {
    background: #FBF1DA;
    border-color: var(--gold);
}

.chapter-step-row-handle {
    align-self: center;
    font-size: 12px;
    color: var(--text-muted-warm);
    cursor: grab;
    flex-shrink: 0;
}

.chapter-step-row:active .chapter-step-row-handle {
    cursor: grabbing;
}

.chapter-step-row:hover {
    background: var(--page);
}

.chapter-step-row-key {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    flex-shrink: 0;
}

.chapter-step-row-preview {
    font-size: 11px;
    color: var(--text-muted-warm);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.chapter-step-row-goto {
    background: none;
    border: none;
    padding: 2px;
    color: var(--text-muted-warm);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
}

.chapter-step-row-goto:hover {
    color: var(--danger);
}

.chapter-step-row-expand {
    font-size: 11px;
    color: var(--text-muted-warm);
    flex-shrink: 0;
    cursor: pointer;
    transition: transform .15s ease;
}

.chapter-choice-row {
    padding: 5px 8px 5px 26px;
    font-size: 11px;
    color: var(--text-soft);
    cursor: pointer;
    border-radius: 6px;
    border: 1px solid transparent;
    transition: background .15s ease, border-color .15s ease;
}

.chapter-choice-row:hover {
    background: var(--page);
}

.chapter-choice-row.active {
    background: #FBF1DA;
    border-color: var(--gold);
    color: var(--text-main);
    font-weight: 600;
}

.scenario-title-input {
    font-size: 14px;
    font-weight: 500;
    padding: 2px 6px;
    border: 1px solid var(--danger);
    border-radius: 6px;
    min-width: 180px;
}

@keyframes choiceTrailPulse {
    0% {
        r: 10;
        opacity: 1;
    }
    100% {
        r: 26;
        opacity: 0;
    }
}

.choice-target-card {
    background: var(--page);
    border: 1px solid var(--page-line);
    border-radius: 10px;
    padding: 12px;
}

.choice-target-info {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 8px;
}

.choice-target-key {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-main);
}

.choice-target-chapter {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-soft);
    background: var(--page-white);
    border: 1px solid var(--page-line);
    border-radius: 999px;
    padding: 2px 9px;
}

.choice-target-chapter-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.choice-target-chapter-none {
    color: var(--text-muted-warm);
    font-style: italic;
    background: transparent;
    border-style: dashed;
}

.choice-target-preview {
    width: 100%;
    margin-top: 2px;
    font-size: 12px;
    color: var(--text-muted-warm);
    line-height: 1.4;
}

@keyframes navFlashPulse {
    0% { background: #FBF1DA; }
    70% { background: #FBF1DA; }
    100% { background: transparent; }
}

.nav-flash {
    animation: navFlashPulse 1.6s ease-out;
}

#minimapWrap {
    z-index: 90;
}

#minimapSvg rect[data-step-id] {
    transition: opacity .1s ease;
}

#minimapSvg rect[data-step-id]:hover {
    opacity: 0.75;
}

.book-settings-cover-dropzone {
    position: relative;
    width: 100%;
    height: 160px;
    border: 1.5px dashed var(--page-line);
    border-radius: 10px;
    background: var(--page);
    cursor: pointer;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color .15s ease, background .15s ease;
}

.book-settings-cover-dropzone:hover,
.book-settings-cover-dropzone:focus-visible {
    border-color: var(--danger);
    background: #FBF3EC;
    outline: none;
}

.book-settings-cover-dropzone img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.book-settings-cover-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: var(--text-muted-warm);
    font-size: 13px;
    text-align: center;
    padding: 0 16px;
    pointer-events: none;
}

.book-settings-cover-placeholder i {
    font-size: 26px;
}

.book-settings-cover-dropzone.has-image .book-settings-cover-placeholder {
    display: none;
}

.book-settings-cover-dropzone.has-image::after {
    content: "Нажмите, чтобы заменить";
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(20, 16, 10, 0.45);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    opacity: 0;
    transition: opacity .15s ease;
}

.book-settings-cover-dropzone.has-image:hover::after,
.book-settings-cover-dropzone.has-image:focus-visible::after {
    opacity: 1;
}

.book-settings-status-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--page-line);
    border-radius: 10px;
    background: var(--page-white);
}

.book-settings-status-badge {
    font-size: 13px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 999px;
    background: var(--page);
    color: var(--text-soft);
}

.book-settings-status-badge.is-published {
    background: #E3F1E5;
    color: #3F8F4F;
}

/* ------------------------------------------------------------------ */
/* НОВОЕ: вкладки в панели редактирования выбора (см. renderChoicePanel/
   showChoiceTab в editor.js) — раньше это был один длинный скролл с
   предметами, чертами, условиями, флагами, эффектами характеристик и
   маршрутами разом. Кнопки — компактные "таблетки", переносятся на
   новую строку, если не помещаются в узкую 320px-панель.            */
/* ------------------------------------------------------------------ */
.choice-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding-bottom: 14px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--page-line);
}

.choice-tab-btn {
    padding: 5px 11px;
    border: 1px solid var(--page-line);
    border-radius: 999px;
    background: var(--page-white);
    color: var(--text-muted-warm);
    font-size: 11px;
    font-weight: 600;
    line-height: 1.4;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s ease, border-color .15s ease, color .15s ease;
}

.choice-tab-btn:hover {
    background: var(--page);
    color: var(--text-main);
}

.choice-tab-btn.active {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

.choice-tab-pane {
    /* JS (showChoiceTab) выставляет display:block только активной
       вкладке сразу же после отрисовки — эта строка защитная, на
       случай если JS почему-то не успел отработать до первой отрисовки
       кадра (не даёт всем вкладкам мелькнуть разом одним длинным
       списком). */
    display: none;
}