* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Microsoft YaHei', sans-serif;
    background: #f5f7fa;
    overflow: hidden;
    height: 100vh;
}

.toolbar {
    height: 48px;
    background: #fff;
    border-bottom: 1px solid #e4e7ed;
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 8px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.toolbar-group {
    display: flex;
    gap: 6px;
}

.toolbar-divider {
    width: 1px;
    height: 24px;
    background: #dcdfe6;
    margin: 0 8px;
}

.btn {
    padding: 6px 14px;
    border: 1px solid #dcdfe6;
    border-radius: 4px;
    background: #fff;
    color: #606266;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
}

.btn:hover {
    border-color: #409eff;
    color: #409eff;
}

.btn:active {
    transform: scale(0.97);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.zoom-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.zoom-level {
    min-width: 50px;
    text-align: center;
    font-size: 13px;
    color: #606266;
    padding: 0 4px;
}

.align-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #606266;
    cursor: pointer;
}

.align-toggle input {
    cursor: pointer;
}

.align-line {
    position: absolute;
    background: #409eff;
    opacity: 0.6;
    z-index: 100;
    pointer-events: none;
}

.align-line.horizontal {
    height: 1px;
    width: 100%;
    left: 0;
}

.align-line.vertical {
    width: 1px;
    height: 100%;
    top: 0;
}

.btn-primary {
    background: #409eff;
    border-color: #409eff;
    color: #fff;
}

.btn-primary:hover {
    background: #66b1ff;
    border-color: #66b1ff;
    color: #fff;
}

.btn-success {
    background: #67c23a;
    border-color: #67c23a;
    color: #fff;
}

.btn-success:hover {
    background: #85ce61;
    border-color: #85ce61;
    color: #fff;
}

.btn-danger {
    background: #f56c6c;
    border-color: #f56c6c;
    color: #fff;
}

.btn-danger:hover {
    background: #f78989;
    border-color: #f78989;
    color: #fff;
}

.main-area {
    display: flex;
    height: calc(100vh - 48px);
    margin-top: 48px;
}

.sidebar {
    width: 240px;
    background: #fff;
    border-right: 1px solid #e4e7ed;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 600;
    color: #303133;
    border-bottom: 1px solid #e4e7ed;
    background: #fafafa;
}

.outline-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.outline-item {
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    color: #606266;
    margin-bottom: 2px;
    transition: all 0.15s;
}

.outline-item:hover {
    background: #f0f7ff;
}

.outline-item.selected {
    background: #ecf5ff;
    color: #409eff;
}

.outline-item.level-0 {
    font-weight: 600;
    font-size: 14px;
}

.outline-item.level-1 {
    padding-left: 24px;
}

.outline-item.level-2 {
    padding-left: 40px;
    font-size: 12px;
}

.outline-item.level-3 {
    padding-left: 56px;
    font-size: 12px;
    color: #909399;
}

.canvas-wrapper {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #f5f7fa;
    background-image: 
        radial-gradient(circle, #e0e3e8 1px, transparent 1px);
    background-size: 20px 20px;
}

.connections-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 10000px;
    height: 10000px;
    pointer-events: none;
    z-index: 1;
    overflow: visible;
}

.canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 10000px;
    height: 10000px;
    z-index: 2;
}

.node {
    position: absolute;
    min-width: 80px;
    max-width: 200px;
    padding: 10px 16px;
    background: #fff;
    border: 2px solid #409eff;
    border-radius: 6px;
    cursor: move;
    user-select: none;
    transition: box-shadow 0.2s, transform 0.1s;
    z-index: 10;
}

.node:hover {
    box-shadow: 0 4px 12px rgba(64, 158, 255, 0.2);
}

.node.selected {
    box-shadow: 0 0 0 3px rgba(64, 158, 255, 0.3);
}

.node.root {
    background: linear-gradient(135deg, #409eff 0%, #337ecc 100%);
    border-color: #337ecc;
    color: #fff;
    font-weight: 600;
    font-size: 15px;
    padding: 14px 24px;
    border-radius: 8px;
}

.node.level-1 {
    background: linear-gradient(135deg, #67c23a 0%, #529b2e 100%);
    border-color: #529b2e;
    color: #fff;
    font-weight: 500;
}

.node.level-2 {
    background: linear-gradient(135deg, #e6a23c 0%, #c48a2c 100%);
    border-color: #c48a2c;
    color: #fff;
}

.node.level-3 {
    background: linear-gradient(135deg, #909399 0%, #73767a 100%);
    border-color: #73767a;
    color: #fff;
    font-size: 13px;
}

.node-text {
    font-size: 14px;
    text-align: center;
    outline: none;
    word-break: break-word;
}

.node-text:focus {
    background: rgba(64, 158, 255, 0.1);
    border-radius: 3px;
}

.node.root .node-text {
    color: #fff;
}

.add-btn {
    position: absolute;
    right: -14px;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
    background: #409eff;
    border: 2px solid #fff;
    border-radius: 50%;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.2s;
    z-index: 20;
}

.node:hover .add-btn {
    opacity: 1;
}

.node.level-1 .add-btn,
.node.level-1:hover .add-btn {
    background: #67c23a !important;
}

.node.level-2 .add-btn,
.node.level-2:hover .add-btn {
    background: #e6a23c !important;
}

.node.level-3 .add-btn,
.node.level-3:hover .add-btn {
    background: #909399 !important;
}

.node.level-1 .add-btn:hover {
    background: #85ce61 !important;
    transform: translateY(-50%) scale(1.1);
}

.node.level-2 .add-btn:hover {
    background: #ebb563 !important;
    transform: translateY(-50%) scale(1.1);
}

.node.level-3 .add-btn:hover {
    background: #a6a9ad !important;
    transform: translateY(-50%) scale(1.1);
}

.add-btn:hover {
    background: #66b1ff !important;
    transform: translateY(-50%) scale(1.1);
}

.connection-line {
    fill: none;
    stroke: #c0c4cc;
    stroke-width: 2;
    stroke-linecap: round;
}

.connection-line.level-0 {
    stroke: #409eff;
    stroke-width: 2.5;
}

.connection-line.level-1 {
    stroke: #67c23a;
    stroke-width: 2;
}

.connection-line.level-2 {
    stroke: #e6a23c;
    stroke-width: 1.5;
}

.context-menu {
    position: fixed;
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.12);
    padding: 4px 0;
    min-width: 140px;
    display: none;
    z-index: 1000;
}

.context-menu.show {
    display: block;
}

.menu-item {
    padding: 8px 16px;
    font-size: 13px;
    color: #606266;
    cursor: pointer;
    transition: all 0.15s;
}

.menu-item:hover {
    background: #f0f7ff;
    color: #409eff;
}

.menu-divider {
    height: 1px;
    background: #e4e7ed;
    margin: 4px 0;
}

.color-panel {
    position: fixed;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.12);
    padding: 8px;
    display: none;
    gap: 6px;
    z-index: 1000;
}

.color-panel.show {
    display: flex;
}

.color-item {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.15s;
    border: 2px solid transparent;
}

.color-item:hover {
    transform: scale(1.15);
    border-color: #303133;
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #f5f7fa;
}

::-webkit-scrollbar-thumb {
    background: #c0c4cc;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #909399;
}

body.dark-mode {
    background: #1a1a2e;
}

body.dark-mode .toolbar {
    background: #16213e;
    border-bottom-color: #0f3460;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

body.dark-mode .btn {
    background: #1a1a2e;
    border-color: #0f3460;
    color: #e0e0e0;
}

body.dark-mode .btn:hover {
    border-color: #409eff;
    color: #409eff;
}

body.dark-mode .btn-primary {
    background: #409eff;
    border-color: #409eff;
    color: #fff;
}

body.dark-mode .btn-success {
    background: #67c23a;
    border-color: #67c23a;
    color: #fff;
}

body.dark-mode .btn-danger {
    background: #f56c6c;
    border-color: #f56c6c;
    color: #fff;
}

body.dark-mode .sidebar {
    background: #16213e;
    border-right-color: #0f3460;
}

body.dark-mode .sidebar-header {
    background: #1a1a2e;
    border-bottom-color: #0f3460;
    color: #e0e0e0;
}

body.dark-mode .outline-item {
    color: #b0b0b0;
}

body.dark-mode .outline-item:hover {
    background: #1a1a2e;
}

body.dark-mode .outline-item.selected {
    background: #0f3460;
    color: #409eff;
}

body.dark-mode .canvas-wrapper {
    background: #1a1a2e;
    background-image: 
        radial-gradient(circle, #2a2a4a 1px, transparent 1px);
}

body.dark-mode .node {
    background: #16213e;
    border-color: #409eff;
    color: #e0e0e0;
}

body.dark-mode .node:hover {
    box-shadow: 0 4px 12px rgba(64, 158, 255, 0.3);
}

body.dark-mode .node.selected {
    box-shadow: 0 0 0 3px rgba(64, 158, 255, 0.5);
}

body.dark-mode .node.root {
    background: linear-gradient(135deg, #409eff 0%, #337ecc 100%);
    border-color: #337ecc;
    color: #fff;
}

body.dark-mode .node.level-1 {
    background: linear-gradient(135deg, #67c23a 0%, #529b2e 100%);
    border-color: #529b2e;
    color: #fff;
}

body.dark-mode .node.level-2 {
    background: linear-gradient(135deg, #e6a23c 0%, #c48a2c 100%);
    border-color: #c48a2c;
    color: #fff;
}

body.dark-mode .node.level-3 {
    background: linear-gradient(135deg, #909399 0%, #73767a 100%);
    border-color: #73767a;
    color: #fff;
}

body.dark-mode .add-btn {
    border-color: #1a1a2e;
}

body.dark-mode .context-menu {
    background: #16213e;
    box-shadow: 0 2px 12px rgba(0,0,0,0.4);
}

body.dark-mode .menu-item {
    color: #b0b0b0;
}

body.dark-mode .menu-item:hover {
    background: #1a1a2e;
    color: #409eff;
}

body.dark-mode .menu-divider {
    background: #0f3460;
}

body.dark-mode .color-panel {
    background: #16213e;
    box-shadow: 0 2px 12px rgba(0,0,0,0.4);
}

body.dark-mode .align-toggle {
    color: #b0b0b0;
}

body.dark-mode .zoom-level {
    color: #b0b0b0;
}

body.dark-mode ::-webkit-scrollbar-track {
    background: #1a1a2e;
}

body.dark-mode ::-webkit-scrollbar-thumb {
    background: #0f3460;
}

body.dark-mode ::-webkit-scrollbar-thumb:hover {
    background: #409eff;
}
