body.canvas-marker-mode-active {
    cursor: crosshair;
}

.canvas-marker-hidden {
    visibility: hidden !important;
    pointer-events: none !important;
}

.left-canvas-card.canvas-marker-edit-target {
    cursor: crosshair;
    box-shadow: 0 0 0 calc(2px / var(--current-scale, 1)) rgba(239, 35, 35, 0.95), var(--shadow-lg);
}

.left-canvas-card.canvas-marker-edit-target .canvas-card-size-badge,
.left-canvas-card.canvas-marker-edit-target .canvas-card-controls,
.left-canvas-card.canvas-marker-edit-target .canvas-resize-handles,
.left-canvas-card.canvas-marker-edit-target .node-out {
    display: none !important;
}

.canvas-marker-layer {
    position: absolute;
    inset: 0;
    z-index: 100000;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: visible;
}

.canvas-marker-arrow-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
    pointer-events: none;
}

.canvas-marker-arrow {
    stroke: #ef2323;
    stroke-width: 3;
    stroke-linecap: round;
    opacity: 0.96;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.24));
}

.canvas-marker-arrow.draft {
    opacity: 0.58;
    stroke-dasharray: 7 6;
}

.canvas-marker-ref-link {
    stroke: #cbd5e1;
    stroke-width: 3;
    fill: none;
    opacity: 0.98;
}

.canvas-marker-ref-link.draft {
    stroke: #a1a1aa;
    stroke-dasharray: 5 5;
}

.canvas-marker-ref-link.draft.ready {
    stroke: #10b981;
}

.canvas-marker-start {
    fill: #fff;
    stroke: #ef2323;
    stroke-width: 3;
    filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.22));
}

.canvas-marker-start.draft {
    opacity: 0.72;
}

.canvas-marker-arrow-label {
    fill: #ef2323;
    stroke: #fff;
    stroke-width: 3;
    paint-order: stroke;
    font-size: 18px;
    font-weight: 800;
    line-height: 1;
    user-select: none;
}

.canvas-marker-tip-handle {
    fill: #fff;
    stroke: #ef2323;
    stroke-width: 3;
    cursor: grab;
    pointer-events: all;
    filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.22));
}

.canvas-marker-tip-handle:active {
    cursor: grabbing;
}

.canvas-marker-tip-hit {
    fill: rgba(239, 35, 35, 0.001);
    stroke: transparent;
    cursor: grab;
    pointer-events: all;
}

.canvas-marker-note {
    position: absolute;
    z-index: 100010;
    width: 246px;
    min-height: 120px;
    padding: 11px 11px 10px;
    border: 1px solid rgba(239, 35, 35, 0.28);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 16px 36px rgba(15, 23, 42, 0.24);
    transform: translate(-50%, calc(-100% - 14px)) scale(calc(1 / var(--current-scale, 1)));
    transform-origin: bottom center;
    pointer-events: auto;
    cursor: grab;
    color: #111827;
}

.canvas-marker-note-ref-node {
    position: absolute;
    left: -7px;
    top: 50%;
    width: 14px;
    height: 14px;
    margin-top: -7px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: #10b981;
    box-sizing: border-box;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.2s;
}

.canvas-marker-note-ref-node.snap-ready {
    background: #fbbf24;
    transform: scale(1.5);
}

.canvas-marker-note-ref-node:hover {
    background: #059669;
    transform: scale(1.3);
}

.canvas-marker-note:active {
    cursor: grabbing;
}

.canvas-marker-note-title {
    padding-right: 28px;
    margin-bottom: 7px;
    color: #ef2323;
    font-size: 12px;
    font-weight: 800;
    line-height: 1.2;
}

.canvas-marker-note textarea {
    width: 100%;
    min-height: 78px;
    resize: vertical;
    border: 1px solid #d1d5db;
    border-radius: 7px;
    padding: 8px;
    color: #111827;
    font-size: 13px;
    line-height: 1.45;
    outline: none;
    cursor: text;
}

.canvas-marker-note textarea:focus {
    border-color: #ef2323;
    box-shadow: 0 0 0 3px rgba(239, 35, 35, 0.12);
}

.canvas-marker-note-close {
    position: absolute;
    top: 7px;
    right: 7px;
    width: 22px;
    height: 22px;
    border: 0;
    border-radius: 50%;
    background: #f3f4f6;
    color: #6b7280;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
}

.canvas-marker-note-close:hover {
    background: #fee2e2;
    color: #b91c1c;
}

.canvas-marker-actions {
    position: absolute;
    left: 50%;
    top: calc(100% + 12px);
    z-index: 100020;
    width: max-content;
    min-width: 360px;
    max-width: none;
    padding: 10px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.24);
    transform: translateX(-50%);
    transform-origin: top center;
}

.canvas-marker-local-panel {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 9px;
    min-width: 0;
}

.canvas-marker-local-panel .task-window-control-label {
    color: #666;
    font-size: 11px;
    font-weight: 500;
}

.canvas-marker-local-panel .canvas-marker-model-section {
    flex: 1 1 auto;
}

.canvas-marker-local-panel .canvas-marker-model-picker {
    width: 146px;
    max-width: 146px;
}

.canvas-marker-local-panel .task-ratio-dropdown {
    z-index: 100070;
    max-height: none;
    overflow: visible;
}

.canvas-marker-local-panel .task-model-options {
    z-index: 100080;
}

.canvas-marker-local-panel .task-ratio-trigger {
    white-space: nowrap;
}

.canvas-marker-local-panel .task-resolution-selector {
    border-top: 0;
    padding: 0;
}

.canvas-marker-local-panel .task-resolution-label:first-child {
    margin-top: 0;
}

.canvas-marker-local-panel .task-resolution-grid,
.canvas-marker-local-panel .task-resolution-toapis-grid {
    margin-bottom: 7px;
}

.canvas-marker-button-row {
    display: flex;
    justify-content: center;
}

.canvas-marker-actions-divider {
    height: 1px;
    margin: 10px 2px 7px;
    background: rgba(15, 23, 42, 0.12);
}

.canvas-marker-prompt-note {
    color: #6b7280;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.35;
    text-align: center;
    white-space: nowrap;
}

.canvas-marker-btn {
    min-height: 36px;
    min-width: 112px;
    border: 0;
    border-radius: 999px;
    padding: 0 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: #050505;
    color: #fff;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
}

.canvas-marker-btn:hover {
    background: #1f2937;
}

.canvas-marker-btn:disabled {
    opacity: 0.62;
    cursor: not-allowed;
}

.canvas-marker-btn .credit-cost-badge {
    color: #fff;
}

.canvas-marker-btn .credit-cost-icon {
    color: #facc15;
}

.left-canvas-card.canvas-marker-reference-card {
    cursor: move;
    box-shadow: 0 0 0 calc(2px / var(--current-scale, 1)) rgba(59, 130, 246, 0.9), var(--shadow-lg);
}

.left-canvas-card.canvas-marker-reference-card .canvas-card-size-badge,
.left-canvas-card.canvas-marker-reference-card .canvas-card-controls {
    display: none !important;
}

.left-canvas-card.canvas-marker-reference-card .node-out {
    display: block !important;
    pointer-events: auto !important;
}

.canvas-marker-ref-delete {
    position: absolute;
    top: calc(6px / var(--current-scale, 1));
    right: calc(6px / var(--current-scale, 1));
    z-index: 100025;
    width: calc(24px / var(--current-scale, 1));
    height: calc(24px / var(--current-scale, 1));
    min-width: 18px;
    min-height: 18px;
    border: 0;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(17, 24, 39, 0.78);
    color: #fff;
    font-size: calc(16px / var(--current-scale, 1));
    line-height: 1;
    cursor: pointer;
    pointer-events: auto;
}

.canvas-marker-ref-delete:hover {
    background: #ef2323;
}

.canvas-marker-ref-line-delete {
    z-index: 100100;
}

.canvas-marker-drawer-toggle {
    position: fixed;
    left: 0;
    top: 50%;
    z-index: 100110;
    width: 34px;
    height: 106px;
    border: 0;
    border-radius: 0 10px 10px 0;
    background: rgba(5, 5, 5, 0.94);
    color: #fff;
    box-shadow: 0 12px 26px rgba(0, 0, 0, 0.24);
    cursor: pointer;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: translateY(-50%);
    transition: left 0.22s ease, background-color 0.18s ease;
    pointer-events: auto;
}

.canvas-marker-drawer-toggle:hover {
    background: #111827;
}

.canvas-marker-drawer-toggle.open {
    left: 300px;
}

.canvas-marker-reference-drawer {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 100105;
    width: 300px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    background: rgba(5, 5, 5, 0.96);
    color: #fff;
    box-shadow: 18px 0 44px rgba(0, 0, 0, 0.32);
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    pointer-events: auto;
}

.canvas-marker-reference-drawer.open {
    transform: translateX(0);
}

.canvas-marker-drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 56px;
    padding: 0 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.canvas-marker-drawer-title {
    min-width: 0;
    overflow: hidden;
    color: #fff;
    font-size: 14px;
    font-weight: 800;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.canvas-marker-drawer-close {
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.canvas-marker-drawer-close:hover {
    background: rgba(239, 35, 35, 0.92);
}

.canvas-marker-drawer-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 10px;
}

.canvas-marker-drawer-empty {
    padding: 18px 8px;
    color: rgba(255, 255, 255, 0.62);
    font-size: 12px;
    line-height: 1.45;
    text-align: center;
}

.canvas-marker-drawer-row {
    display: grid;
    grid-template-columns: 68px minmax(0, 1fr) 56px;
    align-items: center;
    gap: 10px;
    min-height: 74px;
    padding: 7px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.canvas-marker-drawer-row:last-child {
    border-bottom: 0;
}

.canvas-marker-drawer-thumb {
    width: 68px;
    height: 54px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.08);
}

.canvas-marker-drawer-thumb img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
}

.canvas-marker-drawer-meta {
    min-width: 0;
}

.canvas-marker-drawer-card-title {
    overflow: hidden;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.canvas-marker-drawer-card-size {
    margin-top: 5px;
    overflow: hidden;
    color: rgba(255, 255, 255, 0.58);
    font-size: 11px;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.canvas-marker-drawer-call {
    min-width: 52px;
    height: 30px;
    border: 0;
    border-radius: 999px;
    background: #fff;
    color: #050505;
    font-size: 12px;
    font-weight: 800;
    line-height: 1;
    cursor: pointer;
}

.canvas-marker-drawer-call:hover {
    background: #e5e7eb;
}

.canvas-marker-drawer-call:disabled {
    opacity: 0.38;
    cursor: not-allowed;
}

.canvas-marker-status {
    position: absolute;
    left: 50%;
    bottom: calc(100% + (12px / var(--current-scale, 1)));
    z-index: 100030;
    display: none;
    max-width: min(420px, calc(100vw - var(--right-panel-width, 380px) - 56px));
    padding: calc(7px / var(--current-scale, 1)) calc(13px / var(--current-scale, 1));
    border-radius: 999px;
    background: rgba(75, 85, 99, 0.94);
    color: #fff;
    font-size: calc(12px / var(--current-scale, 1));
    font-weight: 700;
    line-height: 1.35;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-shadow: 0 calc(8px / var(--current-scale, 1)) calc(22px / var(--current-scale, 1)) rgba(15, 23, 42, 0.20);
    transform: translateX(-50%);
    pointer-events: none;
}

.canvas-marker-status.show {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.canvas-marker-mode-pill {
    position: fixed;
    left: calc((100vw - var(--right-panel-width, 380px)) / 2);
    top: 20px;
    z-index: 100090;
    transform: translateX(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    max-width: min(680px, calc(100vw - var(--right-panel-width, 380px) - 40px));
    padding: 9px 12px 9px 18px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.68);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: 0;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
    backdrop-filter: blur(8px);
    pointer-events: auto;
}

.canvas-marker-mode-pill span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.canvas-marker-mode-pill button {
    border: 0;
    border-radius: 999px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
}

.canvas-marker-mode-pill button:hover {
    background: rgba(255, 255, 255, 0.28);
}

.canvas-marker-exit-backdrop {
    position: fixed;
    inset: 0;
    z-index: 100200;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.28);
    pointer-events: auto;
}

.canvas-marker-exit-dialog {
    width: min(360px, calc(100vw - 40px));
    padding: 20px;
    border-radius: 10px;
    background: #fff;
    color: #111827;
    box-shadow: 0 22px 60px rgba(15, 23, 42, 0.32);
}

.canvas-marker-exit-title {
    font-size: 15px;
    font-weight: 800;
    line-height: 1.5;
    text-align: center;
}

.canvas-marker-exit-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 18px;
}

.canvas-marker-exit-btn {
    min-width: 92px;
    min-height: 34px;
    border: 0;
    border-radius: 999px;
    padding: 0 15px;
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
}

.canvas-marker-exit-btn.secondary {
    background: #f3f4f6;
    color: #374151;
}

.canvas-marker-exit-btn.primary {
    background: #111827;
    color: #fff;
}

.canvas-marker-toast {
    position: fixed;
    left: calc((100vw - var(--right-panel-width, 380px)) / 2);
    bottom: 86px;
    z-index: 100160;
    transform: translateX(-50%) translateY(8px);
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(17, 24, 39, 0.86);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.25;
    opacity: 0;
    transition: opacity 0.18s ease, transform 0.18s ease;
    pointer-events: none;
}

.canvas-marker-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.canvas-marker-disabled-control {
    opacity: 0.42 !important;
    cursor: not-allowed !important;
}

.canvas-marker-disabled-control,
.canvas-marker-disabled-control * {
    pointer-events: none !important;
}

body.canvas-marker-mode-active .card-toolbar,
body.canvas-marker-mode-active .card-image-info-popup,
body.canvas-marker-mode-active .card-placeholder-popup {
    display: none !important;
}

@media (max-width: 900px) {
    .canvas-marker-mode-pill,
    .canvas-marker-toast {
        left: 50%;
        max-width: calc(100vw - 40px);
    }
}
