/* board.css - Guven Board (whiteboard) stilləri */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    overflow: hidden;
    color: #1a1a2e;
}

.hidden {
    display: none !important;
}

/* ==================== Header ==================== */
.board-header {
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    background: #ffffff;
    border-bottom: 1px solid #e6e7eb;
    position: relative;
    z-index: 20;
}

.header-left,
.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    color: #444;
    text-decoration: none;
}

.back-btn:hover {
    background: #f0f0f3;
}

#boardName {
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    padding: 6px 10px;
    width: 220px;
    background: transparent;
}

#boardName:hover {
    border-color: #e0e0e6;
}

#boardName:focus {
    outline: none;
    border-color: #4262FF;
    background: #fff;
}

.save-status {
    font-size: 12px;
    color: #8a8a94;
    white-space: nowrap;
}

.save-status.error {
    color: #d43b3b;
    font-weight: 600;
}

.save-status.offline {
    color: #c07b00;
}

.hdr-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    border: 1px solid #e0e0e6;
    background: #fff;
    border-radius: 8px;
    padding: 7px 13px;
    font-size: 13px;
    font-weight: 600;
    color: #333;
    cursor: pointer;
}

.hdr-btn:hover {
    background: #f5f5f8;
}

.hdr-btn.primary {
    background: #4262FF;
    border-color: #4262FF;
    color: #fff;
}

.hdr-btn.primary:hover {
    background: #3251e8;
}

/* ==================== Board sahəsi ==================== */
.board-shell {
    position: relative;
    height: calc(100vh - 52px);
}

.board-stage {
    position: absolute;
    inset: 0;
    background-color: #f4f5f7;
    background-image: radial-gradient(circle, #c9cad3 1px, transparent 1px);
    background-size: 24px 24px;
    touch-action: none;
}

.board-stage.mode-hand {
    cursor: grab;
}

.board-stage.is-panning {
    cursor: grabbing !important;
}

/* ==================== Alət paneli ==================== */
.tool-sidebar {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: #fff;
    border-radius: 12px;
    padding: 8px 6px;
    box-shadow: 0 4px 18px rgba(30, 30, 60, 0.14);
    z-index: 10;
}

.tool-btn {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    border-radius: 9px;
    font-size: 17px;
    color: #2b2b3a;
    cursor: pointer;
}

.tool-btn:hover {
    background: #f0f0f4;
}

.tool-btn.active {
    background: #ECECFE;
    color: #4262FF;
}

.tool-btn.disabled {
    opacity: 0.35;
    cursor: default;
}

.tool-btn.disabled:hover {
    background: transparent;
}

.tool-divider {
    height: 1px;
    background: #e8e8ee;
    margin: 4px 6px;
}

/* ==================== Sticky rəng paleti ==================== */
.sticky-palette {
    position: absolute;
    left: 78px;
    top: 50%;
    transform: translateY(-50%);
    display: grid;
    grid-template-columns: repeat(2, 44px);
    gap: 9px;
    background: #fff;
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 4px 18px rgba(30, 30, 60, 0.14);
    z-index: 10;
}

.palette-swatch {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}

.palette-swatch:hover {
    transform: scale(1.07);
}

.palette-swatch.active {
    outline: 2px solid #4262FF;
    outline-offset: 2px;
}

/* ==================== Çəkim paneli (qələm/marker/silgi/lasso) ==================== */
.draw-bar {
    position: absolute;
    left: 78px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: #fff;
    border-radius: 12px;
    padding: 8px 6px;
    box-shadow: 0 4px 18px rgba(30, 30, 60, 0.14);
    z-index: 10;
    max-height: calc(100% - 32px);
    overflow-y: auto;
    scrollbar-width: none;
}

.draw-bar::-webkit-scrollbar {
    display: none;
}

.draw-tool {
    position: relative;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    border-radius: 9px;
    font-size: 16px;
    color: #2b2b3a;
    cursor: pointer;
    flex: 0 0 auto;
}

.draw-tool:hover {
    background: #f0f0f4;
}

.draw-tool.active {
    background: #ECECFE;
    color: #4262FF;
}

.draw-tool-disabled {
    opacity: 0.4;
}

.draw-tool-disabled:hover {
    background: transparent;
}

/* Qismən silgi ikonundakı kiçik nöqtə fərqləndiricisi */
.draw-tool-partial .partial-dot {
    position: absolute;
    right: 8px;
    bottom: 8px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.85;
}

.draw-sep {
    width: 30px;
    height: 1px;
    background: #e8e8ee;
    margin: 4px 0;
    flex: 0 0 auto;
}

.draw-swatches {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 2px 0;
}

/* Swatch: çevrə + içində rəngli nöqtə (ölçüsü = qalınlıq) */
.draw-swatch {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid #d6d6de;
    background: #fff;
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
    flex: 0 0 auto;
}

.draw-swatch:hover {
    border-color: #a9a9b8;
}

.draw-swatch.active {
    border: 2.5px solid #4262FF;
}

.draw-swatch-dot {
    border-radius: 50%;
    display: inline-block;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
}

.draw-swatch-plus {
    border-style: dashed;
    color: #7a7a88;
    font-size: 12px;
}

.draw-swatch-plus:hover {
    color: #4262FF;
    border-color: #4262FF;
}

/* ==================== Çəkim popup-ı (slider + palet) ==================== */
.draw-popup {
    position: absolute;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #fff;
    border-radius: 14px;
    padding: 14px;
    box-shadow: 0 6px 24px rgba(30, 30, 60, 0.18);
    z-index: 30;
    /* 4 sütun x 32px + 3 x 10px boşluq + sürüşdürücü yeri = 174px daxili en */
    width: 202px;
}

.draw-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(to right, #4262FF 0%, #4262FF 50%, #c9cede 50%, #c9cede 100%);
    outline: none;
    cursor: pointer;
}

.draw-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #fff;
    border: 2.5px solid #4262FF;
    cursor: grab;
}

.draw-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    border: 2.5px solid #4262FF;
    cursor: grab;
}

.draw-palette-title {
    font-size: 13px;
    color: #8a8a96;
    margin-bottom: 8px;
}

.draw-palette-grid {
    display: grid;
    grid-template-columns: repeat(4, 32px);
    gap: 10px;
    max-height: 194px;          /* ~5 sıra: qalanı üçün yalnız şaquli sürüşdürmə */
    overflow-y: auto;
    overflow-x: hidden;         /* üfüqi sürüşdürücü heç vaxt görünmür */
    scrollbar-width: thin;
    scrollbar-color: #c9cede transparent;
    scrollbar-gutter: stable;
}

.draw-palette-grid::-webkit-scrollbar {
    width: 6px;
}

.draw-palette-grid::-webkit-scrollbar-thumb {
    background: #c9cede;
    border-radius: 3px;
}

.draw-palette-grid::-webkit-scrollbar-track {
    background: transparent;
}

.draw-palette-color {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 11px;
    padding: 0;
    transition: transform .12s ease;
}

.draw-palette-color.is-white {
    box-shadow: inset 0 0 0 1.5px #d6d6de;
    color: #2b2b3a;
}

.draw-palette-color:hover {
    transform: scale(1.12);
}

/* Palitranın sonundakı "öz rəngin" düyməsi */
.draw-palette-custom {
    background: conic-gradient(#ff4d4d, #ffd93d, #6bd968, #4dd2ff, #7a6bff, #ff6bd2, #ff4d4d);
    position: relative;
}

.draw-palette-custom i {
    font-size: 11px;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, .45);
}

.draw-palette-custom.active {
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px #4262FF;
}

/* ==================== Öz rəngin: SV kvadratı + çalar + hex ==================== */
.draw-custom {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #ecedf3;
}

.draw-custom.hidden {
    display: none;
}

.draw-sv {
    position: relative;
    width: 100%;
    height: 104px;
    border-radius: 8px;
    cursor: crosshair;
    touch-action: none;
    /* Fon rəngi JS-dən: çaların tam doymuş tonu */
    background-image:
        linear-gradient(to top, #000, rgba(0, 0, 0, 0)),
        linear-gradient(to right, #fff, rgba(255, 255, 255, 0));
}

.draw-sv-knob,
.draw-hue-knob {
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .28), 0 1px 3px rgba(0, 0, 0, .3);
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.draw-hue {
    position: relative;
    width: 100%;
    height: 12px;
    border-radius: 6px;
    cursor: pointer;
    touch-action: none;
    background: linear-gradient(to right,
        #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);
}

.draw-hue-knob {
    top: 50%;
    width: 16px;
    height: 16px;
    background: #fff;
}

.draw-hex-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.draw-hex {
    flex: 1;
    min-width: 0;
    height: 30px;
    border: 1px solid #e2e3ec;
    border-radius: 7px;
    padding: 0 8px;
    font-size: 13px;
    font-family: inherit;
    color: #2b2b3a;
    text-transform: uppercase;
    outline: none;
}

.draw-hex:focus {
    border-color: #4262FF;
}

.draw-hex.is-invalid {
    border-color: #F03E3E;
}

.draw-eyedropper {
    width: 30px;
    height: 30px;
    flex: none;
    border: 1px solid #e2e3ec;
    border-radius: 7px;
    background: #fff;
    color: #5b5b6b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
}

.draw-eyedropper:hover {
    background: #f2f3f8;
    color: #2b2b3a;
}

.draw-eyedropper.active {
    background: #4262FF;
    border-color: #4262FF;
    color: #fff;
}

/* ==================== Fiqur menyusu ==================== */
.shapes-menu {
    position: absolute;
    left: 78px;
    top: 50%;
    transform: translateY(-50%);
    background: #fff;
    border-radius: 12px;
    padding: 10px;
    box-shadow: 0 4px 18px rgba(30, 30, 60, 0.14);
    z-index: 10;
}

.sm-row {
    display: flex;
    gap: 4px;
}

.sm-grid {
    display: grid;
    grid-template-columns: repeat(4, 44px);
    gap: 4px;
}

.sm-grid-6 {
    grid-template-columns: repeat(6, 40px);
}

.sm-item {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    border-radius: 9px;
    font-size: 16px;
    color: #2b2b3a;
    cursor: pointer;
}

.sm-grid-6 .sm-item {
    width: 40px;
    height: 40px;
}

.sm-item:hover {
    background: #f0f0f4;
}

.sm-item.active {
    background: #ECECFE;
    color: #4262FF;
}

.sm-conn {
    opacity: 1;
}

.sm-sep {
    height: 1px;
    background: #e8e8ee;
    margin: 8px 0;
}

.sm-more {
    display: block;
    width: 100%;
    margin-top: 10px;
    padding: 9px;
    background: #f0f0f3;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #333;
    cursor: pointer;
}

.sm-more:hover {
    background: #e7e7ec;
}

.sm-head {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
}

.sm-back {
    border: none;
    background: transparent;
    width: 30px;
    height: 30px;
    border-radius: 7px;
    color: #2b2b3a;
    cursor: pointer;
}

.sm-back:hover {
    background: #f0f0f4;
}

.sm-sections {
    width: 292px;
    max-height: min(430px, 62vh);
    overflow-y: auto;
    padding-right: 4px;
}

.sm-sec-title {
    font-size: 12.5px;
    font-weight: 700;
    color: #55555f;
    margin: 10px 0 6px;
}

/* ==================== Zoom və tarixçə panelləri ==================== */
.zoom-bar,
.history-bar {
    position: absolute;
    bottom: 16px;
    display: flex;
    align-items: center;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 14px rgba(30, 30, 60, 0.14);
    z-index: 10;
    overflow: hidden;
}

.zoom-bar {
    right: 16px;
}

.history-bar {
    left: 16px;
}

.zoom-bar button,
.history-bar button {
    border: none;
    background: transparent;
    height: 40px;
    min-width: 40px;
    padding: 0 10px;
    font-size: 14px;
    color: #2b2b3a;
    cursor: pointer;
}

.zoom-bar button:hover,
.history-bar button:hover {
    background: #f0f0f4;
}

.zoom-bar button:disabled,
.history-bar button:disabled {
    opacity: 0.35;
    cursor: default;
}

#zoomLabel {
    font-weight: 600;
    min-width: 56px;
}

/* ==================== Kontekst toolbar ==================== */
.context-toolbar {
    position: absolute;
    z-index: 15;
    user-select: none;
}

.ct-main {
    display: flex;
    align-items: center;
    gap: 2px;
    background: #fff;
    border-radius: 10px;
    padding: 5px 7px;
    box-shadow: 0 4px 18px rgba(30, 30, 60, 0.18);
}

.ct-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 34px;
    height: 34px;
    padding: 0 7px;
    border: none;
    background: transparent;
    border-radius: 7px;
    font-size: 14px;
    color: #2b2b3a;
    cursor: pointer;
    white-space: nowrap;
}

.ct-btn:hover {
    background: #f0f0f4;
}

.ct-btn.active {
    background: #ECECFE;
    color: #4262FF;
}

.ct-b {
    font-weight: 700;
    font-size: 15px;
}

.ct-font-btn {
    max-width: 120px;
}

.ct-font-btn span {
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 84px;
}

.ct-caret {
    font-size: 9px;
    color: #9a9aa4;
}

.ct-divider {
    width: 1px;
    height: 22px;
    background: #e8e8ee;
    margin: 0 4px;
    flex: none;
}

.ct-sizebox {
    display: flex;
    align-items: center;
}

.ct-size-arrows {
    display: flex;
    flex-direction: column;
}

.ct-size-arrows button {
    border: none;
    background: transparent;
    font-size: 8px;
    color: #55555f;
    cursor: pointer;
    padding: 2px 5px;
    border-radius: 4px;
    line-height: 1;
}

.ct-size-arrows button:hover {
    background: #f0f0f4;
}

.ct-color-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
}

/* Shape toolbar düymələri */
.ct-shape-tools {
    display: flex;
    align-items: center;
    gap: 2px;
}

.ct-colbtn {
    flex-direction: column;
    gap: 3px;
    padding: 4px 7px 5px;
}

.ct-A {
    font-weight: 700;
    font-size: 14px;
    line-height: 1;
}

.ct-colbtn i {
    font-size: 13px;
    line-height: 1;
}

.ct-underbar {
    width: 16px;
    height: 4px;
    border-radius: 2px;
    background: #1A1A2E;
}

.ct-underbar.none {
    background: repeating-linear-gradient(45deg, #cfcfd8 0 3px, #fff 3px 6px);
}

.ct-ring {
    width: 15px;
    height: 15px;
    border: 3px solid #1A1A2E;
    border-radius: 50%;
}

.ct-fill-dot {
    width: 18px;
    height: 18px;
    border-radius: 5px;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
}

.ct-fill-dot.none,
.ct-color-swatch.checker {
    background: repeating-conic-gradient(#e2e2e8 0% 25%, #fff 0% 50%) 0 0 / 10px 10px;
}

/* Popover-lər */
.ct-pop {
    position: absolute;
    top: calc(100% + 8px);
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 6px 22px rgba(30, 30, 60, 0.2);
    padding: 8px;
    z-index: 16;
}

.context-toolbar.below .ct-pop {
    top: auto;
    bottom: calc(100% + 8px);
}

.ct-pop-shapes {
    display: grid;
    grid-template-columns: repeat(4, 38px);
    gap: 5px;
}

.ct-shape-item {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    border-radius: 7px;
    color: #2b2b3a;
    cursor: pointer;
}

.ct-shape-item:hover {
    background: #f0f0f4;
}

.ct-shape-item.active {
    background: #ECECFE;
    color: #4262FF;
}

.ct-pop-list {
    display: flex;
    flex-direction: column;
    min-width: 150px;
    max-height: 260px;
    overflow-y: auto;
}

.ct-list-item {
    border: none;
    background: transparent;
    text-align: left;
    padding: 8px 12px;
    font-size: 14px;
    border-radius: 7px;
    cursor: pointer;
    color: #2b2b3a;
}

.ct-list-item:hover {
    background: #f0f0f4;
}

.ct-list-item.active {
    background: #ECECFE;
    color: #4262FF;
}

.ct-pop-sizes {
    min-width: 90px;
}

.ct-pop-row,
.ct-pop-row-inner {
    display: flex;
    gap: 4px;
}

.ct-pop-align {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ct-pop-row button,
.ct-pop-row-inner button {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: 7px;
    font-size: 14px;
    color: #2b2b3a;
    cursor: pointer;
}

.ct-pop-row button:hover,
.ct-pop-row-inner button:hover {
    background: #f0f0f4;
}

.ct-pop-row button.active,
.ct-pop-row-inner button.active {
    background: #ECECFE;
    color: #4262FF;
}

.ct-pop-link {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 300px;
}

.ct-pop-link input {
    flex: 1;
    border: 1px solid #dcdce4;
    border-radius: 7px;
    padding: 8px 10px;
    font-size: 13px;
    outline: none;
}

.ct-pop-link input:focus {
    border-color: #4262FF;
}

.ct-link-save {
    border: none;
    background: #4262FF;
    color: #fff;
    border-radius: 7px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.ct-link-remove {
    border: none;
    background: transparent;
    color: #d43b3b;
    border-radius: 7px;
    padding: 8px;
    cursor: pointer;
}

.ct-link-remove:hover,
.ct-link-save:hover {
    filter: brightness(0.93);
}

.ct-pop-colors {
    display: grid;
    grid-template-columns: repeat(4, 34px);
    gap: 7px;
}

.ct-color-swatch {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}

.ct-color-swatch:hover {
    transform: scale(1.08);
}

.ct-color-swatch.active {
    outline: 2px solid #4262FF;
    outline-offset: 1px;
}

.ct-color-swatch.round {
    border-radius: 50%;
}

.ct-color-swatch.none {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    color: #d43b3b;
    font-size: 14px;
}

/* Fiqur dəyişmə popover-i */
.ct-pop-swap {
    width: 296px;
    max-height: 320px;
    overflow-y: auto;
}

/* Çərçivə popover-i */
.ct-pop-border {
    width: 200px;
}

.ct-strokew-row {
    display: flex;
    gap: 4px;
    justify-content: space-between;
}

.ct-strokew {
    flex: 1;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    border-radius: 7px;
    cursor: pointer;
}

.ct-strokew:hover {
    background: #f0f0f4;
}

.ct-strokew.active {
    background: #ECECFE;
}

.ct-strokew span {
    display: inline-block;
    width: 22px;
    background: #2b2b3a;
    border-radius: 2px;
}

.ct-pop-sep {
    height: 1px;
    background: #e8e8ee;
    margin: 8px 0;
}

.ct-border-colors {
    display: grid;
    grid-template-columns: repeat(5, 32px);
    gap: 6px;
}

.ct-border-colors .ct-color-swatch {
    width: 32px;
    height: 32px;
}

.ct-pop-menu {
    display: flex;
    flex-direction: column;
    min-width: 190px;
}

.ct-pop-menu button {
    display: flex;
    align-items: center;
    gap: 10px;
    border: none;
    background: transparent;
    text-align: left;
    padding: 9px 12px;
    font-size: 13.5px;
    border-radius: 7px;
    color: #2b2b3a;
    cursor: pointer;
}

.ct-pop-menu button:hover {
    background: #f0f0f4;
}

.ct-pop-menu button.danger {
    color: #d43b3b;
}

.ct-pop-menu i {
    width: 16px;
    text-align: center;
}

.ct-kbd {
    margin-left: auto;
    font-size: 11px;
    color: #9a9aa4;
}

/* ==================== Connector toolbar ==================== */
.connector-toolbar .ct-main {
    border-radius: 12px;
    padding: 5px 6px;
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: thin;
}

.context-toolbar.connector-toolbar .ct-pop {
    top: calc(100% + 8px);
    bottom: auto;
    overflow-y: auto;
}

.context-toolbar.connector-toolbar .ct-pop.pop-above {
    top: auto;
    bottom: calc(100% + 8px);
}

.connector-toolbar .ct-btn:disabled,
.connector-toolbar .ct-pop-menu button:disabled {
    opacity: 0.38;
    cursor: not-allowed;
    background: transparent;
}

.conn-end-btn {
    min-width: 82px;
    justify-content: flex-start;
    padding: 0 8px;
}

.conn-end-btn svg {
    flex: none;
}

.conn-end-btn span {
    max-width: 46px;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 13px;
}

.conn-swap-btn {
    min-width: 30px;
    padding: 0 5px;
}

.conn-route-btn {
    flex-direction: column;
    gap: 0;
    min-width: 46px;
    height: 40px;
}

.conn-route-btn svg {
    display: block;
    height: 21px;
}

.conn-route-btn small {
    font-size: 10px;
    line-height: 1;
}

.conn-color-dot {
    width: 21px;
    height: 21px;
    display: block;
    border-radius: 50%;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.16);
}

.conn-marker-pop {
    display: flex;
    flex-direction: column;
    min-width: 154px;
    gap: 2px;
}

.conn-marker-item {
    height: 38px;
    display: flex;
    align-items: center;
    gap: 8px;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: #2b2b3a;
    padding: 0 9px;
    cursor: pointer;
    text-align: left;
}

.conn-marker-item:hover,
.conn-marker-item.active {
    background: #f0f0f4;
}

.conn-marker-item.active {
    color: #4262FF;
}

.conn-line-pop {
    width: 238px;
}

.conn-pop-label {
    margin: 1px 4px 7px;
    color: #777785;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.conn-route-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
}

.conn-route-grid button {
    min-height: 58px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #2b2b3a;
    cursor: pointer;
}

.conn-route-grid button span {
    font-size: 10px;
}

.conn-route-grid button:hover,
.conn-route-grid button.active,
.conn-stroke-grid button:hover,
.conn-stroke-grid button.active {
    background: #ECECFE;
    color: #4262FF;
}

.conn-stroke-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
}

.conn-stroke-grid button {
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 7px;
    background: transparent;
    cursor: pointer;
}

.conn-stroke {
    width: 44px;
    height: 2px;
    display: block;
    background: #2b2b3a;
}

.conn-stroke.dashed {
    background: repeating-linear-gradient(90deg, #2b2b3a 0 9px, transparent 9px 14px);
}

.conn-stroke.dotted {
    background: repeating-linear-gradient(90deg, #2b2b3a 0 2px, transparent 2px 7px);
}

.conn-attach-pop {
    width: 296px;
}

/* Xəttin ucuna dblclick ilə açılan item menyusu */
.endpoint-attach-menu {
    position: absolute;
    z-index: 20;
}

.conn-attach-pop .sm-sections {
    width: auto;
    max-height: min(320px, 50vh);
    margin-top: 2px;
    padding-right: 2px;
}

.conn-attach-pop .sm-sec-title:first-child {
    margin-top: 0;
}

.ct-text-position-btn {
    position: relative;
    width: 44px;
    flex-direction: column;
    gap: 0;
    font-size: 9px;
    font-weight: 700;
    line-height: 1;
}

.ct-text-position-btn svg {
    width: 25px;
    height: 10px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.4;
    stroke-dasharray: 2 2;
}

.ct-text-position-pop button {
    width: 74px;
    font-size: 12px;
}

.ct-tp-flat,
.ct-tp-path {
    font-weight: 700;
}

/* ==================== Mətn redaktə overlay ==================== */
#textEditOverlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 5;
}

.board-text-edit {
    position: absolute;
    pointer-events: auto;
    transform-origin: top left;
    margin: 0;
    border: none;
    outline: none;
    background: transparent;
    resize: none;
    overflow: hidden;
    white-space: pre-wrap;
    word-break: break-word;
}

/* ==================== Toast ==================== */
.toast {
    position: fixed;
    bottom: 26px;
    left: 50%;
    transform: translateX(-50%);
    background: #24243a;
    color: #fff;
    font-size: 13px;
    padding: 11px 18px;
    border-radius: 9px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
    z-index: 100;
    max-width: 70vw;
    text-align: center;
}

/* ==================== Boardlarım modalı ==================== */
.board-modal {
    position: fixed;
    inset: 0;
    background: rgba(20, 20, 40, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.board-modal-content {
    background: #fff;
    border-radius: 14px;
    width: 500px;
    max-width: calc(100vw - 40px);
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.board-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #ececf1;
}

.board-modal-header h3 {
    margin: 0;
    font-size: 16px;
}

.board-modal-close {
    border: none;
    background: transparent;
    font-size: 17px;
    color: #666;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
}

.board-modal-close:hover {
    background: #f0f0f4;
}

.boards-list {
    overflow-y: auto;
    padding: 8px;
}

.boards-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 9px;
    cursor: pointer;
}

.boards-item:hover {
    background: #f4f4f8;
}

.boards-item i {
    color: #4262FF;
}

.boards-item-name {
    flex: 1;
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.boards-item-date {
    font-size: 12px;
    color: #8a8a94;
    white-space: nowrap;
}

.boards-empty {
    padding: 34px 20px;
    text-align: center;
    color: #8a8a94;
    font-size: 14px;
}

/* ==================== Navbar: əlavə düymələr (Faza 8.3) ==================== */
.hdr-btn.icon-only {
    padding: 7px 10px;
}

.hdr-btn.danger {
    background: #d43b3b;
    border-color: #d43b3b;
    color: #fff;
}

.hdr-btn.danger:hover {
    background: #c02f2f;
}

.hdr-btn:disabled {
    opacity: 0.45;
    cursor: default;
}

.readonly-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: #c07b00;
    background: #fff6e5;
    border: 1px solid #f2dcb0;
    border-radius: 7px;
    padding: 5px 9px;
}

.share-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: 9px;
    background: #4262FF;
    color: #fff;
    font-size: 10.5px;
    font-weight: 700;
}

/* ==================== Navbar popover-ləri ==================== */
.hdr-pop {
    position: fixed;
    z-index: 60;
    width: 320px;
    max-height: 60vh;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #e0e0e6;
    border-radius: 10px;
    box-shadow: 0 12px 30px rgba(20, 20, 50, 0.16);
    padding: 6px;
}

.pop-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 7px 8px 9px;
    border-bottom: 1px solid #eeeef2;
    font-size: 12.5px;
    font-weight: 700;
    color: #33333f;
}

.pop-head-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid #e0e0e6;
    background: #fff;
    border-radius: 7px;
    padding: 5px 9px;
    font-size: 12px;
    font-weight: 600;
    color: #4262FF;
    cursor: pointer;
}

.pop-head-btn:hover {
    background: #f2f4ff;
    border-color: #c9d0ff;
}

.pop-list {
    padding: 4px 0;
}

.pop-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 7px;
}

.pop-row:hover {
    background: #f6f6fa;
}

.pop-row-main {
    flex: 1;
    min-width: 0;
}

.pop-row-title {
    font-size: 12.5px;
    font-weight: 600;
    color: #26263a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pop-row-meta {
    font-size: 11px;
    color: #8a8a94;
    margin-top: 2px;
}

.pop-row-btn {
    border: 1px solid #e0e0e6;
    background: #fff;
    border-radius: 6px;
    padding: 4px 9px;
    font-size: 11.5px;
    font-weight: 600;
    color: #33333f;
    cursor: pointer;
    white-space: nowrap;
}

.pop-row-btn:hover {
    background: #f2f4ff;
    border-color: #c9d0ff;
    color: #4262FF;
}

.pop-empty {
    padding: 22px 12px;
    text-align: center;
    font-size: 12.5px;
    color: #8a8a94;
}

.pop-menu button {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    border: none;
    background: none;
    padding: 8px 10px;
    border-radius: 7px;
    font-size: 13px;
    color: #33333f;
    cursor: pointer;
    text-align: left;
}

.pop-menu button:hover {
    background: #f4f4f8;
}

.pop-menu button i {
    width: 14px;
    text-align: center;
    color: #7a7a88;
}

.pop-menu button.danger,
.pop-menu button.danger i {
    color: #d43b3b;
}

.pop-menu button.danger:hover {
    background: #fdeeee;
}

.pop-sep {
    height: 1px;
    background: #eeeef2;
    margin: 4px 2px;
}

/* ==================== Paylaşma modalı (Faza 8.5) ==================== */
.share-modal {
    width: 460px;
    max-width: 94vw;
}

.share-body {
    padding: 14px 16px 18px;
}

.share-search {
    position: relative;
    display: flex;
    align-items: center;
}

.share-search i {
    position: absolute;
    left: 11px;
    font-size: 12px;
    color: #9a9aa6;
    pointer-events: none;
}

.share-search input {
    width: 100%;
    border: 1px solid #e0e0e6;
    border-radius: 8px;
    padding: 9px 12px 9px 31px;
    font-size: 13.5px;
    color: #1a1a2e;
}

.share-search input:focus {
    outline: none;
    border-color: #4262FF;
}

.share-candidates {
    margin-top: 8px;
    max-height: 210px;
    overflow-y: auto;
    border: 1px solid #eeeef2;
    border-radius: 9px;
    padding: 4px;
}

.share-candidate {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    border: none;
    background: none;
    padding: 7px 8px;
    border-radius: 7px;
    cursor: pointer;
    text-align: left;
}

.share-candidate:hover:not(:disabled) {
    background: #f2f4ff;
}

.share-candidate:disabled {
    opacity: 0.5;
    cursor: default;
}

.share-add {
    color: #4262FF;
    font-size: 12px;
}

.share-list {
    margin-top: 14px;
    max-height: 260px;
    overflow-y: auto;
}

.share-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 6px;
    border-radius: 8px;
}

.share-row:hover {
    background: #f8f8fb;
}

.share-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 30px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #eef1ff;
    color: #4262FF;
    font-size: 13px;
    font-weight: 700;
}

.share-row-main {
    flex: 1;
    min-width: 0;
    display: block;
}

.share-row-name {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #26263a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.share-row-mail {
    display: block;
    font-size: 11px;
    color: #8a8a94;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.share-role {
    border: 1px solid #e0e0e6;
    border-radius: 7px;
    padding: 5px 7px;
    font-size: 12px;
    color: #33333f;
    background: #fff;
    cursor: pointer;
}

.share-role:disabled {
    opacity: 0.5;
    cursor: default;
}

.share-remove {
    width: 26px;
    height: 26px;
    border: none;
    background: none;
    border-radius: 6px;
    color: #9a9aa6;
    cursor: pointer;
}

.share-remove:hover:not(:disabled) {
    background: #fdeeee;
    color: #d43b3b;
}

.share-remove:disabled {
    opacity: 0.4;
    cursor: default;
}

.share-empty {
    padding: 20px 10px;
    text-align: center;
    font-size: 12.5px;
    color: #8a8a94;
}

/* ==================== Paylaşma: tablar ==================== */
.share-tabs {
    display: flex;
    gap: 4px;
    padding: 0 16px;
    border-bottom: 1px solid #eeeef2;
}

.share-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    padding: 9px 12px;
    font-size: 13px;
    font-weight: 500;
    color: #6a6a78;
    cursor: pointer;
}

.share-tab:hover {
    color: #1a1a2e;
}

.share-tab.active {
    color: #4262FF;
    border-bottom-color: #4262FF;
}

/* ==================== Paylaşma: user kodu ==================== */
.share-code {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid #eeeef2;
}

.share-code-label {
    font-size: 12px;
    color: #8a8a94;
    margin-bottom: 6px;
}

.share-code-row {
    display: flex;
    gap: 6px;
}

.share-code-row input {
    flex: 1;
    min-width: 0;
    border: 1px solid #e0e0e6;
    border-radius: 8px;
    padding: 8px 11px;
    font-size: 13.5px;
    color: #1a1a2e;
}

.share-code-row input:focus {
    outline: none;
    border-color: #4262FF;
}

.share-code-row input.is-invalid {
    border-color: #e05252;
}

.share-code-result {
    margin-top: 8px;
    border: 1px solid #eeeef2;
    border-radius: 9px;
    padding: 4px;
}

/* ==================== Paylaşma: şirkət ==================== */
.share-company-list {
    max-height: 260px;
    overflow-y: auto;
    border: 1px solid #eeeef2;
    border-radius: 9px;
    padding: 4px;
}

.share-company-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    background: none;
    border: none;
    border-radius: 7px;
    padding: 9px 10px;
    text-align: left;
    cursor: pointer;
}

.share-company-item:hover:not(:disabled) {
    background: #f4f5f9;
}

.share-company-item:disabled {
    opacity: .5;
    cursor: default;
}

.share-company-item.active {
    background: #eef1ff;
}

.share-company-icon {
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: #f0f0f4;
    color: #6a6a78;
    font-size: 12px;
}

.share-company-item.active .share-company-icon {
    background: #4262FF;
    color: #fff;
}

.share-company-main {
    flex: 1;
    min-width: 0;
}

.share-company-name {
    font-size: 13.5px;
    color: #1a1a2e;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.share-company-kind {
    font-size: 11.5px;
    color: #8a8a94;
}

.share-company-options {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #eeeef2;
}

.share-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13.5px;
    color: #1a1a2e;
    cursor: pointer;
}

.share-toggle input {
    width: 15px;
    height: 15px;
    accent-color: #4262FF;
    cursor: pointer;
}

.share-company-role {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    font-size: 13px;
    color: #6a6a78;
}

.share-company-hint {
    margin-top: 10px;
    font-size: 12px;
    color: #8a8a94;
    line-height: 1.5;
}

.share-company-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 14px;
}

/* ==================== Ümumi dialoq ==================== */
.dialog-content {
    width: 420px;
    max-width: 92vw;
}

.dialog-body {
    padding: 16px 18px 4px;
}

.dialog-text {
    margin: 0 0 12px;
    font-size: 13.5px;
    color: #4a4a58;
    line-height: 1.5;
}

.dialog-input {
    width: 100%;
    border: 1px solid #e0e0e6;
    border-radius: 8px;
    padding: 9px 11px;
    font-size: 14px;
    color: #1a1a2e;
}

.dialog-input:focus {
    outline: none;
    border-color: #4262FF;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 9px;
    padding: 16px 18px 18px;
}

/* ==================== Yalnız-oxu rejimi ==================== */
body.is-readonly .tool-sidebar {
    pointer-events: none;
    opacity: 0.45;
}

body.is-readonly .history-bar {
    display: none;
}
