:root{
    --bg: #0f1115;
    --panel: #151923;
    --panel2: #10131a;
    --text: #e7e7e7;
    --muted: #9aa4b2;
    --border: #2a3342;
    --primary: #2f6fed;
    --danger: #b13a3a;
    --node: rgba(255,255,255,0.06);
    --node-border: rgba(255,255,255,0.14);
    --shadow: 0 12px 30px rgba(0,0,0,0.45);
}

*{ box-sizing: border-box; }
html, body{ height: 100%; }
body{
    margin: 0;
    background: radial-gradient(1200px 800px at 15% 10%, rgba(47,111,237,0.18), transparent 60%), var(--bg);
    color: var(--text);
    font-family: Arial, sans-serif;
    overflow: hidden;
}

.topbar{
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 58px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(15,17,21,0.65);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(42,51,66,0.65);
    z-index: 20;
}
.mode-switch{ display: flex; gap: 8px; align-items: center; }
.mode-btn{
    border: 1px solid var(--border);
    background: rgba(21,25,35,0.85);
    color: var(--text);
    padding: 9px 10px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 13px;
}
.mode-btn.active{
    background: rgba(47,111,237,0.2);
    border-color: rgba(47,111,237,0.6);
}
.topbar-right{ display:flex; align-items:center; gap: 10px; }
.ghost-btn{
    border: 1px solid var(--border);
    background: rgba(21,25,35,0.85);
    color: var(--text);
    padding: 9px 12px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 13px;
}
.ghost-btn.small-btn{ padding: 7px 10px; font-size: 12px; }
.primary-btn{
    border: 1px solid rgba(47,111,237,0.4);
    background: rgba(47,111,237,0.95);
    color: white;
    padding: 10px 14px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 13px;
}
.danger-btn{
    border: 1px solid rgba(177,58,58,0.5);
    background: rgba(177,58,58,0.2);
    color: #ffd0d0;
    padding: 10px 14px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 13px;
}

.canvas-wrap{
    position: relative;
    height: 100vh;
    width: 100%;
    padding-top: 58px;
}
.canvas{
    position: relative;
    width: 100%;
    height: calc(100vh - 58px);
    overflow: hidden;
}

#connectors.connectors{
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

#addMainBlockBtn{
    position: absolute;
    left: 14px;
    bottom: 14px;
    z-index: 5;
    display: none;
}
.floating-add{
    border: 1px solid rgba(47,111,237,0.4);
    background: rgba(47,111,237,0.95);
    color: white;
    padding: 12px 16px;
    border-radius: 14px;
    cursor: pointer;
    box-shadow: var(--shadow);
}

.node{
    position: absolute;
    z-index: 2;
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--node);
    border: 1px solid var(--node-border);
    cursor: pointer;
    user-select: none;
    box-shadow: 0 10px 24px rgba(0,0,0,0.18);
    min-width: 140px;
}
.node.main{ min-width: 170px; padding: 12px 14px; }
.node.sub{
    min-width: 110px;
    background: rgba(255,255,255,0.045);
    border-radius: 10px;
}

/* Objects mode due-date highlighting */
.node.due-green{
    border-color: rgba(35, 196, 126, 0.75);
    box-shadow: 0 10px 24px rgba(35, 196, 126, 0.12);
}
.node.due-red{
    border-color: rgba(220, 53, 69, 0.75);
    box-shadow: 0 10px 24px rgba(220, 53, 69, 0.12);
}
.node-label{
    font-weight: 700;
    font-size: 13px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.drawer{
    position: absolute;
    top: 58px;
    right: 0;
    height: calc(100vh - 58px);
    width: min(980px, 62vw);
    background: rgba(21,25,35,0.98);
    border-left: 1px solid rgba(42,51,66,0.8);
    transform: translateX(100%);
    transition: transform 240ms ease;
    z-index: 30;
    display: flex;
    flex-direction: column;
}
.drawer.open{ transform: translateX(0); }

@media (max-width: 900px){
    .drawer{
        width: 92vw;
    }
}
.drawer-header{
    padding: 14px;
    display:flex;
    align-items:center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(42,51,66,0.7);
}
.drawer-title{ font-weight: 800; }
.due-badge{
    display: inline-flex;
    margin-left: 10px;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 700;
    border-radius: 999px;
    border: 1px solid rgba(42,51,66,0.75);
    color: var(--muted);
    background: rgba(16,19,26,0.55);
    vertical-align: middle;
}
.due-badge.due-green{
    border-color: rgba(35,196,126,0.85);
    color: #bff7dc;
    background: rgba(35,196,126,0.18);
}
.due-badge.due-red{
    border-color: rgba(220,53,69,0.85);
    color: #ffd1d1;
    background: rgba(220,53,69,0.18);
}
.drawer-header.due-green{
    box-shadow: inset 0 -1px 0 rgba(35,196,126,0.55), 0 12px 26px rgba(35,196,126,0.10);
}
.drawer-header.due-red{
    box-shadow: inset 0 -1px 0 rgba(220,53,69,0.55), 0 12px 26px rgba(220,53,69,0.10);
}
.drawer-tabs-row{
    padding: 10px 14px;
    display:flex;
    align-items:center;
    gap: 10px;
}
.drawer-tabs{
    display:flex;
    gap: 8px;
    overflow:auto;
    padding-bottom: 6px;
    flex: 1;
}
.tab-btn{
    border: 1px solid var(--border);
    background: rgba(16,19,26,0.8);
    color: var(--text);
    padding: 8px 10px;
    border-radius: 10px;
    cursor:pointer;
    font-size: 12px;
    white-space: nowrap;
}
.tab-btn.active{
    border-color: rgba(47,111,237,0.7);
    background: rgba(47,111,237,0.18);
}

.drawer-content{
    padding: 0 14px;
    overflow:auto;
    flex: 1;
}
.md-content{
    padding: 12px 0 18px;
}
.md-content h1, .md-content h2, .md-content h3{
    margin-top: 12px;
}
.md-content p{ line-height: 1.55; }
.drawer-view{ }
.drawer-edit{ padding: 10px 0 18px; }
.hidden{ display:none !important; }

.drawer-comments{
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid rgba(42,51,66,0.7);
}
.comments-header{
    display:flex;
    align-items:center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}
.comments-title{
    font-weight: 900;
}
.comments-list{
    display:flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 14px;
}
.comment-card{
    border: 1px solid rgba(42,51,66,0.85);
    background: rgba(16,19,26,0.55);
    border-radius: 12px;
    padding: 12px;
}
.comment-meta{
    color: var(--muted);
    font-size: 12px;
    display:flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}
.comment-content{
    margin-top: 8px;
    font-size: 13px;
}
.comment-actions{
    margin-top: 10px;
    display:flex;
    gap: 10px;
    flex-wrap: wrap;
}
.comment-actions .ghost-btn.small-btn{
    padding: 6px 10px;
}

.editor-toolbar{
    display:flex;
    gap: 8px;
    flex-wrap: wrap;
    padding: 10px 0 12px;
}
.editor-btn{
    border: 1px solid rgba(42,51,66,0.9);
    background: rgba(16,19,26,0.75);
    color: var(--text);
    padding: 8px 10px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 13px;
}
.editor-btn:hover{
    border-color: rgba(47,111,237,0.65);
}

.rich-editor{
    background: rgba(16,19,26,0.8);
    border: 1px solid rgba(42,51,66,0.8);
    border-radius: 12px;
    padding: 12px;
    color: var(--text);
    min-height: 220px;
    overflow: auto;
    outline: none;
}
.rich-editor:empty:before{
    content: attr(aria-label);
    color: var(--muted);
    pointer-events: none;
}

.editor-preview-label{
    margin-top: 12px;
}
.rich-preview{
    background: rgba(16,19,26,0.5);
    border: 1px solid rgba(42,51,66,0.55);
    border-radius: 12px;
    padding: 12px;
    min-height: 220px;
    overflow: auto;
}

.field-label{
    display:block;
    color: var(--muted);
    margin-top: 12px;
    font-size: 12px;
}
.input, .textarea{
    width: 100%;
    background: rgba(16,19,26,0.8);
    border: 1px solid rgba(42,51,66,0.8);
    color: var(--text);
    border-radius: 10px;
    padding: 10px 12px;
    outline: none;
}
.textarea{ resize: vertical; min-height: 120px; }
.edit-actions{
    display:flex;
    gap: 10px;
    margin-top: 14px;
}
.row{ display:flex; gap: 10px; align-items: center; }
.drawer-footer{
    padding: 12px 14px;
    border-top: 1px solid rgba(42,51,66,0.7);
}

.modal{
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.62);
    display:flex;
    align-items:center;
    justify-content:center;
    z-index: 50;
}
.modal-card{
    width: 480px;
    max-width: calc(100vw - 24px);
    background: rgba(21,25,35,0.98);
    border: 1px solid rgba(42,51,66,0.8);
    border-radius: 14px;
    padding: 16px;
    box-shadow: var(--shadow);
}
.modal-head{
    display:flex;
    align-items:center;
    justify-content: space-between;
    margin-bottom: 10px;
}
.modal-title{ font-weight: 900; }
.modal-form{ display:flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.msg-error{
    min-height: 18px;
    color: #ffd0d0;
    font-size: 13px;
}
.muted-text{ margin-top: 10px; color: var(--muted); font-size: 12px; line-height: 1.4; }
.muted-text a{ color: #9ec0ff; }

.notes-panel{
    position: fixed;
    top: 58px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15,17,21,0.5);
    z-index: 10;
    padding: 14px;
    overflow: auto;
}
.notes-header{
    display:flex;
    align-items:center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.notes-title{ font-weight: 900; }
.notes-list{
    display:flex;
    flex-direction: column;
    gap: 12px;
}
.note-card{
    border: 1px solid rgba(42,51,66,0.8);
    background: rgba(21,25,35,0.85);
    border-radius: 14px;
    padding: 14px;
}
.note-card .note-title{
    font-weight: 900;
    margin-bottom: 8px;
}
.note-card .note-meta{
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 10px;
}
.note-card .note-actions{
    display:flex;
    gap: 10px;
    margin-top: 10px;
}

