:root {
    --he-bg-color: #ffffff;
    --he-border-color: #ddd;
    --he-toolbar-bg: #fff;
    --he-btn-hover: #f5f5f5;
    --he-btn-active: #f2f2f2;
    --he-icon-color: #555;
    --he-toolbar-height: 42px;
}

/* 에디터 전체 컨테이너 */
.he-container {
    border: 1px solid var(--he-border-color);
    background: var(--he-bg-color);
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    margin-bottom: 10px;
    box-sizing: border-box;
}

.he-content {
    overflow-y: auto;
    /* min-height 로직 제거를 위해 height는 JS에서 인라인으로 제어 */
    outline: none;
    padding: 10px; /* 내부 여백 확보 */
}

/* 상단 툴바 */
.he-toolbar {
    background: var(--he-toolbar-bg);
    border-bottom: 1px solid var(--he-border-color);
    padding: 5px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}

/* 툴바 그룹 (구분선) */
.he-group {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-right: 8px;
    padding-right: 8px;
    border-right: 1px solid #eee;
}
.he-group:last-child {
    border-right: none;
}

/* 툴바 버튼 공통 */
.he-btn {
    width: 45px;
    height: 45px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--he-icon-color);
    transition: background 0.2s;
    font-size: 13px;
    padding: 0;
    white-space: nowrap;
}
.he-btn:hover {
    background: var(--he-btn-hover);
}
.he-btn.active {
    background: var(--he-btn-active);
    color: #000;
}
.he-btn img {
    display: block;
    pointer-events: none;
    width: 18px;
    height: 18px;
}
.he-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

/* 셀렉트 박스 (글자 크기 등) */
.he-select {
    height: 28px;
    border: 1px solid #ddd;
    border-radius: 3px;
    padding: 0 5px;
    font-size: 13px;
    outline: none;
    cursor: pointer;
    background: #fff;
    color: #333;
}

/* 소스보기 모드 (다크 테마) */
.he-source-view {
    display: none;
    width: 100%;
    box-sizing: border-box !important;
    padding: 20px !important;
    border: none !important;
    outline: none !important;
    resize: none !important;
    border-radius: 0px !important;
    
    line-height: 1.6;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace  !important;
    font-size: 14px;
    white-space: pre !important;
    overflow: auto;
    
    background: #1e1e1e !important;
    color: #d4d4d4 !important;
}

/* =========================================
   플로팅 툴바 (Core Feature)
   ========================================= */
.he-floating-toolbar {
    position: absolute;
    display: none;
    background: #333;
    border-radius: 5px;
    padding: 5px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 10000;
    gap: 5px;
    align-items: center;
    
    transform: none; /* 좌측 정렬을 위해 transform 제거됨 */
    
    white-space: nowrap;
}

/* 플로팅 툴바 화살표 */
.he-floating-toolbar::after {
    content: '';
    position: absolute;
    
    top: -10px; 
    bottom: auto;
    
    left: 15px; 
    margin-left: 0;
    
    border-width: 5px;
    border-style: solid;
    
    border-color: transparent transparent #333 transparent;
}

/* 플로팅 툴바 내부 버튼 (다크 모드 대응) */
.he-floating-toolbar .he-btn {
    width: 32px;
    height: 32px;
    color: #fff;
    border-radius: 3px;
}
.he-floating-toolbar .he-btn:hover {
    background: #555;
}
.he-floating-toolbar .he-btn.active {
    background: #007bff;
    color: #fff;
}
.he-floating-toolbar .he-btn img {
    filter: invert(1); /* 아이콘 흰색으로 반전 */
}

/* 플로팅 툴바 구분선 */
.he-floating-separator {
    width: 1px;
    height: 20px;
    background: #555;
    margin: 0 5px;
    display: inline-block;
}

/* 하단 리사이즈 핸들 바 */
.he-bottom-bar {
    height: 12px;
    background-color: #f8f9fa;
    border-top: 1px solid #ddd;
    cursor: ns-resize; /* 상하 리사이즈 커서 */
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
}

.he-bottom-bar:hover {
    background-color: #e9ecef;
}

/* 리사이즈 바 내부의 그립 아이콘 느낌 (두 줄) */
.he-resize-grip {
    width: 40px;
    height: 4px;
    border-top: 1px solid #ccc;
    border-bottom: 1px solid #ccc;
}

/* =========================================
   정렬 드롭다운 메뉴 (Align Dropdown)
   ========================================= */
.he-align-dropdown {
    position: absolute;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    padding: 5px;
    z-index: 10001;
    display: none;
    flex-direction: row; /* 가로로 버튼 나열 */
    gap: 4px;
}

.he-align-dropdown.open {
    display: flex;
}

.he-align-item {
    width: 32px;
    height: 32px;
    border: 1px solid transparent;
    background: transparent;
    border-radius: 3px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.he-align-item:hover {
    background-color: #f0f0f0;
}

.he-align-item img {
    width: 16px;
    height: 16px;
    pointer-events: none;
    display: block;
}